mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 21:52:07 +08:00
分堆打包订单分页接口性能优化
This commit is contained in:
+20
-22
@@ -1,6 +1,5 @@
|
|||||||
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -15,66 +14,70 @@ import java.util.List;
|
|||||||
public class PackRespVO {
|
public class PackRespVO {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7788")
|
@Schema(description = "订单号", example = "7788")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "订单号", example = "7788")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7788")
|
|
||||||
|
@Schema(description = "包裹ID", example = "7788")
|
||||||
private Long packId;
|
private Long packId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "自定义单号", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "自定义单号",example = "ABCD")
|
||||||
private String customOrderNo;
|
private String customOrderNo;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "经销商电话", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "经销商电话",example = "ABCD")
|
||||||
private String dealerPhoneNumber;
|
private String dealerPhoneNumber;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "经销商", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "经销商",example = "ABCD")
|
||||||
private String dealer;
|
private String dealer;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "订单日期", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "订单日期",example = "ABCD")
|
||||||
private LocalDateTime orderDate;
|
private LocalDateTime orderDate;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "交付日期", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "交付日期",example = "ABCD")
|
||||||
private LocalDateTime deliveryDate;
|
private LocalDateTime deliveryDate;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "打包状态", requiredMode = Schema.RequiredMode.REQUIRED,example = "0")
|
@Schema(description = "打包状态",example = "0")
|
||||||
private Integer packaged;
|
private Integer packaged;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "客户", requiredMode = Schema.RequiredMode.REQUIRED,example = "张三")
|
@Schema(description = "客户",example = "张三")
|
||||||
private String customer;
|
private String customer;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "客户地址", requiredMode = Schema.RequiredMode.REQUIRED,example = "AABB")
|
@Schema(description = "客户地址",example = "AABB")
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "客户电话", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "客户电话",example = "ABCD")
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "业务员", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "业务员",example = "ABCD")
|
||||||
private String salesman;
|
private String salesman;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "拆单员", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "拆单员",example = "ABCD")
|
||||||
private String splitter;
|
private String splitter;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED,example = "ABCD")
|
@Schema(description = "备注",example = "ABCD")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "板件数量")
|
||||||
|
private Integer plateNum;
|
||||||
|
|
||||||
@Schema(description = "已打包数-包裹数")
|
@Schema(description = "已打包数-包裹数")
|
||||||
private Long packCount;
|
private Long packCount;
|
||||||
@@ -97,9 +100,4 @@ public class PackRespVO {
|
|||||||
|
|
||||||
@Schema(description = "订单对应的包裹ID集")
|
@Schema(description = "订单对应的包裹ID集")
|
||||||
private List<Long> packIdList;
|
private List<Long> packIdList;
|
||||||
|
|
||||||
// @Schema(description = "订单对应的板件信息", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
// List<PlateDetailsRespVO> plateDetailsRespVO;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单明细临时表 order_item DO
|
* 订单明细临时表 order_item_temp DO
|
||||||
*
|
*
|
||||||
* @author 晨丰科技
|
* @author 晨丰科技
|
||||||
*/
|
*/
|
||||||
|
|||||||
-2
@@ -320,8 +320,6 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
|||||||
.select(PlateDO::getId));
|
.select(PlateDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PackRespVO> selectPackPlateNum(@Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
|
|
||||||
|
|
||||||
List<PlateDetailsRespVO> selectOrderNoPackPlateList(@Param("orderId") Long orderId, @Param("organId") Long organId);
|
List<PlateDetailsRespVO> selectOrderNoPackPlateList(@Param("orderId") Long orderId, @Param("organId") Long organId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+17
-38
@@ -937,60 +937,39 @@ public class PackServiceImpl implements PackService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页数据查询对应的板件总数、包裹数量、已打包板件数量
|
||||||
|
*
|
||||||
|
* @param orderIds
|
||||||
|
* @param packRespVOS
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private PageResult<PackRespVO> buildPageResult(List<Long> orderIds, IPage<PackRespVO> packRespVOS) {
|
||||||
|
|
||||||
|
if (orderIds.isEmpty()) {
|
||||||
// 打包分页页面显示数据查询
|
|
||||||
private PageResult<PackRespVO> buildPageResult(List<Long> orderIds,IPage<PackRespVO> packRespVOS){
|
|
||||||
|
|
||||||
if(orderIds.isEmpty()){
|
|
||||||
return new PageResult<>();
|
return new PageResult<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 查询板材的总量
|
|
||||||
List<PackRespVO> packRespVOList = orderPlateMapper.selectPackPlateNum(orderIds, getUserOrganId());
|
|
||||||
|
|
||||||
AssertUtils.notEmpty(packRespVOList, ORDER_PLATE_ERROR);
|
|
||||||
|
|
||||||
for (PackRespVO packRespVO : packRespVOList) {
|
|
||||||
packRespVO.setTotalPieceCount((long) packRespVO.getPlateIdList().size());
|
|
||||||
packRespVO.setPlateIdList(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 查询当前生产的包裹数量
|
// 查询当前生产的包裹数量
|
||||||
List<PackRespVO> respVOS = orderPackageMapper.selectPackPage(orderIds, getUserOrganId());
|
List<PackRespVO> orderPackNumGroup = orderPackageMapper.selectPackPage(orderIds, getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
for (PackRespVO packRespVO : respVOS) {
|
|
||||||
packRespVO.setPackCount((long) packRespVO.getPackIdList().size());
|
|
||||||
packRespVO.setPackIdList(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 查询当前订单已经打包的板材数量
|
// 查询当前订单已经打包的板材数量
|
||||||
List<PackRespVO> plateNum = orderPackageMapper.selectPackPieceCount(orderIds, getUserOrganId());
|
List<PackRespVO> orderPackedPlateNumGroup = orderPackageMapper.selectPackPieceCount(orderIds, getUserOrganId());
|
||||||
|
|
||||||
for (PackRespVO packRespVO : plateNum) {
|
for (PackRespVO vosRecord : packRespVOS.getRecords()) {
|
||||||
packRespVO.setPackPieceCount((long) packRespVO.getPlateIdList().size());
|
|
||||||
packRespVO.setPlateIdList(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (PackRespVO vosRecords : packRespVOS.getRecords()) {
|
|
||||||
|
|
||||||
// 板材总数
|
// 板材总数
|
||||||
vosRecords.setTotalPieceCount(packRespVOList.stream().filter(f -> Objects.equals(f.getId(), vosRecords.getId())).mapToLong(PackRespVO::getTotalPieceCount).sum());
|
vosRecord.setTotalPieceCount(vosRecord.getPlateNum().longValue());
|
||||||
// 已打包数
|
// 已打包裹数
|
||||||
vosRecords.setPackCount(respVOS.stream().filter(f -> Objects.equals(f.getId(), vosRecords.getId())).mapToLong(PackRespVO::getPackCount).sum());
|
vosRecord.setPackCount(orderPackNumGroup.stream().filter(f -> Objects.equals(f.getOrderId(), vosRecord.getId())).mapToLong(PackRespVO::getPackCount).sum());
|
||||||
// 已打包片数
|
// 已打包片数
|
||||||
vosRecords.setPackPieceCount(plateNum.stream().filter(f -> Objects.equals(f.getId(), vosRecords.getId())).mapToLong(PackRespVO::getPackPieceCount).sum());
|
vosRecord.setPackPieceCount(orderPackedPlateNumGroup.stream().filter(f -> Objects.equals(f.getOrderId(), vosRecord.getId())).mapToLong(PackRespVO::getPackPieceCount).sum());
|
||||||
// 待处理量
|
// 待处理量
|
||||||
vosRecords.setPendingNum(vosRecords.getTotalPieceCount() - vosRecords.getPackPieceCount());
|
vosRecord.setPendingNum(vosRecord.getTotalPieceCount() - vosRecord.getPackPieceCount());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new PageResult<>(packRespVOS.getRecords(), packRespVOS.getTotal());
|
return new PageResult<>(packRespVOS.getRecords(), packRespVOS.getTotal());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -503,6 +503,7 @@
|
|||||||
<result property="packCount" column="packCount"/>
|
<result property="packCount" column="packCount"/>
|
||||||
<result property="totalPieceCount" column="totalPieceCount"/>
|
<result property="totalPieceCount" column="totalPieceCount"/>
|
||||||
<result property="packPieceCount" column="packPieceCount"/>
|
<result property="packPieceCount" column="packPieceCount"/>
|
||||||
|
<result property="plateNum" column="plateNum"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@@ -554,7 +555,8 @@
|
|||||||
salesman as salesman,
|
salesman as salesman,
|
||||||
splitter as splitter,
|
splitter as splitter,
|
||||||
packaged as packaged,
|
packaged as packaged,
|
||||||
remark as remark
|
remark as remark,
|
||||||
|
plate_num as plateNum
|
||||||
|
|
||||||
from orders
|
from orders
|
||||||
<where>
|
<where>
|
||||||
|
|||||||
+11
-34
@@ -1,69 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper">
|
<mapper namespace="com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper">
|
||||||
|
<select id="selectPackPage"
|
||||||
<resultMap id="PackMap" type="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackRespVO">
|
parameterType="java.util.List"
|
||||||
|
resultType="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackRespVO">
|
||||||
<result property="id" column="orderId"/>
|
|
||||||
<collection property="plateIdList" ofType="java.lang.Long" column="plateId"/>
|
|
||||||
|
|
||||||
<collection property="packIdList" ofType="java.lang.Long" column="packId"/>
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPackPage" parameterType="java.util.List" resultMap="PackMap">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
select
|
select
|
||||||
order_id as orderId,
|
order_id as orderId,
|
||||||
package_no as packId
|
COUNT(*) AS packCount
|
||||||
|
|
||||||
from order_package
|
from order_package
|
||||||
|
|
||||||
where
|
where
|
||||||
organ_id = #{organId}
|
organ_id = #{organId}
|
||||||
|
and status != 0
|
||||||
and status !=0
|
|
||||||
|
|
||||||
and deleted = false
|
and deleted = false
|
||||||
|
|
||||||
and order_id in
|
and order_id in
|
||||||
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
|
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
GROUP BY order_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPackPieceCount"
|
<select id="selectPackPieceCount"
|
||||||
parameterType="java.util.List"
|
parameterType="java.util.List"
|
||||||
resultMap="PackMap">
|
resultType="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackRespVO">
|
||||||
|
|
||||||
select distinct
|
select
|
||||||
op.order_id as orderId,
|
op.order_id as orderId,
|
||||||
oi.plate_id as plateId
|
COUNT(DISTINCT oi.plate_id) AS packPieceCount
|
||||||
|
|
||||||
from order_package op
|
from order_package op
|
||||||
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.package_no = oi.package_id
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.package_no = oi.package_id
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
op.organ_id = #{organId}
|
op.organ_id = #{organId}
|
||||||
and op.deleted = false
|
and op.deleted = false
|
||||||
and op.order_id in
|
and op.order_id in
|
||||||
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
|
<foreach item="id" collection="orderIds" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
and op.status in (1,2,3)
|
and op.status in (1,2,3)
|
||||||
and oi.package_id != 0
|
and oi.package_id != 0
|
||||||
and oi.plate_id != 0;
|
and oi.plate_id != 0
|
||||||
|
GROUP BY op.order_id;
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap id="OrderPackDataMap" type="com.cf.imes.module.executor.controller.admin.order.vo.order.LabelOrderPackData">
|
<resultMap id="OrderPackDataMap" type="com.cf.imes.module.executor.controller.admin.order.vo.order.LabelOrderPackData">
|
||||||
|
|||||||
-33
@@ -717,39 +717,6 @@
|
|||||||
from order_plate where order_id = #{orderId} and organ_id = #{organId};
|
from order_plate where order_id = #{orderId} and organ_id = #{organId};
|
||||||
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="PlateMap" type="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackRespVO">
|
|
||||||
|
|
||||||
|
|
||||||
<result property="id" column="orderId"/>
|
|
||||||
|
|
||||||
<collection property="plateIdList" ofType="java.lang.Long" column="plateId"/>
|
|
||||||
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPackPlateNum" resultMap="PlateMap">
|
|
||||||
|
|
||||||
select
|
|
||||||
order_id as orderId,
|
|
||||||
id as plateId
|
|
||||||
|
|
||||||
from order_plate
|
|
||||||
|
|
||||||
where organ_id = #{organId}
|
|
||||||
|
|
||||||
and deleted = false
|
|
||||||
|
|
||||||
and order_id in
|
|
||||||
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
|
||||||
#{orderIds}
|
|
||||||
</foreach>
|
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap id="PlateDetailsMap" type="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PlateDetailsRespVO">
|
<resultMap id="PlateDetailsMap" type="com.cf.imes.module.executor.controller.admin.manage.pack.vo.PlateDetailsRespVO">
|
||||||
|
|||||||
Reference in New Issue
Block a user