From 4e752243c0efa7aa01ed6bd7a312716f6e2ea001 Mon Sep 17 00:00:00 2001 From: btobab Date: Sun, 8 Mar 2026 13:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9E=9A=E4=B8=BE,=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/custom/InboundFictitiousFlag.java | 29 + .../common/enums/custom/InboundLevelType.java | 29 + .../custom/InboundNoticeReceivingStatus.java | 31 + .../custom/InboundNoticeTabInStatus.java | 30 + .../InboundNoticeTabReceivingStatus.java | 31 + .../custom/InboundOngoodsshelfInStatus.java | 29 + .../custom/InboundResourceLockStatus.java | 29 + .../InboundResourceOccupancyStatus.java | 29 + .../enums/custom/InboundStorageMode.java | 31 + .../enums/custom/InboundTaskStatus.java | 30 + .../common/enums/custom/InboundTaskType.java | 28 + .../common/enums/custom/NoticeTaskStatus.java | 29 + .../common/enums/custom/NoticeTaskType.java | 29 + .../enums/custom/OutboundAuditStatus.java | 29 + .../enums/custom/OutboundConfirmStatus.java | 30 + .../enums/custom/OutboundOrderStatus.java | 29 + .../custom/OutboundResourceLockStatus.java | 29 + .../OutboundResourceOccupancyStatus.java | 29 + .../zbf/common/enums/custom/OutboundType.java | 29 + .../common/enums/custom/StorageAgvFlag.java | 29 + .../enums/custom/TaskFictitiousFlag.java | 29 + .../impl/TRkWareNoticeServiceImpl.java | 2641 +++++++++-------- 22 files changed, 1938 insertions(+), 1320 deletions(-) create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundFictitiousFlag.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundLevelType.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeReceivingStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabInStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabReceivingStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundOngoodsshelfInStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceLockStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceOccupancyStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundStorageMode.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskType.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskType.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundAuditStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundConfirmStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundOrderStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceLockStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceOccupancyStatus.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundType.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/StorageAgvFlag.java create mode 100644 zbf-common/src/main/java/com/zbf/common/enums/custom/TaskFictitiousFlag.java diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundFictitiousFlag.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundFictitiousFlag.java new file mode 100644 index 0000000..f63b822 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundFictitiousFlag.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 入库虚拟标记 + */ +public enum InboundFictitiousFlag +{ + REAL("0", "真实库位"), + VIRTUAL("1", "虚拟库位"); + + private final String code; + private final String description; + + InboundFictitiousFlag(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundLevelType.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundLevelType.java new file mode 100644 index 0000000..c9ef91a --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundLevelType.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 入库层级 + */ +public enum InboundLevelType +{ + LEVEL_ONE("1", "一级库"), + LEVEL_TWO("2", "二级库"); + + private final String code; + private final String description; + + InboundLevelType(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeReceivingStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeReceivingStatus.java new file mode 100644 index 0000000..d2c3122 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeReceivingStatus.java @@ -0,0 +1,31 @@ +package com.zbf.common.enums.custom; + +/** + * 入库通知单收货状态 + */ +public enum InboundNoticeReceivingStatus +{ + CREATED("0", "新建"), + PROCESSING("1", "处理中"), + COMPLETED("2", "已完成"), + PUSHED("3", "已推送"); + + private final String code; + private final String description; + + InboundNoticeReceivingStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabInStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabInStatus.java new file mode 100644 index 0000000..bfd400a --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabInStatus.java @@ -0,0 +1,30 @@ +package com.zbf.common.enums.custom; + +/** + * 入库通知单明细内部状态 + */ +public enum InboundNoticeTabInStatus +{ + INITIAL("0", "初始"), + LOCKED("1", "锁定"), + TRANSFERRED("2", "已转移"); + + private final String code; + private final String description; + + InboundNoticeTabInStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabReceivingStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabReceivingStatus.java new file mode 100644 index 0000000..371fbf6 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundNoticeTabReceivingStatus.java @@ -0,0 +1,31 @@ +package com.zbf.common.enums.custom; + +/** + * 入库通知单明细收货状态 + */ +public enum InboundNoticeTabReceivingStatus +{ + PENDING("0", "待上架"), + PARTIAL("1", "部分上架"), + COMPLETED("2", "上架完成"), + PUSHED("3", "已推送"); + + private final String code; + private final String description; + + InboundNoticeTabReceivingStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundOngoodsshelfInStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundOngoodsshelfInStatus.java new file mode 100644 index 0000000..47a4c75 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundOngoodsshelfInStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 入库任务内部状态 + */ +public enum InboundOngoodsshelfInStatus +{ + PENDING("0", "待执行"), + PLC_ASSIGNED("2", "已分配PLC"); + + private final String code; + private final String description; + + InboundOngoodsshelfInStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceLockStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceLockStatus.java new file mode 100644 index 0000000..3724544 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceLockStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 入库相关资源锁定状态 + */ +public enum InboundResourceLockStatus +{ + UNLOCKED("0", "未锁定"), + LOCKED("1", "已锁定"); + + private final String code; + private final String description; + + InboundResourceLockStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceOccupancyStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceOccupancyStatus.java new file mode 100644 index 0000000..725ca6c --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundResourceOccupancyStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 入库相关资源占用状态 + */ +public enum InboundResourceOccupancyStatus +{ + IDLE("0", "空闲"), + OCCUPIED("1", "占用"); + + private final String code; + private final String description; + + InboundResourceOccupancyStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundStorageMode.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundStorageMode.java new file mode 100644 index 0000000..89561b8 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundStorageMode.java @@ -0,0 +1,31 @@ +package com.zbf.common.enums.custom; + +/** + * 入库仓储模式 + */ +public enum InboundStorageMode +{ + STANDARD("1", "标准入库"), + WORKSHOP_RETURN("2", "车间退货"), + DIRECT_INBOUND("3", "无单直入"), + TRANSFER("4", "调拨入库"); + + private final String code; + private final String description; + + InboundStorageMode(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskStatus.java new file mode 100644 index 0000000..b182e2b --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskStatus.java @@ -0,0 +1,30 @@ +package com.zbf.common.enums.custom; + +/** + * 入库任务状态 + */ +public enum InboundTaskStatus +{ + PENDING("0", "待处理"), + DISABLED("1", "停用"), + CONFIRMED("3", "已确认"); + + private final String code; + private final String description; + + InboundTaskStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskType.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskType.java new file mode 100644 index 0000000..614c29f --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/InboundTaskType.java @@ -0,0 +1,28 @@ +package com.zbf.common.enums.custom; + +/** + * 入库任务类型 + */ +public enum InboundTaskType +{ + INBOUND("0", "入库任务"); + + private final String code; + private final String description; + + InboundTaskType(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskStatus.java new file mode 100644 index 0000000..36d73bb --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 通知任务状态 + */ +public enum NoticeTaskStatus +{ + PENDING("0", "待处理"), + COMPLETED("1", "已处理"); + + private final String code; + private final String description; + + NoticeTaskStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskType.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskType.java new file mode 100644 index 0000000..12e69b6 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/NoticeTaskType.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 通知任务类型 + */ +public enum NoticeTaskType +{ + INBOUND("0", "入库通知任务"), + OUTBOUND("1", "出库通知任务"); + + private final String code; + private final String description; + + NoticeTaskType(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundAuditStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundAuditStatus.java new file mode 100644 index 0000000..4a54149 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundAuditStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 出库审核状态 + */ +public enum OutboundAuditStatus +{ + PENDING("0", "待审核"), + APPROVED("1", "已审核"); + + private final String code; + private final String description; + + OutboundAuditStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundConfirmStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundConfirmStatus.java new file mode 100644 index 0000000..994ea8a --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundConfirmStatus.java @@ -0,0 +1,30 @@ +package com.zbf.common.enums.custom; + +/** + * 出库确认状态 + */ +public enum OutboundConfirmStatus +{ + PENDING("0", "待执行"), + PARTIAL("1", "部分完成"), + COMPLETED("2", "已完成"); + + private final String code; + private final String description; + + OutboundConfirmStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundOrderStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundOrderStatus.java new file mode 100644 index 0000000..c5193a4 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundOrderStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 出库单状态 + */ +public enum OutboundOrderStatus +{ + CREATED("0", "新建"), + LOCKED("1", "已锁定"); + + private final String code; + private final String description; + + OutboundOrderStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceLockStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceLockStatus.java new file mode 100644 index 0000000..b55b0b8 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceLockStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 出库相关资源锁定状态 + */ +public enum OutboundResourceLockStatus +{ + UNLOCKED("0", "未锁定"), + LOCKED("1", "已锁定"); + + private final String code; + private final String description; + + OutboundResourceLockStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceOccupancyStatus.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceOccupancyStatus.java new file mode 100644 index 0000000..7d7949b --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundResourceOccupancyStatus.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 出库相关资源占用状态 + */ +public enum OutboundResourceOccupancyStatus +{ + IDLE("0", "空闲"), + OCCUPIED("1", "占用"); + + private final String code; + private final String description; + + OutboundResourceOccupancyStatus(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundType.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundType.java new file mode 100644 index 0000000..1019da6 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/OutboundType.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 出库类型 + */ +public enum OutboundType +{ + STANDARD("1", "普通出库"), + TRANSFER("3", "调拨出库"); + + private final String code; + private final String description; + + OutboundType(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/StorageAgvFlag.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/StorageAgvFlag.java new file mode 100644 index 0000000..7cbfb19 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/StorageAgvFlag.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 仓库AGV标记 + */ +public enum StorageAgvFlag +{ + NON_AGV("0", "非AGV仓库"), + AGV("1", "AGV仓库"); + + private final String code; + private final String description; + + StorageAgvFlag(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-common/src/main/java/com/zbf/common/enums/custom/TaskFictitiousFlag.java b/zbf-common/src/main/java/com/zbf/common/enums/custom/TaskFictitiousFlag.java new file mode 100644 index 0000000..fba7d87 --- /dev/null +++ b/zbf-common/src/main/java/com/zbf/common/enums/custom/TaskFictitiousFlag.java @@ -0,0 +1,29 @@ +package com.zbf.common.enums.custom; + +/** + * 任务虚拟标记 + */ +public enum TaskFictitiousFlag +{ + REAL("0", "真实任务"), + VIRTUAL("1", "虚拟任务"); + + private final String code; + private final String description; + + TaskFictitiousFlag(String code, String description) + { + this.code = code; + this.description = description; + } + + public String getCode() + { + return code; + } + + public String getDescription() + { + return description; + } +} diff --git a/zbf-system/src/main/java/com/zbf/system/service/impl/TRkWareNoticeServiceImpl.java b/zbf-system/src/main/java/com/zbf/system/service/impl/TRkWareNoticeServiceImpl.java index be5ea14..c3301a0 100644 --- a/zbf-system/src/main/java/com/zbf/system/service/impl/TRkWareNoticeServiceImpl.java +++ b/zbf-system/src/main/java/com/zbf/system/service/impl/TRkWareNoticeServiceImpl.java @@ -7,7 +7,16 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.zbf.common.annotation.DataScope; import com.zbf.common.annotation.Log; -import com.zbf.common.core.domain.entity.SysUser; +import com.zbf.common.enums.custom.InboundFictitiousFlag; +import com.zbf.common.enums.custom.InboundLevelType; +import com.zbf.common.enums.custom.InboundNoticeReceivingStatus; +import com.zbf.common.enums.custom.InboundNoticeTabInStatus; +import com.zbf.common.enums.custom.InboundNoticeTabReceivingStatus; +import com.zbf.common.enums.custom.InboundOngoodsshelfInStatus; +import com.zbf.common.enums.custom.InboundResourceLockStatus; +import com.zbf.common.enums.custom.InboundResourceOccupancyStatus; +import com.zbf.common.enums.custom.InboundTaskStatus; +import com.zbf.common.enums.custom.InboundTaskType; import com.zbf.common.exception.ServiceException; import com.zbf.common.utils.DateUtils; import com.zbf.common.utils.OrderCodeFactory; @@ -276,7 +285,7 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl confirmNoticeTab(TRkWareNoticeTabUpdate params) { + public Map confirmNoticeTab(TRkWareNoticeTabUpdate confirmRequest) { // 返回结果 Map resultMap = new HashMap<>(); // 查询入库通知单明细 - TRkWareNotice tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(params.getId()); + TRkWareNotice inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(confirmRequest.getId()); // 手持通知信息 - TCallNotice tCallNotice = new TCallNotice(); - tCallNotice.setId(IdUtils.randomUUID()); - params.getParams().put("callNoticeId", tCallNotice.getId()); + TCallNotice inboundCallNotice = new TCallNotice(); + inboundCallNotice.setId(IdUtils.randomUUID()); + confirmRequest.getParams().put("callNoticeId", inboundCallNotice.getId()); - if (tRkWareNotice == null) { + if (inboundNotice == null) { resultMap.put("error", "入库通知单不存在"); throw new RuntimeException("入库通知单不存在"); } // 托盘号为空 - if (ObjectUtils.isEmpty(params.getCtlNo())) { + if (ObjectUtils.isEmpty(confirmRequest.getCtlNo())) { // 查询PLC表 - List plcSList = plcService.selectPlcList(); - Plc plc = plcSList.get(0); + List plcList = plcService.selectPlcList(); + Plc currentPlc = plcList.get(0); // 到达9999999 则自动从0开始 - if (plc.getPlcid() == 9999999) { - plc.setPlcid(0L); + if (currentPlc.getPlcid() == 9999999) { + currentPlc.setPlcid(0L); } else { - plc.setPlcid(plc.getPlcid() + 1); + currentPlc.setPlcid(currentPlc.getPlcid() + 1); } - plc.setId(1); - plcService.updatePlc(plc); + currentPlc.setId(1); + plcService.updatePlc(currentPlc); - params.getParams().put("plcId", plc.getPlcid()); + confirmRequest.getParams().put("plcId", currentPlc.getPlcid()); } else { // 校验同一托盘号在库存中是否存在 - /*TMiStock tMiStock = new TMiStock(); - tMiStock.setCtl(params.getCtlNo()); - List tMiStocks = tMiStockMapper.selectTMiStockList(tMiStock); + /*TMiStock stockQuery = new TMiStock(); + stockQuery.setCtl(confirmRequest.getCtlNo()); + List matchedStocks = tMiStockMapper.selectTMiStockList(stockQuery); - if (tMiStocks.size() > 0) { - resultMap.put("error", "托盘【" + params.getCtlNo() + "】已占用,请更换"); - throw new RuntimeException("托盘" + params.getCtlNo() + "已占用,请更换"); + if (matchedStocks.size() > 0) { + resultMap.put("error", "托盘【" + confirmRequest.getCtlNo() + "】已占用,请更换"); + throw new RuntimeException("托盘" + confirmRequest.getCtlNo() + "已占用,请更换"); }*/ //校验托盘容器是否正确 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TBasePallet::getPalletId, params.getCtlNo()); - List plcs = palletMapper.selectList(wrapper); - if (plcs.isEmpty()) { + LambdaQueryWrapper palletQueryWrapper = new LambdaQueryWrapper<>(); + palletQueryWrapper.eq(TBasePallet::getPalletId, confirmRequest.getCtlNo()); + List palletMatches = palletMapper.selectList(palletQueryWrapper); + if (palletMatches.isEmpty()) { resultMap.put("error", "托盘不存在"); - throw new RuntimeException("托盘" + params.getCtlNo() + "不存在"); + throw new RuntimeException("托盘" + confirmRequest.getCtlNo() + "不存在"); } - TBasePallet palletChk = plcs.get(0); - if ("1".equals(palletChk.getIsLock())) { - resultMap.put("error", "托盘号【" + params.getCtlNo() + "】已禁用"); - log.error("托盘号【" + params.getCtlNo() + "】已禁用"); - throw new RuntimeException("托盘号【" + params.getCtlNo() + "】已禁用"); + TBasePallet targetPallet = palletMatches.get(0); + if (InboundResourceLockStatus.LOCKED.getCode().equals(targetPallet.getIsLock())) { + resultMap.put("error", "托盘号【" + confirmRequest.getCtlNo() + "】已禁用"); + log.error("托盘号【" + confirmRequest.getCtlNo() + "】已禁用"); + throw new RuntimeException("托盘号【" + confirmRequest.getCtlNo() + "】已禁用"); } - if ("0".equals(palletChk.getStatus()) || StringUtils.isBlank(palletChk.getStatus())) { - TBasePallet tBasePallet = new TBasePallet(); - tBasePallet.setStatus("1"); - tBasePallet.setId(palletChk.getId()); - tBasePallet.setUpdateBy(params.getUserName()); - tBasePallet.setUpdateTime(new Date()); - palletMapper.updateTBasePallet(tBasePallet); + if (InboundResourceOccupancyStatus.IDLE.getCode().equals(targetPallet.getStatus()) + || StringUtils.isBlank(targetPallet.getStatus())) { + TBasePallet palletOccupancyUpdate = new TBasePallet(); + palletOccupancyUpdate.setStatus(InboundResourceOccupancyStatus.OCCUPIED.getCode()); + palletOccupancyUpdate.setId(targetPallet.getId()); + palletOccupancyUpdate.setUpdateBy(confirmRequest.getUserName()); + palletOccupancyUpdate.setUpdateTime(new Date()); + palletMapper.updateTBasePallet(palletOccupancyUpdate); } } // 通知单明细map - Map trkWareNoticeTabMap = new HashMap(); - for (int i = 0; i < tRkWareNotice.getTRkWareNoticeTabList().size(); i++) { - TRkWareNoticeTab noticeTab = tRkWareNotice.getTRkWareNoticeTabList().get(i); - trkWareNoticeTabMap.put(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId(), noticeTab); + Map noticeTabByBusinessKey = new HashMap(); + for (int i = 0; i < inboundNotice.getTRkWareNoticeTabList().size(); i++) { + TRkWareNoticeTab noticeTab = inboundNotice.getTRkWareNoticeTabList().get(i); + noticeTabByBusinessKey.put(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId(), noticeTab); } - if ("".equals(params.getUserName())) { - params.setUserName(params.getRecordPerson()); + if ("".equals(confirmRequest.getUserName())) { + confirmRequest.setUserName(confirmRequest.getRecordPerson()); } - List updateNoticeTabs = new ArrayList(); - List insertTOngoodsshelfs = new ArrayList(); + List updatedNoticeTabs = new ArrayList(); + List inboundTasksToCreate = new ArrayList(); //冻结校验 - List list1 = params.getTrkWareNoticeTabList(); - for (TRkWareNoticeTab tab : list1) { - TRkWareNoticeTab tRkWareNoticeTab = mapper.selectTRkWareNoticeTabById(tab.getId()); - if ("1".equals(tRkWareNoticeTab.getInStatus())) { - resultMap.put("error", "物料【" + tRkWareNoticeTab.getGoodsName() + "】已冻结,不可收货"); - log.error("物料【" + tRkWareNoticeTab.getInStatus() + "】已冻结,不可收货"); - throw new RuntimeException("物料【" + tRkWareNoticeTab.getInStatus() + tRkWareNoticeTab.getGoodsName() + " 】已冻结,不可收货"); + List submittedNoticeTabs = confirmRequest.getTrkWareNoticeTabList(); + for (TRkWareNoticeTab submittedNoticeTab : submittedNoticeTabs) { + TRkWareNoticeTab noticeTabInDb = mapper.selectTRkWareNoticeTabById(submittedNoticeTab.getId()); + if (InboundNoticeTabInStatus.LOCKED.getCode().equals(noticeTabInDb.getInStatus())) { + resultMap.put("error", "物料【" + noticeTabInDb.getGoodsName() + "】已冻结,不可收货"); + log.error("物料【" + noticeTabInDb.getInStatus() + "】已冻结,不可收货"); + throw new RuntimeException("物料【" + noticeTabInDb.getInStatus() + noticeTabInDb.getGoodsName() + " 】已冻结,不可收货"); } } // 遍历提交的通知单明细数据 - for (TRkWareNoticeTab tabNew : params.getTrkWareNoticeTabList()) { - TRkWareNoticeTab tabOld = trkWareNoticeTabMap.get(tabNew.getSalesOrderNumber() + tabNew.getGoodsId()); + for (TRkWareNoticeTab submittedNoticeTab : confirmRequest.getTrkWareNoticeTabList()) { + TRkWareNoticeTab noticeTabToUpdate = noticeTabByBusinessKey.get(submittedNoticeTab.getSalesOrderNumber() + submittedNoticeTab.getGoodsId()); - if (tabOld == null) { - resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】的通知单明细不存在"); - throw new RuntimeException("物料【" + tabNew.getGoodsName() + "】的通知单明细不存在"); + if (noticeTabToUpdate == null) { + resultMap.put("error", "物料【" + submittedNoticeTab.getGoodsName() + "】的通知单明细不存在"); + throw new RuntimeException("物料【" + submittedNoticeTab.getGoodsName() + "】的通知单明细不存在"); } // 仓库ID - String storageId = params.getStorageId(); - if (!ObjectUtils.isEmpty(tabNew.getStorageId())) { - storageId = tabNew.getStorageId(); + String resolvedStorageId = confirmRequest.getStorageId(); + if (!ObjectUtils.isEmpty(submittedNoticeTab.getStorageId())) { + resolvedStorageId = submittedNoticeTab.getStorageId(); } // 获取仓库信息 - TBaseStorage tBaseStorage = new TBaseStorage(); - tBaseStorage.setStorageId(null); - List sTBaseStorages = tBaseStorageMapper.selectTBaseStorageList(tBaseStorage); + TBaseStorage storageQuery = new TBaseStorage(); + storageQuery.setStorageId(null); + List availableStorages = tBaseStorageMapper.selectTBaseStorageList(storageQuery); - if (sTBaseStorages.size() > 0) { - tBaseStorage = sTBaseStorages.get(0); + if (availableStorages.size() > 0) { + TBaseStorage storage = availableStorages.get(0); // 判断是否为AGV库 TODO - if ("1".equals(tBaseStorage.getIsAgv())) { + if ("1".equals(storage.getIsAgv())) { // 更新入库通知单明细状态 @@ -472,97 +482,97 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl 0) { - resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】的收货数量不能大于签收数量"); - throw new RuntimeException("物料【" + tabNew.getGoodsName() + "】的收货数量不能大于签收数量"); + if (currentReceivedQuantity.add(accumulatedReceivedQuantity).compareTo(plannedReceivingQuantity) > 0) { + resultMap.put("error", "物料【" + submittedNoticeTab.getGoodsName() + "】的收货数量不能大于签收数量"); + throw new RuntimeException("物料【" + submittedNoticeTab.getGoodsName() + "】的收货数量不能大于签收数量"); } // 设置更新信息 - tabOld.setRecNum(recNumNowNew.add(recNum)); + noticeTabToUpdate.setRecNum(currentReceivedQuantity.add(accumulatedReceivedQuantity)); - if (tabOld.getRecNum().compareTo(receivingNum) == 0) { + if (noticeTabToUpdate.getRecNum().compareTo(plannedReceivingQuantity) == 0) { // 物料明细冻结 - tabOld.setInStatus("1"); + noticeTabToUpdate.setInStatus(InboundNoticeTabInStatus.LOCKED.getCode()); } // // tabOld.setReceivingStatus("0"); - tabOld.setRecNumNow(recNumNowNew); - tabOld.setStorageId(storageId); + noticeTabToUpdate.setRecNumNow(currentReceivedQuantity); + noticeTabToUpdate.setStorageId(resolvedStorageId); // 托盘 - tabOld.setCtl(params.getCtlNo()); + noticeTabToUpdate.setCtl(confirmRequest.getCtlNo()); - tabOld.setUpdateBy(params.getUserName()); - tabOld.setUpdateTime(new Date()); + noticeTabToUpdate.setUpdateBy(confirmRequest.getUserName()); + noticeTabToUpdate.setUpdateTime(new Date()); // 仓库名称 - if (sTBaseStorages.size() > 0) { - tBaseStorage = sTBaseStorages.get(0); - tabOld.setStorageShortName(tBaseStorage.getStorageShortName()); + if (availableStorages.size() > 0) { + TBaseStorage storage = availableStorages.get(0); + noticeTabToUpdate.setStorageShortName(storage.getStorageShortName()); } - updateNoticeTabs.add(tabOld); + updatedNoticeTabs.add(noticeTabToUpdate); - tRkWareNoticeTabMapper.updateTRkWareNoticeTab(tabOld); + tRkWareNoticeTabMapper.updateTRkWareNoticeTab(noticeTabToUpdate); // 生成入库任务 - insertTOngoodsshelfs.add(makeTOngoodsshelf(tRkWareNotice, tabOld, params)); + inboundTasksToCreate.add(buildInboundTask(inboundNotice, noticeTabToUpdate, confirmRequest)); } // 生成入库任务 - if (insertTOngoodsshelfs.size() > 0) { - for (TOngoodsshelf tOngoodsshelf : insertTOngoodsshelfs) { - tOngoodsshelfMapper.insertTOngoodsshelf(tOngoodsshelf); + if (inboundTasksToCreate.size() > 0) { + for (TOngoodsshelf inboundTaskToInsert : inboundTasksToCreate) { + tOngoodsshelfMapper.insertTOngoodsshelf(inboundTaskToInsert); } // 仓库id - tCallNotice.setStorageId(params.getStorageId()); + inboundCallNotice.setStorageId(confirmRequest.getStorageId()); // 托盘号 - tCallNotice.setCtl(params.getCtlNo()); + inboundCallNotice.setCtl(confirmRequest.getCtlNo()); // pLCID - tCallNotice.setPlcid((Long) params.getParams().get("plcId")); + inboundCallNotice.setPlcid((Long) confirmRequest.getParams().get("plcId")); // 任务类型 0:入库任务 - tCallNotice.setTaskType("0"); + inboundCallNotice.setTaskType(InboundTaskType.INBOUND.getCode()); // 物料编码 - // tCallNotice.setGoodsId(tOngoodsshelf.getGoodsId()); + // inboundCallNotice.setGoodsId(inboundTaskToInsert.getGoodsId()); // 物料名称 - // tCallNotice.setGoodsName(tOngoodsshelf.getGoodsName()); + // inboundCallNotice.setGoodsName(inboundTaskToInsert.getGoodsName()); // 入库任务ID - // tCallNotice.setRukuId(tOngoodsshelf.getId()); + // inboundCallNotice.setRukuId(inboundTaskToInsert.getId()); // 创建者 - tCallNotice.setCreateBy(params.getCreateBy()); + inboundCallNotice.setCreateBy(confirmRequest.getCreateBy()); // 时间 - tCallNotice.setCreateTime(new Date()); + inboundCallNotice.setCreateTime(new Date()); // 状态 0:未处理 - tCallNotice.setStatus("0"); + inboundCallNotice.setStatus(InboundTaskStatus.PENDING.getCode()); // 虚拟入库任务 - tCallNotice.setFictitious(params.getFictitious()); + inboundCallNotice.setFictitious(confirmRequest.getFictitious()); // 通知单号 - tCallNotice.setTaskId(tRkWareNotice.getNoticeId()); + inboundCallNotice.setTaskId(inboundNotice.getNoticeId()); - tNoticeService.sendNotice(tCallNotice); + tNoticeService.sendNotice(inboundCallNotice); } @@ -572,433 +582,423 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl saveNoticeTab(TRkWareNoticeTabUpdate params) { + public Map saveNoticeTab(TRkWareNoticeTabUpdate saveRequest) { // 返回结果 Map resultMap = new HashMap<>(); // 查询入库通知单明细 - TRkWareNotice tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(params.getId()); + TRkWareNotice inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(saveRequest.getId()); - if (tRkWareNotice == null) { + if (inboundNotice == null) { resultMap.put("error", "入库通知单不存在"); return resultMap; } - if ("2".equals(tRkWareNotice.getReceivingStatus())) { + if (InboundNoticeReceivingStatus.COMPLETED.getCode().equals(inboundNotice.getReceivingStatus())) { resultMap.put("error", "入库通知单已全部收货,请刷新"); return resultMap; } // 通知单明细map - Map trkWareNoticeTabMap = new HashMap(); - for (int i = 0; i < tRkWareNotice.getTRkWareNoticeTabList().size(); i++) { - TRkWareNoticeTab noticeTab = tRkWareNotice.getTRkWareNoticeTabList().get(i); - trkWareNoticeTabMap.put(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId(), noticeTab); + Map noticeTabByBusinessKey = new HashMap(); + for (int i = 0; i < inboundNotice.getTRkWareNoticeTabList().size(); i++) { + TRkWareNoticeTab noticeTab = inboundNotice.getTRkWareNoticeTabList().get(i); + noticeTabByBusinessKey.put(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId(), noticeTab); } - List iRkWareNoticeTabs = new ArrayList(); + List noticeTabsToInsert = new ArrayList(); // 遍历提交的通知单明细数据 - for (TRkWareNoticeTab tabNew : params.getTrkWareNoticeTabList()) { + for (TRkWareNoticeTab noticeTabToInsert : saveRequest.getTrkWareNoticeTabList()) { - if (trkWareNoticeTabMap.containsKey(tabNew.getSalesOrderNumber() + tabNew.getGoodsId())) { + if (noticeTabByBusinessKey.containsKey(noticeTabToInsert.getSalesOrderNumber() + noticeTabToInsert.getGoodsId())) { throw new RuntimeException( - "子需求单号【" + tabNew.getSalesOrderNumber() + "】和物料ID【" + tabNew.getGoodsId() + "】组合重复. "); + "子需求单号【" + noticeTabToInsert.getSalesOrderNumber() + "】和物料ID【" + noticeTabToInsert.getGoodsId() + "】组合重复. "); } - if (ObjectUtils.isEmpty(tabNew.getGoodsId())) { + if (ObjectUtils.isEmpty(noticeTabToInsert.getGoodsId())) { resultMap.put("error", "物料编码不能为空"); return resultMap; } - if (ObjectUtils.isEmpty(tabNew.getGoodsName())) { + if (ObjectUtils.isEmpty(noticeTabToInsert.getGoodsName())) { resultMap.put("error", "物料名称不能为空"); return resultMap; } - BigDecimal receivingNum = tabNew.getReceivingNum() == null ? BigDecimal.ZERO : tabNew.getReceivingNum(); - BigDecimal arraMount = tabNew.getArraMount() == null ? BigDecimal.ZERO : tabNew.getArraMount(); + BigDecimal plannedReceivingQuantity = noticeTabToInsert.getReceivingNum() == null ? BigDecimal.ZERO : noticeTabToInsert.getReceivingNum(); + BigDecimal arrivedQuantity = noticeTabToInsert.getArraMount() == null ? BigDecimal.ZERO : noticeTabToInsert.getArraMount(); // if (recNumNowNew.compareTo(BigDecimal.ZERO) > 0 // || recNumNew.compareTo(BigDecimal.ZERO) > 0) { - // resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】的签收数量不为0"); + // resultMap.put("error", "物料【" + noticeTabToInsert.getGoodsName() + "】的签收数量不为0"); // return resultMap; // } - if (receivingNum.compareTo(BigDecimal.ZERO) <= 0) { - resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】的签收数量必须大于0"); + if (plannedReceivingQuantity.compareTo(BigDecimal.ZERO) <= 0) { + resultMap.put("error", "物料【" + noticeTabToInsert.getGoodsName() + "】的签收数量必须大于0"); return resultMap; } - if (arraMount.compareTo(BigDecimal.ZERO) <= 0) { - resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】的到货数量必须大于0"); + if (arrivedQuantity.compareTo(BigDecimal.ZERO) <= 0) { + resultMap.put("error", "物料【" + noticeTabToInsert.getGoodsName() + "】的到货数量必须大于0"); return resultMap; } - if (receivingNum.compareTo(arraMount) > 0) { - resultMap.put("error", "物料【" + tabNew.getGoodsName() + "】签收数量不能大于到货数量"); + if (plannedReceivingQuantity.compareTo(arrivedQuantity) > 0) { + resultMap.put("error", "物料【" + noticeTabToInsert.getGoodsName() + "】签收数量不能大于到货数量"); return resultMap; } - if (receivingNum.compareTo(arraMount) < 0) { + if (plannedReceivingQuantity.compareTo(arrivedQuantity) < 0) { //拒绝数量 - tabNew.setRejectNum(arraMount.subtract(receivingNum)); + noticeTabToInsert.setRejectNum(arrivedQuantity.subtract(plannedReceivingQuantity)); } /** 在途 */ - tabNew.setReceivingStatus("0"); - tabNew.setNoticeId(tRkWareNotice.getId()); - tabNew.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); + noticeTabToInsert.setReceivingStatus(InboundNoticeTabReceivingStatus.PENDING.getCode()); + noticeTabToInsert.setNoticeId(inboundNotice.getId()); + noticeTabToInsert.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); // 托盘 - // tabNew.setCtl(params.getCtlNo()); + // noticeTabToInsert.setCtl(saveRequest.getCtlNo()); - tabNew.setCreateBy(SecurityUtils.getUserNick()); - tabNew.setCreateTime(new Date()); - tabNew.setUpdateBy(SecurityUtils.getUserNick()); - tabNew.setUpdateTime(new Date()); + noticeTabToInsert.setCreateBy(SecurityUtils.getUserNick()); + noticeTabToInsert.setCreateTime(new Date()); + noticeTabToInsert.setUpdateBy(SecurityUtils.getUserNick()); + noticeTabToInsert.setUpdateTime(new Date()); // 二级库 - tabNew.setLevelType("2"); + noticeTabToInsert.setLevelType(InboundLevelType.LEVEL_TWO.getCode()); - tabNew.setSourceNum(tRkWareNotice.getDeliveryId()); - tabNew.setDeliveryId(tRkWareNotice.getDeliveryId()); + noticeTabToInsert.setSourceNum(inboundNotice.getDeliveryId()); + noticeTabToInsert.setDeliveryId(inboundNotice.getDeliveryId()); - iRkWareNoticeTabs.add(tabNew); + noticeTabsToInsert.add(noticeTabToInsert); } - if (iRkWareNoticeTabs.size() > 0) { + if (noticeTabsToInsert.size() > 0) { // 入库通知单明细批量插入 - tRkWareNoticeMapper.batchTRkWareNoticeTab(iRkWareNoticeTabs); + tRkWareNoticeMapper.batchTRkWareNoticeTab(noticeTabsToInsert); } resultMap.put("success", "保存成功"); @@ -1140,159 +1140,159 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl manualCompletion(TRkWareNoticeTabUpdate params) { + public Map manualCompletion(TRkWareNoticeTabUpdate completionRequest) { // 返回结果 Map resultMap = new HashMap<>(); - List updateList = new ArrayList<>(); - for (TRkWareNoticeTab tab : params.getTrkWareNoticeTabList()) { - tab = tRkWareNoticeMapper.selectTRkWareNoticeTabById(tab.getId()); + List completedNoticeTabs = new ArrayList<>(); + for (TRkWareNoticeTab submittedNoticeTab : completionRequest.getTrkWareNoticeTabList()) { + TRkWareNoticeTab noticeTabToComplete = tRkWareNoticeMapper.selectTRkWareNoticeTabById(submittedNoticeTab.getId()); /** 查询是否存在未完成的入库任务 */ - TOngoodsshelf tOngoodsshelf = new TOngoodsshelf(); - tOngoodsshelf.setNoticeTabId(tab.getId()); - tOngoodsshelf.setInStatus("2"); - List tOngoodsshelfs = tOngoodsshelfMapper.selectTOngoodsshelfList(tOngoodsshelf); + TOngoodsshelf pendingInboundTaskQuery = new TOngoodsshelf(); + pendingInboundTaskQuery.setNoticeTabId(noticeTabToComplete.getId()); + pendingInboundTaskQuery.setInStatus(InboundOngoodsshelfInStatus.PLC_ASSIGNED.getCode()); + List pendingInboundTasks = tOngoodsshelfMapper.selectTOngoodsshelfList(pendingInboundTaskQuery); - if (tOngoodsshelfs.size() > 0) { - resultMap.put("error", "通知单明细[" + tab.getId() + "]存在未完成的任务,不能删除"); + if (pendingInboundTasks.size() > 0) { + resultMap.put("error", "通知单明细[" + noticeTabToComplete.getId() + "]存在未完成的任务,不能删除"); return resultMap; } // 人工设置为全部收货 - tab.setReceivingStatus("2"); - tab.setUpdateTime(new Date()); - tab.setUpdateBy(params.getUserName()); + noticeTabToComplete.setReceivingStatus(InboundNoticeTabReceivingStatus.COMPLETED.getCode()); + noticeTabToComplete.setUpdateTime(new Date()); + noticeTabToComplete.setUpdateBy(completionRequest.getUserName()); - updateList.add(tab); + completedNoticeTabs.add(noticeTabToComplete); - tRkWareNoticeTabMapper.updateTRkWareNoticeTab(tab); + tRkWareNoticeTabMapper.updateTRkWareNoticeTab(noticeTabToComplete); } /** 设置通知单明细为完成状态 */ -// if (updateList.size() > 0) { -// tRkWareNoticeMapper.updateForeach(updateList); +// if (completedNoticeTabs.size() > 0) { +// tRkWareNoticeMapper.updateForeach(completedNoticeTabs); // } // 查询入库通知单明细 - TRkWareNotice tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(params.getId()); + TRkWareNotice inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(completionRequest.getId()); - if (tRkWareNotice == null) { + if (inboundNotice == null) { resultMap.put("error", "入库通知单不存在"); return resultMap; } - boolean allReceived = true; - for (TRkWareNoticeTab tab : tRkWareNotice.getTRkWareNoticeTabList()) { - if ("2".equals(tab.getReceivingStatus())) { - allReceived = false; + boolean allNoticeTabsCompleted = true; + for (TRkWareNoticeTab noticeTab : inboundNotice.getTRkWareNoticeTabList()) { + if (InboundNoticeTabReceivingStatus.COMPLETED.getCode().equals(noticeTab.getReceivingStatus())) { + allNoticeTabsCompleted = false; break; } } // 更细入库通知单状态 - if (allReceived) { + if (allNoticeTabsCompleted) { // 2:全部收货 - tRkWareNotice.setReceivingStatus("2"); - tRkWareNotice.setUpdateBy(params.getUserName()); - tRkWareNotice.setUpdateTime(new Date()); - tRkWareNoticeMapper.updateTRkWareNotice(tRkWareNotice); + inboundNotice.setReceivingStatus(InboundNoticeReceivingStatus.COMPLETED.getCode()); + inboundNotice.setUpdateBy(completionRequest.getUserName()); + inboundNotice.setUpdateTime(new Date()); + tRkWareNoticeMapper.updateTRkWareNotice(inboundNotice); } // 查询存货表数据 - TRkReceivingGoods tRkReceivingGoods = tRkReceivingGoodsMapper - .selectTRkReceivingGoodsByNoticeId(tRkWareNotice.getNoticeId()); + TRkReceivingGoods receivingGoods = tRkReceivingGoodsMapper + .selectTRkReceivingGoodsByNoticeId(inboundNotice.getNoticeId()); - String trkReceivingGoodsId = OrderCodeFactory.getOrderCode("R", ""); - if (tRkReceivingGoods != null) { - tRkReceivingGoods.setReceivingStatus(tRkWareNotice.getReceivingStatus()); - tRkReceivingGoods.setUpdateBy(params.getUserName()); - tRkReceivingGoods.setUpdateTime(new Date()); - tRkReceivingGoodsMapper.updateTRkReceivingGoods(tRkReceivingGoods); + String receivingGoodsId = OrderCodeFactory.getOrderCode("R", ""); + if (receivingGoods != null) { + receivingGoods.setReceivingStatus(inboundNotice.getReceivingStatus()); + receivingGoods.setUpdateBy(completionRequest.getUserName()); + receivingGoods.setUpdateTime(new Date()); + tRkReceivingGoodsMapper.updateTRkReceivingGoods(receivingGoods); - trkReceivingGoodsId = tRkReceivingGoods.getId(); + receivingGoodsId = receivingGoods.getId(); } else { - TRkReceivingGoods tGoods = new TRkReceivingGoods(); - BeanUtils.copyProperties(tRkWareNotice, tGoods); - tGoods.setId(trkReceivingGoodsId); - tGoods.setUpdateBy(params.getUserName()); - tGoods.setUpdateTime(new Date()); - tGoods.setCreateBy(params.getUserName()); - tGoods.setCreateTime(new Date()); - tRkReceivingGoodsMapper.insertTRkReceivingGoods(tGoods); + TRkReceivingGoods receivingGoodsToInsert = new TRkReceivingGoods(); + BeanUtils.copyProperties(inboundNotice, receivingGoodsToInsert); + receivingGoodsToInsert.setId(receivingGoodsId); + receivingGoodsToInsert.setUpdateBy(completionRequest.getUserName()); + receivingGoodsToInsert.setUpdateTime(new Date()); + receivingGoodsToInsert.setCreateBy(completionRequest.getUserName()); + receivingGoodsToInsert.setCreateTime(new Date()); + tRkReceivingGoodsMapper.insertTRkReceivingGoods(receivingGoodsToInsert); } // 查询是否存在收货表数据 - if (tRkWareNotice.getTRkWareNoticeTabList().size() > 0) { + if (inboundNotice.getTRkWareNoticeTabList().size() > 0) { - Map trkReceiveGoodsTabMap = new HashMap(); + Map receivingGoodsTabByBusinessKey = new HashMap(); - if (tRkReceivingGoods != null) { + if (receivingGoods != null) { - for (TRkReceivingGoodsTab goodsTab : tRkReceivingGoods.getTRkReceivingGoodsTabList()) { - trkReceiveGoodsTabMap.put(goodsTab.getSalesOrderNumber() + goodsTab.getGoodsId(), goodsTab); + for (TRkReceivingGoodsTab receivingGoodsTab : receivingGoods.getTRkReceivingGoodsTabList()) { + receivingGoodsTabByBusinessKey.put(receivingGoodsTab.getSalesOrderNumber() + receivingGoodsTab.getGoodsId(), receivingGoodsTab); } } - List insertGoodsTabs = new ArrayList<>(); + List receivingGoodsTabsToInsert = new ArrayList<>(); // 存货表更新集合 - List tReceivingGoodsTabs = new ArrayList(); + List receivingGoodsTabsToUpdate = new ArrayList(); - for (TRkWareNoticeTab noticeTab : tRkWareNotice.getTRkWareNoticeTabList()) { - TRkReceivingGoodsTab goodsTab = trkReceiveGoodsTabMap + for (TRkWareNoticeTab noticeTab : inboundNotice.getTRkWareNoticeTabList()) { + TRkReceivingGoodsTab receivingGoodsTabToUpdate = receivingGoodsTabByBusinessKey .get(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId()); - if (goodsTab != null) { - goodsTab.setRecNum(noticeTab.getRecNum()); - goodsTab.setReceivingStatus(noticeTab.getReceivingStatus()); - goodsTab.setUpdateBy(params.getUserName()); - goodsTab.setUpdateTime(new Date()); - tReceivingGoodsTabs.add(goodsTab); + if (receivingGoodsTabToUpdate != null) { + receivingGoodsTabToUpdate.setRecNum(noticeTab.getRecNum()); + receivingGoodsTabToUpdate.setReceivingStatus(noticeTab.getReceivingStatus()); + receivingGoodsTabToUpdate.setUpdateBy(completionRequest.getUserName()); + receivingGoodsTabToUpdate.setUpdateTime(new Date()); + receivingGoodsTabsToUpdate.add(receivingGoodsTabToUpdate); } else { - goodsTab = new TRkReceivingGoodsTab(); - BeanUtils.copyProperties(noticeTab, goodsTab); - goodsTab.setNoticeId(trkReceivingGoodsId); -// goodsTab.setId(OrderCodeFactory.getOrderCode("RTAB", "")); - insertGoodsTabs.add(goodsTab); + TRkReceivingGoodsTab receivingGoodsTabToInsert = new TRkReceivingGoodsTab(); + BeanUtils.copyProperties(noticeTab, receivingGoodsTabToInsert); + receivingGoodsTabToInsert.setNoticeId(receivingGoodsId); +// receivingGoodsTabToInsert.setId(OrderCodeFactory.getOrderCode("RTAB", "")); + receivingGoodsTabsToInsert.add(receivingGoodsTabToInsert); } } - if (tReceivingGoodsTabs.size() > 0) { + if (receivingGoodsTabsToUpdate.size() > 0) { // 批量更新存货明细表 - tRkReceivingGoodsMapper.updateForeach(tReceivingGoodsTabs); + tRkReceivingGoodsMapper.updateForeach(receivingGoodsTabsToUpdate); } - if (insertGoodsTabs.size() > 0) { - tRkReceivingGoodsMapper.batchTRkReceivingGoodsTab(insertGoodsTabs); + if (receivingGoodsTabsToInsert.size() > 0) { + tRkReceivingGoodsMapper.batchTRkReceivingGoodsTab(receivingGoodsTabsToInsert); } } // 入库通知单及明细数据 移到 bak表 - if (allReceived) { + if (allNoticeTabsCompleted) { // 查询入库通知单明细 - tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(params.getNoticeId()); - TRkWareNoticeBak tRkWareNoticeBak = new TRkWareNoticeBak(); - BeanUtils.copyProperties(tRkWareNotice, tRkWareNoticeBak); -// String tRkWareNoticeBakId = OrderCodeFactory.getOrderCode("TRKBAK", ""); -// tRkWareNoticeBak.setId(tRkWareNoticeBakId); - tRkWareNoticeBakMapper.insertTRkWareNoticeBak(tRkWareNoticeBak); + inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(completionRequest.getNoticeId()); + TRkWareNoticeBak inboundNoticeBakRecord = new TRkWareNoticeBak(); + BeanUtils.copyProperties(inboundNotice, inboundNoticeBakRecord); +// String inboundNoticeBakId = OrderCodeFactory.getOrderCode("TRKBAK", ""); +// inboundNoticeBakRecord.setId(inboundNoticeBakId); + tRkWareNoticeBakMapper.insertTRkWareNoticeBak(inboundNoticeBakRecord); - List tRkWareNoticeTabBaks = new ArrayList(); - for (TRkWareNoticeTab trWareNoticeTab : tRkWareNotice.getTRkWareNoticeTabList()) { - TRkWareNoticeTabBak tRkWareNoticeTabBak = new TRkWareNoticeTabBak(); -// trWareNoticeTab.setId(OrderCodeFactory.getOrderCode("TRKTABBAK", "")); -// trWareNoticeTab.setNoticeId(tRkWareNoticeBakId); - BeanUtils.copyProperties(trWareNoticeTab, tRkWareNoticeTabBak); - tRkWareNoticeTabBak.setPurchaser(tRkWareNotice.getPurchaser()); - tRkWareNoticeTabBak.setSendeDate(tRkWareNotice.getSendeDate()); - tRkWareNoticeTabBak.setProviderName(tRkWareNotice.getProviderName()); - tRkWareNoticeTabBak.setRecPerson(tRkWareNotice.getRecPerson()); - tRkWareNoticeTabBaks.add(tRkWareNoticeTabBak); + List inboundNoticeTabBakRecords = new ArrayList(); + for (TRkWareNoticeTab inboundNoticeTab : inboundNotice.getTRkWareNoticeTabList()) { + TRkWareNoticeTabBak inboundNoticeTabBakRecord = new TRkWareNoticeTabBak(); +// inboundNoticeTab.setId(OrderCodeFactory.getOrderCode("TRKTABBAK", "")); +// inboundNoticeTab.setNoticeId(inboundNoticeBakId); + BeanUtils.copyProperties(inboundNoticeTab, inboundNoticeTabBakRecord); + inboundNoticeTabBakRecord.setPurchaser(inboundNotice.getPurchaser()); + inboundNoticeTabBakRecord.setSendeDate(inboundNotice.getSendeDate()); + inboundNoticeTabBakRecord.setProviderName(inboundNotice.getProviderName()); + inboundNoticeTabBakRecord.setRecPerson(inboundNotice.getRecPerson()); + inboundNoticeTabBakRecords.add(inboundNoticeTabBakRecord); } - if (tRkWareNoticeTabBaks.size() > 0) { - tRkWareNoticeBakMapper.batchTRkWareNoticeTabBak(tRkWareNoticeTabBaks); + if (inboundNoticeTabBakRecords.size() > 0) { + tRkWareNoticeBakMapper.batchTRkWareNoticeTabBak(inboundNoticeTabBakRecords); } // 删除入库通知单和明细 - tRkWareNoticeMapper.deleteTRkWareNoticeById(tRkWareNotice.getId()); - tRkWareNoticeMapper.deleteNoticeTabByNoticeId(tRkWareNotice.getId()); + tRkWareNoticeMapper.deleteTRkWareNoticeById(inboundNotice.getId()); + tRkWareNoticeMapper.deleteNoticeTabByNoticeId(inboundNotice.getId()); } resultMap.put("success", "通知单明细已人工完成"); @@ -1306,30 +1306,30 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl shelvesConfirm(TRkWareNoticeTabUpdate params) { + public Map shelvesConfirm(TRkWareNoticeTabUpdate shelfConfirmRequest) { // 返回结果 Map resultMap = new HashMap<>(); // 库位 - if (ObjectUtils.isEmpty(params.getStorageLocation())) { + if (ObjectUtils.isEmpty(shelfConfirmRequest.getStorageLocation())) { resultMap.put("error", "库位不能为空"); return resultMap; } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TBaseStorageAreaLocation::getLocationId, params.getStorageLocation()); - List areaLocations = service.selectList(wrapper); - if (areaLocations.isEmpty()) { + LambdaQueryWrapper storageLocationQueryWrapper = new LambdaQueryWrapper<>(); + storageLocationQueryWrapper.eq(TBaseStorageAreaLocation::getLocationId, shelfConfirmRequest.getStorageLocation()); + List storageLocationMatches = tBaseStorageAreaLocationMapper.selectList(storageLocationQueryWrapper); + if (storageLocationMatches.isEmpty()) { throw new RuntimeException("库位号错误"); } - TBaseStorageAreaLocation locationCheck = areaLocations.get(0); - if ("1".equals(locationCheck.getIsLock())) { - resultMap.put("error", "库位【" + params.getStorageLocation() + "】已禁用"); - log.error("库位【" + params.getStorageLocation() + "】已禁用"); - throw new RuntimeException("库位【" + params.getStorageLocation() + "】已禁用"); + TBaseStorageAreaLocation targetStorageLocation = storageLocationMatches.get(0); + if (InboundResourceLockStatus.LOCKED.getCode().equals(targetStorageLocation.getIsLock())) { + resultMap.put("error", "库位【" + shelfConfirmRequest.getStorageLocation() + "】已禁用"); + log.error("库位【" + shelfConfirmRequest.getStorageLocation() + "】已禁用"); + throw new RuntimeException("库位【" + shelfConfirmRequest.getStorageLocation() + "】已禁用"); } // if("0".equals(locationCheck.getStatus())){ @@ -1337,262 +1337,261 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl ctlWrapper = new LambdaQueryWrapper<>(); - ctlWrapper.eq(TBasePallet::getPalletId, params.getCtlNo()); - List plcs = palletMapper.selectList(ctlWrapper); - if (!plcs.isEmpty()) { - TBasePallet palletChk = plcs.get(0); - if ("1".equals(palletChk.getIsLock())) { - resultMap.put("error", "托盘号【" + params.getCtlNo() + "】已禁用"); - log.error("托盘号【" + params.getCtlNo() + "】已禁用"); - throw new RuntimeException("托盘号【" + params.getCtlNo() + "】已禁用"); + LambdaQueryWrapper palletQueryWrapper = new LambdaQueryWrapper<>(); + palletQueryWrapper.eq(TBasePallet::getPalletId, shelfConfirmRequest.getCtlNo()); + List palletMatches = palletMapper.selectList(palletQueryWrapper); + if (!palletMatches.isEmpty()) { + TBasePallet targetPallet = palletMatches.get(0); + if (InboundResourceLockStatus.LOCKED.getCode().equals(targetPallet.getIsLock())) { + resultMap.put("error", "托盘号【" + shelfConfirmRequest.getCtlNo() + "】已禁用"); + log.error("托盘号【" + shelfConfirmRequest.getCtlNo() + "】已禁用"); + throw new RuntimeException("托盘号【" + shelfConfirmRequest.getCtlNo() + "】已禁用"); } - if ("0".equals(palletChk.getStatus()) || StringUtils.isBlank(palletChk.getStatus())) { - TBasePallet tBasePallet = new TBasePallet(); - tBasePallet.setStatus("1"); - tBasePallet.setId(palletChk.getId()); - tBasePallet.setUpdateBy(params.getUserName()); - tBasePallet.setUpdateTime(new Date()); - palletMapper.updateTBasePallet(tBasePallet); + if (InboundResourceOccupancyStatus.IDLE.getCode().equals(targetPallet.getStatus()) + || StringUtils.isBlank(targetPallet.getStatus())) { + TBasePallet palletOccupancyUpdate = new TBasePallet(); + palletOccupancyUpdate.setStatus(InboundResourceOccupancyStatus.OCCUPIED.getCode()); + palletOccupancyUpdate.setId(targetPallet.getId()); + palletOccupancyUpdate.setUpdateBy(shelfConfirmRequest.getUserName()); + palletOccupancyUpdate.setUpdateTime(new Date()); + palletMapper.updateTBasePallet(palletOccupancyUpdate); } } } // List tMiStocks = null; - // if (!ObjectUtils.isEmpty(params.getCtlNo())) { + // if (!ObjectUtils.isEmpty(shelfConfirmRequest.getCtlNo())) { // // 校验同一托盘号在库存中是否存在 - // TMiStock tMiStock = new TMiStock(); - // tMiStock.setCtl(params.getCtlNo()); - // tMiStocks = tMiStockMapper.selectTMiStockList(tMiStock); + // TMiStock stockQuery = new TMiStock(); + // stockQuery.setCtl(shelfConfirmRequest.getCtlNo()); + // tMiStocks = tMiStockMapper.selectTMiStockList(stockQuery); // if (tMiStocks.size() > 0) { - // resultMap.put("error", "托盘【" + params.getCtlNo() + "】已占用,请更换"); + // resultMap.put("error", "托盘【" + shelfConfirmRequest.getCtlNo() + "】已占用,请更换"); // return resultMap; // } // } // // 校验同一库位是否占用 // TMiStock tMiStock2 = new TMiStock(); - // tMiStock2.setLocationId(params.getStorageLocation()); + // tMiStock2.setLocationId(shelfConfirmRequest.getStorageLocation()); // tMiStocks = tMiStockMapper.selectTMiStockList(tMiStock2); // if (tMiStocks.size() > 0) { - // resultMap.put("error", "库位【" + params.getCtlNo() + "】已占用,请更换"); + // resultMap.put("error", "库位【" + shelfConfirmRequest.getCtlNo() + "】已占用,请更换"); // return resultMap; // } // 超期呆滞时间获取 - SysConfig sysConfig = new SysConfig(); - sysConfig.setConfigKey("overdue.stagnation"); - List sList = sysConfigMapper.selectConfigList(sysConfig); + SysConfig overdueStagnationConfigQuery = new SysConfig(); + overdueStagnationConfigQuery.setConfigKey("overdue.stagnation"); + List overdueStagnationConfigList = sysConfigMapper.selectConfigList(overdueStagnationConfigQuery); - if (sList.size() > 0) { - params.getExtras().put("extraTime", sList.get(0).getConfigValue()); + if (overdueStagnationConfigList.size() > 0) { + shelfConfirmRequest.getExtras().put("extraTime", overdueStagnationConfigList.get(0).getConfigValue()); } else { - params.getExtras().put("extraTime", ""); + shelfConfirmRequest.getExtras().put("extraTime", ""); } - List updateNoticeTabs = new ArrayList(); - List insertTMiStocks = new ArrayList(); - List insertTMiStockFs = new ArrayList(); + List updatedNoticeTabs = new ArrayList(); + List realStockRecordsToInsert = new ArrayList(); + List virtualStockRecordsToInsert = new ArrayList(); // 判断通知单明细是否存在为完成的 - Boolean allReceive = true; + Boolean allNoticeTabsCompleted = true; - String noticeId = ""; - TRkWareNotice tRkWareNotice = null; + String inboundNoticeId = ""; + TRkWareNotice inboundNotice = null; String callNoticeId = ""; // 遍历提交的入库任务列表 - for (TOngoodsshelf tOngoodsshelf : params.gettOngoodsshelfList()) { + for (TOngoodsshelf submittedInboundTask : shelfConfirmRequest.gettOngoodsshelfList()) { // 备份呼叫任务号 - callNoticeId = tOngoodsshelf.getCallNoticeId(); + callNoticeId = submittedInboundTask.getCallNoticeId(); - if (StringUtils.isBlank(noticeId)) { + if (StringUtils.isBlank(inboundNoticeId)) { - noticeId = tOngoodsshelf.getAcceId(); + inboundNoticeId = submittedInboundTask.getAcceId(); // 查询入库通知单 - tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(noticeId); + inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(inboundNoticeId); - if (tRkWareNotice == null) { + if (inboundNotice == null) { resultMap.put("error", "入库通知单不存在"); return resultMap; } - if ("2".equals(tRkWareNotice.getReceivingStatus())) { + if (InboundNoticeReceivingStatus.COMPLETED.getCode().equals(inboundNotice.getReceivingStatus())) { resultMap.put("error", "入库通知单已全部收货,请刷新"); return resultMap; } } // 根据ID查询入库通知单明细数据 - TRkWareNoticeTab tabOld = tRkWareNoticeMapper.selectTRkWareNoticeTabById(tOngoodsshelf.getNoticeTabId()); + TRkWareNoticeTab noticeTabToUpdate = tRkWareNoticeMapper.selectTRkWareNoticeTabById(submittedInboundTask.getNoticeTabId()); - if (tabOld == null) { + if (noticeTabToUpdate == null) { resultMap.put("error", "物料的通知单明细不存在"); return resultMap; } - if ("2".equals(tabOld.getReceivingStatus())) { + if (InboundNoticeTabReceivingStatus.COMPLETED.getCode().equals(noticeTabToUpdate.getReceivingStatus())) { continue; } // 累计收货数量 - BigDecimal recNum = tabOld.getRecNum() == null ? BigDecimal.ZERO : tabOld.getRecNum(); + BigDecimal receivedQuantity = noticeTabToUpdate.getRecNum() == null ? BigDecimal.ZERO : noticeTabToUpdate.getRecNum(); //累计入库数量 - BigDecimal acceNum = tabOld.getAcceNum() == null ? BigDecimal.ZERO : tabOld.getAcceNum(); + BigDecimal accumulatedShelvedQuantity = noticeTabToUpdate.getAcceNum() == null ? BigDecimal.ZERO : noticeTabToUpdate.getAcceNum(); // 本次上架数量 - BigDecimal AccNumNew = tOngoodsshelf.getAccNum() == null ? BigDecimal.ZERO : tOngoodsshelf.getAccNum(); + BigDecimal currentShelvedQuantity = submittedInboundTask.getAccNum() == null ? BigDecimal.ZERO : submittedInboundTask.getAccNum(); - if (AccNumNew.compareTo(BigDecimal.ZERO) == 0) { - resultMap.put("error", "物料【" + tabOld.getGoodsName() + "】的上架数量不能为0"); + if (currentShelvedQuantity.compareTo(BigDecimal.ZERO) == 0) { + resultMap.put("error", "物料【" + noticeTabToUpdate.getGoodsName() + "】的上架数量不能为0"); return resultMap; } // 收货状态:全部收货 - String receiveStatus = "2"; + String updatedReceivingStatus = InboundNoticeTabReceivingStatus.COMPLETED.getCode(); - BigDecimal AccNumTotalNum = AccNumNew.add(acceNum); + BigDecimal totalShelvedQuantity = currentShelvedQuantity.add(accumulatedShelvedQuantity); - if (AccNumTotalNum.compareTo(recNum) < 0) { + if (totalShelvedQuantity.compareTo(receivedQuantity) < 0) { /** 部分收货 */ - receiveStatus = "1"; + updatedReceivingStatus = InboundNoticeTabReceivingStatus.PARTIAL.getCode(); } // 设置更新信息 - tabOld.setReceivingStatus(receiveStatus); + noticeTabToUpdate.setReceivingStatus(updatedReceivingStatus); // 本次上架数量 - tabOld.setAmount(AccNumNew); + noticeTabToUpdate.setAmount(currentShelvedQuantity); // 累计上架数量 - tabOld.setAcceNum(AccNumTotalNum); + noticeTabToUpdate.setAcceNum(totalShelvedQuantity); // 托盘 - tabOld.setCtl(params.getCtlNo()); + noticeTabToUpdate.setCtl(shelfConfirmRequest.getCtlNo()); // LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - // queryWrapper.eq(TBaseStorage::getStorageId, tOngoodsshelf.getStorageId()); + // queryWrapper.eq(TBaseStorage::getStorageId, submittedInboundTask.getStorageId()); // TBaseStorage storage = tBaseStorageMapper.selectOne(queryWrapper); // tabOld.setStorageShortName(storage.getStorageShortName()); - tabOld.setUpdateBy(params.getUserName()); - tabOld.setUpdateTime(new Date()); + noticeTabToUpdate.setUpdateBy(shelfConfirmRequest.getUserName()); + noticeTabToUpdate.setUpdateTime(new Date()); // 仓库信息 - tabOld.setStorageId(tOngoodsshelf.getStorageId()); - tabOld.setStorageLocation(params.getStorageLocation()); - tabOld.setApplicant(params.getUserName()); + noticeTabToUpdate.setStorageId(submittedInboundTask.getStorageId()); + noticeTabToUpdate.setStorageLocation(shelfConfirmRequest.getStorageLocation()); + noticeTabToUpdate.setApplicant(shelfConfirmRequest.getUserName()); //更新明细 - tRkWareNoticeTabMapper.updateTRkWareNoticeTab(tabOld); - updateNoticeTabs.add(tabOld); + tRkWareNoticeTabMapper.updateTRkWareNoticeTab(noticeTabToUpdate); + updatedNoticeTabs.add(noticeTabToUpdate); // 入库任务: 3 确认完成 - tOngoodsshelf.setStatus("3"); + submittedInboundTask.setStatus(InboundTaskStatus.CONFIRMED.getCode()); // 库位 - tOngoodsshelf.setLocationId(params.getStorageLocation()); + submittedInboundTask.setLocationId(shelfConfirmRequest.getStorageLocation()); // 托盘号 - tOngoodsshelf.setCtl(params.getCtlNo()); + submittedInboundTask.setCtl(shelfConfirmRequest.getCtlNo()); // 入库时间 - tOngoodsshelf.setOndate(DateUtils.getTime()); + submittedInboundTask.setOndate(DateUtils.getTime()); - TOngoodsshelf rfid = tOngoodsshelfMapper.selectTOngoodsshelfById(tOngoodsshelf.getId()); + TOngoodsshelf storedInboundTask = tOngoodsshelfMapper.selectTOngoodsshelfById(submittedInboundTask.getId()); // 生成入库任务bak数据 - TOngoodsshelfBak tOngoodsshelfBak = new TOngoodsshelfBak(); - BeanUtils.copyProperties(tOngoodsshelf, tOngoodsshelfBak); -// tOngoodsshelfBak.setId(OrderCodeFactory.getOrderCode("TSB", "")); - tOngoodsshelfBakMapper.insertTOngoodsshelfBak(tOngoodsshelfBak); + TOngoodsshelfBak inboundTaskArchive = new TOngoodsshelfBak(); + BeanUtils.copyProperties(submittedInboundTask, inboundTaskArchive); +// inboundTaskArchive.setId(OrderCodeFactory.getOrderCode("TSB", "")); + tOngoodsshelfBakMapper.insertTOngoodsshelfBak(inboundTaskArchive); // 生成库存信息 - if ("0".equals(params.getFictitious())) { - String id = tOngoodsshelf.getId(); - - - insertTMiStocks.add(makeTMiStock(tRkWareNotice, tabOld, params ,rfid)); + if (InboundFictitiousFlag.REAL.getCode().equals(shelfConfirmRequest.getFictitious())) { + realStockRecordsToInsert.add(buildRealStockRecord(inboundNotice, noticeTabToUpdate, shelfConfirmRequest, storedInboundTask)); } else { - insertTMiStockFs.add(makeTMiStockF(tRkWareNotice, tabOld, params)); + virtualStockRecordsToInsert.add(buildVirtualStockRecord(inboundNotice, noticeTabToUpdate, shelfConfirmRequest)); } // 删除入库任务 - tOngoodsshelfMapper.deleteTOngoodsshelfById(tOngoodsshelf.getId()); + tOngoodsshelfMapper.deleteTOngoodsshelfById(submittedInboundTask.getId()); } if (!StringUtils.isEmpty(callNoticeId)) { - TOngoodsshelf tOngoodsshelf = new TOngoodsshelf(); - tOngoodsshelf.setCallNoticeId(callNoticeId); - List tOngoodsshelfs = tOngoodsshelfMapper.selectTOngoodsshelfList(tOngoodsshelf); + TOngoodsshelf remainingTaskQuery = new TOngoodsshelf(); + remainingTaskQuery.setCallNoticeId(callNoticeId); + List remainingInboundTasks = tOngoodsshelfMapper.selectTOngoodsshelfList(remainingTaskQuery); - if (tOngoodsshelfs.size() == 0) { + if (remainingInboundTasks.size() == 0) { // 关闭入库任务通知 - TCallNotice tCallNotice = new TCallNotice(); - tCallNotice.setId(callNoticeId); - tCallNotice.setTaskType("0"); - tCallNotice.setUpdateBy(params.getUserName()); - tCallNotice.setUpdateTime(new Date()); - tNoticeService.updateTaskStatus(tCallNotice); + TCallNotice callNoticeUpdate = new TCallNotice(); + callNoticeUpdate.setId(callNoticeId); + callNoticeUpdate.setTaskType(InboundTaskType.INBOUND.getCode()); + callNoticeUpdate.setUpdateBy(shelfConfirmRequest.getUserName()); + callNoticeUpdate.setUpdateTime(new Date()); + tNoticeService.updateTaskStatus(callNoticeUpdate); } } - if ("0".equals(params.getFictitious())) { + if (InboundFictitiousFlag.REAL.getCode().equals(shelfConfirmRequest.getFictitious())) { // 更新库存信息 - if (insertTMiStocks.size() > 0) { - for (TMiStock tMiStock1 : insertTMiStocks) { - String goodsId = tMiStock1.getGoodsId(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(TBaseGoods::getGoodsId, goodsId); - TBaseGoods tBaseGoods = tBaseGoodsMapper.selectOne(queryWrapper); + if (realStockRecordsToInsert.size() > 0) { + for (TMiStock realStockRecord : realStockRecordsToInsert) { + String goodsId = realStockRecord.getGoodsId(); + LambdaQueryWrapper goodsQueryWrapper = new LambdaQueryWrapper<>(); + goodsQueryWrapper.eq(TBaseGoods::getGoodsId, goodsId); + TBaseGoods baseGoods = tBaseGoodsMapper.selectOne(goodsQueryWrapper); //原来仓库 - if (tBaseGoods == null) { + if (baseGoods == null) { throw new RuntimeException("物料ID:" + goodsId + "在基础物料没维护,请先维护!"); } - tMiStock1.setOriginal(tBaseGoods.getStorageId()); - tMiStock1.setPrice(String.valueOf(tBaseGoods.getPrice())); + realStockRecord.setOriginal(baseGoods.getStorageId()); + realStockRecord.setPrice(String.valueOf(baseGoods.getPrice())); //总价 - BigDecimal shelvesNum = tMiStock1.getShelvesNum(); - BigDecimal price = tBaseGoods.getPrice(); - if (price == null || price.compareTo(BigDecimal.ZERO) == 0) { - price = BigDecimal.ZERO; // 默认值为 1 + BigDecimal shelvedQuantity = realStockRecord.getShelvesNum(); + BigDecimal unitPrice = baseGoods.getPrice(); + if (unitPrice == null || unitPrice.compareTo(BigDecimal.ZERO) == 0) { + unitPrice = BigDecimal.ZERO; // 默认值为 1 } - if (shelvesNum.compareTo(BigDecimal.ZERO) == 0) { + if (shelvedQuantity.compareTo(BigDecimal.ZERO) == 0) { throw new RuntimeException("入库数量为0异常"); } - BigDecimal totalPrice = price.multiply(shelvesNum); - tMiStock1.setTotalMoney(totalPrice); - tMiStock1.setPrice(String.valueOf(price)); + BigDecimal totalPrice = unitPrice.multiply(shelvedQuantity); + realStockRecord.setTotalMoney(totalPrice); + realStockRecord.setPrice(String.valueOf(unitPrice)); - tMiStockMapper.insertTMiStock(tMiStock1); + tMiStockMapper.insertTMiStock(realStockRecord); } } } else { // 更新虚拟库存信息 - if (insertTMiStockFs.size() > 0) { - for (TMiStockF tMiStock1 : insertTMiStockFs) { - tMiStockFMapper.insertTMiStock(tMiStock1); + if (virtualStockRecordsToInsert.size() > 0) { + for (TMiStockF virtualStockRecord : virtualStockRecordsToInsert) { + tMiStockFMapper.insertTMiStock(virtualStockRecord); } } } @@ -1600,126 +1599,126 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl 0) { + if (updatedNoticeTabs.size() > 0) { - Map trkReceiveGoodsTabMap = new HashMap(); + Map receivingGoodsTabByBusinessKey = new HashMap(); - if (tRkReceivingGoods != null) { - for (TRkReceivingGoodsTab goodsTab : tRkReceivingGoods.getTRkReceivingGoodsTabList()) { - trkReceiveGoodsTabMap.put(goodsTab.getSalesOrderNumber() + goodsTab.getGoodsId(), goodsTab); + if (receivingGoods != null) { + for (TRkReceivingGoodsTab receivingGoodsTab : receivingGoods.getTRkReceivingGoodsTabList()) { + receivingGoodsTabByBusinessKey.put(receivingGoodsTab.getSalesOrderNumber() + receivingGoodsTab.getGoodsId(), receivingGoodsTab); } } - List insertGoodsTabs = new ArrayList<>(); + List receivingGoodsTabsToInsert = new ArrayList<>(); // 存货表更新集合 - List tReceivingGoodsTabs = new ArrayList(); + List receivingGoodsTabsToUpdate = new ArrayList(); - for (TRkWareNoticeTab noticeTab : updateNoticeTabs) { - TRkReceivingGoodsTab goodsTab = trkReceiveGoodsTabMap - .get(noticeTab.getSalesOrderNumber() + noticeTab.getGoodsId()); - if (goodsTab != null) { - goodsTab.setRecNum(noticeTab.getRecNum()); - goodsTab.setReceivingStatus(noticeTab.getReceivingStatus()); - goodsTab.setUpdateBy(params.getUserName()); - goodsTab.setUpdateTime(new Date()); - tReceivingGoodsTabs.add(goodsTab); + for (TRkWareNoticeTab updatedNoticeTab : updatedNoticeTabs) { + TRkReceivingGoodsTab receivingGoodsTabToUpdate = receivingGoodsTabByBusinessKey + .get(updatedNoticeTab.getSalesOrderNumber() + updatedNoticeTab.getGoodsId()); + if (receivingGoodsTabToUpdate != null) { + receivingGoodsTabToUpdate.setRecNum(updatedNoticeTab.getRecNum()); + receivingGoodsTabToUpdate.setReceivingStatus(updatedNoticeTab.getReceivingStatus()); + receivingGoodsTabToUpdate.setUpdateBy(shelfConfirmRequest.getUserName()); + receivingGoodsTabToUpdate.setUpdateTime(new Date()); + receivingGoodsTabsToUpdate.add(receivingGoodsTabToUpdate); } else { - goodsTab = new TRkReceivingGoodsTab(); - BeanUtils.copyProperties(noticeTab, goodsTab); - goodsTab.setNoticeId(trkReceivingGoodsId); -// goodsTab.setId(OrderCodeFactory.getOrderCode("RTAB", "")); - insertGoodsTabs.add(goodsTab); + TRkReceivingGoodsTab receivingGoodsTabToInsert = new TRkReceivingGoodsTab(); + BeanUtils.copyProperties(updatedNoticeTab, receivingGoodsTabToInsert); + receivingGoodsTabToInsert.setNoticeId(receivingGoodsId); +// receivingGoodsTabToInsert.setId(OrderCodeFactory.getOrderCode("RTAB", "")); + receivingGoodsTabsToInsert.add(receivingGoodsTabToInsert); } } - if (tReceivingGoodsTabs.size() > 0) { + if (receivingGoodsTabsToUpdate.size() > 0) { // 批量更新存货明细表 - tRkReceivingGoodsMapper.updateForeach(tReceivingGoodsTabs); + tRkReceivingGoodsMapper.updateForeach(receivingGoodsTabsToUpdate); } - if (insertGoodsTabs.size() > 0) { - tRkReceivingGoodsMapper.batchTRkReceivingGoodsTab(insertGoodsTabs); + if (receivingGoodsTabsToInsert.size() > 0) { + tRkReceivingGoodsMapper.batchTRkReceivingGoodsTab(receivingGoodsTabsToInsert); } } // 入库通知单及明细数据 移到 bak表 - if (allReceive) { + if (allNoticeTabsCompleted) { // 查询入库通知单明细 - tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(tRkWareNotice.getNoticeId()); - TRkWareNoticeBak tRkWareNoticeBak = new TRkWareNoticeBak(); - BeanUtils.copyProperties(tRkWareNotice, tRkWareNoticeBak); -// String tRkWareNoticeBakId = OrderCodeFactory.getOrderCode("TRKBAK", ""); -// tRkWareNoticeBak.setId(tRkWareNoticeBakId); - tRkWareNoticeBakMapper.insertTRkWareNoticeBak(tRkWareNoticeBak); + inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeByNoticeId(inboundNotice.getNoticeId()); + TRkWareNoticeBak inboundNoticeBakRecord = new TRkWareNoticeBak(); + BeanUtils.copyProperties(inboundNotice, inboundNoticeBakRecord); +// String inboundNoticeBakId = OrderCodeFactory.getOrderCode("TRKBAK", ""); +// inboundNoticeBakRecord.setId(inboundNoticeBakId); + tRkWareNoticeBakMapper.insertTRkWareNoticeBak(inboundNoticeBakRecord); - List tRkWareNoticeTabBaks = new ArrayList(); - for (TRkWareNoticeTab trWareNoticeTab : tRkWareNotice.getTRkWareNoticeTabList()) { - TRkWareNoticeTabBak tRkWareNoticeTabBak = new TRkWareNoticeTabBak(); -// trWareNoticeTab.setId(OrderCodeFactory.getOrderCode("TRKTABBAK", "")); -// trWareNoticeTab.setNoticeId(tRkWareNoticeBakId); - BeanUtils.copyProperties(trWareNoticeTab, tRkWareNoticeTabBak); - tRkWareNoticeTabBak.setPurchaser(tRkWareNotice.getPurchaser()); - tRkWareNoticeTabBak.setSendeDate(tRkWareNotice.getSendeDate()); - tRkWareNoticeTabBak.setProviderName(tRkWareNotice.getProviderName()); - tRkWareNoticeBak.setRecPerson(tRkWareNotice.getRecPerson()); - tRkWareNoticeTabBaks.add(tRkWareNoticeTabBak); + List inboundNoticeTabBakRecords = new ArrayList(); + for (TRkWareNoticeTab inboundNoticeTab : inboundNotice.getTRkWareNoticeTabList()) { + TRkWareNoticeTabBak inboundNoticeTabBakRecord = new TRkWareNoticeTabBak(); +// inboundNoticeTab.setId(OrderCodeFactory.getOrderCode("TRKTABBAK", "")); +// inboundNoticeTab.setNoticeId(inboundNoticeBakId); + BeanUtils.copyProperties(inboundNoticeTab, inboundNoticeTabBakRecord); + inboundNoticeTabBakRecord.setPurchaser(inboundNotice.getPurchaser()); + inboundNoticeTabBakRecord.setSendeDate(inboundNotice.getSendeDate()); + inboundNoticeTabBakRecord.setProviderName(inboundNotice.getProviderName()); + inboundNoticeBakRecord.setRecPerson(inboundNotice.getRecPerson()); + inboundNoticeTabBakRecords.add(inboundNoticeTabBakRecord); } - if (tRkWareNoticeTabBaks.size() > 0) { - tRkWareNoticeBakMapper.batchTRkWareNoticeTabBak(tRkWareNoticeTabBaks); + if (inboundNoticeTabBakRecords.size() > 0) { + tRkWareNoticeBakMapper.batchTRkWareNoticeTabBak(inboundNoticeTabBakRecords); } // 删除入库通知单和明细 - tRkWareNoticeMapper.deleteTRkWareNoticeById(tRkWareNotice.getId()); - tRkWareNoticeMapper.deleteNoticeTabByNoticeId(tRkWareNotice.getId()); + tRkWareNoticeMapper.deleteTRkWareNoticeById(inboundNotice.getId()); + tRkWareNoticeMapper.deleteNoticeTabByNoticeId(inboundNotice.getId()); // 关闭入库通知单任务消息 - TCallNoticeOrder tCallNotice = new TCallNoticeOrder(); - tCallNotice.setTaskId(tRkWareNotice.getId()); - tCallNotice.setTaskType("0"); - tCallNotice.setUpdateBy(params.getUserName()); - tCallNotice.setUpdateTime(new Date()); - tNoticeOrderService.updateTaskStatus(tCallNotice); + TCallNoticeOrder callNoticeOrderStatusUpdate = new TCallNoticeOrder(); + callNoticeOrderStatusUpdate.setTaskId(inboundNotice.getId()); + callNoticeOrderStatusUpdate.setTaskType(InboundTaskType.INBOUND.getCode()); + callNoticeOrderStatusUpdate.setUpdateBy(shelfConfirmRequest.getUserName()); + callNoticeOrderStatusUpdate.setUpdateTime(new Date()); + tNoticeOrderService.updateTaskStatus(callNoticeOrderStatusUpdate); } resultMap.put("success", "上架成功"); @@ -1739,16 +1738,16 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl dataList, boolean isUpdateSupport, String operName) { - if (StringUtils.isNull(dataList) || dataList.size() == 0) { + public String importData(List importedNoticeTabs, boolean isUpdateSupport, String operName) { + if (StringUtils.isNull(importedNoticeTabs) || importedNoticeTabs.size() == 0) { throw new ServiceException("导入入库通知单数据不能为空!"); } - int successNum = 0; - int failureNum = 0; - StringBuilder successMsg = new StringBuilder(); - StringBuilder failureMsg = new StringBuilder(); - TRkWareNoticeTab tRkWareNoticeTab1 = dataList.get(0); - TRkWareNotice tRkWareNotice = new TRkWareNotice(); + int successCount = 0; + int failureCount = 0; + StringBuilder successMessage = new StringBuilder(); + StringBuilder failureMessage = new StringBuilder(); + TRkWareNoticeTab firstImportedNoticeTab = importedNoticeTabs.get(0); + TRkWareNotice importedNotice = new TRkWareNotice(); //来源单号生成 Random random = new Random(); @@ -1756,84 +1755,84 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl tRkWareNotices = tRkWareNoticeMapper.selectTRkWareNoticeList(tRkWareNotice); - if (tRkWareNotices.size() == 0) { - setTrkNotice(tRkWareNotice, tRkWareNoticeTab1, operName); - tRkWareNotice.setReceivingStatus("0"); - tRkWareNotice.setStorageMode("1"); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + importedNotice.setDeliveryId(firstImportedNoticeTab.getDeliveryId()); + List duplicateNotices = tRkWareNoticeMapper.selectTRkWareNoticeList(importedNotice); + if (duplicateNotices.size() == 0) { + setTrkNotice(importedNotice, firstImportedNoticeTab, operName); + importedNotice.setReceivingStatus("0"); + importedNotice.setStorageMode("1"); + tRkWareNoticeMapper.insertTRkWareNotice(importedNotice); } else if (isUpdateSupport) { - List collect = tRkWareNotices.stream().map(TRkWareNotice::getId).collect(Collectors.toList()); - tRkWareNoticeMapper.deleteTRkWareNoticeByIds(collect.toArray(new String[collect.size()])); - setTrkNotice(tRkWareNotice, tRkWareNoticeTab1, operName); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + List noticeIdsToDelete = duplicateNotices.stream().map(TRkWareNotice::getId).collect(Collectors.toList()); + tRkWareNoticeMapper.deleteTRkWareNoticeByIds(noticeIdsToDelete.toArray(new String[noticeIdsToDelete.size()])); + setTrkNotice(importedNotice, firstImportedNoticeTab, operName); + tRkWareNoticeMapper.insertTRkWareNotice(importedNotice); } else { - throw new ServiceException("来源单号 " + tRkWareNoticeTab1.getDeliveryId() + " 重复导入异常!"); + throw new ServiceException("来源单号 " + firstImportedNoticeTab.getDeliveryId() + " 重复导入异常!"); } - for (int i = 0; i < dataList.size(); i++) { + for (int importIndex = 0; importIndex < importedNoticeTabs.size(); importIndex++) { try { //校验必输字段 - TRkWareNoticeTab tab = dataList.get(i); - checkData(i, tab); + TRkWareNoticeTab importedNoticeTab = importedNoticeTabs.get(importIndex); + validateImportedNoticeTab(importIndex, importedNoticeTab); // 验证是否存在该明细 -// tab.setDeliveryId(tab.getDeliveryId()); - TRkWareNoticeTab tRkWareNoticeTab = new TRkWareNoticeTab(); - tRkWareNoticeTab.setSalesOrderNumber(tab.getSalesOrderNumber()); - tRkWareNoticeTab.setGoodsId(tab.getGoodsId()); - tRkWareNoticeTab.setReceivingStatus("0"); - tRkWareNoticeTab.setInStatus("0"); - tab.setDataSource("二级库"); - tRkWareNoticeTab.setDataSource("二级库"); +// importedNoticeTab.setDeliveryId(importedNoticeTab.getDeliveryId()); + TRkWareNoticeTab noticeTabQuery = new TRkWareNoticeTab(); + noticeTabQuery.setSalesOrderNumber(importedNoticeTab.getSalesOrderNumber()); + noticeTabQuery.setGoodsId(importedNoticeTab.getGoodsId()); + noticeTabQuery.setReceivingStatus("0"); + noticeTabQuery.setInStatus("0"); + importedNoticeTab.setDataSource("二级库"); + noticeTabQuery.setDataSource("二级库"); - tab.setLevelType("2"); + importedNoticeTab.setLevelType("2"); - List tRkWareNoticeTabs = tRkWareNoticeTabMapper.selectTRkWareNoticeTabList(tRkWareNoticeTab); + List duplicateNoticeTabs = tRkWareNoticeTabMapper.selectTRkWareNoticeTabList(noticeTabQuery); - if (tRkWareNoticeTabs.size() == 0) { - setTab(tab, tRkWareNotice.getId(), operName); - tab.setDeliveryId(tRkWareNoticeTab1.getDeliveryId()); - tab.setSourceNum(tRkWareNoticeTab1.getDeliveryId()); - tab.setRecNumNow(null); - tab.setRecNum(null); - tab.setReceivingNum(tab.getArraMount()); - tRkWareNoticeTabMapper.insertTRkWareNoticeTab(tab); - successNum++; - successMsg.append("
" + successNum + "、物料编号 " + tab.getGoodsId() + " 导入成功"); + if (duplicateNoticeTabs.size() == 0) { + initializeNoticeTabForInsert(importedNoticeTab, importedNotice.getId(), operName); + importedNoticeTab.setDeliveryId(firstImportedNoticeTab.getDeliveryId()); + importedNoticeTab.setSourceNum(firstImportedNoticeTab.getDeliveryId()); + importedNoticeTab.setRecNumNow(null); + importedNoticeTab.setRecNum(null); + importedNoticeTab.setReceivingNum(importedNoticeTab.getArraMount()); + tRkWareNoticeTabMapper.insertTRkWareNoticeTab(importedNoticeTab); + successCount++; + successMessage.append("
" + successCount + "、物料编号 " + importedNoticeTab.getGoodsId() + " 导入成功"); } else if (isUpdateSupport) { - List collect = tRkWareNoticeTabs.stream().map(TRkWareNoticeTab::getId).collect(Collectors.toList()); - tRkWareNoticeTabMapper.deleteTRkWareNoticeTabByIds(collect.toArray(new String[collect.size()])); - setTab(tab, tRkWareNotice.getId(), operName); - tab.setDeliveryId(tRkWareNoticeTab1.getDeliveryId()); - tab.setSourceNum(tRkWareNoticeTab1.getDeliveryId()); - tab.setRecNumNow(null); - tab.setRecNum(null); - tab.setReceivingNum(tab.getArraMount()); - tRkWareNoticeTabMapper.insertTRkWareNoticeTab(tab); - successNum++; - successMsg.append("
" + successNum + "、物料编号 " + tab.getGoodsId() + " 更新成功"); + List noticeTabIdsToDelete = duplicateNoticeTabs.stream().map(TRkWareNoticeTab::getId).collect(Collectors.toList()); + tRkWareNoticeTabMapper.deleteTRkWareNoticeTabByIds(noticeTabIdsToDelete.toArray(new String[noticeTabIdsToDelete.size()])); + initializeNoticeTabForInsert(importedNoticeTab, importedNotice.getId(), operName); + importedNoticeTab.setDeliveryId(firstImportedNoticeTab.getDeliveryId()); + importedNoticeTab.setSourceNum(firstImportedNoticeTab.getDeliveryId()); + importedNoticeTab.setRecNumNow(null); + importedNoticeTab.setRecNum(null); + importedNoticeTab.setReceivingNum(importedNoticeTab.getArraMount()); + tRkWareNoticeTabMapper.insertTRkWareNoticeTab(importedNoticeTab); + successCount++; + successMessage.append("
" + successCount + "、物料编号 " + importedNoticeTab.getGoodsId() + " 更新成功"); } else { - failureNum++; - failureMsg.append("
" + failureNum + "、物料编号 " + tab.getGoodsId() + " 已存在"); + failureCount++; + failureMessage.append("
" + failureCount + "、物料编号 " + importedNoticeTab.getGoodsId() + " 已存在"); } } catch (Exception e) { - failureNum++; - String msg = "
" + failureNum + "、来源单号 " + tRkWareNoticeTab1.getDeliveryId() + " 导入失败:"; - failureMsg.append(msg + e.getMessage()); + failureCount++; + String msg = "
" + failureCount + "、来源单号 " + firstImportedNoticeTab.getDeliveryId() + " 导入失败:"; + failureMessage.append(msg + e.getMessage()); log.error(msg, e); } } - if (failureNum > 0) { - failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new ServiceException(failureMsg.toString()); + if (failureCount > 0) { + failureMessage.insert(0, "很抱歉,导入失败!共 " + failureCount + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMessage.toString()); } else { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + successMessage.insert(0, "恭喜您,数据已全部导入成功!共 " + successCount + " 条,数据如下:"); } - return successMsg.toString(); + return successMessage.toString(); } /** @@ -1846,16 +1845,16 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl dataList, boolean isUpdateSupport, String operName) { - if (StringUtils.isNull(dataList) || dataList.size() == 0) { + public String importExcelData(List importedExcelNoticeTabs, boolean isUpdateSupport, String operName) { + if (StringUtils.isNull(importedExcelNoticeTabs) || importedExcelNoticeTabs.size() == 0) { throw new ServiceException("导入入库通知单数据不能为空!"); } - int successNum = 0; - int failureNum = 0; - StringBuilder successMsg = new StringBuilder(); - StringBuilder failureMsg = new StringBuilder(); - TRkWareNoticeTabExcel tRkWareNoticeTab1 = dataList.get(0); - TRkWareNotice tRkWareNotice = new TRkWareNotice(); + int successCount = 0; + int failureCount = 0; + StringBuilder successMessage = new StringBuilder(); + StringBuilder failureMessage = new StringBuilder(); + TRkWareNoticeTabExcel firstImportedNoticeTab = importedExcelNoticeTabs.get(0); + TRkWareNotice importedNotice = new TRkWareNotice(); //来源单号生成 Random random = new Random(); @@ -1863,13 +1862,13 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl tRkWareNotices = tRkWareNoticeMapper.selectTRkWareNoticeList(tRkWareNotice); - if (tRkWareNotices.size() == 0) { - setExcelTrkNotice(tRkWareNotice, tRkWareNoticeTab1, operName); - tRkWareNotice.setReceivingStatus("0"); - tRkWareNotice.setStorageMode("1"); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + importedNotice.setDeliveryId(firstImportedNoticeTab.getPurchaseId()); + List duplicateNotices = tRkWareNoticeMapper.selectTRkWareNoticeList(importedNotice); + if (duplicateNotices.size() == 0) { + setExcelTrkNotice(importedNotice, firstImportedNoticeTab, operName); + importedNotice.setReceivingStatus("0"); + importedNotice.setStorageMode("1"); + tRkWareNoticeMapper.insertTRkWareNotice(importedNotice); // TRkWareNotice notice2 = new TRkWareNotice(); // notice2.setId(tRkWareNotice.getId()); @@ -1877,46 +1876,46 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl collect = tRkWareNotices.stream().map(TRkWareNotice::getId).collect(Collectors.toList()); - tRkWareNoticeMapper.deleteTRkWareNoticeByIds(collect.toArray(new String[collect.size()])); - setExcelTrkNotice(tRkWareNotice, tRkWareNoticeTab1, operName); - tRkWareNotice.setReceivingStatus("0"); - tRkWareNotice.setStorageMode("1"); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + List noticeIdsToDelete = duplicateNotices.stream().map(TRkWareNotice::getId).collect(Collectors.toList()); + tRkWareNoticeMapper.deleteTRkWareNoticeByIds(noticeIdsToDelete.toArray(new String[noticeIdsToDelete.size()])); + setExcelTrkNotice(importedNotice, firstImportedNoticeTab, operName); + importedNotice.setReceivingStatus("0"); + importedNotice.setStorageMode("1"); + tRkWareNoticeMapper.insertTRkWareNotice(importedNotice); } else { - throw new ServiceException("来源单号 " + tRkWareNoticeTab1.getDeliveryId() + " 重复导入异常!"); + throw new ServiceException("来源单号 " + firstImportedNoticeTab.getDeliveryId() + " 重复导入异常!"); } - for (int i = 0; i < dataList.size(); i++) { + for (int importIndex = 0; importIndex < importedExcelNoticeTabs.size(); importIndex++) { try { //校验必输字段 - TRkWareNoticeTabExcel tab = dataList.get(i); -// checkData(i, tab); + TRkWareNoticeTabExcel importedExcelNoticeTab = importedExcelNoticeTabs.get(importIndex); +// validateImportedNoticeTab(importIndex, importedExcelNoticeTab); // 验证是否存在该明细 - tab.setDeliveryId(tab.getPurchaseId()); - TRkWareNoticeTab tRkWareNoticeTab = new TRkWareNoticeTab(); - tRkWareNoticeTab.setSalesOrderNumber(tab.getSalesOrderNumber()); - tRkWareNoticeTab.setGoodsId(tab.getGoodsId()); - tRkWareNoticeTab.setReceivingStatus("0"); - tRkWareNoticeTab.setInStatus("0"); - tRkWareNoticeTab.setDataSource("一级库"); + importedExcelNoticeTab.setDeliveryId(importedExcelNoticeTab.getPurchaseId()); + TRkWareNoticeTab noticeTabQuery = new TRkWareNoticeTab(); + noticeTabQuery.setSalesOrderNumber(importedExcelNoticeTab.getSalesOrderNumber()); + noticeTabQuery.setGoodsId(importedExcelNoticeTab.getGoodsId()); + noticeTabQuery.setReceivingStatus("0"); + noticeTabQuery.setInStatus("0"); + noticeTabQuery.setDataSource("一级库"); - tab.setDataSource("一级库"); - tab.setLevelType("1"); + importedExcelNoticeTab.setDataSource("一级库"); + importedExcelNoticeTab.setLevelType("1"); SimpleDateFormat originalFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { - if (StringUtils.isNotBlank(tab.getExpiryDate())) { - Date date = originalFormat.parse(tab.getExpiryDate()); - Date date1 = originalFormat.parse(tab.getPlanDate()); - String formattedDate = targetFormat.format(date); - String formattedDate1 = targetFormat.format(date1); - System.out.println(formattedDate); - tab.setExpiryDate(formattedDate); - tab.setPlanDate(formattedDate1); + if (StringUtils.isNotBlank(importedExcelNoticeTab.getExpiryDate())) { + Date expiryDate = originalFormat.parse(importedExcelNoticeTab.getExpiryDate()); + Date planDate = originalFormat.parse(importedExcelNoticeTab.getPlanDate()); + String formattedExpiryDate = targetFormat.format(expiryDate); + String formattedPlanDate = targetFormat.format(planDate); + System.out.println(formattedExpiryDate); + importedExcelNoticeTab.setExpiryDate(formattedExpiryDate); + importedExcelNoticeTab.setPlanDate(formattedPlanDate); } } catch (ParseException e) { @@ -1924,150 +1923,150 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl tRkWareNoticeTabs = tRkWareNoticeTabMapper.selectTRkWareNoticeTabList(tRkWareNoticeTab); - tab1.setDeliveryId(tRkWareNoticeTab1.getDeliveryId()); - tab1.setSourceNum(tRkWareNoticeTab1.getDeliveryId()); - if (tRkWareNoticeTabs.size() == 0) { - logger.info("createBy:{}", tab1.getCreateBy()); - setTab(tab1, tRkWareNotice.getId(), operName); - tab1.setReceivingNum(tab.getArraMount()); - logger.info("createBy:{}", tab1.getCreateBy()); - tRkWareNoticeTabMapper.insertTRkWareNoticeTab(tab1); -// TRkWareNoticeTab tab2 = new TRkWareNoticeTab(); -// tab2.setId(tab1.getId()); -// tab2.setCreateBy(operName); -// tRkWareNoticeTabMapper.updateTRkWareNoticeTab(tab2); -// logger.info("createBy:{}",tab1.getCreateBy()); - successNum++; - successMsg.append("
" + successNum + "、物料编号 " + tab.getGoodsId() + " 导入成功"); + TRkWareNoticeTab noticeTabToInsert = new TRkWareNoticeTab(); + BeanUtils.copyProperties(importedExcelNoticeTab, noticeTabToInsert); + List duplicateNoticeTabs = tRkWareNoticeTabMapper.selectTRkWareNoticeTabList(noticeTabQuery); + noticeTabToInsert.setDeliveryId(firstImportedNoticeTab.getDeliveryId()); + noticeTabToInsert.setSourceNum(firstImportedNoticeTab.getDeliveryId()); + if (duplicateNoticeTabs.size() == 0) { + logger.info("createBy:{}", noticeTabToInsert.getCreateBy()); + initializeNoticeTabForInsert(noticeTabToInsert, importedNotice.getId(), operName); + noticeTabToInsert.setReceivingNum(importedExcelNoticeTab.getArraMount()); + logger.info("createBy:{}", noticeTabToInsert.getCreateBy()); + tRkWareNoticeTabMapper.insertTRkWareNoticeTab(noticeTabToInsert); +// TRkWareNoticeTab noticeTabToUpdate = new TRkWareNoticeTab(); +// noticeTabToUpdate.setId(noticeTabToInsert.getId()); +// noticeTabToUpdate.setCreateBy(operName); +// tRkWareNoticeTabMapper.updateTRkWareNoticeTab(noticeTabToUpdate); +// logger.info("createBy:{}", noticeTabToInsert.getCreateBy()); + successCount++; + successMessage.append("
" + successCount + "、物料编号 " + importedExcelNoticeTab.getGoodsId() + " 导入成功"); } else if (isUpdateSupport) { - List collect = tRkWareNoticeTabs.stream().map(TRkWareNoticeTab::getId).collect(Collectors.toList()); - tRkWareNoticeTabMapper.deleteTRkWareNoticeTabByIds(collect.toArray(new String[collect.size()])); - setTab(tab1, tRkWareNotice.getId(), operName); - tab1.setReceivingNum(tab.getArraMount()); - tRkWareNoticeTabMapper.insertTRkWareNoticeTab(tab1); - successNum++; - successMsg.append("
" + successNum + "、物料编号 " + tab.getGoodsId() + " 更新成功"); + List noticeTabIdsToDelete = duplicateNoticeTabs.stream().map(TRkWareNoticeTab::getId).collect(Collectors.toList()); + tRkWareNoticeTabMapper.deleteTRkWareNoticeTabByIds(noticeTabIdsToDelete.toArray(new String[noticeTabIdsToDelete.size()])); + initializeNoticeTabForInsert(noticeTabToInsert, importedNotice.getId(), operName); + noticeTabToInsert.setReceivingNum(importedExcelNoticeTab.getArraMount()); + tRkWareNoticeTabMapper.insertTRkWareNoticeTab(noticeTabToInsert); + successCount++; + successMessage.append("
" + successCount + "、物料编号 " + importedExcelNoticeTab.getGoodsId() + " 更新成功"); } else { - failureNum++; - failureMsg.append("
" + failureNum + "、物料编号 " + tab.getGoodsId() + " 已存在"); + failureCount++; + failureMessage.append("
" + failureCount + "、物料编号 " + importedExcelNoticeTab.getGoodsId() + " 已存在"); } } catch (Exception e) { - failureNum++; - String msg = "
" + failureNum + "、来源单号 " + tRkWareNoticeTab1.getDeliveryId() + " 导入失败:"; - failureMsg.append(msg + e.getMessage()); + failureCount++; + String msg = "
" + failureCount + "、来源单号 " + firstImportedNoticeTab.getDeliveryId() + " 导入失败:"; + failureMessage.append(msg + e.getMessage()); log.error(msg, e); } } - if (failureNum > 0) { - failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new ServiceException(failureMsg.toString()); + if (failureCount > 0) { + failureMessage.insert(0, "很抱歉,导入失败!共 " + failureCount + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMessage.toString()); } else { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + successMessage.insert(0, "恭喜您,数据已全部导入成功!共 " + successCount + " 条,数据如下:"); } - return successMsg.toString(); + return successMessage.toString(); } - private void setTab(TRkWareNoticeTab tab, String id, String operName) { - tab.setId(OrderCodeFactory.getOrderCode("", "")); - tab.setNoticeId(id); - tab.setCreateBy(operName); - tab.setInStatus("0"); - tab.setStatus("0"); - tab.setCreateTime(DateUtils.getNowDate()); + private void initializeNoticeTabForInsert(TRkWareNoticeTab noticeTabToInsert, String noticeId, String operName) { + noticeTabToInsert.setId(OrderCodeFactory.getOrderCode("", "")); + noticeTabToInsert.setNoticeId(noticeId); + noticeTabToInsert.setCreateBy(operName); + noticeTabToInsert.setInStatus("0"); + noticeTabToInsert.setStatus("0"); + noticeTabToInsert.setCreateTime(DateUtils.getNowDate()); } - private void setExcelTrkNotice(TRkWareNotice tRkWareNotice, TRkWareNoticeTabExcel tRkWareNoticeTab1, String operName) { - tRkWareNotice.setId(OrderCodeFactory.getOrderCode("", "")); - tRkWareNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); - tRkWareNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); - if (StringUtils.isBlank(tRkWareNoticeTab1.getApplicant())) { - tRkWareNotice.setApplicant(tRkWareNoticeTab1.getPurchaser()); + private void setExcelTrkNotice(TRkWareNotice inboundNotice, TRkWareNoticeTabExcel importedNoticeTab, String operName) { + inboundNotice.setId(OrderCodeFactory.getOrderCode("", "")); + inboundNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); + inboundNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); + if (StringUtils.isBlank(importedNoticeTab.getApplicant())) { + inboundNotice.setApplicant(importedNoticeTab.getPurchaser()); } else { - tRkWareNotice.setApplicant(tRkWareNoticeTab1.getApplicant()); + inboundNotice.setApplicant(importedNoticeTab.getApplicant()); } - tRkWareNotice.setOperatorId(SecurityUtils.getUserNick()); - tRkWareNotice.setOrderType(tRkWareNoticeTab1.getOrderType()); - tRkWareNotice.setReceiveAddr(tRkWareNoticeTab1.getReceiveAddr()); - tRkWareNotice.setReceiver(tRkWareNoticeTab1.getReceiver()); - tRkWareNotice.setReceiverDept(tRkWareNoticeTab1.getReceiverDept()); - tRkWareNotice.setProviderId(tRkWareNoticeTab1.getProviderId()); - tRkWareNotice.setProviderName(tRkWareNoticeTab1.getProviderName()); - tRkWareNotice.setShippingDept(tRkWareNoticeTab1.getShippingDept()); - tRkWareNotice.setContact(tRkWareNoticeTab1.getContact()); - tRkWareNotice.setTelephone(tRkWareNoticeTab1.getNeedTel()); - tRkWareNotice.setSendeDate(tRkWareNoticeTab1.getSendeDate()); - tRkWareNotice.setPurchaseDept(tRkWareNoticeTab1.getPurchaseDept()); - tRkWareNotice.setUseReceiver(tRkWareNoticeTab1.getUseReceiver()); - tRkWareNotice.setUseCustodian(tRkWareNoticeTab1.getUseCustodian()); - tRkWareNotice.setUseLeader(tRkWareNoticeTab1.getUseLeader()); - tRkWareNotice.setReceiverDept(tRkWareNoticeTab1.getReceiverDept()); - tRkWareNotice.setTenderer(tRkWareNoticeTab1.getTenderer()); - tRkWareNotice.setCreateBy(operName); - tRkWareNotice.setCreateTime(DateUtils.getNowDate()); - tRkWareNotice.setRecPerson(tRkWareNoticeTab1.getRecPerson()); - tRkWareNotice.setPurchaser(tRkWareNoticeTab1.getPurchaser()); - tRkWareNotice.setArraDate(tRkWareNoticeTab1.getArraDate()); - tRkWareNotice.setDocumentStatus(tRkWareNoticeTab1.getDocumentStatus()); - tRkWareNotice.setDeliveryId(tRkWareNoticeTab1.getPurchaseId()); + inboundNotice.setOperatorId(SecurityUtils.getUserNick()); + inboundNotice.setOrderType(importedNoticeTab.getOrderType()); + inboundNotice.setReceiveAddr(importedNoticeTab.getReceiveAddr()); + inboundNotice.setReceiver(importedNoticeTab.getReceiver()); + inboundNotice.setReceiverDept(importedNoticeTab.getReceiverDept()); + inboundNotice.setProviderId(importedNoticeTab.getProviderId()); + inboundNotice.setProviderName(importedNoticeTab.getProviderName()); + inboundNotice.setShippingDept(importedNoticeTab.getShippingDept()); + inboundNotice.setContact(importedNoticeTab.getContact()); + inboundNotice.setTelephone(importedNoticeTab.getNeedTel()); + inboundNotice.setSendeDate(importedNoticeTab.getSendeDate()); + inboundNotice.setPurchaseDept(importedNoticeTab.getPurchaseDept()); + inboundNotice.setUseReceiver(importedNoticeTab.getUseReceiver()); + inboundNotice.setUseCustodian(importedNoticeTab.getUseCustodian()); + inboundNotice.setUseLeader(importedNoticeTab.getUseLeader()); + inboundNotice.setReceiverDept(importedNoticeTab.getReceiverDept()); + inboundNotice.setTenderer(importedNoticeTab.getTenderer()); + inboundNotice.setCreateBy(operName); + inboundNotice.setCreateTime(DateUtils.getNowDate()); + inboundNotice.setRecPerson(importedNoticeTab.getRecPerson()); + inboundNotice.setPurchaser(importedNoticeTab.getPurchaser()); + inboundNotice.setArraDate(importedNoticeTab.getArraDate()); + inboundNotice.setDocumentStatus(importedNoticeTab.getDocumentStatus()); + inboundNotice.setDeliveryId(importedNoticeTab.getPurchaseId()); } - private void setTrkNotice(TRkWareNotice tRkWareNotice, TRkWareNoticeTab tRkWareNoticeTab1, String operName) { - tRkWareNotice.setId(OrderCodeFactory.getOrderCode("", "")); - tRkWareNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); - tRkWareNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); - tRkWareNotice.setApplicant(tRkWareNoticeTab1.getApplicant()); - tRkWareNotice.setOrderType(tRkWareNoticeTab1.getOrderType()); - tRkWareNotice.setReceiveAddr(tRkWareNoticeTab1.getReceiveAddr()); - tRkWareNotice.setReceiver(tRkWareNoticeTab1.getReceiver()); - tRkWareNotice.setReceiverDept(tRkWareNoticeTab1.getReceiverDept()); - tRkWareNotice.setProviderId(tRkWareNoticeTab1.getProviderId()); - tRkWareNotice.setProviderName(tRkWareNoticeTab1.getProviderName()); - tRkWareNotice.setShippingDept(tRkWareNoticeTab1.getShippingDept()); - tRkWareNotice.setContact(tRkWareNoticeTab1.getContact()); - tRkWareNotice.setTelephone(tRkWareNoticeTab1.getTelephone()); - tRkWareNotice.setSendeDate(tRkWareNoticeTab1.getSendeDate()); - tRkWareNotice.setPurchaseDept(tRkWareNoticeTab1.getPurchaseDept()); - tRkWareNotice.setUseReceiver(tRkWareNoticeTab1.getUseReceiver()); - tRkWareNotice.setUseCustodian(tRkWareNoticeTab1.getUseCustodian()); - tRkWareNotice.setUseLeader(tRkWareNoticeTab1.getUseLeader()); - tRkWareNotice.setReceiverDept(tRkWareNoticeTab1.getReceiverDept()); - tRkWareNotice.setTenderer(tRkWareNoticeTab1.getTenderer()); - tRkWareNotice.setCreateBy(operName); - tRkWareNotice.setCreateTime(DateUtils.getNowDate()); - tRkWareNotice.setRecPerson(tRkWareNoticeTab1.getRecPerson()); - tRkWareNotice.setPurchaser(tRkWareNoticeTab1.getPurchaser()); - tRkWareNotice.setArraDate(tRkWareNoticeTab1.getArraDate()); - tRkWareNotice.setDocumentStatus(tRkWareNoticeTab1.getDocumentStatus()); + private void setTrkNotice(TRkWareNotice inboundNotice, TRkWareNoticeTab sourceNoticeTab, String operName) { + inboundNotice.setId(OrderCodeFactory.getOrderCode("", "")); + inboundNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); + inboundNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); + inboundNotice.setApplicant(sourceNoticeTab.getApplicant()); + inboundNotice.setOrderType(sourceNoticeTab.getOrderType()); + inboundNotice.setReceiveAddr(sourceNoticeTab.getReceiveAddr()); + inboundNotice.setReceiver(sourceNoticeTab.getReceiver()); + inboundNotice.setReceiverDept(sourceNoticeTab.getReceiverDept()); + inboundNotice.setProviderId(sourceNoticeTab.getProviderId()); + inboundNotice.setProviderName(sourceNoticeTab.getProviderName()); + inboundNotice.setShippingDept(sourceNoticeTab.getShippingDept()); + inboundNotice.setContact(sourceNoticeTab.getContact()); + inboundNotice.setTelephone(sourceNoticeTab.getTelephone()); + inboundNotice.setSendeDate(sourceNoticeTab.getSendeDate()); + inboundNotice.setPurchaseDept(sourceNoticeTab.getPurchaseDept()); + inboundNotice.setUseReceiver(sourceNoticeTab.getUseReceiver()); + inboundNotice.setUseCustodian(sourceNoticeTab.getUseCustodian()); + inboundNotice.setUseLeader(sourceNoticeTab.getUseLeader()); + inboundNotice.setReceiverDept(sourceNoticeTab.getReceiverDept()); + inboundNotice.setTenderer(sourceNoticeTab.getTenderer()); + inboundNotice.setCreateBy(operName); + inboundNotice.setCreateTime(DateUtils.getNowDate()); + inboundNotice.setRecPerson(sourceNoticeTab.getRecPerson()); + inboundNotice.setPurchaser(sourceNoticeTab.getPurchaser()); + inboundNotice.setArraDate(sourceNoticeTab.getArraDate()); + inboundNotice.setDocumentStatus(sourceNoticeTab.getDocumentStatus()); } - private void checkData(int index, TRkWareNoticeTab trdata) { + private void validateImportedNoticeTab(int index, TRkWareNoticeTab importedNoticeTab) { //来源单号 - if (StringUtils.isBlank(trdata.getDeliveryId())) { + if (StringUtils.isBlank(importedNoticeTab.getDeliveryId())) { throw new RuntimeException("导入明细第" + (index + 1) + "条来源单号为空"); } - if (StringUtils.isBlank(trdata.getDeliveryId())) { + if (StringUtils.isBlank(importedNoticeTab.getDeliveryId())) { throw new RuntimeException("导入明细第" + (index + 1) + "条来源单号为空"); } - if (StringUtils.isBlank(trdata.getGoodsId())) { + if (StringUtils.isBlank(importedNoticeTab.getGoodsId())) { throw new RuntimeException("导入明细第" + (index + 1) + "条物料编码为空"); } - if (StringUtils.isBlank(trdata.getGoodsName())) { + if (StringUtils.isBlank(importedNoticeTab.getGoodsName())) { throw new RuntimeException("导入明细第" + (index + 1) + "条物料名称为空"); } - if (StringUtils.isBlank(trdata.getUnit())) { + if (StringUtils.isBlank(importedNoticeTab.getUnit())) { throw new RuntimeException("导入明细第" + (index + 1) + "条物料单位为空"); } - if (trdata.getArraMount() == null) { + if (importedNoticeTab.getArraMount() == null) { throw new RuntimeException("导入明细第" + (index + 1) + "条到货数量为空"); } /*if (StringUtils.isBlank(trdata.getApplicant())) { @@ -2080,58 +2079,58 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl sendOrderNotice(TRkWareNoticeTabUpdate update) { + public Map sendOrderNotice(TRkWareNoticeTabUpdate noticePushRequest) { Map resultMap = new HashMap<>(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TCallNoticeOrder::getTaskId, update.getId()); - wrapper.eq(TCallNoticeOrder::getStatus, "0"); - TCallNoticeOrder tCallNoticeOrder = callNoticeOrderMapper.selectOne(wrapper); - if (tCallNoticeOrder != null) { + LambdaQueryWrapper noticeOrderQueryWrapper = new LambdaQueryWrapper<>(); + noticeOrderQueryWrapper.eq(TCallNoticeOrder::getTaskId, noticePushRequest.getId()); + noticeOrderQueryWrapper.eq(TCallNoticeOrder::getStatus, "0"); + TCallNoticeOrder pendingNoticeOrder = callNoticeOrderMapper.selectOne(noticeOrderQueryWrapper); + if (pendingNoticeOrder != null) { resultMap.put("error", "已经推送手持设备,请相关人员查看"); return resultMap; } // 获取通知单信息 - TRkWareNotice tRkWareNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(update.getId()); + TRkWareNotice inboundNotice = tRkWareNoticeMapper.selectTRkWareNoticeById(noticePushRequest.getId()); - if (ObjectUtils.isEmpty(tRkWareNotice)) { + if (ObjectUtils.isEmpty(inboundNotice)) { resultMap.put("error", "待发送消息的入库通知单不存在"); return resultMap; } - if (tRkWareNotice.getTRkWareNoticeTabList() == null || tRkWareNotice.getTRkWareNoticeTabList().isEmpty()) { + if (inboundNotice.getTRkWareNoticeTabList() == null || inboundNotice.getTRkWareNoticeTabList().isEmpty()) { resultMap.put("error", "待发送消息的入库通知单没有物料明细数据"); return resultMap; } // 发送呼叫任务 - TCallNoticeOrder tCallNotice = new TCallNoticeOrder(); + TCallNoticeOrder noticeOrderToSend = new TCallNoticeOrder(); // 通知单编号 - tCallNotice.setTaskId(tRkWareNotice.getId()); + noticeOrderToSend.setTaskId(inboundNotice.getId()); // 任务类型 0:通知单入库 - tCallNotice.setTaskType("0"); + noticeOrderToSend.setTaskType("0"); // 状态 - tCallNotice.setStatus("0"); + noticeOrderToSend.setStatus("0"); // 创建者 - tCallNotice.setCreateBy(update.getCreateBy()); - tCallNotice.setCreateTime(new Date()); - tCallNotice.setUpdateBy(update.getCreateBy()); - tCallNotice.setUpdateTime(new Date()); + noticeOrderToSend.setCreateBy(noticePushRequest.getCreateBy()); + noticeOrderToSend.setCreateTime(new Date()); + noticeOrderToSend.setUpdateBy(noticePushRequest.getCreateBy()); + noticeOrderToSend.setUpdateTime(new Date()); // 0:正常任务 - tCallNotice.setFictitious("0"); + noticeOrderToSend.setFictitious("0"); // 来源单号 - tCallNotice.setDeliveryId(tRkWareNotice.getDeliveryId()); + noticeOrderToSend.setDeliveryId(inboundNotice.getDeliveryId()); // 供应商名 - tCallNotice.setProviderName(tRkWareNotice.getProviderName()); + noticeOrderToSend.setProviderName(inboundNotice.getProviderName()); // 部门ID - tCallNotice.setDeptId(update.getDeptId()); + noticeOrderToSend.setDeptId(noticePushRequest.getDeptId()); // 订单类型 - String storageMode = sysDictDataMapper.selectDictLabel("warehouse_type", tRkWareNotice.getStorageMode()); - tCallNotice.setOrderType(storageMode); - tNoticeOrderService.sendNotice(tCallNotice); + String storageModeLabel = sysDictDataMapper.selectDictLabel("warehouse_type", inboundNotice.getStorageMode()); + noticeOrderToSend.setOrderType(storageModeLabel); + tNoticeOrderService.sendNotice(noticeOrderToSend); resultMap.put("success", "消息发送成功"); resultMap.put("error", ""); @@ -2140,9 +2139,9 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl handAddGoodsTab(TRkWareNoticeTabUpdate update) { + public Map handAddGoodsTab(TRkWareNoticeTabUpdate manualInboundRequest) { -// List noticeTabList = update.getTrkWareNoticeTabList(); +// List noticeTabList = manualInboundRequest.getTrkWareNoticeTabList(); /*noticeTabList.forEach(e->{ String ctl = e.getCtl(); String goodsId = e.getGoodsId(); @@ -2161,349 +2160,351 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl resultMap = new HashMap<>(); - String isAgvByStorageId = tBaseStorageMapper.getIsAgvByStorageId(update.getStorageId()); + String agvStorageFlag = tBaseStorageMapper.getIsAgvByStorageId(manualInboundRequest.getStorageId()); - if (isAgvByStorageId.equals("1")) { - TRkWareNotice tRkWareNotice = createTRkWareNotice(update); - List updateNoticeTabs = new ArrayList<>(); - for (TRkWareNoticeTab tabNew : update.getTrkWareNoticeTabList()) { - updateNoticeTabs.add(createTRkWareNoticeTab(tabNew, rfid, update)); + if (agvStorageFlag.equals("1")) { + TRkWareNotice manualInboundNotice = buildManualInboundNotice(manualInboundRequest); + List noticeTabsToInsert = new ArrayList<>(); + for (TRkWareNoticeTab noticeTabToInsert : manualInboundRequest.getTrkWareNoticeTabList()) { + noticeTabsToInsert.add(buildAgvInboundNoticeTab(noticeTabToInsert, generatedRfid, manualInboundRequest)); } - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); - if (!updateNoticeTabs.isEmpty()) { - tRkWareNoticeMapper.batchTRkWareNoticeTab(updateNoticeTabs); + tRkWareNoticeMapper.insertTRkWareNotice(manualInboundNotice); + if (!noticeTabsToInsert.isEmpty()) { + tRkWareNoticeMapper.batchTRkWareNoticeTab(noticeTabsToInsert); } - Map map = sendIwmsUnified(update); + Map iwmsSyncResult = sendIwmsUnified(manualInboundRequest); - if (map.containsKey("success")) { - resultMap.put("success", map.get("success")); + if (iwmsSyncResult.containsKey("success")) { + resultMap.put("success", iwmsSyncResult.get("success")); } else { - resultMap.put("error", map.get("error")); + resultMap.put("error", iwmsSyncResult.get("error")); } return resultMap; } else { //绑定库位直接上架 - if (StringUtils.isNotBlank(update.getLocationId())) { + if (StringUtils.isNotBlank(manualInboundRequest.getLocationId())) { - LambdaQueryWrapper locWrapper = new LambdaQueryWrapper<>(); - locWrapper.eq(TBaseStorageAreaLocation::getLocationId, update.getLocationId()); - List areaLocations = service.selectList(locWrapper); - if (!areaLocations.isEmpty()) { - TBaseStorageAreaLocation locationCheck = areaLocations.get(0); - if ("1".equals(locationCheck.getIsLock())) { - resultMap.put("error", "库位【" + update.getLocationId() + "】已禁用"); - log.error("库位【" + update.getLocationId() + "】已禁用"); + LambdaQueryWrapper locationQueryWrapper = new LambdaQueryWrapper<>(); + locationQueryWrapper.eq(TBaseStorageAreaLocation::getLocationId, manualInboundRequest.getLocationId()); + List matchedLocations = service.selectList(locationQueryWrapper); + if (!matchedLocations.isEmpty()) { + TBaseStorageAreaLocation targetLocation = matchedLocations.get(0); + if ("1".equals(targetLocation.getIsLock())) { + resultMap.put("error", "库位【" + manualInboundRequest.getLocationId() + "】已禁用"); + log.error("库位【" + manualInboundRequest.getLocationId() + "】已禁用"); return resultMap; } } - if (!ObjectUtils.isEmpty(update.getCtlNo())) { + if (!ObjectUtils.isEmpty(manualInboundRequest.getCtlNo())) { //校验托盘容器是否正确 - LambdaQueryWrapper ctlWrapper = new LambdaQueryWrapper<>(); - ctlWrapper.eq(TBasePallet::getPalletId, update.getCtlNo()); - List plcs = palletMapper.selectList(ctlWrapper); - if (!plcs.isEmpty()) { - TBasePallet palletChk = plcs.get(0); - if ("1".equals(palletChk.getIsLock())) { - resultMap.put("error", "托盘号【" + update.getCtlNo() + "】已禁用"); - log.error("托盘号【" + update.getCtlNo() + "】已禁用"); + LambdaQueryWrapper palletQueryWrapper = new LambdaQueryWrapper<>(); + palletQueryWrapper.eq(TBasePallet::getPalletId, manualInboundRequest.getCtlNo()); + List palletMatches = palletMapper.selectList(palletQueryWrapper); + if (!palletMatches.isEmpty()) { + TBasePallet targetPallet = palletMatches.get(0); + if ("1".equals(targetPallet.getIsLock())) { + resultMap.put("error", "托盘号【" + manualInboundRequest.getCtlNo() + "】已禁用"); + log.error("托盘号【" + manualInboundRequest.getCtlNo() + "】已禁用"); return resultMap; } } } - List tabList = update.getTrkWareNoticeTabList(); - for (TRkWareNoticeTab tab : tabList) { + List submittedNoticeTabs = manualInboundRequest.getTrkWareNoticeTabList(); + for (TRkWareNoticeTab submittedNoticeTab : submittedNoticeTabs) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TBaseGoods::getGoodsId, tab.getGoodsId()); + LambdaQueryWrapper goodsQueryWrapper = new LambdaQueryWrapper<>(); + goodsQueryWrapper.eq(TBaseGoods::getGoodsId, submittedNoticeTab.getGoodsId()); //物料信息 - TBaseGoods tBaseGoods = tBaseGoodsMapper.selectOne(wrapper); + TBaseGoods baseGoods = tBaseGoodsMapper.selectOne(goodsQueryWrapper); - if (tBaseGoods == null) { + if (baseGoods == null) { resultMap.put("error", "暂无物料信息"); return resultMap; } - TMiStock tMiStock = new TMiStock(); - tMiStock.setId(OrderCodeFactory.getOrderCode("TMI", "")); + TMiStock realStockRecord = new TMiStock(); + realStockRecord.setId(OrderCodeFactory.getOrderCode("TMI", "")); // 上架数量 - tMiStock.setShelvesNum(tab.getRecNum()); + realStockRecord.setShelvesNum(submittedNoticeTab.getRecNum()); // 中标供应商 - tMiStock.setProviderId(tab.getProviderId()); + realStockRecord.setProviderId(submittedNoticeTab.getProviderId()); // 单位 - tMiStock.setUnit(tab.getUnit()); + realStockRecord.setUnit(submittedNoticeTab.getUnit()); // 子需求编号 - tMiStock.setSalesOrderNumber(OrderCodeFactory.getOrderCode("SJ", "")); + realStockRecord.setSalesOrderNumber(OrderCodeFactory.getOrderCode("SJ", "")); // 物料名称 - tMiStock.setGoodsName(tBaseGoods.getGoodsName()); + realStockRecord.setGoodsName(baseGoods.getGoodsName()); // 规格型号 - tMiStock.setSpecification(tBaseGoods.getSpecification()); + realStockRecord.setSpecification(baseGoods.getSpecification()); // 物料描述 - tMiStock.setRecoil(tBaseGoods.getRecoil()); + realStockRecord.setRecoil(baseGoods.getRecoil()); // 招标员 - tMiStock.setCustomerId(""); + realStockRecord.setCustomerId(""); // 需求组织 - tMiStock.setOperatorId(SecurityUtils.getUserNick()); + realStockRecord.setOperatorId(SecurityUtils.getUserNick()); // 申请部门 - tMiStock.setSupplier(SecurityUtils.getDeptName()); + realStockRecord.setSupplier(SecurityUtils.getDeptName()); // 创建时间 - tMiStock.setOperateDate(new Date()); + realStockRecord.setOperateDate(new Date()); // 上报时间 - tMiStock.setReportTime(DateUtils.getDate()); + realStockRecord.setReportTime(DateUtils.getDate()); // 申请单号 设置为来源单号 发货单号 TODO - tMiStock.setLotId(OrderCodeFactory.getOrderCode("RK", "")); + realStockRecord.setLotId(OrderCodeFactory.getOrderCode("RK", "")); // 申请人 - tMiStock.setApplicant(SecurityUtils.getUserNick()); + realStockRecord.setApplicant(SecurityUtils.getUserNick()); // 计划日期 - tMiStock.setPlanDate(""); + realStockRecord.setPlanDate(""); // 计划期间 - tMiStock.setPlanTime(""); + realStockRecord.setPlanTime(""); // 需求周期 - tMiStock.setNeedCycle(tab.getNeedCycle()); + realStockRecord.setNeedCycle(submittedNoticeTab.getNeedCycle()); // 需求类型 - tMiStock.setNeedType(tab.getNeedType()); + realStockRecord.setNeedType(submittedNoticeTab.getNeedType()); // 物料编码 - tMiStock.setGoodsId(tab.getGoodsId()); + realStockRecord.setGoodsId(submittedNoticeTab.getGoodsId()); // 物料分类 - tMiStock.setGoodsTypeId(tab.getGoodsTypeId()); + realStockRecord.setGoodsTypeId(submittedNoticeTab.getGoodsTypeId()); // 品牌 - tMiStock.setBrand(tab.getBrand()); + realStockRecord.setBrand(submittedNoticeTab.getBrand()); // 计划单价(含税) - tMiStock.setPrice(tab.getPrice() != null ? tab.getPrice().toString() : null); + realStockRecord.setPrice(submittedNoticeTab.getPrice() != null ? submittedNoticeTab.getPrice().toString() : null); // 计划金额 - BigDecimal shelvesNum = tab.getRecNum(); - BigDecimal price = tBaseGoods.getPrice(); - if (price == null || price.compareTo(BigDecimal.ZERO) == 0) { - price = BigDecimal.ZERO; // 默认值为 1 + BigDecimal shelvedQuantity = submittedNoticeTab.getRecNum(); + BigDecimal unitPrice = baseGoods.getPrice(); + if (unitPrice == null || unitPrice.compareTo(BigDecimal.ZERO) == 0) { + unitPrice = BigDecimal.ZERO; // 默认值为 1 } - tMiStock.setTotalMoney(price.multiply(shelvesNum)); + realStockRecord.setTotalMoney(unitPrice.multiply(shelvedQuantity)); // 需求时间 - tMiStock.setExpiryDate(tab.getExpiryDate()); + realStockRecord.setExpiryDate(submittedNoticeTab.getExpiryDate()); // 建议供应商名称 TODO - tMiStock.setProviderName(tab.getProviderName()); + realStockRecord.setProviderName(submittedNoticeTab.getProviderName()); // 收货人 - tMiStock.setReceiver(SecurityUtils.getUserNick()); + realStockRecord.setReceiver(SecurityUtils.getUserNick()); // 需求部门 - tMiStock.setNeedDept(SecurityUtils.getDeptName()); + realStockRecord.setNeedDept(SecurityUtils.getDeptName()); // 采购组织 - tMiStock.setPurchaseDept(SecurityUtils.getDeptName()); + realStockRecord.setPurchaseDept(SecurityUtils.getDeptName()); // 收货组织 - tMiStock.setProduclotId(SecurityUtils.getDeptName()); + realStockRecord.setProduclotId(SecurityUtils.getDeptName()); // 收货人部门 - tMiStock.setReceiverDept(SecurityUtils.getDeptName()); + realStockRecord.setReceiverDept(SecurityUtils.getDeptName()); // 送货区域 - tMiStock.setReceivingArea(tab.getReceivingArea()); + realStockRecord.setReceivingArea(submittedNoticeTab.getReceivingArea()); // 技术需求附件 - tMiStock.setPackageId(tab.getPackageId()); + realStockRecord.setPackageId(submittedNoticeTab.getPackageId()); // 物资计划明细备注 - tMiStock.setRemark(tab.getRemark()); + realStockRecord.setRemark(submittedNoticeTab.getRemark()); // 用途 - tMiStock.setUseType(tab.getUseType()); + realStockRecord.setUseType(submittedNoticeTab.getUseType()); // 中标供应商联系方式 - tMiStock.setTelephone(tab.getTelephone()); + realStockRecord.setTelephone(submittedNoticeTab.getTelephone()); // wms订单号 入库通知单号 - tMiStock.setNoticeId(tab.getNoticeId()); + realStockRecord.setNoticeId(submittedNoticeTab.getNoticeId()); // 生产日期 - tMiStock.setProductionDate(tab.getProductionDate()); + realStockRecord.setProductionDate(submittedNoticeTab.getProductionDate()); // 入库类型 - tMiStock.setStorageMode("1"); + realStockRecord.setStorageMode("1"); // 仓库编号 - tMiStock.setStorageId(update.getStorageId()); - TBaseStorage agvByStorageId = tBaseStorageMapper.getName(update.getStorageId()); + realStockRecord.setStorageId(manualInboundRequest.getStorageId()); + TBaseStorage targetStorage = tBaseStorageMapper.getName(manualInboundRequest.getStorageId()); - tMiStock.setStorageShortName(agvByStorageId.getStorageShortName()); + realStockRecord.setStorageShortName(targetStorage.getStorageShortName()); // 库位 - tMiStock.setLocationId(update.getStorageLocation()); + realStockRecord.setLocationId(manualInboundRequest.getStorageLocation()); // 增加外部批次号 - tMiStock.setBatchNo(tab.getBatchNo()); + realStockRecord.setBatchNo(submittedNoticeTab.getBatchNo()); // 条码 - tMiStock.setBarcode(tab.getBarcode()); + realStockRecord.setBarcode(submittedNoticeTab.getBarcode()); // 入库级别 - tMiStock.setLevelType(update.getTypes()); + realStockRecord.setLevelType(manualInboundRequest.getTypes()); - tMiStock.setStandard("180"); + realStockRecord.setStandard("180"); // 托盘 - tMiStock.setCtl(update.getCtlNo()); - tMiStock.setOriginal(tBaseGoods.getStorageId()); + realStockRecord.setCtl(manualInboundRequest.getCtlNo()); + realStockRecord.setOriginal(baseGoods.getStorageId()); - tMiStock.setCreateBy(SecurityUtils.getUserNick()); - tMiStock.setCreateTime(new Date()); - tMiStock.setRecordPerson(""); - tMiStock.setLocationId(update.getLocationId()); + realStockRecord.setCreateBy(SecurityUtils.getUserNick()); + realStockRecord.setCreateTime(new Date()); + realStockRecord.setRecordPerson(""); + realStockRecord.setLocationId(manualInboundRequest.getLocationId()); // 入库时间 - tMiStock.setWareDate(DateUtils.getTime()); + realStockRecord.setWareDate(DateUtils.getTime()); - tMiStock.setDeptId(SecurityUtils.getDeptId()); - tMiStock.setNeedPerson(tab.getNeedPerson()); - tMiStock.setNeedTel(tab.getNeedTel()); - tMiStockMapper.insertTMiStock(tMiStock); + realStockRecord.setDeptId(SecurityUtils.getDeptId()); + realStockRecord.setNeedPerson(submittedNoticeTab.getNeedPerson()); + realStockRecord.setNeedTel(submittedNoticeTab.getNeedTel()); + tMiStockMapper.insertTMiStock(realStockRecord); } resultMap.put("success", "入库成功"); return resultMap; } //原来的逻辑 - handleOtherStorage(update, resultMap); + handleNonAgvManualInbound(manualInboundRequest, resultMap); } return resultMap; } - private TRkWareNotice createTRkWareNotice(TRkWareNoticeTabUpdate update) { - TRkWareNotice tRkWareNotice = new TRkWareNotice(); - tRkWareNotice.setId(update.getId()); - tRkWareNotice.setNoticeId(update.getNoticeId()); - tRkWareNotice.setUpdateBy(update.getRecordPerson()); - tRkWareNotice.setUpdateTime(new Date()); - tRkWareNotice.setCreateBy(update.getRecordPerson()); - tRkWareNotice.setCreateTime(new Date()); - tRkWareNotice.setStorageMode("3"); - tRkWareNotice.setReceivingStatus("3"); - tRkWareNotice.setDeptId(update.getDeptId()); - return tRkWareNotice; + private TRkWareNotice buildManualInboundNotice(TRkWareNoticeTabUpdate manualInboundRequest) { + TRkWareNotice manualInboundNotice = new TRkWareNotice(); + manualInboundNotice.setId(manualInboundRequest.getId()); + manualInboundNotice.setNoticeId(manualInboundRequest.getNoticeId()); + manualInboundNotice.setUpdateBy(manualInboundRequest.getRecordPerson()); + manualInboundNotice.setUpdateTime(new Date()); + manualInboundNotice.setCreateBy(manualInboundRequest.getRecordPerson()); + manualInboundNotice.setCreateTime(new Date()); + manualInboundNotice.setStorageMode("3"); + manualInboundNotice.setReceivingStatus("3"); + manualInboundNotice.setDeptId(manualInboundRequest.getDeptId()); + return manualInboundNotice; } - private TRkWareNoticeTab createTRkWareNoticeTab(TRkWareNoticeTab tabNew, String rfid, TRkWareNoticeTabUpdate update) { - tabNew.setSalesOrderNumber(rfid); - tabNew.setReceivingStatus("3"); - tabNew.setInStatus("1"); - tabNew.setRecNumNow(tabNew.getRecNum()); - tabNew.setArraMount(tabNew.getRecNum()); - tabNew.setReceivingNum(tabNew.getRecNum()); - tabNew.setUpdateBy(update.getRecordPerson()); - tabNew.setUpdateTime(new Date()); - tabNew.setCreateBy(update.getRecordPerson()); - tabNew.setCreateTime(new Date()); - tabNew.setNoticeId(update.getId()); - tabNew.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); - tabNew.setLevelType("2"); - return tabNew; + private TRkWareNoticeTab buildAgvInboundNoticeTab(TRkWareNoticeTab noticeTabToInsert, String generatedRfid, + TRkWareNoticeTabUpdate manualInboundRequest) { + noticeTabToInsert.setSalesOrderNumber(generatedRfid); + noticeTabToInsert.setReceivingStatus("3"); + noticeTabToInsert.setInStatus("1"); + noticeTabToInsert.setRecNumNow(noticeTabToInsert.getRecNum()); + noticeTabToInsert.setArraMount(noticeTabToInsert.getRecNum()); + noticeTabToInsert.setReceivingNum(noticeTabToInsert.getRecNum()); + noticeTabToInsert.setUpdateBy(manualInboundRequest.getRecordPerson()); + noticeTabToInsert.setUpdateTime(new Date()); + noticeTabToInsert.setCreateBy(manualInboundRequest.getRecordPerson()); + noticeTabToInsert.setCreateTime(new Date()); + noticeTabToInsert.setNoticeId(manualInboundRequest.getId()); + noticeTabToInsert.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); + noticeTabToInsert.setLevelType("2"); + return noticeTabToInsert; } - private void handleOtherStorage(TRkWareNoticeTabUpdate update, Map resultMap) { - if (ObjectUtils.isEmpty(update.getCtlNo())) { - List plcSList = plcService.selectPlcList(); - Plc plc = plcSList.get(0); - if (plc.getPlcid() == 9999999) { - plc.setPlcid(0L); + private void handleNonAgvManualInbound(TRkWareNoticeTabUpdate manualInboundRequest, Map resultMap) { + if (ObjectUtils.isEmpty(manualInboundRequest.getCtlNo())) { + List plcList = plcService.selectPlcList(); + Plc currentPlc = plcList.get(0); + if (currentPlc.getPlcid() == 9999999) { + currentPlc.setPlcid(0L); } else { - plc.setPlcid(plc.getPlcid() + 1); + currentPlc.setPlcid(currentPlc.getPlcid() + 1); } - plc.setId(1); - plcService.updatePlc(plc); - update.getParams().put("plcId", plc.getPlcid()); + currentPlc.setId(1); + plcService.updatePlc(currentPlc); + manualInboundRequest.getParams().put("plcId", currentPlc.getPlcid()); } else { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TBasePallet::getPalletId, update.getCtlNo()); - List plcs = palletMapper.selectList(wrapper); - if (plcs.isEmpty()) { + LambdaQueryWrapper palletQueryWrapper = new LambdaQueryWrapper<>(); + palletQueryWrapper.eq(TBasePallet::getPalletId, manualInboundRequest.getCtlNo()); + List palletMatches = palletMapper.selectList(palletQueryWrapper); + if (palletMatches.isEmpty()) { resultMap.put("error", "托盘不存在"); return; } - TBasePallet palletChk = plcs.get(0); - if ("1".equals(palletChk.getIsLock())) { - resultMap.put("error", "托盘号【" + update.getCtlNo() + "】已禁用"); - log.error("托盘号【" + update.getCtlNo() + "】已禁用"); - throw new RuntimeException("托盘号【" + update.getCtlNo() + "】已禁用"); + TBasePallet targetPallet = palletMatches.get(0); + if ("1".equals(targetPallet.getIsLock())) { + resultMap.put("error", "托盘号【" + manualInboundRequest.getCtlNo() + "】已禁用"); + log.error("托盘号【" + manualInboundRequest.getCtlNo() + "】已禁用"); + throw new RuntimeException("托盘号【" + manualInboundRequest.getCtlNo() + "】已禁用"); } } - TCallNotice tCallNotice = new TCallNotice(); - tCallNotice.setId(IdUtils.randomUUID()); - update.getParams().put("callNoticeId", tCallNotice.getId()); + TCallNotice inboundCallNotice = new TCallNotice(); + inboundCallNotice.setId(IdUtils.randomUUID()); + manualInboundRequest.getParams().put("callNoticeId", inboundCallNotice.getId()); - TRkWareNotice tRkWareNotice = new TRkWareNotice(); - tRkWareNotice.setId(update.getId()); - tRkWareNotice.setNoticeId(update.getNoticeId()); - tRkWareNotice.setUpdateBy(update.getRecordPerson()); - tRkWareNotice.setUpdateTime(new Date()); - tRkWareNotice.setCreateBy(update.getRecordPerson()); - tRkWareNotice.setCreateTime(new Date()); - tRkWareNotice.setStorageMode("3"); - tRkWareNotice.setReceivingStatus("0"); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + TRkWareNotice manualInboundNotice = new TRkWareNotice(); + manualInboundNotice.setId(manualInboundRequest.getId()); + manualInboundNotice.setNoticeId(manualInboundRequest.getNoticeId()); + manualInboundNotice.setUpdateBy(manualInboundRequest.getRecordPerson()); + manualInboundNotice.setUpdateTime(new Date()); + manualInboundNotice.setCreateBy(manualInboundRequest.getRecordPerson()); + manualInboundNotice.setCreateTime(new Date()); + manualInboundNotice.setStorageMode("3"); + manualInboundNotice.setReceivingStatus("0"); + tRkWareNoticeMapper.insertTRkWareNotice(manualInboundNotice); - List updateNoticeTabs = new ArrayList(); - List insertTOngoodsshelfs = new ArrayList(); + List noticeTabsToInsert = new ArrayList(); + List inboundTasksToInsert = new ArrayList(); // 遍历提交的物料数据明细 - int ziNeedNo = 0; - TBaseStorage tBaseStorage = new TBaseStorage(); + int subDemandSequence = 0; + TBaseStorage storageQuery = new TBaseStorage(); + TBaseStorage storage = new TBaseStorage(); // 获取仓库信息 - if (!ObjectUtils.isEmpty(update.getStorageId())) { - tBaseStorage.setStorageId(update.getStorageId()); - List sTBaseStorages = tBaseStorageMapper.selectTBaseStorageList(tBaseStorage); + if (!ObjectUtils.isEmpty(manualInboundRequest.getStorageId())) { + storageQuery.setStorageId(manualInboundRequest.getStorageId()); + List matchedStorages = tBaseStorageMapper.selectTBaseStorageList(storageQuery); - if (sTBaseStorages.size() > 0) { - tBaseStorage = sTBaseStorages.get(0); + if (matchedStorages.size() > 0) { + storage = matchedStorages.get(0); } } - for (TRkWareNoticeTab tabNew : update.getTrkWareNoticeTabList()) { + for (TRkWareNoticeTab noticeTabToInsert : manualInboundRequest.getTrkWareNoticeTabList()) { // 仓库名称 - tabNew.setStorageShortName(tBaseStorage.getStorageShortName()); + noticeTabToInsert.setStorageShortName(storage.getStorageShortName()); // 子需求编号 - tabNew.setSalesOrderNumber(String.valueOf(ziNeedNo)); - ziNeedNo++; + noticeTabToInsert.setSalesOrderNumber(String.valueOf(subDemandSequence)); + subDemandSequence++; // 在途 - tabNew.setReceivingStatus("0"); + noticeTabToInsert.setReceivingStatus("0"); // 冻结 - tabNew.setInStatus("1"); - tabNew.setRecNumNow(tabNew.getRecNum()); - tabNew.setUpdateBy(update.getRecordPerson()); - tabNew.setUpdateTime(new Date()); - tabNew.setCreateBy(update.getRecordPerson()); - tabNew.setCreateTime(new Date()); - tabNew.setNoticeId(update.getId()); - tabNew.setStorageId(update.getStorageId()); - tabNew.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); - tabNew.setLevelType(update.getTypes()); - updateNoticeTabs.add(tabNew); - insertTOngoodsshelfs.add(makeTOngoodsshelf(tRkWareNotice, tabNew, update)); + noticeTabToInsert.setInStatus("1"); + noticeTabToInsert.setRecNumNow(noticeTabToInsert.getRecNum()); + noticeTabToInsert.setUpdateBy(manualInboundRequest.getRecordPerson()); + noticeTabToInsert.setUpdateTime(new Date()); + noticeTabToInsert.setCreateBy(manualInboundRequest.getRecordPerson()); + noticeTabToInsert.setCreateTime(new Date()); + noticeTabToInsert.setNoticeId(manualInboundRequest.getId()); + noticeTabToInsert.setStorageId(manualInboundRequest.getStorageId()); + noticeTabToInsert.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); + noticeTabToInsert.setLevelType(manualInboundRequest.getTypes()); + noticeTabsToInsert.add(noticeTabToInsert); + inboundTasksToInsert.add(buildInboundTask(manualInboundNotice, noticeTabToInsert, manualInboundRequest)); } // 生成入库任务 - if (insertTOngoodsshelfs.size() > 0) { - for (TOngoodsshelf tOngoodsshelf : insertTOngoodsshelfs) { - tOngoodsshelf.setStorageId(update.getStorageId()); - tOngoodsshelfMapper.insertTOngoodsshelf(tOngoodsshelf); + if (inboundTasksToInsert.size() > 0) { + for (TOngoodsshelf inboundTaskToInsert : inboundTasksToInsert) { + inboundTaskToInsert.setStorageId(manualInboundRequest.getStorageId()); + tOngoodsshelfMapper.insertTOngoodsshelf(inboundTaskToInsert); } - tCallNotice.setStorageId(update.getStorageId()); - tCallNotice.setStorageShortName(update.getStorageShortName()); - tCallNotice.setCtl(update.getCtlNo()); - if (StringUtils.isEmpty(update.getCtlNo())) { + inboundCallNotice.setStorageId(manualInboundRequest.getStorageId()); + inboundCallNotice.setStorageShortName(manualInboundRequest.getStorageShortName()); + inboundCallNotice.setCtl(manualInboundRequest.getCtlNo()); + if (StringUtils.isEmpty(manualInboundRequest.getCtlNo())) { // pLCID - tCallNotice.setPlcid((Long) update.getParams().get("plcId")); + inboundCallNotice.setPlcid((Long) manualInboundRequest.getParams().get("plcId")); } - tCallNotice.setTaskType("0"); - tCallNotice.setCreateBy(update.getRecordPerson()); - tCallNotice.setCreateTime(new Date()); - tCallNotice.setStatus("0"); - tCallNotice.setFictitious("0"); - tCallNotice.setTaskId(tRkWareNotice.getNoticeId()); - tNoticeService.sendNotice(tCallNotice); + inboundCallNotice.setTaskType("0"); + inboundCallNotice.setCreateBy(manualInboundRequest.getRecordPerson()); + inboundCallNotice.setCreateTime(new Date()); + inboundCallNotice.setStatus("0"); + inboundCallNotice.setFictitious("0"); + inboundCallNotice.setTaskId(manualInboundNotice.getNoticeId()); + tNoticeService.sendNotice(inboundCallNotice); } - if (updateNoticeTabs.size() > 0) { + if (noticeTabsToInsert.size() > 0) { // 入库通知单明细批量插入 - tRkWareNoticeMapper.batchTRkWareNoticeTab(updateNoticeTabs); + tRkWareNoticeMapper.batchTRkWareNoticeTab(noticeTabsToInsert); } resultMap.put("success", "收货成功"); resultMap.put("error", ""); @@ -2513,47 +2514,47 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl sendIwmsUnified(TRkWareNoticeTabUpdate update) { + public Map sendIwmsUnified(TRkWareNoticeTabUpdate iwmsPushRequest) { Map resultMap = new HashMap<>(); - List noticeTabList = update.getTrkWareNoticeTabList(); + List submittedNoticeTabs = iwmsPushRequest.getTrkWareNoticeTabList(); - if (noticeTabList != null) { - for (TRkWareNoticeTab tRkWareNoticeTab : noticeTabList) { + if (submittedNoticeTabs != null) { + for (TRkWareNoticeTab submittedNoticeTab : submittedNoticeTabs) { // 获取推送过来的数量 - BigDecimal recNumNow = tRkWareNoticeTab.getRecNumNow(); - String id = tRkWareNoticeTab.getId(); + BigDecimal currentReceivedQuantity = submittedNoticeTab.getRecNumNow(); + String noticeTabId = submittedNoticeTab.getId(); // 查询数据库中的当前数量 - TRkWareNoticeTab tab = tRkWareNoticeTabMapper.selectTRkWareNoticeTabById(id); - BigDecimal recNum = tab.getReceivingNum(); - if (recNum == null) { - recNum = tab.getArraMount(); + TRkWareNoticeTab noticeTabInDb = tRkWareNoticeTabMapper.selectTRkWareNoticeTabById(noticeTabId); + BigDecimal plannedReceivingQuantity = noticeTabInDb.getReceivingNum(); + if (plannedReceivingQuantity == null) { + plannedReceivingQuantity = noticeTabInDb.getArraMount(); } - TRkWareNoticeTab tRkWareNoticeTab1 = new TRkWareNoticeTab(); + TRkWareNoticeTab noticeTabQuantityUpdate = new TRkWareNoticeTab(); // 检查数量是否不一致 - if (recNumNow.compareTo(recNum) < 0) { // 使用 compareTo 进行 BigDecimal 比较 + if (currentReceivedQuantity.compareTo(plannedReceivingQuantity) < 0) { // 使用 compareTo 进行 BigDecimal 比较 // 计算差值 - BigDecimal difference = recNum.subtract(recNumNow); // 计算剩余数量 + BigDecimal remainingQuantity = plannedReceivingQuantity.subtract(currentReceivedQuantity); // 计算剩余数量 // 创建新的入库单记录剩余数量 - if (difference.compareTo(BigDecimal.ZERO) > 0) { // 如果剩余数量大于 0 - TRkWareNoticeTab newTab = new TRkWareNoticeTab(); - BeanUtils.copyProperties(tab, newTab); - newTab.setRecNum(null); // 设置剩余数量 - newTab.setReceivingNum(difference); - newTab.setArraMount(difference); // 设置剩余数量 + if (remainingQuantity.compareTo(BigDecimal.ZERO) > 0) { // 如果剩余数量大于 0 + TRkWareNoticeTab remainingNoticeTab = new TRkWareNoticeTab(); + BeanUtils.copyProperties(noticeTabInDb, remainingNoticeTab); + remainingNoticeTab.setRecNum(null); // 设置剩余数量 + remainingNoticeTab.setReceivingNum(remainingQuantity); + remainingNoticeTab.setArraMount(remainingQuantity); // 设置剩余数量 // 这里可以设置其他必要的字段,例如物料编号、入库单号等 - newTab.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); - tRkWareNoticeTabMapper.insertTRkWareNoticeTab(newTab); // 插入新的入库单 -// tRkWareNoticeTab1.setReceivingStatus("1"); + remainingNoticeTab.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); + tRkWareNoticeTabMapper.insertTRkWareNoticeTab(remainingNoticeTab); // 插入新的入库单 +// noticeTabQuantityUpdate.setReceivingStatus("1"); } } // 更新当前入库单的数量 - tRkWareNoticeTab1.setId(id); - tRkWareNoticeTab1.setRecNum(recNumNow); - tRkWareNoticeTab1.setInStatus("1"); - tRkWareNoticeTabMapper.updateNum(tRkWareNoticeTab1); + noticeTabQuantityUpdate.setId(noticeTabId); + noticeTabQuantityUpdate.setRecNum(currentReceivedQuantity); + noticeTabQuantityUpdate.setInStatus("1"); + tRkWareNoticeTabMapper.updateNum(noticeTabQuantityUpdate); } } else { resultMap.put("error", "收货明细为空异常"); @@ -2561,48 +2562,48 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl requestData = new HashMap<>(); - requestData.put("reqCode", reqCode); - List tabList = update.getTrkWareNoticeTabList(); - List updatedTabs = new ArrayList<>(); + requestData.put("reqCode", requestCode); + List noticeTabsToPush = iwmsPushRequest.getTrkWareNoticeTabList(); + List pushedNoticeTabs = new ArrayList<>(); List> dataList = new ArrayList<>(); - for (TRkWareNoticeTab tab : tabList) { + for (TRkWareNoticeTab noticeTabToPush : noticeTabsToPush) { Map dataObject = new HashMap<>(); - populateDataObject(dataObject, tab, update); + populateDataObject(dataObject, noticeTabToPush, iwmsPushRequest); dataList.add(dataObject); // Update tab status -// tab.setInStatus("1"); -// tab.setRecNum(tab.getRe); -// updatedTabs.add(tab); +// noticeTabToPush.setInStatus("1"); +// noticeTabToPush.setRecNum(noticeTabToPush.getRe); +// pushedNoticeTabs.add(noticeTabToPush); } requestData.put("data", dataList); // 循环结束后,将列表赋值给requestData的data键 //测试 不用就关闭注释 -// updateNoticeAndOrderStatus(tRkWareNotice, update, updatedTabs); +// updateNoticeAndOrderStatus(inboundNotice, iwmsPushRequest, pushedNoticeTabs); String requestBody = ""; try { requestBody = objectMapper.writeValueAsString(requestData); @@ -2611,7 +2612,7 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl dataObject, TRkWareNoticeTab tab, TRkWareNoticeTabUpdate update) { + private void populateDataObject(Map dataObject, TRkWareNoticeTab noticeTab, TRkWareNoticeTabUpdate iwmsPushRequest) { dataObject.put("operType", "A"); - dataObject.put("orderType", update.getCtlNo() != null && update.getCtlNo().startsWith("A1") ? "4" : "1"); - dataObject.put("orderNum", update.getId()); - dataObject.put("orderItem", tab.getId()); - dataObject.put("orderKeyThird", tab.getSalesOrderNumber()); + dataObject.put("orderType", iwmsPushRequest.getCtlNo() != null && iwmsPushRequest.getCtlNo().startsWith("A1") ? "4" : "1"); + dataObject.put("orderNum", iwmsPushRequest.getId()); + dataObject.put("orderItem", noticeTab.getId()); + dataObject.put("orderKeyThird", noticeTab.getSalesOrderNumber()); dataObject.put("whCode", "RZ01"); dataObject.put("ownerCode", "8000"); - dataObject.put("matCode", tab.getGoodsId()); - dataObject.put("matQty", tab.getRecNumNow()); - dataObject.put("traceCode", update.getCtlNo() == null ? tab.getCtl() : update.getCtlNo()); - dataObject.put("intoOrderStr2", update.getCtlNo() != null && update.getCtlNo().startsWith("A1") ? "KQTRAY" : "KQ2LBOX"); + dataObject.put("matCode", noticeTab.getGoodsId()); + dataObject.put("matQty", noticeTab.getRecNumNow()); + dataObject.put("traceCode", iwmsPushRequest.getCtlNo() == null ? noticeTab.getCtl() : iwmsPushRequest.getCtlNo()); + dataObject.put("intoOrderStr2", iwmsPushRequest.getCtlNo() != null && iwmsPushRequest.getCtlNo().startsWith("A1") ? "KQTRAY" : "KQ2LBOX"); - if (update.getCtlNo() != null && update.getCtlNo().startsWith("A1")) { + if (iwmsPushRequest.getCtlNo() != null && iwmsPushRequest.getCtlNo().startsWith("A1")) { dataObject.put("batchAttr07", "1"); dataObject.put("intoOrderStr2", "KQTRAY"); } else { dataObject.put("intoOrderBox2", "KQ2LBOX"); dataObject.put("boxAttr07", "2"); dataObject.put("boxCode", generateRandomHexCode(8)); - dataObject.put("boxQty", tab.getArraMount()); + dataObject.put("boxQty", noticeTab.getArraMount()); } /* - dataObject.put("createUser", tab.getApplicant()); + dataObject.put("createUser", noticeTab.getApplicant()); */ } - private void updateNoticeAndOrderStatus(TRkWareNotice tRkWareNotice, TRkWareNoticeTabUpdate update, List updatedTabs) { - tRkWareNotice.setReceiver(SecurityUtils.getUserNick()); -// List tabs = updatedTabs; -// for (TRkWareNoticeTab tab : tabs) { -// if(tab.getRecNum() == null) -// tab.setRecNum(BigDecimal.ZERO); -// tab.setRecNum(tab.getRecNum().add(tab.getRecNumNow())); -// tRkWareNoticeTabMapper.updateTRkWareNoticeTab(tab); + private void updateNoticeAndOrderStatus(TRkWareNotice inboundNotice, TRkWareNoticeTabUpdate iwmsPushRequest, List pushedNoticeTabs) { + inboundNotice.setReceiver(SecurityUtils.getUserNick()); +// List noticeTabsToUpdate = pushedNoticeTabs; +// for (TRkWareNoticeTab noticeTab : noticeTabsToUpdate) { +// if(noticeTab.getRecNum() == null) +// noticeTab.setRecNum(BigDecimal.ZERO); +// noticeTab.setRecNum(noticeTab.getRecNum().add(noticeTab.getRecNumNow())); +// tRkWareNoticeTabMapper.updateTRkWareNoticeTab(noticeTab); // } -// tRkWareNoticeMapper.updateForeach(updatedTabs); +// tRkWareNoticeMapper.updateForeach(pushedNoticeTabs); //获取最新的通知单 - TRkWareNotice notice = selectTRkWareNoticeById(update.getId()); - List list = notice.getTRkWareNoticeTabList(); - int count = (int) list.stream().filter(c -> c.getInStatus().equals("0")).count(); + TRkWareNotice latestInboundNotice = selectTRkWareNoticeById(iwmsPushRequest.getId()); + List latestNoticeTabs = latestInboundNotice.getTRkWareNoticeTabList(); + int pendingNoticeTabCount = (int) latestNoticeTabs.stream().filter(noticeTab -> noticeTab.getInStatus().equals("0")).count(); - if (count == 0) { - tRkWareNotice.setReceivingStatus("1"); + if (pendingNoticeTabCount == 0) { + inboundNotice.setReceivingStatus("1"); } - if (update.getTrkWareNoticeTabList() == null) { - tRkWareNotice.setReceivingStatus("3"); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TCallNoticeOrder::getTaskId, update.getNoticeId()); + if (iwmsPushRequest.getTrkWareNoticeTabList() == null) { + inboundNotice.setReceivingStatus("3"); + LambdaQueryWrapper noticeOrderQueryWrapper = new LambdaQueryWrapper<>(); + noticeOrderQueryWrapper.eq(TCallNoticeOrder::getTaskId, iwmsPushRequest.getNoticeId()); } - tRkWareNoticeMapper.updateTRkWareNotice(tRkWareNotice); + tRkWareNoticeMapper.updateTRkWareNotice(inboundNotice); } @@ -2752,91 +2753,91 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl virtualListing(TCkOrders orders) { + public Map virtualListing(TCkOrders stockTransferOrder) { Map resultMap = new HashMap<>(); - TRkWareNotice wareNotice = new TRkWareNotice(); - wareNotice.setId(OrderCodeFactory.getOrderCode("", "")); - wareNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); - wareNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); - wareNotice.setApplicant(SecurityUtils.getUserNick()); - wareNotice.setOrderType("3"); - wareNotice.setCreateBy(SecurityUtils.getUserNick()); - wareNotice.setCreateTime(DateUtils.getNowDate()); - wareNotice.setIsAvgExec("1"); - int i = insertTRkWareNotice(wareNotice); - TMiStock tMiStock = new TMiStock(); - for (TCkOrderdetail ckOrderdetail : orders.getTckOrderdetailList()) { + TRkWareNotice virtualInboundNotice = new TRkWareNotice(); + virtualInboundNotice.setId(OrderCodeFactory.getOrderCode("", "")); + virtualInboundNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); + virtualInboundNotice.setDeptId(SecurityUtils.getLoginUser().getDeptId()); + virtualInboundNotice.setApplicant(SecurityUtils.getUserNick()); + virtualInboundNotice.setOrderType("3"); + virtualInboundNotice.setCreateBy(SecurityUtils.getUserNick()); + virtualInboundNotice.setCreateTime(DateUtils.getNowDate()); + virtualInboundNotice.setIsAvgExec("1"); + int insertedNoticeCount = insertTRkWareNotice(virtualInboundNotice); + TMiStock matchedStock = new TMiStock(); + for (TCkOrderdetail outboundOrderDetail : stockTransferOrder.getTckOrderdetailList()) { - if (!ObjectUtils.isEmpty(ckOrderdetail.getLocationId())) { - LambdaQueryWrapper locWrapper = new LambdaQueryWrapper<>(); - locWrapper.eq(TBaseStorageAreaLocation::getLocationId, ckOrderdetail.getLocationId()); - List areaLocations = service.selectList(locWrapper); - if (!areaLocations.isEmpty()) { - TBaseStorageAreaLocation locationCheck = areaLocations.get(0); - if ("1".equals(locationCheck.getIsLock())) { - resultMap.put("error", "库位【" + ckOrderdetail.getLocationId() + "】已禁用"); - log.error("库位【" + ckOrderdetail.getLocationId() + "】已禁用"); + if (!ObjectUtils.isEmpty(outboundOrderDetail.getLocationId())) { + LambdaQueryWrapper locationQueryWrapper = new LambdaQueryWrapper<>(); + locationQueryWrapper.eq(TBaseStorageAreaLocation::getLocationId, outboundOrderDetail.getLocationId()); + List matchedLocations = service.selectList(locationQueryWrapper); + if (!matchedLocations.isEmpty()) { + TBaseStorageAreaLocation targetLocation = matchedLocations.get(0); + if ("1".equals(targetLocation.getIsLock())) { + resultMap.put("error", "库位【" + outboundOrderDetail.getLocationId() + "】已禁用"); + log.error("库位【" + outboundOrderDetail.getLocationId() + "】已禁用"); return resultMap; } } } - if (!ObjectUtils.isEmpty(ckOrderdetail.getCtl())) { + if (!ObjectUtils.isEmpty(outboundOrderDetail.getCtl())) { //校验托盘容器是否正确 - LambdaQueryWrapper ctlWrapper = new LambdaQueryWrapper<>(); - ctlWrapper.eq(TBasePallet::getPalletId, ckOrderdetail.getCtl()); - List plcs = palletMapper.selectList(ctlWrapper); - if (!plcs.isEmpty()) { - TBasePallet palletChk = plcs.get(0); - if ("1".equals(palletChk.getIsLock())) { - resultMap.put("error", "托盘号【" + ckOrderdetail.getCtl() + "】已禁用"); - log.error("托盘号【" + ckOrderdetail.getCtl() + "】已禁用"); + LambdaQueryWrapper palletQueryWrapper = new LambdaQueryWrapper<>(); + palletQueryWrapper.eq(TBasePallet::getPalletId, outboundOrderDetail.getCtl()); + List palletMatches = palletMapper.selectList(palletQueryWrapper); + if (!palletMatches.isEmpty()) { + TBasePallet targetPallet = palletMatches.get(0); + if ("1".equals(targetPallet.getIsLock())) { + resultMap.put("error", "托盘号【" + outboundOrderDetail.getCtl() + "】已禁用"); + log.error("托盘号【" + outboundOrderDetail.getCtl() + "】已禁用"); return resultMap; } } } - List tabs = new ArrayList<>(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(TMiStock::getCtl, ckOrderdetail.getCtl()); - queryWrapper.eq(TMiStock::getGoodsId, ckOrderdetail.getGoodsId()); - queryWrapper.eq(TMiStock::getGoodsName, ckOrderdetail.getGoodsName()); - queryWrapper.eq(TMiStock::getLocationId, ckOrderdetail.getLocationId()); - queryWrapper.eq(TMiStock::getStorageId, ckOrderdetail.getStorageId()); - queryWrapper.eq(TMiStock::getShelvesNum, ckOrderdetail.getShelvesNum()); - tMiStock = tMiStockMapper.selectOne(queryWrapper); - if (tMiStock != null) { + List noticeTabsToInsert = new ArrayList<>(); + LambdaQueryWrapper stockQueryWrapper = new LambdaQueryWrapper<>(); + stockQueryWrapper.eq(TMiStock::getCtl, outboundOrderDetail.getCtl()); + stockQueryWrapper.eq(TMiStock::getGoodsId, outboundOrderDetail.getGoodsId()); + stockQueryWrapper.eq(TMiStock::getGoodsName, outboundOrderDetail.getGoodsName()); + stockQueryWrapper.eq(TMiStock::getLocationId, outboundOrderDetail.getLocationId()); + stockQueryWrapper.eq(TMiStock::getStorageId, outboundOrderDetail.getStorageId()); + stockQueryWrapper.eq(TMiStock::getShelvesNum, outboundOrderDetail.getShelvesNum()); + matchedStock = tMiStockMapper.selectOne(stockQueryWrapper); + if (matchedStock != null) { TRkWareNoticeTab noticeTab = new TRkWareNoticeTab(); - noticeTab.setStorageId(orders.getStorageId()); - noticeTab.setStorageShortName(orders.getStorageShortName()); - noticeTab.setRecNum(ckOrderdetail.getShelvesNum()); - noticeTab.setArraMount(tMiStock.getShelvesNum()); - noticeTab.setRecNumNow(ckOrderdetail.getShelvesNum()); + noticeTab.setStorageId(stockTransferOrder.getStorageId()); + noticeTab.setStorageShortName(stockTransferOrder.getStorageShortName()); + noticeTab.setRecNum(outboundOrderDetail.getShelvesNum()); + noticeTab.setArraMount(matchedStock.getShelvesNum()); + noticeTab.setRecNumNow(outboundOrderDetail.getShelvesNum()); noticeTab.setId(OrderCodeFactory.getOrderCode("TR", "")); - noticeTab.setNoticeId(wareNotice.getId()); - noticeTab.setGoodsId(ckOrderdetail.getGoodsId()); - noticeTab.setGoodsName(ckOrderdetail.getGoodsName()); - noticeTab.setUnit(ckOrderdetail.getUnit()); - noticeTab.setSpecification(ckOrderdetail.getSpecification()); - noticeTab.setAbc(ckOrderdetail.getAbc()); + noticeTab.setNoticeId(virtualInboundNotice.getId()); + noticeTab.setGoodsId(outboundOrderDetail.getGoodsId()); + noticeTab.setGoodsName(outboundOrderDetail.getGoodsName()); + noticeTab.setUnit(outboundOrderDetail.getUnit()); + noticeTab.setSpecification(outboundOrderDetail.getSpecification()); + noticeTab.setAbc(outboundOrderDetail.getAbc()); noticeTab.setApplicant(SecurityUtils.getUserNick()); noticeTab.setCreateBy(SecurityUtils.getUserNick()); noticeTab.setLevelType("1"); - noticeTab.setCtl(ckOrderdetail.getCtl()); + noticeTab.setCtl(outboundOrderDetail.getCtl()); noticeTab.setCreateTime(new Date()); //已经收货 noticeTab.setInStatus("2"); //来源单号 noticeTab.setSalesOrderNumber(generateUniqueSalesOrderNumber()); - tabs.add(noticeTab); + noticeTabsToInsert.add(noticeTab); //通知明显 - if (i >= 1) { - tRkWareNoticeMapper.batchTRkWareNoticeTab(tabs); + if (insertedNoticeCount >= 1) { + tRkWareNoticeMapper.batchTRkWareNoticeTab(noticeTabsToInsert); } - tMiStockMapper.deleteById(tMiStock.getId()); + tMiStockMapper.deleteById(matchedStock.getId()); //删除 库存等待过账 } else { resultMap.put("error", "暂无库存信息"); @@ -2844,14 +2845,14 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl map = sendIwmsUnified(update); - if (map.get("code").equals("0")) { + /*Map iwmsPushResult = sendIwmsUnified(iwmsPushRequest); + if (iwmsPushResult.get("code").equals("0")) { //删除库存 过账 - if (tMiStock != null) { - tMiStockMapper.deleteById(tMiStock); + if (matchedStock != null) { + tMiStockMapper.deleteById(matchedStock); } resultMap.put("success", "机器人收货成功"); } else { @@ -2864,97 +2865,97 @@ public class TRkWareNoticeServiceImpl extends ServiceImpl workshopReturn(TckOrdersBak orders) { - Map result = new HashMap(); + public Map workshopReturn(TckOrdersBak returnOrder) { + Map resultMap = new HashMap(); - if (ObjectUtils.isEmpty(orders.getTckOrderdetailBakList())) { - result.put("error", "物料列表为空"); - return result; + if (ObjectUtils.isEmpty(returnOrder.getTckOrderdetailBakList())) { + resultMap.put("error", "物料列表为空"); + return resultMap; } // 生成入库通知单 - TRkWareNotice tRkWareNotice = new TRkWareNotice(); - tRkWareNotice.setId(OrderCodeFactory.getOrderCode("", "")); - tRkWareNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); - tRkWareNotice.setUpdateBy(orders.getApplicant()); - tRkWareNotice.setUpdateTime(new Date()); - tRkWareNotice.setCreateBy(orders.getApplicant()); - tRkWareNotice.setCreateTime(new Date()); - tRkWareNotice.setStorageMode("2"); - tRkWareNotice.setReceivingStatus("0"); - tRkWareNotice.setApplicant(SecurityUtils.getUserNick()); - tRkWareNotice.setSendeDate(DateUtils.getDate()); - tRkWareNotice.setDeptId(orders.getDeptId()); + TRkWareNotice returnInboundNotice = new TRkWareNotice(); + returnInboundNotice.setId(OrderCodeFactory.getOrderCode("", "")); + returnInboundNotice.setNoticeId(OrderCodeFactory.getOrderCode("TWO", "")); + returnInboundNotice.setUpdateBy(returnOrder.getApplicant()); + returnInboundNotice.setUpdateTime(new Date()); + returnInboundNotice.setCreateBy(returnOrder.getApplicant()); + returnInboundNotice.setCreateTime(new Date()); + returnInboundNotice.setStorageMode("2"); + returnInboundNotice.setReceivingStatus("0"); + returnInboundNotice.setApplicant(SecurityUtils.getUserNick()); + returnInboundNotice.setSendeDate(DateUtils.getDate()); + returnInboundNotice.setDeptId(returnOrder.getDeptId()); - String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - Date date = new Date(); - String uniqueId = String.valueOf(date.getTime()); - SimpleDateFormat df = new SimpleDateFormat("HHmmss"); - String timeString = df.format(date); - String randomLetter = String.valueOf(letters.charAt(random.nextInt(25))); + String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + Date currentTime = new Date(); + String timestampMillis = String.valueOf(currentTime.getTime()); + SimpleDateFormat timeFormatter = new SimpleDateFormat("HHmmss"); + String formattedTime = timeFormatter.format(currentTime); + String randomSuffixLetter = String.valueOf(alphabet.charAt(random.nextInt(25))); // String deliveryId = String.valueOf(Math.floor(1000 + Math.random() * 9000)); - String deliveryId = uniqueId + timeString + randomLetter; - tRkWareNotice.setDeliveryId(deliveryId); - tRkWareNoticeMapper.insertTRkWareNotice(tRkWareNotice); + String deliveryId = timestampMillis + formattedTime + randomSuffixLetter; + returnInboundNotice.setDeliveryId(deliveryId); + tRkWareNoticeMapper.insertTRkWareNotice(returnInboundNotice); // 入库通知单明细 - List updateNoticeTabs = new ArrayList(); + List noticeTabsToInsert = new ArrayList(); // 遍历提交的物料数据明细 - int ziNeedNo = 0; - for (TckOrderdetailBak tBak : orders.getTckOrderdetailBakList()) { + int subDemandSequence = 0; + for (TckOrderdetailBak returnOrderDetail : returnOrder.getTckOrderdetailBakList()) { - if (tBak.getTrNum().compareTo(tBak.getRecNumNow()) < 0) { - result.put("error", "退库数量不能大于出库数量,物料【" + tBak.getGoodsName() + "】"); - return result; + if (returnOrderDetail.getTrNum().compareTo(returnOrderDetail.getRecNumNow()) < 0) { + resultMap.put("error", "退库数量不能大于出库数量,物料【" + returnOrderDetail.getGoodsName() + "】"); + return resultMap; } - TRkWareNoticeTab tabNew = new TRkWareNoticeTab(); + TRkWareNoticeTab noticeTabToInsert = new TRkWareNoticeTab(); // 物料编码 - tabNew.setGoodsId(tBak.getGoodsId()); - tabNew.setGoodsName(tBak.getGoodsName()); - tabNew.setSpecification(tBak.getSpecification()); - tabNew.setUnit(tBak.getUnit()); - tabNew.setRecoil(tBak.getRecoil()); - tabNew.setArraMount(tBak.getRecNumNow()); - tabNew.setStorageId(tBak.getStorageId()); - tabNew.setStorageShortName(tBak.getStorageShortName()); - tabNew.setStorageLocation(tBak.getLocationId()); - tabNew.setGoodsTypeId(tBak.getGoodsTypeId()); - tabNew.setApplicant(orders.getApplicant()); - tabNew.setBarcode(tBak.getBarcode()); + noticeTabToInsert.setGoodsId(returnOrderDetail.getGoodsId()); + noticeTabToInsert.setGoodsName(returnOrderDetail.getGoodsName()); + noticeTabToInsert.setSpecification(returnOrderDetail.getSpecification()); + noticeTabToInsert.setUnit(returnOrderDetail.getUnit()); + noticeTabToInsert.setRecoil(returnOrderDetail.getRecoil()); + noticeTabToInsert.setArraMount(returnOrderDetail.getRecNumNow()); + noticeTabToInsert.setStorageId(returnOrderDetail.getStorageId()); + noticeTabToInsert.setStorageShortName(returnOrderDetail.getStorageShortName()); + noticeTabToInsert.setStorageLocation(returnOrderDetail.getLocationId()); + noticeTabToInsert.setGoodsTypeId(returnOrderDetail.getGoodsTypeId()); + noticeTabToInsert.setApplicant(returnOrder.getApplicant()); + noticeTabToInsert.setBarcode(returnOrderDetail.getBarcode()); // 子需求编号 - tabNew.setSalesOrderNumber(String.valueOf(ziNeedNo)); - ziNeedNo++; + noticeTabToInsert.setSalesOrderNumber(String.valueOf(subDemandSequence)); + subDemandSequence++; // 在途 - tabNew.setReceivingStatus("0"); + noticeTabToInsert.setReceivingStatus("0"); // 冻结 - tabNew.setInStatus("0"); - tabNew.setRecNumNow(tabNew.getRecNum()); - tabNew.setUpdateBy(orders.getRecordPerson()); - tabNew.setUpdateTime(new Date()); - tabNew.setCreateBy(orders.getRecordPerson()); - tabNew.setCreateTime(new Date()); - tabNew.setNoticeId(tRkWareNotice.getId()); - tabNew.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); - tabNew.setLevelType("1"); - updateNoticeTabs.add(tabNew); + noticeTabToInsert.setInStatus("0"); + noticeTabToInsert.setRecNumNow(noticeTabToInsert.getRecNum()); + noticeTabToInsert.setUpdateBy(returnOrder.getRecordPerson()); + noticeTabToInsert.setUpdateTime(new Date()); + noticeTabToInsert.setCreateBy(returnOrder.getRecordPerson()); + noticeTabToInsert.setCreateTime(new Date()); + noticeTabToInsert.setNoticeId(returnInboundNotice.getId()); + noticeTabToInsert.setId(OrderCodeFactory.getOrderCode("TRKTAB", "")); + noticeTabToInsert.setLevelType("1"); + noticeTabsToInsert.add(noticeTabToInsert); } - if (updateNoticeTabs.size() > 0) { + if (noticeTabsToInsert.size() > 0) { // 入库通知单明细批量插入 - tRkWareNoticeMapper.batchTRkWareNoticeTab(updateNoticeTabs); + tRkWareNoticeMapper.batchTRkWareNoticeTab(noticeTabsToInsert); } - result.put("deliveryId", deliveryId); - result.put("noticeId", tRkWareNotice.getNoticeId()); - result.put("id", tRkWareNotice.getId()); - result.put("success", "车间退货入库"); - result.put("error", ""); + resultMap.put("deliveryId", deliveryId); + resultMap.put("noticeId", returnInboundNotice.getNoticeId()); + resultMap.put("id", returnInboundNotice.getId()); + resultMap.put("success", "车间退货入库"); + resultMap.put("error", ""); - return result; + return resultMap; } }