|
|
|
|
@ -32,6 +32,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.io.Serializable; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
@ -65,7 +66,7 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
BaseLocationMapper baseLocationMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IBaseDeriveService baseDeriveService; |
|
|
|
|
private IBusinEnptyContainerService iBusinEnptyContainerService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Result<BaseLocationVo> queryById(Long id) { |
|
|
|
|
@ -259,11 +260,11 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
BaseLocation update = BeanUtil.toBean(bo, BaseLocation.class); |
|
|
|
|
update.setBranchId(one.getBranchId()); |
|
|
|
|
String code = |
|
|
|
|
bo.getTunnel() + "-" |
|
|
|
|
+ bo.getLocationRow() |
|
|
|
|
+ bo.getLocationColumn() |
|
|
|
|
+ bo.getLayer()+"-" |
|
|
|
|
+bo.getIsDeep(); |
|
|
|
|
bo.getTunnel() + "-" |
|
|
|
|
+ bo.getLocationRow() |
|
|
|
|
+ bo.getLocationColumn() |
|
|
|
|
+ bo.getLayer() + "-" |
|
|
|
|
+ bo.getIsDeep(); |
|
|
|
|
update.setLocationCode(code); |
|
|
|
|
Result result = checkEntity(update); |
|
|
|
|
if (!Result.isOk(result)) { |
|
|
|
|
@ -278,8 +279,8 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
String code = bo.getTunnel() + "-" |
|
|
|
|
+ bo.getLocationRow() |
|
|
|
|
+ bo.getLocationColumn() |
|
|
|
|
+ bo.getLayer()+"-" |
|
|
|
|
+bo.getIsDeep(); |
|
|
|
|
+ bo.getLayer() + "-" |
|
|
|
|
+ bo.getIsDeep(); |
|
|
|
|
add.setLocationCode(code); |
|
|
|
|
add.setBranchId(SecurityUtils.getCurrentBranchId()); |
|
|
|
|
Result result = checkEntity(add); |
|
|
|
|
@ -308,10 +309,10 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
// }
|
|
|
|
|
// 货位id是否重复
|
|
|
|
|
List<String> listLocationCodes = list.stream().map( |
|
|
|
|
s -> ( s.getTunnel() + "-" |
|
|
|
|
s -> (s.getTunnel() + "-" |
|
|
|
|
+ s.getLocationRow() |
|
|
|
|
+ s.getLocationColumn() |
|
|
|
|
+ s.getLayer()+"-" |
|
|
|
|
+ s.getLayer() + "-" |
|
|
|
|
+ s.getIsDeep() |
|
|
|
|
)).distinct().collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtils.isEmpty(listLocationCodes) |
|
|
|
|
@ -487,49 +488,49 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//入库时对双深位巷道中的货位进行处理
|
|
|
|
|
public List<BaseLocationVo> getUseBaseLoction(List<BaseLocationVo> baseLocationVoList){ |
|
|
|
|
public List<BaseLocationVo> getUseBaseLoction(List<BaseLocationVo> baseLocationVoList) { |
|
|
|
|
BaseLocationVo baseLocationVo = new BaseLocationVo(); |
|
|
|
|
for (int i=0;i<baseLocationVoList.size();i++){ |
|
|
|
|
for (int i = 0; i < baseLocationVoList.size(); i++) { |
|
|
|
|
//当前只有第一巷道为双深位货位
|
|
|
|
|
if (baseLocationVoList.get(i).getTunnel().equals("01")){ |
|
|
|
|
baseLocationVo=baseLocationVoList.get(i); |
|
|
|
|
if (baseLocationVoList.get(i).getTunnel().equals("01")) { |
|
|
|
|
baseLocationVo = baseLocationVoList.get(i); |
|
|
|
|
//货位为单深位(查看双深位状态是否是已分配状态如果是已分配状态那这个单深位不能放货)
|
|
|
|
|
if (baseLocationVo.getIsDeep().equals("1")){ |
|
|
|
|
BaseLocation one=null; |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("2")){ |
|
|
|
|
if (baseLocationVo.getIsDeep().equals("1")) { |
|
|
|
|
BaseLocation one = null; |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("2")) { |
|
|
|
|
one = this.getOne(new LambdaQueryWrapper<BaseLocation>() |
|
|
|
|
.eq(BaseLocation::getLocationRow, "1") |
|
|
|
|
.eq(BaseLocation::getLocationColumn, baseLocationVo.getLocationColumn()) |
|
|
|
|
.eq(BaseLocation::getLayer, baseLocationVo.getLayer())); |
|
|
|
|
} |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("3")){ |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("3")) { |
|
|
|
|
one = this.getOne(new LambdaQueryWrapper<BaseLocation>() |
|
|
|
|
.eq(BaseLocation::getLocationRow, "4") |
|
|
|
|
.eq(BaseLocation::getLocationColumn, baseLocationVo.getLocationColumn()) |
|
|
|
|
.eq(BaseLocation::getLayer, baseLocationVo.getLayer())); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (one!=null&&one.getLocationStatus().equals("4")){ |
|
|
|
|
if (one != null && one.getLocationStatus().equals("4")) { |
|
|
|
|
baseLocationVoList.remove(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//货位为双深位状态(查看单深位状态是否为已分配状态或者有货位状态(已分配状态防止货物还未取走))
|
|
|
|
|
if (baseLocationVo.getIsDeep().equals("2")){ |
|
|
|
|
BaseLocation one=null; |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("1")){ |
|
|
|
|
if (baseLocationVo.getIsDeep().equals("2")) { |
|
|
|
|
BaseLocation one = null; |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("1")) { |
|
|
|
|
one = this.getOne(new LambdaQueryWrapper<BaseLocation>() |
|
|
|
|
.eq(BaseLocation::getLocationRow, "2") |
|
|
|
|
.eq(BaseLocation::getLocationColumn, baseLocationVo.getLocationColumn()) |
|
|
|
|
.eq(BaseLocation::getLayer, baseLocationVo.getLayer())); |
|
|
|
|
} |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("4")){ |
|
|
|
|
if (baseLocationVo.getLocationRow().equals("4")) { |
|
|
|
|
one = this.getOne(new LambdaQueryWrapper<BaseLocation>() |
|
|
|
|
.eq(BaseLocation::getLocationRow, "3") |
|
|
|
|
.eq(BaseLocation::getLocationColumn, baseLocationVo.getLocationColumn()) |
|
|
|
|
.eq(BaseLocation::getLayer, baseLocationVo.getLayer())); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (one!=null&&(one.getLocationStatus().equals("4")||one.getLocationStatus().equals("1"))){ |
|
|
|
|
if (one != null && (one.getLocationStatus().equals("4") || one.getLocationStatus().equals("1"))) { |
|
|
|
|
baseLocationVoList.remove(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -546,25 +547,25 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Result<BaseLocationVo> assignEmptyLocation( String vehicheModel,String color, String batch,List<BusinDataTaskGoodsVo> businDataTaskGoodsVos) { |
|
|
|
|
if(businDataTaskGoodsVos !=null && businDataTaskGoodsVos.size()>0){ |
|
|
|
|
public Result<BaseLocationVo> assignEmptyLocation(String vehicheModel, String color, String batch, List<BusinDataTaskGoodsVo> businDataTaskGoodsVos) { |
|
|
|
|
if (businDataTaskGoodsVos != null && businDataTaskGoodsVos.size() > 0) { |
|
|
|
|
BusinDataTaskGoodsVo businDataTaskGoodsVo = businDataTaskGoodsVos.get(0); |
|
|
|
|
String taskCode = businDataTaskGoodsVo.getTaskCode(); |
|
|
|
|
log.info("分配货位任务号:"+taskCode+" 车型:"+vehicheModel+" 颜色:"+color); |
|
|
|
|
log.info("分配货位任务号:" + taskCode + " 车型:" + vehicheModel + " 颜色:" + color); |
|
|
|
|
} |
|
|
|
|
//获取车型对应的空货位
|
|
|
|
|
BaseLocationQueryListBo bo = new BaseLocationQueryListBo(); |
|
|
|
|
bo.setVehicheModel(vehicheModel); |
|
|
|
|
bo.setLocationStatus("0"); |
|
|
|
|
bo.setColor(color); |
|
|
|
|
log.info("保险杠分配货位查询条件:"+ JsonUtil.toJSONString(bo)); |
|
|
|
|
log.info("保险杠分配货位查询条件:" + JsonUtil.toJSONString(bo)); |
|
|
|
|
List<BaseLocationVo> baseLocationVos = this.baseMapper.queryBaseLocationListByDerive(bo); |
|
|
|
|
if(baseLocationVos.size()==0){ |
|
|
|
|
if (baseLocationVos.size() == 0) { |
|
|
|
|
//查看缓冲区是否还有货位
|
|
|
|
|
Long bufferArea =Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.buffer_area)); |
|
|
|
|
Long bufferArea = Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.buffer_area)); |
|
|
|
|
List<BaseLocationVo> baseLocationVoList = baseLocationMapper.getLocationByAreaId(bufferArea); |
|
|
|
|
log.info("保险杠缓冲区分配到的货位信息:"+baseLocationVoList.size()); |
|
|
|
|
if (baseLocationVoList.size()<0) { |
|
|
|
|
log.info("保险杠缓冲区分配到的货位信息:" + baseLocationVoList.size()); |
|
|
|
|
if (baseLocationVoList.size() < 0) { |
|
|
|
|
log.info("车型及缓冲区都未查询到空货位"); |
|
|
|
|
return Result.err().msg("当前该派生对应的空货位可用"); |
|
|
|
|
} |
|
|
|
|
@ -574,11 +575,11 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
// baseLocationVos=this.getUseBaseLoction(baseLocationVos);
|
|
|
|
|
//空货位所在巷道列表,同时过滤掉已有入库任务的巷道
|
|
|
|
|
List<String> tunnelList = baseLocationVos.stream().map(e -> e.getTunnel()).distinct().collect(Collectors.toList()); |
|
|
|
|
log.info("保险杠分配货位查询到的货位对应的巷道信息:"+JsonUtil.toJSONString(tunnelList)); |
|
|
|
|
log.info("保险杠分配货位查询到的货位对应的巷道信息:" + JsonUtil.toJSONString(tunnelList)); |
|
|
|
|
// TODO 测试注释 要打开
|
|
|
|
|
if(vehicheModel.contains("3UE")){ |
|
|
|
|
for (int i=0;i<tunnelList.size();i++){ |
|
|
|
|
if (tunnelList.get(i).contains("1")||tunnelList.get(i).contains("6")){ |
|
|
|
|
if (vehicheModel.contains("3UE")) { |
|
|
|
|
for (int i = 0; i < tunnelList.size(); i++) { |
|
|
|
|
if (tunnelList.get(i).contains("1") || tunnelList.get(i).contains("6")) { |
|
|
|
|
tunnelList.remove(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -592,11 +593,11 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
Integer maxEmptyLocationNum = 0; |
|
|
|
|
for (int i = 0; i < tunnelList.size(); i++) { |
|
|
|
|
String tunnel = tunnelList.get(i); |
|
|
|
|
Integer taskNum = tunnelTaskUtil.getTotalTaskNum(tunnel,0); |
|
|
|
|
Integer taskNum = tunnelTaskUtil.getTotalTaskNum(tunnel, 0); |
|
|
|
|
int curEmptyNum = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()).size(); |
|
|
|
|
log.info("保险杠分配之前----当前巷道:"+tunnel+" 目前任务数:"+taskNum+" 当前空货位数量:"+curEmptyNum+" 最小任务数:"+minTaskNum+" 最大空货位数:"+maxEmptyLocationNum); |
|
|
|
|
log.info("保险杠分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum); |
|
|
|
|
if (minTaskNum == 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if(i != 0){ |
|
|
|
|
if (i != 0) { |
|
|
|
|
if (curEmptyNum > maxEmptyLocationNum) { |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
@ -607,8 +608,8 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
}else if (minTaskNum == 0) { |
|
|
|
|
if(i == 0){ |
|
|
|
|
} else if (minTaskNum == 0) { |
|
|
|
|
if (i == 0) { |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
@ -626,27 +627,27 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("保险杠分配之后----当前巷道:"+tunnel+" 目前任务数:"+taskNum+" 当前空货位数量:"+curEmptyNum+" 最小任务数:"+minTaskNum+" 最大空货位数:"+maxEmptyLocationNum); |
|
|
|
|
log.info("保险杠分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("巷道的任务数量:"+JsonUtil.toJSONString(tunnelResult)); |
|
|
|
|
log.info("巷道的任务数量:" + JsonUtil.toJSONString(tunnelResult)); |
|
|
|
|
//从选取的巷道中选择库位
|
|
|
|
|
if (tunnelResult.size() > 0) { |
|
|
|
|
String tunnel = tunnelResult.get(0); |
|
|
|
|
List<BaseLocationVo> resultLocationList = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); |
|
|
|
|
BaseLocationVo locationVo = resultLocationList.get(0); |
|
|
|
|
log.info("分配的货位:"+JsonUtil.toJSONString(locationVo)); |
|
|
|
|
log.info("分配的货位:" + JsonUtil.toJSONString(locationVo)); |
|
|
|
|
//巷道中货位数大于1时,进行分配
|
|
|
|
|
if (resultLocationList.size() > 0) { |
|
|
|
|
BaseLocationVo assginLocation = assginLocation(resultLocationList,batch,vehicheModel,businDataTaskGoodsVos); |
|
|
|
|
BaseLocationVo assginLocation = assginLocation(resultLocationList, batch, vehicheModel, businDataTaskGoodsVos); |
|
|
|
|
if (assginLocation != null) { |
|
|
|
|
locationVo = assginLocation; |
|
|
|
|
log.info("最终分配的货位信息:"+assginLocation); |
|
|
|
|
log.info("最终分配的货位信息:" + assginLocation); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//确定分配该库位,并将库位状态改为已分配
|
|
|
|
|
this.changeLocationStatus(locationVo.getId(),"4"); |
|
|
|
|
this.changeLocationStatus(locationVo.getId(), "4"); |
|
|
|
|
locationVo.setLocationStatus("4"); |
|
|
|
|
return Result.ok().data(locationVo); |
|
|
|
|
} else { |
|
|
|
|
@ -715,12 +716,12 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
int curEmptyNum = currTunnelLocationVos.size(); |
|
|
|
|
BaseLocationVo baseLocationVo = currTunnelLocationVos.get(0); |
|
|
|
|
int currGoodsQty = 0; |
|
|
|
|
if (baseLocationVo.getGoodQty() !=null){ |
|
|
|
|
currGoodsQty=baseLocationVo.getGoodQty(); |
|
|
|
|
if (baseLocationVo.getGoodQty() != null) { |
|
|
|
|
currGoodsQty = baseLocationVo.getGoodQty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取巷道内库存数量最少并且空货位数最多的
|
|
|
|
|
log.info("保险杠分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum+" 当前库存量:"+currGoodsQty); |
|
|
|
|
log.info("保险杠分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); |
|
|
|
|
if (minTaskNum == 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if (i != 0) { |
|
|
|
|
if (currGoodsQty < minGoodsQty) { |
|
|
|
|
@ -761,7 +762,7 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("保险杠分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum+" 当前库存量:"+currGoodsQty); |
|
|
|
|
log.info("保险杠分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("巷道的任务数量:" + JsonUtil.toJSONString(tunnelResult)); |
|
|
|
|
@ -791,59 +792,267 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized Result<BaseLocationVo> assignEmptyLocationAll(AssingEmptyLocBo assingEmptyLocBo) { |
|
|
|
|
BaseLocationVo locationVo = null; |
|
|
|
|
//bo等于空时,是空治具分配货位,否则是保险杠分配货位
|
|
|
|
|
if (assingEmptyLocBo == null) { |
|
|
|
|
//获取立库区的空治具存放区域编号
|
|
|
|
|
Long emptyconArea = Long.valueOf(sysParameterService.selectConfigByKey(SecurityUtils.getCurrentBranchId(), ParameterConstants.ParameterSystem.emptycon_area)); |
|
|
|
|
List<BaseLocationVo> baseLocationVos = baseLocationMapper.getLocationByAreaId(emptyconArea); |
|
|
|
|
if (baseLocationVos.size() > 0) { |
|
|
|
|
locationVo = baseLocationVos.get(0); |
|
|
|
|
} else { |
|
|
|
|
return Result.err().msg("空台车分配货位暂无空货位可用"); |
|
|
|
|
} |
|
|
|
|
log.info("给空治具分配货位查询到的货位信息:" + JsonUtil.toJSONString(locationVo)); |
|
|
|
|
|
|
|
|
|
//存放空治具货位所在巷道列表
|
|
|
|
|
List<String> tunnelList = baseLocationVos.stream().map(e -> e.getTunnel()).distinct().collect(Collectors.toList()); |
|
|
|
|
log.info("存放空治具货位所在巷道列表:" + JsonUtil.toJSONString(tunnelList)); |
|
|
|
|
//从存在存放空治具货位的巷道里选择较优的巷道进行入库
|
|
|
|
|
//首选选择任务数为空或者任务数最少的巷道
|
|
|
|
|
//任务数相同时选取存放空治具货位最多的巷道
|
|
|
|
|
List<String> tunnelResult = new ArrayList<>(); |
|
|
|
|
Integer minTaskNum = 0; |
|
|
|
|
Integer maxEmptyLocationNum = 0; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tunnelList.size(); i++) { |
|
|
|
|
String tunnel = tunnelList.get(i); |
|
|
|
|
Integer taskNum = tunnelTaskUtil.getTotalTaskNum(tunnel, 0); |
|
|
|
|
int curEmptyNum = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()).size(); |
|
|
|
|
log.info("空治具分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum); |
|
|
|
|
if (minTaskNum == 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if (i != 0) { |
|
|
|
|
if (curEmptyNum > maxEmptyLocationNum) { |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum == 0) { |
|
|
|
|
if (i == 0) { |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum != 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if (curEmptyNum > maxEmptyLocationNum) { |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum != 0 && taskNum < minTaskNum) { |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("空治具分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum); |
|
|
|
|
} |
|
|
|
|
//从选取的巷道中选择库位
|
|
|
|
|
if (tunnelResult.size() > 0) { |
|
|
|
|
String tunnel = tunnelResult.get(0); |
|
|
|
|
log.info("空治具选择的巷道:" + tunnel); |
|
|
|
|
List<BaseLocationVo> resultLocationList = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); |
|
|
|
|
locationVo = resultLocationList.get(0); |
|
|
|
|
log.info("空治具分配到的货位信息:" + JsonUtil.toJSONString(locationVo)); |
|
|
|
|
//巷道中货位数大于1时,进行分配
|
|
|
|
|
if (resultLocationList.size() > 1) { |
|
|
|
|
locationVo = iBusinEnptyContainerService.assginLocation(resultLocationList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
List<BusinDataTaskGoodsVo> businDataTaskGoodsVos = assingEmptyLocBo.getBusinDataTaskGoodsVos(); |
|
|
|
|
String goodsNo = assingEmptyLocBo.getGoodsNo(); |
|
|
|
|
String vehicheModel = assingEmptyLocBo.getVehicheModel(); |
|
|
|
|
String batch = assingEmptyLocBo.getBatch(); |
|
|
|
|
if (businDataTaskGoodsVos != null && businDataTaskGoodsVos.size() > 0) { |
|
|
|
|
BusinDataTaskGoodsVo businDataTaskGoodsVo = businDataTaskGoodsVos.get(0); |
|
|
|
|
String taskCode = businDataTaskGoodsVo.getTaskCode(); |
|
|
|
|
log.info("分配货位任务号:" + taskCode + " 保险杠编号:" + goodsNo); |
|
|
|
|
} |
|
|
|
|
BaseLocationQueryListBo bo = new BaseLocationQueryListBo(); |
|
|
|
|
bo.setGoodsNo(goodsNo); |
|
|
|
|
bo.setLocationStatus("0"); |
|
|
|
|
log.info("保险杠分配货位查询条件:" + JsonUtil.toJSONString(bo)); |
|
|
|
|
List<BaseLocationVo> baseLocationVos = this.baseMapper.queryBaseLocationListByGoods(bo); |
|
|
|
|
if (baseLocationVos.size() == 0) { |
|
|
|
|
//查看缓冲区是否还有货位
|
|
|
|
|
Long bufferArea = Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.buffer_area)); |
|
|
|
|
List<BaseLocationVo> baseLocationVoList = baseLocationMapper.getLocationByAreaId(bufferArea); |
|
|
|
|
log.info("保险杠缓冲区分配到的货位信息:" + baseLocationVoList.size()); |
|
|
|
|
if (baseLocationVoList.size() < 0) { |
|
|
|
|
log.info("车型及缓冲区都未查询到空货位"); |
|
|
|
|
return Result.err().msg("保险杠分配货位暂无空货位可用"); |
|
|
|
|
} |
|
|
|
|
//baseLocationVos.addAll(baseLocationVoList);
|
|
|
|
|
baseLocationVos = baseLocationVoList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//拿到所有可用货位,根据巷道号对双深位的巷道进行处理
|
|
|
|
|
//空货位所在巷道列表,同时过滤掉已有入库任务的巷道
|
|
|
|
|
List<String> tunnelList = baseLocationVos.stream().map(e -> e.getTunnel()).distinct().collect(Collectors.toList()); |
|
|
|
|
log.info("保险杠分配货位查询到的货位对应的巷道信息:" + JsonUtil.toJSONString(tunnelList)); |
|
|
|
|
if (vehicheModel.contains("3UE")) { |
|
|
|
|
for (int i = 0; i < tunnelList.size(); i++) { |
|
|
|
|
if (tunnelList.get(i).contains("1") || tunnelList.get(i).contains("6")) { |
|
|
|
|
tunnelList.remove(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//从存在空货位的巷道里选择较优的巷道进行入库
|
|
|
|
|
//首选选择任务数为空或者任务数最少的巷道
|
|
|
|
|
//任务数相同时选取空货位最多的巷道;24.06.27改为查询库存数量最少并且空货位数最多的
|
|
|
|
|
List<String> tunnelResult = new ArrayList<>(); |
|
|
|
|
Integer minTaskNum = 0; |
|
|
|
|
Integer maxEmptyLocationNum = 0; |
|
|
|
|
Integer minGoodsQty = 0; |
|
|
|
|
for (int i = 0; i < tunnelList.size(); i++) { |
|
|
|
|
String tunnel = tunnelList.get(i); |
|
|
|
|
Integer taskNum = tunnelTaskUtil.getTotalTaskNum(tunnel, 0); |
|
|
|
|
List<BaseLocationVo> currTunnelLocationVos = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); |
|
|
|
|
int curEmptyNum = currTunnelLocationVos.size(); |
|
|
|
|
BaseLocationVo baseLocationVo = currTunnelLocationVos.get(0); |
|
|
|
|
int currGoodsQty = 0; |
|
|
|
|
if (baseLocationVo.getGoodQty() != null) { |
|
|
|
|
currGoodsQty = baseLocationVo.getGoodQty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取巷道内库存数量最少并且空货位数最多的
|
|
|
|
|
log.info("保险杠分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); |
|
|
|
|
if (minTaskNum == 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if (i != 0) { |
|
|
|
|
if (currGoodsQty < minGoodsQty) { |
|
|
|
|
minGoodsQty = currGoodsQty; |
|
|
|
|
if (curEmptyNum > maxEmptyLocationNum) { |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
minGoodsQty = currGoodsQty; |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum == 0) { |
|
|
|
|
if (i == 0) { |
|
|
|
|
minGoodsQty = currGoodsQty; |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum != 0 && taskNum.equals(minTaskNum)) { |
|
|
|
|
if (currGoodsQty < minGoodsQty) { |
|
|
|
|
minGoodsQty = currGoodsQty; |
|
|
|
|
if (curEmptyNum > maxEmptyLocationNum) { |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (minTaskNum != 0 && taskNum < minTaskNum) { |
|
|
|
|
minGoodsQty = currGoodsQty; |
|
|
|
|
minTaskNum = taskNum; |
|
|
|
|
tunnelResult.clear(); |
|
|
|
|
tunnelResult.add(tunnel); |
|
|
|
|
maxEmptyLocationNum = curEmptyNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("保险杠分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("巷道的任务数量:" + JsonUtil.toJSONString(tunnelResult)); |
|
|
|
|
//从选取的巷道中选择库位
|
|
|
|
|
if (tunnelResult.size() > 0) { |
|
|
|
|
String tunnel = tunnelResult.get(0); |
|
|
|
|
List<BaseLocationVo> resultLocationList = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); |
|
|
|
|
locationVo = resultLocationList.get(0); |
|
|
|
|
log.info("分配的货位:" + JsonUtil.toJSONString(locationVo)); |
|
|
|
|
//巷道中货位数大于1时,进行分配
|
|
|
|
|
if (resultLocationList.size() > 0) { |
|
|
|
|
//判断是否是双深位相关
|
|
|
|
|
BaseLocationVo assginLocation = assginLocation(resultLocationList, batch, vehicheModel, businDataTaskGoodsVos); |
|
|
|
|
if (assginLocation != null) { |
|
|
|
|
locationVo = assginLocation; |
|
|
|
|
log.info("最终分配的货位信息:" + assginLocation); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (locationVo != null) { |
|
|
|
|
//确定分配该库位,并将库位状态改为已分配
|
|
|
|
|
this.changeLocationStatus(locationVo.getId(), "4"); |
|
|
|
|
locationVo.setLocationStatus("4"); |
|
|
|
|
return Result.ok().data(locationVo); |
|
|
|
|
} else { |
|
|
|
|
// TODO 是否需要逻辑处理,如果在选取的巷道中货位为空时!!
|
|
|
|
|
return Result.err(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从选取的巷道中选择库位
|
|
|
|
|
private BaseLocationVo assginLocation(List<BaseLocationVo> locationList,String batch,String vehicheModel,List<BusinDataTaskGoodsVo> businDataTaskGoodsVos) { |
|
|
|
|
private BaseLocationVo assginLocation(List<BaseLocationVo> locationList, String batch, String vehicheModel, List<BusinDataTaskGoodsVo> businDataTaskGoodsVos) { |
|
|
|
|
BaseLocationVo resultLocationVo = null; |
|
|
|
|
//根据拣货路径选择最近一个货位
|
|
|
|
|
for (int i = 0; i < locationList.size(); i++) { |
|
|
|
|
BaseLocationVo locationVo = locationList.get(i); |
|
|
|
|
log.info("查询到的货位:"+JsonUtil.toJSONString(locationVo)); |
|
|
|
|
log.info("查询到的货位:" + JsonUtil.toJSONString(locationVo)); |
|
|
|
|
//如果该货位为双深位,则直接选择该库位
|
|
|
|
|
if ("2".equals(locationVo.getIsDeep())) { |
|
|
|
|
return locationVo; |
|
|
|
|
} else { |
|
|
|
|
// 检查该单深位是否有对应双深位;如果有
|
|
|
|
|
Result<BaseLocationVo> deepLocationResult = this.getDeepLocation(locationVo); |
|
|
|
|
log.info("单深位是否有双深位:单深位编号:"+locationVo.getLocationCode()+" 返回的双深位信息:"+deepLocationResult.getData()); |
|
|
|
|
log.info("单深位是否有双深位:单深位编号:" + locationVo.getLocationCode() + " 返回的双深位信息:" + deepLocationResult.getData()); |
|
|
|
|
if (HttpStatus.SUCCESS == deepLocationResult.getCode()) { |
|
|
|
|
BaseLocationVo deepLocation = deepLocationResult.getData(); |
|
|
|
|
Result<List<SysStockDetailVo>> sysStockDetailVoResult = iSysStockDetailService.queryByLocation(deepLocation.getId()); |
|
|
|
|
if (HttpStatus.SUCCESS == sysStockDetailVoResult.getCode()) { |
|
|
|
|
List<SysStockDetailVo> sysStockDetailVoList = sysStockDetailVoResult.getData(); |
|
|
|
|
log.info("双深位的保险杠信息:"+JsonUtil.toJSONString(sysStockDetailVoList)); |
|
|
|
|
int count= 0; |
|
|
|
|
log.info("双深位的保险杠信息:" + JsonUtil.toJSONString(sysStockDetailVoList)); |
|
|
|
|
int count = 0; |
|
|
|
|
|
|
|
|
|
List<String> stockGoodsNoList = sysStockDetailVoList.stream().map(SysStockDetailVo::getGoodsNo).distinct().collect(Collectors.toList()); |
|
|
|
|
log.info("双深位的保险杠条码信息:"+JsonUtil.toJSONString(stockGoodsNoList)); |
|
|
|
|
log.info("双深位的保险杠条码信息:" + JsonUtil.toJSONString(stockGoodsNoList)); |
|
|
|
|
List<String> taskGoodsNoList = businDataTaskGoodsVos.stream().map(BusinDataTaskGoodsVo::getGoodsNo).distinct().collect(Collectors.toList()); |
|
|
|
|
log.info("当前任务的保险杠信息:"+JsonUtil.toJSONString(taskGoodsNoList)); |
|
|
|
|
for (String str: taskGoodsNoList) { |
|
|
|
|
if(stockGoodsNoList.contains(str)){ |
|
|
|
|
log.info("当前任务的保险杠信息:" + JsonUtil.toJSONString(taskGoodsNoList)); |
|
|
|
|
for (String str : taskGoodsNoList) { |
|
|
|
|
if (stockGoodsNoList.contains(str)) { |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!batch.equals(sysStockDetailVoList.get(0).getBatch()) |
|
|
|
|
if (!batch.equals(sysStockDetailVoList.get(0).getBatch()) |
|
|
|
|
|| count != stockGoodsNoList.size() |
|
|
|
|
|| deepLocation.getLocationStatus().equals("2")){ |
|
|
|
|
log.info("当前批次:"+batch+" 双深位批次:"+sysStockDetailVoList.get(0).getBatch()); |
|
|
|
|
log.info("保险杠个数:"+count +"双深位保险杠个数:"+stockGoodsNoList.size()); |
|
|
|
|
|| deepLocation.getLocationStatus().equals("2")) { |
|
|
|
|
log.info("当前批次:" + batch + " 双深位批次:" + sysStockDetailVoList.get(0).getBatch()); |
|
|
|
|
log.info("保险杠个数:" + count + "双深位保险杠个数:" + stockGoodsNoList.size()); |
|
|
|
|
continue; |
|
|
|
|
}else{ |
|
|
|
|
if(deepLocation.getLocationStatus().equals("4")){ |
|
|
|
|
log.info("双深位货位已分配:"+deepLocation.getLocationCode()); |
|
|
|
|
} else { |
|
|
|
|
if (deepLocation.getLocationStatus().equals("4")) { |
|
|
|
|
log.info("双深位货位已分配:" + deepLocation.getLocationCode()); |
|
|
|
|
continue; |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
return locationVo; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
if(deepLocation.getLocationStatus().equals("0")){ |
|
|
|
|
log.info("双深位无库存,直接返回:"+JsonUtil.toJSONString(deepLocation)); |
|
|
|
|
} else { |
|
|
|
|
if (deepLocation.getLocationStatus().equals("0")) { |
|
|
|
|
log.info("双深位无库存,直接返回:" + JsonUtil.toJSONString(deepLocation)); |
|
|
|
|
return deepLocation; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.info("单深位货位,返回:"+locationVo); |
|
|
|
|
} else { |
|
|
|
|
log.info("单深位货位,返回:" + locationVo); |
|
|
|
|
return locationVo; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -883,10 +1092,9 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
return Result.err().msg("货位资料不存在!"); |
|
|
|
|
} else { |
|
|
|
|
//已分配
|
|
|
|
|
if((!"4".equals(status))&&"4".equals(location.getLocationStatus())){ |
|
|
|
|
if ((!"4".equals(status)) && "4".equals(location.getLocationStatus())) { |
|
|
|
|
tunnelTaskUtil.subInboundTaskNum(location.getTunnel()); |
|
|
|
|
} |
|
|
|
|
else if("4".equals(status)&&"0".equals(location.getLocationStatus())){ |
|
|
|
|
} else if ("4".equals(status) && "0".equals(location.getLocationStatus())) { |
|
|
|
|
tunnelTaskUtil.addInboundTaskNum(location.getTunnel()); |
|
|
|
|
} |
|
|
|
|
location.setLocationStatus(status); |
|
|
|
|
@ -897,7 +1105,7 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<BaseLocationVo> getTUunnel(String goodsId){ |
|
|
|
|
public List<BaseLocationVo> getTUunnel(String goodsId) { |
|
|
|
|
return this.baseMapper.gettunnel(goodsId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -908,7 +1116,7 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Result<List<BaseLocationDetailVo>> queryTargetLocation(BaseLocationUrgentBo bo){ |
|
|
|
|
public Result<List<BaseLocationDetailVo>> queryTargetLocation(BaseLocationUrgentBo bo) { |
|
|
|
|
List<BaseLocationDetailVo> list = baseMapper.queryTargetLocation(bo); |
|
|
|
|
return Result.ok().data(list); |
|
|
|
|
} |
|
|
|
|
|