diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java index 02434cf7..3785c0a1 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java @@ -132,6 +132,7 @@ public interface ErrorCodeConstants { ErrorCode WAREHOUSE_CODE_NOT_EXISTS = new ErrorCode(1_033_000_002, "code不存在"); ErrorCode WAREHOUSE_AVAIABLE_NOT_EXISTS = new ErrorCode(1_033_000_003, "是否可用不存在"); ErrorCode WAREHOUSE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_033_000_004, "导入仓库不能为空"); + ErrorCode WAREHOUSE_STOCK_EXCEPTION = new ErrorCode(1_033_000_005, "库存问题【{}】"); //月台ErrorCode ErrorCode DOCK_NOT_EXISTS = new ErrorCode(1_000_034_000, "月台(收货口)不存在"); ErrorCode DOCK_CODE_NOT_EXISTS = new ErrorCode(1_000_034_001, "code不存在"); @@ -173,6 +174,9 @@ public interface ErrorCodeConstants { ErrorCode LOCATION_ITEMCODE_AND_LOCATIONCODE_NOT_EXISTS = new ErrorCode(1_000_037_012, "未查找到零件item_code库位location_code对应的上架策略"); ErrorCode LOCATION_HANDLE_TOLOCATIONCODE_AND_RECOMMEND_TOLOCATIONCODECODE_INCONFORMITY = new ErrorCode(1_000_037_013, "实际库位与任务推荐的目标库位不一致"); ErrorCode LOCATION_DISABLE_NEGATIVE = new ErrorCode(1_000_037_014, "库位不允许负库存"); + ErrorCode LOCATION_EXCEPTION = new ErrorCode(1_000_037_015, "库位问题:【{}】"); + ErrorCode LOCATION_INVENTORY_EXCEPTION = new ErrorCode(1_000_037_016, "库存问题:【{}】"); + ErrorCode LOCATION_NOT_CUST = new ErrorCode(1_000_037_017, "【{}】不是客户寄售库"); //车间ErrorCode ErrorCode WORKSHOP_NOT_EXISTS = new ErrorCode(1_038_000_000, "车间不存在"); ErrorCode WORKSHOP_CODE_EXISTS = new ErrorCode(1_039_000_001, "code已存在"); @@ -805,9 +809,11 @@ public interface ErrorCodeConstants { ErrorCode SWITCH_NOT_EXISTS = new ErrorCode(1_000_166_000, "单据开关不存在"); //企业ErrorCode ErrorCode ENTERPRISE_NOT_EXISTS = new ErrorCode(1_000_167_000, "企业不存在"); - //"订单行"+ poLine + "的已发货数量" + shippedQty + "+计划数量" + qty + "大于订单数量" + orderQty ErrorCode - ErrorCode AMOUNT_EXCEPTION = new ErrorCode(1_000_400_000, "数量问题:【{}】"); //UOM ErrorCode + ErrorCode BATCH_EXCEPTION = new ErrorCode(1_000_400_000, "批次问题:【{}】"); ErrorCode UOM_EXCEPTION = new ErrorCode(1_000_401_000, "单位问题:【{}】"); + ErrorCode MANAGEMENTPRECISION_EXCEPTION = new ErrorCode(1_000_402_000, "管理精度问题:【{}】"); + ErrorCode QTY_EXCEPTION = new ErrorCode(1_000_403_000, "数量问题:【{}】"); + } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java index 5151b6bb..8aec3ea8 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java @@ -4,7 +4,6 @@ import cn.hutool.core.exceptions.UtilException; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.win.framework.common.exception.ErrorCode; import com.win.module.wms.controller.rule.vo.RuleRespVO; import com.win.module.wms.dal.dataobject.balance.BalanceDO; import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; @@ -103,7 +102,7 @@ public class JobUtils { Map recordMap = recordJsonObject.get("record", Map.class); resList.add(recordMap); } catch (Exception e) { - throw new UtilException("数据解析异常,请重试!", e); + log.error("数据解析异常,请重试!", e); } } @@ -127,13 +126,13 @@ public class JobUtils { if ("TRUE".equals(allowBiggerQty)) { result = true; } else { - throw new UtilException("实际数量" + handleQty + " 不允许大于推荐数量" + recommendQty); + throw exception(QTY_EXCEPTION,"实际数量" + handleQty + " 不允许大于推荐数量" + recommendQty); } } else if (handleQty.compareTo(recommendQty) == -1) { if ("TRUE".equals(allowSmallerQty)) { result = true; } else { - throw new UtilException("实际数量" + handleQty + " 不允许小于推荐数量" + recommendQty); + throw exception(QTY_EXCEPTION,"实际数量" + handleQty + " 不允许小于推荐数量" + recommendQty); } } else if (handleQty.compareTo(recommendQty) == 0) { result = true; @@ -154,23 +153,22 @@ public class JobUtils { if ("TRUE".equals(allowModifyBatch)) { result = true; } else { - throw new UtilException("实际数量" + jobDetailBatch + " 不允许大于推荐数量" + recordDetailBatch); + throw exception(QTY_EXCEPTION,"实际数量" + jobDetailBatch + " 不允许大于推荐数量" + recordDetailBatch); } } else if (jobDetailBatch.compareTo(recordDetailBatch) == -1) { if ("TRUE".equals(allowModifyBatch)) { result = true; } else { - throw new UtilException("实际数量" + jobDetailBatch + " 不允许小于推荐数量" + recordDetailBatch); + throw exception(QTY_EXCEPTION,"实际数量" + jobDetailBatch + " 不允许小于推荐数量" + recordDetailBatch); } } - if (jobDetailBatch.compareTo(recordDetailBatch) == 0) { result = true; } else { if ("TRUE".equals(allowModifyBatch)) { result = true; } else { - throw new UtilException("实际批次" + jobDetailBatch + " 与任务推荐批次" + recordDetailBatch + "不一致"); + throw exception(BATCH_EXCEPTION,"实际批次" + jobDetailBatch + " 与任务推荐批次" + recordDetailBatch + "不一致"); } } return result; @@ -319,12 +317,12 @@ public class JobUtils { } } }else { - throw new UtilException("物料代码" + pitemCode + "无效"); + throw exception(ITEMBASIC_EXCEPTION,"物料代码" + pitemCode + "无效"); } if (ifInStatus == true) { return true; } else { - throw new UtilException("物料" + pitemCode + "的状态" + itembasicDO.getStatus() + "与业务类型" + + throw exception(ITEMBASIC_EXCEPTION,"物料" + pitemCode + "的状态" + itembasicDO.getStatus() + "与业务类型" + businesstypeDO.getName() + "的物料状态" + businesstypeDO.getItemStatuses() + "不一致"); } } @@ -342,12 +340,12 @@ public class JobUtils { } } else { - throw new UtilException("库位" + plocationCode + "无效"); + throw exception(LOCATION_EXCEPTION,"库位" + plocationCode + "无效"); } if (ifInLocationType == true) { return true; } else { - throw new UtilException("入库库位" + plocationCode + "的库位类型" + locationDO.getType() + "与业务类型" + + throw exception(LOCATION_EXCEPTION,"入库库位" + plocationCode + "的库位类型" + locationDO.getType() + "与业务类型" + businesstypeDO.getName() + "的入库库位类型" + businesstypeDO.getInLocationTypes() + "不一致"); } } @@ -365,12 +363,12 @@ public class JobUtils { } } else { - throw new UtilException("库位" + plocationCode + "无效"); + throw exception(LOCATION_EXCEPTION,"库位" + plocationCode + "无效"); } if (ifOutLocationType == true) { return true; } else { - throw new UtilException("出库库位" + plocationCode + "的库位类型" + locationDO.getType() + "与业务类型与业务类型" + + throw exception(LOCATION_EXCEPTION,"出库库位" + plocationCode + "的库位类型" + locationDO.getType() + "与业务类型与业务类型" + businesstypeDO.getName() + "的出库库位类型" + businesstypeDO.getOutLocationTypes() + "不一致"); } } @@ -387,12 +385,12 @@ public class JobUtils { } } else { - throw new UtilException("入库库存状态" + pinventoryStatus + "为空"); + throw exception(WAREHOUSE_STOCK_EXCEPTION,"入库库存状态" + pinventoryStatus + "为空"); } if (ifInInventoryStatuses == true) { return true; } else { - throw new UtilException("入库库存状态" + pinventoryStatus + "与业务类型" + + throw exception(LOCATION_INVENTORY_EXCEPTION,"入库库存状态" + pinventoryStatus + "与业务类型" + businesstypeDO.getName() + "的入库库存状态" + businesstypeDO.getInInventoryStatuses() + "不一致"); } } @@ -409,12 +407,12 @@ public class JobUtils { } } else { - throw new UtilException("出库库存状态" + pinventoryStatus + "为空"); + throw exception(LOCATION_INVENTORY_EXCEPTION,"出库库存状态" + pinventoryStatus + "为空"); } if (ifOutInventoryStatuses == true) { return true; } else { - throw new UtilException("出库库存状态" + pinventoryStatus + "与业务类型" + + throw exception(LOCATION_INVENTORY_EXCEPTION,"出库库存状态" + pinventoryStatus + "与业务类型" + businesstypeDO.getName() + "的出库库存状态" + businesstypeDO.getOutInventoryStatuses() + "不一致"); } } @@ -463,28 +461,28 @@ public class JobUtils { if ("{\"ManagementPrecision\":\"BY_QUANTITY\"}".equals(managementtRule.getConfiguration())) { balanceDO = balanceService.selectNumber(itemcode, inventoryStatus, locationcode); if(balanceDO == null){ - throw new UtilException( "物品代码" + itemcode + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); + throw exception(MANAGEMENTPRECISION_EXCEPTION, "物品代码" + itemcode + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); }else { return balanceDO; } }else if ("{\"ManagementPrecision\":\"BY_BATCH\"}".equals(managementtRule.getConfiguration())) { balanceDO = balanceService.selectBatch(itemcode, batch, inventoryStatus, locationcode); if(balanceDO == null){ - throw new UtilException( "物品代码" + itemcode + "批次" + batch + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); + throw exception(MANAGEMENTPRECISION_EXCEPTION, "物品代码" + itemcode + "批次" + batch + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); }else { return balanceDO; } }else if("{\"ManagementPrecision\":\"BY_PACKAGING\"}".equals(managementtRule.getConfiguration())) { balanceDO = balanceService.selectPackaging(itemcode, packingnumber, batch, inventoryStatus, locationcode); if(balanceDO == null){ - throw new UtilException( "物品代码" + itemcode + "箱码" + packingnumber + "批次" + batch + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); + throw exception(MANAGEMENTPRECISION_EXCEPTION,"物品代码" + itemcode + "箱码" + packingnumber + "批次" + batch + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); }else { return balanceDO; } }else if("{\"ManagementPrecision\":\"BY_UNIQUE_ID\"}".equals(managementtRule.getConfiguration())) { balanceDO = balanceService.selectUniqueId(packingnumber, locationcode, inventoryStatus); if(balanceDO == null){ - throw new UtilException( "唯一码" + packingnumber + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); + throw exception(MANAGEMENTPRECISION_EXCEPTION, "唯一码" + packingnumber + "库存状态" + inventoryStatus + "在" + locationcode + "库位中未查找到库存记录"); }else { return balanceDO; } @@ -557,12 +555,12 @@ public class JobUtils { * @return * @author lianhongxi */ - public String LocaltionExist(String itemcode, String packingnumber, String batch, String locationcode, List inventoryStatus, BigDecimal requstqty) { + public boolean warehouseStockExist(String itemcode, String packingnumber, String batch, String locationcode, List inventoryStatus, BigDecimal requstqty) { BigDecimal enableqty = CountLocaltion(itemcode, packingnumber, batch, locationcode, inventoryStatus); if (requstqty.compareTo(enableqty) > 0) { - throw exception(new ErrorCode(1256, "请求数量" + requstqty + "大于库存数量" + enableqty)); + throw exception(WAREHOUSE_STOCK_EXCEPTION, "请求数量" + requstqty + "大于库存数量" + enableqty); } else { - return "成功"; + return true; } } @@ -579,41 +577,40 @@ public class JobUtils { } //库存不应该存在 - public List locationNoExist(String itemcode, String packingnumber, String locationcode, List inventoryStatus) { + public List warehouseStocknNotExist(String itemcode, String packingnumber, String locationcode, List inventoryStatus) { RuleRespVO managementtRule = ruleService.management(null, null, null, null, null, null, itemcode, null, null, null, locationcode, null, null); List balanceDO = null; if ("{\"ManagementPrecision\":\"BY_UNIQUE_ID\"}".equals(managementtRule.getConfiguration())) { balanceDO = balanceService.selectUniqueId(packingnumber, locationcode, inventoryStatus); return balanceDO; - } else { - throw exception(new ErrorCode(1256, "校验通过")); + }else { + return null; } } //查询库位BQ-QL - public String selectlocation(String code) { + public boolean selectlocation(String code) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("code", code); + queryWrapper.eq("available", "TRUE"); LocationDO locationDO = locationMapper.selectOne(queryWrapper); - if (locationDO == null && "TRUE".equals(locationDO.getAvailable())) { - return "TURE"; + if (locationDO == null) { + return true; } else { - return "FALSE"; + return false; } } //从库位未被其他任务占用,有可用库存 - public String locationExistnew(String itemcode, String packingnumber, String batch, String fromlocationcode, List inventoryStatus, BigDecimal requstqty) { + public boolean locationUsable(String itemcode, String packingnumber, String batch, String fromlocationcode, List inventoryStatus, BigDecimal requstqty) { if (fromlocationcode.isEmpty()) { - return "不需要其他校验"; + return true; } - String Yesorno = selectlocation(fromlocationcode); - if ("TURE".equals(Yesorno)) { - String END = LocaltionExist(itemcode, packingnumber, batch, fromlocationcode, inventoryStatus, requstqty); - return END; + if (selectlocation(fromlocationcode)) { + return warehouseStockExist(itemcode, packingnumber, batch, fromlocationcode, inventoryStatus, requstqty); } else { - return "效验通过"; + throw exception(LOCATION_NOT_CUST,fromlocationcode); } } @@ -666,11 +663,7 @@ public class JobUtils { */ public List numAndJobIsSame(String itemCode, String packingNumber, String batch, String locationCode, List inventoryStatus) { List balanceDOList = new ArrayList<>(); - try { - balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); - } catch (Exception e) { - throw exception(new ErrorCode(1256, "接口调用异常,请重试")); - } + balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); return balanceDOList; } @@ -687,12 +680,8 @@ public class JobUtils { * @return */ public List fromInventoryEffective(String itemCode, String packingNumber, String batch, String locationCode, List inventoryStatus) { - List balanceDOList = new ArrayList<>(); - try { - balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); - } catch (Exception e) { - throw exception(new ErrorCode(1256, "接口调用异常,请重试")); - } + List balanceDOList = new ArrayList(); + balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); return balanceDOList; } @@ -729,16 +718,10 @@ public class JobUtils { */ public Boolean fromInventoryEffectiveCustomer(String locationCode, String itemCode, String packingNumber, String batch, List inventoryStatus) { Boolean returnRes = false; - List balanceDOList = new ArrayList<>(); - try { - String restlt = selectlocation(locationCode); - if ("TURE".equals(restlt)) { - fromInventoryEffective(itemCode, packingNumber, batch, locationCode, inventoryStatus); - } else if ("FALSE".equals(restlt)) { - return returnRes; - } - } catch (Exception e) { - throw exception(new ErrorCode(1256, "接口调用异常,请重试")); + if (selectlocation(locationCode)) { + fromInventoryEffective(itemCode, packingNumber, batch, locationCode, inventoryStatus); + } else{ + return returnRes; } return true; }