diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java index c4ad903..05ca814 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java @@ -72,7 +72,7 @@ public class WmsApiController extends BaseController { /** - * 申请领料 + * 申请领料,如果是五楼申请领柜体,wcs轮询后执行完成要删除库存 */ // @RequiresPermissions("wms:mobile:addrawinstock") @Log(title = "原材料出库记录", businessType = BusinessType.APPLY) @@ -143,7 +143,7 @@ public class WmsApiController extends BaseController { } /** - * 申请返库 + * 申请返库,wcs轮询后执行完成要插入库存,完整标识为否 */ @Log(title = "原材料返库记录", businessType = BusinessType.APPLY) @PostMapping(("/applyRawBack")) 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 4a0665c..112412d 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 @@ -29,7 +29,7 @@ import com.hw.common.core.web.page.TableDataInfo; * @date 2023-12-20 */ @RestController -@RequestMapping("/wmscheck") +@RequestMapping("/inventoryCheck") public class WmsInventoryCheckController extends BaseController { @Autowired @@ -38,7 +38,7 @@ public class WmsInventoryCheckController extends BaseController /** * 查询盘点记录列表 */ - @RequiresPermissions("wms:wmscheck:list") + @RequiresPermissions("wms:inventoryCheck:list") @GetMapping("/list") public TableDataInfo list(WmsInventoryCheck wmsInventoryCheck) { @@ -50,7 +50,7 @@ public class WmsInventoryCheckController extends BaseController /** * 导出盘点记录列表 */ - @RequiresPermissions("wms:wmscheck:export") + @RequiresPermissions("wms:inventoryCheck:export") @Log(title = "盘点记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, WmsInventoryCheck wmsInventoryCheck) @@ -63,7 +63,7 @@ public class WmsInventoryCheckController extends BaseController /** * 获取盘点记录详细信息 */ - @RequiresPermissions("wms:wmscheck:query") + @RequiresPermissions("wms:inventoryCheck:query") @GetMapping(value = "/{inventoryCheckId}") public AjaxResult getInfo(@PathVariable("inventoryCheckId") Long inventoryCheckId) { @@ -84,7 +84,7 @@ public class WmsInventoryCheckController extends BaseController /** * 修改盘点记录 */ - @RequiresPermissions("wms:wmscheck:edit") + @RequiresPermissions("wms:inventoryCheck:edit") @Log(title = "盘点记录", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody WmsInventoryCheck wmsInventoryCheck) @@ -95,7 +95,7 @@ public class WmsInventoryCheckController extends BaseController /** * 删除盘点记录 */ - @RequiresPermissions("wms:wmscheck:remove") + @RequiresPermissions("wms:inventoryCheck:remove") @Log(title = "盘点记录", businessType = BusinessType.DELETE) @DeleteMapping("/{inventoryCheckIds}") public AjaxResult remove(@PathVariable Long[] inventoryCheckIds) 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 35ff6a8..d85b570 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 @@ -198,9 +198,9 @@ public class WmsMobileController extends BaseController { @GetMapping("/getAuditPassRawReturns") public TableDataInfo getAuditPassRawReturns(WmsRawReturnDetail wmsRawReturnDetail) { startPage(); - WmsRawReturn wmsRawReturn = new WmsRawReturn(); wmsRawReturn.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); + wmsRawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); List list = wmsRawReturnService.selectWmsRawReturnJoinList(wmsRawReturn); return getDataTable(list); } @@ -349,7 +349,7 @@ public class WmsMobileController extends BaseController { queryProductOutstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); queryProductOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); queryProductOutstock.setProductType(WmsConstants.WMS_PRODUCT_OUTSTOCK_PRODUCT_TYPE_PRODUCT); - List list = wmsProductOutstockService.selectWmsProductOutstockJoinList(queryProductOutstock); + List list = wmsProductOutstockService.selectWmsProductOutstockJoinList(queryProductOutstock); return getDataTable(list); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsProductInstockController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsProductInstockController.java index 523a35f..4d2401e 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsProductInstockController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsProductInstockController.java @@ -29,7 +29,7 @@ import com.hw.common.core.web.page.TableDataInfo; * @date 2023-12-25 */ @RestController -@RequestMapping("/productinstock") +@RequestMapping("/productInstock") public class WmsProductInstockController extends BaseController { @Autowired @@ -38,7 +38,7 @@ public class WmsProductInstockController extends BaseController /** * 查询成品入库记录;成品入库记录列表 */ - @RequiresPermissions("wms:productinstock:list") + @RequiresPermissions("wms:productInstock:list") @GetMapping("/list") public TableDataInfo list(WmsProductInstock wmsProductInstock) { @@ -50,7 +50,7 @@ public class WmsProductInstockController extends BaseController /** * 导出成品入库记录;成品入库记录列表 */ - @RequiresPermissions("wms:productinstock:export") + @RequiresPermissions("wms:productInstock:export") @Log(title = "成品入库记录;成品入库记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, WmsProductInstock wmsProductInstock) @@ -63,7 +63,7 @@ public class WmsProductInstockController extends BaseController /** * 获取成品入库记录;成品入库记录详细信息 */ - @RequiresPermissions("wms:productinstock:query") + @RequiresPermissions("wms:productInstock:query") @GetMapping(value = "/{productInstockId}") public AjaxResult getInfo(@PathVariable("productInstockId") Long productInstockId) { @@ -73,7 +73,7 @@ public class WmsProductInstockController extends BaseController /** * 新增成品入库记录;成品入库记录 */ - @RequiresPermissions("wms:productinstock:add") + @RequiresPermissions("wms:productInstock:add") @Log(title = "成品入库记录;成品入库记录", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody WmsProductInstock wmsProductInstock) @@ -84,7 +84,7 @@ public class WmsProductInstockController extends BaseController /** * 修改成品入库记录;成品入库记录 */ - @RequiresPermissions("wms:productinstock:edit") + @RequiresPermissions("wms:productInstock:edit") @Log(title = "成品入库记录;成品入库记录", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody WmsProductInstock wmsProductInstock) @@ -95,7 +95,7 @@ public class WmsProductInstockController extends BaseController /** * 删除成品入库记录;成品入库记录 */ - @RequiresPermissions("wms:productinstock:remove") + @RequiresPermissions("wms:productInstock:remove") @Log(title = "成品入库记录;成品入库记录", businessType = BusinessType.DELETE) @DeleteMapping("/{productInstockIds}") public AjaxResult remove(@PathVariable Long[] productInstockIds) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java index f900cf6..f8f0b55 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java @@ -46,6 +46,9 @@ public class WmsRawOutstock extends BaseEntity { @Excel(name = "库位编码;移库和合库时需要保存") private String locationCode; + private Long stockTotalId; + + /** * 工单ID,关联pd_base_order_info的order_id */ @@ -253,6 +256,14 @@ public class WmsRawOutstock extends BaseEntity { return locationCode; } + public Long getStockTotalId() { + return stockTotalId; + } + + public void setStockTotalId(Long stockTotalId) { + this.stockTotalId = stockTotalId; + } + public void setOrderId(Long orderId) { this.orderId = orderId; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java index 797db83..5100204 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java @@ -90,7 +90,7 @@ public interface WmsProductStockMapper /** - * 查询totalAmount>0成品库存列表 + * 查询totalAmount>0成品库存列表,join material和warehouse * * @param wmsProductStock 成品库存 * @return 成品库存集合 @@ -115,4 +115,12 @@ public interface WmsProductStockMapper public List selectWmsProductStocksBySaleorder(WmsProductStock wmsProductStock); + /** + * 查询totalAmount>0成品库存列表 + * + * @param wmsProductStock 成品库存 + * @return 成品库存集合 + */ + public List selectOnlyWmsProductStockInList(WmsProductStock wmsProductStock); + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawStockMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawStockMapper.java index 8683761..466747a 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawStockMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawStockMapper.java @@ -85,7 +85,7 @@ public interface WmsRawStockMapper { public List selectWmsRawStocks4Apply(WmsRawStock wmsRawStock); /** - * 查询totalAmount>0的库存列表 + * 查询totalAmount>0的库存列表,join material和warehouse * * @param wmsRawStock 原材料库存 * @return 原材料库存集合 @@ -93,4 +93,11 @@ public interface WmsRawStockMapper { public List selectWmsRawStockInList(WmsRawStock wmsRawStock); + /** + * 查询totalAmount>0的库存列表 + * + * @param wmsRawStock 原材料库存 + * @return 原材料库存集合 + */ + public List selectOnlyWmsRawStockInList(WmsRawStock wmsRawStock); } 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 ee8c039..79dd029 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 @@ -148,13 +148,16 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { queryRawStock.setLocationCode(locationCode); List wmsRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryRawStock); if (wmsRawStocks != null && !wmsRawStocks.isEmpty()) { - for (WmsRawStock wmsRawStock : wmsRawStocks) { + //需要根据materialid过滤聚合,盘点是盘点某个物料,不能按物料条码进行盘点 + Map> wmsRawStockMap = wmsRawStocks.stream() + .collect(Collectors.groupingBy(WmsRawStock::getMaterialId)); + + for (Long materialId : wmsRawStockMap.keySet()) { WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); - wmsInventoryCheckDetail.setMaterialId(wmsRawStock.getMaterialId()); - wmsInventoryCheckDetail.setMaterialBatch(wmsRawStock.getInstockBatch()); + wmsInventoryCheckDetail.setMaterialId(materialId); wmsInventoryCheckDetail.setInventoryTime(0L); wmsInventoryCheckDetail.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW); - wmsInventoryCheckDetail.setStockId(wmsRawStock.getRawStockId()); +// wmsInventoryCheckDetail.setStockId(wmsRawStock.getRawStockId()); wmsInventoryCheckDetail.setLocationCode(locationCode); wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); wmsInventoryCheckDetail.setCreateDate(currentDate); @@ -162,7 +165,8 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); } - } else {//如果库位没有库存也要增加数据 + + } else {//如果库位没有库存也要增加数据,用来判断所有库位是否已盘点完成 WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); wmsInventoryCheckDetail.setInventoryTime(0L); wmsInventoryCheckDetail.setLocationCode(locationCode); @@ -178,12 +182,17 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { queryProductStock.setLocationCode(locationCode); List wmsProductStocks = wmsProductStockMapper.selectWmsProductStockInList(queryProductStock); if (wmsProductStocks != null && !wmsProductStocks.isEmpty()) { - for (WmsProductStock wmsProductStock : wmsProductStocks) { + //需要根据materialid过滤聚合,盘点是盘点某个物料,不能按物料条码进行盘点 + Map> wmsProductStockMap = wmsProductStocks.stream() + .collect(Collectors.groupingBy(WmsProductStock::getProductId)); + for (Long productId : wmsProductStockMap.keySet()) { + List wmsProductStockList = wmsProductStockMap.get(productId); + WmsProductStock wmsProductStock = wmsProductStockList.get(0); WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); - wmsInventoryCheckDetail.setMaterialId(wmsProductStock.getProductId()); - wmsInventoryCheckDetail.setMaterialBatch(wmsProductStock.getProductBatch()); + wmsInventoryCheckDetail.setMaterialId(productId); +// wmsInventoryCheckDetail.setMaterialBatch(wmsProductStock.getProductBatch()); wmsInventoryCheckDetail.setStockType(wmsProductStock.getStockType()); - wmsInventoryCheckDetail.setStockId(wmsProductStock.getProductStockId()); +// wmsInventoryCheckDetail.setStockId(wmsProductStock.getProductStockId()); wmsInventoryCheckDetail.setInventoryTime(0L); wmsInventoryCheckDetail.setLocationCode(locationCode); wmsInventoryCheckDetail.setCheckStatus(WmsConstants.WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING); @@ -192,7 +201,8 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { wmsInventoryCheckDetail.setInventoryCheckId(toSetInventoryCheckId); wmsInventoryCheckDetails.add(wmsInventoryCheckDetail); } - } else { + + } else {//如果库位没有库存也要增加数据,用来判断所有库位是否已盘点完成 WmsInventoryCheckDetail wmsInventoryCheckDetail = new WmsInventoryCheckDetail(); wmsInventoryCheckDetail.setInventoryTime(0L); wmsInventoryCheckDetail.setLocationCode(locationCode); @@ -328,27 +338,40 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { } String stockType = existedInventoryCheckDetail.getStockType(); - Long stockId = existedInventoryCheckDetail.getStockId(); - BigDecimal realAmount = wmsInventoryCheckDetailVo.getRealAmount(); +// 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); - } + + WmsInventoryCheck wmsInventoryCheck = wmsInventoryCheckMapper.selectWmsInventoryCheckByInventoryCheckId(existedInventoryCheckDetail.getInventoryCheckId()); + + //根据物料id查询库存数量 + if (stockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) { + WmsRawStock queryRawStock = new WmsRawStock(); + queryRawStock.setMaterialId(existedInventoryCheckDetail.getMaterialId()); + queryRawStock.setWarehouseId(wmsInventoryCheck.getWarehouseId()); + List wmsRawStockInList = wmsRawStockMapper.selectOnlyWmsRawStockInList(queryRawStock); + //需要区分批次和非批次,所以需要通过totalAmount相加得出此物料库存总数量 + BigDecimal stockAmount = wmsRawStockInList == null || wmsRawStockInList.isEmpty() ? BigDecimal.ZERO : + wmsRawStockInList.stream() + .map(WmsRawStock::getTotalAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + existedInventoryCheckDetail.setStockAmount(stockAmount); } else { - if (realAmount.compareTo(BigDecimal.ZERO) > 0) { - throw new ServiceException("此库位无库存信息,实际盘库数量需等于0"); - } + WmsProductStock queryProductStock = new WmsProductStock(); + queryProductStock.setProductId(existedInventoryCheckDetail.getMaterialId()); + queryProductStock.setWarehouseId(wmsInventoryCheck.getWarehouseId()); + List wmsProductStockInList = wmsProductStockMapper.selectOnlyWmsProductStockInList(queryProductStock); + //需要区分批次和非批次,所以需要通过totalAmount相加得出此物料库存总数量 + BigDecimal stockAmount = wmsProductStockInList == null || wmsProductStockInList.isEmpty() ? BigDecimal.ZERO : + wmsProductStockInList.stream() + .map(WmsProductStock::getTotalAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + existedInventoryCheckDetail.setStockAmount(stockAmount); } + existedInventoryCheckDetail.setRealAmount(realAmount); existedInventoryCheckDetail.setUpdateDate(new Date()); existedInventoryCheckDetail.setUpdateBy(SecurityUtils.getUsername()); 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 764f89f..6f71d08 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 @@ -293,7 +293,7 @@ public class WmsMoveServiceImpl implements IWmsMoveService { String taskCode = Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode); wmsRawStocks.forEach(wmsRawStock -> { WmsMove wmsMove = new WmsMove(); - wmsMove.setInstockBatch(wmsRawStock.getInstockBatch()); + wmsMove.setInstockBatch(wmsRawStock.getInstockBatch());//物料条码 wmsMove.setMaterialId(wmsRawStock.getMaterialId()); wmsMove.setWarehouseId(wmsRawStock.getWarehouseId()); wmsMove.setOriLocationCode(wmsMoveApplyVo.getOriLocationCode()); @@ -412,8 +412,8 @@ public class WmsMoveServiceImpl implements IWmsMoveService { String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); - String batchCode = baseBarcodeInfo.getBatchCode(); + //先根据原库位编码找到需要移库的信息 WmsMove queryMove = new WmsMove(); queryMove.setTaskCode(taskCode); // queryMove.setInstockBatch(batchCode); @@ -423,8 +423,9 @@ public class WmsMoveServiceImpl implements IWmsMoveService { throw new ServiceException("没有此移库信息"); } + //从原库位所有需要移库的物料条码中find当前移库物料条码的信息 WmsMove wmsMove = wmsMoveList.stream().filter(move -> - move.getInstockBatch().equals(batchCode)).findFirst().get(); + move.getInstockBatch().equals(materialBarcode)).findFirst().get(); if (wmsMove == null) { throw new ServiceException("没有此移库信息"); } @@ -452,9 +453,9 @@ public class WmsMoveServiceImpl implements IWmsMoveService { String barcodeType = baseBarcodeInfo.getBarcodeType(); if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料 - moveOutUpdateRawStock(locationCode, batchCode, applyQty, userName, currentDate); + moveOutUpdateRawStock(locationCode, materialBarcode, applyQty, userName, currentDate); } else {//如果是成品 - moveOutUpdateProductStock(locationCode, batchCode, applyQty, userName, currentDate); + moveOutUpdateProductStock(locationCode, materialBarcode, applyQty, userName, currentDate); } //插入移库合库明细记录 @@ -531,10 +532,9 @@ public class WmsMoveServiceImpl implements IWmsMoveService { wmsMoveMapper.updateWmsMove(wmsMove); } - public void moveOutUpdateRawStock(String locationCode, String batchCode, BigDecimal applyQty, + public void moveOutUpdateRawStock(String locationCode, String materialBarcode, BigDecimal applyQty, String userName, Date currentDate) { - //TODO:批次码 - WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(batchCode); + WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode); if (wmsRawStock == null) { throw new ServiceException("原库位无库存信息,不能进行移库"); } @@ -560,10 +560,10 @@ public class WmsMoveServiceImpl implements IWmsMoveService { } - public void moveOutUpdateProductStock(String locationCode, String batchCode, BigDecimal applyQty, + public void moveOutUpdateProductStock(String locationCode, String materialBarcode, BigDecimal applyQty, String userName, Date currentDate) { - WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByBatch(batchCode); + WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode); if (wmsProductStock == null) { throw new ServiceException("原库位无库存信息,不能进行移库"); } @@ -687,10 +687,9 @@ public class WmsMoveServiceImpl implements IWmsMoveService { public void moveInUpdateRawStock(WmsBaseLocation location, MesBaseBarcodeInfo mesBaseBarcodeInfo, BigDecimal applyQty, String userName, Date currentDate) { - String batchCode = mesBaseBarcodeInfo.getBatchCode(); + String materialBarcode = mesBaseBarcodeInfo.getBarcodeInfo(); String locationCode = location.getLocationCode(); - //todo:批次码 - WmsRawStock rawStock = wmsRawStockMapper.selectRawStockByBarcode(batchCode); + WmsRawStock rawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode); if (rawStock != null) { rawStock.setTotalAmount(rawStock.getTotalAmount().add(applyQty)); rawStock.setUpdateDate(currentDate); @@ -746,7 +745,6 @@ public class WmsMoveServiceImpl implements IWmsMoveService { * * @param wmsMove * @param wmsMoveList - * @param oriLocation * @param applyQty * @param userName * @param currentDate diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java index 5f40fbc..0324764 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java @@ -287,7 +287,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { } /** - * 生产入库,适合在五楼背板安装区(将组装好的柜体入到半成品库) + * 生产入库,适合在五楼背板安装区(将组装好的柜体入到半成品库),WCS轮询入库记录后进行入库,入库后更新库存 * * @param wmsProduceInstockVo * @return diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java index 373adc6..a6d9396 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java @@ -80,6 +80,9 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService String saleorderCode = wmsProductOutstock.getSaleorderCode(); Long productId = wmsProductOutstock.getProductId(); BigDecimal applyQty = wmsProductOutstock.getApplyQty(); + if(applyQty.compareTo(BigDecimal.ZERO) <=0){ + throw new ServiceException("申请数量需大于0"); + } WmsProductStock queryProductStock = new WmsProductStock(); queryProductStock.setWarehouseId(warehouseId); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java index 5ff932b..1379f8b 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java @@ -251,7 +251,7 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService { /** - * 柜体拆分后返库 + * 柜体拆分后返库,wcs轮询后执行完成要插入库存,完整标识为否 * * @param wmsRawBackVo */ @@ -306,7 +306,7 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService { wmsRawInstock.setApplyBy(SecurityUtils.getUsername()); wmsRawInstock.setApplyDate(new Date()); - //wcs轮询后执行完成要更新库存 + //wcs轮询后执行完成要插入库存,完整标识为否 return wmsRawInstockMapper.insertWmsRawInstock(wmsRawInstock); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java index 6ae8583..e8129e8 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java @@ -228,31 +228,34 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("无待审核原材料出库记录"); } - //审核不通过,需要有审核意见,并且需要更新库位占用数量(解除之前占用的数量)。 + //审核不通过,需要有审核意见,并且需要更新wmsStockTotal库位占用数量(解除之前占用的数量)。 if (auditStatus.equalsIgnoreCase(WmsConstants.WMS_AUDIT_STATUS_FAIL)) { if (StringUtils.isEmpty(auditReason)) { throw new ServiceException("请输入审核意见"); } wmsRawOutstocks.forEach(wmsRawOutstock -> { //todo:批次码 - String locationCode = wmsRawOutstock.getLocationCode(); - String instockBatch = wmsRawOutstock.getMaterialBatch(); + Long stockTotalId = wmsRawOutstock.getStockTotalId(); BigDecimal planAmount = wmsRawOutstock.getOutstockAmount(); - WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(instockBatch); - if (wmsRawStock != null) { - BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null || - wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? - BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); + WmsStockTotal wmsStockTotal = wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(stockTotalId); + + if (wmsStockTotal != null) { + BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null || + wmsStockTotal.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? + BigDecimal.ZERO : wmsStockTotal.getOccupyAmount(); + + if (occupyAmount.compareTo(planAmount) >= 0) { - wmsRawStock.setOccupyAmount(occupyAmount.subtract(planAmount)); - wmsRawStock.setUpdateBy(userName); - wmsRawStock.setUpdateDate(currentDate); + wmsStockTotal.setOccupyAmount(occupyAmount.subtract(planAmount)); + wmsStockTotal.setUpdateBy(userName); + wmsStockTotal.setUpdateDate(currentDate); } else { - wmsRawStock.setOccupyAmount(BigDecimal.ZERO); - wmsRawStock.setUpdateBy(userName); - wmsRawStock.setUpdateDate(currentDate); + wmsStockTotal.setOccupyAmount(BigDecimal.ZERO); + wmsStockTotal.setUpdateBy(userName); + wmsStockTotal.setUpdateDate(currentDate); } - wmsRawStockMapper.updateWmsRawStock(wmsRawStock); + + wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal); } }); } @@ -382,7 +385,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { updateRawStock(materialBarcode, outstockAmount, userName, currentDate); - //trigger中更新stocktotal的占用数量和库存数量 + //rawstock的trigger中更新stocktotal的占用数量和库存数量 return 1; } @@ -506,9 +509,9 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { : wmsRawOutstock.getTaskType(); String warehouseType = baseWarehouse.getWarehouseType(); + //TODO 判断质检状态,还是在实际出库时判断质检状态 String queryQualityStatus = WmsConstants.WMS_QUALITY_STATUS_PASS; - List toInsertedRawOutstocks = new ArrayList<>(); Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); @@ -536,7 +539,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { WmsRawOutstock toInsertedRawOutstock = getWmsRawOutstock(baseWarehouse, planCode, planDetailCode, rawOutstockDetail.getMaterialId(), taskCode, taskType, wmsRawOutstock.getApplyReason(), - planAmount, currentDate, userName); + planAmount, currentDate, userName, wmsStockTotal.getStockTotalId()); toInsertedRawOutstocks.add(toInsertedRawOutstock); } else { @@ -569,7 +572,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { */ private WmsRawOutstock getWmsRawOutstock(WmsBaseWarehouse baseWarehouse, String planCode, String planDetailCode, Long materialId, String taskCode, String taskType, String applyReason, - BigDecimal planAmount, Date currentDate, String userName) { + BigDecimal planAmount, Date currentDate, String userName, Long stockTotalId) { //出库要求 (0申请出库,1申请审核出库,2直接出库) String outRequirement = baseWarehouse.getOutRequirement(); String warehouseType = baseWarehouse.getWarehouseType(); @@ -593,6 +596,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { toInsertedRawOutstock.setWarehouseId(baseWarehouse.getWarehouseId()); // toInsertedRawOutstock.setLocationCode(wmsRawStock.getLocationCode()); toInsertedRawOutstock.setStationId(SecurityUtils.getStationId()); + toInsertedRawOutstock.setStockTotalId(stockTotalId); // toInsertedRawOutstock.setPalletInfoCode(wmsRawStock.getPalletInfoCode()); toInsertedRawOutstock.setOperationType(operationType); toInsertedRawOutstock.setApplyBy(userName); @@ -603,7 +607,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { toInsertedRawOutstock.setOutstockAmount(planAmount); toInsertedRawOutstock.setPlanCode(planCode); toInsertedRawOutstock.setPlanDetailCode(planDetailCode); -// toInsertedRawOutstock.setMaterialBatch(wmsRawStock.getInstockBatch()); +// toInsertedRawOutstock.setMaterialBatch(wmsRawStock.getInstockBatch());//申请出库时不指定某个物料 toInsertedRawOutstock.setTaskType(taskType); toInsertedRawOutstock.setCreateTime(currentDate); toInsertedRawOutstock.setCreateBy(userName); @@ -920,6 +924,11 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { */ @Override public int assembleOutstock(WmsAssembleOutstockVo wmsAssembleOutstockVo) { + /**1、todo:柜体出库,wcs轮询后执行完成要删除库存 + * 2、拆分,生成条码绑定,贴码 + * 3、返库(返库的是之前的条码,库存也是之前条码库存信息,返库后记录完整标识),WCS轮询执行完成后要插入库存,完整标识为否 + * * + */ String materialBarcode = wmsAssembleOutstockVo.getMaterialBarcode(); R baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); if (baseBarcodeInfoR == null) { @@ -930,8 +939,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("物料编码有误"); } + /**todo:需要最终确认一下。在申请领柜体后,wcs会调度agv将对应库位的柜体运输到柜体拆分区,然后更新rawoutstock的materialbatch为其物料条码*/ String bindBarcode = baseBarcodeInfo.getBindBarcode(); - WmsRawOutstock queryRawOutstock = new WmsRawOutstock(); queryRawOutstock.setMaterialBatch(bindBarcode); List wmsRawOutstocks = wmsRawOutstockMapper.selectWmsRawOutstockList(queryRawOutstock); @@ -947,7 +956,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("没找到库存信息"); } - WmsRawStock wmsRawStock = wmsRawStocks.get(0); //待agv出库后,wcs更新库存信息(需要删除库存,由于是1个) + WmsRawStock wmsRawStock = wmsRawStocks.get(0); //todo:待agv出库后,wcs更新库存信息(需要删除库存,由于是1个) WmsRawOutstock wmsRawOutstock = new WmsRawOutstock(); wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode)); @@ -1118,7 +1127,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { wmsRawOutstock.setApplyDate(currentDate); wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock); - this.insertRawOutstockDetail(wmsRawOutstock, locationCode,materialBarcode, batchCode, + this.insertRawOutstockDetail(wmsRawOutstock, locationCode, materialBarcode, batchCode, userName, currentDate); directOutstockUpdateRawStock(locationCode, materialBarcode, outstockAmount, userName, currentDate); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java index 8de71fa..a276509 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java @@ -102,7 +102,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { @Override public WmsRawReturn selectWmsRawReturnByRawReturnId4Confirm(Long rawReturnId) { //获取退库记录with退库记录明细列表 - WmsRawReturn rawReturn = wmsRawReturnMapper.selectWmsRawReturnByRawReturnId(rawReturnId); + WmsRawReturn rawReturn = wmsRawReturnMapper.selectOnlyWmsRawReturnByRawReturnId(rawReturnId); Long materialId = rawReturn.getMaterialId() == null ? 0L : rawReturn.getMaterialId(); Long productId = rawReturn.getProductId() == null ? 0L : rawReturn.getProductId(); Long[] rawReturnMaterialIds = {materialId, productId}; @@ -133,6 +133,15 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { } + /**由于wmarawreturndetail表弃用,为兼容之前pda设计,暂时使用wmsrawreturndetail返回数据*/ + WmsRawReturnDetail wmsRawReturnDetail = new WmsRawReturnDetail(); + wmsRawReturnDetail.setLocationCode(rawReturn.getLocationCode()); + wmsRawReturnDetail.setMaterialBarcode(rawReturn.getMaterialBarcode()); + wmsRawReturnDetail.setReturnAmount(rawReturn.getReturnAmount()); + List wmsRawReturnDetails = new ArrayList<>(); + wmsRawReturnDetails.add(wmsRawReturnDetail); + rawReturn.setWmsRawReturnDetailList(wmsRawReturnDetails); + return rawReturn; } @@ -248,7 +257,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { throw new ServiceException("请输入审核意见"); } - WmsRawReturn wmsRawReturn = wmsRawReturnMapper.selectWmsRawReturnByRawReturnId(wmsRawReturnAuditVo.getRawReturnId()); + WmsRawReturn wmsRawReturn = wmsRawReturnMapper.selectOnlyWmsRawReturnByRawReturnId(wmsRawReturnAuditVo.getRawReturnId()); wmsRawReturn.setAuditStatus(auditStatus); wmsRawReturn.setAuditReason(auditReason); wmsRawReturn.setAuditBy(SecurityUtils.getUsername()); diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml index ed9f1ba..5605c78 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml @@ -201,21 +201,21 @@ @@ -270,6 +270,49 @@ + + + +