From 68b53fbbf6a148c1473511f02db60731fc261b6b Mon Sep 17 00:00:00 2001 From: xins Date: Mon, 1 Apr 2024 14:17:31 +0800 Subject: [PATCH] =?UTF-8?q?1.9.3=20WMS=EF=BC=9A=E5=AE=8C=E6=88=90PDA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9B=98=E5=BA=93=E5=8A=9F=E8=83=BD(?= =?UTF-8?q?=E5=8C=85=E6=8B=AC=E8=8E=B7=E5=8F=96=E7=9B=98=E7=82=B9=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=97=E8=A1=A8=E3=80=81=E8=8E=B7=E5=8F=96=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=88=97=E8=A1=A8=E3=80=81=E7=94=B3=E8=AF=B7=E7=9B=98?= =?UTF-8?q?=E5=BA=93=E3=80=81=E7=9B=98=E5=BA=93=E7=A1=AE=E8=AE=A4=E5=92=8C?= =?UTF-8?q?=E7=9B=98=E5=BA=93=E5=AE=8C=E6=88=90)=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/common/core/constant/WmsConstants.java | 10 + .../com/hw/common/core/utils/uuid/Seq.java | 12 + .../WmsInventoryCheckController.java | 16 +- .../wms/controller/WmsMobileController.java | 101 +++-- .../com/hw/wms/domain/WmsInventoryCheck.java | 125 +++++-- .../wms/domain/WmsInventoryCheckDetail.java | 182 +++++++-- .../domain/vo/WmsInventoryCheckDetailVo.java | 27 ++ .../hw/wms/domain/vo/WmsInventoryCheckVo.java | 28 ++ .../com/hw/wms/domain/vo/WmsMoveApplyVo.java | 6 +- .../hw/wms/mapper/WmsBaseLocationMapper.java | 6 + .../mapper/WmsInventoryCheckDetailMapper.java | 79 ++++ .../wms/mapper/WmsInventoryCheckMapper.java | 48 ++- .../service/IWmsInventoryCheckService.java | 65 +++- .../impl/WmsInventoryCheckServiceImpl.java | 354 ++++++++++++++++-- .../wms/service/impl/WmsMoveServiceImpl.java | 6 +- .../mapper/wms/WmsBaseLocationMapper.xml | 33 ++ .../wms/WmsInventoryCheckDetailMapper.xml | 167 +++++++++ .../mapper/wms/WmsInventoryCheckMapper.xml | 99 +++-- 18 files changed, 1175 insertions(+), 189 deletions(-) create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckDetailVo.java create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckVo.java create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckDetailMapper.java create mode 100644 hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckDetailMapper.xml diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java index 999d5df..0c90ab0 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java @@ -224,4 +224,14 @@ public class WmsConstants { public static final String WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH = "3";//出库完成 + + /*盘点记录状态*/ + public static final String WMS_INVENTORY_CHECK_STATUS_INVENTORYING = "1";//盘点中 + public static final String WMS_INVENTORY_CHECK_STATUS_FINISH = "2";//盘点完成 + + + /*盘点记录明细状态*/ +// public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_TO_INVENTORY = "0";//待盘点 + public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING = "1";//盘点中 + public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_FINISH = "2";//盘点完成 } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java index 0a6d2bc..d0c22e3 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java @@ -223,6 +223,16 @@ public class Seq { // 原材料入库记录标识 public static final String rawInstockSeqCode = "RI"; + + // 仓储盘点记录序列类型 + public static final String wmsInventoryCheckSeqType = "inventorycheck"; + + // 仓储盘点记录接口序列数 + private static AtomicInteger wmsInventoryCheckSeq = new AtomicInteger(1); + + // 仓储盘点记录标识 + public static final String wmsInventoryCheckSeqCode = "IC"; + /** * 获取通用序列号 * @@ -325,6 +335,8 @@ public class Seq { atomicInt = wmsMergeSeq; }else if(rawInstockSeqType.equals(type)) { atomicInt = rawInstockSeq; + }else if(wmsInventoryCheckSeqType.equals(type)) { + atomicInt = wmsInventoryCheckSeq; } return getId(atomicInt, 3, code); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsInventoryCheckController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsInventoryCheckController.java index b80a12c..4a0665c 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsInventoryCheckController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsInventoryCheckController.java @@ -24,7 +24,7 @@ import com.hw.common.core.web.page.TableDataInfo; /** * 盘点记录Controller - * + * * @author xs * @date 2023-12-20 */ @@ -73,13 +73,13 @@ public class WmsInventoryCheckController extends BaseController /** * 新增盘点记录 */ - @RequiresPermissions("wms:wmscheck:add") - @Log(title = "盘点记录", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody WmsInventoryCheck wmsInventoryCheck) - { - return toAjax(wmsInventoryCheckService.insertWmsInventoryCheck(wmsInventoryCheck)); - } +// @RequiresPermissions("wms:wmscheck:add") +// @Log(title = "盘点记录", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody WmsInventoryCheck wmsInventoryCheck) +// { +// return toAjax(wmsInventoryCheckService.insertWmsInventoryCheck(wmsInventoryCheck)); +// } /** * 修改盘点记录 diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java index 20a1224..167d5a6 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.Map; /** * 移动端手持Controller @@ -64,7 +65,7 @@ public class WmsMobileController extends BaseController { private IWmsProductStockService wmsProductStockService; @Autowired - private IWmsProductStockSaleorderService wmsProductStockSaleorderService; + private IWmsInventoryCheckService wmsInventoryCheckService; @Resource private RemoteMesService remoteMesService; @@ -418,27 +419,7 @@ public class WmsMobileController extends BaseController { - /** - * 获取仓库信息列表 - */ -// @RequiresPermissions("wms:rawoutstock:query") - @GetMapping(value = "/getWarehouses") - public AjaxResult getWarehouses() { - WmsBaseWarehouse queryWarehouse = new WmsBaseWarehouse(); - queryWarehouse.setWarehouseType(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL); - List warehouses = wmsBaseWarehouseService.selectWmsBaseWarehouseList(queryWarehouse); - return success(warehouses); - } - /** - * 获取库位信息列表 - */ -// @RequiresPermissions("wms:rawoutstock:query") - @GetMapping(value = "/getLocations") - public AjaxResult getLocations(WmsBaseLocation baseLocation) { - List baseLocations = wmsBaseLocationService.selectWmsBaseLocationList(baseLocation); - return success(baseLocations); - } /** * 人工申请移库 @@ -495,4 +476,82 @@ public class WmsMobileController extends BaseController { } + + /** + * 获取盘点任务列表 + */ +// @RequiresPermissions("wms:rawoutstock:query") + @GetMapping(value = "/getInventoryChecks") + public TableDataInfo getInventoryChecks(WmsInventoryCheck queryInventoryCheck) { + startPage(); + List inventoryChecks = wmsInventoryCheckService.selectWmsInventoryCheckJoinList(queryInventoryCheck); + return getDataTable(inventoryChecks); + } + + /** + * 获取仓库信息列表,提供给盘库使用 + */ +// @RequiresPermissions("wms:rawoutstock:query") + @GetMapping(value = "/getWarehouses") + public AjaxResult getWarehouses() { + WmsBaseWarehouse queryWarehouse = new WmsBaseWarehouse(); + queryWarehouse.setWarehouseType(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL); + List warehouses = wmsBaseWarehouseService.selectWmsBaseWarehouseList(queryWarehouse); + return success(warehouses); + } + + /** + * 获取库位信息列表,提供给盘库使用 + */ +// @RequiresPermissions("wms:rawoutstock:query") + @GetMapping(value = "/getLocations") + public TableDataInfo getLocations(WmsBaseLocation baseLocation) { + startPage(); + //todo 需要根据正在盘点的生成库位的盘点记录明细过滤 + List baseLocations = wmsBaseLocationService.selectWmsBaseLocationList(baseLocation); + return getDataTable(baseLocations); + } + + + /** + * 开始盘点(生成盘点数据) + */ + @Log(title = "物料盘点", businessType = BusinessType.INSERT) + @PostMapping(("/inventoryCheck")) + public AjaxResult inventoryCheck(@Validated @RequestBody WmsInventoryCheckVo wmsInventoryCheckVo) { + return success(wmsInventoryCheckService.insertWmsInventoryCheck(wmsInventoryCheckVo)); + } + + + /** + * 获取待盘点和盘点中的盘点记录明细列表 + */ +// @RequiresPermissions("wms:rawoutstock:query") + @GetMapping(value = "/getInventoryCheckDetails") + public AjaxResult getInventoryCheckDetails(WmsInventoryCheckDetail wmsInventoryCheckDetail) { + List checkDetails = wmsInventoryCheckService.getIncompletedInventoryCheckDetails(wmsInventoryCheckDetail); + return success(checkDetails); + } + + +//TODO 盘点中的不能进行移库合库? + /** + * 确认盘点 + */ + @Log(title = "物料盘点", businessType = BusinessType.CONFIRM) + @PostMapping(("/confirmInventoryCheckDetail")) + public AjaxResult confirmInventoryCheckDetail(@RequestBody WmsInventoryCheckDetailVo wmsInventoryCheckDetailVo) { + return success(wmsInventoryCheckService.confirmInventoryCheckDetail(wmsInventoryCheckDetailVo)); + } + + + + /** + * 盘点完成 + */ + @Log(title = "物料盘点", businessType = BusinessType.INSERT) + @PostMapping(("/completeInventoryCheck")) + public AjaxResult completeInventoryCheck(@RequestBody WmsInventoryCheck wmsInventoryCheck) { + return success(wmsInventoryCheckService.completeInventoryCheck(wmsInventoryCheck)); + } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java index a09d954..3db88b6 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java @@ -10,9 +10,9 @@ import com.hw.common.core.web.domain.BaseEntity; /** * 盘点记录对象 wms_inventory_check - * - * @author xs - * @date 2023-12-20 + * + * @author xins + * @date 2024-03-29 */ public class WmsInventoryCheck extends BaseEntity { @@ -29,10 +29,32 @@ public class WmsInventoryCheck extends BaseEntity @Excel(name = "仓库ID") private Long warehouseId; - /** 盘点状态(0待盘点,1盘点中,2盘点完成,3全部盘点完成);在仓库下所有库位都盘点完成时是全部盘点完成,而某一次盘点的库位范围盘点完成则是盘点完成 */ - @Excel(name = "盘点状态(0待盘点,1盘点中,2盘点完成,3全部盘点完成);在仓库下所有库位都盘点完成时是全部盘点完成,而某一次盘点的库位范围盘点完成则是盘点完成") + /** 盘点状态(0待盘点(暂无此状态),1盘点中,2盘点完成);在仓库下所有库位都盘点完成时是盘点完成,否则为盘点中 */ + @Excel(name = "盘点状态(0待盘点", readConverterExp = "暂=无此状态") private String checkStatus; + /** 盘点开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "盘点开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date beginTime; + + /** 盘点结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "盘点结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 库位总数量 */ + @Excel(name = "库位总数量") + private Long locationAmount; + + /** 正在盘点库位数量 */ + @Excel(name = "正在盘点库位数量") + private Long inventoryingAmount; + + /** 已盘点库位数量 */ + @Excel(name = "已盘点库位数量") + private Long inventoriedAmount; + /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -43,60 +65,103 @@ public class WmsInventoryCheck extends BaseEntity @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") private Date updateDate; - /** 盘点记录明细信息 */ + /** 盘点记录明细;盘点记录对应的明细信息信息 */ private List wmsInventoryCheckDetailList; - public void setInventoryCheckId(Long inventoryCheckId) + public void setInventoryCheckId(Long inventoryCheckId) { this.inventoryCheckId = inventoryCheckId; } - public Long getInventoryCheckId() + public Long getInventoryCheckId() { return inventoryCheckId; } - public void setInventoryCheckCode(String inventoryCheckCode) + public void setInventoryCheckCode(String inventoryCheckCode) { this.inventoryCheckCode = inventoryCheckCode; } - public String getInventoryCheckCode() + public String getInventoryCheckCode() { return inventoryCheckCode; } - public void setWarehouseId(Long warehouseId) + public void setWarehouseId(Long warehouseId) { this.warehouseId = warehouseId; } - public Long getWarehouseId() + public Long getWarehouseId() { return warehouseId; } - public void setCheckStatus(String checkStatus) + public void setCheckStatus(String checkStatus) { this.checkStatus = checkStatus; } - public String getCheckStatus() + public String getCheckStatus() { return checkStatus; } - public void setCreateDate(Date createDate) + public void setBeginTime(Date beginTime) + { + this.beginTime = beginTime; + } + + public Date getBeginTime() + { + return beginTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + public Long getLocationAmount() { + return locationAmount; + } + + public void setLocationAmount(Long locationAmount) { + this.locationAmount = locationAmount; + } + + public Long getInventoryingAmount() { + return inventoryingAmount; + } + + public void setInventoryingAmount(Long inventoryingAmount) { + this.inventoryingAmount = inventoryingAmount; + } + + public Long getInventoriedAmount() { + return inventoriedAmount; + } + + public void setInventoriedAmount(Long inventoriedAmount) { + this.inventoriedAmount = inventoriedAmount; + } + + public void setCreateDate(Date createDate) { this.createDate = createDate; } - public Date getCreateDate() + public Date getCreateDate() { return createDate; } - public void setUpdateDate(Date updateDate) + public void setUpdateDate(Date updateDate) { this.updateDate = updateDate; } - public Date getUpdateDate() + public Date getUpdateDate() { return updateDate; } @@ -114,16 +179,18 @@ public class WmsInventoryCheck extends BaseEntity @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("inventoryCheckId", getInventoryCheckId()) - .append("inventoryCheckCode", getInventoryCheckCode()) - .append("warehouseId", getWarehouseId()) - .append("checkStatus", getCheckStatus()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createDate", getCreateDate()) - .append("updateBy", getUpdateBy()) - .append("updateDate", getUpdateDate()) - .append("wmsInventoryCheckDetailList", getWmsInventoryCheckDetailList()) - .toString(); + .append("inventoryCheckId", getInventoryCheckId()) + .append("inventoryCheckCode", getInventoryCheckCode()) + .append("warehouseId", getWarehouseId()) + .append("checkStatus", getCheckStatus()) + .append("beginTime", getBeginTime()) + .append("endTime", getEndTime()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createDate", getCreateDate()) + .append("updateBy", getUpdateBy()) + .append("updateDate", getUpdateDate()) + .append("wmsInventoryCheckDetailList", getWmsInventoryCheckDetailList()) + .toString(); } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheckDetail.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheckDetail.java index bf96808..d5d60ba 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheckDetail.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheckDetail.java @@ -9,10 +9,10 @@ import com.hw.common.core.annotation.Excel; import com.hw.common.core.web.domain.BaseEntity; /** - * 盘点记录明细对象 wms_inventory_check_detail - * - * @author xs - * @date 2023-12-20 + * 盘点记录明细;盘点记录对应的明细信息对象 wms_inventory_check_detail + * + * @author xins + * @date 2024-03-29 */ public class WmsInventoryCheckDetail extends BaseEntity { @@ -33,6 +33,18 @@ public class WmsInventoryCheckDetail extends BaseEntity @Excel(name = "库位编码") private String locationCode; + /** 物料批次号 */ + @Excel(name = "物料批次号") + private String materialBatch; + + /** 库存类型(1原材料,2半成品,3成品) */ + @Excel(name = "库存类型(1原材料,2半成品,3成品)") + private String stockType; + + /** 库存ID(根据库存类型1是wmsRawStockId,2和3是wmsProductStockId) */ + @Excel(name = "库存ID", readConverterExp = "根=据库存类型1是wmsRawStockId,2和3是wmsProductStockId") + private Long stockId; + /** 库存数量 */ @Excel(name = "库存数量") private BigDecimal stockAmount; @@ -41,14 +53,22 @@ public class WmsInventoryCheckDetail extends BaseEntity @Excel(name = "实际数量") private BigDecimal realAmount; - /** 盘点状态(0待盘点,1盘点中,2盘点完成);在生成盘点任务记录明细时,选择需要盘点的状态是盘点中,没有选择的则是待盘点,而下次盘点同一个仓库需要判断是否有未最终完成的盘点记录 */ - @Excel(name = "盘点状态(0待盘点,1盘点中,2盘点完成);在生成盘点任务记录明细时,选择需要盘点的状态是盘点中,没有选择的则是待盘点,而下次盘点同一个仓库需要判断是否有未最终完成的盘点记录") + /** 盘点状态(0待盘点,1盘点中,2盘点完成);在生成盘点任务记录明细时,选择需要盘点的状态是待盘点,没有选择的则不生成记录,在确认盘点后改为盘点中,在此次任务盘点完成后置为盘点完成,如果全部库位库存盘点完成,则需要修改盘点记录的状态为盘点完成 */ + @Excel(name = "盘点状态(0待盘点,1盘点中,2盘点完成);在生成盘点任务记录明细时,选择需要盘点的状态是待盘点,没有选择的则不生成记录,在确认盘点后改为盘点中,在此次任务盘点完成后置为盘点完成,如果全部库位库存盘点完成,则需要修改盘点记录的状态为盘点完成") private String checkStatus; + /** 盘点次数;重复盘点的话记录盘点的次数 */ + @Excel(name = "盘点次数;重复盘点的话记录盘点的次数") + private Long inventoryTime; + /** 同步ERP状态,盘点实际数量与库存数量不同时需要同步(0:失败,1成功) */ @Excel(name = "同步ERP状态,盘点实际数量与库存数量不同时需要同步(0:失败,1成功)") private String erpStatus; + /** 同步给ERP的数量 */ + @Excel(name = "同步给ERP的数量") + private BigDecimal erpAmount; + /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -59,113 +79,195 @@ public class WmsInventoryCheckDetail extends BaseEntity @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") private Date updateDate; - public void setInventoryCheckDetailId(Long inventoryCheckDetailId) + private String materialCode; + + private String materialName; + + /** 盘点状态(0待盘点,1盘点中,2盘点完成); 多个以,隔开 */ + private String checkStatusStr; + + public void setInventoryCheckDetailId(Long inventoryCheckDetailId) { this.inventoryCheckDetailId = inventoryCheckDetailId; } - public Long getInventoryCheckDetailId() + public Long getInventoryCheckDetailId() { return inventoryCheckDetailId; } - public void setInventoryCheckId(Long inventoryCheckId) + public void setInventoryCheckId(Long inventoryCheckId) { this.inventoryCheckId = inventoryCheckId; } - public Long getInventoryCheckId() + public Long getInventoryCheckId() { return inventoryCheckId; } - public void setMaterialId(Long materialId) + public void setMaterialId(Long materialId) { this.materialId = materialId; } - public Long getMaterialId() + public Long getMaterialId() { return materialId; } - public void setLocationCode(String locationCode) + public void setLocationCode(String locationCode) { this.locationCode = locationCode; } - public String getLocationCode() + public String getLocationCode() { return locationCode; } - public void setStockAmount(BigDecimal stockAmount) + public void setMaterialBatch(String materialBatch) + { + this.materialBatch = materialBatch; + } + + public String getMaterialBatch() + { + return materialBatch; + } + public void setStockType(String stockType) + { + this.stockType = stockType; + } + + public String getStockType() + { + return stockType; + } + + public void setStockId(Long stockId) + { + this.stockId = stockId; + } + + public Long getStockId() + { + return stockId; + } + public void setStockAmount(BigDecimal stockAmount) { this.stockAmount = stockAmount; } - public BigDecimal getStockAmount() + public BigDecimal getStockAmount() { return stockAmount; } - public void setRealAmount(BigDecimal realAmount) + public void setRealAmount(BigDecimal realAmount) { this.realAmount = realAmount; } - public BigDecimal getRealAmount() + public BigDecimal getRealAmount() { return realAmount; } - public void setCheckStatus(String checkStatus) + public void setCheckStatus(String checkStatus) { this.checkStatus = checkStatus; } - public String getCheckStatus() + public String getCheckStatus() { return checkStatus; } - public void setErpStatus(String erpStatus) + public void setInventoryTime(Long inventoryTime) + { + this.inventoryTime = inventoryTime; + } + + public Long getInventoryTime() + { + return inventoryTime; + } + public void setErpStatus(String erpStatus) { this.erpStatus = erpStatus; } - public String getErpStatus() + public String getErpStatus() { return erpStatus; } - public void setCreateDate(Date createDate) + public void setErpAmount(BigDecimal erpAmount) + { + this.erpAmount = erpAmount; + } + + public BigDecimal getErpAmount() + { + return erpAmount; + } + public void setCreateDate(Date createDate) { this.createDate = createDate; } - public Date getCreateDate() + public Date getCreateDate() { return createDate; } - public void setUpdateDate(Date updateDate) + public void setUpdateDate(Date updateDate) { this.updateDate = updateDate; } - public Date getUpdateDate() + public Date getUpdateDate() { return updateDate; } + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getCheckStatusStr() { + return checkStatusStr; + } + + public void setCheckStatusStr(String checkStatusStr) { + this.checkStatusStr = checkStatusStr; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("inventoryCheckDetailId", getInventoryCheckDetailId()) - .append("inventoryCheckId", getInventoryCheckId()) - .append("materialId", getMaterialId()) - .append("locationCode", getLocationCode()) - .append("stockAmount", getStockAmount()) - .append("realAmount", getRealAmount()) - .append("checkStatus", getCheckStatus()) - .append("erpStatus", getErpStatus()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createDate", getCreateDate()) - .append("updateBy", getUpdateBy()) - .append("updateDate", getUpdateDate()) - .toString(); + .append("inventoryCheckDetailId", getInventoryCheckDetailId()) + .append("inventoryCheckId", getInventoryCheckId()) + .append("materialId", getMaterialId()) + .append("locationCode", getLocationCode()) + .append("materialBatch", getMaterialBatch()) + .append("stockType", getStockType()) + .append("stockId", getStockId()) + .append("stockAmount", getStockAmount()) + .append("realAmount", getRealAmount()) + .append("checkStatus", getCheckStatus()) + .append("inventoryTime", getInventoryTime()) + .append("erpStatus", getErpStatus()) + .append("erpAmount", getErpAmount()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createDate", getCreateDate()) + .append("updateBy", getUpdateBy()) + .append("updateDate", getUpdateDate()) + .toString(); } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckDetailVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckDetailVo.java new file mode 100644 index 0000000..150a846 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckDetailVo.java @@ -0,0 +1,27 @@ +package com.hw.wms.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.List; + +/** + * @Description: 盘点记录明细确认VO对象 + * @ClassName: WmsInventoryCheckDetailVo + * @Author : xins + * @Date :2024-04-01 9:51 + * @Version :1.0 + */ +@Data +public class WmsInventoryCheckDetailVo { + + //盘点记录明细ID + @NotNull(message="inventoryCheckDetailId") + private Long inventoryCheckDetailId; + + //实际盘点数量 + @NotNull(message = "实际盘点数量必须输入") + private BigDecimal realAmount; +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckVo.java new file mode 100644 index 0000000..96984e8 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsInventoryCheckVo.java @@ -0,0 +1,28 @@ +package com.hw.wms.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @Description: 进行盘点VO对象 + * @ClassName: WmsInventoryCheckVo + * @Author : xins + * @Date :2024-03-29 11:27 + * @Version :1.0 + */ +@Data +public class WmsInventoryCheckVo { + + //仓库ID + @NotNull(message="warehouseId必须输入") + private Long warehouseId; + + @NotEmpty(message="库位编码必须输入") + private List locationCodes; + + private Long inventoryCheckId; +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsMoveApplyVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsMoveApplyVo.java index 2ade65f..4484b59 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsMoveApplyVo.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsMoveApplyVo.java @@ -16,9 +16,9 @@ import java.math.BigDecimal; @Data public class WmsMoveApplyVo { - //仓库ID - @NotNull(message="warehouseId必须输入") - private Long warehouseId; +// //仓库ID +// @NotNull(message="warehouseId必须输入") +// private Long warehouseId; @NotBlank(message="原库位编码必须输入") private String oriLocationCode; diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsBaseLocationMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsBaseLocationMapper.java index dc5a9ac..cdf2ef8 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsBaseLocationMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsBaseLocationMapper.java @@ -85,5 +85,11 @@ public interface WmsBaseLocationMapper public List selectWmsBaseLocationJoinList(WmsBaseLocation wmsBaseLocation); + /** + * 获取库位数量 + * @param wmsBaseLocation + * @return + */ + public int selectCountOfWmsBaseLocation(WmsBaseLocation wmsBaseLocation); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckDetailMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckDetailMapper.java new file mode 100644 index 0000000..be7134c --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckDetailMapper.java @@ -0,0 +1,79 @@ +package com.hw.wms.mapper; + +import java.util.List; +import com.hw.wms.domain.WmsInventoryCheckDetail; +import org.apache.ibatis.annotations.Param; + +/** + * 盘点记录明细Mapper接口 + * + * @author xins + * @date 2024-03-29 + */ +public interface WmsInventoryCheckDetailMapper +{ + /** + * 查询盘点记录明细 + * + * @param inventoryCheckDetailId 盘点记录明细主键 + * @return 盘点记录明细 + */ + public WmsInventoryCheckDetail selectWmsInventoryCheckDetailByInventoryCheckDetailId(Long inventoryCheckDetailId); + + /** + * 查询盘点记录明细列表 + * + * @param wmsInventoryCheckDetail 盘点记录明细 + * @return 盘点记录明细集合 + */ + public List selectWmsInventoryCheckDetailList(WmsInventoryCheckDetail wmsInventoryCheckDetail); + + /** + * 新增盘点记录明细 + * + * @param wmsInventoryCheckDetail 盘点记录明细 + * @return 结果 + */ + public int insertWmsInventoryCheckDetail(WmsInventoryCheckDetail wmsInventoryCheckDetail); + + /** + * 修改盘点记录明细 + * + * @param wmsInventoryCheckDetail 盘点记录明细 + * @return 结果 + */ + public int updateWmsInventoryCheckDetail(WmsInventoryCheckDetail wmsInventoryCheckDetail); + + /** + * 删除盘点记录明细 + * + * @param inventoryCheckDetailId 盘点记录明细主键 + * @return 结果 + */ + public int deleteWmsInventoryCheckDetailByInventoryCheckDetailId(Long inventoryCheckDetailId); + + /** + * 批量删除盘点记录明细 + * + * @param inventoryCheckDetailIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWmsInventoryCheckDetailByInventoryCheckDetailIds(Long[] inventoryCheckDetailIds); + + /** + * 根据盘点记录ID和库位编码获取盘点记录明细 + * @param inventoryCheckId + * @param locationCode + * @return + */ + public int selectCountOfCheckDetailByCheckIdAndLocation(@Param("inventoryCheckId") Long inventoryCheckId, + @Param("locationCode") String locationCode); + + /** + * 查询盘点记录明细列表,Join material + * + * @param wmsInventoryCheckDetail 盘点记录明细 + * @return 盘点记录明细集合 + */ + public List selectWmsInventoryCheckDetailJoinList(WmsInventoryCheckDetail wmsInventoryCheckDetail); +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckMapper.java index 981f713..1f498b8 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsInventoryCheckMapper.java @@ -6,15 +6,15 @@ import com.hw.wms.domain.WmsInventoryCheckDetail; /** * 盘点记录Mapper接口 - * + * * @author xs * @date 2023-12-20 */ -public interface WmsInventoryCheckMapper +public interface WmsInventoryCheckMapper { /** - * 查询盘点记录 - * + * 查询盘点记录,Join inventoryCheckDetail + * * @param inventoryCheckId 盘点记录主键 * @return 盘点记录 */ @@ -22,7 +22,7 @@ public interface WmsInventoryCheckMapper /** * 查询盘点记录列表 - * + * * @param wmsInventoryCheck 盘点记录 * @return 盘点记录集合 */ @@ -30,7 +30,7 @@ public interface WmsInventoryCheckMapper /** * 新增盘点记录 - * + * * @param wmsInventoryCheck 盘点记录 * @return 结果 */ @@ -38,7 +38,7 @@ public interface WmsInventoryCheckMapper /** * 修改盘点记录 - * + * * @param wmsInventoryCheck 盘点记录 * @return 结果 */ @@ -46,7 +46,7 @@ public interface WmsInventoryCheckMapper /** * 删除盘点记录 - * + * * @param inventoryCheckId 盘点记录主键 * @return 结果 */ @@ -54,7 +54,7 @@ public interface WmsInventoryCheckMapper /** * 批量删除盘点记录 - * + * * @param inventoryCheckIds 需要删除的数据主键集合 * @return 结果 */ @@ -62,26 +62,46 @@ public interface WmsInventoryCheckMapper /** * 批量删除盘点记录明细 - * + * * @param inventoryCheckIds 需要删除的数据主键集合 * @return 结果 */ public int deleteWmsInventoryCheckDetailByInventoryCheckIds(Long[] inventoryCheckIds); - + /** * 批量新增盘点记录明细 - * + * * @param wmsInventoryCheckDetailList 盘点记录明细列表 * @return 结果 */ public int batchWmsInventoryCheckDetail(List wmsInventoryCheckDetailList); - + /** * 通过盘点记录主键删除盘点记录明细信息 - * + * * @param inventoryCheckId 盘点记录ID * @return 结果 */ public int deleteWmsInventoryCheckDetailByInventoryCheckId(Long inventoryCheckId); + + + /** + * 查询盘点记录列表,Join warehouse + * + * @param wmsInventoryCheck 盘点记录 + * @return 盘点记录集合 + */ + public List selectWmsInventoryCheckJoinList(WmsInventoryCheck wmsInventoryCheck); + + + + + /** + * 查询盘点记录 + * + * @param inventoryCheckId 盘点记录主键 + * @return 盘点记录 + */ + public WmsInventoryCheck selectOnlyInventoryCheckByInventoryCheckId(Long inventoryCheckId); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsInventoryCheckService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsInventoryCheckService.java index 73be06c..58f10f2 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsInventoryCheckService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsInventoryCheckService.java @@ -1,19 +1,25 @@ package com.hw.wms.service; import java.util.List; +import java.util.Map; + import com.hw.wms.domain.WmsInventoryCheck; +import com.hw.wms.domain.WmsInventoryCheckDetail; +import com.hw.wms.domain.vo.WmsInventoryCheckDetailVo; +import com.hw.wms.domain.vo.WmsInventoryCheckVo; +import org.springframework.transaction.annotation.Transactional; /** * 盘点记录Service接口 - * + * * @author xs * @date 2023-12-20 */ -public interface IWmsInventoryCheckService +public interface IWmsInventoryCheckService { /** * 查询盘点记录 - * + * * @param inventoryCheckId 盘点记录主键 * @return 盘点记录 */ @@ -21,7 +27,7 @@ public interface IWmsInventoryCheckService /** * 查询盘点记录列表 - * + * * @param wmsInventoryCheck 盘点记录 * @return 盘点记录集合 */ @@ -29,15 +35,15 @@ public interface IWmsInventoryCheckService /** * 新增盘点记录 - * - * @param wmsInventoryCheck 盘点记录 + * + * @param wmsInventoryCheckVo 进行盘点VO对象 * @return 结果 */ - public int insertWmsInventoryCheck(WmsInventoryCheck wmsInventoryCheck); + public Long insertWmsInventoryCheck(WmsInventoryCheckVo wmsInventoryCheckVo); /** * 修改盘点记录 - * + * * @param wmsInventoryCheck 盘点记录 * @return 结果 */ @@ -45,7 +51,7 @@ public interface IWmsInventoryCheckService /** * 批量删除盘点记录 - * + * * @param inventoryCheckIds 需要删除的盘点记录主键集合 * @return 结果 */ @@ -53,9 +59,48 @@ public interface IWmsInventoryCheckService /** * 删除盘点记录信息 - * + * * @param inventoryCheckId 盘点记录主键 * @return 结果 */ public int deleteWmsInventoryCheckByInventoryCheckId(Long inventoryCheckId); + + + /** + * 查询盘点记录列表,join warehouse + * + * @param wmsInventoryCheck 盘点记录 + * @return 盘点记录 + */ + public List selectWmsInventoryCheckJoinList(WmsInventoryCheck wmsInventoryCheck); + +// /** +// * 根据判断状态获取数据,按状态返回list数据 +// * @param wmsInventoryCheckDetail +// * @return +// */ +// public Map> getIncompletedInventoryCheckDetails(WmsInventoryCheckDetail wmsInventoryCheckDetail); + + /** + * 根据判断状态获取数据,按状态返回list数据 + * + * @param wmsInventoryCheckDetail + * @return + */ + public List getIncompletedInventoryCheckDetails(WmsInventoryCheckDetail wmsInventoryCheckDetail); + + /** + * 确认盘点 + * @param wmsInventoryCheckDetailVo + * @return + */ + public int confirmInventoryCheckDetail(WmsInventoryCheckDetailVo wmsInventoryCheckDetailVo); + + /** + * 盘点完成 + * @param wmsInventoryCheck + * @return + */ + @Transactional(rollbackFor = Exception.class) + public int completeInventoryCheck(WmsInventoryCheck wmsInventoryCheck); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java index 39eb849..b4e65f4 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java @@ -1,131 +1,403 @@ package com.hw.wms.service.impl; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; + +import com.hw.common.core.constant.WmsConstants; +import com.hw.common.core.exception.ServiceException; +import com.hw.common.core.utils.uuid.Seq; +import com.hw.common.security.utils.SecurityUtils; +import com.hw.wms.domain.WmsInventoryCheckDetail; +import com.hw.wms.domain.*; +import com.hw.wms.domain.vo.WmsInventoryCheckDetailVo; +import com.hw.wms.domain.vo.WmsInventoryCheckVo; +import com.hw.wms.mapper.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.ArrayList; +import java.util.Map; +import java.util.stream.Collectors; + import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.hw.wms.domain.WmsInventoryCheckDetail; -import com.hw.wms.mapper.WmsInventoryCheckMapper; -import com.hw.wms.domain.WmsInventoryCheck; import com.hw.wms.service.IWmsInventoryCheckService; /** * 盘点记录Service业务层处理 - * + * * @author xs * @date 2023-12-20 */ @Service -public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService -{ +public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { @Autowired private WmsInventoryCheckMapper wmsInventoryCheckMapper; + @Autowired + private WmsInventoryCheckDetailMapper wmsInventoryCheckDetailMapper; + + @Autowired + private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; + + @Autowired + private WmsBaseLocationMapper wmsBaseLocationMapper; + + @Autowired + private WmsRawStockMapper wmsRawStockMapper; + + @Autowired + private WmsProductStockMapper wmsProductStockMapper; + /** * 查询盘点记录 - * + * * @param inventoryCheckId 盘点记录主键 * @return 盘点记录 */ @Override - public WmsInventoryCheck selectWmsInventoryCheckByInventoryCheckId(Long inventoryCheckId) - { + public WmsInventoryCheck selectWmsInventoryCheckByInventoryCheckId(Long inventoryCheckId) { return wmsInventoryCheckMapper.selectWmsInventoryCheckByInventoryCheckId(inventoryCheckId); } /** * 查询盘点记录列表 - * + * * @param wmsInventoryCheck 盘点记录 * @return 盘点记录 */ @Override - public List selectWmsInventoryCheckList(WmsInventoryCheck wmsInventoryCheck) - { + public List selectWmsInventoryCheckList(WmsInventoryCheck wmsInventoryCheck) { return wmsInventoryCheckMapper.selectWmsInventoryCheckList(wmsInventoryCheck); } /** * 新增盘点记录 - * - * @param wmsInventoryCheck 盘点记录 + * + * @param wmsInventoryCheckVo 进行盘点VO对象 * @return 结果 */ @Transactional @Override - public int insertWmsInventoryCheck(WmsInventoryCheck wmsInventoryCheck) - { - int rows = wmsInventoryCheckMapper.insertWmsInventoryCheck(wmsInventoryCheck); - insertWmsInventoryCheckDetail(wmsInventoryCheck); - return rows; + public Long insertWmsInventoryCheck(WmsInventoryCheckVo wmsInventoryCheckVo) { + Long inventoryCheckId = wmsInventoryCheckVo.getInventoryCheckId(); + Long toSetInventoryCheckId = inventoryCheckId; + Long warehouseId = wmsInventoryCheckVo.getWarehouseId(); + List locationCodes = wmsInventoryCheckVo.getLocationCodes(); + + String userName = SecurityUtils.getUsername(); + Date currentDate = new Date(); + + if (inventoryCheckId == null || inventoryCheckId.equals(0L)) { + WmsInventoryCheck queryInventoryCheck = new WmsInventoryCheck(); + queryInventoryCheck.setWarehouseId(warehouseId); + queryInventoryCheck.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_STATUS_INVENTORYING); + List wmsInventoryChecks = wmsInventoryCheckMapper.selectWmsInventoryCheckList(queryInventoryCheck); + if (wmsInventoryChecks != null && !wmsInventoryChecks.isEmpty()) { + throw new ServiceException("此仓库有未盘点完成的任务,请先盘点完成"); + } + + WmsBaseLocation queryLocation = new WmsBaseLocation(); + queryLocation.setWarehouseId(warehouseId); + int locationAmount = wmsBaseLocationMapper.selectCountOfWmsBaseLocation(queryLocation); + + WmsInventoryCheck wmsInventoryCheck = new WmsInventoryCheck(); + wmsInventoryCheck.setInventoryCheckCode(Seq.getId(Seq.wmsInventoryCheckSeqType, Seq.wmsInventoryCheckSeqCode)); + wmsInventoryCheck.setWarehouseId(warehouseId); + wmsInventoryCheck.setLocationAmount((long) locationAmount); + wmsInventoryCheck.setInventoryingAmount((long) locationCodes.size()); + wmsInventoryCheck.setBeginTime(currentDate); + wmsInventoryCheck.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_STATUS_INVENTORYING); + wmsInventoryCheck.setCreateDate(currentDate); + wmsInventoryCheck.setCreateBy(userName); + wmsInventoryCheckMapper.insertWmsInventoryCheck(wmsInventoryCheck); + + toSetInventoryCheckId = wmsInventoryCheck.getInventoryCheckId(); + } else { + WmsInventoryCheck toUpdatedInventoryCheck = wmsInventoryCheckMapper.selectWmsInventoryCheckByInventoryCheckId(inventoryCheckId); + toUpdatedInventoryCheck.setInventoryingAmount(toUpdatedInventoryCheck.getInventoriedAmount() + (long) locationCodes.size()); + toUpdatedInventoryCheck.setUpdateDate(currentDate); + toUpdatedInventoryCheck.setUpdateBy(userName); + wmsInventoryCheckMapper.updateWmsInventoryCheck(toUpdatedInventoryCheck); + } + + WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId); + String warehouseInstockType = baseWarehouse.getWarehouseInstockType(); + List wmsInventoryCheckDetails = new ArrayList<>(); + + for (String locationCode : locationCodes) { + WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); + if (location == null) { + throw new ServiceException("没有库位[" + locationCode + "]"); + } + if (!location.getLocationStatus().equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { + throw new ServiceException("库位[" + locationCode + "]状态锁定中,不能进行盘点"); + } + + //校验是否已经生成盘点记录明细(暂时不需要校验,有唯一索引) +// if (inventoryCheckId != null && !inventoryCheckId.equals(0L)) { +// int existedCount = wmsInventoryCheckDetailMapper.selectCountOfCheckDetailByCheckIdAndLocation(inventoryCheckId, locationCode); +// if (existedCount > 0) { +// throw new ServiceException("已经生成库位[" + locationCode + "]的盘点记录,不能重复盘点"); +// } +// } + + if (warehouseInstockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) { + WmsRawStock queryRawStock = new WmsRawStock(); + queryRawStock.setLocationCode(locationCode); + List wmsRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryRawStock); + if (wmsRawStocks != null && !wmsRawStocks.isEmpty()) { + for (WmsRawStock wmsRawStock : wmsRawStocks) { + WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); + wmsInventoryCheckDetail.setMaterialId(wmsRawStock.getMaterialId()); + wmsInventoryCheckDetail.setMaterialBatch(wmsRawStock.getInstockBatch()); + wmsInventoryCheckDetail.setInventoryTime(0L); + wmsInventoryCheckDetail.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW); + wmsInventoryCheckDetail.setStockId(wmsRawStock.getRawStockId()); + wmsInventoryCheckDetail.setLocationCode(locationCode); + wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); + wmsInventoryCheckDetail.setCreateDate(currentDate); + wmsInventoryCheckDetail.setCreateBy(userName); + wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); + wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); + } + } else {//如果库位没有库存也要增加数据 + WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); + wmsInventoryCheckDetail.setInventoryTime(0L); + wmsInventoryCheckDetail.setLocationCode(locationCode); + wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); + wmsInventoryCheckDetail.setCreateDate(currentDate); + wmsInventoryCheckDetail.setCreateBy(userName); + wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); + wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); + } + + } else { + WmsProductStock queryProductStock = new WmsProductStock(); + queryProductStock.setLocationCode(locationCode); + List wmsProductStocks = wmsProductStockMapper.selectWmsProductStockInList(queryProductStock); + if (wmsProductStocks != null && !wmsProductStocks.isEmpty()) { + for (WmsProductStock wmsProductStock : wmsProductStocks) { + WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); + wmsInventoryCheckDetail.setMaterialId(wmsProductStock.getProductId()); + wmsInventoryCheckDetail.setMaterialBatch(wmsProductStock.getProductBatch()); + wmsInventoryCheckDetail.setStockType(wmsProductStock.getStockType()); + wmsInventoryCheckDetail.setStockId(wmsProductStock.getProductStockId()); + wmsInventoryCheckDetail.setInventoryTime(0L); + wmsInventoryCheckDetail.setLocationCode(locationCode); + wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); + wmsInventoryCheckDetail.setCreateDate(currentDate); + wmsInventoryCheckDetail.setCreateBy(userName); + wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); + wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); + } + } else { + WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); + wmsInventoryCheckDetail.setInventoryTime(0L); + wmsInventoryCheckDetail.setLocationCode(locationCode); + wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); + wmsInventoryCheckDetail.setCreateDate(currentDate); + wmsInventoryCheckDetail.setCreateBy(userName); + wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); + wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); + } + } + } + + if (wmsInventoryCheckDetails.size() > 0) { + wmsInventoryCheckMapper.batchWmsInventoryCheckDetail(wmsInventoryCheckDetails); + } + + return toSetInventoryCheckId; } /** * 修改盘点记录 - * + * * @param wmsInventoryCheck 盘点记录 * @return 结果 */ @Transactional @Override - public int updateWmsInventoryCheck(WmsInventoryCheck wmsInventoryCheck) - { + public int updateWmsInventoryCheck(WmsInventoryCheck wmsInventoryCheck) { wmsInventoryCheckMapper.deleteWmsInventoryCheckDetailByInventoryCheckId(wmsInventoryCheck.getInventoryCheckId()); - insertWmsInventoryCheckDetail(wmsInventoryCheck); return wmsInventoryCheckMapper.updateWmsInventoryCheck(wmsInventoryCheck); } /** * 批量删除盘点记录 - * + * * @param inventoryCheckIds 需要删除的盘点记录主键 * @return 结果 */ @Transactional @Override - public int deleteWmsInventoryCheckByInventoryCheckIds(Long[] inventoryCheckIds) - { + public int deleteWmsInventoryCheckByInventoryCheckIds(Long[] inventoryCheckIds) { wmsInventoryCheckMapper.deleteWmsInventoryCheckDetailByInventoryCheckIds(inventoryCheckIds); return wmsInventoryCheckMapper.deleteWmsInventoryCheckByInventoryCheckIds(inventoryCheckIds); } /** * 删除盘点记录信息 - * + * * @param inventoryCheckId 盘点记录主键 * @return 结果 */ @Transactional @Override - public int deleteWmsInventoryCheckByInventoryCheckId(Long inventoryCheckId) - { + public int deleteWmsInventoryCheckByInventoryCheckId(Long inventoryCheckId) { wmsInventoryCheckMapper.deleteWmsInventoryCheckDetailByInventoryCheckId(inventoryCheckId); return wmsInventoryCheckMapper.deleteWmsInventoryCheckByInventoryCheckId(inventoryCheckId); } /** * 新增盘点记录明细信息 - * - * @param wmsInventoryCheck 盘点记录对象 + * + * @param wmsInventoryCheckDetailList 盘点记录明细列表 + * @param inventoryCheckId 盘点记录ID */ - public void insertWmsInventoryCheckDetail(WmsInventoryCheck wmsInventoryCheck) - { - List wmsInventoryCheckDetailList = wmsInventoryCheck.getWmsInventoryCheckDetailList(); - Long inventoryCheckId = wmsInventoryCheck.getInventoryCheckId(); - if (StringUtils.isNotNull(wmsInventoryCheckDetailList)) - { + public void insertWmsInventoryCheckDetail(List wmsInventoryCheckDetailList, Long inventoryCheckId) { + if (StringUtils.isNotNull(wmsInventoryCheckDetailList)) { List list = new ArrayList(); - for (WmsInventoryCheckDetail wmsInventoryCheckDetail : wmsInventoryCheckDetailList) - { + for (WmsInventoryCheckDetail wmsInventoryCheckDetail : wmsInventoryCheckDetailList) { wmsInventoryCheckDetail.setInventoryCheckId(inventoryCheckId); list.add(wmsInventoryCheckDetail); } - if (list.size() > 0) - { + if (list.size() > 0) { wmsInventoryCheckMapper.batchWmsInventoryCheckDetail(list); } } } + + + /** + * 查询盘点记录列表,join warehouse + * + * @param wmsInventoryCheck 盘点记录 + * @return 盘点记录 + */ + @Override + public List selectWmsInventoryCheckJoinList(WmsInventoryCheck wmsInventoryCheck) { + return wmsInventoryCheckMapper.selectWmsInventoryCheckJoinList(wmsInventoryCheck); + } + +// /** +// * 根据判断状态获取数据,按状态返回list数据 +// * +// * @param wmsInventoryCheckDetail +// * @return +// */ +// @Override +// public Map> getIncompletedInventoryCheckDetailsMap(WmsInventoryCheckDetail wmsInventoryCheckDetail) { +// wmsInventoryCheckDetail.setCheckStatusStr(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_TO_INVENTORY + "," + WmsConstants.WMS_INVENTORY_CHECK_STATUS_INVENTORYING); +// List wmsInventoryCheckDetailList = wmsInventoryCheckDetailMapper.selectWmsInventoryCheckDetailJoinList(wmsInventoryCheckDetail); +// +// Map> checkDetailMap = +// wmsInventoryCheckDetailList.stream().filter(checkDetail -> StringUtils.isNotEmpty(checkDetail.getCheckStatus())).collect(Collectors.groupingBy(WmsInventoryCheckDetail::getCheckStatus)); +// +// return checkDetailMap; +// } + + + /** + * 根据判断状态获取数据,按状态返回list数据 + * + * @param wmsInventoryCheckDetail + * @return + */ + @Override + public List getIncompletedInventoryCheckDetails(WmsInventoryCheckDetail wmsInventoryCheckDetail) { + List wmsInventoryCheckDetailList = wmsInventoryCheckDetailMapper.selectWmsInventoryCheckDetailJoinList(wmsInventoryCheckDetail); + return wmsInventoryCheckDetailList; + } + + + /** + * 确认盘点 + * + * @param wmsInventoryCheckDetailVo + * @return + */ + @Override + public int confirmInventoryCheckDetail(WmsInventoryCheckDetailVo wmsInventoryCheckDetailVo) { + WmsInventoryCheckDetail existedInventoryCheckDetail = wmsInventoryCheckDetailMapper. + selectWmsInventoryCheckDetailByInventoryCheckDetailId(wmsInventoryCheckDetailVo.getInventoryCheckDetailId()); + if (existedInventoryCheckDetail.getCheckStatus().equals(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_FINISH)) { + throw new ServiceException("已经盘点完成,不能再确认"); + } + + String stockType = existedInventoryCheckDetail.getStockType(); + Long stockId = existedInventoryCheckDetail.getStockId(); + BigDecimal realAmount = wmsInventoryCheckDetailVo.getRealAmount(); + Long inventoryTime = existedInventoryCheckDetail.getInventoryTime() == null ? 0L : existedInventoryCheckDetail.getInventoryTime(); + existedInventoryCheckDetail.setInventoryTime(inventoryTime + 1); + existedInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); + if (stockId != null) { + if (stockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) { + WmsRawStock rawStock = wmsRawStockMapper.selectWmsRawStockByRawStockId(stockId); + BigDecimal stockAmount = rawStock == null ? BigDecimal.ZERO : rawStock.getTotalAmount(); + existedInventoryCheckDetail.setStockAmount(stockAmount); + } else { + WmsProductStock productStock = wmsProductStockMapper.selectWmsProductStockByProductStockId(stockId); + BigDecimal stockAmount = productStock == null ? BigDecimal.ZERO : productStock.getTotalAmount(); + existedInventoryCheckDetail.setStockAmount(stockAmount); + } + } else { + if (realAmount.compareTo(BigDecimal.ZERO) > 0) { + throw new ServiceException("此库位无库存信息,实际盘库数量需等于0"); + } + } + + existedInventoryCheckDetail.setRealAmount(realAmount); + existedInventoryCheckDetail.setUpdateDate(new Date()); + existedInventoryCheckDetail.setUpdateBy(SecurityUtils.getUsername()); + + return wmsInventoryCheckDetailMapper.updateWmsInventoryCheckDetail(existedInventoryCheckDetail); + } + + + /** + * 盘点完成 + * + * @param wmsInventoryCheck + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int completeInventoryCheck(WmsInventoryCheck wmsInventoryCheck) { + List wmsInventoryCheckDetailList = wmsInventoryCheck.getWmsInventoryCheckDetailList(); + List unconfirmedCheckDetails = wmsInventoryCheckDetailList.stream() + .filter(checkDetail -> checkDetail.getInventoryTime() < 1).collect(Collectors.toList()); + if (unconfirmedCheckDetails != null && !unconfirmedCheckDetails.isEmpty()) { + throw new ServiceException("请先全部确认后再点击盘点完成"); + } + + Map> inventoryCheckDetailMap = wmsInventoryCheckDetailList.stream() + .collect(Collectors.groupingBy(WmsInventoryCheckDetail::getLocationCode)); + long completeLocationAmount = inventoryCheckDetailMap.entrySet().size(); + +// List inventoryCheckDetailIds = wmsInventoryCheckDetailList.stream().map(WmsInventoryCheckDetail::getInventoryCheckDetailId).collect(Collectors.toList()); + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + wmsInventoryCheckDetailList.forEach(wmsInventoryCheckDetail -> { + wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_FINISH); + wmsInventoryCheckDetail.setUpdateDate(currentDate); + wmsInventoryCheckDetail.setUpdateBy(userName); + wmsInventoryCheckDetailMapper.updateWmsInventoryCheckDetail(wmsInventoryCheckDetail); + }); + + WmsInventoryCheck existedInventoryCheck = wmsInventoryCheckMapper.selectOnlyInventoryCheckByInventoryCheckId(wmsInventoryCheck.getInventoryCheckId()); + Long inventoriedAmount = existedInventoryCheck.getInventoriedAmount(); + Long locationAmount = existedInventoryCheck.getLocationAmount(); + Long currentInventoriedAmount = inventoriedAmount + completeLocationAmount; + wmsInventoryCheck.setInventoriedAmount(currentInventoriedAmount); + wmsInventoryCheck.setUpdateDate(currentDate); + wmsInventoryCheck.setUpdateBy(userName); + if (currentInventoriedAmount >= locationAmount) { + wmsInventoryCheck.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_STATUS_FINISH); + wmsInventoryCheck.setEndTime(currentDate); + } + return wmsInventoryCheckMapper.updateWmsInventoryCheck(wmsInventoryCheck); + } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java index ceb28b3..ba3cf52 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java @@ -208,7 +208,11 @@ public class WmsMoveServiceImpl implements IWmsMoveService { } WmsBaseWarehouse baseWareHouse = wmsBaseWarehouseMapper. - selectWmsBaseWarehouseByWarehouseId(wmsMoveApplyVo.getWarehouseId()); + selectWmsBaseWarehouseByWarehouseId(oriLocation.getWarehouseId()); + if (!baseWareHouse.getWarehouseType().equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { + throw new ServiceException("请选择人工仓库的库位进行移库"); + } + String warehouseInstockType = baseWareHouse.getWarehouseInstockType(); List toInsertedMoves = new ArrayList<>(); Date currentDate = new Date(); diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml index 2260cd8..c5dd3e3 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml @@ -260,6 +260,39 @@ + + + + + diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckDetailMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckDetailMapper.xml new file mode 100644 index 0000000..dd656d2 --- /dev/null +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckDetailMapper.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select inventory_check_detail_id, inventory_check_id, material_id, location_code, material_batch, stock_type, stock_id, stock_amount, real_amount, check_status, inventory_time, erp_status, erp_amount, remark, create_by, create_date, update_by, update_date from wms_inventory_check_detail + + + + + + + + insert into wms_inventory_check_detail + + inventory_check_id, + material_id, + location_code, + material_batch, + stock_type, + stock_id, + stock_amount, + real_amount, + check_status, + inventory_time, + erp_status, + erp_amount, + remark, + create_by, + create_date, + update_by, + update_date, + + + #{inventoryCheckId}, + #{materialId}, + #{locationCode}, + #{materialBatch}, + #{stockType}, + #{stockId}, + #{stockAmount}, + #{realAmount}, + #{checkStatus}, + #{inventoryTime}, + #{erpStatus}, + #{erpAmount}, + #{remark}, + #{createBy}, + #{createDate}, + #{updateBy}, + #{updateDate}, + + + + + update wms_inventory_check_detail + + inventory_check_id = #{inventoryCheckId}, + material_id = #{materialId}, + location_code = #{locationCode}, + material_batch = #{materialBatch}, + stock_type = #{stockType}, + stock_id = #{stockId}, + stock_amount = #{stockAmount}, + real_amount = #{realAmount}, + check_status = #{checkStatus}, + inventory_time = #{inventoryTime}, + erp_status = #{erpStatus}, + erp_amount = #{erpAmount}, + remark = #{remark}, + create_by = #{createBy}, + create_date = #{createDate}, + update_by = #{updateBy}, + update_date = #{updateDate}, + + where inventory_check_detail_id = #{inventoryCheckDetailId} + + + + delete from wms_inventory_check_detail where inventory_check_detail_id = #{inventoryCheckDetailId} + + + + delete from wms_inventory_check_detail where inventory_check_detail_id in + + #{inventoryCheckDetailId} + + + + + + + + + + + + + + select wicd.inventory_check_detail_id, wicd.inventory_check_id, wicd.material_id, wicd.material_batch, + wicd.stock_type, wicd.stock_id, wicd.stock_amount, wicd.real_amount, wicd.check_status, wicd.inventory_time, + mbmi.material_code,mbmi.material_name + from wms_inventory_check_detail wicd left join mes_base_material_info mbmi on wicd.material_id = mbmi.material_id + + + + + diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckMapper.xml index 1c890a9..f9f11d5 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckMapper.xml @@ -1,14 +1,19 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + + + + + @@ -20,15 +25,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + @@ -37,58 +48,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select inventory_check_id, inventory_check_code, warehouse_id, check_status, remark, create_by, create_date, update_by, update_date from wms_inventory_check + select inventory_check_id, inventory_check_code, warehouse_id, check_status, begin_time, end_time, location_amount, inventorying_amount, inventoried_amount, remark, create_by, create_date, update_by, update_date from wms_inventory_check - + - + insert into wms_inventory_check - inventory_check_code, + inventory_check_code, warehouse_id, check_status, + begin_time, + end_time, + location_amount, + inventorying_amount, + inventoried_amount, remark, create_by, create_date, update_by, update_date, - + - #{inventoryCheckCode}, + #{inventoryCheckCode}, #{warehouseId}, #{checkStatus}, + #{beginTime}, + #{endTime}, + #{locationAmount}, + #{inventoryingAmount}, + #{inventoriedAmount}, #{remark}, #{createBy}, #{createDate}, #{updateBy}, #{updateDate}, - + update wms_inventory_check - inventory_check_code = #{inventoryCheckCode}, + inventory_check_code = #{inventoryCheckCode}, warehouse_id = #{warehouseId}, check_status = #{checkStatus}, + begin_time = #{beginTime}, + end_time = #{endTime}, + location_amount = #{locationAmount}, + inventorying_amount = #{inventoryingAmount}, + inventoried_amount = #{inventoriedAmount}, remark = #{remark}, create_by = #{createBy}, create_date = #{createDate}, @@ -103,14 +131,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from wms_inventory_check where inventory_check_id in + delete from wms_inventory_check where inventory_check_id in #{inventoryCheckId} - + - delete from wms_inventory_check_detail where inventory_check_id in + delete from wms_inventory_check_detail where inventory_check_id in #{inventoryCheckId} @@ -121,9 +149,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into wms_inventory_check_detail( inventory_check_detail_id, inventory_check_id, material_id, location_code, stock_amount, real_amount, check_status, erp_status, remark, create_by, create_date, update_by, update_date) values - - ( #{item.inventoryCheckDetailId}, #{item.inventoryCheckId}, #{item.materialId}, #{item.locationCode}, #{item.stockAmount}, #{item.realAmount}, #{item.checkStatus}, #{item.erpStatus}, #{item.remark}, #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate}) + insert into wms_inventory_check_detail( inventory_check_detail_id, inventory_check_id, material_id, location_code, material_batch, stock_type, stock_id, stock_amount, real_amount, check_status, inventory_time, erp_status, erp_amount, remark, create_by, create_date, update_by, update_date) values + + ( #{item.inventoryCheckDetailId}, #{item.inventoryCheckId}, #{item.materialId}, #{item.locationCode}, #{item.materialBatch}, #{item.stockType}, #{item.stockId}, #{item.stockAmount}, #{item.realAmount}, #{item.checkStatus}, #{item.inventoryTime}, #{item.erpStatus}, #{item.erpAmount}, #{item.remark}, #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate}) - \ No newline at end of file + + + + + + + + + + + +