From 21db948cfcbccabe79951407d4d0a90b601ace0d Mon Sep 17 00:00:00 2001 From: xins Date: Mon, 18 Mar 2024 16:56:16 +0800 Subject: [PATCH] =?UTF-8?q?1.8.0=20WMS=EF=BC=9APDA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8E=9F=E6=9D=90=E6=96=99=E9=80=80=E5=BA=93=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E3=80=81PDA=E6=8E=A5=E5=8F=A3=E4=BA=BA=E5=B7=A5=E6=88=90?= =?UTF-8?q?=E5=93=81=E5=87=BA=E5=BA=93=E7=94=B3=E8=AF=B7=E3=80=81PDA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BA=BA=E5=B7=A5=E6=88=90=E5=93=81=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E3=80=81PDA=E6=8E=A5=E5=8F=A3=E5=8D=8A=E6=88=90?= =?UTF-8?q?=E5=93=81=E5=85=A5=E6=88=90=E5=93=81=E5=BA=93=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/mes/api/domain/MesBaseBarcodeInfo.java | 6 +- .../com/hw/common/core/utils/uuid/Seq.java | 13 ++ .../wms/controller/WmsMobileController.java | 14 +- .../com/hw/wms/domain/WmsProductOutstock.java | 12 +- .../wms/domain/WmsProductOutstockDetail.java | 2 +- .../com/hw/wms/domain/WmsProductStock.java | 19 ++ .../vo/WmsProductOutstockConfirmVo.java | 25 +++ .../hw/wms/mapper/WmsProductStockMapper.java | 13 +- .../impl/WmsProductInstockServiceImpl.java | 48 ++--- .../WmsProductOutstockDetailServiceImpl.java | 34 +-- .../impl/WmsProductOutstockServiceImpl.java | 20 +- .../service/impl/WmsRawReturnServiceImpl.java | 81 ++++++-- .../impl/WmsTransactionalServiceImpl.java | 2 +- .../service/impl/WmsTransferServiceImpl.java | 193 ++++++++---------- .../mapper/wms/WmsProductOutstockMapper.xml | 3 +- .../mapper/wms/WmsProductStockMapper.xml | 34 ++- .../mapper/wms/WmsRawReturnMapper.xml | 6 +- 17 files changed, 325 insertions(+), 200 deletions(-) create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockConfirmVo.java diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java index ece11aa..462a3a2 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java @@ -108,7 +108,7 @@ public class MesBaseBarcodeInfo extends BaseEntity /** 销售订单编号;适合生产出入库等 */ @Excel(name = "销售订单ID") - private String saleOrderId; + private Long saleOrderId; /** 销售订单编号;适合生产出入库等 */ @Excel(name = "销售订单编号") @@ -322,11 +322,11 @@ public class MesBaseBarcodeInfo extends BaseEntity return planDetailCode; } - public String getSaleOrderId() { + public Long getSaleOrderId() { return saleOrderId; } - public void setSaleOrderId(String saleOrderId) { + public void setSaleOrderId(Long saleOrderId) { this.saleOrderId = saleOrderId; } 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 49c9092..9f532bc 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 @@ -118,6 +118,17 @@ public class Seq { // 设备报修工单标识 public static final String dmsBillsFaultInstanceSeqCode = "BF"; + + + // 物料转库记录序列类型 + public static final String wmsTransferSeqType = "WMSTRANSFER"; + + // 物料转库记录接口序列数 + private static AtomicInteger wmsTransferSeq = new AtomicInteger(1); + + // 物料转库记录标识 + public static final String wmsTransferSeqCode = "TF"; + /** * 获取通用序列号 * @@ -200,6 +211,8 @@ public class Seq { atomicInt = dmsBillsFaultInstanceSeq; }else if (rawOutstockSeqType.equals(type)) { atomicInt = rawOutstockSeq; + }else if (wmsTransferSeqType.equals(type)) { + atomicInt = wmsTransferSeq; } return getId(atomicInt, 3, code); } 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 a98c22c..44d2241 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 @@ -311,12 +311,12 @@ public class WmsMobileController extends BaseController { */ // @RequiresPermissions("wms:rawoutstock:query") @GetMapping(value = "/getProductStocksBySalesorderCode") - public TableDataInfo getProductStocksBySalesorderCode(WmsProductStockSaleorder queryProductStockSaleorder) { + public TableDataInfo getProductStocksBySalesorderCode(WmsProductStock queryProductStock) { startPage(); // WmsProductStock queryProductStock = new WmsProductStock(); // queryProductStock.setSaleorderCode(request.getParameter("salesorderCode")); // queryProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - List list = wmsProductStockSaleorderService.selectWmsProductStockSaleordersBySaleorder(queryProductStockSaleorder); + List list = wmsProductStockService.selectWmsProductStocksBySaleorder(queryProductStock); return getDataTable(list); } @@ -373,6 +373,16 @@ public class WmsMobileController extends BaseController { } + /** + * 人工成品出库最终确认(适用于成品出库后,运输到指定地点,根据销售订单最终确认) + */ + @Log(title = "成品出库确认", businessType = BusinessType.UPDATE) + @PostMapping(("/finalConfirmProductOutstock")) + public AjaxResult finalConfirmProductOutstock(@RequestBody WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo) { + return toAjax(1); + } + + /** * 组装出库,适合在五楼背板安装区(将拆分的柜体再运输出来进行组装) */ diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstock.java index 39952e4..b6ce0dc 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstock.java @@ -71,6 +71,7 @@ public class WmsProductOutstock extends BaseEntity { @Excel(name = "计划明细编号,关联pd_base_plan_detail的plan_detail_code") private String planDetailCode; + private Long saleOrderId; private String saleorderCode; private String projectNo; @@ -166,6 +167,7 @@ public class WmsProductOutstock extends BaseEntity { + /** * 成品出库记录明细信息 */ @@ -243,6 +245,14 @@ public class WmsProductOutstock extends BaseEntity { this.planDetailCode = planDetailCode; } + public Long getSaleOrderId() { + return saleOrderId; + } + + public void setSaleOrderId(Long saleOrderId) { + this.saleOrderId = saleOrderId; + } + public String getSaleorderCode() { return saleorderCode; } @@ -403,8 +413,6 @@ public class WmsProductOutstock extends BaseEntity { this.materialName = materialName; } - - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstockDetail.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstockDetail.java index 3735878..e42878e 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstockDetail.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductOutstockDetail.java @@ -58,7 +58,7 @@ public class WmsProductOutstockDetail extends BaseEntity private BigDecimal confirmAmount; /** 执行状态(0待执行,1执行中,2执行完成) */ - @Excel(name = "执行状态(0待执行,1执行中,2执行完成)") + @Excel(name = "执行状态(0待执行,1执行中,2执行完成,3已确认)") private String executeStatus; /** 同步ERP状态(0:失败,1成功) */ diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductStock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductStock.java index a97dd22..ea1197d 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductStock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsProductStock.java @@ -61,6 +61,7 @@ public class WmsProductStock extends BaseEntity @Excel(name = "计划明细编号,关联pd_base_plan_detail的plan_detail_code") private String planDetailCode; + private Long saleOrderId; /** * 销售订单编号 */ @@ -103,6 +104,8 @@ public class WmsProductStock extends BaseEntity private String warehouseName; + private BigDecimal applyAmount; + public void setProductStockId(Long productStockId) { @@ -193,6 +196,14 @@ public class WmsProductStock extends BaseEntity this.planDetailCode = planDetailCode; } + public Long getSaleOrderId() { + return saleOrderId; + } + + public void setSaleOrderId(Long saleOrderId) { + this.saleOrderId = saleOrderId; + } + public String getSaleorderCode() { return saleorderCode; } @@ -297,6 +308,14 @@ public class WmsProductStock extends BaseEntity this.warehouseName = warehouseName; } + public BigDecimal getApplyAmount() { + return applyAmount; + } + + public void setApplyAmount(BigDecimal applyAmount) { + this.applyAmount = applyAmount; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockConfirmVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockConfirmVo.java new file mode 100644 index 0000000..b5fe5a7 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockConfirmVo.java @@ -0,0 +1,25 @@ +package com.hw.wms.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description: 适合成品出库后,运输到指定地点最终确认的VO对象 + * @ClassName: WmsProductOutstockConfirmVo + * @Author : xins + * @Date :2024-03-18 15:21 + * @Version :1.0 + */ +@Data +public class WmsProductOutstockConfirmVo { + + //成品条码 + @NotBlank(message="成品条码必须输入") + private String materialBarcode; + + @NotBlank(message="销售订单号码必须输入") + private String saleorderCode; + + +} 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 140ecd5..797db83 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 @@ -69,15 +69,24 @@ public interface WmsProductStockMapper */ public BigDecimal getProductStockTotalAmount(WmsProductStock wmsProductStock); + /** * 根据库位编码和入库批次号查询成品库存 + * @param productBatch + * @return WmsRawStock + */ + public WmsProductStock selectProductStockByBatch(@Param("productBatch") String productBatch); + + /** + * 根据库位编码、入库批次号和销售订单ID查询成品库存 * @param locationCode * @param productBatch * @param stockType + * @param saleOrderId * @return WmsRawStock */ - public WmsProductStock selectProductStockByLocationAndBatch(@Param("locationCode") String locationCode, - @Param("productBatch") String productBatch,@Param("stockType") String stockType); + public WmsProductStock selectProductStockByLocationAndBatchAndSaleOrderId(@Param("locationCode") String locationCode,@Param("productBatch") String productBatch, + @Param("saleOrderId") Long saleOrderId,@Param("stockType") String stockType); /** 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 cbac118..4b30f86 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 @@ -167,7 +167,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { if (baseBarcodeInfo == null) { throw new ServiceException("物料编码有误"); } - Long productId =baseBarcodeInfo.getMaterialId(); + Long productId = baseBarcodeInfo.getMaterialId(); String locationCode = wmsProductInstockVo.getLocationCode(); WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); @@ -251,47 +251,39 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { throw new ServiceException("已超出库位数量限制,请重新选择库位"); } - //如果是同一库位入同一批次,则更新数量 - WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - if (wmsProductStock != null) { + //一个成品一个条码,对应一条库存信息 + WmsProductStock wmsProductStock = new WmsProductStock(); + wmsProductStock.setWarehouseId(wmsProductInstock.getWarehouseId()); + wmsProductStock.setLocationCode(locationCode); + wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); + wmsProductStock.setProductId(productId); + wmsProductStock.setProductBatch(productBatch); + wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode()); + wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode()); + wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor()); + wmsProductStock.setSaleorderCode(baseBarcodeInfo.getSaleorderCode()); // wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus()); - wmsProductStock.setTotalAmount(wmsProductStock.getTotalAmount().add(instockAmount)); - wmsProductStock.setUpdateBy(userName); - wmsProductStock.setUpdateDate(currentDate); - wmsProductStockMapper.updateWmsProductStock(wmsProductStock); - } else { - wmsProductStock = new WmsProductStock(); - wmsProductStock.setWarehouseId(wmsProductInstock.getWarehouseId()); - wmsProductStock.setLocationCode(locationCode); - wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - wmsProductStock.setProductId(productId); - wmsProductStock.setProductBatch(productBatch); - wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode()); - wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode()); - wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor()); - wmsProductStock.setSaleorderCode(baseBarcodeInfo.getSaleorderCode()); -// wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus()); - wmsProductStock.setTotalAmount(instockAmount); - wmsProductStock.setCreateBy(userName); - wmsProductStock.setCreateDate(currentDate); - wmsProductStock.setInstockDate(currentDate); - wmsProductStockMapper.insertWmsProductStock(wmsProductStock); - } + wmsProductStock.setTotalAmount(instockAmount); + wmsProductStock.setCreateBy(userName); + wmsProductStock.setCreateDate(currentDate); + wmsProductStock.setInstockDate(currentDate); + wmsProductStockMapper.insertWmsProductStock(wmsProductStock); + } /** * 生产入库,适合在五楼背板安装区(将组装好的柜体入到半成品库) + * * @param wmsProduceInstockVo * @return */ @Override - public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo){ + public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo) { return 1; } - public void syncToErp() { //todo 根据质检状态是通过的同步给ERP } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java index f8e39be..0ab3b10 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java @@ -4,9 +4,13 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; +import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.WmsConstants; +import com.hw.common.core.domain.R; import com.hw.common.core.exception.ServiceException; import com.hw.common.security.utils.SecurityUtils; +import com.hw.mes.api.RemoteMesService; +import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.wms.domain.WmsBaseLocation; import com.hw.wms.domain.WmsProductOutstock; import com.hw.wms.domain.WmsProductStock; @@ -20,6 +24,8 @@ import com.hw.wms.domain.WmsProductOutstockDetail; import com.hw.wms.service.IWmsProductOutstockDetailService; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; + /** * 成品出库记录明细Service业务层处理 * @@ -74,8 +80,7 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD @Transactional(rollbackFor = Exception.class) public int insertWmsProductOutstockDetail(WmsProductOutstockDetail wmsProductOutstockDetail) { String locationCode = wmsProductOutstockDetail.getLocationCode(); - String productBarcode = wmsProductOutstockDetail.getProductBarcode(); - String productBatch = wmsProductOutstockDetail.getProductBatch(); + String productBarcode = wmsProductOutstockDetail.getProductBarcode();//成品条码和批次码相同 Long productOutstockId = wmsProductOutstockDetail.getProductOutstockId(); WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); @@ -96,10 +101,12 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD throw new ServiceException("此出库申请已完成,不能再出库"); } - WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch, WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); + WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatchAndSaleOrderId(locationCode, + productBarcode, productOutstock.getSaleOrderId(), WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); if (productStock == null) { - throw new ServiceException("此库位没有库存"); + throw new ServiceException("此库位没有对应订单库存"); } + BigDecimal totalAmount = productStock.getTotalAmount(); BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount(); BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount(); @@ -109,6 +116,8 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD throw new ServiceException("此库位没有可出库存"); } + + /**判断已出库数量和申请的数量*/ BigDecimal applyQty = productOutstock.getApplyQty() == null ? BigDecimal.ZERO : productOutstock.getApplyQty(); BigDecimal outstockQty = productOutstock.getOutstockQty() == null ? BigDecimal.ZERO : productOutstock.getOutstockQty(); @@ -128,18 +137,19 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD } productOutstock.setOutstockQty(currentOutstockQty); - if(productOutstock.getBeginTime()==null) { - productOutstock.setBeginTime(currentDate); + if (productOutstock.getBeginTime() == null) { + productOutstock.setBeginTime(currentDate); } productOutstock.setUpdateDate(currentDate); productOutstock.setUpdateBy(userName); wmsProductOutstockMapper.updateWmsProductOutstock(productOutstock); - //更新库存 - productStock.setTotalAmount(totalAmount.subtract(BigDecimal.ONE)); - productStock.setUpdateBy(userName); - productStock.setUpdateDate(currentDate); - wmsProductStockMapper.updateWmsProductStock(productStock); + //删除库存(由于一个成品对应一个库存信息,删除即可) +// productStock.setTotalAmount(totalAmount.subtract(BigDecimal.ONE)); +// productStock.setUpdateBy(userName); +// productStock.setUpdateDate(currentDate); +// wmsProductStockMapper.updateWmsProductStock(productStock); + wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId()); //插入出库记录明细 wmsProductOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); @@ -151,8 +161,6 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD wmsProductOutstockDetailMapper.insertWmsProductOutstockDetail(wmsProductOutstockDetail); - //todo:同步erp - return 1; } 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 c87edb1..ac92914 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,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService queryProductStock.setWarehouseId(warehouseId); queryProductStock.setSaleorderCode(saleorderCode); queryProductStock.setProductId(productId); + queryProductStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId()); List productStocks = wmsProductStockMapper.selectWmsProductStocksBySaleorder(queryProductStock); if (productStocks == null || productStocks.isEmpty()) { throw new ServiceException("没有库存"); @@ -89,15 +90,18 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService BigDecimal orderAmount = productStock.getOrderAmount(); /*获取仓库可用库存数量*/ BigDecimal totalAmount = productStock.getTotalAmount() == null ? BigDecimal.ZERO : productStock.getTotalAmount(); - BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount(); - BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount(); + BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用 + BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();// BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount); + BigDecimal sumApplyQty = productStock.getApplyAmount();//获取已申请出库数量 - /*获取已申请出库数量*/ - WmsProductOutstock queryProductOutStock = new WmsProductOutstock(); - queryProductOutStock.setSaleorderCode(saleorderCode); - List wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock); - BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add); +// WmsProductOutstock queryProductOutStock = new WmsProductOutstock(); +// queryProductOutStock.setSaleorderCode(saleorderCode); +// queryProductOutStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId()); +// queryProductOutStock.setWarehouseId(warehouseId); +// queryProductOutStock.setProductId(productId); +// List wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock); +// BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add); //可申请数量 BigDecimal availableApplyQty = availableAmount.subtract(sumApplyQty); @@ -123,7 +127,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService int rows = wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock); - //todo:如果是agv自动仓库,需要调用WCS进行调度出库 + //如果是agv自动仓库,需要调用WCS轮询查询成品出库记录进行调度出库 return rows; } 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 35dbe3f..e09c480 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 @@ -3,6 +3,7 @@ package com.hw.wms.service.impl; import java.math.BigDecimal; import java.util.*; +import com.hw.common.core.constant.MesConstants; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.domain.R; @@ -18,8 +19,7 @@ import com.hw.wms.domain.vo.WmsRawOutstockAuditVo; import com.hw.wms.domain.vo.WmsRawOutstockConfirmVo; import com.hw.wms.domain.vo.WmsRawReturnAuditVo; import com.hw.wms.domain.vo.WmsRawReturnConfirmVo; -import com.hw.wms.mapper.WmsRawReturnDetailMapper; -import com.hw.wms.mapper.WmsRawStockMapper; +import com.hw.wms.mapper.*; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,7 +28,6 @@ import java.util.stream.Collectors; import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.hw.wms.mapper.WmsRawReturnMapper; import com.hw.wms.service.IWmsRawReturnService; import javax.annotation.Resource; @@ -47,6 +46,12 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { @Autowired private WmsRawReturnDetailMapper wmsRawReturnDetailMapper; + @Autowired + private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; + + @Autowired + private WmsBaseLocationMapper wmsBaseLocationMapper; + @Autowired private WmsRawStockMapper wmsRawStockMapper; @@ -102,9 +107,9 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { Long productId = rawReturn.getProductId() == null ? 0L : rawReturn.getProductId(); Long[] rawReturnMaterialIds = {materialId, productId}; - List wmsRawReturnDetailList = rawReturn.getWmsRawReturnDetailList(); - Long[] rawReturnDetailMaterialIds = wmsRawReturnDetailList.stream().map(o -> o.getMaterialId()).toArray(Long[]::new); - Long[] materialIds = ArrayUtils.addAll(rawReturnMaterialIds, rawReturnDetailMaterialIds); +// List wmsRawReturnDetailList = rawReturn.getWmsRawReturnDetailList(); +// Long[] rawReturnDetailMaterialIds = wmsRawReturnDetailList.stream().map(o -> o.getMaterialId()).toArray(Long[]::new); + Long[] materialIds = ArrayUtils.addAll(rawReturnMaterialIds); if (materialIds.length > 0) { MesBaseMaterialInfoVo mesBaseMaterialInfoVo = new MesBaseMaterialInfoVo(); @@ -117,20 +122,13 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { .collect(Collectors.toMap(MesBaseMaterialInfo::getMaterialId, mesBaseMaterialInfo -> mesBaseMaterialInfo)); MesBaseMaterialInfo materialInfo = mesBaseMaterialInfoMap.get(materialId); if (materialInfo != null) { - rawReturn.setMaterialName(materialInfo.getMaterialName()); + rawReturn.setMaterialName(materialInfo.getMaterialName());//物料名称 } MesBaseMaterialInfo productInfo = mesBaseMaterialInfoMap.get(productId); if (productInfo != null) { - rawReturn.setProductName(productInfo.getMaterialName()); + rawReturn.setProductName(productInfo.getMaterialName());//成品名称 } - wmsRawReturnDetailList.forEach(wmsRawReturnDetail -> { - MesBaseMaterialInfo detailMaterialInfo = mesBaseMaterialInfoMap.get(wmsRawReturnDetail.getMaterialId()); - if (materialInfo != null) { - wmsRawReturnDetail.setMaterialCode(detailMaterialInfo.getMaterialCode()); - wmsRawReturnDetail.setMaterialName(detailMaterialInfo.getMaterialName()); - } - }); } } @@ -270,6 +268,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { Long rawReturnId = wmsRawReturnConfirmVo.getRawReturnId(); String materialBarcode = wmsRawReturnConfirmVo.getMaterialBarcode(); BigDecimal returnAmount = wmsRawReturnConfirmVo.getReturnAmount(); + String locationCode = wmsRawReturnConfirmVo.getLocationCode(); //todo: 判断质检状态,超出库位数量限制,超期判断 // if (wmsRawReturnDetail.getQualityStatus() != null @@ -277,6 +276,10 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { // throw new ServiceException("质检通过才能出库"); // } + if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) { + throw new ServiceException("输入数量大于0"); + } + R mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); if (mesBaseBarcodeInfoR == null) { throw new ServiceException("物料编码错误"); @@ -290,6 +293,27 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { throw new ServiceException("审核未通过,不能出库"); } + String batchFlag = mesBaseBarcodeInfo.getBatchFlag(); + + if (!batchFlag.equals(MesConstants.IS_BATCH)) { + if (returnAmount.compareTo(BigDecimal.ONE) != 0) { + throw new ServiceException("输入数量需为1"); + } + } + + if(!wmsRawReturn.getMaterialId().equals(mesBaseBarcodeInfo.getMaterialId())){ + throw new ServiceException("物料编码错误"); + } + + WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); + if(baseLocation == null){ + throw new ServiceException("库位编码有误"); + } + + if(!baseLocation.getWarehouseId().equals(wmsRawReturn.getWarehouseId())){ + throw new ServiceException("退库仓库有误"); + } + // 判断本次退库数量+已退库数量是否大于计划退库数量 BigDecimal planAmount = wmsRawReturn.getPlanAmount(); BigDecimal hadReturnAmount = wmsRawReturn.getReturnAmount() == null ? BigDecimal.ZERO : wmsRawReturn.getReturnAmount(); @@ -299,7 +323,6 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { throw new ServiceException("退库数量不能大于" + planAmount); } - String executeStatus = ""; if (updatedReturnAmount.compareTo(planAmount) == 0) { executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH; @@ -321,9 +344,8 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { mesBaseBarcodeInfo, userName, currentDate); //更新原材料库存 - this.updateRawStock(wmsRawReturnConfirmVo, mesBaseBarcodeInfo, userName, currentDate); + this.updateRawStock(wmsRawReturnConfirmVo, mesBaseBarcodeInfo, baseLocation,userName, currentDate); - //todo 同步erp return 1; } @@ -347,13 +369,30 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { } - private void updateRawStock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo, MesBaseBarcodeInfo mesBaseBarcodeInfo, String userName, Date currentDate) { + private void updateRawStock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo, MesBaseBarcodeInfo mesBaseBarcodeInfo, WmsBaseLocation baseLocation, + String userName, Date currentDate) { String locationCode = wmsRawReturnConfirmVo.getLocationCode(); String instockBatch = mesBaseBarcodeInfo.getBatchCode(); WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch); if (wmsRawStock == null) { - throw new ServiceException("数据异常"); + WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(baseLocation.getWarehouseId()); + wmsRawStock = new WmsRawStock(); + wmsRawStock.setWarehouseId(warehouse.getWarehouseId()); + wmsRawStock.setWarehouseFloor(warehouse.getWarehouseFloor()); + wmsRawStock.setLocationCode(locationCode); + wmsRawStock.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW); + wmsRawStock.setMaterialId(mesBaseBarcodeInfo.getMaterialId()); + wmsRawStock.setInstockBatch(mesBaseBarcodeInfo.getBatchCode()); + wmsRawStock.setInstockDate(mesBaseBarcodeInfo.getAcceptedDate()); + wmsRawStock.setLastOutstockTime(mesBaseBarcodeInfo.getLastOutstockDate()); +// wmsRawStock.setQualityStatus();//TODO:质检状态 + wmsRawStock.setCompleteFlag(WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAG_YES); + wmsRawStock.setTotalAmount(wmsRawReturnConfirmVo.getReturnAmount()); + wmsRawStock.setCreateBy(userName); + wmsRawStock.setCreateDate(currentDate); + wmsRawStockMapper.insertWmsRawStock(wmsRawStock); + } else { BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount(); BigDecimal updatedTotalAmount = totalAmount.add(wmsRawReturnConfirmVo.getReturnAmount()); @@ -430,7 +469,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { toUpdatedWmsRawReturn.setPlanCode(wmsRawReturn.getPlanCode()); toUpdatedWmsRawReturn.setPlanDetailCode(wmsRawReturn.getPlanDetailCode()); toUpdatedWmsRawReturn.setTaskType(wmsRawReturn.getTaskType()); - toUpdatedWmsRawReturn.setTaskCode(Seq.getId(Seq.rawReturnSeqType,Seq.rawReturnCode)); + toUpdatedWmsRawReturn.setTaskCode(Seq.getId(Seq.rawReturnSeqType, Seq.rawReturnCode)); // toUpdatedWmsRawReturn.setProductId(); toUpdatedWmsRawReturn.setApplyReason(wmsRawReturn.getApplyReason()); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransactionalServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransactionalServiceImpl.java index a05bdcd..24f6579 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransactionalServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransactionalServiceImpl.java @@ -43,7 +43,7 @@ public class WmsTransactionalServiceImpl implements IWmsTransactionalService { BigDecimal applyQty = wmsTransfer.getApplyQty(); String productBatch = wmsTransfer.getProductBatch(); String oriLocationCode = wmsTransfer.getOriLocationCode(); - WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(oriLocationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI); + WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByBatch(productBatch); if (wmsProductStock == null) { throw new ServiceException("库位["+oriLocationCode+"]没有此批次["+productBatch+"]的库存"); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransferServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransferServiceImpl.java index 407fb7d..aff1c9b 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransferServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsTransferServiceImpl.java @@ -8,14 +8,12 @@ import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.domain.R; 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.mes.api.RemoteMesService; import com.hw.mes.api.domain.MesBaseBarcodeInfo; -import com.hw.wms.domain.WmsBaseLocation; -import com.hw.wms.domain.WmsProductStock; -import com.hw.wms.mapper.WmsBaseLocationMapper; -import com.hw.wms.mapper.WmsProductStockMapper; -import com.hw.wms.mapper.WmsTransferDetailMapper; +import com.hw.wms.domain.*; +import com.hw.wms.mapper.*; import com.hw.wms.service.IWmsTransactionalService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,9 +22,6 @@ import java.util.ArrayList; import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.hw.wms.domain.WmsTransferDetail; -import com.hw.wms.mapper.WmsTransferMapper; -import com.hw.wms.domain.WmsTransfer; import com.hw.wms.service.IWmsTransferService; import javax.annotation.Resource; @@ -54,6 +49,9 @@ public class WmsTransferServiceImpl implements IWmsTransferService { @Autowired private IWmsTransactionalService wmsTransactionalService; + @Autowired + private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; + @Resource private RemoteMesService remoteMesService; @@ -196,7 +194,8 @@ public class WmsTransferServiceImpl implements IWmsTransferService { public int transferOutstock(WmsTransferDetail wmsTransferDetail) { String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); - String locationCode = wmsTransferDetail.getLocationCode(); + String oriLocationCode = wmsTransferDetail.getLocationCode(); + String materialBarcode = wmsTransferDetail.getMaterialBarcode(); R mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); @@ -208,39 +207,40 @@ public class WmsTransferServiceImpl implements IWmsTransferService { throw new ServiceException("物料编码错误"); } - String productBatch = mesBaseBarcodeInfo.getBatchCode(); - - Long transferId = wmsTransferDetail.getTransferId(); - WmsTransfer wmsTransfer; - - if (transferId == null) { - WmsTransfer queryTransfer = new WmsTransfer(); - queryTransfer.setOriLocationCode(locationCode); - queryTransfer.setProductBatch(productBatch); - queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); - List wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer); - if (wmsTransfers == null || wmsTransfers.isEmpty()) { - throw new ServiceException("没有此任务"); - } - if (wmsTransfers.size() > 1) { - throw new ServiceException("有多条此库位任务,请选择具体任务后点击出库"); - } - wmsTransfer = wmsTransfers.get(0); - } else { - wmsTransfer = wmsTransferMapper.selectWmsTransferByTransferId(transferId); + WmsTransfer queryTransfer = new WmsTransfer(); + queryTransfer.setOriLocationCode(oriLocationCode); + queryTransfer.setProductBatch(materialBarcode); + queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); + List wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer); + if (wmsTransfers != null && !wmsTransfers.isEmpty()) { + throw new ServiceException("有此库位出库任务,请不要重复出库"); } - BigDecimal applyQty = wmsTransfer.getApplyQty(); - BigDecimal outstockQty = wmsTransfer.getOutstockQty() == null ? BigDecimal.ZERO : wmsTransfer.getOutstockQty(); - BigDecimal currentOutstockQty = outstockQty.add(BigDecimal.ONE); - if (applyQty.compareTo(currentOutstockQty) < 0) { - throw new ServiceException("已出库完成,不能多次出库"); + WmsBaseLocation oriLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(oriLocationCode); + if (oriLocation == null) { + throw new ServiceException("库位不存在"); } + WmsTransfer wmsTransfer = new WmsTransfer(); + wmsTransfer.setTaskCode(Seq.getId(Seq.wmsTransferSeqType, Seq.wmsTransferSeqCode)); + wmsTransfer.setOriWarehouseId(oriLocation.getWarehouseId()); + wmsTransfer.setOriLocationCode(oriLocationCode); + wmsTransfer.setMaterialId(mesBaseBarcodeInfo.getMaterialId()); + wmsTransfer.setProductBatch(materialBarcode); + wmsTransfer.setApplyQty(BigDecimal.ONE); + wmsTransfer.setOutstockQty(BigDecimal.ONE); + wmsTransfer.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); + wmsTransfer.setTransferType(WmsConstants.WMS_TRANSFER_TYPE_OUT_TO_PRODUCT_STOCK); + wmsTransfer.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); + wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); + wmsTransfer.setApplyBy(userName); + wmsTransfer.setApplyDate(currentDate); + wmsTransfer.setBeginTime(currentDate); + + wmsTransferMapper.insertWmsTransfer(wmsTransfer); //插入转库任务明细 wmsTransferDetail.setTransferId(wmsTransfer.getTransferId()); - wmsTransferDetail.setInstockBatch(productBatch); wmsTransferDetail.setMaterialId(mesBaseBarcodeInfo.getMaterialId()); wmsTransferDetail.setRealAmount(BigDecimal.ONE); wmsTransferDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); @@ -251,20 +251,10 @@ public class WmsTransferServiceImpl implements IWmsTransferService { wmsTransferDetail.setExecuteTime(currentDate); wmsTransferDetailMapper.insertWmsTransferDetail(wmsTransferDetail); - //更新转库任务 - wmsTransfer.setOutstockQty(currentOutstockQty); - wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); - wmsTransfer.setUpdateDate(currentDate); - wmsTransfer.setUpdateBy(userName); - wmsTransferMapper.updateWmsTransfer(wmsTransfer); - //更新成品库存 - WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI); - productStock.setTotalAmount(productStock.getTotalAmount().subtract(BigDecimal.ONE)); - productStock.setOccupyAmount(productStock.getOccupyAmount().subtract(BigDecimal.ONE)); - productStock.setUpdateDate(currentDate); - productStock.setUpdateBy(userName); - wmsProductStockMapper.updateWmsProductStock(productStock); + //删除成品库存 + WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode); + wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId()); return 1; } @@ -280,7 +270,7 @@ public class WmsTransferServiceImpl implements IWmsTransferService { public int transferInstock(WmsTransferDetail wmsTransferDetail) { String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); - String locationCode = wmsTransferDetail.getLocationCode(); + String targetLocationCode = wmsTransferDetail.getLocationCode(); String materialBarcode = wmsTransferDetail.getMaterialBarcode(); R mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); @@ -291,43 +281,39 @@ public class WmsTransferServiceImpl implements IWmsTransferService { if (mesBaseBarcodeInfo == null) { throw new ServiceException("物料编码错误"); } - String productBatch = mesBaseBarcodeInfo.getBatchCode(); - - WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); - Long warehouseId = location.getWarehouseId(); - - Long transferId = wmsTransferDetail.getTransferId(); - WmsTransfer wmsTransfer; - if (transferId == null) { - WmsTransfer queryTransfer = new WmsTransfer(); - queryTransfer.setTargetWarehouseId(warehouseId); - queryTransfer.setProductBatch(productBatch); - queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); - List wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer); - if (wmsTransfers == null || wmsTransfers.isEmpty()) { - throw new ServiceException("没有此任务或者还未出库"); - } - if (wmsTransfers.size() > 1) { - throw new ServiceException("有多条此库位任务,请选择具体任务后点击出库"); - } - wmsTransfer = wmsTransfers.get(0); - } else { - wmsTransfer = wmsTransferMapper.selectWmsTransferByTransferId(transferId); + WmsBaseLocation targetLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(targetLocationCode); + if (targetLocation == null) { + throw new ServiceException("库位不存在"); } - BigDecimal applyQty = wmsTransfer.getApplyQty(); - BigDecimal outstockQty = wmsTransfer.getOutstockQty() == null ? BigDecimal.ZERO : wmsTransfer.getOutstockQty(); - BigDecimal instockQty = wmsTransfer.getInstockQty(); - BigDecimal currentInstockQty = instockQty.add(BigDecimal.ONE); - if (outstockQty.compareTo(currentInstockQty) < 0) { - throw new ServiceException("请先出库再入库"); + /**判断有没有已出库的转库记录*/ + WmsTransfer queryTransfer = new WmsTransfer(); + queryTransfer.setProductBatch(materialBarcode); + queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); + List wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer); + if(wmsTransfers==null || wmsTransfers.isEmpty()){ + throw new ServiceException("没有此成品的转库出库记录,不能转库入库"); } + Long targetWarehouseId = targetLocation.getWarehouseId(); + WmsBaseWarehouse targetWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(targetWarehouseId); + + WmsTransfer wmsTransfer = wmsTransfers.get(0); + wmsTransfer.setTargetWarehouseId(targetWarehouseId); + wmsTransfer.setTargetLocationCode(targetLocationCode); + wmsTransfer.setInstockQty(BigDecimal.ONE); + wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); + wmsTransfer.setUpdateBy(userName); + wmsTransfer.setUpdateDate(currentDate); + wmsTransfer.setEndTime(currentDate); + wmsTransferMapper.updateWmsTransfer(wmsTransfer); + + //插入转库任务明细 wmsTransferDetail.setTransferId(wmsTransfer.getTransferId()); - wmsTransferDetail.setInstockBatch(productBatch); + wmsTransferDetail.setInstockBatch(materialBarcode); wmsTransferDetail.setMaterialId(mesBaseBarcodeInfo.getMaterialId()); wmsTransferDetail.setRealAmount(BigDecimal.ONE); wmsTransferDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); @@ -338,42 +324,25 @@ public class WmsTransferServiceImpl implements IWmsTransferService { wmsTransferDetail.setExecuteTime(currentDate); wmsTransferDetailMapper.insertWmsTransferDetail(wmsTransferDetail); - //更新转库任务 - wmsTransfer.setInstockQty(currentInstockQty); - if (applyQty.compareTo(currentInstockQty) == 0) {//出库和入库都已完成 - wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); - } - - wmsTransfer.setUpdateDate(currentDate); - wmsTransfer.setUpdateBy(userName); - wmsTransferMapper.updateWmsTransfer(wmsTransfer); - - //更新成品库存 - WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - if (productStock == null) { - productStock = new WmsProductStock(); - productStock.setTotalAmount(BigDecimal.ONE); - productStock.setWarehouseId(warehouseId); - productStock.setLocationCode(locationCode); - productStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - productStock.setProductBatch(productBatch); - // productStock.setQualityStatus();//todo: 获取质检状态 - productStock.setProductId(mesBaseBarcodeInfo.getMaterialId()); - productStock.setPlanCode(mesBaseBarcodeInfo.getPlanCode()); - productStock.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode()); - productStock.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode()); - productStock.setCreateDate(currentDate); - productStock.setCreateBy(userName); - wmsProductStockMapper.insertWmsProductStock(productStock); - } else { - productStock.setTotalAmount(productStock.getTotalAmount().add(BigDecimal.ONE)); - productStock.setUpdateDate(currentDate); - productStock.setUpdateBy(userName); - wmsProductStockMapper.updateWmsProductStock(productStock); - } + //更新成品库存,一个成品一个条码,对应一条库存记录 + WmsProductStock productStock = new WmsProductStock(); + productStock.setTotalAmount(BigDecimal.ONE); + productStock.setWarehouseId(targetWarehouseId); + productStock.setLocationCode(targetLocationCode); + productStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); + productStock.setProductBatch(materialBarcode); + // productStock.setQualityStatus();//todo: 获取质检状态 + productStock.setWarehouseFloor(targetWarehouse.getWarehouseFloor()); + productStock.setProductId(mesBaseBarcodeInfo.getMaterialId()); + productStock.setPlanCode(mesBaseBarcodeInfo.getPlanCode()); + productStock.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode()); + productStock.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); + productStock.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode()); + productStock.setCreateDate(currentDate); + productStock.setCreateBy(userName); + wmsProductStockMapper.insertWmsProductStock(productStock); - //TODO:同步ERP库存 return 1; } diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml index 26c16fe..209f214 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml @@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -259,7 +260,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 9072096..73491ec 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 @@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -160,9 +162,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - where location_code = #{locationCode} and product_batch = #{productBatch} and stock_type = #{stockType} + where product_batch = #{productBatch} limit 1 + + + @@ -218,6 +225,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnMapper.xml index 83cbe77..7570b9f 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnMapper.xml @@ -90,8 +90,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"