新增/删除小板 排单板件/面积统计修正

This commit is contained in:
gaoqr
2026-06-04 20:22:43 +08:00
parent 57d8be5aa8
commit 05c6eea837
3 changed files with 28 additions and 16 deletions
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.LabelOrderPlateData; import com.cf.imes.module.executor.controller.admin.order.vo.order.LabelOrderPlateData;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlanPlateNumAndAreaRespVO;
import com.cf.imes.module.executor.controller.admin.plan.vo.*; import com.cf.imes.module.executor.controller.admin.plan.vo.*;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO; import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO;
@@ -105,4 +106,12 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
List<SavePlanPlateList.GoodsItemList> selectPlanGoodsList(@Param("planId") Long planId, @Param("organId") Long organId); List<SavePlanPlateList.GoodsItemList> selectPlanGoodsList(@Param("planId") Long planId, @Param("organId") Long organId);
/**
* 统计排单板件数量和面积
*
* @param planId
* @return
*/
OrderPlanPlateNumAndAreaRespVO selectPlanPlateNumAndArea(@Param("planId") Long planId);
} }
@@ -1438,6 +1438,13 @@ public class PlanServiceImpl implements PlanService {
} }
} }
OrderPlanPlateNumAndAreaRespVO planPlateNumAndAreaRespVO = planItemMapper.selectPlanPlateNumAndArea(planId);
// 更新排单板件数量和面积
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
.eq(PlanDO::getId, planId)
.set(PlanDO::getPlateNum, planPlateNumAndAreaRespVO.getNum())
.set(PlanDO::getPlateArea, planPlateNumAndAreaRespVO.getArea()));
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
computeOrderInfo(orderIds); computeOrderInfo(orderIds);
} }
@@ -1454,8 +1461,6 @@ 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));
@@ -1493,18 +1498,13 @@ public class PlanServiceImpl implements PlanService {
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) { OrderPlanPlateNumAndAreaRespVO planPlateNumAndAreaRespVO = planItemMapper.selectPlanPlateNumAndArea(planId);
// 更新排单板件数量和面积 // 更新排单板件数量和面积
planMapper.update(new LambdaUpdateWrapper<PlanDO>() planMapper.update(new LambdaUpdateWrapper<PlanDO>()
.eq(PlanDO::getId, planId) .eq(PlanDO::getId, planId)
.set(PlanDO::getPlateNum, plateNum) .set(PlanDO::getPlateNum, planPlateNumAndAreaRespVO.getNum())
.set(PlanDO::getPlateArea, area)); .set(PlanDO::getPlateArea, planPlateNumAndAreaRespVO.getArea()));
}
} }
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
@@ -2105,9 +2105,6 @@ public class PlanServiceImpl implements PlanService {
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_ORDER_UPDATE_CONCURRENCY_ERROR, orderId); throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_ORDER_UPDATE_CONCURRENCY_ERROR, orderId);
} }
} }
// if (1 == 1) {
// throw new ServiceException(null);
// }
} }
/** /**
@@ -569,5 +569,11 @@
</select> </select>
<select id="selectPlanPlateNumAndArea" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlanPlateNumAndAreaRespVO">
select count(op.id) as num, IFNULL(sum(op.area), 0) as area
from order_plate op
where op.plan_id = #{planId}
and op.deleted = false
</select>
</mapper> </mapper>