mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、分堆打包封包、保存分堆抽象和复杂度优化,删除配件优化;2、分堆打包部分接口入参提示优化;
This commit is contained in:
+5
-5
@@ -196,9 +196,9 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode ORDER_COMPONENT_NOT_PROCESS = new ErrorCode(1_003_010_006, "order.component.not.process");
|
||||
public static final ErrorCode ORDER_COMPONENT_RESTORE_REPEAT = new ErrorCode(1_003_010_007, "order.component.restore.repeat");
|
||||
|
||||
//=========== 部件管理 1-003-011-000 ============
|
||||
public static final ErrorCode HEAP_SPLIT_TASK_NOT_EXIST = new ErrorCode(1_003_011_000, "heap.split.task.not.exist");
|
||||
public static final ErrorCode HEAP_SPLIT_TASK_NAME_EXIST = new ErrorCode(1_003_011_001, "heap.split.task.name.exist");
|
||||
public static final ErrorCode HEAP_SPLIT_NO_NEED_RESTART = new ErrorCode(1_003_011_002, "heap.split.no.need.restart");
|
||||
public static final ErrorCode HEAP_SPLIT_NEED_RESTART = new ErrorCode(1_003_011_003, "heap.split.need.restart");
|
||||
//=========== 分堆打包 1-003-011-000 ============
|
||||
public static final ErrorCode PARTS_PACK_NUM_NOT_ENOUGH = new ErrorCode(1_003_010_000, "parts.pack.num.not.enough");
|
||||
public static final ErrorCode PARTS_PACK_ITEM_SOURCE_NOT_EXISTS = new ErrorCode(1_003_010_001, "parts.pack.item.source.not.exist");
|
||||
public static final ErrorCode PARTS_HEAPSPLIT_NUM_NOT_ENOUGH = new ErrorCode(1_003_010_002, "parts.heapsplit.num.not.enough");
|
||||
public static final ErrorCode PARTS_HEAPSPLIT_ITEM_SOURCE_NOT_EXISTS = new ErrorCode(1_003_010_003, "parts.heapsplit.item.source.not.exist");
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import com.cf.imes.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 打包配置 - 打包方式枚举
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/4/1 10:50
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OrderPackageMethodEnum implements IntArrayValuable {
|
||||
ROOM_NAME(0),
|
||||
BODY_NAME(1),
|
||||
ORDER(2);
|
||||
|
||||
private final int method;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(OrderPackageMethodEnum::getMethod).toArray();
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
}
|
||||
+15
-11
@@ -7,7 +7,6 @@ import com.cf.imes.module.executor.controller.admin.manage.pack.vo.*;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.OrderPackageVO;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.PackageDetailsRespVO;
|
||||
import com.cf.imes.module.executor.service.manage.pack.PackService;
|
||||
import com.cf.imes.module.executor.service.manage.query.ProductionStatusService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -33,9 +32,6 @@ public class PackController {
|
||||
@Resource
|
||||
private PackService packService;
|
||||
|
||||
@Resource
|
||||
private ProductionStatusService productionStatusService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "打包分页查询")
|
||||
@PreAuthorize("@ss.hasPermission('manage:pack:query')")
|
||||
@@ -65,27 +61,35 @@ public class PackController {
|
||||
|
||||
|
||||
@PostMapping("/getOrderPack")
|
||||
@Operation(summary = "查看生产订单对应的包裹信息-未分页")
|
||||
@Operation(summary = "查看订单列表对应的包裹列表")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('manage:pack:export-pack-num','manage:pack:pack')")
|
||||
public CommonResult<List<OrderPackageVO>> getOrderPack(@Valid @RequestBody PackageDetailsReqVO reqVO) {
|
||||
return success(packService.getOrderPack(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/packageDetails/{packageNo}")
|
||||
@Operation(summary = "查询包裹的详细信息")
|
||||
@Operation(summary = "查询包裹编号对应的包裹中的明细")
|
||||
@Parameter(name = "packageNo", description = "包裹编号", required = true)
|
||||
@PreAuthorize("@ss.hasAnyPermissions('manage:pack:pack-details','manage:pack:query')")
|
||||
public CommonResult<List<PackageDetailsRespVO>> queryPackageDetails(@PathVariable String packageNo){
|
||||
return success(packService.getPackageDetails(packageNo));
|
||||
public CommonResult<List<PackageDetailsRespVO>> queryOrdersPackageDetails(@PathVariable String packageNo){
|
||||
return success(packService.getOrdersPackageDetails(packageNo));
|
||||
}
|
||||
|
||||
@GetMapping("/packageDetails/{orderId}/{packageNo}")
|
||||
@Operation(summary = "查询订单编号下对应包裹编号的包裹中的明细")
|
||||
@Parameter(name = "orderId", description = "订单编号", required = true)
|
||||
@Parameter(name = "packageNo", description = "包裹编号", required = true)
|
||||
@PreAuthorize("@ss.hasAnyPermissions('manage:pack:pack-details','manage:pack:query')")
|
||||
public CommonResult<List<PackageDetailsRespVO>> queryOrderPackageDetails(@PathVariable Long orderId, @PathVariable String packageNo) {
|
||||
return success(packService.getOrderPackageDetails(orderId, packageNo));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getPageOrderPack")
|
||||
@PostMapping("/getPageOrderPack")
|
||||
@Operation(summary = "查看生产订单对应的包裹信息-分页")
|
||||
@PreAuthorize("@ss.hasPermission('manage:pack:pack-details')")
|
||||
public CommonResult<PageResult<OrderPackageVO>> getPageOrderPack(@Valid PackageDetailsReqVO reqVO) {
|
||||
|
||||
return success(packService.getPageOrderPack(reqVO));
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("/updatePack")
|
||||
|
||||
+8
@@ -1,7 +1,10 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.heapsplit;
|
||||
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackagePartsSaveReqVO;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,5 +32,10 @@ public class HeapSplitSaveReqVO {
|
||||
private List<PackagePartsSaveReqVO> delParts = new ArrayList<>();
|
||||
|
||||
@Schema(description = "订单id列表")
|
||||
@Size(min = 1, max = 100, message = "订单号列表不能为空且长度不能超过100")
|
||||
private List<Long> orderIds = new ArrayList<>();
|
||||
|
||||
@Schema(description = "打包方式:0柜名、1房名、2订单")
|
||||
@InEnum(OrderPackageMethodEnum.class)
|
||||
private Integer packMethod;
|
||||
}
|
||||
|
||||
+7
-5
@@ -1,11 +1,12 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,8 +15,8 @@ import java.util.List;
|
||||
@ToString(callSuper = true)
|
||||
public class OrderPackReqVO {
|
||||
|
||||
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "订单号为空")
|
||||
@Schema(description = "订单号列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Size(min = 1, max = 100, message = "订单号列表不能为空且长度不能超过100")
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@@ -31,7 +32,8 @@ public class OrderPackReqVO {
|
||||
private List<Long> deletePlateIdList = new ArrayList<>();
|
||||
|
||||
@Schema(description = "打包方式:0柜名、1房名、2订单")
|
||||
private Integer packMethod = 1;
|
||||
@InEnum(OrderPackageMethodEnum.class)
|
||||
private Integer packMethod;
|
||||
|
||||
@Schema(description = "新增打包的配件列表")
|
||||
private List<PackagePartsSaveReqVO> addPartsList = new ArrayList<>();
|
||||
|
||||
-8
@@ -1,6 +1,5 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -12,10 +11,6 @@ import java.util.List;
|
||||
@Data
|
||||
@Builder
|
||||
public class OrderPackRespVO {
|
||||
|
||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long orderId;
|
||||
|
||||
@@ -25,9 +20,6 @@ public class OrderPackRespVO {
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String packageNo;
|
||||
|
||||
@Schema(description = "包裹类型,-1未定义,0板材,1配件,2其他配件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer packageType;
|
||||
|
||||
@Schema(description = "包裹名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String name;
|
||||
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 订单模块表 Request VO")
|
||||
@Data
|
||||
//@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OrderPartsReqVO /*extends PageParam*/ {
|
||||
|
||||
|
||||
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// @NotNull(message = "订单号为空")
|
||||
private Long orderId;
|
||||
|
||||
private List<Long> orderIds;
|
||||
|
||||
|
||||
@Schema(description = "更新配件时传-包裹ID")
|
||||
private Long packId;
|
||||
|
||||
|
||||
@Schema(description = "新增的配件ID")
|
||||
private List<Long> addPartsIdList;
|
||||
|
||||
|
||||
@Schema(description = "更新配件时传-删除的配件ID")
|
||||
private List<Long> deletePartsIdList;
|
||||
|
||||
|
||||
@Schema(description = "新增的板件ID")
|
||||
private List<Long> addPlateIdList;
|
||||
|
||||
|
||||
}
|
||||
+26
-24
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -10,84 +11,85 @@ import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 配件列表详情 Response VO")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class OrderPartsRespVO {
|
||||
|
||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "包裹ID")
|
||||
private Long packageId;
|
||||
|
||||
@Schema(description = "订单ID")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "包裹号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "包裹号")
|
||||
private String packageNo;
|
||||
|
||||
@Schema(description = "房间名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "房间名称")
|
||||
@ExcelProperty("房间名称")
|
||||
private String roomName;
|
||||
|
||||
@Schema(description = "柜体名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "柜体名称")
|
||||
@ExcelProperty("柜体名称")
|
||||
private String cabinetName;
|
||||
|
||||
@Schema(description = "房间ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "房间ID")
|
||||
private String roomId;
|
||||
|
||||
@Schema(description = "柜体ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "柜体ID")
|
||||
private String bodyId;
|
||||
|
||||
@Schema(description = "配件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件ID")
|
||||
private Long partsId;
|
||||
|
||||
@Schema(description = "配件名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "型号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "型号")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "规格")
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "品牌")
|
||||
private String brand;
|
||||
|
||||
@Schema(description = "厂家", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "厂家")
|
||||
private String factory;
|
||||
|
||||
|
||||
@Schema(description = "配件类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件类型")
|
||||
private String type;
|
||||
|
||||
|
||||
@Schema(description = "是否复合配件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "是否复合配件")
|
||||
private Boolean isComposite;
|
||||
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@Schema(description = "配件颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件颜色")
|
||||
private String partsColor;
|
||||
|
||||
@Schema(description = "配件宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件宽度")
|
||||
private Double partsWidth;
|
||||
|
||||
@Schema(description = "配件长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件长度")
|
||||
private Double partsLength;
|
||||
|
||||
@Schema(description = "配件厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件厚度")
|
||||
private Double partsThickness;
|
||||
|
||||
@Schema(description = "配件主类:1封边2五金3组件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件主类:1封边2五金3组件")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "子配件ID列表,复合部件时记录子配件ID,半角逗号分隔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "子配件ID列表,复合部件时记录子配件ID,半角逗号分隔")
|
||||
private String subparts;
|
||||
|
||||
@Schema(description = "数量-用于计算,不显示")
|
||||
@@ -98,7 +100,7 @@ public class OrderPartsRespVO {
|
||||
|
||||
private List<GroupNameList> processGroupNameList;
|
||||
|
||||
@Schema(description = "加工组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "加工组")
|
||||
private String processGroup;
|
||||
|
||||
@Schema(description = "分堆状态,true:已分堆")
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@@ -15,5 +16,6 @@ public class PackReqVO {
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "包裹编号不能为空")
|
||||
private Long packageNo;
|
||||
}
|
||||
|
||||
+7
-1
@@ -4,6 +4,8 @@ import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderItemTypeEnum;
|
||||
import com.cf.imes.module.executor.enums.pack.PackScanComponentCorrelationTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -20,16 +22,20 @@ public class PackScanComponentCorrelationReqVO {
|
||||
|
||||
@InEnum(PackScanComponentCorrelationTypeEnum.class)
|
||||
@Schema(description = "扫描类型,0本身、1部件父级、2部件顶级")
|
||||
@NotNull(message = "扫描类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "扫描本体编号")
|
||||
@NotNull(message = "扫描本体编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@InEnum(OrderItemTypeEnum.class)
|
||||
@Schema(description = "扫描本体类型")
|
||||
@NotNull(message = "扫描本体类型不能为空")
|
||||
private Integer itemType;
|
||||
|
||||
@Schema(description = "订单ID列表")
|
||||
@Schema(description = "订单ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Size(max = 100, message = "订单ID列表最大长度为100")
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "是否关联加工组")
|
||||
|
||||
+3
@@ -3,6 +3,7 @@ package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@@ -23,6 +24,8 @@ public class PackageDetailsReqVO extends PageParam {
|
||||
@Length(max = 19,message = "订单号长度不能超过 19 位")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "订单号列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Size(max = 100, message = "订单号列表长度不能超过 100 个")
|
||||
private List<Long> orderIds;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class PackingReqVO {
|
||||
|
||||
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "包裹异常,请查看是否封包")
|
||||
@NotNull(message = "包裹编号不能为空,请查看是否封包")
|
||||
private Long packageNo;
|
||||
|
||||
|
||||
|
||||
+23
-23
@@ -17,88 +17,88 @@ import java.util.List;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class PlateDetailsRespVO {
|
||||
|
||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "包裹ID")
|
||||
private Long packageId;
|
||||
|
||||
@Schema(description = "包裹号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "包裹号")
|
||||
private String packageNo;
|
||||
|
||||
@Schema(description = "房间名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "房间名称")
|
||||
@ExcelProperty("房间名称")
|
||||
private String roomName;
|
||||
|
||||
@Schema(description = "柜体名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "柜体名称")
|
||||
@ExcelProperty("柜体名称")
|
||||
private String cabinetName;
|
||||
|
||||
@Schema(description = "房间ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "房间ID")
|
||||
private String roomId;
|
||||
|
||||
@Schema(description = "柜体ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "柜体ID")
|
||||
private String bodyId;
|
||||
|
||||
@Schema(description = "订单ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "订单ID")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "板材ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板材ID")
|
||||
private String plateId;
|
||||
|
||||
@Schema(description = "自定义板编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "自定义板编号")
|
||||
private String customPlateNo;
|
||||
|
||||
@Schema(description = "板编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板编号")
|
||||
@ExcelProperty("板编号")
|
||||
private String plateNo;
|
||||
|
||||
@Schema(description = "板名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板名称")
|
||||
@ExcelProperty("板名称")
|
||||
private String plateName;
|
||||
|
||||
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "材料")
|
||||
@ExcelProperty("材料")
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "颜色")
|
||||
@ExcelProperty("颜色")
|
||||
private String color;
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "宽度")
|
||||
@ExcelProperty("宽度")
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "长度")
|
||||
@ExcelProperty("长度")
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "厚度")
|
||||
@ExcelProperty("厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "面积", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "面积")
|
||||
@ExcelProperty("面积")
|
||||
private Double area;
|
||||
|
||||
@Schema(description = "纹路", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "纹路")
|
||||
@ExcelProperty("纹路")
|
||||
private Integer texture;
|
||||
|
||||
@Schema(description = "异形", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "异形")
|
||||
@ExcelProperty("异形")
|
||||
private Boolean specialShaped;
|
||||
|
||||
@Schema(description = "正反面造型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "正反面造型")
|
||||
@ExcelProperty("正反面造型")
|
||||
private Boolean profiling;
|
||||
|
||||
@Schema(description = "排孔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "排孔")
|
||||
@ExcelProperty("排孔")
|
||||
private Boolean rowHole;
|
||||
|
||||
@Schema(description = "加工组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "加工组")
|
||||
@ExcelProperty("加工组")
|
||||
private String processGroup;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.query.vo.pack;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -8,6 +9,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 订单包裹表 Response VO")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class OrderPackageVO {
|
||||
|
||||
|
||||
|
||||
+37
-37
@@ -13,112 +13,112 @@ import java.util.List;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class PackageDetailsRespVO {
|
||||
|
||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "包裹ID")
|
||||
private Long packageNo;
|
||||
|
||||
@Schema(description = "订单ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "订单ID")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "房间名称-板材类型显示", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "房间名称-板材类型显示")
|
||||
private String roomName;
|
||||
|
||||
@Schema(description = "柜体名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "柜体名称")
|
||||
private String cabinetName;
|
||||
|
||||
@Schema(description = "板材ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板材ID")
|
||||
private Long plateId;
|
||||
|
||||
@Schema(description = "板编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板编号")
|
||||
private String plateNo;
|
||||
|
||||
@Schema(description = "自定义板编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "自定义板编号")
|
||||
private String customPlateNo;
|
||||
|
||||
@Schema(description = "板名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "板名称")
|
||||
private String plateName;
|
||||
|
||||
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "材料")
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "颜色")
|
||||
private String color;
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "宽度")
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "长度")
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "面积", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "面积")
|
||||
private Double area;
|
||||
|
||||
@Schema(description = "纹路", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "纹路")
|
||||
private String texture;
|
||||
|
||||
@Schema(description = "是否异型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "是否异型")
|
||||
private Boolean specialShaped;
|
||||
|
||||
@Schema(description = "是否造型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "是否造型")
|
||||
private Boolean profiling;
|
||||
|
||||
@Schema(description = "是否有孔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "是否有孔")
|
||||
private Boolean rowHole;
|
||||
|
||||
@Schema(description = "加工组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "加工组")
|
||||
private String processGroup;
|
||||
|
||||
@Schema(description = "备注(板材和配件都要传递)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "备注(板材和配件都要传递)")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "配件名称-配件类型显示", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件名称-配件类型显示")
|
||||
private String partsName;
|
||||
|
||||
@Schema(description = "配件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件ID")
|
||||
private Long partsId;
|
||||
|
||||
@Schema(description = "型号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "型号")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "规格")
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "明细配件类型, 2 五金/配件 3 其他 4 报价配件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "明细配件类型, 2 五金/配件 3 其他 4 报价配件")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal num;
|
||||
@Schema(description = "数量")
|
||||
private BigDecimal packNum;
|
||||
|
||||
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "是否复合部件:0 否 1 是", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "是否复合部件:0 否 1 是")
|
||||
private Boolean isComposite;
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "品牌")
|
||||
private String brand;
|
||||
|
||||
@Schema(description = "厂家", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "厂家")
|
||||
private String factory;
|
||||
|
||||
@Schema(description = "配件颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件颜色")
|
||||
private String partsColor;
|
||||
|
||||
@Schema(description = "配件宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件宽度")
|
||||
private Double partsWidth;
|
||||
|
||||
@Schema(description = "配件长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件长度")
|
||||
private Double partsLength;
|
||||
|
||||
@Schema(description = "配件厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件厚度")
|
||||
private Double partsThickness;
|
||||
|
||||
@Schema(description = "配件主类:1封边2五金3组件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "配件主类:1封边2五金3组件")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "子配件ID列表,复合部件时记录子配件ID,半角逗号分隔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "子配件ID列表,复合部件时记录子配件ID,半角逗号分隔")
|
||||
private String subparts;
|
||||
|
||||
|
||||
|
||||
-8
@@ -35,7 +35,6 @@ import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单表 order_{N} Mapper
|
||||
@@ -320,11 +319,4 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
* @return
|
||||
*/
|
||||
OrderPlateNumAndAreaDO selectPlateNumAndArea(@Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 更新订单打包状态
|
||||
*
|
||||
* @param orderIds
|
||||
*/
|
||||
void updateOrdersPackageStatus(@Param("orderIds") List<Long> orderIds);
|
||||
}
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ public interface OrderPartsMapper extends BaseMapperX<OrderPartsDO> {
|
||||
List<OrderPartsRespVO> selectOrdersPartsList(@Param("orderIds") List<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 查询订单列表未打包配件
|
||||
* 查询订单列表分堆配件
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
|
||||
+6
-6
@@ -4,23 +4,23 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分堆任务状态枚举
|
||||
* 分堆状态枚举
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/3/11 10:35
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum HeapSplitTaskStatusEnum {
|
||||
public enum HeapSplitStatusEnum {
|
||||
/**
|
||||
* 未完成
|
||||
* 未分堆
|
||||
*/
|
||||
UNFINISHED(0),
|
||||
NO(0),
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
* 已分堆
|
||||
*/
|
||||
FINISHED(1);
|
||||
YES(1);
|
||||
|
||||
private final int status;
|
||||
}
|
||||
+1
@@ -19,6 +19,7 @@ public enum PackScanComponentCorrelationTypeEnum implements IntArrayValuable {
|
||||
* 本身
|
||||
*/
|
||||
SELF(0),
|
||||
|
||||
/**
|
||||
* 部件父级
|
||||
*/
|
||||
|
||||
+198
-126
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.executor.service.heapsplit;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -13,6 +14,8 @@ import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import com.cf.imes.module.executor.enums.heapsplit.HeapSplitStatusEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,9 +25,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PARTS_HEAPSPLIT_NUM_NOT_ENOUGH;
|
||||
|
||||
/**
|
||||
* 分堆 ServiceImpl 接口实现类
|
||||
*
|
||||
@@ -46,16 +50,18 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveHeapsplit(HeapSplitSaveReqVO reqVO) {
|
||||
Integer packMethod = reqVO.getPackMethod();
|
||||
List<Long> orderIds = reqVO.getOrderIds();
|
||||
// 更新板件分堆状态
|
||||
List<Long> plateIds = reqVO.getPlateIds();
|
||||
if (CollUtil.isNotEmpty(plateIds)) {
|
||||
List<List<Long>> platePartitions = CollUtil.split(plateIds, 1000);
|
||||
for (List<Long> batch : platePartitions) {
|
||||
orderItemMapper.update(new LambdaUpdateWrapper<OrderItemDO>()
|
||||
.in(OrderItemDO::getOrderId, reqVO.getOrderIds())
|
||||
.in(OrderItemDO::getOrderId, orderIds)
|
||||
.in(OrderItemDO::getPlateId, batch)
|
||||
.eq(OrderItemDO::getHeapSplitStatus, 0)
|
||||
.set(OrderItemDO::getHeapSplitStatus, 1));
|
||||
.eq(OrderItemDO::getHeapSplitStatus, HeapSplitStatusEnum.NO.getStatus())
|
||||
.set(OrderItemDO::getHeapSplitStatus, HeapSplitStatusEnum.YES.getStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,60 +71,122 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
List<List<Long>> delPlatePartitions = CollUtil.split(delPlateIds, 1000);
|
||||
for (List<Long> batch : delPlatePartitions) {
|
||||
orderItemMapper.update(new LambdaUpdateWrapper<OrderItemDO>()
|
||||
.in(OrderItemDO::getOrderId, reqVO.getOrderIds())
|
||||
.in(OrderItemDO::getOrderId, orderIds)
|
||||
.in(OrderItemDO::getPlateId, batch)
|
||||
.eq(OrderItemDO::getHeapSplitStatus, 1)
|
||||
.set(OrderItemDO::getHeapSplitStatus, 0));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新配件分堆状态
|
||||
List<PackagePartsSaveReqVO> parts = reqVO.getParts();
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
parts.stream().collect(Collectors.groupingBy(PackagePartsSaveReqVO::getBodyId));
|
||||
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
Long bodyId = entry.getKey();
|
||||
List<PackagePartsSaveReqVO> partsList = entry.getValue();
|
||||
|
||||
for (PackagePartsSaveReqVO partsSaveReqVO : partsList) {
|
||||
Long partsId = partsSaveReqVO.getPartsId();
|
||||
Integer num = partsSaveReqVO.getNum();
|
||||
// partsId下的所有明细,基于num正序,优先分堆数量小的
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getPartsId, partsId)
|
||||
.in(OrderItemDO::getOrderId, reqVO.getOrderIds())
|
||||
.eq(OrderItemDO::getBodyId, bodyId)
|
||||
.eq(OrderItemDO::getHeapSplitStatus, false)
|
||||
.orderByAsc(OrderItemDO::getNum));
|
||||
|
||||
allocateSingleGroup(orderItemDOS, num);
|
||||
.eq(OrderItemDO::getHeapSplitStatus, HeapSplitStatusEnum.YES.getStatus())
|
||||
.set(OrderItemDO::getHeapSplitStatus, HeapSplitStatusEnum.NO.getStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
// 删除配件分堆状态
|
||||
List<PackagePartsSaveReqVO> delParts = reqVO.getDelParts();
|
||||
Map<Long, List<PackagePartsSaveReqVO>> delGroupMap =
|
||||
delParts.stream().collect(Collectors.groupingBy(PackagePartsSaveReqVO::getBodyId));
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : delGroupMap.entrySet()) {
|
||||
Long bodyId = entry.getKey();
|
||||
List<PackagePartsSaveReqVO> partsList = entry.getValue();
|
||||
processParts(reqVO.getDelParts(), packMethod, orderIds, false);
|
||||
// 更新配件分堆状态
|
||||
processParts(reqVO.getParts(), packMethod, orderIds, true);
|
||||
}
|
||||
|
||||
for (PackagePartsSaveReqVO partsSaveReqVO : partsList) {
|
||||
Long partsId = partsSaveReqVO.getPartsId();
|
||||
Integer num = partsSaveReqVO.getNum();
|
||||
// partsId下的所有明细,基于num正序,优先分堆数量小的
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getPartsId, partsId)
|
||||
.in(OrderItemDO::getOrderId, reqVO.getOrderIds())
|
||||
.eq(OrderItemDO::getBodyId, bodyId)
|
||||
.orderByAsc(OrderItemDO::getNum));
|
||||
/**
|
||||
* 配件分堆状态和数量处理
|
||||
*
|
||||
* @param list
|
||||
* @param packMethod
|
||||
* @param orderIds
|
||||
* @param isAdd
|
||||
*/
|
||||
private void processParts(
|
||||
List<PackagePartsSaveReqVO> list,
|
||||
Integer packMethod,
|
||||
List<Long> orderIds,
|
||||
boolean isAdd) {
|
||||
|
||||
restoreGroup(orderItemDOS, num);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
list.stream().collect(Collectors.groupingBy(item -> getGroupKey(item, packMethod)));
|
||||
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
|
||||
Long groupKey = entry.getKey();
|
||||
|
||||
for (PackagePartsSaveReqVO vo : entry.getValue()) {
|
||||
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper = buildWrapper(
|
||||
groupKey,
|
||||
vo.getPartsId(),
|
||||
packMethod,
|
||||
orderIds,
|
||||
isAdd // add才需要heapSplit过滤
|
||||
);
|
||||
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(wrapper);
|
||||
|
||||
if (isAdd) {
|
||||
allocateGroup(orderItemDOS, vo.getNum());
|
||||
} else {
|
||||
restoreGroup(orderItemDOS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组规则
|
||||
* @param item
|
||||
* @param packMethod
|
||||
* @return
|
||||
*/
|
||||
private Long getGroupKey(PackagePartsSaveReqVO item, Integer packMethod) {
|
||||
if (ObjectUtil.equals(OrderPackageMethodEnum.ROOM_NAME.getMethod(), packMethod)) {
|
||||
return item.getRoomId();
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.BODY_NAME.getMethod(), packMethod)) {
|
||||
return item.getBodyId();
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.ORDER.getMethod(), packMethod)) {
|
||||
return item.getOrderId();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态构建查询wrapper
|
||||
*
|
||||
* @param groupKey
|
||||
* @param partsId
|
||||
* @param packMethod
|
||||
* @param orderIds
|
||||
* @param filterHeapSplit
|
||||
* @return
|
||||
*/
|
||||
private LambdaQueryWrapper<OrderItemDO> buildWrapper(
|
||||
Long groupKey,
|
||||
Long partsId,
|
||||
Integer packMethod,
|
||||
List<Long> orderIds,
|
||||
boolean filterHeapSplit) {
|
||||
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.eq(OrderItemDO::getPartsId, partsId);
|
||||
|
||||
if (filterHeapSplit) {
|
||||
wrapper.eq(OrderItemDO::getHeapSplitStatus, false);
|
||||
}
|
||||
|
||||
if (ObjectUtil.equals(OrderPackageMethodEnum.ROOM_NAME.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getRoomId, groupKey)
|
||||
.in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.BODY_NAME.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getBodyId, groupKey)
|
||||
.in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.ORDER.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getOrderId, groupKey);
|
||||
}
|
||||
|
||||
wrapper.orderByAsc(OrderItemDO::getNum);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrdersHeapSplitDetailRespVO getOrdersHeapSplitedDetail(List<Long> orderIds) {
|
||||
OrdersHeapSplitDetailRespVO respVO = new OrdersHeapSplitDetailRespVO();
|
||||
@@ -127,7 +195,13 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private void allocateSingleGroup(List<OrderItemDO> list, int targetNum) {
|
||||
/**
|
||||
* 分堆打包数量
|
||||
*
|
||||
* @param list 同一查询范围的order_parts id相同的orderitem列表
|
||||
* @param targetNum 分配目标数
|
||||
*/
|
||||
private void allocateGroup(List<OrderItemDO> list, int targetNum) {
|
||||
|
||||
int remain = targetNum;
|
||||
|
||||
@@ -137,7 +211,7 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
break;
|
||||
}
|
||||
|
||||
double current = Optional.ofNullable(item.getNum()).orElse(0.0);
|
||||
double current = item.getNum() - item.getHeapNum();
|
||||
if (current <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -146,7 +220,7 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
if (current <= remain) {
|
||||
|
||||
// 标记分堆
|
||||
item.setHeapSplitStatus(1);
|
||||
item.setHeapSplitStatus(HeapSplitStatusEnum.YES.getStatus());
|
||||
|
||||
// 更新分堆数量
|
||||
item.setHeapNum(current);
|
||||
@@ -159,11 +233,11 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
// 情况2:> 需要拆分
|
||||
else {
|
||||
|
||||
// 1️⃣ 原记录扣减
|
||||
item.setHeapNum(current - remain);
|
||||
// 1、原记录累加分堆数量
|
||||
item.setHeapNum(item.getHeapNum() + remain);
|
||||
orderItemMapper.updateById(item);
|
||||
|
||||
// 2️⃣ 新建分堆记录
|
||||
// 2、 新建分堆记录
|
||||
OrderItemDO newItem = buildHeapItem(item, remain);
|
||||
orderItemMapper.insert(newItem);
|
||||
|
||||
@@ -173,115 +247,113 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
}
|
||||
|
||||
if (remain > 0) {
|
||||
throw new ServiceException(new ErrorCode(10001, "数量不足,剩余未分配:" + remain));
|
||||
throw new ServiceException(PARTS_HEAPSPLIT_NUM_NOT_ENOUGH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分堆未全覆盖创建item副本
|
||||
*
|
||||
* @param source
|
||||
* @param heapNum
|
||||
* @return
|
||||
*/
|
||||
private OrderItemDO buildHeapItem(OrderItemDO source, double heapNum) {
|
||||
OrderItemDO newItem = new OrderItemDO();
|
||||
|
||||
// 基础字段复制(建议用BeanUtils)
|
||||
// 字段复制
|
||||
BeanUtils.copyProperties(source, newItem);
|
||||
|
||||
newItem.setId(null); // 新ID
|
||||
newItem.setHeapNum(heapNum);
|
||||
|
||||
// 标记为“已分堆”
|
||||
newItem.setHeapSplitStatus(1);
|
||||
newItem.setHeapSplitStatus(HeapSplitStatusEnum.YES.getStatus());
|
||||
newItem.setSourceId(source.getId());
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void restoreGroup(List<OrderItemDO> list, int targetNum) {
|
||||
int remain = targetNum;
|
||||
|
||||
Map<Long, OrderItemDO> originMap = list.stream()
|
||||
.filter(i -> ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.collect(Collectors.toMap(OrderItemDO::getId, Function.identity()));
|
||||
/**
|
||||
* 还原配件分堆数量
|
||||
*
|
||||
* @param list 同一查询范围的order_parts id相同的orderitem列表
|
||||
*/
|
||||
private void restoreGroup(List<OrderItemDO> list) {
|
||||
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
List<OrderItemDO> updateList = new ArrayList<>();
|
||||
List<OrderItemDO> insertList = new ArrayList<>();
|
||||
|
||||
// 1️⃣ 先处理子 item(sourceId != 0)
|
||||
List<OrderItemDO> subItems = list.stream()
|
||||
.filter(i -> ObjectUtil.notEqual(0L, i.getSourceId())
|
||||
&& i.getHeapSplitStatus() == 1)
|
||||
.toList();
|
||||
for (OrderItemDO item : subItems) {
|
||||
Map<Long, List<OrderItemDO>> groupMap = list.stream()
|
||||
.collect(Collectors.groupingBy(i ->
|
||||
ObjectUtil.equals(0L, i.getSourceId()) ? i.getId() : i.getSourceId()
|
||||
));
|
||||
|
||||
if (remain <= 0) break;
|
||||
for (Map.Entry<Long, List<OrderItemDO>> entry : groupMap.entrySet()) {
|
||||
|
||||
double heap = Optional.ofNullable(item.getHeapNum()).orElse(0.0);
|
||||
if (heap <= 0) continue;
|
||||
List<OrderItemDO> items = entry.getValue();
|
||||
|
||||
double toRestore = Math.min(heap, remain);
|
||||
// 找父
|
||||
OrderItemDO parent = items.stream()
|
||||
.filter(i -> ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new ServiceException(new ErrorCode(10001, "未找到父节点")));
|
||||
|
||||
OrderItemDO origin = originMap.get(item.getSourceId());
|
||||
if (origin == null) {
|
||||
throw new ServiceException(new ErrorCode(10002, "找不到来源原 item"));
|
||||
}
|
||||
// 找子
|
||||
List<OrderItemDO> subItems = items.stream()
|
||||
.filter(i -> !ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.toList();
|
||||
|
||||
// 🔥 从 origin.heapNum 扣减
|
||||
double originHeap = Optional.ofNullable(origin.getHeapNum()).orElse(0.0);
|
||||
origin.setHeapNum(originHeap - toRestore);
|
||||
double parentHeap = Optional.ofNullable(parent.getHeapNum()).orElse(0.0);
|
||||
double subTotal = subItems.stream()
|
||||
.mapToDouble(i -> Optional.ofNullable(i.getHeapNum()).orElse(0.0))
|
||||
.sum();
|
||||
|
||||
if (origin.getHeapNum() <= 0) {
|
||||
origin.setHeapNum(0.0);
|
||||
origin.setHeapSplitStatus(0);
|
||||
}
|
||||
|
||||
updateList.add(origin);
|
||||
if (CollUtil.isNotEmpty(subItems)) {
|
||||
// 有子
|
||||
if (ObjectUtil.equals(parent.getHeapSplitStatus(), HeapSplitStatusEnum.YES.getStatus())) {
|
||||
// 父本身已分堆,则降级成子
|
||||
parent.setSourceId(parent.getId());
|
||||
updateList.add(parent);
|
||||
|
||||
// 增加一个父,数量是 num-原来的父的已分堆heapNum=现在
|
||||
OrderItemDO newBase = new OrderItemDO();
|
||||
BeanUtil.copyProperties(parent, newBase);
|
||||
|
||||
newBase.setId(null);
|
||||
newBase.setSourceId(0L);
|
||||
newBase.setHeapNum(parent.getNum() - subTotal);
|
||||
newBase.setHeapSplitStatus(HeapSplitStatusEnum.NO.getStatus());
|
||||
insertList.add(newBase);
|
||||
|
||||
} else {
|
||||
// 本身没分堆,把父的子heapNum扣掉
|
||||
parent.setHeapNum(parentHeap - subTotal);
|
||||
updateList.add(parent);
|
||||
}
|
||||
|
||||
// 删除原来的子
|
||||
deleteIds.addAll(subItems.stream().map(OrderItemDO::getId).toList());
|
||||
|
||||
// 子 item处理
|
||||
if (toRestore == heap) {
|
||||
// 全扣 → 删除
|
||||
deleteIds.add(item.getId());
|
||||
} else {
|
||||
// 部分扣 → 更新剩余
|
||||
item.setHeapNum(heap - toRestore);
|
||||
updateList.add(item);
|
||||
// 没有子,分堆了就还原数
|
||||
if (ObjectUtil.equals(parent.getHeapSplitStatus(), HeapSplitStatusEnum.YES.getStatus())) {
|
||||
parent.setHeapNum(0.0);
|
||||
parent.setHeapSplitStatus(HeapSplitStatusEnum.NO.getStatus());
|
||||
updateList.add(parent);
|
||||
}
|
||||
}
|
||||
|
||||
remain -= toRestore;
|
||||
}
|
||||
|
||||
// 2️⃣ 再处理原 item(剩余的 heapNum)
|
||||
List<OrderItemDO> originItems = originMap.values().stream()
|
||||
.filter(i -> i.getHeapSplitStatus() == 1)
|
||||
.toList();
|
||||
|
||||
for (OrderItemDO item : originItems) {
|
||||
|
||||
if (remain <= 0) break;
|
||||
|
||||
double heap = Optional.ofNullable(item.getHeapNum()).orElse(0.0);
|
||||
if (heap <= 0) continue;
|
||||
|
||||
double toRestore = Math.min(heap, remain);
|
||||
|
||||
item.setHeapNum(heap - toRestore);
|
||||
|
||||
if (item.getHeapNum() <= 0) {
|
||||
item.setHeapNum(0.0);
|
||||
item.setHeapSplitStatus(0);
|
||||
}
|
||||
|
||||
updateList.add(item);
|
||||
|
||||
remain -= toRestore;
|
||||
}
|
||||
|
||||
// 3️⃣ 校验
|
||||
if (remain > 0) {
|
||||
throw new ServiceException(new ErrorCode(10003, "还原失败,数量不足,剩余:" + remain));
|
||||
}
|
||||
|
||||
// 4️⃣ 批量执行
|
||||
// 执行数据库操作
|
||||
if (!updateList.isEmpty()) {
|
||||
orderItemMapper.updateBatch(updateList);
|
||||
}
|
||||
|
||||
if (!insertList.isEmpty()) {
|
||||
orderItemMapper.insertBatch(insertList);
|
||||
}
|
||||
if (!deleteIds.isEmpty()) {
|
||||
orderItemMapper.deleteByIds(deleteIds);
|
||||
}
|
||||
|
||||
+14
-27
@@ -30,24 +30,6 @@ public interface PackService {
|
||||
// 查看生产订单对应的板材信息
|
||||
List<PlateDetailsRespVO> getOrderPlateList(Long orderId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单列表中未打包的板件
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
List<PlateDetailsRespVO> getOrdersPackPlateList(List<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 查询订单列表中未打包的配件
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
List<OrderPartsRespVO> getOrdersPackPartsList(List<Long> orderIds);
|
||||
|
||||
|
||||
/**
|
||||
* 拆包
|
||||
*
|
||||
@@ -70,8 +52,11 @@ public interface PackService {
|
||||
List<OrderPackRespVO> selectPack(Long orderId);
|
||||
|
||||
|
||||
|
||||
// 删除包裹及其关联的包裹信息(删除全部)
|
||||
/**
|
||||
* 删除包裹
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
void deleteOrderPack(PackReqVO reqVO);
|
||||
|
||||
|
||||
@@ -94,12 +79,6 @@ public interface PackService {
|
||||
// 查询预打包优化信息
|
||||
String getPrePackInfo(Long orderId);
|
||||
|
||||
/**
|
||||
* 校验打包状态:已打包的不允许扫描关联
|
||||
* @param orderId
|
||||
*/
|
||||
void validOrderPackageStatus(Long orderId);
|
||||
|
||||
/**
|
||||
* 获取部件关联板件和配件id
|
||||
*
|
||||
@@ -122,5 +101,13 @@ public interface PackService {
|
||||
* @param packageNo
|
||||
* @return
|
||||
*/
|
||||
List<PackageDetailsRespVO> getPackageDetails(String packageNo);
|
||||
List<PackageDetailsRespVO> getOrdersPackageDetails(String packageNo);
|
||||
|
||||
/**
|
||||
* 获取包裹板件、配件详情
|
||||
*
|
||||
* @param packageNo
|
||||
* @return
|
||||
*/
|
||||
List<PackageDetailsRespVO> getOrderPackageDetails(Long orderId, String packageNo);
|
||||
}
|
||||
|
||||
+245
-310
@@ -2,8 +2,8 @@ package com.cf.imes.module.executor.service.manage.pack;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -16,7 +16,7 @@ import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
|
||||
import com.cf.imes.framework.mybatis.core.query.QueryWrapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.executor.api.plan.OrderPlanApi;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.*;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.OrderPackageVO;
|
||||
@@ -35,6 +35,7 @@ import com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPackageNewMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPrepackagedMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import com.cf.imes.module.executor.enums.pack.PackScanComponentCorrelationTypeEnum;
|
||||
import com.cf.imes.module.executor.service.order.OrderService;
|
||||
import com.cf.imes.module.executor.service.orderParts.OrderPartsService;
|
||||
@@ -57,7 +58,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.util.string.SearchUtil.insertSeparator;
|
||||
@@ -65,12 +65,12 @@ import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.ge
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.NO_PRODUCTION_ORDER_INFORMATION_AVAILABLE;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_ALREADY_PACKAGED;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_DATE_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NO_DATA_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PACK_DATA_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PACK_DATA_NULL_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PACK_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PARTS_NOT_EXISTS;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PARTS_PACK_ITEM_SOURCE_NOT_EXISTS;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PARTS_PACK_NUM_NOT_ENOUGH;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PART_PACK_DATA_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLATE_NOT_EXISTS;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.THE_CURRENT_PACKAGE_TYPE_IS_INCORRECT;
|
||||
@@ -176,35 +176,6 @@ public class PackServiceImpl implements PackService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlateDetailsRespVO> getOrdersPackPlateList(List<Long> orderIds) {
|
||||
|
||||
List<PlateDetailsRespVO> plateDetailsRespVOS = orderPlateMapper.selectOrdersPackPlateList(orderIds);
|
||||
|
||||
if (plateDetailsRespVOS.isEmpty()) {
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return plateDetailsRespVOS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderPartsRespVO> getOrdersPackPartsList(List<Long> orderIds) {
|
||||
|
||||
List<OrderPartsRespVO> orderPartsRespVOS = orderPartsMapper.selectOrdersPartsList(orderIds);
|
||||
|
||||
if (orderPartsRespVOS.isEmpty()) {
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return orderPartsRespVOS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderPackageVO> getOrderPack(PackageDetailsReqVO reqVO) {
|
||||
@@ -229,13 +200,14 @@ public class PackServiceImpl implements PackService {
|
||||
@Override
|
||||
public PageResult<OrderPackageVO> getPageOrderPack(PackageDetailsReqVO reqVO) {
|
||||
|
||||
PageDTO<OrderPackageVO> page = new PageDTO<>(reqVO.getPageNo(), reqVO.getPageSize());
|
||||
PageDTO<OrderPackagDONew> page = new PageDTO<>(reqVO.getPageNo(), reqVO.getPageSize());
|
||||
|
||||
List<Long> packId = null;
|
||||
|
||||
Long orderId = Long.valueOf(reqVO.getOrderId());
|
||||
|
||||
if (reqVO.getPlateNo() != null) {
|
||||
String packageNo = reqVO.getPackageNo();
|
||||
if (CharSequenceUtil.isNotEmpty(packageNo)) {
|
||||
|
||||
List<Long> plateId = orderPlateMapper.selectplateByPlateNoList(reqVO.getPlateNo(), orderId, getUserOrganId())
|
||||
.stream().map(PlateDO::getId).toList();
|
||||
@@ -244,32 +216,25 @@ public class PackServiceImpl implements PackService {
|
||||
return null;
|
||||
}
|
||||
|
||||
packId = orderItemMapper.selectPackByPlateId(plateId,orderId ,getUserOrganId()).stream().map(OrderItemDO::getPackageId).distinct().toList();
|
||||
packId = orderItemMapper.selectPackByPlateId(plateId, orderId, getUserOrganId()).stream().map(OrderItemDO::getPackageId).distinct().toList();
|
||||
|
||||
}
|
||||
|
||||
IPage<OrderPackagDONew> orderPackagDONews = orderPackageNewMapper.selectPage(page, new LambdaQueryWrapperX<OrderPackagDONew>()
|
||||
.eq(OrderPackagDONew::getOrderId, orderId)
|
||||
.likeIfPresent(OrderPackagDONew::getPackageNo, packageNo)
|
||||
.eqIfPresent(OrderPackagDONew::getPackageNo, packId)
|
||||
.eqIfPresent(OrderPackagDONew::getStatus, reqVO.getPackStatus())
|
||||
.orderByDesc(OrderPackagDONew::getCreateTime)
|
||||
);
|
||||
|
||||
QueryWrapperX<OrderPackageDO> queryWrapperX = new QueryWrapperX<>();
|
||||
queryWrapperX
|
||||
.eq("o.organ_id", getUserOrganId())
|
||||
.eq("o.deleted", false)
|
||||
.eq("o.id", reqVO.getOrderId())
|
||||
.eq("op.deleted", false)
|
||||
.likeIfPresent("op.package_no", reqVO.getPackageNo())
|
||||
.inIfPresent("op.id", packId)
|
||||
.eqIfPresent("op.status", reqVO.getPackStatus())
|
||||
.orderByDesc("op.create_time");
|
||||
|
||||
|
||||
IPage<OrderPackageVO> orderPackageDOIPage = orderPackageMapper.selectByOrderNo(page, queryWrapperX);
|
||||
|
||||
|
||||
if (CollUtil.isEmpty(orderPackageDOIPage.getRecords())) {
|
||||
List<OrderPackagDONew> records = orderPackagDONews.getRecords();
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
|
||||
return new PageResult<>(orderPackageDOIPage.getRecords(), orderPackageDOIPage.getTotal());
|
||||
return new PageResult<>(BeanUtil.copyToList(records, OrderPackageVO.class), orderPackagDONews.getTotal());
|
||||
|
||||
}
|
||||
|
||||
@@ -305,30 +270,7 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
ordersMapper.updateById(orderDO);
|
||||
}
|
||||
// OrderPackageDO packageDO = orderPackageMapper.selectById(packageID);
|
||||
//
|
||||
// AssertUtils.notEmpty(packageDO, ORDER_PACK_DATA_NULL_ERROR);
|
||||
//
|
||||
// Long orderId = packageDO.getOrderId();
|
||||
//
|
||||
// OrderDO orderDO = ordersMapper.selectById(orderId);
|
||||
//
|
||||
// AssertUtils.notEmpty(orderDO, ORDER_NO_DATA_ERROR);
|
||||
//
|
||||
// orderDO.setPackaged(OrderPackageStatusEnum.UNPACKED.getStatus());
|
||||
//
|
||||
// if(orderDO.getStatus().equals(OrderStatusEnum.FINISH_PRODUCTION.getStatus())){
|
||||
// orderDO.setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus());
|
||||
// orderDO.setFinishTime(null);
|
||||
// }
|
||||
//
|
||||
// ordersMapper.updateById(orderDO);
|
||||
//
|
||||
// packageDO.setStatus(OrderPackageStatusEnum.UNPACKED.getStatus());
|
||||
// orderPackageMapper.updateById(packageDO);
|
||||
return typeConversion(orderPackagDONews.get(0), orderIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -368,54 +310,7 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
// 配件明细新增包裹 ID
|
||||
if (CollUtil.isNotEmpty(addPartsList)) {
|
||||
// 1️⃣ 根据 packMethod 决定分组 key
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
addPartsList.stream().collect(Collectors.groupingBy(item -> {
|
||||
if (packMethod == 1) {
|
||||
return item.getBodyId();
|
||||
} else if (packMethod == 0) {
|
||||
return item.getRoomId();
|
||||
} else if (packMethod == 2) {
|
||||
return item.getOrderId();
|
||||
}
|
||||
return 0L;
|
||||
}));
|
||||
|
||||
// 2️⃣ 分组处理
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
|
||||
Long groupKey = entry.getKey();
|
||||
List<PackagePartsSaveReqVO> partsList = entry.getValue();
|
||||
|
||||
for (PackagePartsSaveReqVO partsSaveReqVO : partsList) {
|
||||
|
||||
Long partsId = partsSaveReqVO.getPartsId();
|
||||
Integer num = partsSaveReqVO.getNum();
|
||||
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.eq(OrderItemDO::getPartsId, partsId)
|
||||
|
||||
.eq(OrderItemDO::getPackageId, 0);
|
||||
|
||||
// 3️⃣ 根据 packMethod 动态加条件
|
||||
if (packMethod == 0) {
|
||||
wrapper.eq(OrderItemDO::getRoomId, groupKey).in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (packMethod == 1) {
|
||||
wrapper.eq(OrderItemDO::getBodyId, groupKey).in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (packMethod == 2) {
|
||||
wrapper.eq(OrderItemDO::getOrderId, groupKey);
|
||||
}
|
||||
|
||||
wrapper.orderByAsc(OrderItemDO::getNum);
|
||||
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(wrapper);
|
||||
|
||||
allocateSingleGroup(orderItemDOS, packageNo, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
processParts(addPartsList, packMethod, orderIds, packageNo, true);
|
||||
|
||||
// 更新订单打包状态
|
||||
for (Long orderId : orderIds) {
|
||||
@@ -444,31 +339,6 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
}
|
||||
|
||||
// 配件明细新增包裹 ID
|
||||
if (CollUtil.isNotEmpty(addPartsList)) {
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
addPartsList.stream().collect(Collectors.groupingBy(PackagePartsSaveReqVO::getBodyId));
|
||||
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
Long bodyId = entry.getKey();
|
||||
List<PackagePartsSaveReqVO> partsList = entry.getValue();
|
||||
|
||||
for (PackagePartsSaveReqVO partsSaveReqVO : partsList) {
|
||||
Long partsId = partsSaveReqVO.getPartsId();
|
||||
Integer num = partsSaveReqVO.getNum();
|
||||
// partsId下的所有明细,基于num正序,优先打包数量小的
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getPartsId, partsId)
|
||||
.in(OrderItemDO::getOrderId, orderIds)
|
||||
.eq(OrderItemDO::getBodyId, bodyId)
|
||||
.eq(OrderItemDO::getPackageId, 0)
|
||||
.orderByAsc(OrderItemDO::getNum));
|
||||
|
||||
allocateSingleGroup(orderItemDOS, existPackageNo, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 板件明细移除包裹 ID
|
||||
List<List<Long>> split3 = CollUtil.split(deletePlateIdList, 1000);
|
||||
if (CollUtil.isNotEmpty(split3)) {
|
||||
@@ -478,55 +348,10 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
// 配件明细移除包裹 ID
|
||||
if (CollUtil.isNotEmpty(delPartsList)) {
|
||||
processParts(delPartsList, packMethod, orderIds, existPackageNo, false);
|
||||
|
||||
// 1️⃣ 按 packMethod 分组
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
delPartsList.stream().collect(Collectors.groupingBy(item -> {
|
||||
if (packMethod == 1) {
|
||||
return item.getBodyId();
|
||||
} else if (packMethod == 0) {
|
||||
return item.getRoomId();
|
||||
} else if (packMethod == 2) {
|
||||
return item.getOrderId();
|
||||
}
|
||||
return 0L;
|
||||
}));
|
||||
|
||||
// 2️⃣ 分组处理
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
|
||||
Long groupKey = entry.getKey();
|
||||
List<PackagePartsSaveReqVO> partsList = entry.getValue();
|
||||
|
||||
for (PackagePartsSaveReqVO partsSaveReqVO : partsList) {
|
||||
|
||||
Long partsId = partsSaveReqVO.getPartsId();
|
||||
Integer num = partsSaveReqVO.getNum();
|
||||
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.eq(OrderItemDO::getPartsId, partsId)
|
||||
.eq(OrderItemDO::getPackageId, existPackageNo);
|
||||
|
||||
// 3️⃣ 根据 packMethod 加条件
|
||||
if (packMethod == 0) {
|
||||
wrapper.eq(OrderItemDO::getRoomId, groupKey).in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (packMethod == 1) {
|
||||
wrapper.eq(OrderItemDO::getBodyId, groupKey).in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (packMethod == 2) {
|
||||
wrapper.eq(OrderItemDO::getOrderId, groupKey);
|
||||
}
|
||||
|
||||
// 4️⃣ 排序(小的先还原 ✔)
|
||||
wrapper.orderByAsc(OrderItemDO::getNum);
|
||||
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(wrapper);
|
||||
|
||||
restoreGroup(orderItemDOS, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 配件明细新增包裹 ID
|
||||
processParts(addPartsList, packMethod, orderIds, existPackageNo, true);
|
||||
|
||||
// 更新封包状态
|
||||
orderPackageNewMapper.update(new LambdaUpdateWrapper<OrderPackagDONew>()
|
||||
@@ -550,101 +375,203 @@ public class PackServiceImpl implements PackService {
|
||||
|
||||
}
|
||||
|
||||
private void restoreGroup(List<OrderItemDO> list, int targetNum) {
|
||||
int remain = targetNum;
|
||||
/**
|
||||
* 分组规则
|
||||
* @param item
|
||||
* @param packMethod
|
||||
* @return
|
||||
*/
|
||||
private Long getGroupKey(PackagePartsSaveReqVO item, Integer packMethod) {
|
||||
if (ObjectUtil.equals(OrderPackageMethodEnum.ROOM_NAME.getMethod(), packMethod)) {
|
||||
return item.getRoomId();
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.BODY_NAME.getMethod(), packMethod)) {
|
||||
return item.getBodyId();
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.ORDER.getMethod(), packMethod)) {
|
||||
return item.getOrderId();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
Map<Long, OrderItemDO> originMap = list.stream()
|
||||
.filter(i -> ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.collect(Collectors.toMap(OrderItemDO::getId, Function.identity()));
|
||||
/**
|
||||
* 动态构建查询wrapper
|
||||
*
|
||||
* @param groupKey
|
||||
* @param partsId
|
||||
* @param packMethod
|
||||
* @param orderIds
|
||||
* @param packageNo
|
||||
* @param isAdd
|
||||
* @return
|
||||
*/
|
||||
private LambdaQueryWrapper<OrderItemDO> buildWrapper(
|
||||
Long groupKey,
|
||||
Long partsId,
|
||||
Integer packMethod,
|
||||
List<Long> orderIds,
|
||||
String packageNo,
|
||||
boolean isAdd) {
|
||||
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
List<OrderItemDO> updateList = new ArrayList<>();
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 1️⃣ 先处理子 item(sourceId != 0)
|
||||
List<OrderItemDO> subItems = list.stream()
|
||||
.filter(i -> ObjectUtil.notEqual(0L, i.getSourceId())
|
||||
&& i.getPackageId() != 0L)
|
||||
.collect(Collectors.toList());
|
||||
for (OrderItemDO item : subItems) {
|
||||
wrapper.eq(OrderItemDO::getPartsId, partsId);
|
||||
|
||||
if (remain <= 0) break;
|
||||
|
||||
double pack = Optional.ofNullable(item.getPackNum()).orElse(0.0);
|
||||
if (pack <= 0) continue;
|
||||
|
||||
double toRestore = Math.min(pack, remain);
|
||||
|
||||
OrderItemDO origin = originMap.get(item.getSourceId());
|
||||
if (origin == null) {
|
||||
throw new ServiceException(new ErrorCode(10002, "找不到来源原 item"));
|
||||
}
|
||||
|
||||
// 🔥 从 origin.packNum 扣减
|
||||
double originPack = Optional.ofNullable(origin.getPackNum()).orElse(0.0);
|
||||
origin.setPackNum(originPack - toRestore);
|
||||
|
||||
if (origin.getPackNum() <= 0) {
|
||||
origin.setPackNum(0.0);
|
||||
origin.setPackageId(0L);
|
||||
}
|
||||
|
||||
updateList.add(origin);
|
||||
|
||||
// 子 item处理
|
||||
if (toRestore == pack) {
|
||||
// 全扣 → 删除
|
||||
deleteIds.add(item.getId());
|
||||
} else {
|
||||
// 部分扣 → 更新剩余
|
||||
item.setPackNum(pack - toRestore);
|
||||
updateList.add(item);
|
||||
}
|
||||
|
||||
remain -= toRestore;
|
||||
if (isAdd) {
|
||||
// 新增要查的是没打包的
|
||||
wrapper.eq(OrderItemDO::getPackageId, 0L);
|
||||
} else {
|
||||
// 删除看的是已打包的
|
||||
wrapper.eq(OrderItemDO::getPackageId, packageNo);
|
||||
}
|
||||
|
||||
// 2️⃣ 再处理原 item(剩余的 packNum)
|
||||
List<OrderItemDO> originItems = originMap.values().stream()
|
||||
.filter(i -> i.getPackageId() != 0L)
|
||||
.collect(Collectors.toList());
|
||||
if (ObjectUtil.equals(OrderPackageMethodEnum.ROOM_NAME.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getRoomId, groupKey)
|
||||
.in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.BODY_NAME.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getBodyId, groupKey)
|
||||
.in(OrderItemDO::getOrderId, orderIds);
|
||||
} else if (ObjectUtil.equals(OrderPackageMethodEnum.ORDER.getMethod(), packMethod)) {
|
||||
wrapper.eq(OrderItemDO::getOrderId, groupKey);
|
||||
}
|
||||
|
||||
for (OrderItemDO item : originItems) {
|
||||
wrapper.orderByAsc(OrderItemDO::getNum);
|
||||
|
||||
if (remain <= 0) break;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
double pack = Optional.ofNullable(item.getPackNum()).orElse(0.0);
|
||||
if (pack <= 0) continue;
|
||||
/**
|
||||
* 配件打包数量处理
|
||||
*
|
||||
* @param partsList
|
||||
* @param packMethod
|
||||
* @param orderIds
|
||||
* @param packageId
|
||||
* @param isAdd
|
||||
*/
|
||||
private void processParts(List<PackagePartsSaveReqVO> partsList,
|
||||
Integer packMethod,
|
||||
List<Long> orderIds,
|
||||
String packageId,
|
||||
boolean isAdd) {
|
||||
|
||||
double toRestore = Math.min(pack, remain);
|
||||
if (CollUtil.isEmpty(partsList)) return;
|
||||
|
||||
item.setPackNum(pack - toRestore);
|
||||
// 分组
|
||||
Map<Long, List<PackagePartsSaveReqVO>> groupMap =
|
||||
partsList.stream().collect(Collectors.groupingBy(item -> getGroupKey(item, packMethod)));
|
||||
|
||||
if (item.getPackNum() <= 0) {
|
||||
item.setPackNum(0.0);
|
||||
item.setPackageId(0L);
|
||||
for (Map.Entry<Long, List<PackagePartsSaveReqVO>> entry : groupMap.entrySet()) {
|
||||
|
||||
Long groupKey = entry.getKey();
|
||||
|
||||
for (PackagePartsSaveReqVO vo : entry.getValue()) {
|
||||
|
||||
LambdaQueryWrapper<OrderItemDO> wrapper =
|
||||
buildWrapper(groupKey, vo.getPartsId(), packMethod, orderIds, packageId, isAdd);
|
||||
|
||||
List<OrderItemDO> list = orderItemMapper.selectList(wrapper);
|
||||
|
||||
if (isAdd) {
|
||||
// 分配打包数量
|
||||
allocateGroup(list, packageId, vo.getNum());
|
||||
} else {
|
||||
// 还原打包数量
|
||||
restoreGroup(list);
|
||||
}
|
||||
}
|
||||
|
||||
updateList.add(item);
|
||||
|
||||
remain -= toRestore;
|
||||
}
|
||||
|
||||
// 3️⃣ 校验
|
||||
if (remain > 0) {
|
||||
throw new ServiceException(new ErrorCode(10003, "还原失败,数量不足,剩余:" + remain));
|
||||
}
|
||||
|
||||
// 4️⃣ 批量执行
|
||||
if (!updateList.isEmpty()) {
|
||||
orderItemMapper.updateBatch(updateList);
|
||||
}
|
||||
|
||||
if (!deleteIds.isEmpty()) {
|
||||
orderItemMapper.deleteBatchIds(deleteIds);
|
||||
}
|
||||
}
|
||||
|
||||
private void allocateSingleGroup(List<OrderItemDO> list, String packNo, int targetNum) {
|
||||
/**
|
||||
* 还原配件打包数量
|
||||
*
|
||||
* @param list 同一查询范围的order_parts id相同的orderitem列表
|
||||
*/
|
||||
private void restoreGroup(List<OrderItemDO> list) {
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
List<OrderItemDO> updateList = new ArrayList<>();
|
||||
List<OrderItemDO> insertList = new ArrayList<>();
|
||||
|
||||
Map<Long, List<OrderItemDO>> groupMap = list.stream()
|
||||
.collect(Collectors.groupingBy(i ->
|
||||
ObjectUtil.equals(0L, i.getSourceId()) ? i.getId() : i.getSourceId()
|
||||
));
|
||||
|
||||
for (Map.Entry<Long, List<OrderItemDO>> entry : groupMap.entrySet()) {
|
||||
|
||||
List<OrderItemDO> items = entry.getValue();
|
||||
|
||||
// 找父
|
||||
OrderItemDO parent = items.stream()
|
||||
.filter(i -> ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new ServiceException(PARTS_PACK_ITEM_SOURCE_NOT_EXISTS));
|
||||
|
||||
// 找子
|
||||
List<OrderItemDO> subItems = items.stream()
|
||||
.filter(i -> !ObjectUtil.equals(0L, i.getSourceId()))
|
||||
.toList();
|
||||
|
||||
double parentPack = Optional.ofNullable(parent.getPackNum()).orElse(0.0);
|
||||
double subTotal = subItems.stream()
|
||||
.mapToDouble(i -> Optional.ofNullable(i.getPackNum()).orElse(0.0))
|
||||
.sum();
|
||||
|
||||
if (CollUtil.isNotEmpty(subItems)) {
|
||||
// 有子
|
||||
if (ObjectUtil.notEqual(parent.getPackageId(), 0L)) {
|
||||
// 父本身已打包,则降级成子
|
||||
parent.setSourceId(parent.getId());
|
||||
updateList.add(parent);
|
||||
|
||||
// 增加一个父,数量是 num-原来的父的已打包packNum=现在
|
||||
OrderItemDO newBase = new OrderItemDO();
|
||||
BeanUtil.copyProperties(parent, newBase);
|
||||
|
||||
newBase.setId(null);
|
||||
newBase.setSourceId(0L);
|
||||
newBase.setPackNum(parent.getNum() - subTotal);
|
||||
newBase.setPackageId(0L);
|
||||
insertList.add(newBase);
|
||||
|
||||
} else {
|
||||
// 本身没打包,把父-子packNum扣掉
|
||||
parent.setPackNum(parentPack - subTotal);
|
||||
updateList.add(parent);
|
||||
}
|
||||
|
||||
// 删除原来的子
|
||||
deleteIds.addAll(subItems.stream().map(OrderItemDO::getId).toList());
|
||||
|
||||
} else {
|
||||
// 没有子,打包了就还原数
|
||||
if (ObjectUtil.notEqual(parent.getPackageId(), 0L)) {
|
||||
parent.setPackNum(0.0);
|
||||
parent.setPackageId(0L);
|
||||
updateList.add(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 执行数据库操作
|
||||
if (!updateList.isEmpty()) {
|
||||
orderItemMapper.updateBatch(updateList);
|
||||
}
|
||||
if (!insertList.isEmpty()) {
|
||||
orderItemMapper.insertBatch(insertList);
|
||||
}
|
||||
if (!deleteIds.isEmpty()) {
|
||||
orderItemMapper.deleteByIds(deleteIds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配打包数量
|
||||
*
|
||||
* @param list 同一查询范围的order_parts id相同的orderitem列表
|
||||
* @param packNo 包裹编号
|
||||
* @param targetNum 分配目标数
|
||||
*/
|
||||
private void allocateGroup(List<OrderItemDO> list, String packNo, int targetNum) {
|
||||
|
||||
int remain = targetNum;
|
||||
|
||||
@@ -654,9 +581,7 @@ public class PackServiceImpl implements PackService {
|
||||
break;
|
||||
}
|
||||
|
||||
double current = Optional.ofNullable(item.getPackNum())
|
||||
.filter(v -> v > 0)
|
||||
.orElse(Optional.ofNullable(item.getNum()).orElse(0.0));
|
||||
double current = item.getNum() - item.getPackNum();
|
||||
if (current <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -678,8 +603,8 @@ public class PackServiceImpl implements PackService {
|
||||
// 情况2:> 需要拆分
|
||||
else {
|
||||
|
||||
// 原记录扣减
|
||||
item.setPackNum(current - remain);
|
||||
// 原记录累加打包数量
|
||||
item.setPackNum(item.getPackNum() + remain);
|
||||
orderItemMapper.updateById(item);
|
||||
|
||||
// 新建分堆记录
|
||||
@@ -692,10 +617,18 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
if (remain > 0) {
|
||||
throw new ServiceException(new ErrorCode(10001, "数量不足,剩余未分配:" + remain));
|
||||
throw new ServiceException(PARTS_PACK_NUM_NOT_ENOUGH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包未全覆盖创建item副本
|
||||
*
|
||||
* @param source
|
||||
* @param packNo
|
||||
* @param packNum
|
||||
* @return
|
||||
*/
|
||||
private OrderItemDO buildPackItem(OrderItemDO source, String packNo, double packNum) {
|
||||
OrderItemDO newItem = new OrderItemDO();
|
||||
|
||||
@@ -767,8 +700,6 @@ public class PackServiceImpl implements PackService {
|
||||
|
||||
|
||||
|
||||
|
||||
// 删除包裹及其关联的包裹信息(删除全部)
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteOrderPack(PackReqVO reqVO) {
|
||||
@@ -784,9 +715,8 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
// 如果有未拆包的提示先拆包
|
||||
if (orderPackagDOS.stream().anyMatch(o -> o.getStatus() == OrderPackageStatusEnum.PACKAGED.getStatus())) {
|
||||
// todo 异常提示
|
||||
throw new ServiceException(new ErrorCode(10001, "请先拆包"));
|
||||
if (orderPackagDOS.stream().anyMatch(o -> ObjectUtil.equals(OrderPackageStatusEnum.PACKAGED.getStatus(), o.getStatus()))) {
|
||||
throw new ServiceException(ORDER_ALREADY_PACKAGED);
|
||||
}
|
||||
// 整理出该包裹对应的订单id列表
|
||||
List<Long> packOrderIds = orderPackagDOS.stream()
|
||||
@@ -834,7 +764,7 @@ public class PackServiceImpl implements PackService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1️⃣ 找基准 item(source = true)
|
||||
// 1、找基准 item(source = true)
|
||||
OrderItemDO baseItem = partItemDOS.stream()
|
||||
.filter(i -> ObjectUtil.equals(entry.getKey(), i.getId()))
|
||||
.findFirst()
|
||||
@@ -846,7 +776,7 @@ public class PackServiceImpl implements PackService {
|
||||
double basePack = Optional.ofNullable(baseItem.getPackNum()).orElse(0.0);
|
||||
double sumOthers = 0.0;
|
||||
|
||||
// 2️⃣ 累加其他 item
|
||||
// 2、累加其他 item
|
||||
for (OrderItemDO item : list) {
|
||||
|
||||
if (item.getId().equals(baseItem.getId())) continue;
|
||||
@@ -855,12 +785,12 @@ public class PackServiceImpl implements PackService {
|
||||
deleteIds.add(item.getId());
|
||||
}
|
||||
|
||||
// ✅ 情况1:未打包 → 正常合并
|
||||
// 情况1:未打包 → 正常合并
|
||||
if (!basePacked) {
|
||||
baseItem.setPackNum(basePack + sumOthers);
|
||||
baseItem.setPackNum(basePack - sumOthers);
|
||||
updateList.add(baseItem);
|
||||
}
|
||||
// ✅ 情况2:已打包 → 拆分新基准
|
||||
// 情况2:已打包 → 拆分新基准
|
||||
else {
|
||||
// ① 原基准降级
|
||||
baseItem.setSourceId(baseItem.getId());
|
||||
@@ -872,8 +802,8 @@ public class PackServiceImpl implements PackService {
|
||||
|
||||
newBase.setId(null);
|
||||
newBase.setSourceId(0L);
|
||||
newBase.setPackageId(0L); // ❗新基准一定是未打包
|
||||
newBase.setPackNum(sumOthers);
|
||||
newBase.setPackageId(0L); // 新基准一定是未打包
|
||||
newBase.setPackNum(baseItem.getNum() - sumOthers);
|
||||
|
||||
insertList.add(newBase);
|
||||
}
|
||||
@@ -889,7 +819,7 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
if (!deleteIds.isEmpty()) {
|
||||
orderItemMapper.deleteBatchIds(deleteIds);
|
||||
orderItemMapper.deleteByIds(deleteIds);
|
||||
}
|
||||
}
|
||||
// 移除配件的打包状态
|
||||
@@ -1064,7 +994,7 @@ public class PackServiceImpl implements PackService {
|
||||
List<OrderDO> orderDO = ordersMapper.selectByIds(orderIds);
|
||||
AssertUtils.notEmpty(orderDO, ORDER_PACK_ERROR);
|
||||
|
||||
if (StrUtil.isNotEmpty(packNo)) {
|
||||
if (CharSequenceUtil.isNotEmpty(packNo)) {
|
||||
List<OrderPackagDONew> orderPackageDOS = orderPackageNewMapper.selectList(new LambdaQueryWrapper<OrderPackagDONew>()
|
||||
.eq(OrderPackagDONew::getPackageNo, packNo));
|
||||
AssertUtils.notEmpty(orderPackageDOS, ORDER_PACK_DATA_ERROR);
|
||||
@@ -1077,11 +1007,9 @@ public class PackServiceImpl implements PackService {
|
||||
// 类型转换
|
||||
private OrderPackRespVO typeConversion(OrderPackageDO orderPackageDO) {
|
||||
return OrderPackRespVO.builder()
|
||||
// .id(orderPackageDO.getId())
|
||||
.orderId(orderPackageDO.getOrderId())
|
||||
.organId(orderPackageDO.getOrganId())
|
||||
.packageNo(orderPackageDO.getPackageNo())
|
||||
.packageType(orderPackageDO.getType())
|
||||
.name(orderPackageDO.getName())
|
||||
.status(orderPackageDO.getStatus())
|
||||
.remark(orderPackageDO.getRemark())
|
||||
@@ -1209,16 +1137,6 @@ public class PackServiceImpl implements PackService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validOrderPackageStatus(Long orderId) {
|
||||
OrderDO order = orderService.getOrder(orderId);
|
||||
AssertUtils.notEmpty(order, ORDER_NOT_EXISTS);
|
||||
|
||||
// 已经打包的提示
|
||||
Integer packaged = order.getPackaged();
|
||||
AssertUtils.equals(OrderPackageStatusEnum.PACKAGED.getStatus(), packaged, ORDER_ALREADY_PACKAGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getComponentCorrelation(PackScanComponentCorrelationReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
@@ -1285,7 +1203,7 @@ public class PackServiceImpl implements PackService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PackageDetailsRespVO> getPackageDetails(String packageNo) {
|
||||
public List<PackageDetailsRespVO> getOrdersPackageDetails(String packageNo) {
|
||||
List<OrderPackagDONew> orderPackagDONews = orderPackageNewMapper.selectList(new LambdaQueryWrapper<OrderPackagDONew>()
|
||||
.eq(OrderPackagDONew::getPackageNo, packageNo));
|
||||
|
||||
@@ -1298,4 +1216,21 @@ public class PackServiceImpl implements PackService {
|
||||
packPlateList.addAll(packPartsList);
|
||||
return packPlateList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PackageDetailsRespVO> getOrderPackageDetails(Long orderId, String packageNo) {
|
||||
List<OrderPackagDONew> orderPackagDONews = orderPackageNewMapper.selectList(new LambdaQueryWrapper<OrderPackagDONew>()
|
||||
.eq(OrderPackagDONew::getPackageNo, packageNo)
|
||||
.eq(OrderPackagDONew::getOrderId, orderId)
|
||||
);
|
||||
|
||||
if (CollUtil.isEmpty(orderPackagDONews)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Set<Long> orderIds = Set.of(orderId);
|
||||
List<PackageDetailsRespVO> packPartsList = orderPartsMapper.selectPackedParts(orderIds, packageNo);
|
||||
List<PackageDetailsRespVO> packPlateList = orderPlateMapper.selectPackedPlateList(orderIds, packageNo);
|
||||
packPlateList.addAll(packPartsList);
|
||||
return packPlateList;
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -182,13 +182,6 @@ public interface OrderService {
|
||||
|
||||
OrderAllData getOrderAllData(Long orderId, Long planId);
|
||||
|
||||
/**
|
||||
* 检查item是否有未打包的并更新订单打包状态
|
||||
*
|
||||
* @param orderIds
|
||||
*/
|
||||
void updateOrdersPackageStatus(List<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 获取订单id对应的所有父子订单id
|
||||
*
|
||||
|
||||
-5
@@ -1683,11 +1683,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrdersPackageStatus(List<Long> orderIds) {
|
||||
orderMapper.updateOrdersPackageStatus(orderIds);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getFatherAndSonOrderIds(List<Long> orderIds) {
|
||||
|
||||
-31
@@ -644,35 +644,4 @@
|
||||
and o.deleted = false
|
||||
</select>
|
||||
|
||||
<update id="updateOrdersPackageStatus">
|
||||
UPDATE orders o
|
||||
SET o.packaged =
|
||||
CASE
|
||||
WHEN
|
||||
EXISTS (SELECT 1 FROM order_item oi
|
||||
WHERE oi.order_id = o.id
|
||||
AND oi.package_id = 0 and oi.plate_id != 0
|
||||
AND oi.order_id IN
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
)
|
||||
OR EXISTS (SELECT 1 FROM order_item oi
|
||||
JOIN order_parts op on oi.organ_id = op.organ_id and oi.order_id = op.order_id and oi.parts_id = op.id
|
||||
WHERE oi.order_id = o.id
|
||||
AND oi.package_id = 0 and oi.parts_id != 0 and op.type != '封边条'
|
||||
AND oi.order_id IN
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
)
|
||||
THEN '${@com.cf.imes.framework.common.enums.OrderPackageStatusEnum@UNPACKED.status}'
|
||||
ELSE '${@com.cf.imes.framework.common.enums.OrderPackageStatusEnum@PACKAGED.status}'
|
||||
END
|
||||
WHERE o.id in
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
+13
-7
@@ -288,7 +288,7 @@
|
||||
<result property="category" column="category"/>
|
||||
<result property="subparts" column="subparts"/>
|
||||
<result property="componentName" column="componentName"/>
|
||||
<result property="num" column="num"/>
|
||||
<result property="packNum" column="packNum"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectPackedParts"
|
||||
@@ -301,7 +301,7 @@
|
||||
t.body_id AS bodyId,
|
||||
t.group_names AS groupName,
|
||||
t.component_names AS componentName,
|
||||
t.num AS num,
|
||||
t.pack_num AS packNum,
|
||||
t.package_id AS packageId,
|
||||
op.id AS partsId,
|
||||
op.order_id AS orderId,
|
||||
@@ -330,7 +330,7 @@
|
||||
MIN(oc.name) AS component_names,
|
||||
MIN(ob.room_name) AS room_name,
|
||||
MIN(ob.name) AS body_name,
|
||||
SUM(oi.pack_num) AS num
|
||||
SUM(oi.pack_num) AS pack_num
|
||||
FROM order_item oi
|
||||
LEFT JOIN order_group og
|
||||
ON oi.organ_id = og.organ_id
|
||||
@@ -398,7 +398,6 @@
|
||||
t.group_names AS groupName,
|
||||
t.component_names AS componentName,
|
||||
t.num AS num,
|
||||
t.pack_num AS packNum,
|
||||
op.id AS partsId,
|
||||
op.order_id AS orderId,
|
||||
op.name,
|
||||
@@ -425,8 +424,7 @@
|
||||
MIN(oc.name) AS component_names,
|
||||
MIN(ob.room_name) AS room_name,
|
||||
MIN(ob.name) AS body_name,
|
||||
SUM(oi.num) AS num,
|
||||
SUM(oi.pack_num) AS pack_num
|
||||
SUM(oi.num - oi.pack_num) AS num
|
||||
FROM order_item oi
|
||||
LEFT JOIN order_group og
|
||||
ON oi.organ_id = og.organ_id
|
||||
@@ -443,6 +441,7 @@
|
||||
WHERE
|
||||
oi.parts_id != 0
|
||||
AND oi.package_id = 0
|
||||
AND oi.source_id = 0
|
||||
GROUP BY oi.room_id, oi.body_id, oi.parts_id
|
||||
) t ON t.parts_id = op.id
|
||||
WHERE op.deleted = false
|
||||
@@ -468,6 +467,7 @@
|
||||
t.num AS num,
|
||||
t.heap_num AS heapNum,
|
||||
op.id AS partsId,
|
||||
op.order_id AS orderId,
|
||||
op.name,
|
||||
op.model,
|
||||
op.spec,
|
||||
@@ -493,7 +493,7 @@
|
||||
MIN(oc.name) AS component_names,
|
||||
MIN(ob.room_name) AS room_name,
|
||||
MIN(ob.name) AS body_name,
|
||||
SUM(oi.num) AS num,
|
||||
SUM(oi.num - oi.heap_num) AS num,
|
||||
SUM(oi.heap_num) AS heap_num
|
||||
FROM order_item oi
|
||||
LEFT JOIN order_group og
|
||||
@@ -510,6 +510,12 @@
|
||||
AND oc.id = oi.comp_id
|
||||
WHERE
|
||||
oi.parts_id != 0
|
||||
AND
|
||||
(
|
||||
source_id = 0
|
||||
OR
|
||||
(source_id != 0 AND oi.heap_split_status = 1)
|
||||
)
|
||||
GROUP BY oi.room_id, oi.body_id, oi.parts_id, oi.heap_split_status
|
||||
) t ON t.parts_id = op.id
|
||||
WHERE op.deleted = false
|
||||
|
||||
+6
-1
@@ -40,4 +40,9 @@ heap.split.task.name.exist=分堆任务名已存在,请重新命名
|
||||
heap.split.no.need.restart=该分堆任务无需重启,请刷新列表后检查状态
|
||||
heap.split.need.restart=该分堆任务已完成,请重启该任务后再次查看
|
||||
|
||||
order.already.packaged=该订单已打包完成,无法操作
|
||||
order.already.packaged=该订单已打包完成,无法操作
|
||||
|
||||
parts.pack.num.not.enough=配件可打包数量不足,请刷新后再次打包
|
||||
parts.pack.item.source.not.exist=配件打包数据异常,请刷新后再次打包
|
||||
parts.heapsplit.num.not.enough=配件可分堆数量不足,请刷新后再次分堆
|
||||
parts.heapsplit.item.source.not.exist=配件分堆数据异常,请刷新后再次分堆
|
||||
+6
-1
@@ -40,4 +40,9 @@ heap.split.task.name.exist=分堆任務名已存在,請重新命名
|
||||
heap.split.no.need.restart=該分堆任務無需重啓,請重繪清單後檢查狀態
|
||||
heap.split.need.restart=該分堆任務已完成,請重啓該任務後再次查看
|
||||
|
||||
order.already.packaged=該訂單已打包完成,無法操作
|
||||
order.already.packaged=該訂單已打包完成,無法操作
|
||||
|
||||
parts.pack.num.not.enough=配件可打包數量不足,請重繪後再次打包
|
||||
parts.pack.item.source.not.exist=配件打包數據异常,請重繪後再次打包
|
||||
parts.heapsplit.num.not.enough=配件可分堆數量不足,請重繪後再次分堆
|
||||
parts.heapsplit.item.source.not.exist=配件分堆數據异常,請重繪後再次分堆
|
||||
+6
-1
@@ -40,4 +40,9 @@ heap.split.task.name.exist=The task name for heap splitting already exists, plea
|
||||
heap.split.no.need.restart=This heap splitting task does not require a restart. Please refresh the list and check the status
|
||||
heap.split.need.restart=The heap splitting task has been completed. Please restart the task and check again
|
||||
|
||||
order.already.packaged=The order has been packaged and cannot be processed
|
||||
order.already.packaged=The order has been packaged and cannot be processed
|
||||
|
||||
parts.pack.num.not.enough=The number of accessories that can be packaged is insufficient. Please refresh and pack again
|
||||
parts.pack.item.source.not.exist=Abnormal accessory packaging data, please refresh and package again
|
||||
parts.heapsplit.num.not.enough=The number of accessories that can be stacked is insufficient. Please refresh and stack again
|
||||
parts.heapsplit.item.source.not.exist=Abnormal accessory stacking data, please refresh and stack again
|
||||
Reference in New Issue
Block a user