mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、getOrderSource异常修复;2、未排单 - 订单分页查询sql优化;
This commit is contained in:
+3
-1
@@ -27,12 +27,14 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
|
||||
* @param page
|
||||
* @param wrapper
|
||||
* @param type
|
||||
* @param orderIds 父级订单数组
|
||||
* @param orderGoodsIds 商品id列表
|
||||
* @param orderIds 父级订单数组
|
||||
* @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);
|
||||
|
||||
List<PlateDetailRespVO> selectPlanPlateDetailList(@Param("planId") Long planId, @Param("organId") Long organId);
|
||||
|
||||
+10
-10
@@ -130,6 +130,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
|
||||
// 重复使用的常量
|
||||
private static final String FIELD_ORDER_ID = "o.id";
|
||||
private static final String FIELD_OP_IS_SPECIAL_SHAPED = "op.is_special_shaped";
|
||||
private static final String FIELD_PLANID = "planId";
|
||||
private static final String FIELD_ORGAN_ID = "o.organ_id";
|
||||
@@ -561,7 +562,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
List<String> goodsId = Optional.ofNullable(pageReqVO.getGoodsIds()).orElse(new ArrayList<>());
|
||||
|
||||
List<Long> ids = new ArrayList<>();
|
||||
List<Long> orderGoodsIds = new ArrayList<>();
|
||||
// 查询类型:订单分组
|
||||
int type = OrderPlanQueryTypeEnum.ORDER_GROUP.getType();
|
||||
if(CollUtil.isNotEmpty(goodsId)) {
|
||||
@@ -569,7 +570,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
List<Long> orderIdList = Optional.ofNullable(pageReqVO.getOrderIds()).orElse(new ArrayList<>());
|
||||
|
||||
List<GoodsDO> goodsDOS = goodsMapper.selectListByGoodsId(orderIdList, goodsId, organId);
|
||||
ids.addAll(goodsDOS.stream().map(GoodsDO::getId).toList());
|
||||
orderGoodsIds.addAll(goodsDOS.stream().map(GoodsDO::getId).toList());
|
||||
type = OrderPlanQueryTypeEnum.GOODS_GROUP.getType();
|
||||
}
|
||||
|
||||
@@ -579,24 +580,23 @@ public class PlanServiceImpl implements PlanService {
|
||||
.eq(FIELD_DELETED, false)
|
||||
.in(FIELD_STATUS, statusList)
|
||||
|
||||
.inIfPresent("og.id", ids)
|
||||
.inIfPresent("o.id", pageReqVO.getOrderIds())
|
||||
.likeIfPresent("o.id", pageReqVO.getOrderId() != null ? pageReqVO.getOrderId() : null)
|
||||
.inIfPresent(FIELD_ORDER_ID, pageReqVO.getOrderIds())
|
||||
.likeIfPresent(FIELD_ORDER_ID, pageReqVO.getOrderId() != null ? pageReqVO.getOrderId() : null)
|
||||
.likeIfPresent(FIELD_CUSTOMER, pageReqVO.getConsignee())
|
||||
.likeIfPresent(FIELD_CUSTOM_ORDER_NO, pageReqVO.getDefaultId())
|
||||
.likeIfPresent(FIELD_ADDRESS, pageReqVO.getConsigneeAddress())
|
||||
.betweenIfPresent(FIELD_ORDER_DATE, pageReqVO.getCreateTime());
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<OrderRespVOCopy> orderList = planItemMapper.selectOrderList(page, queryWrapperX, type);
|
||||
IPage<OrderRespVOCopy> orderList = planItemMapper.selectOrderList(page, queryWrapperX, type, orderGoodsIds);
|
||||
List<OrderRespVOCopy> mainOrderList = orderList.getRecords();
|
||||
long total = orderList.getTotal();
|
||||
|
||||
// 订单分组查询子单
|
||||
if (ObjectUtil.equals(OrderPlanQueryTypeEnum.ORDER_GROUP.getType(), type) && CollUtil.isNotEmpty(mainOrderList)) {
|
||||
if (CollUtil.isNotEmpty(mainOrderList)) {
|
||||
// 主单id列表
|
||||
Long[] mainOrderIds = mainOrderList.stream().map(OrderRespVOCopy::getOrderId).toArray(Long[]::new);
|
||||
PageDTO<OrderRespVOCopy> childPage = new PageDTO<>(pageReqVO.getPageNo(), PageParam.PAGE_SIZE_NONE);
|
||||
IPage<OrderRespVOCopy> childOrderList = planItemMapper.selectOrderList(childPage, queryWrapperX, type, mainOrderIds);
|
||||
IPage<OrderRespVOCopy> childOrderList = planItemMapper.selectOrderList(childPage, queryWrapperX, type, orderGoodsIds, mainOrderIds);
|
||||
|
||||
List<OrderRespVOCopy> childList = childOrderList.getRecords();
|
||||
|
||||
@@ -647,8 +647,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
queryWrapperX
|
||||
.eq(FIELD_DELETED, false)
|
||||
.in(FIELD_STATUS, statusList)
|
||||
.inIfPresent("o.id", pageReqVO.getOrderIds())
|
||||
.likeIfPresent("o.id", pageReqVO.getOrderId())
|
||||
.inIfPresent(FIELD_ORDER_ID, pageReqVO.getOrderIds())
|
||||
.likeIfPresent(FIELD_ORDER_ID, pageReqVO.getOrderId())
|
||||
.likeIfPresent(FIELD_CUSTOMER, pageReqVO.getConsignee())
|
||||
.likeIfPresent(FIELD_CUSTOM_ORDER_NO, pageReqVO.getDefaultId())
|
||||
.likeIfPresent(FIELD_ADDRESS, pageReqVO.getConsigneeAddress())
|
||||
|
||||
+68
-45
@@ -20,31 +20,49 @@
|
||||
|
||||
<select id="selectOrderList" resultMap="OrderPageMap">
|
||||
select
|
||||
o.id as orderId,
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
|
||||
o.plate_num - o.planned_plate_num as num,
|
||||
o.area - o.planned_plate_area as area,
|
||||
o.parent_id as parentId,
|
||||
o.order_type as orderType,
|
||||
</if>
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
sum(og.plate_num - og.planned_plate_num) as num,
|
||||
sum(og.area - og.planned_plate_area) as area,
|
||||
</if>
|
||||
o.id as orderId,
|
||||
|
||||
o.order_date as orderDate,
|
||||
o.delivery_date as deliveryDate,
|
||||
o.customer as customer,
|
||||
o.address as address,
|
||||
o.custom_order_no as defineId,
|
||||
o.status as status
|
||||
from orders o
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
join order_goods og on og.organ_id = o.organ_id and og.order_id = o.id
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
|
||||
o.plate_num - o.planned_plate_num as num,
|
||||
o.area - o.planned_plate_area as area,
|
||||
</if>
|
||||
|
||||
${ew.customSqlSegment}
|
||||
and o.plate_num - o.planned_plate_num > 0
|
||||
<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,
|
||||
o.delivery_date as deliveryDate,
|
||||
o.customer as customer,
|
||||
o.address as address,
|
||||
o.custom_order_no as defineId,
|
||||
o.status as status
|
||||
|
||||
from orders o
|
||||
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
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
|
||||
<if test="orderGoodsIds != null and orderGoodsIds.size() > 0">
|
||||
AND og.id IN
|
||||
<foreach item="orderGoodsId" collection="orderGoodsIds" open="(" separator="," close=")">
|
||||
#{orderGoodsId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by og.order_id
|
||||
) t on t.order_id = o.id
|
||||
</if>
|
||||
|
||||
${ew.customSqlSegment}
|
||||
and o.plate_num - o.planned_plate_num > 0
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
|
||||
<choose>
|
||||
<when test="orderIds != null and orderIds.length > 0">
|
||||
@@ -58,13 +76,7 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
|
||||
and og.plate_num - og.planned_plate_num > 0
|
||||
group by orderId, orderDate, deliveryDate, customer, address, defineId, status
|
||||
</if>
|
||||
|
||||
order by o.id desc;
|
||||
|
||||
order by o.id desc
|
||||
</select>
|
||||
|
||||
|
||||
@@ -247,26 +259,37 @@
|
||||
|
||||
|
||||
<select id="selectNoPlanGoodsByRoomAndBodyIds" resultMap="OrderGoodsMap" parameterType="java.lang.Long">
|
||||
|
||||
|
||||
select
|
||||
og.color as color,
|
||||
og.color,
|
||||
og.goods_name as goodsName,
|
||||
og.material as material,
|
||||
og.thickness as thickness,
|
||||
og.brand as brand,
|
||||
og.texture as texture,
|
||||
sum(og.plate_num - og.planned_plate_num) as num
|
||||
og.material,
|
||||
og.thickness,
|
||||
og.brand,
|
||||
og.texture,
|
||||
|
||||
from order_item oi
|
||||
join order_plate op on op.order_id = oi.order_id and op.organ_id = oi.organ_id and op.id = oi.plate_id
|
||||
join order_goods og on og.order_id = oi.order_id and og.organ_id = oi.organ_id and og.id = op.goods_id
|
||||
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 oi.plate_id != 0
|
||||
and og.plate_num - og.planned_plate_num > 0
|
||||
and og.deleted = false
|
||||
group by og.color, og.goods_name, og.material, og.thickness, og.brand, og.texture
|
||||
order by thickness desc
|
||||
and op.plan_id = 0
|
||||
group by
|
||||
og.color,
|
||||
og.goods_name,
|
||||
og.material,
|
||||
og.thickness,
|
||||
og.brand,
|
||||
og.texture
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
+1
-2
@@ -614,11 +614,10 @@
|
||||
|
||||
select distinct op.id as plateId,
|
||||
op.order_id as orderId,
|
||||
o.id as packId,
|
||||
o.package_no as packNo
|
||||
from order_plate op
|
||||
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||
left join order_package o on oi.organ_id = o.organ_id and oi.order_id = o.order_id and oi.package_id = o.id
|
||||
left join order_package o on oi.organ_id = o.organ_id and oi.order_id = o.order_id and oi.package_id = o.package_no
|
||||
|
||||
where op.organ_id = #{organId}
|
||||
and op.deleted = false
|
||||
|
||||
Reference in New Issue
Block a user