调整扫码入库货位分配的请求响应
This commit is contained in:
@@ -40,5 +40,4 @@ public interface IToErpService {
|
|||||||
|
|
||||||
void AddStockinDetailByErpStockinDetail(ErpInStockinDetail erpInStockinetail);
|
void AddStockinDetailByErpStockinDetail(ErpInStockinDetail erpInStockinetail);
|
||||||
|
|
||||||
String getCargoSpaceByProductInfo(String productId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -700,74 +700,5 @@ public class ToErpServiceImpl implements IToErpService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成入库单据 -> 向子单明细分配入库货位
|
|
||||||
* 获取库存物料号 -> 货位id -> 存储区组group -> 状态:未占用 -> 按规则获取货位
|
|
||||||
* @param productId 物料号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getCargoSpaceByProductInfo(String productId){
|
|
||||||
|
|
||||||
//>>>>>>>>>>>>>>获取物料库存信息 -> 有库存 -> 货位(cargospace) -> 存储区组(groupCodingNo) -> 根据groupCoding(由高到低) -> 获取状态1的货位分配
|
|
||||||
//>>>>>>>>>>>>>>获取物料库存信息 -> 无库存 -> 遍历存储区组(groupCodingNo) -> 查找全部货位空的区组 -> 根据groupCoding(由高到低) -> 获取状态1的货位分配
|
|
||||||
|
|
||||||
try {
|
|
||||||
//获取物料的货位集合 - 首先查找已经存放该物料的存储区
|
|
||||||
List<BasStock> stocks = basStockService.selectBasStockListByProductId(productId);
|
|
||||||
|
|
||||||
//如果集合空 - 寻找未被占用的存储区组放货
|
|
||||||
if (stocks.size() == 0) {
|
|
||||||
for (int i = 1; i <= 45; i++) {
|
|
||||||
BasCargoSpace cargospace = new BasCargoSpace();
|
|
||||||
|
|
||||||
//存储区
|
|
||||||
String groupCodingNo = String.format("%03d", i);
|
|
||||||
cargospace.setGroupCodingNo(groupCodingNo);
|
|
||||||
|
|
||||||
//获取【groupCodingNo】所有货位
|
|
||||||
List<BasCargoSpace> cargoSpaces = basCargoSpaceService.selectBasCargoSpaceList(cargospace);
|
|
||||||
|
|
||||||
//判断是否全部未占用,即某存储区全部为空位 - 避免物料混放
|
|
||||||
boolean isAllEmpty = cargoSpaces.stream().allMatch(c -> "1".equals(c.getStatus()));
|
|
||||||
|
|
||||||
//区域未占用 - 则分配最内侧货位
|
|
||||||
if (isAllEmpty && cargoSpaces.size() > 0) {
|
|
||||||
cargoSpaces.sort(Comparator.comparing(BasCargoSpace::getGroupCoding).reversed());
|
|
||||||
return cargoSpaces.get(0).getCargoSpaceId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//如果物料已经存放在多个货位(区域) - 去重
|
|
||||||
List<BasStock> stocksNew = stocks.stream().distinct().collect(Collectors.toList());
|
|
||||||
|
|
||||||
//查询对应货位的区域在【BasCargoSpace】是否有空位 - 在groupCodingNo的分组中是否仍然有状态【1】的货位
|
|
||||||
for (BasStock stock : stocksNew){
|
|
||||||
//获取每种物料的存放货位信息
|
|
||||||
BasCargoSpace cargoSpace = basCargoSpaceService.selectBasCargoSpaceByCargoSpaceId(stock.getCargoSpaceId());
|
|
||||||
|
|
||||||
//获取每种物料的存放货位信息 - 存储区
|
|
||||||
String group = cargoSpace.getGroupCodingNo();
|
|
||||||
|
|
||||||
//获取该存储区组的所有货位
|
|
||||||
List<BasCargoSpace> cargoSpaces = basCargoSpaceService.selectBasCargoSpaceListByGroupCodingNo(group);
|
|
||||||
|
|
||||||
//在集合中获取状态为【1】的货位
|
|
||||||
for (BasCargoSpace cs : cargoSpaces){
|
|
||||||
//货位状态:1(未占用) -> 返回该货位结果
|
|
||||||
if ("1".equals(cs.getStatus())){
|
|
||||||
return cs.getCargoSpaceId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
log.error("入库子单获取目标货位失败,异常信息:" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user