mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
未排单订单分组维度数据修正
This commit is contained in:
+12
-2
@@ -29,14 +29,24 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
|
||||
* @param wrapper
|
||||
* @param type
|
||||
* @param orderGoodsIds 商品id列表
|
||||
* @param orderIds 父级订单数组
|
||||
* @param rootIds 父级订单数组
|
||||
* @return
|
||||
*/
|
||||
IPage<OrderRespVOCopy> selectOrderList(@Param("page") IPage<OrderRespVOCopy> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper,
|
||||
@Param("type") int type,
|
||||
@Param("orderGoodsIds") List<Long> orderGoodsIds,
|
||||
@Param("orderIds") Long... orderIds);
|
||||
@Param("rootIds") List<Long> rootIds);
|
||||
|
||||
/**
|
||||
* 未排单顶级订单id列表
|
||||
*
|
||||
* @param page
|
||||
* @param wrapper
|
||||
* @return
|
||||
*/
|
||||
IPage<Long> selectRootOrderIdList(@Param("page") IPage<OrderRespVOCopy> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper);
|
||||
|
||||
/**
|
||||
* 未排单子单查询
|
||||
|
||||
+10
-10
@@ -539,16 +539,11 @@ public class PlanServiceImpl implements PlanService {
|
||||
// 查询类型:订单分组
|
||||
int type = OrderPlanQueryTypeEnum.ORDER_GROUP.getType();
|
||||
if(CollUtil.isNotEmpty(goodsIds)) {
|
||||
// 从订单材质查询订单id列表
|
||||
List<Long> goodsOrderId =
|
||||
goodsMapper.getParentOrderIdsByGoodsIds(
|
||||
goodsIds,
|
||||
pageReqVO.getOrderIds());
|
||||
List<Long> orderIdList = Optional.ofNullable(pageReqVO.getOrderIds()).orElse(new ArrayList<>());
|
||||
|
||||
if (CollUtil.isNotEmpty(goodsOrderId)) {
|
||||
// 查询本身和父订单id
|
||||
pageReqVO.setOrderIds(orderService.getFatherAndSonOrderIds(goodsOrderId));
|
||||
}
|
||||
List<GoodsDO> goodsDOS = goodsMapper.selectListByGoodsId(orderIdList, goodsIds, organId);
|
||||
orderGoodsIds.addAll(goodsDOS.stream().map(GoodsDO::getId).toList());
|
||||
type = OrderPlanQueryTypeEnum.GOODS_GROUP.getType();
|
||||
}
|
||||
|
||||
QueryWrapperX<OrderDO> queryWrapperX = new QueryWrapperX<>();
|
||||
@@ -564,7 +559,12 @@ public class PlanServiceImpl implements PlanService {
|
||||
.likeIfPresent(FIELD_ADDRESS, pageReqVO.getConsigneeAddress())
|
||||
.betweenIfPresent(FIELD_ORDER_DATE, LocalDateTimeUtils.generateTimeSection(pageReqVO.getCreateTime()));
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<OrderRespVOCopy> orderList = planItemMapper.selectOrderList(page, queryWrapperX, type, orderGoodsIds);
|
||||
|
||||
// 查询满足未排单条件的顶级订单id
|
||||
IPage<Long> rootOrderIdList = planItemMapper.selectRootOrderIdList(page, queryWrapperX);
|
||||
// 查询顶级列表的信息
|
||||
IPage<OrderRespVOCopy> orderList = planItemMapper.selectOrderList(page, queryWrapperX, type, orderGoodsIds, rootOrderIdList.getRecords());
|
||||
|
||||
List<OrderRespVOCopy> mainOrderList = orderList.getRecords();
|
||||
long total = orderList.getTotal();
|
||||
|
||||
|
||||
+48
-36
@@ -19,7 +19,6 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="selectOrderList" resultMap="OrderPageMap">
|
||||
|
||||
SELECT
|
||||
o.id AS orderId,
|
||||
|
||||
@@ -28,6 +27,11 @@
|
||||
o.area - o.planned_plate_area AS area,
|
||||
</if>
|
||||
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
t.num,
|
||||
t.area,
|
||||
</if>
|
||||
|
||||
o.parent_id AS parentId,
|
||||
o.order_type AS orderType,
|
||||
o.order_date AS orderDate,
|
||||
@@ -39,46 +43,54 @@
|
||||
|
||||
FROM orders o
|
||||
|
||||
JOIN (
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
LEFT 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
|
||||
|
||||
SELECT
|
||||
root_id
|
||||
FROM (
|
||||
<if test="orderGoodsIds != null and orderGoodsIds.size() > 0">
|
||||
AND og.id IN
|
||||
<foreach item="orderGoodsId"
|
||||
collection="orderGoodsIds"
|
||||
open="("
|
||||
separator=","
|
||||
close=")">
|
||||
#{orderGoodsId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
SELECT
|
||||
IF(x.parent_id = 0, x.id, x.parent_id) AS root_id
|
||||
GROUP BY og.order_id
|
||||
) t ON t.order_id = o.id
|
||||
</if>
|
||||
|
||||
FROM orders x
|
||||
|
||||
<choose>
|
||||
|
||||
<when test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
|
||||
${ew.customSqlSegment.replace('o.', 'x.')}
|
||||
|
||||
AND IFNULL(x.plate_num,0) - IFNULL(x.planned_plate_num,0) > 0
|
||||
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
|
||||
WHERE IFNULL(x.plate_num,0) - IFNULL(x.planned_plate_num,0) > 0
|
||||
|
||||
</otherwise>
|
||||
|
||||
</choose>
|
||||
|
||||
) tmp
|
||||
|
||||
GROUP BY root_id
|
||||
|
||||
) root_order
|
||||
|
||||
ON root_order.root_id = o.id
|
||||
|
||||
WHERE o.parent_id = 0
|
||||
WHERE 1 = 1
|
||||
<if test="rootIds != null and rootIds.size() > 0">
|
||||
AND o.id IN
|
||||
<foreach item="rootId"
|
||||
collection="rootIds"
|
||||
open="("
|
||||
separator=","
|
||||
close=")">
|
||||
#{rootId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
ORDER BY o.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectRootOrderIdList" resultType="java.lang.Long">
|
||||
|
||||
SELECT o.root_id
|
||||
FROM orders o
|
||||
${ew.customSqlSegment}
|
||||
AND o.deleted = false
|
||||
AND IFNULL(o.plate_num,0) - IFNULL(o.planned_plate_num,0) > 0
|
||||
GROUP BY o.root_id
|
||||
ORDER BY o.root_id DESC
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user