Commit 03610c2f zshaohui

科博达修改和富士对接提交

1 个父辈 0c7ced91
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.barcode.service.po.Barcode;
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;
...@@ -9,13 +12,15 @@ import com.neotel.smfcore.core.device.enums.OP; ...@@ -9,13 +12,15 @@ import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.storage.enums.DeviceType; 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.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.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import lombok.extern.slf4j.Slf4j; 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.Map; import java.util.*;
import java.util.stream.Collectors;
/** /**
* XLR料仓 * XLR料仓
...@@ -48,7 +53,7 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -48,7 +53,7 @@ public class XLRBoxHandler extends BaseDeviceHandler {
statusBean = putInLine(storage, statusBean); statusBean = putInLine(storage, statusBean);
} else { } else {
//查看是否有要出库的操作 //查看是否有要出库的操作
statusBean =taskService.checkOut(storage, statusBean); statusBean =checkOut(storage, statusBean);
} }
//获取操作 //获取操作
Map<String, String> opMap = DevicesStatusUtil.getAndRemoveOp(cid); Map<String, String> opMap = DevicesStatusUtil.getAndRemoveOp(cid);
...@@ -92,6 +97,154 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -92,6 +97,154 @@ public class XLRBoxHandler extends BaseDeviceHandler {
} }
} }
/**
* 出库处理
*/
public StatusBean checkOut(Storage storage, StatusBean statusBean) {
try {
//准备更新暂停出入库
if (dataCache.getCache(Constants.CACHE_StopOut)) {
return statusBean;
}
String cid = storage.getCid();
//有入库任务的料仓不分配出库任务
if (!taskService.hasExecutingTask(cid, OP.PUT_IN)) {
DataLog task = findCheckoutBoxTask(storage);
if (task != null) {
//从等待列表中删除,加入到执行列表中
log.info("分配出库任务" + task.getBarcode() + "[" + task.getPosName() + "]到 " + cid);
task.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(task);
statusBean.setOp(OP.CHECKOUT);
String posName = task.getPosName();
Barcode codeObj = null;
StoragePos storagePos = storagePosManager.getByBarcode(task.getBarcode());
if (storagePos != null){
codeObj = storagePos.getBarcode();
}
if (codeObj == null) {
codeObj = barcodeManager.findByBarcode(task.getBarcode());
}
int plateW = 0;
int plateH = 0;
//是否是单盘出库,批量上下料使用
boolean isSingleOut = task.isSingleOut();
if (codeObj != null) {
plateW = codeObj.getPlateSize();
plateH = codeObj.getHeight();
if (codeObj.isOnlySingleOut()) {
log.info(codeObj.getBarcode() + " 只能单盘出库");
isSingleOut = true;
}
} else {
log.warn("出库无料仓位" + storage.getName() + "[" + posName + "]");
StoragePos pos=storagePosManager.getByPosName(posName);
plateW = pos.getW();
plateH = pos.getH();
}
String NgMsg=task.getAppendData("ngMsg");
boolean isNg=false;
if(ObjectUtil.isNotEmpty(NgMsg)){
isNg=true;
}
statusBean.addPosInfo(task.getBarcode(), posName, plateW, plateH, isSingleOut,isNg,NgMsg,0,task.getSourceName());
log.info("出库" + storage.getName() + "[" + posName + "]物料[" + task.getBarcode() + "]" + isSingleOut + "["+NgMsg+"]发送到客户端" + cid);
}
}
String posId = statusBean.getData().get("posId");
if (!Strings.isNullOrEmpty(posId)) {
log.info("SEQ:" + statusBean.getSeq() + "出库库位信息:[" + posId + "]发送到客户端");
}
} catch (Exception e) {
log.error("出库出错", e);
}
return statusBean;
}
/**
* 为 box 分配出库任务
*/
private DataLog findCheckoutBoxTask(Storage storage) {
String cid = storage.getCid();
int checkoutSize = 0;
Collection<DataLog> allTasks = taskService.getQueueTasks();
//按照库位的优先级进行排序
Map<String, StoragePos> usedPosList = dataCache.getUsedPosList(storage.getCid());
List<DataLog> dataLogList = new ArrayList<>();
for (DataLog dataLog : allTasks) {
for (StoragePos pos : usedPosList.values()) {
if (pos.getPosName().equals(dataLog.getPosName())){
dataLog.setPriority(pos.getPriority());
}
}
dataLogList.add(dataLog);
}
dataLogList = dataLogList.stream().sorted(Comparator.comparing(DataLog::getPriority)).collect(Collectors.toList());
for (DataLog task : dataLogList) {
if (!task.isCheckOutTask()) {
continue;
}
//如果该BOX在已执行任务中已经有入库任务,不再分配直接返回
if (cid.equals(task.getCid()) && task.isExecuting()) {
if (task.isPutInTask()) {
log.error("cid[" + cid + "]已有入库任务,不可再分配出库任务");
return null;
} else if (task.needReSendToClient() && task.isCheckOutTask()) {//超过30秒仍未完成的出库再次发送到客户端
log.error("cid[" + cid + "]的出库任务[" + task.getPosName() + "]"+task.getBarcode()+"超过60秒仍未完成,重新发送到客户端!");
task.setUpdateDate(new Date());
return task;
}
//只能同时有两个正在执行的出库任务,如果超过两个不再分配了
if (task.isCheckOutTask()) {
checkoutSize++;
if (checkoutSize >= 2) {
//log.error("cid["+cid + "]的BOX["+ boxId+"]的出库任务已经超过2个,不再分配!");
return null;
}
}
}
}
//指定紧急单盘出库的优先出库,否则按批量出库处理
DataLog singleOutTask = null;
DataLog outTask = null;
for (DataLog task : dataLogList) {//优先分配单盘任务和没有工单的任务
if (cid.equals(task.getCid()) && task.isCheckOutTask() && task.isWait()) {
String posName = task.getPosName();
if (!Strings.isNullOrEmpty(posName)) {//有库位号
if (task.isSingleOut()) {
//单盘优先出库
if (singleOutTask == null || task.getCreateDate().before(singleOutTask.getCreateDate())) {
singleOutTask = task;
}
} else {
if (outTask == null || task.getPriority() < outTask.getPriority()) {
outTask = task;
}
}
}
}
}
if (singleOutTask != null) {
log.info("分配优先(单盘或无工单)出库任务" + singleOutTask.getBarcode() + "[" + singleOutTask.getPosName() + "]到 " + cid);
return singleOutTask;
}
return outTask;
}
@Override @Override
public DeviceType getDeviceType() { public DeviceType getDeviceType() {
return DeviceType.SMD_XLR; return DeviceType.SMD_XLR;
......
...@@ -548,6 +548,7 @@ public class LiteOrderCache { ...@@ -548,6 +548,7 @@ public class LiteOrderCache {
task.setLightColor(nextColor.getRgb()); task.setLightColor(nextColor.getRgb());
task.setStatus(OP_STATUS.WAIT.name()); task.setStatus(OP_STATUS.WAIT.name());
task.setSingleOut(singleOut); task.setSingleOut(singleOut);
task.setLine(cacheOrder.getLine());
// task = dataLogDao.save(task); // task = dataLogDao.save(task);
taskService.addTaskToExecute(task); taskService.addTaskToExecute(task);
} }
......
...@@ -242,6 +242,13 @@ public class DataLog extends BasePo implements Serializable ,Comparable<DataLog> ...@@ -242,6 +242,13 @@ public class DataLog extends BasePo implements Serializable ,Comparable<DataLog>
*/ */
private MSDAppendInfo msdAppendInfo; private MSDAppendInfo msdAppendInfo;
/**
* 优先级
*/
private double priority = 0f;
private String line = "";
public String getBarcode() { public String getBarcode() {
if(barcode == null){ if(barcode == null){
return ""; return "";
......
...@@ -170,6 +170,11 @@ public class KebodaController { ...@@ -170,6 +170,11 @@ public class KebodaController {
} }
//先移除被锁定的库位
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
log.info(barcode.getBarcode()+"料盘重新入库,先移除被锁定的库位");
StoragePos pos = null; StoragePos pos = null;
int loopCount=0; int loopCount=0;
...@@ -340,5 +345,4 @@ public class KebodaController { ...@@ -340,5 +345,4 @@ public class KebodaController {
} }
return barcodeSave; return barcodeSave;
} }
} }
...@@ -5,6 +5,7 @@ import com.neotel.smfcore.common.utils.SmbUtil; ...@@ -5,6 +5,7 @@ import com.neotel.smfcore.common.utils.SmbUtil;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.nexim.bean.Notify; import com.neotel.smfcore.custom.nexim.bean.Notify;
import com.neotel.smfcore.custom.nexim.config.FileDirectoryConfig;
import com.neotel.smfcore.custom.nexim.enums.Action; import com.neotel.smfcore.custom.nexim.enums.Action;
import com.neotel.smfcore.custom.nexim.enums.NexObject; import com.neotel.smfcore.custom.nexim.enums.NexObject;
import com.neotel.smfcore.custom.nexim.util.NotifyUtil; import com.neotel.smfcore.custom.nexim.util.NotifyUtil;
...@@ -18,9 +19,6 @@ import java.io.File; ...@@ -18,9 +19,6 @@ import java.io.File;
@Slf4j @Slf4j
public class NeximApi extends BaseSmfApiListener { public class NeximApi extends BaseSmfApiListener {
private final String remoteFilePath = "smb://192.168.1.243/Test/";
@Override @Override
public boolean isForThisApi(String apiName) { public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("nexim"); return apiName != null && apiName.equalsIgnoreCase("nexim");
...@@ -29,24 +27,16 @@ public class NeximApi extends BaseSmfApiListener { ...@@ -29,24 +27,16 @@ public class NeximApi extends BaseSmfApiListener {
@Override @Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) { public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) { if (task.isFinished()) {
Notify notify = NotifyUtil.getNotifyByTask(Action.LOAD.name(), NexObject.CARRIER.name(), task); NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
//创建本地文件
String localFilePath = NotifyUtil.getLocalFilePathByNotify(notify);
boolean put = SmbUtil.smbPut(remoteFilePath, localFilePath);
log.info(localFilePath + "入库通知结果为:" + put);
FileUtil.del(new File(localFilePath));
} }
} }
@Override @Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) { public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isFinished()) { if (task.isFinished()) {
Notify notify = NotifyUtil.getNotifyByTask(Action.PROVIDE.name(), NexObject.CARRIER.name(), task); NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
//创建本地文件 NotifyUtil.createProvideEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getSourceName(),task.getLine(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
String localFilePath = NotifyUtil.getLocalFilePathByNotify(notify); NotifyUtil.createDeleteEtn(task.getBarcode(),task.getW(),task.getH(),task.getPartNumber(),FileDirectoryConfig.NOTIFY);
boolean put = SmbUtil.smbPut(remoteFilePath, localFilePath);
log.info(localFilePath + "出库通知结果为:" + put);
FileUtil.del(new File(localFilePath));
} }
} }
} }
package com.neotel.smfcore.custom.nexim.config;
public class FileDirectoryConfig {
//public static final String NOTIFY = "Remoteorder\\notify\\";
public static final String NOTIFY = "F:\\FUJI\\remoteorder\\notify\\";
//public static final String INPUT = "Remoteorder\\input\\";
public static final String INPUT = "F:\\FUJI\\remoteorder\\line\\";
public static final String OUTPUT = "Remoteorder\\output\\";
}
...@@ -19,12 +19,14 @@ import com.neotel.smfcore.core.storage.service.po.Storage; ...@@ -19,12 +19,14 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog; 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.nexim.NeximApi;
import com.neotel.smfcore.custom.nexim.bean.OrderReq; import com.neotel.smfcore.custom.nexim.bean.OrderReq;
import com.neotel.smfcore.custom.nexim.bean.OrderResp; import com.neotel.smfcore.custom.nexim.bean.OrderResp;
import com.neotel.smfcore.custom.nexim.enums.Action; import com.neotel.smfcore.custom.nexim.enums.Action;
import com.neotel.smfcore.custom.nexim.enums.ErrorCode; import com.neotel.smfcore.custom.nexim.enums.ErrorCode;
import com.neotel.smfcore.custom.nexim.enums.NexObject; import com.neotel.smfcore.custom.nexim.enums.NexObject;
import com.neotel.smfcore.custom.nexim.enums.OrderType; import com.neotel.smfcore.custom.nexim.enums.OrderType;
import com.neotel.smfcore.custom.nexim.util.NotifyUtil;
import com.neotel.smfcore.custom.nexim.util.OrderUtil; import com.neotel.smfcore.custom.nexim.util.OrderUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import jcifs.smb.SmbFile; import jcifs.smb.SmbFile;
...@@ -122,29 +124,37 @@ public class OrderHandler { ...@@ -122,29 +124,37 @@ public class OrderHandler {
public void init() { public void init() {
scheduledThreadPool.scheduleAtFixedRate(() -> { scheduledThreadPool.scheduleAtFixedRate(() -> {
try { try {
if("nexim".equals(smfApi.getApiName())) { if ("nexim".equals(smfApi.getApiName())) {
handler(); handler();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage());
} }
}, 10, 5, TimeUnit.SECONDS); }, 60, 10, TimeUnit.SECONDS);
} }
public static void handler() throws IOException { public static void handler() throws IOException {
String path = dataCache.getOrderSetting().getOrderDir(); String path = dataCache.getOrderSetting().getOrderDir();
log.info("开始执行工单,路径为:" + path);
File file = new File(path); File file = new File(path);
if (file.exists() && file.isDirectory()) { if (file.exists() && file.isDirectory()) {
String resultStr = "";
File[] files = file.listFiles(); File[] files = file.listFiles();
List<File> fileList = Arrays.stream(files).sorted(Comparator.comparing(File::lastModified).reversed()).collect(Collectors.toList()); List<File> fileList = Arrays.stream(files).sorted(Comparator.comparing(File::lastModified).reversed()).collect(Collectors.toList());
File currentFile = fileList.get(0); File currentFile = fileList.get(0);
List<String> lineList = OrderUtil.getLines(currentFile.getAbsolutePath(), StandardCharsets.US_ASCII); List<String> lineList = OrderUtil.getLines(currentFile.getAbsolutePath(), StandardCharsets.US_ASCII);
log.info("获取到line为:" + JSON.toJSONString(lineList));
String orderName = ""; String orderName = "";
String orderLine = "";
List<LiteOrderItem> orderItemList = new ArrayList<>(); List<LiteOrderItem> orderItemList = new ArrayList<>();
for (String line : lineList) { for (String line : lineList) {
resultStr = resultStr + line;
if (line.split("=").length < 2) { if (line.split("=").length < 2) {
continue; continue;
} }
...@@ -152,6 +162,9 @@ public class OrderHandler { ...@@ -152,6 +162,9 @@ public class OrderHandler {
if (line.startsWith("Name")) { if (line.startsWith("Name")) {
orderName = value; orderName = value;
} }
if (line.startsWith("ProdSite")){
orderLine = value;
}
if (line.startsWith("Item")) { if (line.startsWith("Item")) {
String[] itemStr = value.split("\\|", -1); String[] itemStr = value.split("\\|", -1);
...@@ -178,17 +191,25 @@ public class OrderHandler { ...@@ -178,17 +191,25 @@ public class OrderHandler {
} }
} }
int error = 0;
LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderName); LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderName);
if (liteOrder != null) { if (liteOrder == null) {
LiteOrder order = new LiteOrder();
order.setOrderItems(orderItemList);
order.setOrderNo(orderName);
order.setLine(orderLine);
liteOrderManager.createWithItems(order);
liteOrderCache.addOrderToMap(order);
} else {
return; return;
} }
LiteOrder order = new LiteOrder();
order.setOrderItems(orderItemList);
order.setOrderNo(orderName);
liteOrderManager.createWithItems(order);
liteOrderCache.addOrderToMap(order);
checkOutService.checkOutLiteOrder(orderName, false, false); resultStr = resultStr + "\n";
resultStr = resultStr +"[Result]";
resultStr = resultStr + "\n";
resultStr = resultStr + "Error="+error;
NotifyUtil.createOrderAns(file.getName(),resultStr);
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!