Commit 2a622d86 LN

1053:1.入库分配时优先分配无出库任务的料仓。2.获取料架数量时按照任务排序。3.出库任务查找:同时只发一个工单两个料架的出库任务。

1 个父辈 4389a1a8
......@@ -861,6 +861,13 @@ public class BarcodeRule {
rule = "PN[5:0:-1]|BATCH[2:0:-1]|LOT|QTY[2:0:-1]|RI|SP[5:0:-1]|EXPDATEdd-MM-yyyy[2:0:-1]|xxx|xxx|xxx";
rule = "PN[5:0:-1]|BATCH[2:0:-1]|LOT|QTY[2_7Q:0:-1]|RI|SP[5:0:-1]|EXPDATEdd-MM-yyyy[2:0:-1]|xxx|xxx|xxx";
codeStr="zBYHNMC3.41+250123|1TBYHNMC3.41|7Q1000|1TBYHNMC3.41|P466385|1PMT29F2T08EMHBFJ4-T:B";
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|XXX";
codeStr="=1+0x0-400x62=zJFSRW46.11+250205|1TJFSRW46.11|7Q404|1TJFSRW46.11|P530828|1PMT29F2T08ELLEEG7-QD:E";
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|XXX";
// rule="PN[1:0:-1]|BATCH[2:0:-1]|LOT[2:0:-1]|QTY[2_7Q:0:-1]|RI[1:0:-1]|SP[3:0:-1]|PRODATEyyyyMMdd[2:0:-1]|xxx";
BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){
......@@ -874,6 +881,7 @@ public class BarcodeRule {
System.out.println("Supllier:"+b.getProvider());
System.out.println("Memo:"+b.getMemo());
}else{
System.out.println("解析失败");
log.info("解析失败");
}
......
......@@ -908,6 +908,29 @@ public class BaseDeviceHandler implements IDeviceHandler {
return dataLogs;
}
protected StatusBean sendOutTaskToClient(DataLog outTask, StatusBean statusBean, Storage storage ) {
if (outTask != null) {
log.info("分配出库任务" + outTask.getBarcode() + "[" + outTask.getPosName() + "]到 " + storage.getCid());
outTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(outTask);
statusBean.setOp(OP.CHECKOUT);
String posName = outTask.getPosName();
Barcode codeObj = barcodeManager.findByBarcode(outTask.getBarcode());
int plateW = 0;
int plateH = 0;
if (codeObj != null) {
plateW = codeObj.getPlateSize();
plateH = codeObj.getHeight();
} else {
log.warn("出库无料仓位" + storage.getName() + "[" + posName + "]");
}
statusBean.addPosInfo(outTask.getBarcode(), posName, plateW, plateH, false);
log.info("出库" + storage.getName() + "[" + posName + "]物料[" + outTask.getBarcode() + "] 发送到客户端" + storage.getCid());
}
return statusBean;
}
/**
* 判断是否打开了亮灯指引功能
* @return
......
......@@ -23,13 +23,13 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.dao.IAlarmInfoDao;
import com.neotel.smfcore.core.system.service.po.AlarmInfo;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.micron1053.util.MicronDataCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
......@@ -97,11 +97,35 @@ public class RobotBoxHandler extends BaseDeviceHandler {
if (dataCache.getCache(Constants.CACHE_StopOut)) {
return statusBean;
}
String cid = statusBean.getCid();
// 任务根据时间排序。查找当前正在出的工单和料架 (入库任务不计算)
List<DataLog> allTasks=taskService.getAllTasks();
Collections.sort(allTasks);
List<String> shelfType=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= MicronDataCache.getShelfType(task);
if(!shelfType.contains(shelf)){
shelfType.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);
Collection<DataLog> queueTasks = taskService.getQueueTasks();
int executingOutTaskSize = 0;
DataLog outTask = null;
for (DataLog queueTask : queueTasks) {
......@@ -125,34 +149,33 @@ public class RobotBoxHandler extends BaseDeviceHandler {
outTask = null;
break;
}
outTask = queueTask;
if (queueTask.isUrgentReel()) {
outTask = queueTask;
break;
}
//如果料架>=2,当前任务的料架在已出料架中,可以直接出
//如果料架<2,且当前任务属于已出工单,可以直接出
//循环查找,当前任务不满足时查找下一个任务
String shelf = MicronDataCache.getShelfType(queueTask);
if (shelfType.size() < 2 || shelfType.contains(shelf)) {
//料架正确,工单为空,返回
if (ObjectUtil.isEmpty(queueTask.getSourceId())) {
outTask = queueTask;
break;
} else if (sourceIds.size() < 1 || sourceIds.contains(queueTask.getSourceId())) {
outTask = queueTask;
break;
}
}
}
}
}
}
if (outTask != null) {
log.info("分配出库任务" + outTask.getBarcode() + "[" + outTask.getPosName() + "]到 " + cid);
outTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(outTask);
statusBean.setOp(OP.CHECKOUT);
String posName = outTask.getPosName();
Barcode codeObj = barcodeManager.findByBarcode(outTask.getBarcode());
int plateW = 0;
int plateH = 0;
if (codeObj != null) {
plateW = codeObj.getPlateSize();
plateH = codeObj.getHeight();
} else {
log.warn("出库无料仓位" + storage.getName() + "[" + posName + "]");
}
statusBean.addPosInfo(outTask.getBarcode(), posName, plateW, plateH, false);
log.info("出库" + storage.getName() + "[" + posName + "]物料[" + outTask.getBarcode() + "] 发送到客户端" + cid);
}
statusBean= sendOutTaskToClient(outTask,statusBean,storage);
} catch (Exception e) {
log.error("出库出错", e);
......@@ -160,7 +183,6 @@ public class RobotBoxHandler extends BaseDeviceHandler {
return statusBean;
}
protected StatusBean handleFinished(StatusBean statusBean) {
Map<String, BoxStatusBean> statusOfBoxes = statusBean.getBoxStatus();
if (statusOfBoxes != null) {
......
package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
......@@ -16,15 +17,13 @@ import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.micron1053.util.MicronDataCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
@Slf4j
public class ThirdBoxHandler extends BaseDeviceHandler{
......@@ -83,17 +82,41 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
if (dataCache.getCache(Constants.CACHE_StopOut)) {
return statusBean;
}
String cid = statusBean.getCid();
// 任务根据时间排序。查找当前正在出的工单和料架 (入库任务不计算)
List<DataLog> allTasks=taskService.getAllTasks();
Collections.sort(allTasks);
List<String> shelfType=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= MicronDataCache.getShelfType(task);
if(!shelfType.contains(shelf)){
shelfType.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);
Collection<DataLog> queueTasks = taskService.getQueueTasks();
int executingOutTaskSize = 0;
DataLog outTask = null;
for (DataLog queueTask : queueTasks) {
if (queueTask.getCid().equals(cid)) {
//有入库任务不分配出库任务
if (queueTask.isPutInTask()) {
if (queueTask.isPutInTask()) {
return statusBean;
} else {
if (queueTask.isExecuting()) {
......@@ -111,34 +134,33 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
outTask = null;
break;
}
outTask = queueTask;
if (queueTask.isUrgentReel()) {
outTask = queueTask;
break;
}
//如果料架>=2,当前任务的料架在已出料架中,可以直接出
//如果料架<2,且当前任务属于已出工单,可以直接出
//循环查找,当前任务不满足时查找下一个任务
String shelf = MicronDataCache.getShelfType(queueTask);
if (shelfType.size() < 2 || shelfType.contains(shelf)) {
//料架正确,工单为空,返回
if (ObjectUtil.isEmpty(queueTask.getSourceId())) {
outTask = queueTask;
break;
} else if (sourceIds.size() < 1 || sourceIds.contains(queueTask.getSourceId())) {
outTask = queueTask;
break;
}
}
}
}
}
}
if (outTask != null) {
log.info("分配出库任务" + outTask.getBarcode() + "[" + outTask.getPosName() + "]到 " + cid);
outTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(outTask);
statusBean.setOp(OP.CHECKOUT);
String posName = outTask.getPosName();
Barcode codeObj = barcodeManager.findByBarcode(outTask.getBarcode());
int plateW = 0;
int plateH = 0;
if (codeObj != null) {
plateW = codeObj.getPlateSize();
plateH = codeObj.getHeight();
} else {
log.warn("出库无料仓位" + storage.getName() + "[" + posName + "]");
}
statusBean.addPosInfo(outTask.getBarcode(), posName, plateW, plateH, false);
log.info("出库" + storage.getName() + "[" + posName + "]物料[" + outTask.getBarcode() + "] 发送到客户端" + cid);
}
statusBean= sendOutTaskToClient(outTask,statusBean,storage );
} catch (Exception e) {
log.error("出库出错", e);
......
......@@ -19,7 +19,7 @@ import java.util.List;
@Data
@Document
public class DataLog extends BasePo implements Serializable {
public class DataLog extends BasePo implements Serializable ,Comparable<DataLog> {
public DataLog(){
......@@ -435,4 +435,9 @@ public class DataLog extends BasePo implements Serializable {
}
return false;
}
@Override
public int compareTo(DataLog o) {
return this.getId().compareTo(o.getId());
}
}
......@@ -702,11 +702,28 @@ public class TaskService {
}
});
return findEmptyPosInStorages(barcode, availbleStorageList, storageTaskCountMap, lastPosId);
return findEmptyPosInStorages(barcode, availbleStorageList, hasOutTaskStorageIds, lastPosId);
}
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Map<String, Integer> executingTaskCountMap, String lastPosId) {
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Set<String> hasOutTaskStorageIds, String lastPosId) {
//第一遍查找,先不查找有出库任务的料仓
for (Storage storage : availbleStorageList) {
if(hasOutTaskStorageIds.contains(storage.getId())){
continue;
}
try {
Collection<String> operatingPosIds = excludePosIds();
log.debug("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位");
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds, lastPosId);
if (pos != null) {
return pos;
}
} catch (Exception e) {
log.error("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位失败:" + e.getMessage());
}
}
//第二遍查找,从所有料仓中查找
for (Storage storage : availbleStorageList) {
try {
Collection<String> operatingPosIds = excludePosIds();
......@@ -719,7 +736,6 @@ public class TaskService {
log.error("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位失败:" + e.getMessage());
}
}
try {
String cids = "";
for (Storage storage : availbleStorageList) {
......
......@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -51,14 +52,21 @@ public class MicronDeviceController {
@ResponseBody
@AnonymousAccess
public ResultBean getTaskCount( HttpServletRequest request) {
// String type = request.getParameter("type");
// 根据时间排序,获取所有任务,Wait和已完成的 任务不发
List<DataLog> dataLogs = taskService.getAllTasks();
// String[] types=new String[]{"pizzaBox","pcb","tray","reel"};
Collections.sort(dataLogs);
Map<String, Integer> resultMap = new HashMap<>();
for (DataLog task : dataLogs
) {
if(task.isEnd()||task.isFinished()||task.isCancel()){
continue;
}
if(task.isCheckOutTask()&&task.isWait()){
continue;
}
String taskType = MicronDataCache.GetMaterialType(task);
String key = taskType + "_out";
if (task.isPutInTask()) {
......
......@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@RestController
......@@ -64,9 +61,18 @@ public class MicronML5Controller {
}
Map<String, Integer> needShelfs = new HashMap<>();
// 根据时间排序,获取所有任务,Wait和已完成的 任务不发
List<DataLog> dataLogs = taskService.getAllTasks();
Collections.sort(dataLogs);
for (DataLog task : dataLogs
) {
if(task.isPutInTask()|| task.isEnd()||task.isFinished()||task.isCancel()){
continue;
}
if(task.isCheckOutTask()&&task.isWait()){
continue;
}
String taskType = MicronDataCache.GetMaterialType(task);
String shelf = MicronDataCache.getShelfType(taskType);
if (needShelfs.containsKey(shelf)) {
......
......@@ -86,6 +86,10 @@ public class MicronDataCache {
public static String GetMaterialType(DataLog dataLog){
return GetMaterialType(dataLog.getCid(),dataLog.getStorageId(),dataLog.getW(),dataLog.getH());
}
public static String getShelfType(DataLog dataLog){
String mType=GetMaterialType(dataLog);
return getShelfType(mType);
}
public static String getShelfType(String materialType){
if(materialType.equals(PIZZABOX)){
return "M01";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!