|
|
@ -13,7 +13,7 @@ import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
import com.win.module.wms.controller.location.vo.*; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
import com.win.module.wms.convert.location.LocationConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.balance.BalanceDO; |
|
|
|
import com.win.module.wms.dal.dataobject.location.LocationDO; |
|
|
|
import com.win.module.wms.dal.mysql.balance.BalanceMapper; |
|
|
|
import com.win.module.wms.dal.mysql.expectout.ExpectoutMapper; |
|
|
@ -105,6 +105,7 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
public PageResult<LocationDO> getLocationSenior(CustomConditions conditions) { |
|
|
|
return locationMapper.selectSenior(conditions); |
|
|
|
} |
|
|
|
|
|
|
|
private String validateLocationImport(LocationDO location) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
@ -182,8 +183,7 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
LocationDO existConfigurationSetting = locationMapper.selectByCode(locationDO.getCode()); |
|
|
|
if (existConfigurationSetting == null && mode != 3) { |
|
|
|
locationMapper.insert(LocationConvert.INSTANCE.convert(location)); |
|
|
|
} |
|
|
|
else if (existConfigurationSetting != null && mode != 2) { |
|
|
|
} else if (existConfigurationSetting != null && mode != 2) { |
|
|
|
// 如果存在,判断是否允许更新
|
|
|
|
locationDO.setId(existConfigurationSetting.getId()); |
|
|
|
locationMapper.updateById(locationDO); |
|
|
@ -192,6 +192,7 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
}); |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
private void validateLocationForCreateOrUpdate(Long id, String code, String warehouseCode, String areaCode, String erpLocationCode, String locationGroupCode, |
|
|
|
String type, Integer pickPriority, String userGroupCode, String available) { |
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
@ -209,6 +210,7 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
validateAvailableExists(available); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void validateLocationExists(Long id) { |
|
|
|
if (id == null) { |
|
|
|
return; |
|
|
@ -217,6 +219,7 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
throw exception(LOCATION_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateCodeExists(Long id, String code) { |
|
|
|
if (code.isEmpty()) { |
|
|
@ -237,12 +240,14 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
throw exception(LOCATION_CODE_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateWarehouseCodeExists(String warehouseCode) { |
|
|
|
if (warehouseCode.isEmpty()) { |
|
|
|
throw exception(LOCATION_WARE_HOUSE_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateAreaCodeExists(String areaCode) { |
|
|
|
if (areaCode.isEmpty()) { |
|
|
@ -263,30 +268,35 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
throw exception(LOCATION_LOCATION_GROUP_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateTypeExists(String type) { |
|
|
|
if (type.isEmpty()) { |
|
|
|
throw exception(LOCATION_TYPE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validatePickPriorityExists(Integer pickPriority) { |
|
|
|
if (pickPriority == null) { |
|
|
|
throw exception(LOCATION_PICK_PRIORITY_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateUserGroupCodeExists(String userGroupCode) { |
|
|
|
if (userGroupCode.isEmpty()) { |
|
|
|
throw exception(LOCATION_USER_GROUP_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateAvailableExists(String available) { |
|
|
|
if (available.isEmpty()) { |
|
|
|
throw exception(LOCATION_AVAILABLE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//调用公共方法查询库位信息
|
|
|
|
@Override |
|
|
|
public LocationDO selectLocation(String pcode) { |
|
|
@ -301,10 +311,8 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//{"WarehouseCode":"W1","AreaCode":"A1","LocationGroupCode":"LG1","LocationCode":"H01","EmptyLocationFirst":"FALSE","NotEmptyLocationFirst":"FALSE",
|
|
|
|
// "EnableMixItem":"TRUE","EnableMixLot":"TRUE","EnableMixStatus":"TRUE"}
|
|
|
|
@Override |
|
|
|
public LocationDO inspectLocation(RuleRespVO ruleRespVO, ItembasicDO itembasicDO) { |
|
|
|
public LocationDO inspectLocation(RuleRespVO ruleRespVO, String itemCode, String batch, String inventoryStatus) { |
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(ruleRespVO.getConfiguration()); |
|
|
|
Object locationCode = jsonObject.get("LocationCode"); |
|
|
|
//设置了库位直接返回
|
|
|
@ -367,35 +375,60 @@ public class LocationServiceImpl implements LocationService { |
|
|
|
Object enableMixLot = jsonObject.get("EnableMixLot"); |
|
|
|
//可以混状态
|
|
|
|
Object enableMixStatus = jsonObject.get("EnableMixStatus"); |
|
|
|
if("TRUE".equals(emptyLocationFirst)) { |
|
|
|
locationDOList = this.emptyLocationFirst(locationDOList, enableMixItem, enableMixLot, enableMixStatus); |
|
|
|
} else if("TRUE".equals(notEmptyLocationFirst)) { |
|
|
|
locationDOList = this.notEmptyLocationFirst(locationDOList, enableMixItem, enableMixLot, enableMixStatus); |
|
|
|
} |
|
|
|
locationDOList = this.locationFirst(locationDOList, emptyLocationFirst, notEmptyLocationFirst, itemCode, batch, inventoryStatus, enableMixItem, enableMixLot, enableMixStatus); |
|
|
|
return locationDOList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 优先空库位过滤 |
|
|
|
* 判断优先空库位和非空库位 |
|
|
|
* |
|
|
|
* @param locationDOList 库位list |
|
|
|
* @param emptyLocationFirst 优先空库位 |
|
|
|
* @param notEmptyLocationFirst 优先非空库位 |
|
|
|
* @param itemCode 物品编号 |
|
|
|
* @param batch 批次 |
|
|
|
* @param inventoryStatus 状态 |
|
|
|
* @param enableMixItem 可以混物品 |
|
|
|
* @param enableMixLot 可以混批次 |
|
|
|
* @param enableMixStatus 可以混状态 |
|
|
|
* @return 过滤之后的库位list |
|
|
|
*/ |
|
|
|
private List<LocationDO> emptyLocationFirst(List<LocationDO> locationDOList, Object enableMixItem, Object enableMixLot, Object enableMixStatus) { |
|
|
|
return locationDOList; |
|
|
|
private List<LocationDO> locationFirst(List<LocationDO> locationDOList, Object emptyLocationFirst, Object notEmptyLocationFirst, String itemCode, String batch, String inventoryStatus, Object enableMixItem, Object enableMixLot, Object enableMixStatus) { |
|
|
|
List<LocationDO> emptyList = new ArrayList<>(); |
|
|
|
List<LocationDO> notEmptyList = new ArrayList<>(); |
|
|
|
for (LocationDO locationDO : locationDOList) { |
|
|
|
List<BalanceDO> balanceDOList = balanceMapper.getBalanceList(null, null, null, null, locationDO.getCode()); |
|
|
|
if (balanceDOList.isEmpty()) { |
|
|
|
emptyList.add(locationDO); |
|
|
|
} else { |
|
|
|
boolean flag = true; |
|
|
|
for (BalanceDO balanceDO : balanceDOList) { |
|
|
|
if ("TRUE".equals(enableMixItem) && !itemCode.equals(balanceDO.getItemCode())) { |
|
|
|
flag = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
if ("TRUE".equals(enableMixLot) && !batch.equals(balanceDO.getBatch())) { |
|
|
|
flag = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
if ("TRUE".equals(enableMixStatus) && !inventoryStatus.equals(balanceDO.getInventoryStatus())) { |
|
|
|
flag = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (flag) { |
|
|
|
notEmptyList.add(locationDO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//优先空库位
|
|
|
|
if("TRUE".equals(emptyLocationFirst) && !emptyList.isEmpty()) { |
|
|
|
return emptyList; |
|
|
|
} |
|
|
|
//优先非空库位
|
|
|
|
if("TRUE".equals(notEmptyLocationFirst) && !notEmptyList.isEmpty()) { |
|
|
|
return notEmptyList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 优先非空库位过滤 |
|
|
|
* @param locationDOList 库位list |
|
|
|
* @param enableMixItem 可以混物品 |
|
|
|
* @param enableMixLot 可以混批次 |
|
|
|
* @param enableMixStatus 可以混状态 |
|
|
|
* @return 过滤之后的库位list |
|
|
|
*/ |
|
|
|
private List<LocationDO> notEmptyLocationFirst(List<LocationDO> locationDOList, Object enableMixItem, Object enableMixLot, Object enableMixStatus) { |
|
|
|
return locationDOList; |
|
|
|
} |
|
|
|
|
|
|
|