From 36df7cd26517948ba005fcae0d04238dbe0acefe Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Wed, 3 Jun 2026 12:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=85=E9=81=93bug#1616=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/dal/mysql/goods/GoodsMapper.java | 9 +++++ .../service/plan/PlanServiceImpl.java | 21 +++++++---- .../resources/mapper/goods/GoodsMapper.xml | 33 +++++++++++++++++ .../mapper/planitem/PlanItemMapper.xml | 35 ------------------- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java index aed433125..4238e81ea 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java @@ -215,4 +215,13 @@ public interface GoodsMapper extends BaseMapperX { * @return */ List selectPlateNumAndArea(@Param("orderGoodsIds") Collection orderGoodsIds, @Param("delete") Boolean delete); + + /** + * 根据板材id和订单id查询父订单id + * + * @param goodsId + * @param orderIds + * @return + */ + List getParentOrderIdsByGoodsIds(@Param("goodsIds") List goodsId, @Param("orderIds") List orderIds); } \ No newline at end of file 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 21808a6c5..b61eec1a4 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 @@ -58,6 +58,7 @@ import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper; import com.cf.imes.module.executor.enums.ErrorCodeConstants; import com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum; import com.cf.imes.module.executor.enums.OrderStatusEnum; +import com.cf.imes.module.executor.service.order.OrderService; import com.cf.imes.module.executor.util.elasticsearch.EsUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -132,6 +133,8 @@ public class PlanServiceImpl implements PlanService { @Resource private OrderComponentMapper orderComponentMapper; + @Resource + private OrderService orderService; // 重复使用的常量 private static final String FIELD_ORDER_ID = "o.id"; @@ -530,18 +533,22 @@ public class PlanServiceImpl implements PlanService { statusList.add(OrderStatusEnum.IN_PRODUCTION.getStatus()); statusList.add(OrderStatusEnum.SORTED.getStatus()); - List goodsId = Optional.ofNullable(pageReqVO.getGoodsIds()).orElse(new ArrayList<>()); + List goodsIds = Optional.ofNullable(pageReqVO.getGoodsIds()).orElse(new ArrayList<>()); List orderGoodsIds = new ArrayList<>(); // 查询类型:订单分组 int type = OrderPlanQueryTypeEnum.ORDER_GROUP.getType(); - if(CollUtil.isNotEmpty(goodsId)) { + if(CollUtil.isNotEmpty(goodsIds)) { + // 从订单材质查询订单id列表 + List goodsOrderId = + goodsMapper.getParentOrderIdsByGoodsIds( + goodsIds, + pageReqVO.getOrderIds()); - List orderIdList = Optional.ofNullable(pageReqVO.getOrderIds()).orElse(new ArrayList<>()); - - List goodsDOS = goodsMapper.selectListByGoodsId(orderIdList, goodsId, organId); - orderGoodsIds.addAll(goodsDOS.stream().map(GoodsDO::getId).toList()); - type = OrderPlanQueryTypeEnum.GOODS_GROUP.getType(); + if (CollUtil.isNotEmpty(goodsOrderId)) { + // 查询本身和父订单id + pageReqVO.setOrderIds(orderService.getFatherAndSonOrderIds(goodsOrderId)); + } } QueryWrapperX queryWrapperX = new QueryWrapperX<>(); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml index 615d9a065..aa6c3200a 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml @@ -589,4 +589,37 @@ GROUP BY op.goods_id + + + \ No newline at end of file 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 c2408cd8e..1af649301 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 @@ -28,11 +28,6 @@ o.area - o.planned_plate_area AS area, - - t.num, - t.area, - - o.parent_id AS parentId, o.order_type AS orderType, o.order_date AS orderDate, @@ -44,34 +39,6 @@ FROM orders o - - - JOIN ( - SELECT - og.order_id, - SUM(og.plate_num - og.planned_plate_num) AS num, - SUM(og.area - og.planned_plate_area) AS area - FROM order_goods og - - WHERE og.plate_num - og.planned_plate_num > 0 - - - AND og.id IN - - #{orderGoodsId} - - - - GROUP BY og.order_id - - ) t ON t.order_id = o.id - - - JOIN ( SELECT @@ -111,8 +78,6 @@ WHERE o.parent_id = 0 - AND IFNULL(o.plate_num,0) - IFNULL(o.planned_plate_num,0) > 0 - ORDER BY o.id DESC