From fb8b55a4c6092352a8eecfe79469c74385cfb15a Mon Sep 17 00:00:00 2001 From: xs Date: Tue, 29 Oct 2024 18:57:54 +0800 Subject: [PATCH] =?UTF-8?q?3.3.7=20MES:=20RFID=E6=89=8B=E6=8C=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=8E=9F=E6=9D=90=E6=96=99=E6=9D=A1=E7=A0=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BB=93=E5=BA=93=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E6=A0=A1=E9=AA=8C=20WMS=EF=BC=9A=20=E5=8E=9F=E6=9D=90?= =?UTF-8?q?=E6=96=99=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=E5=92=8C=E5=8E=9F?= =?UTF-8?q?=E6=9D=90=E6=96=99=E5=87=BA=E5=BA=93=E8=AE=B0=E5=BD=95=E5=AE=8C?= =?UTF-8?q?=E5=96=84=20PDA=E6=8E=A5=E5=8F=A3=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hw/wms/api/RemoteWmsService.java | 6 +- .../vo/WmsWarehouseMaterialExistVo.java | 11 +++ .../api/factory/RemoteWmsFallbackFactory.java | 6 ++ .../hw/common/core/constant/WmsConstants.java | 1 + .../mes/controller/MesMobileController.java | 14 +++ .../impl/MesBasePalletInfoServiceImpl.java | 13 ++- .../WmsBaseWarehouseController.java | 11 ++- .../wms/controller/WmsMobileController.java | 63 ++++++++++-- .../java/com/hw/wms/domain/WmsRawInstock.java | 2 +- .../com/hw/wms/domain/WmsRawOutstock.java | 2 +- .../domain/vo/WmsLocationLockUnLockVo.java | 21 ++++ .../hw/wms/domain/vo/WmsReturnOutstockVo.java | 28 ++++++ .../wms/service/IWmsBaseLocationService.java | 23 +++++ .../wms/service/IWmsRawOutstockService.java | 7 ++ .../impl/WmsBaseLocationServiceImpl.java | 63 +++++++++++- .../impl/WmsRawOutstockServiceImpl.java | 96 ++++++++++++++++++- .../mapper/wms/WmsRawInstockMapper.xml | 1 + .../mapper/wms/WmsRawOutstockMapper.xml | 1 + 18 files changed, 347 insertions(+), 22 deletions(-) create mode 100644 hw-api/hw-api-wms/src/main/java/com/hw/wms/api/domain/vo/WmsWarehouseMaterialExistVo.java create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsLocationLockUnLockVo.java create mode 100644 hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsReturnOutstockVo.java diff --git a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java index b5658d6..9f89ccf 100644 --- a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java +++ b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java @@ -8,6 +8,7 @@ import com.hw.wms.api.domain.WmsWarehouseMaterial; import com.hw.wms.api.domain.vo.WmsAutoOutstockVo; import com.hw.wms.api.domain.vo.WmsProductStockVo; import com.hw.wms.api.domain.vo.WmsRawStockVo; +import com.hw.wms.api.domain.vo.WmsWarehouseMaterialExistVo; import com.hw.wms.api.factory.RemoteWmsFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.validation.annotation.Validated; @@ -15,7 +16,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; @FeignClient(contextId = "remoteWmsService", value = ServiceNameConstants.WMS_SERVICE, fallbackFactory = RemoteWmsFallbackFactory.class) @@ -75,4 +75,8 @@ public interface RemoteWmsService { @PostMapping("/rawstock/autoOutstock") public R autoOutstock(@Validated @RequestBody WmsAutoOutstockVo wmsAutoOutstockVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/wmswarehouse/isExistWarehouseMaterial") + public R isExistWarehouseMaterial(@Validated @RequestBody WmsWarehouseMaterial wmsWarehouseMaterial, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/domain/vo/WmsWarehouseMaterialExistVo.java b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/domain/vo/WmsWarehouseMaterialExistVo.java new file mode 100644 index 0000000..a28337d --- /dev/null +++ b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/domain/vo/WmsWarehouseMaterialExistVo.java @@ -0,0 +1,11 @@ +package com.hw.wms.api.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +@Data +public class WmsWarehouseMaterialExistVo { + @NotEmpty(message="物料ID不能为空") + private Long materialId; +} diff --git a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java index 2fb467e..0befa0a 100644 --- a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java +++ b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java @@ -7,6 +7,7 @@ import com.hw.wms.api.domain.WmsWarehouseMaterial; import com.hw.wms.api.domain.vo.WmsAutoOutstockVo; import com.hw.wms.api.domain.vo.WmsProductStockVo; import com.hw.wms.api.domain.vo.WmsRawStockVo; +import com.hw.wms.api.domain.vo.WmsWarehouseMaterialExistVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; @@ -71,6 +72,11 @@ public class RemoteWmsFallbackFactory implements FallbackFactory isExistWarehouseMaterial(WmsWarehouseMaterial wmsWarehouseMaterial, String source) { + return R.fail("获取是否绑定仓库信息失败:" + throwable.getMessage()); + } + }; } } 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 45eb2fd..693df5e 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 @@ -193,6 +193,7 @@ public class WmsConstants { public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_INSTALL = "3";//组装出库 public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_AUTO_OUTSTOCK = "4";//自动出库 + public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK = "5";//退货出库 public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER = "9";//其他 diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java index 4a53866..f6d58d0 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java @@ -2,14 +2,19 @@ package com.hw.mes.controller; import com.hw.common.core.web.controller.BaseController; import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.core.web.page.TableDataInfo; import com.hw.common.log.annotation.Log; import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.mes.domain.MesBasePalletInfo; import com.hw.mes.domain.vo.*; import com.hw.mes.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * MES手持端接口Controller * @@ -33,4 +38,13 @@ public class MesMobileController extends BaseController { } + /** + * 查询库位关联条码信息列表 + */ + @GetMapping("/getMesPalletInfos") + public TableDataInfo getMesPalletInfos(MesBasePalletInfo mesBasePalletInfo) { + startPage(); + List list = mesBasePalletInfoService.selectMesBasePalletInfoList(mesBasePalletInfo); + return getDataTable(list); + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java index 7076502..d5d59e2 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java @@ -10,16 +10,16 @@ import com.hw.common.core.domain.R; import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; -import com.hw.common.core.utils.poi.ExcelUtil; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.domain.vo.MesPalletInfoBindVo; import com.hw.mes.mapper.MesBaseBarcodeInfoMapper; import com.hw.printer.api.RemotePrinterService; -import com.hw.printer.api.domain.vo.PrintContentVo; import com.hw.wms.api.RemoteWmsService; +import com.hw.wms.api.domain.WmsWarehouseMaterial; import com.hw.wms.api.domain.vo.WmsProductStockVo; import com.hw.wms.api.domain.vo.WmsRawStockVo; +import com.hw.wms.api.domain.vo.WmsWarehouseMaterialExistVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -172,6 +172,15 @@ public class MesBasePalletInfoServiceImpl implements IMesBasePalletInfoService { throw new ServiceException("此物料条码存在原材料库存,不能绑定"); } + if(mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)){ + WmsWarehouseMaterial wmsWarehouseMaterial = new WmsWarehouseMaterial(); + wmsWarehouseMaterial.setStorageId(mesBaseBarcodeInfo.getMaterialId()); + R isExistWarehouseMaterial = remoteWmsService.isExistWarehouseMaterial(wmsWarehouseMaterial, SecurityConstants.INNER); + if (!isExistWarehouseMaterial.getData()) { + throw new ServiceException("此物料还没有配置仓库信息"); + } + } + String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsBaseWarehouseController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsBaseWarehouseController.java index b9426a0..e47d3b0 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsBaseWarehouseController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsBaseWarehouseController.java @@ -165,16 +165,23 @@ public class WmsBaseWarehouseController extends BaseController { } - @Log(title = "仓库管理", businessType = BusinessType.ALLOCATE) @PostMapping("/allocateVirtualMaterial") @InnerAuth - public R allocateVirtualMaterial(@RequestBody WmsWarehouseMaterial wmsWarehouseMaterial) { + public R allocateVirtualMaterial(@RequestBody WmsWarehouseMaterial wmsWarehouseMaterial) { boolean isSuccess = wmsWarehouseMaterialService.insertWmsWarehouseMaterial(wmsWarehouseMaterial) > 0; return R.ok(isSuccess); } + @PostMapping("/isExistWarehouseMaterial") + @InnerAuth + public R isExistWarehouseMaterial(@RequestBody WmsWarehouseMaterial wmsWarehouseMaterial) { + List wmsWarehouseMaterials = wmsWarehouseMaterialService.selectWmsWarehouseMaterialList(wmsWarehouseMaterial); + boolean isSuccess = wmsWarehouseMaterials != null && !wmsWarehouseMaterials.isEmpty(); + return R.ok(isSuccess); + } + // /** // * 根据仓库分配可入库物料信息 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 480ca29..2f6e9cf 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 @@ -412,7 +412,7 @@ public class WmsMobileController extends BaseController { @Log(title = "组装返库", businessType = BusinessType.INSERT) @PostMapping(("/assembleBack")) public AjaxResult assembleBack(@Validated @RequestBody WmsAssembleOutstockVo wmsAssembleOutstockVo) { - if(!wmsAssembleOutstockVo.getMaterialBarcode().equals("")) { + if (!wmsAssembleOutstockVo.getMaterialBarcode().equals("")) { throw new ServiceException("组装返库"); } return toAjax(1); @@ -432,12 +432,6 @@ public class WmsMobileController extends BaseController { //todo:入库时校验warehousematerial,入库出库需要校验库位状态,是否是移库合库锁定等 - - - - - - /** * 人工申请移库 */ @@ -455,7 +449,7 @@ public class WmsMobileController extends BaseController { public TableDataInfo getMoveList(WmsMove wmsMove) { startPage(); wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL); - wmsMove.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING+ "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH); + wmsMove.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH); List wmsMoves = wmsMoveService.selectWmsMoveJoinList(wmsMove); return getDataTable(wmsMoves); } @@ -491,7 +485,6 @@ public class WmsMobileController extends BaseController { } - /** * 获取盘点任务列表 */ @@ -550,6 +543,7 @@ public class WmsMobileController extends BaseController { //TODO 盘点中的不能进行移库合库? + /** * 确认盘点 */ @@ -560,7 +554,6 @@ public class WmsMobileController extends BaseController { } - /** * 盘点完成 */ @@ -569,4 +562,54 @@ public class WmsMobileController extends BaseController { public AjaxResult completeInventoryCheck(@RequestBody WmsInventoryCheck wmsInventoryCheck) { return success(wmsInventoryCheckService.completeInventoryCheck(wmsInventoryCheck)); } + + + /** + * 退货出库 + */ + @Log(title = "退货出库", businessType = BusinessType.INSERT) + @PostMapping(("/returnOutstock")) + public AjaxResult returnOutstock(@RequestBody WmsReturnOutstockVo wmsReturnOutstockVo) { + return success(wmsRawOutstockService.returnOutstock(wmsReturnOutstockVo)); + } + + + /** + * 获取退货出库信息 + */ + @GetMapping(value = "/getReturnRawOutstocks") + public TableDataInfo getReturnRawOutstocks(WmsRawOutstock wmsRawOutstock) { + startPage(); + wmsRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK); + return getDataTable(wmsRawOutstockService.selectWmsRawOutstockList(wmsRawOutstock)); + } + + + /** + * 锁定库位 + */ + @Log(title = "库位", businessType = BusinessType.LOCK) + @PostMapping(("/lockLocation")) + public AjaxResult lockLocation(@RequestBody WmsLocationLockUnLockVo wmsLocationLockUnLockVo) { + return success(wmsBaseLocationService.lockWmsBaseLocationByLocationCode(wmsLocationLockUnLockVo.getLocationCode())); + } + + + /** + * 解锁库位 + */ + @Log(title = "库位", businessType = BusinessType.UNLOCK) + @PostMapping(("/unlockLocation")) + public AjaxResult unlockLocation(@RequestBody WmsLocationLockUnLockVo wmsLocationLockUnLockVo) { + return success(wmsBaseLocationService.unlockWmsBaseLocationByLocationCode(wmsLocationLockUnLockVo.getLocationCode())); + } + + + @GetMapping(value = "/getLockLocations") + public AjaxResult getLockLocations(WmsBaseLocation wmsBaseLocation) { + Map> locationMap = wmsBaseLocationService.getLocationCodesGroupByWarehouse(wmsBaseLocation); + System.out.println(locationMap); + return success(locationMap); + } + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java index 0e7249e..7830b0c 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java @@ -93,7 +93,7 @@ public class WmsRawInstock extends BaseEntity private String applyBy; /** 入库时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd") private Date applyDate; 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 e6ea146..0ecb16d 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 @@ -153,7 +153,7 @@ public class WmsRawOutstock extends BaseEntity { /** * 申请时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd") private Date applyDate; diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsLocationLockUnLockVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsLocationLockUnLockVo.java new file mode 100644 index 0000000..fa8d18b --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsLocationLockUnLockVo.java @@ -0,0 +1,21 @@ +package com.hw.wms.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description: 库位锁库解锁VO + * @ClassName: WmsLocationLockUnLockVo + * @Author : xins + * @Date :2024-10-29 + * @Version :1.0 + */ +@Data +public class WmsLocationLockUnLockVo { + //库位码 + @NotBlank(message="库位码必须输入") + private String locationCode; + + +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsReturnOutstockVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsReturnOutstockVo.java new file mode 100644 index 0000000..55688de --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsReturnOutstockVo.java @@ -0,0 +1,28 @@ +package com.hw.wms.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * @Description: 退库出库记录VO + * @ClassName: WmsReturnOutstockVo + * @Author : xins + * @Date :2024-10-29 + * @Version :1.0 + */ +@Data +public class WmsReturnOutstockVo { + //库位码 + @NotBlank(message="库位码必须输入") + private String locationCode; + + //库位码 + private String materialBarcode; + + private BigDecimal returnAmount; + + +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsBaseLocationService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsBaseLocationService.java index 5e2f32a..1908d38 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsBaseLocationService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsBaseLocationService.java @@ -1,6 +1,7 @@ package com.hw.wms.service; import java.util.List; +import java.util.Map; import com.hw.common.core.utils.DateUtils; import com.hw.wms.domain.WmsBaseLocation; @@ -77,6 +78,14 @@ public interface IWmsBaseLocationService */ public int lockWmsBaseLocation(Long locationId); + /** + * 锁定库位 + * + * @param locationCode 库位编码 + * @return 结果 + */ + public int lockWmsBaseLocationByLocationCode(String locationCode); + /** * 解锁库位 * @@ -85,6 +94,14 @@ public interface IWmsBaseLocationService */ public int unlockWmsBaseLocation(Long locationId); + /** + * 解锁库位 + * + * @param locationCode 库位编码 + * @return 结果 + */ + public int unlockWmsBaseLocationByLocationCode(String locationCode); + /** * 打印库位或料箱条码 * @@ -110,4 +127,10 @@ public interface IWmsBaseLocationService */ public int deleteWmsLocationBarcodeByLocationBarcodeIds(Long[] locationBarcodeIds); + /** + * 根据仓库group 查询已锁库位的库位信息 + * @param wmsBaseLocation + * @return + */ + public Map> getLocationCodesGroupByWarehouse(WmsBaseLocation wmsBaseLocation); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java index 17137c9..f68fcdd 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java @@ -155,5 +155,12 @@ public interface IWmsRawOutstockService * @return */ public WmsRawOutstock getNewestOutstockCabinet(WmsRawOutstock wmsRawOutstock); + + /** + * 退货出库 + * @param wmsReturnOutstockVo + * @return + */ + public int returnOutstock(WmsReturnOutstockVo wmsReturnOutstockVo); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsBaseLocationServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsBaseLocationServiceImpl.java index 0adc320..be4fbc6 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsBaseLocationServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsBaseLocationServiceImpl.java @@ -1,6 +1,7 @@ package com.hw.wms.service.impl; import com.hw.common.core.constant.SecurityConstants; +import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.enums.WmsLocationStatus; import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; @@ -19,10 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 库位Service业务层处理 @@ -128,6 +127,8 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService { } + + /** * 锁定库位 * @@ -139,6 +140,24 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService { // wmsBaseLocation.setCreateTime(DateUtils.getNowDate()); // return wmsBaseLocationMapper.insertWmsBaseLocation(wmsBaseLocation); WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId); + return this.lockLocation(baseLocation); + } + + /** + * 锁定库位 + * + * @param locationCode 库位编码 + * @return 结果 + */ + @Override + public int lockWmsBaseLocationByLocationCode(String locationCode) { +// wmsBaseLocation.setCreateTime(DateUtils.getNowDate()); +// return wmsBaseLocationMapper.insertWmsBaseLocation(wmsBaseLocation); + WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); + return this.lockLocation(baseLocation); + } + + public int lockLocation(WmsBaseLocation baseLocation){ String locationStatus = baseLocation.getLocationStatus(); if (locationStatus.equals(WmsLocationStatus.MANUALLOCK.getCode())) { return 1; @@ -151,6 +170,7 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService { return wmsBaseLocationMapper.updateWmsBaseLocation(baseLocation); } + /** * 解锁库位 * @@ -160,6 +180,22 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService { @Override public int unlockWmsBaseLocation(Long locationId) { WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId); + return this.unlockLocation(baseLocation); + } + + /** + * 解锁库位 + * + * @param locationCode 库位编码 + * @return 结果 + */ + @Override + public int unlockWmsBaseLocationByLocationCode(String locationCode) { + WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); + return this.unlockLocation(baseLocation); + } + + public int unlockLocation(WmsBaseLocation baseLocation) { String locationStatus = baseLocation.getLocationStatus(); if (locationStatus.equals(WmsLocationStatus.NORMAL.getCode())) { return 1; @@ -247,4 +283,23 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService { public int deleteWmsLocationBarcodeByLocationBarcodeIds(Long[] locationBarcodeIds) { return wmsLocationBarcodeMapper.deleteWmsLocationBarcodeByLocationBarcodeIds(locationBarcodeIds); } + + + /** + * 根据仓库group 查询已锁库位的库位信息 + * @param wmsBaseLocation + * @return + */ + @Override + public Map> getLocationCodesGroupByWarehouse(WmsBaseLocation wmsBaseLocation){ + wmsBaseLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MANUAL_LOCK); + List wmsBaseLocations = wmsBaseLocationMapper.selectWmsBaseLocationJoinList(wmsBaseLocation); + Map> locationCodesByWarehouse = wmsBaseLocations.stream() + .collect(Collectors.groupingBy( + WmsBaseLocation::getWarehouseName, + Collectors.mapping(WmsBaseLocation::getLocationCode, Collectors.toList()) + )); + + return locationCodesByWarehouse; + } } 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 c93d27d..b4186c8 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 @@ -1243,7 +1243,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { public BigDecimal directOutstockUpdateRawStock(String locationCode, String materialBarcode, BigDecimal outstockAmount, - String userName, Date currentDate) { + String userName, Date currentDate) { WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode); if (wmsRawStock == null) { throw new ServiceException("没找到库存信息"); @@ -1313,4 +1313,98 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { wmsRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_SPLIT); return wmsRawOutstockMapper.selectNewestWmsRawOutstock(wmsRawOutstock); } + + + /** + * 退货出库 + * @param wmsReturnOutstockVo + * @return + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int returnOutstock(WmsReturnOutstockVo wmsReturnOutstockVo) { + String locationCode = wmsReturnOutstockVo.getLocationCode(); + WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); + if (baseLocation == null) { + throw new ServiceException("库位编码错误"); + } + + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(baseLocation.getWarehouseId()); + String warehouseType = baseWarehouse.getWarehouseType(); + String executeStatus = ""; + BigDecimal outstockAmount = BigDecimal.ZERO; + BigDecimal realOutstockAmount = BigDecimal.ZERO; + WmsRawStock wmsRawStock; + if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_AGV)) {//AGV仓库 + executeStatus = WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE; + outstockAmount = BigDecimal.ONE; + WmsRawStock queryRawStock = new WmsRawStock(); + queryRawStock.setLocationCode(locationCode); + List wmsRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryRawStock); + if (wmsRawStocks == null || wmsRawStocks.isEmpty()) { + throw new ServiceException("此库位无库存信息"); + } + + wmsRawStock = wmsRawStocks.get(0); + + } else if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { + executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH; + String materialBarcode = wmsReturnOutstockVo.getMaterialBarcode(); + BigDecimal returnAmount = wmsReturnOutstockVo.getReturnAmount(); + outstockAmount = returnAmount; + realOutstockAmount = returnAmount; + if (StringUtils.isEmpty(materialBarcode)) { + throw new ServiceException("请输入或扫描物料条码"); + } + if (returnAmount == null) { + throw new ServiceException("请输入退货数量"); + } + + wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode); + if (wmsRawStock == null) { + throw new ServiceException("无库存信息"); + } + BigDecimal totalAmount = wmsRawStock.getTotalAmount(); + BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); + BigDecimal availableAmount = totalAmount.subtract(occupyAmount); + if (returnAmount.compareTo(availableAmount) > 0) { + throw new ServiceException("可用库存只有:" + availableAmount); + } + + if (returnAmount.compareTo(totalAmount) == 0) { + wmsRawStockMapper.deleteWmsRawStockByRawStockId(wmsRawStock.getRawStockId()); + } else { + wmsRawStock.setTotalAmount(totalAmount.subtract(returnAmount)); + wmsRawStock.setUpdateBy(userName); + wmsRawStock.setUpdateDate(currentDate); + wmsRawStockMapper.updateWmsRawStock(wmsRawStock); + } + + + } else { + throw new ServiceException("仓库类型有误"); + } + String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType); + + WmsRawOutstock wmsRawOutstock = new WmsRawOutstock(); + wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode)); + wmsRawOutstock.setWarehouseId(baseWarehouse.getWarehouseId()); + wmsRawOutstock.setLocationCode(locationCode); + wmsRawOutstock.setSaleOrderId(wmsRawStock.getSaleOrderId()); + wmsRawOutstock.setMaterialId(wmsRawStock.getMaterialId()); + wmsRawOutstock.setMaterialBatch(wmsRawStock.getInstockBatch()); + wmsRawOutstock.setOutstockAmount(outstockAmount); + wmsRawOutstock.setRealOutstockAmount(realOutstockAmount); + wmsRawOutstock.setOperationType(operationType); + wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); + wmsRawOutstock.setExecuteStatus(executeStatus); + wmsRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK); + wmsRawOutstock.setApplyBy(userName); + wmsRawOutstock.setApplyDate(currentDate); + + return wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock); + + } } diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml index f22d62d..1d86a15 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml @@ -203,6 +203,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + order by wri.apply_date desc