装配订单分页性能优化

This commit is contained in:
gaoqr
2026-07-03 16:19:04 +08:00
parent d4f3692ea4
commit e9dbf203f1
4 changed files with 43 additions and 42 deletions
@@ -143,7 +143,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
* @param parentIds
* @return
*/
List<OrderDO> selectChildList(@Param("reqVO") OrderPageReqVO reqVO, @Param("parentIds") List<Long> parentIds);
List<Long> selectChildIdList(@Param("reqVO") OrderPageReqVO reqVO, @Param("parentIds") List<Long> parentIds);
IPage<OrderRespVOCopy> selectOrderPage(@Param("page") IPage<OrderRespVOCopy> page, @Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper);
@@ -108,9 +108,12 @@ public class AssemblyListServiceImpl implements AssemblyListService {
orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
// 3. 查询子单
List<OrderDO> childList =
orderMapper.selectChildList(pageReqVO, orderIds);
List<Long> childIdList = orderMapper.selectChildIdList(pageReqVO, orderIds);
if (CollUtil.isEmpty(childIdList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
List<OrderDO> childList = orderMapper.selectByIds(childIdList);
if (CollUtil.isEmpty(childList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
@@ -356,9 +356,12 @@ public class OrderServiceImpl implements OrderService {
orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
// 3. 查询子单
List<OrderDO> childList =
orderMapper.selectChildList(pageReqVO, orderIds);
List<Long> childIdList = orderMapper.selectChildIdList(pageReqVO, orderIds);
if (CollUtil.isEmpty(childIdList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
List<OrderDO> childList = orderMapper.selectByIds(childIdList);
if (CollUtil.isEmpty(childList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
@@ -34,13 +34,10 @@
t.root_id
FROM orders t
where 1=1
<if test="reqVO.assembly or reqVO.processStatus != null">
AND EXISTS (
SELECT 1
FROM order_component oc
WHERE oc.order_id = t.id
JOIN order_component oc
ON oc.organ_id = t.organ_id
AND oc.order_id = t.id
AND oc.deleted = 0
AND oc.pid = 0
<if test="reqVO.processStatus != null">
@@ -60,8 +57,8 @@
</when>
</choose>
</if>
)
</if>
where 1=1
<if test="reqVO.id != null and reqVO.id != ''">
AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%')
@@ -171,11 +168,36 @@
</select>
<select id="selectChildList"
resultType="com.cf.imes.module.executor.dal.dataobject.order.OrderDO">
<select id="selectChildIdList"
resultType="java.lang.Long">
SELECT *
SELECT DISTINCT
t.id
FROM orders t
<if test="reqVO.assembly or reqVO.processStatus != null">
JOIN order_component oc
ON oc.organ_id = t.organ_id
AND oc.order_id = t.id
AND oc.deleted = 0
AND oc.pid = 0
<if test="reqVO.processStatus != null">
<choose>
<when test="reqVO.processStatus == 0">
AND oc.extra_process_status = 0
</when>
<when test="reqVO.processStatus == 1">
AND oc.process_status = 1
AND (oc.extra_process_status IS NULL OR oc.extra_process_status != 0)
</when>
<when test="reqVO.processStatus == 2">
AND oc.process_status = 2
</when>
<when test="reqVO.processStatus == 3">
AND oc.extra_process_status = 3
</when>
</choose>
</if>
</if>
WHERE t.parent_id IN
<foreach collection="parentIds"
@@ -186,33 +208,6 @@
#{parentId}
</foreach>
<if test="reqVO.assembly or reqVO.processStatus != null">
AND EXISTS (
SELECT 1
FROM order_component oc
WHERE oc.order_id = t.id
AND oc.deleted = 0
AND oc.pid = 0
<if test="reqVO.processStatus != null">
<choose>
<when test="reqVO.processStatus == 0">
AND oc.extra_process_status = 0
</when>
<when test="reqVO.processStatus == 1">
AND oc.process_status = 1
AND (oc.extra_process_status IS NULL OR oc.extra_process_status != 0)
</when>
<when test="reqVO.processStatus == 2">
AND oc.process_status = 2
</when>
<when test="reqVO.processStatus == 3">
AND oc.extra_process_status = 3
</when>
</choose>
</if>
)
</if>
<if test="reqVO.id != null and reqVO.id != ''">
AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%')
</if>