From a1f6f500d7c7ef572f031d418da9e7f2e0b3e35f Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Wed, 3 Jun 2026 19:18:55 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E6=8E=92=E5=8D=95?= =?UTF-8?q?=E9=9D=A2=E7=A7=AF=E5=B1=9E=E6=80=A7=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=8E=92=E5=8D=95=E3=80=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?/=E5=88=A0=E9=99=A4=E5=B0=8F=E6=9D=BF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=92=E5=8D=95=E6=9D=BF=E4=BB=B6=E6=95=B0=E5=92=8C=E9=9D=A2?= =?UTF-8?q?=E7=A7=AF=E5=90=8C=E6=AD=A5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/plan/vo/PlanRespVO.java | 3 + .../executor/dal/dataobject/plan/PlanDO.java | 6 ++ .../service/plan/PlanServiceImpl.java | 59 +++++++++++++++---- .../mapper/planitem/PlanItemMapper.xml | 4 +- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java index 4e9f592b0..6765aba3a 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java @@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -95,6 +96,8 @@ public class PlanRespVO { @Schema(description = "总小板片数") private Long plateNum; + @Schema(description = "总小板面积") + private BigDecimal area; @Schema(description = "未优化小板片数") private Long unOptimizePlateCount; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java index 432d66f29..9bd2c5014 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*; import com.cf.imes.framework.mybatis.core.dataobject.BaseDO; import lombok.*; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -122,6 +123,11 @@ public class PlanDO extends BaseDO { */ private Integer plateNum; + /** + * 板件面积 + */ + private BigDecimal area; + /** * 已排大板数 */ diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java index e18e76207..f22704713 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java @@ -1394,6 +1394,8 @@ public class PlanServiceImpl implements PlanService { for (Map.Entry> entry : groupedPlates.entrySet()) { Long orderGoodsId = entry.getKey(); List plates = entry.getValue(); + Integer plateNum = 0; + BigDecimal area = BigDecimal.ZERO; // 查询version GoodsDO goodsDO = goodsMapper.selectById(orderGoodsId); @@ -1412,15 +1414,27 @@ public class PlanServiceImpl implements PlanService { int version = goodsDO.getVersion(); // 统计每个order_goods下的未排单面积,更新到order_goods中 OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); + BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea(); + Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum(); int update = goodsMapper.update(new LambdaUpdateWrapper() .eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getVersion, version) - .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) - .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) + .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea) + .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum) .set(GoodsDO::getVersion, version + 1)); if (update == 0) { throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId); } + // 累计板件数量和面积 + plateNum += goodsPlateNumAndAreaPlanInfoNum; + area = area.add(goodsPlateNumAndAreaPlanInfoArea); + } + if (plateNum != 0) { + // 更新排单板件数量和面积 + planMapper.update(new LambdaUpdateWrapper() + .eq(PlanDO::getId, planId) + .set(PlanDO::getPlateNum, plateNum) + .set(PlanDO::getArea, area)); } } @@ -1440,6 +1454,8 @@ public class PlanServiceImpl implements PlanService { for (Map.Entry> entry : groupedPlates.entrySet()) { Long planId = entry.getKey(); List plates = entry.getValue(); + Integer plateNum = 0; + BigDecimal area = BigDecimal.ZERO; // 根据goodsId分组 Map> groupedPlatesByGoodsId = plates.stream().collect(Collectors.groupingBy(PlateDO::getGoodsId)); @@ -1466,16 +1482,29 @@ public class PlanServiceImpl implements PlanService { int version = goodsDO.getVersion(); // 统计每个order_goods下的未排单面积,更新到order_goods中 OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); + BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea(); + Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum(); int update = goodsMapper.update(new LambdaUpdateWrapper() .eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getVersion, version) - .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) - .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) + .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea) + .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum) .set(GoodsDO::getVersion, version + 1)); if (update == 0) { throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId); } + // 累计板件数量和面积 + plateNum += goodsPlateNumAndAreaPlanInfoNum; + area = area.add(goodsPlateNumAndAreaPlanInfoArea); } + if (plateNum != 0) { + // 更新排单板件数量和面积 + planMapper.update(new LambdaUpdateWrapper() + .eq(PlanDO::getId, planId) + .set(PlanDO::getPlateNum, plateNum) + .set(PlanDO::getArea, area)); + } + } // 统计更新orders的小板数量和面积 @@ -1899,7 +1928,7 @@ public class PlanServiceImpl implements PlanService { String goodsId = f.getPlanActualGoodsModelDO().getGoodsId(); // 创建排单 - planDOS.add(PlanDO.builder() + PlanDO planDO = PlanDO.builder() .id(planId) .sort(++sort) .type(PlanTypeEnum.MIXEDORDERPLAN.getType()) @@ -1912,10 +1941,11 @@ public class PlanServiceImpl implements PlanService { .planTime(LocalDateTime.now()) .goodsId(goodsId) .plateNum(planPlateNum) - .build()); + .build(); // 更新板件排单id & 统计更新order_goods的数量和面积 - computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap); + planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap)); + planDOS.add(planDO); } // 统计更新orders的小板数量和面积 @@ -1970,7 +2000,7 @@ public class PlanServiceImpl implements PlanService { Long planId = (Long) identifierGenerator.nextId(null); // 创建排单 - planDOS.add(PlanDO.builder() + PlanDO planDO = PlanDO.builder() .id(planId) .sort(++sort) .type(planType) @@ -1982,10 +2012,11 @@ public class PlanServiceImpl implements PlanService { .operator(loginUser.getNickname()) .planTime(LocalDateTime.now()) .plateNum(planPlateNum) - .build()); + .build(); // 更新板件排单id & 统计更新order_goods的数量和面积 - computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap); + planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap)); + planDOS.add(planDO); } // 统计更新orders的小板数量和面积 computeOrderInfo(orderIdSet); @@ -1997,7 +2028,8 @@ public class PlanServiceImpl implements PlanService { * @param planId * @param goodsPlateIdMap */ - public void computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map> goodsPlateIdMap) { + public BigDecimal computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map> goodsPlateIdMap) { + BigDecimal planArea = BigDecimal.ZERO; for (Map.Entry> entry : goodsPlateIdMap.entrySet()) { Long orderGoodsId = entry.getKey(); // 查询version @@ -2018,16 +2050,19 @@ public class PlanServiceImpl implements PlanService { int version = goodsDO.getVersion(); // 统计每个order_goods下的未排单面积,更新到order_goods中 OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); + BigDecimal plannedArea = goodsPlateNumAndAreaPlanInfo.getArea(); int update = goodsMapper.update(new LambdaUpdateWrapper() .eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getVersion, version) - .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) + .set(GoodsDO::getPlannedPlateArea, plannedArea) .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) .set(GoodsDO::getVersion, version + 1)); if (update == 0) { throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, orderGoodsId); } + planArea = planArea.add(plannedArea); } + return planArea; } /** diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/planitem/PlanItemMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/planitem/PlanItemMapper.xml index 5f3653f2c..151f53565 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/planitem/PlanItemMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/planitem/PlanItemMapper.xml @@ -239,6 +239,7 @@ + @@ -299,7 +300,8 @@ og.thickness as thickness, og.brand as brand, og.texture as texture, - sum(og.plate_num - og.planned_plate_num) as num + sum(og.plate_num - og.planned_plate_num) as num, + sum(og.area - og.planned_plate_area) as area from orders o join order_goods og on o.id = og.order_id and og.organ_id = #{organId}