1、新增排单面积属性;2、创建排单、新增/删除小板修改排单板件数和面积同步;

This commit is contained in:
gaoqr
2026-06-03 19:18:55 +08:00
parent 41ecfc56de
commit a1f6f500d7
4 changed files with 59 additions and 13 deletions
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@@ -95,6 +96,8 @@ public class PlanRespVO {
@Schema(description = "总小板片数") @Schema(description = "总小板片数")
private Long plateNum; private Long plateNum;
@Schema(description = "总小板面积")
private BigDecimal area;
@Schema(description = "未优化小板片数") @Schema(description = "未优化小板片数")
private Long unOptimizePlateCount; private Long unOptimizePlateCount;
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO; import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
@@ -122,6 +123,11 @@ public class PlanDO extends BaseDO {
*/ */
private Integer plateNum; private Integer plateNum;
/**
* 板件面积
*/
private BigDecimal area;
/** /**
* 已排大板数 * 已排大板数
*/ */
@@ -1394,6 +1394,8 @@ public class PlanServiceImpl implements PlanService {
for (Map.Entry<Long, List<OrderPlateIds>> entry : groupedPlates.entrySet()) { for (Map.Entry<Long, List<OrderPlateIds>> entry : groupedPlates.entrySet()) {
Long orderGoodsId = entry.getKey(); Long orderGoodsId = entry.getKey();
List<OrderPlateIds> plates = entry.getValue(); List<OrderPlateIds> plates = entry.getValue();
Integer plateNum = 0;
BigDecimal area = BigDecimal.ZERO;
// 查询version // 查询version
GoodsDO goodsDO = goodsMapper.selectById(orderGoodsId); GoodsDO goodsDO = goodsMapper.selectById(orderGoodsId);
@@ -1412,15 +1414,27 @@ public class PlanServiceImpl implements PlanService {
int version = goodsDO.getVersion(); int version = goodsDO.getVersion();
// 统计每个order_goods下的未排单面积,更新到order_goods中 // 统计每个order_goods下的未排单面积,更新到order_goods中
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea();
Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum();
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>() int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
.eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getId, orderGoodsId)
.eq(GoodsDO::getVersion, version) .eq(GoodsDO::getVersion, version)
.set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea)
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum)
.set(GoodsDO::getVersion, version + 1)); .set(GoodsDO::getVersion, version + 1));
if (update == 0) { if (update == 0) {
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId); throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
} }
// 累计板件数量和面积
plateNum += goodsPlateNumAndAreaPlanInfoNum;
area = area.add(goodsPlateNumAndAreaPlanInfoArea);
}
if (plateNum != 0) {
// 更新排单板件数量和面积
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
.eq(PlanDO::getId, planId)
.set(PlanDO::getPlateNum, plateNum)
.set(PlanDO::getArea, area));
} }
} }
@@ -1440,6 +1454,8 @@ public class PlanServiceImpl implements PlanService {
for (Map.Entry<Long, List<PlateDO>> entry : groupedPlates.entrySet()) { for (Map.Entry<Long, List<PlateDO>> entry : groupedPlates.entrySet()) {
Long planId = entry.getKey(); Long planId = entry.getKey();
List<PlateDO> plates = entry.getValue(); List<PlateDO> plates = entry.getValue();
Integer plateNum = 0;
BigDecimal area = BigDecimal.ZERO;
// 根据goodsId分组 // 根据goodsId分组
Map<Long, List<PlateDO>> groupedPlatesByGoodsId = plates.stream().collect(Collectors.groupingBy(PlateDO::getGoodsId)); Map<Long, List<PlateDO>> groupedPlatesByGoodsId = plates.stream().collect(Collectors.groupingBy(PlateDO::getGoodsId));
@@ -1466,16 +1482,29 @@ public class PlanServiceImpl implements PlanService {
int version = goodsDO.getVersion(); int version = goodsDO.getVersion();
// 统计每个order_goods下的未排单面积,更新到order_goods中 // 统计每个order_goods下的未排单面积,更新到order_goods中
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea();
Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum();
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>() int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
.eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getId, orderGoodsId)
.eq(GoodsDO::getVersion, version) .eq(GoodsDO::getVersion, version)
.set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea)
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum)
.set(GoodsDO::getVersion, version + 1)); .set(GoodsDO::getVersion, version + 1));
if (update == 0) { if (update == 0) {
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId); throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
} }
// 累计板件数量和面积
plateNum += goodsPlateNumAndAreaPlanInfoNum;
area = area.add(goodsPlateNumAndAreaPlanInfoArea);
} }
if (plateNum != 0) {
// 更新排单板件数量和面积
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
.eq(PlanDO::getId, planId)
.set(PlanDO::getPlateNum, plateNum)
.set(PlanDO::getArea, area));
}
} }
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
@@ -1899,7 +1928,7 @@ public class PlanServiceImpl implements PlanService {
String goodsId = f.getPlanActualGoodsModelDO().getGoodsId(); String goodsId = f.getPlanActualGoodsModelDO().getGoodsId();
// 创建排单 // 创建排单
planDOS.add(PlanDO.builder() PlanDO planDO = PlanDO.builder()
.id(planId) .id(planId)
.sort(++sort) .sort(++sort)
.type(PlanTypeEnum.MIXEDORDERPLAN.getType()) .type(PlanTypeEnum.MIXEDORDERPLAN.getType())
@@ -1912,10 +1941,11 @@ public class PlanServiceImpl implements PlanService {
.planTime(LocalDateTime.now()) .planTime(LocalDateTime.now())
.goodsId(goodsId) .goodsId(goodsId)
.plateNum(planPlateNum) .plateNum(planPlateNum)
.build()); .build();
// 更新板件排单id & 统计更新order_goods的数量和面积 // 更新板件排单id & 统计更新order_goods的数量和面积
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap); planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap));
planDOS.add(planDO);
} }
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
@@ -1970,7 +2000,7 @@ public class PlanServiceImpl implements PlanService {
Long planId = (Long) identifierGenerator.nextId(null); Long planId = (Long) identifierGenerator.nextId(null);
// 创建排单 // 创建排单
planDOS.add(PlanDO.builder() PlanDO planDO = PlanDO.builder()
.id(planId) .id(planId)
.sort(++sort) .sort(++sort)
.type(planType) .type(planType)
@@ -1982,10 +2012,11 @@ public class PlanServiceImpl implements PlanService {
.operator(loginUser.getNickname()) .operator(loginUser.getNickname())
.planTime(LocalDateTime.now()) .planTime(LocalDateTime.now())
.plateNum(planPlateNum) .plateNum(planPlateNum)
.build()); .build();
// 更新板件排单id & 统计更新order_goods的数量和面积 // 更新板件排单id & 统计更新order_goods的数量和面积
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap); planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap));
planDOS.add(planDO);
} }
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
computeOrderInfo(orderIdSet); computeOrderInfo(orderIdSet);
@@ -1997,7 +2028,8 @@ public class PlanServiceImpl implements PlanService {
* @param planId * @param planId
* @param goodsPlateIdMap * @param goodsPlateIdMap
*/ */
public void computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) { public BigDecimal computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) {
BigDecimal planArea = BigDecimal.ZERO;
for (Map.Entry<Long, List<Long>> entry : goodsPlateIdMap.entrySet()) { for (Map.Entry<Long, List<Long>> entry : goodsPlateIdMap.entrySet()) {
Long orderGoodsId = entry.getKey(); Long orderGoodsId = entry.getKey();
// 查询version // 查询version
@@ -2018,16 +2050,19 @@ public class PlanServiceImpl implements PlanService {
int version = goodsDO.getVersion(); int version = goodsDO.getVersion();
// 统计每个order_goods下的未排单面积,更新到order_goods中 // 统计每个order_goods下的未排单面积,更新到order_goods中
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId); OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
BigDecimal plannedArea = goodsPlateNumAndAreaPlanInfo.getArea();
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>() int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
.eq(GoodsDO::getId, orderGoodsId) .eq(GoodsDO::getId, orderGoodsId)
.eq(GoodsDO::getVersion, version) .eq(GoodsDO::getVersion, version)
.set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea()) .set(GoodsDO::getPlannedPlateArea, plannedArea)
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum()) .set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum())
.set(GoodsDO::getVersion, version + 1)); .set(GoodsDO::getVersion, version + 1));
if (update == 0) { if (update == 0) {
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, orderGoodsId); throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
} }
planArea = planArea.add(plannedArea);
} }
return planArea;
} }
/** /**
@@ -239,6 +239,7 @@
<result property="thickness" column="thickness"/> <result property="thickness" column="thickness"/>
<result property="brand" column="brand"/> <result property="brand" column="brand"/>
<result property="num" column="num"/> <result property="num" column="num"/>
<result property="area" column="area"/>
<collection property="orderIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds" resultMap="orderIdsMap"/> <collection property="orderIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds" resultMap="orderIdsMap"/>
@@ -299,7 +300,8 @@
og.thickness as thickness, og.thickness as thickness,
og.brand as brand, og.brand as brand,
og.texture as texture, 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 from orders o
join order_goods og on o.id = og.order_id and og.organ_id = #{organId} join order_goods og on o.id = og.order_id and og.organ_id = #{organId}