Commit 08deb920 zshaohui

1.工单挑料问题修改

2.不按顺序出 提交
1 个父辈 174d18dc
package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.thread.FinalizableDelegatedExecutorService;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
......@@ -305,7 +306,7 @@ public class XLRBoxHandler extends BaseDeviceHandler {
//先提取出料口不为空的
List<DataLog> notEmptyExportList = new ArrayList<>();
for (DataLog dataLog : dataLogList) {
if (dataLog.isCheckOutTask() && !dataLog.isCancel() && !dataLog.isFinished() && !dataLog.isOnLine() && !dataLog.isInLine()) {
if (dataLog.isCheckOutTask() && dataLog.isWait() && cid.equals(dataLog.getCid())) {
String export = dataLog.getExport();
Boolean isBox = dataLog.getAppendData("isBox");
if (isBox == null) {
......@@ -316,66 +317,76 @@ public class XLRBoxHandler extends BaseDeviceHandler {
}
}
}
//最多有2个工单正在执行
List<DataLog> needOutTaskList = new ArrayList<>();
Map<String, List<DataLog>> map = notEmptyExportList.stream().collect(Collectors.groupingBy(DataLog::getExport));
for (String key : map.keySet()) {
List<DataLog> groupByList = map.get(key);
Collections.sort(groupByList, (o1, o2) -> {
//获取到站位相同的任务
List<DataLog> resultList = new ArrayList<>();
//获取到站位相同的任务
for (DataLog dataLog : notEmptyExportList) {
String export = dataLog.getExport();
String feederInfo = dataLog.getAppendData("feederInfo");
String feeder = StorageExportUtil.getCurrentExportFeeder(export);
if (feederInfo.startsWith(feeder)) {
resultList.add(dataLog);
}
}
if (resultList != null && !resultList.isEmpty()) {
Collections.sort(resultList, (o1, o2) -> {
String feederInfo1 = o1.getAppendData("feederInfo");
String feederInfo2 = o2.getAppendData("feederInfo");
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())) {
String feederInfo = dataLog.getAppendData("feederInfo");
String feeder = StorageExportUtil.getCurrentExportFeeder(key);
log.info("UM口对应的feeder为:" + feeder + ",当前任务的feeder为:" + feederInfo);
if (feederInfo.startsWith(feeder)) {
needOutTaskList.add(dataLog);
String lastExportMap = lastOutExportMap.get(cid);
log.info(cid+"对应的上一次出料口为:"+lastExportMap);
//获取到所有的出料口
List<String> allEportList = new ArrayList<>();
for (DataLog dataLog : resultList) {
String export = dataLog.getExport();
if (allEportList.isEmpty()) {
allEportList.add(export);
} else {
//smfcore.barcode.noMatchFeeder=出料口feeder[{0}]与当前物料feeder[{1}]不匹配
dataLog.setRemark(MessageUtils.getText("smfcore.barcode.noMatchFeeder",new String[]{feeder,feederInfo},new Locale(SecurityUtils.getCurrentUserLanguage()),"出料口feeder[{0}]与当前物料feeder[{1}]不匹配"));
taskService.updateQueueTask(dataLog);
if (!allEportList.contains(export)) {
allEportList.add(export);
}
}
}
}
String lastOutSourceId = lastOutSourceIdMap.get(cid);
allEportList = allEportList.stream().sorted().collect(Collectors.toList());
if (needOutTaskList != null && !needOutTaskList.isEmpty()) {
for (DataLog dataLog : needOutTaskList) {
if (StringUtils.isNotEmpty(lastOutSourceId)) {
if (!lastOutSourceId.equals(dataLog.getSourceId())) {
orderTask = dataLog;
break;
}
} else {
orderTask = dataLog;
int index = 0;
//寻找到对应的index
for (int i = 0; i < allEportList.size(); i++) {
String export = allEportList.get(i);
if (export.equals(lastExportMap)){
index = i;
break;
}
}
if (orderTask == null) {
needOutTaskList = needOutTaskList.stream().sorted(Comparator.comparing(DataLog::getCreateDate)).collect(Collectors.toList());
orderTask = needOutTaskList.get(0);
if (index != 0) {
index = index + 1;
if (index >= allEportList.size()) {
index = 0;
}
}
String nextExport = allEportList.get(index);
log.info(cid+"获取到下一个出料口为:"+nextExport);
for (DataLog dataLog : resultList) {
if (nextExport.equals(dataLog.getExport())){
orderTask = dataLog;
break;
}
}
}
if (orderTask != null) {
log.info("分配出库任务,站位号为:" + orderTask.getAppendData("feederInfo") + ",出料口为:" + orderTask.getExport() + ",barcode为:" + orderTask.getBarcode());
lastOutSourceIdMap.put(cid, orderTask.getSourceId());
lastOutExportMap.put(cid, orderTask.getExport());
} else {
lastOutSourceIdMap.put(cid, "");
lastOutExportMap.put(cid, "");
}
return orderTask;
}
Map<String, String> lastOutSourceIdMap = Maps.newConcurrentMap();
Map<String,String> lastOutExportMap = Maps.newConcurrentMap();
@Override
public DeviceType getDeviceType() {
......
......@@ -427,7 +427,7 @@ public class DefaultOrderFileListener implements IOrderFileListener {
}
return itemMap;
} catch (Exception ex) {
log.error("解析上传的工单出错:" + ex.toString());
log.error("解析上传的工单出错:" ,ex);
}finally {
if(csvRead != null){
csvRead.close();
......
......@@ -16,4 +16,5 @@ public class StorageExportDto {
private List<StorageExport> outDetailList;
private boolean showButton = true;
}
......@@ -557,7 +557,8 @@ public class JkemController {
@RequestMapping("/jkem/canPutInLine")
@AnonymousAccess
public ResultBean canPutInLine(String barcodeStr) {
CodeBean codeBean = codeResolve.resolveSingleCode(barcodeStr);
return ResultBean.newOkResult("");
/* CodeBean codeBean = codeResolve.resolveSingleCode(barcodeStr);
Barcode barcode = codeBean.getBarcode();
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "无效的条码");
......@@ -639,7 +640,7 @@ public class JkemController {
}
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")});
}
*/ }
@ApiOperation("获取出料口剩余数量")
......
......@@ -187,6 +187,36 @@ public class StorageExportController {
}
}
outDetailList = outDetailList.stream().sorted(Comparator.comparing(StorageExport::getExportName)).collect(Collectors.toList());
//判断是否隐藏按钮
boolean showButton = true;
boolean allEmpty = true;
for (StorageExport storageExport : outDetailList) {
List<StorageExportOutDetail> detailList = storageExport.getDetailList();
if (detailList != null && !detailList.isEmpty()){
allEmpty = false;
}
}
if (allEmpty){
showButton = false;
} else {
for (StorageExport storageExport : outDetailList) {
List<StorageExportOutDetail> detailList = storageExport.getDetailList();
if (detailList != null && !detailList.isEmpty()){
for (StorageExportOutDetail detail : detailList) {
if (StringUtils.isNotEmpty(detail.getBarcode())){
if (!OP_STATUS.ABNORMAL.name().equals(detail.getStatus())
&& !OP_STATUS.FINISHED.name().equals(detail.getStatus())
&& !OP_STATUS.CANCEL.name().equals(detail.getStatus())){
showButton = false;
break;
}
}
}
}
}
}
dto.setShowButton(showButton);
dto.setOutDetailList(outDetailList);
return dto;
}
......
......@@ -2,10 +2,12 @@ package com.neotel.smfcore.custom.Jkem21481.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.Jkem21481.bean.StorageExportOutDetail;
......@@ -17,6 +19,9 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -41,6 +46,9 @@ public class UmExportSettingController {
@Autowired
private TaskService taskService;
@Autowired
private IDataLogManager dataLogManager;
@ApiOperation("获取平板上出料口设置")
@RequestMapping("/getUmSetting")
......@@ -123,6 +131,23 @@ public class UmExportSettingController {
StorageExportOutDetailDto dto = StorageExportUtil.getFeederByBarcode(barcodeStr);
if (dto != null){
return ResultBean.newOkResult(dto);
} else {
log.info(barcodeStr+"对应的出料口任务为空,寻找最后一个出入库记录");
DataLog lastTask = dataLogManager.findOne(new Query(Criteria.where("barcode").is(barcodeStr)).with(Sort.by(Sort.Direction.DESC, "createDate")));
if (lastTask != null && lastTask.isCheckOutTask()){
String export = lastTask.getExport();
if (StringUtils.isNotEmpty(export)) {
String feederInfo = lastTask.getAppendData("feederInfo");
StorageExportOutDetailDto resultDto = new StorageExportOutDetailDto();
resultDto.setFeederInfo(feederInfo);
resultDto.setExport(export);
resultDto.setPartNumber(lastTask.getPartNumber());
resultDto.setBarcode(barcodeStr);
resultDto.setStatus(lastTask.getStatus());
resultDto.setLastStatus(lastTask.getStatus());
return ResultBean.newOkResult(resultDto);
}
}
}
return ResultBean.newErrorResult(-1,"smfcore.valueNotFind","未找到{0}[{1}]",new String[]{"feeder",barcodeStr});
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!