1、删除柜体导致的order_goods数量错误修复;2、排单统计小板数量和面积错误修复;3、订单分组按房间柜体获取材质时缺少面积修复;

This commit is contained in:
gaoqr
2026-06-10 17:43:24 +08:00
parent 2623e680d0
commit 90d5284486
3 changed files with 58 additions and 49 deletions
@@ -1572,7 +1572,7 @@ public class OrderServiceImpl implements OrderService {
goodsMapper.updateDeletedById(orderId, goodsIdDeleted, organId); goodsMapper.updateDeletedById(orderId, goodsIdDeleted, organId);
} }
return goodsIdDeleted; return goodsIds.stream().toList();
} }
@@ -201,7 +201,16 @@ public class PlanServiceImpl implements PlanService {
createPlanAndPlateDataList(grouped, plateItemList, planDOS, processId, processName, loginUser, PlanTypeEnum.ORDERPLAN.getType()); createPlanAndPlateDataList(grouped, plateItemList, planDOS, processId, processName, loginUser, PlanTypeEnum.ORDERPLAN.getType());
} }
// 计算排单的数量和面积
if (CollUtil.isNotEmpty(planDOS)) {
for (PlanDO planDO : planDOS) {
OrderPlanPlateNumAndAreaRespVO orderPlanPlateNumAndAreaRespVO = planItemMapper.selectPlanPlateNumAndArea(planDO.getId());
if (ObjectUtil.isNotNull(orderPlanPlateNumAndAreaRespVO)) {
planDO.setPlateNum(orderPlanPlateNumAndAreaRespVO.getNum());
planDO.setPlateArea(orderPlanPlateNumAndAreaRespVO.getArea());
}
}
}
// 增加排单 // 增加排单
planMapper.insertBatch(planDOS); planMapper.insertBatch(planDOS);
} }
@@ -1360,8 +1369,6 @@ 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);
@@ -1391,16 +1398,6 @@ 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) {
// 更新排单板件数量和面积
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
.eq(PlanDO::getId, planId)
.set(PlanDO::getPlateNum, plateNum)
.set(PlanDO::getPlateArea, area));
} }
} }
@@ -1836,7 +1833,7 @@ public class PlanServiceImpl implements PlanService {
.build(); .build();
// 更新板件排单id & 统计更新order_goods的数量和面积 // 更新板件排单id & 统计更新order_goods的数量和面积
planDO.setPlateArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap)); computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
planDOS.add(planDO); planDOS.add(planDO);
} }
@@ -1907,7 +1904,7 @@ public class PlanServiceImpl implements PlanService {
.build(); .build();
// 更新板件排单id & 统计更新order_goods的数量和面积 // 更新板件排单id & 统计更新order_goods的数量和面积
planDO.setPlateArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap)); computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
planDOS.add(planDO); planDOS.add(planDO);
} }
// 统计更新orders的小板数量和面积 // 统计更新orders的小板数量和面积
@@ -1920,8 +1917,7 @@ public class PlanServiceImpl implements PlanService {
* @param planId * @param planId
* @param goodsPlateIdMap * @param goodsPlateIdMap
*/ */
public BigDecimal computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) { public void 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
@@ -1942,19 +1938,16 @@ 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, plannedArea) .set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea())
.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;
} }
/** /**
@@ -271,37 +271,53 @@
<select id="selectNoPlanGoodsByRoomAndBodyIds" resultMap="OrderGoodsMap" parameterType="java.lang.Long"> <select id="selectNoPlanGoodsByRoomAndBodyIds" resultMap="OrderGoodsMap" parameterType="java.lang.Long">
select SELECT
t.color,
t.goodsName,
t.material,
t.thickness,
t.brand,
t.texture,
COUNT(*) AS num,
SUM(t.area) AS area
FROM (
SELECT DISTINCT
op.id,
op.area,
og.color, og.color,
og.goods_name as goodsName, og.goods_name AS goodsName,
og.material,
og.thickness,
og.brand,
og.texture,
count(distinct op.id) as num
from order_plate op
join order_goods og
on og.id = op.goods_id
and og.order_id = op.order_id
and og.organ_id = op.organ_id
join order_item oi
on oi.plate_id = op.id
and oi.order_id = op.order_id
and oi.organ_id = op.organ_id
and oi.source_id = 0
${ew.customSqlSegment}
and op.plan_id = 0
group by
og.color,
og.goods_name,
og.material, og.material,
og.thickness, og.thickness,
og.brand, og.brand,
og.texture og.texture
FROM order_plate op
JOIN order_goods og
ON og.id = op.goods_id
AND og.order_id = op.order_id
AND og.organ_id = op.organ_id
JOIN order_item oi
ON oi.plate_id = op.id
AND oi.order_id = op.order_id
AND oi.organ_id = op.organ_id
AND oi.source_id = 0
${ew.customSqlSegment}
AND op.plan_id = 0
) t
GROUP BY
t.color,
t.goodsName,
t.material,
t.thickness,
t.brand,
t.texture
ORDER BY t.thickness DESC
</select> </select>