|
|
@ -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<String> inventoryStatus, BigDecimal requstqty) { |
|
|
|
public boolean warehouseStockExist(String itemcode, String packingnumber, String batch, String locationcode, List<String> 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<BalanceDO> locationNoExist(String itemcode, String packingnumber, String locationcode, List<String> inventoryStatus) { |
|
|
|
public List<BalanceDO> warehouseStocknNotExist(String itemcode, String packingnumber, String locationcode, List<String> inventoryStatus) { |
|
|
|
RuleRespVO managementtRule = ruleService.management(null, null, null, null, null, null, itemcode, null, null, |
|
|
|
null, locationcode, null, null); |
|
|
|
List<BalanceDO> 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<String> inventoryStatus, BigDecimal requstqty) { |
|
|
|
public boolean locationUsable(String itemcode, String packingnumber, String batch, String fromlocationcode, List<String> 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<BalanceDO> numAndJobIsSame(String itemCode, String packingNumber, String batch, String locationCode, List<String> inventoryStatus) { |
|
|
|
List<BalanceDO> balanceDOList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); |
|
|
|
} catch (Exception e) { |
|
|
|
throw exception(new ErrorCode(1256, "接口调用异常,请重试")); |
|
|
|
} |
|
|
|
return balanceDOList; |
|
|
|
} |
|
|
|
|
|
|
@ -687,12 +680,8 @@ public class JobUtils { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<BalanceDO> fromInventoryEffective(String itemCode, String packingNumber, String batch, String locationCode, List<String> inventoryStatus) { |
|
|
|
List<BalanceDO> balanceDOList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
List<BalanceDO> balanceDOList = new ArrayList(); |
|
|
|
balanceDOList = selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, locationCode, inventoryStatus); |
|
|
|
} catch (Exception e) { |
|
|
|
throw exception(new ErrorCode(1256, "接口调用异常,请重试")); |
|
|
|
} |
|
|
|
return balanceDOList; |
|
|
|
} |
|
|
|
|
|
|
@ -729,17 +718,11 @@ public class JobUtils { |
|
|
|
*/ |
|
|
|
public Boolean fromInventoryEffectiveCustomer(String locationCode, String itemCode, String packingNumber, String batch, List<String> inventoryStatus) { |
|
|
|
Boolean returnRes = false; |
|
|
|
List<BalanceDO> balanceDOList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
String restlt = selectlocation(locationCode); |
|
|
|
if ("TURE".equals(restlt)) { |
|
|
|
if (selectlocation(locationCode)) { |
|
|
|
fromInventoryEffective(itemCode, packingNumber, batch, locationCode, inventoryStatus); |
|
|
|
} else if ("FALSE".equals(restlt)) { |
|
|
|
} else{ |
|
|
|
return returnRes; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
throw exception(new ErrorCode(1256, "接口调用异常,请重试")); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|