Commit e54d5eac LN

紧急出库 发给料仓出库时锁定位置

1 个父辈 308cbb27
...@@ -34,6 +34,7 @@ import com.neotel.smfcore.core.selfAudit.enums.SELFAUDIT_STATUS; ...@@ -34,6 +34,7 @@ import com.neotel.smfcore.core.selfAudit.enums.SELFAUDIT_STATUS;
import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditManager; import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditManager;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit; import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit;
import com.neotel.smfcore.core.selfAudit.util.SelfAuditUtil; import com.neotel.smfcore.core.selfAudit.util.SelfAuditUtil;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.core.storage.enums.DeviceType; import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
...@@ -984,6 +985,10 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -984,6 +985,10 @@ public class BaseDeviceHandler implements IDeviceHandler {
outTask.setStatus(OP_STATUS.EXECUTING.name()); outTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(outTask); taskService.updateQueueTask(outTask);
//如果是非工单任务,且还未绑定料架,绑定位置
if(ObjectUtil.isEmpty(outTask.getSourceName())&&ObjectUtil.isEmpty(outTask.getTempRfid())){
TaskShelfUtil.addLoc(outTask);
}
statusBean.setOp(OP.CHECKOUT); statusBean.setOp(OP.CHECKOUT);
String posName = outTask.getPosName(); String posName = outTask.getPosName();
Barcode codeObj = barcodeManager.findByBarcode(outTask.getBarcode()); Barcode codeObj = barcodeManager.findByBarcode(outTask.getBarcode());
......
package com.neotel.smfcore.core.device.handler.impl; package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.device.bean.BoxStatusBean; import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.BOX_STATUS; import com.neotel.smfcore.core.device.enums.BOX_STATUS;
...@@ -14,8 +16,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -14,8 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.*;
import java.util.Map;
@Service @Service
@Slf4j @Slf4j
...@@ -45,12 +46,105 @@ public class LineBoxHandler extends BaseDeviceHandler { ...@@ -45,12 +46,105 @@ public class LineBoxHandler extends BaseDeviceHandler {
statusBean = putInLine(storage, statusBean); statusBean = putInLine(storage, statusBean);
} else { } else {
//查看是否有要出库的操作 //查看是否有要出库的操作
statusBean =taskService.checkOut(storage, statusBean); // statusBean =taskService.checkOut(storage, statusBean);
findCheckOutTask(storage,statusBean);
} }
return statusBean; return statusBean;
} }
/**
* 出库处理
*/
public StatusBean findCheckOutTask(Storage storage, StatusBean statusBean) {
try {
//准备更新暂停出入库
if (dataCache.getCache(Constants.CACHE_StopOut)) {
return statusBean;
}
//如果当前有barcode,暂时不发出库任务
String sBarcode=statusBean.getBarcode();
if (ObjectUtil.isNotEmpty(sBarcode)) {
return statusBean;
}
String cid = statusBean.getCid();
// 任务根据时间排序。查找当前正在出的工单和料架 (入库任务不计算)
List<DataLog> allTasks=taskService.getAllTasks();
Collections.sort(allTasks);
//已出的料架列表 同时只能出三个,空不包含
List<String> shelfList=new ArrayList<>();
List<String> sourceIds=new ArrayList<>();
for (DataLog task :
allTasks) {
if(task.isPutInTask()|| task.isEnd()||task.isFinished()||task.isCancel()){
continue;
}
if(task.isCheckOutTask()&&task.isWait()){
continue;
}
String shelf=task.getTempRfid();
if(ObjectUtil.isNotEmpty(shelf)){
shelfList.add(shelf);
}
if(ObjectUtil.isNotEmpty(task.getSourceId())&&(!sourceIds.contains(task.getSourceId()))){
sourceIds.add(task.getSourceId());
}
}
//查询
List<DataLog> queueTasks=new ArrayList<>();
queueTasks.addAll(taskService.getQueueTasks());
Collections.sort(queueTasks);
int executingOutTaskSize = 0;
DataLog outTask = null;
for (DataLog queueTask : queueTasks) {
if (queueTask.getCid().equals(cid)) {
//有入库任务不分配出库任务
if (queueTask.isPutInTask()) {
// return statusBean;
continue;
} else {
if (queueTask.isExecuting()) {
executingOutTaskSize++;
//已经有出库任务正在执行,超过60秒仍未完成的出库再次发送到客户端
if (queueTask.needReSendToClient()) {
outTask = queueTask;
log.error("cid[" + cid + "]的出库任务[" + queueTask.getPosName() + "]超过60秒仍未完成,重新发送到客户端!");
queueTask.setUpdateDate(new Date());
break;
}
} else if (queueTask.isWait()) {
if (executingOutTaskSize >= 2) {
//log.error("cid["+cid + "]的BOX["+ boxId+"]的出库任务已经超过2个,不再分配!");
outTask = null;
break;
}
String shelf=queueTask.getTempRfid();
if (queueTask.isUrgentReel()||ObjectUtil.isEmpty(shelf)) {
outTask = queueTask;
break;
}
//已出的料架列表 同时只能出三个,空或紧急料不包含
if ( shelfList.size() <= 3 || shelfList.contains(shelf)) {
outTask = queueTask;
}
}
}
}
}
statusBean= sendOutTaskToClient(outTask,statusBean,storage);
} catch (Exception e) {
log.error("出库出错", e);
}
return statusBean;
}
@Override @Override
protected StatusBean handleInOutFinished(StatusBean statusBean) { protected StatusBean handleInOutFinished(StatusBean statusBean) {
......
...@@ -270,31 +270,31 @@ public class ShelfInfo { ...@@ -270,31 +270,31 @@ public class ShelfInfo {
} }
return false; return false;
} }
//
/** // /**
* 返回剩余的空库位,包含锁定和未锁定的 // * 返回剩余的空库位,包含锁定和未锁定的
* @return // * @return
*/ // */
public List<Integer> getEmptySlot() { // public List<Integer> getEmptySlot() {
List<Integer> result = new ArrayList<>(); // List<Integer> result = new ArrayList<>();
int smallEmpty = 0; // int smallEmpty = 0;
int bigEmpty = 0; // int bigEmpty = 0;
for (int i = 1; i <= maxLocCount; i++) { // for (int i = 1; i <= maxLocCount; i++) {
ShelfLoc shelfLoc = locMap.get(i); // ShelfLoc shelfLoc = locMap.get(i);
if (shelfLoc != null) { // if (shelfLoc != null) {
//
if (!shelfLoc.isEmpty()) { // if (!shelfLoc.isEmpty()) {
continue; // continue;
} // }
} // }
if (i <= MAX_F_SMALL_NUM) { // if (i <= MAX_F_SMALL_NUM) {
smallEmpty++; // smallEmpty++;
} else { // } else {
bigEmpty++; // bigEmpty++;
} // }
} // }
result.add(smallEmpty); // result.add(smallEmpty);
result.add(bigEmpty); // result.add(bigEmpty);
return result; // return result;
} // }
} }
...@@ -198,30 +198,6 @@ public class TaskShelfController { ...@@ -198,30 +198,6 @@ public class TaskShelfController {
ShelfInfo shelfInfo = TaskShelfUtil.findSameShelf(orderNo, rfid); ShelfInfo shelfInfo = TaskShelfUtil.findSameShelf(orderNo, rfid);
if (shelfInfo != null) { if (shelfInfo != null) {
// if(shelfInfo.getOrderNo().equals(TaskShelfUtil.DEFAULT_ORDERNO)){
// Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
// for (ShelfLoc shelfLoc : locMap.values()) {
// if (shelfLoc.isEmpty()) {
// if (shelfLoc.isSmallLoc()) {
// smallEmpty = smallEmpty + 1;
// } else if (shelfLoc.isBigLoc()) {
// bigEmpty = bigEmpty + 1;
// }
// }
// }
// }else {
// Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
// for (ShelfLoc shelfLoc : locMap.values()) {
// if (shelfLoc.isEmpty()) {
// if (shelfLoc.isSmallLoc()) {
// smallEmpty = smallEmpty + 1;
// } else if (shelfLoc.isBigLoc()) {
// bigEmpty = bigEmpty + 1;
// }
// }
// }
// }
List<Integer> shelfEmpty = getEmptySlot(shelfInfo); List<Integer> shelfEmpty = getEmptySlot(shelfInfo);
smallEmpty = shelfEmpty.get(0); smallEmpty = shelfEmpty.get(0);
bigEmpty = shelfEmpty.get(1); bigEmpty = shelfEmpty.get(1);
...@@ -267,7 +243,7 @@ public class TaskShelfController { ...@@ -267,7 +243,7 @@ public class TaskShelfController {
int bigEmpty = 0; int bigEmpty = 0;
if (shelfInfo != null) { if (shelfInfo != null) {
if (shelfInfo.getOrderNo().equals(TaskShelfUtil.DEFAULT_ORDERNO)) { if (shelfInfo.getOrderNo().equals(TaskShelfUtil.DEFAULT_ORDERNO)) {
List<DataLog> allTask=taskService.getAllTasks(); List<DataLog> allTask=taskService.getAllTasks();
for (DataLog log : for (DataLog log :
...@@ -282,13 +258,13 @@ public class TaskShelfController { ...@@ -282,13 +258,13 @@ public class TaskShelfController {
} }
} }
List<Integer> shelfEmpty=shelfInfo.getEmptySlot(); // List<Integer> shelfEmpty=shelfInfo.getEmptySlot();
if(smallEmpty>shelfEmpty.get(0)){ // if(smallEmpty>shelfEmpty.get(0)){
smallEmpty=shelfEmpty.get(0); // smallEmpty=shelfEmpty.get(0);
} // }
if(bigEmpty>shelfEmpty.get(1)){ // if(bigEmpty>shelfEmpty.get(1)){
bigEmpty=shelfEmpty.get(0); // bigEmpty=shelfEmpty.get(0);
} // }
} else { } else {
Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap(); Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
...@@ -326,12 +302,6 @@ public class TaskShelfController { ...@@ -326,12 +302,6 @@ public class TaskShelfController {
Integer emptyPos = 0; Integer emptyPos = 0;
ShelfInfo shelfInfo = TaskShelfUtil.findShelfByRealRfid(rfid); ShelfInfo shelfInfo = TaskShelfUtil.findShelfByRealRfid(rfid);
if (shelfInfo != null) { if (shelfInfo != null) {
// Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
// for (ShelfLoc shelfLoc : locMap.values()) {
// if (shelfLoc.isEmpty()) {
// emptyPos++;
// }
// }
List<Integer> shelfEmpty=getEmptySlot(shelfInfo); List<Integer> shelfEmpty=getEmptySlot(shelfInfo);
emptyPos = shelfEmpty.get(0)+shelfEmpty.get(1); emptyPos = shelfEmpty.get(0)+shelfEmpty.get(1);
} else { } else {
...@@ -348,13 +318,6 @@ public class TaskShelfController { ...@@ -348,13 +318,6 @@ public class TaskShelfController {
shelfInfoMap.values()) { shelfInfoMap.values()) {
for (ShelfInfo shelf : for (ShelfInfo shelf :
map.values()) { map.values()) {
// Map<Integer, ShelfLoc> locMap = shelf.getLocMap();
// int emptyPos = 0;
// for (ShelfLoc shelfLoc : locMap.values()) {
// if (shelfLoc.isEmpty()) {
// emptyPos++;
// }
// }
List<Integer> shelfEmpty=getEmptySlot(shelf); List<Integer> shelfEmpty=getEmptySlot(shelf);
int emptyPos = shelfEmpty.get(0)+shelfEmpty.get(1); int emptyPos = shelfEmpty.get(0)+shelfEmpty.get(1);
if (ObjectUtil.isNotEmpty(shelf.getRealRfid())) { if (ObjectUtil.isNotEmpty(shelf.getRealRfid())) {
...@@ -370,8 +333,6 @@ public class TaskShelfController { ...@@ -370,8 +333,6 @@ public class TaskShelfController {
log.error("getShelfEmptySlot 出错 rfids=" + rfids, e); log.error("getShelfEmptySlot 出错 rfids=" + rfids, e);
return ResultBean.newErrorResult(305, "", "出错:"+e.toString()); return ResultBean.newErrorResult(305, "", "出错:"+e.toString());
} }
// return ResultBean.newErrorResult(-1, "", "");
} }
...@@ -409,7 +370,7 @@ public class TaskShelfController { ...@@ -409,7 +370,7 @@ public class TaskShelfController {
} }
@ApiOperation("产线扫码亮灯") @ApiOperation("产线扫码亮灯,返回条码放到料架的位置:1-31")
@PostMapping(value = "/codeLed") @PostMapping(value = "/codeLed")
@ResponseBody @ResponseBody
@AnonymousAccess @AnonymousAccess
......
...@@ -279,8 +279,11 @@ public class TaskShelfUtil { ...@@ -279,8 +279,11 @@ public class TaskShelfUtil {
String orderNo = task.getSourceName(); String orderNo = task.getSourceName();
if(ObjectUtil.isEmpty(orderNo)){ if(ObjectUtil.isEmpty(orderNo)){
orderNo=DEFAULT_ORDERNO; orderNo=DEFAULT_ORDERNO;
//紧急料获取库位号时再锁定 //验证若还未锁定料架,锁定
addLoc(task); String tempRfid=task.getTempRfid();
if(ObjectUtil.isEmpty(tempRfid)) {
addLoc(task);
}
} }
ShelfInfo shelfInfo = null; ShelfInfo shelfInfo = null;
List<String> rfidList = Lists.newArrayList(rfidStr.split(ShelfSpilt)); List<String> rfidList = Lists.newArrayList(rfidStr.split(ShelfSpilt));
......
...@@ -20,6 +20,7 @@ import com.neotel.smfcore.core.device.util.DataCache; ...@@ -20,6 +20,7 @@ import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE; import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.rest.dto.TacticsOutDto; import com.neotel.smfcore.core.storage.rest.dto.TacticsOutDto;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
...@@ -483,6 +484,10 @@ public class TaskService { ...@@ -483,6 +484,10 @@ public class TaskService {
taskMap.put(task.getId(), task); taskMap.put(task.getId(), task);
task = dataLogDao.save(task); task = dataLogDao.save(task);
//如果是非工单任务,且还未绑定料架,绑定位置
if(ObjectUtil.isEmpty(task.getSourceName())&&ObjectUtil.isEmpty(task.getTempRfid())){
TaskShelfUtil.addLoc(task);
}
statusBean.setOp(OP.CHECKOUT); statusBean.setOp(OP.CHECKOUT);
String posName = task.getPosName(); String posName = task.getPosName();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!