|
|
@ -3,18 +3,32 @@ package com.win.module.wms.until.job; |
|
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.location.LocationDO; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
public class JobUtils { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ItembasicService itembasicService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private LocationService locationService; |
|
|
|
/** |
|
|
|
* 解析JSON串,返回两个对象的集合 |
|
|
|
* |
|
|
@ -87,5 +101,125 @@ public class JobUtils { |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
//到库位与任务库位是否一致(可配置)
|
|
|
|
public boolean jobToLocationCodeAndRecordToLocationCodeAccord(String jobToLocationCode, String recordToLocationCode, String allowModifyLocation){ |
|
|
|
if(jobToLocationCode != null || !"".equals(jobToLocationCode)){ |
|
|
|
if(!jobToLocationCode.equals(recordToLocationCode)){ |
|
|
|
if("TRUE".equals(allowModifyLocation)){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(LOCATION_HANDLE_TOLOCATIONCODE_AND_RECOMMEND_TOLOCATIONCODECODE_INCONFORMITY); |
|
|
|
} |
|
|
|
}else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
}else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
//DBT---DBT2---IT 物料类型检验是否一致
|
|
|
|
public boolean ifInType(String pitemCode, BusinesstypeDO businesstypeDO){ |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(pitemCode); |
|
|
|
boolean ifInType = false; |
|
|
|
if(itembasicDO != null){ |
|
|
|
String[] itemType = businesstypeDO.getItemTypes().split(","); |
|
|
|
for (int i = 0; i < itemType.length; i++) { |
|
|
|
if(itembasicDO.getType().equals(itemType[i])){ |
|
|
|
ifInType = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(ifInType == true){ |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
throw exception(ITEMBASIC_TYPE_AND_BUSINESSTYPE_NOT_EQUALS); |
|
|
|
} |
|
|
|
} |
|
|
|
//DBT---DBT2---IS 物料状态检验是否一致
|
|
|
|
public boolean ifInStatus(String pitemCode, BusinesstypeDO businesstypeDO){ |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(pitemCode); |
|
|
|
boolean ifInStatus = false; |
|
|
|
if(itembasicDO != null){ |
|
|
|
String[] itemStatus = businesstypeDO.getItemStatuses().split(","); |
|
|
|
for (int i = 0; i < itemStatus.length; i++) { |
|
|
|
if(itembasicDO.getStatus().equals(itemStatus[i])){ |
|
|
|
ifInStatus = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(ifInStatus == true){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(ITEMBASIC_STATUS_AND_BUSINESSSTATUS_NOT_EQUALS); |
|
|
|
} |
|
|
|
} |
|
|
|
//DBT---DBT2---LI 校验入库库位类型是否一致
|
|
|
|
public boolean ifInFromLocationType(String plocationCode, BusinesstypeDO businesstypeDO){ |
|
|
|
LocationDO locationDO = locationService.selectLocationExist(plocationCode); |
|
|
|
boolean ifInLocationType = false; |
|
|
|
if(locationDO != null){ |
|
|
|
String[] itemInLocationTypes = businesstypeDO.getInLocationTypes().split(","); |
|
|
|
for (int i = 0; i < itemInLocationTypes.length; i++) { |
|
|
|
if(locationDO.getType().equals(itemInLocationTypes[i])){ |
|
|
|
ifInLocationType = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(ifInLocationType == true){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(FROM_LOCATION_TYPE_AND_BUSINESSTYPE_INLOCATION_TYPE_NOT_EQUALS); |
|
|
|
} |
|
|
|
} |
|
|
|
//DBT---DBT2---LO 校验出库库位类型是否一致
|
|
|
|
public boolean ifInToLocationType(String plocationCode, BusinesstypeDO businesstypeDO){ |
|
|
|
LocationDO locationDO = locationService.selectLocationExist(plocationCode); |
|
|
|
boolean ifOutLocationType = false; |
|
|
|
if(locationDO != null){ |
|
|
|
String[] itemOutLocationTypes = businesstypeDO.getOutLocationTypes().split(","); |
|
|
|
for (int i = 0; i < itemOutLocationTypes.length; i++) { |
|
|
|
if(locationDO.getType().equals(itemOutLocationTypes[i])){ |
|
|
|
ifOutLocationType = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(ifOutLocationType ==true){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(TO_LOCATION_TYPE_AND_BUSINESSTYPE_OUTLOCATION_TYPE_NOT_EQUALS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//DBT---DBT2---ISI 校验入库状态是否一致
|
|
|
|
public boolean ifInInventoryStatuses(String pinventoryStatus, BusinesstypeDO businesstypeDO){ |
|
|
|
boolean ifInInventoryStatuses = false; |
|
|
|
if(pinventoryStatus != null){ |
|
|
|
String[] inventoryStatuses = businesstypeDO.getInInventoryStatuses().split(","); |
|
|
|
for (int i = 0; i < inventoryStatuses.length; i++) { |
|
|
|
if(pinventoryStatus.equals(inventoryStatuses[i])){ |
|
|
|
ifInInventoryStatuses = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}if(ifInInventoryStatuses == true){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(INVENTORY_STATUS_AND_BUSINESS_IN_INVENTORY_STATUS_NOT_EQUALS_OR_NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
//DBT---DBT2---ISO 校验出库状态是否一致
|
|
|
|
public boolean ifOutInventoryStatuses(String pinventoryStatus, BusinesstypeDO businesstypeDO){ |
|
|
|
boolean ifOutInventoryStatuses = false; |
|
|
|
if(pinventoryStatus != null){ |
|
|
|
String[] inventoryStatuses = businesstypeDO.getOutInventoryStatuses().split(","); |
|
|
|
for (int i = 0; i < inventoryStatuses.length; i++) { |
|
|
|
if(pinventoryStatus.equals(inventoryStatuses[i])){ |
|
|
|
ifOutInventoryStatuses = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}if(ifOutInventoryStatuses == true){ |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
throw exception(INVENTORY_STATUS_AND_BUSINESS_OUT_INVENTORY_STATUS_NOT_EQUALS_OR_NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|