Commit 31d914f3 zshaohui

1.出库任务分配逻辑修改

2.平板上扫码展示对应的出料口
1 个父辈 e66998d0
package com.neotel.smfcore.core.device.handler.impl; package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Maps;
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.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
...@@ -185,10 +187,10 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -185,10 +187,10 @@ public class XLRBoxHandler extends BaseDeviceHandler {
List<DataLog> dataLogList = new ArrayList<>(); List<DataLog> dataLogList = new ArrayList<>();
for (DataLog dataLog : allTasks) { for (DataLog dataLog : allTasks) {
if (dataLog.isPutInTask()){ if (dataLog.isPutInTask()) {
continue; continue;
} }
if (dataLog.isFinished() || dataLog.isCancel()){ if (dataLog.isFinished() || dataLog.isCancel()) {
continue; continue;
} }
/*for (StoragePos pos : usedPosList.values()) { /*for (StoragePos pos : usedPosList.values()) {
...@@ -274,7 +276,7 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -274,7 +276,7 @@ public class XLRBoxHandler extends BaseDeviceHandler {
String posName = task.getPosName(); String posName = task.getPosName();
if (!Strings.isNullOrEmpty(posName)) {//有库位号 if (!Strings.isNullOrEmpty(posName)) {//有库位号
Boolean isBox = task.getAppendData("isBox"); Boolean isBox = task.getAppendData("isBox");
if (isBox == null){ if (isBox == null) {
isBox = false; isBox = false;
} }
if (isBox) { if (isBox) {
...@@ -284,14 +286,14 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -284,14 +286,14 @@ public class XLRBoxHandler extends BaseDeviceHandler {
} }
} else { } else {
String barcode = task.getBarcode(); String barcode = task.getBarcode();
if (barcode.startsWith("T0") && barcode.length() == 9){ if (barcode.startsWith("T0") && barcode.length() == 9) {
boxTask = task; boxTask = task;
} }
} }
} }
} }
} }
if (boxTask != null){ if (boxTask != null) {
log.info("分配优先治具的出库任务" + boxTask.getBarcode() + "[" + boxTask.getPosName() + "]到 " + cid); log.info("分配优先治具的出库任务" + boxTask.getBarcode() + "[" + boxTask.getPosName() + "]到 " + cid);
return boxTask; return boxTask;
} }
...@@ -304,7 +306,7 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -304,7 +306,7 @@ public class XLRBoxHandler extends BaseDeviceHandler {
if (dataLog.isCheckOutTask() && !dataLog.isCancel() && !dataLog.isFinished() && !dataLog.isOnLine() && !dataLog.isInLine()) { if (dataLog.isCheckOutTask() && !dataLog.isCancel() && !dataLog.isFinished() && !dataLog.isOnLine() && !dataLog.isInLine()) {
String export = dataLog.getExport(); String export = dataLog.getExport();
Boolean isBox = dataLog.getAppendData("isBox"); Boolean isBox = dataLog.getAppendData("isBox");
if (isBox == null){ if (isBox == null) {
isBox = false; isBox = false;
} }
if (StringUtils.isNotEmpty(export) && !isBox) { if (StringUtils.isNotEmpty(export) && !isBox) {
...@@ -313,38 +315,86 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -313,38 +315,86 @@ public class XLRBoxHandler extends BaseDeviceHandler {
} }
} }
//获取到上一个出料口和下一个出料口
String lastOutExport = lastOutExportMap.get(cid);
List<String> nextOutExportList = getNextOutExport(lastOutExport);
log.info(cid + "对应的上一个出料口为:" + lastOutExport+"获取到的出料口顺序为:"+JSON.toJSONString(nextOutExportList));
//按出料口进行分组 //按出料口进行分组
Map<String, List<DataLog>> map = notEmptyExportList.stream().collect(Collectors.groupingBy(DataLog::getExport)); for (String nextOutExport : nextOutExportList) {
for (String key : map.keySet()) { Map<String, List<DataLog>> map = notEmptyExportList.stream().collect(Collectors.groupingBy(DataLog::getExport));
List<DataLog> groupByList = map.get(key); for (String key : map.keySet()) {
Collections.sort(groupByList, new Comparator<DataLog>() { if (!key.startsWith(nextOutExport)) {
@Override continue;
public int compare(DataLog o1, DataLog o2) { }
List<DataLog> groupByList = map.get(key);
Collections.sort(groupByList, (o1, o2) -> {
String feederInfo1 = o1.getAppendData("feederInfo"); String feederInfo1 = o1.getAppendData("feederInfo");
String feederInfo2 = o2.getAppendData("feederInfo"); String feederInfo2 = o2.getAppendData("feederInfo");
return feederInfo1.compareTo(feederInfo2); return feederInfo1.compareTo(feederInfo2);
});
DataLog dataLog = null;
if (groupByList != null && !groupByList.isEmpty()) {
dataLog = groupByList.get(0);
} }
}); if (dataLog != null && dataLog.isWait() && cid.equals(dataLog.getCid())) {
if (groupByList != null && !groupByList.isEmpty()) { String feederInfo = dataLog.getAppendData("feederInfo");
DataLog dataLog = groupByList.get(0); String feeder = StorageExportUtil.getCurrentExportFeeder(key);
if (cid.equals(dataLog.getCid())) { log.info("UM口对应的feeder为:" + feeder + ",当前任务的feeder为:" + feederInfo);
//判断出料口信息是否相同 if (feederInfo.startsWith(feeder)) {
if (dataLog.isWait()) { log.info("分配出库任务,站位号为:" + dataLog.getAppendData("feederInfo") + ",出料口为:" + key + ",barcode为:" + dataLog.getBarcode());
String feederInfo = dataLog.getAppendData("feederInfo"); orderTask = dataLog;
String feeder = StorageExportUtil.getCurrentExportFeeder(key); break;
log.info("UM口对应的feeder为:"+feeder+",当前任务的feeder为:"+feederInfo);
if (feederInfo.startsWith(feeder)) {
log.info("分配出库任务,站位号为:" + dataLog.getAppendData("feederInfo") + ",出料口为:" + key + ",barcode为:" + dataLog.getBarcode());
orderTask = dataLog;
break;
}
} }
} }
} }
if (orderTask != null) {
log.info(cid + "对应的下一个出料口为:" + orderTask.getExport());
break;
}
}
//如果没有找到,从头开始找
if (orderTask == null){
lastOutExportMap.put(cid,"");
} else {
lastOutExportMap.put(cid,orderTask.getExport());
} }
return orderTask; return orderTask;
} }
Map<String, String> lastOutExportMap = Maps.newConcurrentMap();
private static List<String> getNextOutExport(String lastOutExport) {
List<String> exportList = new ArrayList<>();
exportList.add("UM1");
exportList.add("UM5");
exportList.add("UM2");
exportList.add("UM6");
exportList.add("UM3");
exportList.add("UM7");
exportList.add("UM4");
exportList.add("UM8");
int index = 0;
if (StringUtils.isEmpty(lastOutExport)) {
return exportList;
}
for (int i = 0; i < exportList.size(); i++) {
String export = exportList.get(i);
if (lastOutExport.startsWith(export)) {
index = i;
break;
}
}
index = (index + 1) >= exportList.size() ? 0 : (index + 1);
List<String> resultList = new ArrayList<>();
for (int i = index; i < exportList.size(); i++) {
resultList.add(exportList.get(i));
}
return resultList;
}
@Override @Override
public DeviceType getDeviceType() { public DeviceType getDeviceType() {
return DeviceType.SMD_XLR; return DeviceType.SMD_XLR;
......
package com.neotel.smfcore.custom.Jkem21481.bean.dto;
import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail;
import lombok.Data;
@Data
public class StorageExportOutDetailDto extends StorageExportOutDetail {
private String export;
}
...@@ -603,15 +603,28 @@ public class JkemController { ...@@ -603,15 +603,28 @@ public class JkemController {
String feederInfo2 = o2.getAppendData("feederInfo"); String feederInfo2 = o2.getAppendData("feederInfo");
return feederInfo1.compareTo(feederInfo2); return feederInfo1.compareTo(feederInfo2);
}); });
//找到第一盘
DataLog dataLog = sameExportDatalogList.get(0); //获取到当前任务的坐标
if (dataLog.getBarcode().equals(task.getBarcode())){ int index = -1;
for ( int i = 0 ; i < sameExportDatalogList.size() ; i++) {
DataLog dataLog = sameExportDatalogList.get(i);
if (dataLog.getBarcode().equals(task.getBarcode())){
index = i;
break;
}
}
if (index <= 0){
log.info(task.getBarcode()+"为工单:"+task.getBarcode()+"任务的第一盘,直接返回ok,index为:"+index);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
//如果storageId一样的话,则直接进行出库 //找到上一盘
if (task.getStorageId().equals(dataLog.getStorageId())){ int lastIndex = index - 1;
log.info(task.getBarcode()+"对的的设备为"+task.getStorageName()+"与"+dataLog.getBarcode()+"的设备相同,直接出库"); DataLog dataLog = sameExportDatalogList.get(lastIndex);
if (task.getStorageId().equals(dataLog.getStorageId()) && !task.isWait() && !task.isExecuting()
&& !OP_STATUS.OUTBOX.name().equals(task.getStatus())
&& !OP_STATUS.OUTTING.name().equals(task.getStatus())) {
log.info(task.getBarcode() + "对的的设备为" + task.getStorageName() + "与" + dataLog.getBarcode() + "的设备相同,直接出库");
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
...@@ -624,6 +637,7 @@ public class JkemController { ...@@ -624,6 +637,7 @@ public class JkemController {
if (dataLog.isOnLine() || dataLog.isFinished() || dataLog.isCancel() || isBox){ if (dataLog.isOnLine() || dataLog.isFinished() || dataLog.isCancel() || isBox){
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
log.info(barcodeStr+" 上一盘的料盘为["+dataLog.getBarcode()+"],状态为["+status+"],对应的feeder为["+dataLog.getAppendData("feederInfo")+"],不允许放到皮带线上");
return ResultBean.newErrorResult(-1,"smf.barcode.cannotPutInLine","上一盘的料盘为[{0}],状态为[{1}],对应的feeder为[{2}],不允许放到皮带线上",new String[]{dataLog.getBarcode(),status,dataLog.getAppendData("feederInfo")}); return ResultBean.newErrorResult(-1,"smf.barcode.cannotPutInLine","上一盘的料盘为[{0}],状态为[{1}],对应的feeder为[{2}],不允许放到皮带线上",new String[]{dataLog.getBarcode(),status,dataLog.getAppendData("feederInfo")});
} }
......
...@@ -10,6 +10,7 @@ import com.neotel.smfcore.core.system.service.po.DataLog; ...@@ -10,6 +10,7 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail; import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail;
import com.neotel.smfcore.custom.Jkem21481.bean.UmSettingMacAndIp; import com.neotel.smfcore.custom.Jkem21481.bean.UmSettingMacAndIp;
import com.neotel.smfcore.custom.Jkem21481.bean.dto.StorageExportOutDetailDto;
import com.neotel.smfcore.custom.Jkem21481.util.StorageExportUtil; import com.neotel.smfcore.custom.Jkem21481.util.StorageExportUtil;
import com.neotel.smfcore.custom.Jkem21481.util.UmSettingUtil; import com.neotel.smfcore.custom.Jkem21481.util.UmSettingUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
...@@ -119,9 +120,9 @@ public class UmExportSettingController { ...@@ -119,9 +120,9 @@ public class UmExportSettingController {
taskService.updateFinishedTask(dataLog); taskService.updateFinishedTask(dataLog);
} }
StorageExportOutDetail detail = StorageExportUtil.getFeederByBarcode(barcodeStr); StorageExportOutDetailDto dto = StorageExportUtil.getFeederByBarcode(barcodeStr);
if (detail != null){ if (dto != null){
return ResultBean.newOkResult(detail); return ResultBean.newOkResult(dto);
} }
return ResultBean.newErrorResult(-1,"smfcore.valueNotFind","未找到{0}[{1}]",new String[]{"feeder",barcodeStr}); return ResultBean.newErrorResult(-1,"smfcore.valueNotFind","未找到{0}[{1}]",new String[]{"feeder",barcodeStr});
} }
......
...@@ -5,6 +5,7 @@ import com.neotel.smfcore.core.device.util.DataCache; ...@@ -5,6 +5,7 @@ import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.Jkem21481.bean.StorageExport; import com.neotel.smfcore.custom.Jkem21481.bean.StorageExport;
import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail; import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail;
import com.neotel.smfcore.custom.Jkem21481.bean.dto.StorageExportOutDetailDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -278,7 +279,7 @@ public class StorageExportUtil { ...@@ -278,7 +279,7 @@ public class StorageExportUtil {
dataCache.updateCache(EXPORT_PREFIX + "_" + export,storageExport); dataCache.updateCache(EXPORT_PREFIX + "_" + export,storageExport);
} }
public static StorageExportOutDetail getFeederByBarcode(String barcodeStr) { public static StorageExportOutDetailDto getFeederByBarcode(String barcodeStr) {
for (StorageExport export : exportMap.values()) { for (StorageExport export : exportMap.values()) {
List<StorageExportOutDetail> detailList = export.getDetailList(); List<StorageExportOutDetail> detailList = export.getDetailList();
if (detailList != null && !detailList.isEmpty()) { if (detailList != null && !detailList.isEmpty()) {
...@@ -286,7 +287,14 @@ public class StorageExportUtil { ...@@ -286,7 +287,14 @@ public class StorageExportUtil {
String barcode = detail.getBarcode(); String barcode = detail.getBarcode();
if (StringUtils.isNotEmpty(barcode)) { if (StringUtils.isNotEmpty(barcode)) {
if (barcode.equals(barcodeStr)){ if (barcode.equals(barcodeStr)){
return detail; StorageExportOutDetailDto dto = new StorageExportOutDetailDto();
dto.setBarcode(detail.getBarcode());
dto.setExport(export.getExportName());
dto.setStatus(detail.getStatus());
dto.setFeederInfo(detail.getFeederInfo());
dto.setPartNumber(detail.getPartNumber());
dto.setLastStatus(detail.getLastStatus());
return dto;
} }
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!