保险杠和空治具分配货位时合并统一方法处理

main
judy 1 year ago
parent aa33f6a202
commit 0158f1238e
  1. 29
      shkj-wms/src/main/java/com/shkj/wms/bo/AssingEmptyLocBo.java
  2. 39
      shkj-wms/src/main/java/com/shkj/wms/constants/ParameterConstants.java
  3. 20
      shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java
  4. 1
      shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java
  5. 3
      shkj-wms/src/main/java/com/shkj/wms/service/IBusinEnptyContainerService.java
  6. 364
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java
  7. 39
      shkj-wms/src/main/java/com/shkj/wms/service/impl/IBusinEnptyContainerServiceImpl.java
  8. 10
      shkj-wms/src/main/java/com/shkj/wms/service/impl/StackServiceImpl.java

@ -0,0 +1,29 @@
package com.shkj.wms.bo;
import com.shkj.wms.vo.BusinDataTaskGoodsVo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 分配货位Bo
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class AssingEmptyLocBo implements Serializable {
private static final long serialVersionUID = 1L;
private String goodsNo;
private String vehicheModel;
private String batch;
private List<BusinDataTaskGoodsVo> businDataTaskGoodsVos;
}

@ -56,13 +56,13 @@ public final class ParameterConstants {
//立库输送线plc地址
public final static String LK_plc_id="LK_plc_id";
public final static String LK_plc_id = "LK_plc_id";
//空治具放置区
public final static String en_point = "outbound_point";
//临时目标接驳点
public final static String target_point = "target_point";
public final static String target_point = "target_point";
//临时PLCID
public final static String plc_id = "PLCID";
@ -73,56 +73,56 @@ public final class ParameterConstants {
//待补货区
public final static String outbound_point = "outbound_point";
//人工下挂点
public final static String Manual_drop_point= "Manual_drop_point";
public final static String Manual_drop_point = "Manual_drop_point";
//紧急出库接驳点点位 分组
public final static String urgency_out_point="urgency_out_point";
public final static String urgency_out_point = "urgency_out_point";
//紧急出库接驳点点位
public final static String urgent_out_point="urgent_out_point";
public final static String urgent_out_point = "urgent_out_point";
//平库入库接驳口
public final static String P_in01="KW18";
public final static String P_in01 = "KW18";
//平库出库接驳口
public final static String P_out01="P_out01";
public final static String P_out01 = "P_out01";
//保养区
public final static String Upkeep_piont="Upkeep_piont";
public final static String Upkeep_piont = "Upkeep_piont";
//待补货区域
public final static String replenish_area = "replenish_area";
//缓冲区域
public final static String buffer_area="buffer_area";
public final static String buffer_area = "buffer_area";
//平库对应area表id
public final static String PinKu_area="PinKu_area";
public final static String PinKu_area = "PinKu_area";
//正常出库组装点
public final static String Assemble_point="Assemble_point";
public final static String Assemble_point = "Assemble_point";
// 组装线等待点位
public final static String m_points="m_points";
public final static String m_points = "m_points";
// 组装线上报点位
public final static String report_point="report_point";
public final static String report_point = "report_point";
// 组装线点位前杠
public final static String assemble_point_before="KW29";
public final static String assemble_point_before = "KW29";
// 组装线点位后杠
public final static String assemble_point_after="KW28";
public final static String assemble_point_after = "KW28";
//出库队列提前生成任务的分钟数
public final static String taskMinutes="taskMinutes";
public final static String taskMinutes = "taskMinutes";
//异常码头等待点位
public final static String abnormalWaitPint="abnormal_wait_point";
public final static String abnormalWaitPint = "abnormal_wait_point";
public final static String waitTaskNumber="wait_task_number";
public final static String waitTaskNumber = "wait_task_number";
//异常条码保险杠出库
public final static String abnormal_out_point="abnormal_out_point";
public final static String abnormal_out_point = "abnormal_out_point";
}
@ -142,5 +142,4 @@ public final class ParameterConstants {
}
}

@ -360,8 +360,14 @@ public class ScheduledTasks {
if (ObjectUtils.isEmpty(businDataTaskVo.getToRow())) {
// locationVoResult = iBaseLocationService.assignEmptyLocation(vehicheModel, color,DateUtils.getDate(),businDataTaskGoodsVos);
// TODO: 2024/6/28 zjx
locationVoResult = iBaseLocationService.assignEmptyLocationByStock(goodsNo, vehicheModel, DateUtils.getDate(), businDataTaskGoodsVos);
// locationVoResult = iBaseLocationService.assignEmptyLocationByStock(goodsNo, vehicheModel, DateUtils.getDate(), businDataTaskGoodsVos);
// 2024/07/18 zjx 分配货位统一方法
AssingEmptyLocBo emptyLocBo = new AssingEmptyLocBo();
emptyLocBo.setBatch(DateUtils.getDate());
emptyLocBo.setVehicheModel(vehicheModel);
emptyLocBo.setGoodsNo(goodsNo);
emptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVos);
locationVoResult=iBaseLocationService.assignEmptyLocationAll(emptyLocBo);
}
if (ObjectUtils.isNotEmpty(locationVoResult) && locationVoResult.getCode() == HttpStatus.SUCCESS.getCode()) {
@ -1952,7 +1958,15 @@ public class ScheduledTasks {
if (ObjectUtils.isEmpty(businDataTaskVo.getToRow())) {
// locationVoResult = iBaseLocationService.assignEmptyLocation(vehicheModel, color,DateUtils.getDate(),businDataTaskGoodsVos);
// TODO: 2024/6/28 zjx
locationVoResult = iBaseLocationService.assignEmptyLocationByStock(goodsNo, vehicheModel, DateUtils.getDate(), businDataTaskGoodsVos);
// locationVoResult = iBaseLocationService.assignEmptyLocationByStock(goodsNo, vehicheModel, DateUtils.getDate(), businDataTaskGoodsVos);
AssingEmptyLocBo emptyLocBo = new AssingEmptyLocBo();
emptyLocBo.setBatch(DateUtils.getDate());
emptyLocBo.setVehicheModel(vehicheModel);
emptyLocBo.setGoodsNo(goodsNo);
emptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVos);
locationVoResult=iBaseLocationService.assignEmptyLocationAll(emptyLocBo);
}
if (ObjectUtils.isNotEmpty(locationVoResult) && locationVoResult.getCode() == HttpStatus.SUCCESS.getCode()) {

@ -151,6 +151,7 @@ public interface IBaseLocationService extends IService<BaseLocation> {
Result<BaseLocationVo> assignEmptyLocationByStock( String goodsNo,String vehicheModel, String batch,List<BusinDataTaskGoodsVo> businDataTaskGoodsVos);
Result<BaseLocationVo> assignEmptyLocationAll(AssingEmptyLocBo assingEmptyLocBo);
/**
* 检查货位是否有对应双深位
*

@ -6,6 +6,7 @@ import com.shkj.wms.bo.BusinContainerUpkeepAddBo;
import com.shkj.wms.bo.BusinContainerUpkeepQueryBo;
import com.shkj.wms.domain.BaseContainer;
import com.shkj.wms.domain.BusinContainerUpkeep;
import com.shkj.wms.vo.BaseLocationVo;
import com.shkj.wms.vo.BusinContainerUpkeepVo;
import java.util.List;
@ -29,4 +30,6 @@ public interface IBusinEnptyContainerService extends IService<BaseContainer> {
* @return 结果
*/
public void emptyContainerFromWare();
BaseLocationVo assginLocation(List<BaseLocationVo> locationList);
}

@ -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);
}

@ -155,21 +155,37 @@ public class IBusinEnptyContainerServiceImpl extends ServiceImpl<BaseContainerMa
toPpoint = dataTaskVo.getTaskPath();
stuat=true;
}else if (stuats){
Map map = checkWareForEmptycon();
if(ObjectUtils.isEmpty(map)){
// Map map = checkWareForEmptycon();
AssingEmptyLocBo emptyLocBo = new AssingEmptyLocBo();
Result<BaseLocationVo> locationVoResult=iBaseLocationService.assignEmptyLocationAll(emptyLocBo);
if (!Result.isOk(locationVoResult)){
return Result.err().msg("暂无空治具存放区域");
}
pointDeviceVo = BeanUtil.toBean(map.get("basePointDeviceVo"),BasePointDeviceVo.class);
locationVo = BeanUtil.toBean(map.get("locationVo"),BaseLocationVo.class);
// pointDeviceVo = BeanUtil.toBean(map.get("basePointDeviceVo"),BasePointDeviceVo.class);
locationVo =locationVoResult.getData();
BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo();
pointQueryBo.setTunnel(locationVo.getTunnel());
pointQueryBo.setDirection("0");
List<BasePointDeviceVo> basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo);
if (basePointDeviceVos.size() > 0) {
basePointDeviceVo = basePointDeviceVos.get(0);
}
agvType= String.valueOf(RCSTaskTypeEnum.TO_B_AND_PUT.getValue());
toPpoint = pointDeviceVo.getPointNo();
dspPlcId=Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.LK_plc_id));
//获取巷道对应的堆垛机信息
BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo();
pointQueryBo.setDevType("1");
pointQueryBo.setTunnel(pointDeviceVo.getTunnel());
BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo);
BasePointDeviceQueryBo pointDeviceQueryBo = new BasePointDeviceQueryBo();
pointDeviceQueryBo.setDevType("1");
pointDeviceQueryBo.setTunnel(pointDeviceVo.getTunnel());
BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointDeviceQueryBo);
stkPlcId = baseDevicePlcVo.getPlcId();
tunnelId = baseDevicePlcVo.getTunnel();
@ -655,7 +671,8 @@ public class IBusinEnptyContainerServiceImpl extends ServiceImpl<BaseContainerMa
return dataTaskVo;
}
private BaseLocationVo assginLocation(List<BaseLocationVo> locationList) {
@Override
public BaseLocationVo assginLocation(List<BaseLocationVo> locationList) {
BaseLocationVo resultLocationVo = null;
//根据拣货路径选择最近一个货位
for (int i = 0; i < locationList.size(); i++) {
@ -692,6 +709,10 @@ public class IBusinEnptyContainerServiceImpl extends ServiceImpl<BaseContainerMa
return resultLocationVo;
}
/**
* 空治具分配货位
* @return
*/
public synchronized Map checkWareForEmptycon(){
//入库
//获取立库区的空治具存放区域编号

@ -308,7 +308,15 @@ public class StackServiceImpl implements IStackService {
//根据派生分配库位
// TODO: 2024/6/28 zjx
// Result<BaseLocationVo> locationVoResult = iBaseLocationService.assignEmptyLocation(vehicheModel,color, DateUtils.getDate(),businDataTaskGoodsVos);
Result<BaseLocationVo> locationVoResult = iBaseLocationService.assignEmptyLocationByStock( goodsNo, vehicheModel,DateUtils.getDate(),businDataTaskGoodsVos);
// Result<BaseLocationVo> locationVoResult = iBaseLocationService.assignEmptyLocationByStock( goodsNo, vehicheModel,DateUtils.getDate(),businDataTaskGoodsVos);
// 2024/07/18 zjx 分配货位统一方法
AssingEmptyLocBo emptyLocBo = new AssingEmptyLocBo();
emptyLocBo.setBatch(DateUtils.getDate());
emptyLocBo.setVehicheModel(vehicheModel);
emptyLocBo.setGoodsNo(goodsNo);
emptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVos);
Result<BaseLocationVo> locationVoResult=iBaseLocationService.assignEmptyLocationAll(emptyLocBo);
String agvno=null;
BaseLocationVo locationVo = locationVoResult.getData();

Loading…
Cancel
Save