Commit 7155d3d7 LN

科博达移库问题修改

1 个父辈 5778df7a
......@@ -818,11 +818,21 @@ public class DeviceController {
// return ResultBean.newOkResult("");
// }
private String getLockPosSKey(String storageId ){
return Constants.XLR_lockPosS+"_"+storageId;
}
private String getLockPosKey(String storageId ){
return Constants.XLR_lockPos+"_"+storageId;
}
@ApiOperation("获取需要移动的库位是否有料")
@RequestMapping("/service/store/needMovePosHasReel")
@ResponseBody
@AnonymousAccess
public ResultBean needMovePosHasReel(@RequestBody Map<String, String> paramMap) {
// 2024-05-18 16:55:46.581 INFO [DeviceController.java:828] - 出库的库位为:20768A_02_A01_001S,需要移动的库位为:20768A_02_A01_001
// 2024-05-18 16:55:46.593 INFO [DeviceController.java:862] - 查找到锁定的外侧库位为目标库位:20768B_02_B01_008
String checkOutPosName = paramMap.get("checkOutPosName");
String needMovePosName = paramMap.get("needMovePosName");
log.info("出库的库位为:"+checkOutPosName+",需要移动的库位为:"+needMovePosName);
......@@ -850,13 +860,13 @@ public class DeviceController {
// log.info("提前锁定库位:" + checkOutPos.getPosName() + ",barcode为:" + barcode.getBarcode());
//有料,先查找锁定的lockS库位,有的话返回
ReelLockPosInfo lockPosInfo= ReelLockPosUtil.getLockPosInfoByCode(Constants.XLR_lockPosS);
ReelLockPosInfo lockPosInfo= ReelLockPosUtil.getLockPosInfoByCode(getLockPosSKey(needMovePos.getStorageId()));
if(lockPosInfo!=null&&ObjectUtil.isNotEmpty(lockPosInfo.getLockPosName())){
posName=lockPosInfo.getLockPosName();
log.info("查找到锁定的内侧库位为目标库位:"+posName+" ");
}
else{
lockPosInfo=ReelLockPosUtil.getLockPosInfoByCode(Constants.XLR_lockPos);
lockPosInfo=ReelLockPosUtil.getLockPosInfoByCode(getLockPosKey(needMovePos.getStorageId()));
if(lockPosInfo!=null&&ObjectUtil.isNotEmpty(lockPosInfo.getLockPosName())){
posName=lockPosInfo.getLockPosName();
log.info("查找到锁定的外侧库位为目标库位:"+posName+" ");
......@@ -874,7 +884,7 @@ public class DeviceController {
if(loopCount>=10 ){
log.info(barcode.getBarcode()+"已循环查找10次 直接跳出循环");
}
pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
pos = taskService.findEmptyPosForMoveIn(storageList, barcode, "", "");
if (pos == null){
break;
}
......@@ -899,18 +909,19 @@ public class DeviceController {
pos = null;
posName="";
}else {
log.info("查找到目标库位:"+pos.getPosName()+" 且外侧库位" + wPosName + "无料,锁定两个库位 :" + pos.getPosName() + "=" + Constants.XLR_lockPosS + ",wPosName=" + Constants.XLR_lockPos);
log.info("查找到目标库位:"+pos.getPosName()+" 且外侧库位" + wPosName + "无料,锁定两个库位 :" + pos.getPosName() + "=" +
getLockPosSKey(needMovePos.getStorageId()) + ",wPosName=" + getLockPosKey(needMovePos.getStorageId()));
//是内侧库位,且外侧库位也无料,锁定两个库位
AddLock(pos,Constants.XLR_lockPosS,cidList);
AddLock(pos,getLockPosSKey(needMovePos.getStorageId()),cidList);
AddLock(storagePos,Constants.XLR_lockPos,cidList);
AddLock(storagePos,getLockPosKey(needMovePos.getStorageId()),cidList);
}
}
}else {
//是外侧库位,直接锁定外侧库位
log.info("查找到外侧库位作为目标库位,锁定库位 :" + pos.getPosName() + "=" + Constants.XLR_lockPos);
log.info("查找到外侧库位作为目标库位,锁定库位 :" + pos.getPosName() + "=" + getLockPosKey(needMovePos.getStorageId()));
AddLock(pos,Constants.XLR_lockPos,cidList);
AddLock(pos,getLockPosKey(needMovePos.getStorageId()),cidList);
}
}
}
......@@ -1008,20 +1019,20 @@ public class DeviceController {
targetPos.setUsed(true);
targetPos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(targetPos);
log.info(barcode.getBarcode() + "转移库位,入库库位: " + needMovePos.getId() + "[" + needMovePos.getPosName() + "]");
log.info(barcode.getBarcode() + "转移库位,入库库位: " + targetPos.getId() + "[" + targetPos.getPosName() + "]");
dataCache.updateInventory(targetPos, barcode);
//解除库位绑定
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
ReelLockPosInfo lockS = ReelLockPosUtil.getLockPosInfoByCode(Constants.XLR_lockPosS);
ReelLockPosInfo lockS = ReelLockPosUtil.getLockPosInfoByCode(getLockPosSKey(needMovePos.getStorageId()));
if (lockS != null && ObjectUtil.isNotEmpty(lockS.getLockPosName()) && lockS.getLockPosName().equals(targetPosName)) {
ReelLockPosUtil.removeReelLockPosInfo(Constants.XLR_lockPosS);
ReelLockPosUtil.removeReelLockPosInfo(getLockPosSKey(needMovePos.getStorageId()));
} else {
ReelLockPosInfo lock = ReelLockPosUtil.getLockPosInfoByCode(Constants.XLR_lockPos);
ReelLockPosInfo lock = ReelLockPosUtil.getLockPosInfoByCode(getLockPosKey(needMovePos.getStorageId()));
if (lock != null && ObjectUtil.isNotEmpty(lock.getLockPosName()) && lock.getLockPosName().equals(targetPosName)) {
ReelLockPosUtil.removeReelLockPosInfo(Constants.XLR_lockPos);
ReelLockPosUtil.removeReelLockPosInfo(getLockPosKey(needMovePos.getStorageId()));
lock = null;
}
......@@ -1039,12 +1050,12 @@ public class DeviceController {
List<String> cidList = new ArrayList<>();
cidList.add(cid);
//如果两个库位锁定都为空了,将当前库位锁定为缓存库位
log.info("重新锁定两个缓存库位 :" + sPos.getPosName() + "=" + Constants.XLR_lockPosS + ","+needMovePos.getPosName()+"=" + Constants.XLR_lockPos);
log.info("重新锁定两个缓存库位 :" + sPos.getPosName() + "=" + getLockPosSKey(needMovePos.getStorageId()) + ","+needMovePos.getPosName()+"=" + getLockPosKey(needMovePos.getStorageId()));
//是内侧库位,且外侧库位也无料,锁定两个库位
AddLock(sPos,Constants.XLR_lockPosS,cidList);
AddLock(sPos,getLockPosSKey(needMovePos.getStorageId()),cidList);
AddLock(needMovePos,Constants.XLR_lockPos,cidList);
AddLock(needMovePos,getLockPosKey(needMovePos.getStorageId()),cidList);
}
}
......
......@@ -796,6 +796,123 @@ public class TaskService {
return findEmptyPosInStorages(barcode, availbleStorageList, hasOutTaskStorageIds, lastPosId);
}
/**
* 查找可以移库的目标库位
*
* @param storageList
* @param barcode
* @return
*/
public StoragePos findEmptyPosForMoveIn(List<Storage> storageList, Barcode barcode, String inRFID, String lastPosId) throws ValidateException {
Collection<DataLog> queueTasks = getQueueTasks();
List<DataLog> allTasksa = getFinishedTasks();
if (!queueTasks.isEmpty()) {
allTasksa.addAll(queueTasks);
}
for (DataLog task : allTasksa) {
if (task.isPutInTask()) {
if (task.getBarcode().equals(barcode.getBarcode())) {
//同一个条码的入库任务
for (Storage storage : storageList) {
if (task.getStorageId().equals(storage.getId()) && task.isPutInTask()) {
log.error("料盘["+barcode.getBarcode()+"]的操作未完成,无法执行入库操作");
throw new ValidateException("smfcore.error.barcode.taskNotEnd", "料盘[{0}}]的操作未完成,无法执行入库操作", new String[]{barcode.getBarcode()});
}
}
}
}
}
List<String> storageIds=new ArrayList<>();
//查找任务数最少的料仓
final Map<String, Integer> storageTaskCountMap = new HashMap<>();
for (Storage storage : storageList) {
storageTaskCountMap.put(storage.getId(), 0);
storageIds.add(storage.getId());
}
Set<String> hasOutTaskStorageIds = new HashSet<>();
//如果有正在执行的任务,把库位发过去
Collection<DataLog> allTasks = taskMap.values();
for (DataLog task : allTasks) {
if (barcode.getBarcode().equals(task.getBarcode())) {
String posId = task.getPosId();
log.info(barcode.getBarcode() + " 已有任务,返回任务中的库位:" + task.getPosName());
return storagePosManager.get(posId);
}
String storageId = task.getStorageId();
if (!Strings.isNullOrEmpty(storageId)) {
Integer taskCount = storageTaskCountMap.get(storageId);
if (taskCount != null) {
taskCount = taskCount + 1;
storageTaskCountMap.put(storageId, taskCount);
}
if (task.isCheckOutTask()) {
hasOutTaskStorageIds.add(storageId);
}
}
}
String lockPosId = ReelLockPosUtil.getReelLockPosId(barcode.getBarcode());
StoragePos pos = null;
if (!Strings.isNullOrEmpty(lockPosId)) {
//已有锁定库位
pos = storagePosManager.get(lockPosId);
if (pos != null) {
if(!storageIds.contains(pos.getStorageId())){
log.info("条码[" + barcode.getBarcode() + "]已有锁定库位[" + pos.getPosName() + "],料仓ID["+pos.getStorageId()+"]不在请求列表["+String.join(",",storageIds)+"]中,重新查找库位");
pos = null;
}
else if (pos.getW() < barcode.getPlateSize() || pos.getH() < barcode.getHeight()) {
log.info("条码[" + barcode.getBarcode() + "]尺寸已改变,无法放入已锁定库位[" + pos.getPosName() + "],重新查找库位");
pos = null;
} else {
Barcode posBarcode = pos.getBarcode();
if (posBarcode == null) {
log.info("条码[" + barcode.getBarcode() + "]已锁定库位[" + pos.getPosName() + "],返回锁定中的库位");
} else {
log.info("条码[" + barcode.getBarcode() + "]已锁定库位[" + pos.getPosName() + "]中已有物料[" + posBarcode.getBarcode() + "],重新查找库位");
pos = null;
}
}
}
}
if (pos != null) {
return pos;
}
//可用的料仓(在线,且可以放入)
List<Storage> availbleStorageList = new ArrayList<>();
for (Storage storage : storageList) {
if (storage.canPutIn(barcode.getPlateSize(), barcode.getHeight())) {
availbleStorageList.add(storage);
}
}
if (availbleStorageList.isEmpty()) {
throw new ValidateException("smfcore.noValidStorage", "料仓列表中未找到可用的料仓");
}
availbleStorageList.sort(new Comparator<Storage>() {
@Override
public int compare(Storage o1, Storage o2) {
Integer taskCount1 = storageTaskCountMap.get(o1.getId());
Integer taskCount2 = storageTaskCountMap.get(o2.getId());
return taskCount1.compareTo(taskCount2);
}
});
return findEmptyPosInStorages(barcode, availbleStorageList, hasOutTaskStorageIds, lastPosId);
}
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Set<String> hasOutTaskStorageIds, String lastPosId) {
//第一遍查找,先不查找有出库任务的料仓
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!