装配订单分页性能优化

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 * @param parentIds
* @return * @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); 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()))); orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
// 3. 查询子单 // 3. 查询子单
List<OrderDO> childList = List<Long> childIdList = orderMapper.selectChildIdList(pageReqVO, orderIds);
orderMapper.selectChildList(pageReqVO, orderIds); if (CollUtil.isEmpty(childIdList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
List<OrderDO> childList = orderMapper.selectByIds(childIdList);
if (CollUtil.isEmpty(childList)) { if (CollUtil.isEmpty(childList)) {
return new PageResult<>(orderDOS, pageResultTotal); return new PageResult<>(orderDOS, pageResultTotal);
} }
@@ -356,9 +356,12 @@ public class OrderServiceImpl implements OrderService {
orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId()))); orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
// 3. 查询子单 // 3. 查询子单
List<OrderDO> childList = List<Long> childIdList = orderMapper.selectChildIdList(pageReqVO, orderIds);
orderMapper.selectChildList(pageReqVO, orderIds); if (CollUtil.isEmpty(childIdList)) {
return new PageResult<>(orderDOS, pageResultTotal);
}
List<OrderDO> childList = orderMapper.selectByIds(childIdList);
if (CollUtil.isEmpty(childList)) { if (CollUtil.isEmpty(childList)) {
return new PageResult<>(orderDOS, pageResultTotal); return new PageResult<>(orderDOS, pageResultTotal);
} }
@@ -34,13 +34,10 @@
t.root_id t.root_id
FROM orders t FROM orders t
where 1=1
<if test="reqVO.assembly or reqVO.processStatus != null"> <if test="reqVO.assembly or reqVO.processStatus != null">
AND EXISTS ( JOIN order_component oc
SELECT 1 ON oc.organ_id = t.organ_id
FROM order_component oc AND oc.order_id = t.id
WHERE oc.order_id = t.id
AND oc.deleted = 0 AND oc.deleted = 0
AND oc.pid = 0 AND oc.pid = 0
<if test="reqVO.processStatus != null"> <if test="reqVO.processStatus != null">
@@ -60,8 +57,8 @@
</when> </when>
</choose> </choose>
</if> </if>
)
</if> </if>
where 1=1
<if test="reqVO.id != null and reqVO.id != ''"> <if test="reqVO.id != null and reqVO.id != ''">
AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%') AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%')
@@ -171,26 +168,16 @@
</select> </select>
<select id="selectChildList" <select id="selectChildIdList"
resultType="com.cf.imes.module.executor.dal.dataobject.order.OrderDO"> resultType="java.lang.Long">
SELECT * SELECT DISTINCT
t.id
FROM orders t FROM orders t
WHERE t.parent_id IN
<foreach collection="parentIds"
item="parentId"
open="("
separator=","
close=")">
#{parentId}
</foreach>
<if test="reqVO.assembly or reqVO.processStatus != null"> <if test="reqVO.assembly or reqVO.processStatus != null">
AND EXISTS ( JOIN order_component oc
SELECT 1 ON oc.organ_id = t.organ_id
FROM order_component oc AND oc.order_id = t.id
WHERE oc.order_id = t.id
AND oc.deleted = 0 AND oc.deleted = 0
AND oc.pid = 0 AND oc.pid = 0
<if test="reqVO.processStatus != null"> <if test="reqVO.processStatus != null">
@@ -210,8 +197,16 @@
</when> </when>
</choose> </choose>
</if> </if>
)
</if> </if>
WHERE t.parent_id IN
<foreach collection="parentIds"
item="parentId"
open="("
separator=","
close=")">
#{parentId}
</foreach>
<if test="reqVO.id != null and reqVO.id != ''"> <if test="reqVO.id != null and reqVO.id != ''">
AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%') AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%')