Commit 7468555c sunke

入库时优先查找没有正在执行任务的库位

1 个父辈 a8a5d940
...@@ -460,6 +460,9 @@ public class InquiryShelfBean { ...@@ -460,6 +460,9 @@ public class InquiryShelfBean {
public ShelfInfo findMaxUsedShelf(String hSerial, String shelfType){ public ShelfInfo findMaxUsedShelf(String hSerial, String shelfType){
Map<String, ShelfInfo> shelfMap = hSerialShelfMap.get(hSerial); Map<String, ShelfInfo> shelfMap = hSerialShelfMap.get(hSerial);
if(shelfMap == null){
return null;
}
ShelfInfo minIndexShelf = null; ShelfInfo minIndexShelf = null;
for (ShelfInfo shelf : shelfMap.values()) { for (ShelfInfo shelf : shelfMap.values()) {
if(StorageConstants.SHEFL_TYPE.judgeType(shelfType, shelf.getShelfType())){ if(StorageConstants.SHEFL_TYPE.judgeType(shelfType, shelf.getShelfType())){
......
...@@ -252,7 +252,7 @@ public class ShelfInfo { ...@@ -252,7 +252,7 @@ public class ShelfInfo {
public boolean putInLimitLoc(String rfid, int rfidLoc, String barcode){ public boolean putInLimitLoc(String rfid, int rfidLoc, String barcode){
if(rfid.contains(shelfType)){//不是同一种料架的忽略 if(rfid.contains(shelfType)){//不是同一种料架的忽略
ShelfLoc shelfLoc = locMap.get(rfidLoc); ShelfLoc shelfLoc = locMap.get(rfidLoc);
if(shelfLoc.isInThisLoc(barcode)){ if(shelfLoc != null && shelfLoc.isInThisLoc(barcode)){
if(shelfLoc.isEmpty()){ if(shelfLoc.isEmpty()){
shelfLoc.putIn(barcode); shelfLoc.putIn(barcode);
locMap.put(rfidLoc, shelfLoc); locMap.put(rfidLoc, shelfLoc);
......
...@@ -368,7 +368,7 @@ public class DataLog extends BaseMongoBean /*implements Comparable<DataLog>*/ { ...@@ -368,7 +368,7 @@ public class DataLog extends BaseMongoBean /*implements Comparable<DataLog>*/ {
*/ */
public boolean needReSendToClient(){ public boolean needReSendToClient(){
if(isCheckOutTask() && isExecuting()){ if(isCheckOutTask() && isExecuting()){
return System.currentTimeMillis() - super.getUpdateDate().getTime() >= 60 * 1000; return System.currentTimeMillis() - super.getUpdateDate().getTime() >= 5 * 60 * 1000;
} }
return false; return false;
} }
......
...@@ -197,11 +197,12 @@ public class QisdaApiController extends BaseController { ...@@ -197,11 +197,12 @@ public class QisdaApiController extends BaseController {
} }
/** /**
* 关闭工单接口 * 检测料盘是否绑定工单
*/ */
@RequestMapping(value = "/closeSoSeq",method = RequestMethod.POST) @RequestMapping(value = "/closeSoSeq",method = RequestMethod.POST)
@ResponseBody @ResponseBody
public ResultBean closeSo(HttpServletRequest request) { public ResultBean closeSo(HttpServletRequest request) {
List<Map<String, String>> bindReelInfos = new ArrayList<>();
try { try {
String soseq = receiveParamInfo(request,"soseq"); String soseq = receiveParamInfo(request,"soseq");
log.info("收到检测锁定工单请求:"+soseq); log.info("收到检测锁定工单请求:"+soseq);
...@@ -381,6 +382,7 @@ public class QisdaApiController extends BaseController { ...@@ -381,6 +382,7 @@ public class QisdaApiController extends BaseController {
//其他工位绑定至少两盘才可以抢 //其他工位绑定至少两盘才可以抢
Barcode barcode = storagePos.getBarcode(); Barcode barcode = storagePos.getBarcode();
String bindSlot = barcode.getAppendInfo().getBindSlot(); String bindSlot = barcode.getAppendInfo().getBindSlot();
if(bindSlot != null){ if(bindSlot != null){
Integer reelCount = slotReelCountMap.get(bindSlot); Integer reelCount = slotReelCountMap.get(bindSlot);
if(reelCount == null){ if(reelCount == null){
...@@ -427,8 +429,12 @@ public class QisdaApiController extends BaseController { ...@@ -427,8 +429,12 @@ public class QisdaApiController extends BaseController {
String oldSlot = appendInfo.getBindSlot(); String oldSlot = appendInfo.getBindSlot();
log.info("首盘需求单["+hSerial+"]站位["+outItem.getSlotlocation()+"]缺料,从站位["+oldSlot+"]绑定料盘中抢夺料盘"+barcode.getBarcode()+"["+reelQty+"]进行绑定"); log.info("首盘需求单["+hSerial+"]站位["+outItem.getSlotlocation()+"]缺料,从站位["+oldSlot+"]绑定料盘中抢夺料盘"+barcode.getBarcode()+"["+reelQty+"]进行绑定");
OutItem oldItem = outItemDao.findItem(hSerial,Integer.valueOf(oldSlot)); OutItem oldItem = outItemDao.findItem(hSerial,Integer.valueOf(oldSlot));
oldItem.setRealLockQty(oldItem.getRealLockQty() - reelQty); if(oldItem != null){
outItemDao.save(oldItem); //不是预绑定的物料
oldItem.setRealLockQty(oldItem.getRealLockQty() - reelQty);
outItemDao.save(oldItem);
}
appendInfo.setBindSlot(outItem.getSlotlocation() + ""); appendInfo.setBindSlot(outItem.getSlotlocation() + "");
barcode.setAppendInfo(appendInfo); barcode.setAppendInfo(appendInfo);
...@@ -1104,8 +1110,9 @@ public class QisdaApiController extends BaseController { ...@@ -1104,8 +1110,9 @@ public class QisdaApiController extends BaseController {
QisdaApi.VMILocationOutFeedback(outItemList, lessBind); QisdaApi.VMILocationOutFeedback(outItemList, lessBind);
} }
} }
String msg = "需求单"+hSerial+"任务分配完成,共["+outReelNum+"]盘任务";
return "需求单"+hSerial+"任务分配完成,共["+outReelNum+"]盘任务"; log.info(msg);
return msg;
} }
......
...@@ -139,6 +139,9 @@ public class QisdaDeviceController extends BaseController { ...@@ -139,6 +139,9 @@ public class QisdaDeviceController extends BaseController {
log.info("返回机器人["+robotIndex+"]barcode=["+task.getBarcode()+"]的尺寸:" + task.getW()); log.info("返回机器人["+robotIndex+"]barcode=["+task.getBarcode()+"]的尺寸:" + task.getW());
return ResultBean.newOkResult(task.getW() + ""); return ResultBean.newOkResult(task.getW() + "");
}catch(ValidateException e){
log.warn("流水线获取尺寸信息出错:"+e.getMessage());
return ResultBean.newErrorResult(105,"流水线获取尺寸信息内部错误:" + e.getMessage());
}catch(Exception e){ }catch(Exception e){
log.error("流水线获取尺寸信息出错",e); log.error("流水线获取尺寸信息出错",e);
return ResultBean.newErrorResult(-1,"流水线获取尺寸信息内部错误:" + e.getMessage()); return ResultBean.newErrorResult(-1,"流水线获取尺寸信息内部错误:" + e.getMessage());
......
...@@ -564,23 +564,25 @@ public class TaskService implements ITaskService { ...@@ -564,23 +564,25 @@ public class TaskService implements ITaskService {
//查找任务数最少的料仓 //查找任务数最少的料仓
Map<String,Integer> countMap = new HashMap<>(); Map<String,Integer> executingTaskCountMap = new HashMap<>();
for (Storage storage : storageList) { for (Storage storage : storageList) {
countMap.put(storage.getId(), 0); executingTaskCountMap.put(storage.getId(), 0);
} }
//Set<String> hasOutTaskStorageIds = new HashSet<>(); Set<String> hasOutTaskStorageIds = new HashSet<>();
for (DataLog task : allTasks) { for (DataLog task : allTasks) {
String storageId = task.getStorageId(); String storageId = task.getStorageId();
if(!Strings.isNullOrEmpty(storageId)){ if(!Strings.isNullOrEmpty(storageId)){
Integer taskCount = countMap.get(storageId); Integer taskCount = executingTaskCountMap.get(storageId);
if(taskCount != null){ if(taskCount != null){
taskCount = taskCount + 1; if(task.isExecuting()){
countMap.put(storageId, taskCount); taskCount = taskCount + 1;
executingTaskCountMap.put(storageId, taskCount);
}
}
if(task.isCheckOutTask() && task.isExecuting()){
hasOutTaskStorageIds.add(storageId);
} }
// if(task.isCheckOutTask()){
// hasOutTaskStorageIds.add(storageId);
// }
} }
} }
...@@ -592,26 +594,38 @@ public class TaskService implements ITaskService { ...@@ -592,26 +594,38 @@ public class TaskService implements ITaskService {
if(status.timeOut()){ if(status.timeOut()){
continue; continue;
} }
// if(hasOutTaskStorageIds.contains(storage.getId())){
// //流水线有出库任务的,不分配入库任务(出库优先)
// continue;
// }
if(storage.canPutIn(barcode.getPlateSize(),barcode.getHeight())){ if(storage.canPutIn(barcode.getPlateSize(),barcode.getHeight())){
availbleStorageList.add(storage); availbleStorageList.add(storage);
} }
} }
//优先从没有出库任务的料仓中查找库位
for (Storage storage : availbleStorageList) { for (Storage storage : availbleStorageList) {
String storageId = storage.getId(); if(hasOutTaskStorageIds.contains(storage.getId())){
//流水线有出库任务的,暂不分配入库任务(出库优先)
continue;
}
Integer executingTaskCount = executingTaskCountMap.get(storage.getId());
if(executingTaskCount >= 1){
continue;
}
try{
log.info("尝试从无出库任务的料仓"+storage.getName()+"["+storage.getCid()+"]查找空位,当前料仓正在执行任务数:" + executingTaskCount);
return findLineEmptyPosForPutIn(storage,barcode);
}catch(Exception e){
log.info("从"+storage.getName()+"["+storage.getCid()+"]查找空位失败:" + e.getMessage());
}
}
Integer taskCount = countMap.get(storageId); for (Storage storage : availbleStorageList) {
if(taskCount >= 2){ Integer executingTaskCount = executingTaskCountMap.get(storage.getId());
if(executingTaskCount >= 2){
continue; continue;
} }
try{ try{
log.info("尝试从"+storage.getName()+"["+storage.getCid()+"]查找空位,当前料仓任务数:" + taskCount); log.info("尝试从"+storage.getName()+"["+storage.getCid()+"]查找空位,当前料仓正在执行任务数:" + executingTaskCount);
return findLineEmptyPosForPutIn(storage,barcode); return findLineEmptyPosForPutIn(storage,barcode);
}catch(Exception e){ }catch(Exception e){
log.info("从"+storage.getName()+"["+storage.getCid()+"]查找空位失败:" + e.getMessage()); log.info("从"+storage.getName()+"["+storage.getCid()+"]查找空位失败:" + e.getMessage());
...@@ -730,40 +744,6 @@ public class TaskService implements ITaskService { ...@@ -730,40 +744,6 @@ public class TaskService implements ITaskService {
return statusBean; return statusBean;
} }
// /**
// * 从库位中查找20条呆滞料,并生成任务保存到数据库中,返回生成的任务数
// */
// private List<DataLog> saveInactionTasks(InactionTaskSet inactionTaskSet){
// int day = inactionTaskSet.getDay();
// List<String> storageIds = dataCache.needClearInactionStorageIds();
// //每个料仓找5个
// int count = 3;
// List<StoragePos> list = Lists.newArrayList();
// for(String storageId : storageIds){
// List<StoragePos> storageList = storagePosManager.findInaction(Lists.<String>newArrayList(storageId), day, excludePosIds(), count);
// list.addAll(storageList);
// }
// List<DataLog> tasks = Lists.newArrayList();
// for (StoragePos pos : list){
// DataLog task = newTask(pos);
// task.setType(StorageConstants.OP.CHECKOUT);
// task.setStatus(StorageConstants.OP_STATUS.WAIT.name());
// //来源
// task.setSourceType(StorageConstants.TASK_SOURCE.INACTION.name());
// task.setSourceId(inactionTaskSet.getId());
// task.setSourceName(inactionTaskSet.getName());
// //将天数放在 subSourceId 中
// task.setSubSourceId(day+"");
// task.setSubSourceInfo("");
// tasks.add(task);
// }
// if(!tasks.isEmpty()){
// dataLogDao.insertAll(tasks);
// }
// return tasks;
//
// }
public DataLog newTask(StoragePos pos){ public DataLog newTask(StoragePos pos){
DataLog task = new DataLog(); DataLog task = new DataLog();
...@@ -918,8 +898,8 @@ public class TaskService implements ITaskService { ...@@ -918,8 +898,8 @@ public class TaskService implements ITaskService {
if(task.isPutInTask()){ if(task.isPutInTask()){
//log.error("cid["+cid + "]box["+boxId+"]已有入库任务,不可再分配出库任务"); //log.error("cid["+cid + "]box["+boxId+"]已有入库任务,不可再分配出库任务");
return null; return null;
}else if(task.needReSendToClient()){//超过30秒仍未完成的出库再次发送到客户端 }else if(task.needReSendToClient()){//超过300秒仍未完成的出库再次发送到客户端
log.error("cid["+cid + "]的出库任务["+ task.getPosName()+"]超过60秒仍未完成,重新发送到客户端!"); log.warn("cid["+cid + "]的出库任务["+task.getBarcode()+"]["+ task.getPosName()+"]超过300秒仍未完成,重新发送到客户端!");
task.setUpdateDate(new Date()); task.setUpdateDate(new Date());
return task; return task;
} }
...@@ -1439,7 +1419,7 @@ public class TaskService implements ITaskService { ...@@ -1439,7 +1419,7 @@ public class TaskService implements ITaskService {
} else if (StorageConstants.BOX_STATUS.OUT_FINISHED == status) {//出仓完成 } else if (StorageConstants.BOX_STATUS.OUT_FINISHED == status) {//出仓完成
DataLog task = findExecutingTask(statusBeanToSave.getCid(), boxStatus.getPosId()); DataLog task = findExecutingTask(statusBeanToSave.getCid(), boxStatus.getPosId());
if (task != null) { if (task != null) {
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成"); log.info("任务["+task.getId()+"]"+task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,当前状态:" + task.getStatus());
DataLog cancelTask = findFinishedTask(statusBeanToSave.getCid(), boxStatus.getPosId()); DataLog cancelTask = findFinishedTask(statusBeanToSave.getCid(), boxStatus.getPosId());
if(cancelTask != null && cancelTask.isCancel()){ if(cancelTask != null && cancelTask.isCancel()){
//将相同库位已经取消的任务从完成队列里删除 //将相同库位已经取消的任务从完成队列里删除
...@@ -1711,11 +1691,13 @@ public class TaskService implements ITaskService { ...@@ -1711,11 +1691,13 @@ public class TaskService implements ITaskService {
@Override @Override
public void addTaskToExecute(DataLog task) { public void addTaskToExecute(DataLog task) {
if(Strings.isNullOrEmpty(task.getOperator())){ // if(Strings.isNullOrEmpty(task.getOperator())){
String loginUser = StorageDataController.getLoginUsername(); // String loginUser = StorageDataController.getLoginUsername();
task.setOperator(loginUser); // task.setOperator(loginUser);
// }
if(Strings.isNullOrEmpty(task.getId())){
task = dataLogDao.save(task);
} }
task = dataLogDao.save(task);
taskMap.put(task.getId(),task); taskMap.put(task.getId(),task);
} }
...@@ -1972,7 +1954,12 @@ public class TaskService implements ITaskService { ...@@ -1972,7 +1954,12 @@ public class TaskService implements ITaskService {
Barcode barcode = storagePos.getBarcode(); Barcode barcode = storagePos.getBarcode();
if(barcode == null){ if(barcode == null){
log.warn("任务:"+task.getId() +" 仓位:"+task.getPosId()+" 的 Barcode 为null, 之前可能处理过直接返回"); //记录日志
task.setStatus(StorageConstants.OP_STATUS.OUTBOX.name());
taskMap.remove(task.getId());
finishedTaskMap.put(task.getBarcode(),task);
log.warn("任务:"+task.getBarcode() +" 仓位:"+task.getPosName()+" 的 Barcode 为null, 之前可能处理过直接返回");
return; return;
} }
...@@ -2010,7 +1997,14 @@ public class TaskService implements ITaskService { ...@@ -2010,7 +1997,14 @@ public class TaskService implements ITaskService {
dataLogDao.save(task); dataLogDao.save(task);
//从队列里面移除操作 //从队列里面移除操作
taskMap.remove(task.getId()); DataLog removeTask = taskMap.remove(task.getId());
try{
if(removeTask == null){
log.error(task.getBarcode()+"的出库任务["+task.getId()+"]清除失败");
}
}catch (Exception e){
}
finishedTaskMap.put(task.getBarcode(),task); finishedTaskMap.put(task.getBarcode(),task);
//dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</display:column> </display:column>
<display:column titleKey="checkOut.operate" media="html" sortProperty="sendStatus" sortable="true"> <display:column titleKey="checkOut.operate" media="html" sortProperty="sendStatus" sortable="true">
<c:if test="${!outInfo.sendEnd && outInfo.taskNum == 0 && !outInfo.closed}"> <c:if test="${!outInfo.sendEnd && !outInfo.closed}">
<button class="btn yellow" id="btn${outInfo.hSerial}" <button class="btn yellow" id="btn${outInfo.hSerial}"
onclick="executeOut('${outInfo.hSerial}')"> onclick="executeOut('${outInfo.hSerial}')">
<i class="fa fa-sign-out"></i><fmt:message key="button.checkout"/></button> <i class="fa fa-sign-out"></i><fmt:message key="button.checkout"/></button>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!