Commit 1c3a58c3 zshaohui

1.双库位 移库问题 提交

1 个父辈 9757f181
......@@ -390,13 +390,13 @@ public class DualPosNameDeviceController {
if (loopCount >= 10) {
endStr = "F";
}
pos = taskService.dualPosNameFindEmptyPosForPutIn(storageList, barcode, "", "", needMovePosName, endStr);
pos = taskService.dualPosNameFindEmptyPosForMoveIn(storageList, barcode, "", "", needMovePosName, endStr);
if (pos == null) {
if ("F".equals(endStr)) {
} else {
endStr = "F";
pos = taskService.dualPosNameFindEmptyPosForPutIn(storageList, barcode, "", "", needMovePosName, endStr);
pos = taskService.dualPosNameFindEmptyPosForMoveIn(storageList, barcode, "", "", needMovePosName, endStr);
}
}
if (pos == null) {
......
......@@ -1622,4 +1622,124 @@ public class TaskService {
return null;
}
/**
* 查找可以移库的目标库位
*
* @param storageList
* @param barcode
* @return
*/
public StoragePos dualPosNameFindEmptyPosForMoveIn(List<Storage> storageList, Barcode barcode, String inRFID, String lastPosId,String needMovePosName,String endStr) 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.isFinished() || task.isCancel()){
continue;
}
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", "[{0}]料仓列表中未找到可用的料仓",new String[]{barcode.getBarcode()});
}
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 dualPosNameFindEmptyPosInStorages(barcode, availbleStorageList, hasOutTaskStorageIds, lastPosId,needMovePosName,endStr);
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!