Commit 2ef4cf7e LN

ml5s使用新的获取库位号接口

1 个父辈 48ad9aed
...@@ -36,7 +36,7 @@ public class MicronApi { ...@@ -36,7 +36,7 @@ public class MicronApi {
public static boolean Debug=false; public static boolean Debug=true;
private static MicronConfig config; private static MicronConfig config;
@Autowired @Autowired
...@@ -90,6 +90,10 @@ public class MicronApi { ...@@ -90,6 +90,10 @@ public class MicronApi {
public static Barcode API001(String operationId,String rfid, Barcode barcode) throws ApiException { public static Barcode API001(String operationId,String rfid, Barcode barcode) throws ApiException {
if(Debug){
log.info("调用API001,调试状态直接返回");
return barcode;
}
String url = config.getUrl(config.api_name_001); String url = config.getUrl(config.api_name_001);
String errorMsg = ""; String errorMsg = "";
if (ObjectUtil.isEmpty(url)) { if (ObjectUtil.isEmpty(url)) {
...@@ -254,6 +258,20 @@ public class MicronApi { ...@@ -254,6 +258,20 @@ public class MicronApi {
public static Map<String,String> API002(String rfid, String operationId, List<StoragePos> storagePos) { public static Map<String,String> API002(String rfid, String operationId, List<StoragePos> storagePos) {
if(Debug){
log.info("调用API002,提示状态直接返回");
Map<String,String> result=new HashMap<>();
for (StoragePos pos :
storagePos) {
if(pos.getBarcode()==null){
continue;
}
result.put(pos.getBarcode().getBarcode(),"true");
}
return result;
}
String jobId=operationId+"_"+rfid; String jobId=operationId+"_"+rfid;
String url = config.getUrl(config.api_name_002); String url = config.getUrl(config.api_name_002);
...@@ -580,6 +598,18 @@ public class MicronApi { ...@@ -580,6 +598,18 @@ public class MicronApi {
public static Map<String,String> Api007(String operationId, String rfid, List<DataLog> dataLogList) { public static Map<String,String> Api007(String operationId, String rfid, List<DataLog> dataLogList) {
if(Debug){
Map<String,String> result=new HashMap<>();
for (DataLog dataLog:
dataLogList) {
result.put(dataLog.getBarcode(),"OK");
}
log.info("调用MES接口 API007: 调试状态直接返回");
return result;
}
String url = config.getUrl(config.api_name_007); String url = config.getUrl(config.api_name_007);
String errMsg = ""; String errMsg = "";
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
...@@ -874,7 +904,7 @@ public class MicronApi { ...@@ -874,7 +904,7 @@ public class MicronApi {
//出库前预扣 //出库前预扣
List<TrackStatus> statusList = new ArrayList<>(); List<TrackStatus> statusList = new ArrayList<>();
if (Debug) { if (Debug) {
long v = retryCount * (retryInterval + 60) * 1000; long v = retryCount * (retryInterval + 60) * 10;
try { try {
Thread.sleep(v); Thread.sleep(v);
log.info("调用MES接口 API010 Debug 模式,sleep=" + v); log.info("调用MES接口 API010 Debug 模式,sleep=" + v);
...@@ -1039,9 +1069,7 @@ public class MicronApi { ...@@ -1039,9 +1069,7 @@ public class MicronApi {
return statusList; return statusList;
} }
public static String Api011(String mode, String userName, String source) { public static String Api011(String mode, String userName, String source) {
if( Debug){
return mode+"_test_operationId";
}
// Mode = "MBR|REQ|MCL|GR|MATRET|RET|NPI|RACK|PCBPRETASK|MCLPRETASK|LINEPREP|CTRLDISPATCH" // Mode = "MBR|REQ|MCL|GR|MATRET|RET|NPI|RACK|PCBPRETASK|MCLPRETASK|LINEPREP|CTRLDISPATCH"
// Source = toolId, Facility+area for UI // Source = toolId, Facility+area for UI
String url = config.getUrl(config.api_name_011); String url = config.getUrl(config.api_name_011);
...@@ -1049,7 +1077,8 @@ public class MicronApi { ...@@ -1049,7 +1077,8 @@ public class MicronApi {
source=config.api_011_Source; source=config.api_011_Source;
} }
source="KTS-0001"; source="KTS-0001";
if(ObjectUtil.isEmpty(url)&&Debug){ if(ObjectUtil.isEmpty(url)||Debug){
log.info("调试状态直接返回,调用MES接口 Api011: url=" + url + " ");
return mode+"_test_operationId"; return mode+"_test_operationId";
} }
url = MessageFormat.format(url,mode,userName,source); url = MessageFormat.format(url,mode,userName,source);
...@@ -1145,7 +1174,7 @@ public class MicronApi { ...@@ -1145,7 +1174,7 @@ public class MicronApi {
String url = config.getUrl(config.api_name_012); String url = config.getUrl(config.api_name_012);
url = MessageFormat.format(url, operationId); url = MessageFormat.format(url, operationId);
if(Debug){ if(Debug){
log.info("调试状态直接返回true, 调用MES接口 Api012: url=" + url + " "); log.info("调试状态直接返回true, 调用MES接口 Api012: url=" + url + " ,operationId="+operationId+",action="+action);
return true; return true;
} }
try { try {
...@@ -1278,10 +1307,11 @@ public class MicronApi { ...@@ -1278,10 +1307,11 @@ public class MicronApi {
// "message": <ErrMessage>, // "message": <ErrMessage>,
// "detail": <ErrDetail> // "detail": <ErrDetail>
// } // }
String url = config.getUrl(config.api_name_201);
if(Debug){ if(Debug){
log.info("调试状态直接返回,调用MES接口 API201: url=" + url + " ");
return ""; return "";
} }
String url = config.getUrl(config.api_name_201);
url = MessageFormat.format(url, linePrepOrderId, operationId); url = MessageFormat.format(url, linePrepOrderId, operationId);
try { try {
...@@ -1325,6 +1355,8 @@ public class MicronApi { ...@@ -1325,6 +1355,8 @@ public class MicronApi {
return "NO"; return "NO";
} }
//以下接口为测试使用
public static MicronResult validateMRB(String mbrId, String skipSap) { public static MicronResult validateMRB(String mbrId, String skipSap) {
//Validate if MBR (From Warehouse )  is valid //Validate if MBR (From Warehouse )  is valid
// if (skipSap instanceof Boolean) { // if (skipSap instanceof Boolean) {
......
...@@ -25,7 +25,7 @@ public class TPMoveInfo implements Serializable { ...@@ -25,7 +25,7 @@ public class TPMoveInfo implements Serializable {
/** /**
* 当前正在移动的料盘信息 * 当前正在移动的料盘信息
*/ */
private String currMoveReel; private String reelId;
/** /**
* 取料位置 * 取料位置
......
...@@ -5,10 +5,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,10 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data @Data
public class ML5SViewDto implements Serializable { public class ML5SViewDto implements Serializable {
...@@ -30,6 +27,14 @@ public class ML5SViewDto implements Serializable { ...@@ -30,6 +27,14 @@ public class ML5SViewDto implements Serializable {
@ApiModelProperty("当前Loading信息名称,为空时可以点START,") @ApiModelProperty("当前Loading信息名称,为空时可以点START,")
private String currLoading = ""; private String currLoading = "";
@ApiModelProperty("当前loading创建时间")
private Date loadingCreateDate ;
@ApiModelProperty("当前loading已扫码盘数")
private int loadingScanQty ;
@ApiModelProperty("当前loading已分拣判断")
private int loadingIsShelfQty ;
@ApiModelProperty("仅显示的日志消息集合") @ApiModelProperty("仅显示的日志消息集合")
......
package com.neotel.smfcore.custom.micron1551.controller;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.enlog.EnLog;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.enums.INITEM.INITEM_STATUS;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
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.dao.IAlarmInfoDao;
import com.neotel.smfcore.core.system.service.po.AlarmInfo;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.micron1053.api.MicronApi;
import com.neotel.smfcore.custom.micron1053.loading.util.LoadingUtil;
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.boot.autoconfigure.session.StoreType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Api(tags = "1551 设备接口")
@RestController
@Slf4j
public class ML5DeviceController {
@Autowired
DataCache dataCache;
@Autowired
IBarcodeManager barcodeManager;
@Autowired
LoadingUtil loadingUtil;
@Autowired
protected TaskService taskService;
@Autowired
protected IStoragePosManager storagePosManager;
@Autowired
protected CodeResolve codeResolve;
@Autowired
private IAlarmInfoDao alarmInfoDao;
@ApiOperation("ML5S扫码后获取库位号")
@PostMapping(value = "/service/ml5s/emptyPosForPutin")
@ResponseBody
@AnonymousAccess
public Map<String, Object> ml5sEmptyPosForPutin(HttpServletRequest request) {
//返回:97=已有入库任务,需继续执行入库动作
//返回:98=已有出库任务,需继续执行出库动作
//返回:99=所在料仓有出库任务,暂停入库
//返回:100=系统更新中,暂停出入库
//返回:104=未找到可用的仓位
//返回 105=查找空库位失败
//返回 106=唯一码已有入库任务
//返回 107=物料已过期,无法入库
//返回 108=库位被锁定,暂停入库,重新获取库位号
//返回 96=已在库位中,NG
//返回108=已有待完成的出入库任务,直接NG
//返回110=接口验证失败,需要去XRay重新点料
//返回120=API验证错误。
String code = request.getParameter("code");
String cids = request.getParameter("cids");
String rfid = request.getParameter("rfid");
if(ObjectUtil.isEmpty(rfid)){
rfid="";
}
String lastPosId = "";
String lineMsg = "";
log.info("ml5s[" + cids + "]获取[" + code + "],rfid=["+rfid+"]的入库库位");
EnLog.info("Line [" + cids + "] get put-in position for [" + code + "], rfid=[" + rfid + "]");
return ml5sPosForPutin(code,cids,"",rfid,request.getLocale());
}
public Map<String, Object> ml5sPosForPutin(String code, String cids, String preCid, String rfid, Locale locale){
log.info("posForPutin,code=["+code+"],cids=["+cids+"],preCid=["+preCid+"]");
EnLog.info("posForPutin, code=[" + code + "], cids=[" + cids + "], preCid=[" + preCid + "]");
String lastPosId = "";
String lineMsg = "";
Map<String, Object> resultMap = Maps.newHashMap();
if (dataCache.getCache(Constants.CACHE_StopOut)) {
// lineMsg = "系统更新中,暂停出入库";
lineMsg="System update in progress, suspend the inlet and outlet";
DeviceMessageUtil.updateLineMsg(lineMsg,code,cids,"" ,"smfcore.linemsg.update",null);
Barcode barcode = new Barcode();
barcode.setBarcode(code);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,lineMsg);
resultMap.put("result", "100");
resultMap.put("msg", lineMsg);
return resultMap;
}
if(ObjectUtil.isEmpty(cids)){
cids="";
}
String[] cidArray= cids.split(",");
String okMsg = "";
String errorMsg = "";
List<Storage> storageList = Lists.newArrayList();
//急停,报警,调试状态的料仓不可用
List<String> cidList = dataCache.getAvailableStorageIds(DeviceType.SMD_DUO);
List<String> thirdList=dataCache.getAvailableStorageIds(DeviceType.SMDBOX_THIRD);
cidList.addAll(thirdList);
// for (String cid : cidList) {
for(String cid:cidArray) {
if (cidList.contains(cid)) {
String notIntoCids = dataCache.getSettings().getNotIntoCids();
if (notIntoCids != null) {
if (notIntoCids.contains(cid)) {
log.info("料仓[" + cid + "]已被屏蔽入库");
EnLog.info("Storage [" + cid + "] is blocked for put-in");
continue;
}
}
if(ObjectUtil.isNotEmpty(preCid)) {
if (cid.equals(preCid)) {
log.info("料仓[" + cid + "]是上个入库料仓,排除此料仓");
EnLog.info("Storage [" + cid + "] is the previous put-in storage, exclude it");
}
}
Storage storage = dataCache.getStorage(cid);
if (storage != null ) {
storageList.add(storage);
}
}
}
if (storageList.isEmpty()) {
//无可用的料仓
resultMap.put("result", "99");
errorMsg = "No Available Storage Equipment";
Barcode barcode = new Barcode();
barcode.setBarcode(code);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
resultMap.put("msg", errorMsg);
} else {
String apiBarcode="";
try {
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
if (barcode.getExpireDate() != null && System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
//过期无法入库
resultMap.put("result", "107");
errorMsg = "[" + barcode.getBarcode() + "]" + MessageUtils.getText("smfcore.error.barcode.expired", new Locale("en", "US"), "物料已过期,无法入库");
resultMap.put("msg", errorMsg);
log.error("物料[" + barcode.getBarcode() + "]已过期,无法入库");
EnLog.error("Material [" + barcode.getBarcode() + "] expired, cannot put in");
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.NG, errorMsg);
return resultMap;
}
}
//如果已在库位中,直接NG
Integer barcodeSet = dataCache.getCache(Constants.CACHE_SAME_BARCODE_SETTINGS);
StoragePos hasPos = storagePosManager.getByBarcode(barcode.getBarcode());
if (hasPos != null) {
Storage storage = dataCache.getStorageById(hasPos.getStorageId());
if (barcodeSet == null || barcodeSet == 1) {
//如果已在库位中,那么自动将该库位的物料出库
log.info(" 物料"+barcode.getBarcode()+"已在库位中, CACHE_SAME_BARCODE_SETTINGS=1,自动出库已在库位中的物料[" + barcode.getBarcode() + "],设置ngReel=true");
EnLog.info("Barcode " + barcode.getBarcode() + " already in position, CACHE_SAME_BARCODE_SETTINGS=1, auto checkout existing material [" + barcode.getBarcode() + "], set ngReel=true");
taskService.checkout(storage, hasPos, true, true, "", "");
} else {
log.info(" 物料"+barcode.getBarcode()+"已在库位中, CACHE_SAME_BARCODE_SETTINGS=2,标记库位[" + hasPos.getPosName() + "]中的物料[" + barcode.getBarcode() + "]为ngReel=NG");
EnLog.info("Barcode " + barcode.getBarcode() + " already in position, CACHE_SAME_BARCODE_SETTINGS=2, mark pos[" + hasPos.getPosName() + "] barcode[" + barcode.getBarcode() + "] as ngReel=NG");
hasPos.getBarcode().updateAppendData("ngReel", true);
storagePosManager.save(hasPos);
}
errorMsg=MessageUtils.getText("smfcore.error.barcode.exist", new String[]{barcode.getBarcode(), storage.getName(), hasPos.getPosName()}, MessageUtils.getDefaultLocal(),"[{0}}]已在{1}}[{2}}]中");
errorMsg="Serial No.(S)["+barcode.getBarcode()+"] has been existing in KTS/WMS already";
resultMap.put("result", "96");
resultMap.put("msg", errorMsg);
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.NG, errorMsg);
return resultMap;
}
try {
if(ObjectUtil.isNotEmpty(preCid)) {
log.info("preCid="+preCid+",["+barcode.getBarcode()+"]开始取消上个入库任务");
EnLog.info("preCid=" + preCid + ", [" + barcode.getBarcode() + "] start cancel previous put-in task");
Collection<DataLog> tasks = taskService.getAllTasks();
for (DataLog task : tasks) {
if (task.isFinished() || task.isCancel()) {
continue;
}
if (task.getBarcode().equals(barcode.getBarcode())) {
if (task.isPutInTask()) {
boolean cancelResult = taskService.cancelTask(task.getId());
log.info("renewPosForPutin 重新获取库位号时,取消[" + barcode.getBarcode() + "]上个入库任务[" + task.getPosName() + "-" + task.getCid() + "]结果:" + cancelResult);
EnLog.info("renewPosForPutin cancel previous put-in task for [" + barcode.getBarcode() + "] [" + task.getPosName() + "-" + task.getCid() + "] result: " + cancelResult);
}
}
}
log.info("preCid="+preCid+",["+barcode.getBarcode()+"]清除锁定库位");
EnLog.info("preCid=" + preCid + ", [" + barcode.getBarcode() + "] clear locked position");
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
if(ObjectUtil.isEmpty(rfid)){
//从缓存获取是否有rfid
String nrfid= loadingUtil.getRfidByBarcode(barcode.getBarcode() );
if(ObjectUtil.isNotEmpty(nrfid)){
log.info("rfid为空,第二次获取库位号,从入库单中查找到rfid:"+nrfid);
EnLog.info("rfid is empty, renewPosForPutin found rfid from inList: " + nrfid);
rfid=nrfid;
}
}
}
} catch (Exception e) {
log.error("取消上个入库任务出错:" + e.toString());
EnLog.error("Cancel previous put-in task error: " + e.toString());
}
for (DataLog dataLog : taskService.getQueueTasks()) {
//已取消或已完成的任务不返回
if(dataLog.isFinished()||dataLog.isCancel()){
continue;
}
if (dataLog.getBarcode().equals(barcode.getBarcode())) {
if (dataLog.isPutInTask()) {
//已有入库任务,返回NG,标记原来的入库任务
resultMap.put("result", "106");
// errorMsg = "Serial No.(S)[" + barcode.getBarcode() + "] already have storage task";
errorMsg = "Serial No.(S)[" + barcode.getBarcode() + "] has been existing in KTS/WMS already";
resultMap.put("msg", errorMsg);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
//判断原任务是否需要NG
// Integer barcodeSet=dataCache.getCache(Constants.CACHE_SAME_BARCODE_SETTINGS);
if(barcodeSet==null||barcodeSet==1) {
//原任务标记NG
dataLog.setNgReel(true);
log.info("获取[" + code + "]的入库库位,条码已有入库任务posname[" + dataLog.getPosName() + "],标记入库任务为NG,入库后自动出库");
EnLog.info("Get put-in pos for [" + code + "], barcode already has put-in task pos[" + dataLog.getPosName() + "], mark task NG and auto checkout after put-in");
taskService.updateQueueTask(dataLog);
//更改旧任务NG
String msg="Repeat Inbound";
loadingUtil.updateItemState(dataLog.getBarcode(),dataLog.getPosName(),INITEM_STATUS.NG,msg);
}else{
log.info("获取[" + code + "]的入库库位,条码已有入库任务posname[" + dataLog.getPosName() + "],CACHE_SAME_BARCODE_SETTINGS="+barcodeSet+",当前物料NG,已入库的任务继续完成");
EnLog.info("Get put-in pos for [" + code + "], barcode already has put-in task pos[" + dataLog.getPosName() + "], CACHE_SAME_BARCODE_SETTINGS=" + barcodeSet + ", current material NG, existing put-in task continues");
}
return resultMap;
// //已有入库任务
// errorMsg = "物料[" + dataLog.getBarcode() + "]已有入库任务,需继续执行入库动作";
// resultMap.put("result","97");
// resultMap.put("msg", errorMsg);
// resultMap.put("pos", dataLog.getPosName());
// resultMap.put("barcode", barcode.getBarcode());
// resultMap.put("cid", dataLog.getCid());
// resultMap.put("taskId", dataLog.getId());
// return resultMap;
} else {
// 重复ID,入库时,error提示 改成:
// 序列号[CARRIERPCB-010] 已有出库任务,出库前不得入库相同序列号物料
// Serial No.(S)[CARRIERPCB-010] already have retrieval task, cannot store same Serial No. material before retrieval finish
//已有出库任务
// errorMsg = "条码[" + dataLog.getBarcode() + "]已有出库任务,需继续执行出库动作";
errorMsg = "Serial No.(S)[" + dataLog.getBarcode() + "] already have retrieval task, cannot store same Serial No. material before retrieval finish";
errorMsg=MessageUtils.getText("smfcore.error.barcode.hasOutTask",new String[]{dataLog.getBarcode()},locale,
"Serial No.(S)[0] already have retrieval task, cannot store same Serial No. material before retrieval finish");
resultMap.put("result", "98");
resultMap.put("msg", errorMsg);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
resultMap.put("posId", dataLog.getPosName());
resultMap.put("plateW", barcode.getPlateSize());
resultMap.put("plateH", barcode.getHeight());
resultMap.put("singleOut", dataLog.isSingleOut() + "");
//紧急料
resultMap.put("urgentReel", dataLog.isUrgentReel() + "");
//需要分盘,进入分盘料
resultMap.put("cutReel", dataLog.isCutReel() + "");
resultMap.put("rfid", "");
resultMap.put("realRfid", "");
resultMap.put("rfidLoc", "");
resultMap.put("barcode", dataLog.getBarcode());
boolean smallReel = barcode.isSmallReel();
resultMap.put("smallReel", smallReel + "");
resultMap.put("taskId", dataLog.getId());
resultMap.put("cid", dataLog.getCid());
log.info("条码[" + dataLog.getBarcode() + "]已有出库任务["+dataLog.getPosName()+"],需继续执行出库动作");
EnLog.info("Barcode[" + dataLog.getBarcode() + "] already has checkout task pos[" + dataLog.getPosName() + "], continue checkout");
return resultMap;
}
}
}
for (DataLog dataLog : taskService.getFinishedTasks()) {
//已取消或已完成的任务不返回
if(dataLog.isFinished()||dataLog.isCancel()){
continue;
}
if (dataLog.getBarcode().equals(barcode.getBarcode())) {
if (dataLog.isPutInTask()) {
//已有待完成的入库任务,直接NG
resultMap.put("result", "108");
errorMsg = "Serial No.(S)[" + barcode.getBarcode() + "] already have task =["+dataLog.getInOutType()+"] ["+dataLog.getStatus()+"]";
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
resultMap.put("msg", errorMsg);
log.info("获取[" + code + "]的入库库位,条码已有入库任务posname[" + dataLog.getPosName() + "],的入库任务,任务状态["+dataLog.getStatus()+"],直接NG");
EnLog.info("Get put-in pos for [" + code + "], existing put-in task pos[" + dataLog.getPosName() + "] status[" + dataLog.getStatus() + "], return NG");
return resultMap;
} else {
//已有待完成的出库任务,直接NG
resultMap.put("result", "108");
errorMsg = "Serial No.(S)[" + barcode.getBarcode() + "] already have task =["+dataLog.getInOutType()+"] ["+dataLog.getStatus()+"]";
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
resultMap.put("msg", errorMsg);
log.info("获取[" + code + "]的入库库位,条码已有入库任务posname[" + dataLog.getPosName() + "],的出库任务,任务状态["+dataLog.getStatus()+"],直接NG");
EnLog.info("Get put-in pos for [" + code + "], existing checkout task pos[" + dataLog.getPosName() + "] status[" + dataLog.getStatus() + "], return NG");
return resultMap;
}
}
}
// 13*44,13*56,13*72这三个料入到我们的料仓,其他的13寸,15寸都入迈康尼的料仓
int inStorageType=0;//0=所有料仓都可以,1=只能入我们料仓。2=只能入麦康尼料仓
if(barcode.getPlateSize()==13){
if(barcode.getHeight()==44||barcode.getHeight()==56||barcode.getHeight()==72){
//只能入robot
inStorageType=1;
}else {
inStorageType=2;
}
}else if(barcode.getPlateSize()==15){
inStorageType=2;
}
List<Storage> storages=new ArrayList<>();
for (Storage storage :storageList) {
if(inStorageType==1){
if( storage.isRobotBox()) {
storages.add(storage);
}
}else if(inStorageType==2){
if(storage.isTHIRDBox()) {
//麦康尼料仓需要判断 当前剩余空库位是否可以放下料盘
if (dataCache.thirdBoxCanPutIn(storage, barcode.getPlateSize(), barcode.getHeight(),taskService.getQueueTasks(storage.getCid()))) {
storages.add(storage);
}
}
}else {
storages.add(storage);
}
}
//先验证下是否有空位,如果无空位直接返回,不需要调用API
StoragePos testFindPos = taskService.findEmptyPosForPutIn(storages, barcode, "", lastPosId);
if(testFindPos==null) {
resultMap.put("result", "104");
String size = getBarcodeSize(barcode);
// errorMsg = "[" + barcode.getBarcode() + "]未找到可用的[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]仓位";
errorMsg = "[" + barcode.getBarcode() + "]Not found available[" + size + "]Position";
resultMap.put("msg", errorMsg);
loadingUtil.AddOrUpdateItemState(rfid,barcode ,"", INITEM_STATUS.NG, errorMsg);
log.info("获取[" + code + "]的入库库位, [" + barcode.getBarcode() + "]未找到可用的[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]仓位");
EnLog.info("Get put-in pos for [" + code + "], barcode[" + barcode.getBarcode() + "] no available position for [" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]");
return resultMap;
}
barcode= ApiCheck(rfid,barcode );
apiBarcode=barcode.getBarcode();
if(barcode.isToXray()){
log.info("物料["+barcode.getBarcode()+"]需要先去点料" );
EnLog.info("Material [" + barcode.getBarcode() + "] requires Xray counting first");
resultMap.put("result", "110");
resultMap.put("barcode", barcode.getBarcode());
errorMsg= MessageUtils.getText("smfcore.api.toXray",new String[]{barcode.getBarcode()},new Locale("en","US"),"{0}需要去点料");
//loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.API001NG,errorMsg);
resultMap.put("msg", errorMsg);
}
else{
StoragePos pos = taskService.findEmptyPosForPutIn(storages, barcode, "", lastPosId);
if (pos != null) {
Storage storage = dataCache.getStorageById(pos.getStorageId());
if(storage.isTHIRDBox()&&ObjectUtil.isEmpty(preCid)) {
Boolean useAPi = dataCache.getCache(Constants.CACHE_API_TEST);
if (useAPi == null) {
useAPi = false;
}
Boolean xrayTest = dataCache.getCache(Constants.CACHE_XRAY_TEST);
if (xrayTest == null) {
xrayTest = false;
}
if ((useAPi == false) && xrayTest) {
log.info("useAPi==false,xrayTest=true, 点料测试已启用,且分配的库位是麦康尼料仓, 物料[" + barcode.getBarcode() + "]需要先去点料");
EnLog.info("useAPi=false, xrayTest=true, xray test enabled and assigned pos is third-party storage, material[" + barcode.getBarcode() + "] requires Xray counting first");
resultMap.put("result", "110");
resultMap.put("barcode", barcode.getBarcode());
errorMsg = MessageUtils.getText("smfcore.api.toXray", new String[]{barcode.getBarcode()}, new Locale("en", "US"), "{0}需要去点料");
lineMsg = errorMsg;
DeviceMessageUtil.updateLineMsg(lineMsg,code,cids, pos.getPosName(),"smfcore.linemsg.posLock",new String[]{barcode.getBarcode(),pos.getPosName()});
return resultMap;
}
}
//如果所在料仓有出库任务未完成,暂停入库
// Collection<DataLog> tasks = taskService.getAllTasks();
// for (DataLog task : tasks) {
// if (task.isCheckOutTask() && task.getStorageId().equals(pos.getStorageId())) {
// if ((!task.isFinished()) && (!task.isInRobot())&&(!task.isInLine()) ) {
// errorMsg = "PosName[" + pos.getPosName() + "]There are outgoing tasks in the silo, suspend storage";
// lineMsg = errorMsg;
// resultMap.put("result", "99");
// resultMap.put("msg", errorMsg);
// log.info("[" + barcode.getBarcode() + "]分到库位[" + pos.getPosName() + "]所在料仓有出库任务,暂停入库");
// return resultMap;
// }
// }
// }
ReelLockPosInfo oldLockInfo = ReelLockPosUtil.getLockPosInfoByCode(barcode.getBarcode());
if (oldLockInfo != null) {
if (!oldLockInfo.getBarcode().equals(barcode.getBarcode())) {
// String result = "-1";
// okMsg = rfid + " [" + barcode.getBarcode() + "]锁定库位[" + pos.getPosName() + "],清理旧有锁定信息";
// resultMap.put("result", result);
// resultMap.put("msg", okMsg);
//已经锁定过库位,但不是同一个条码,需要把对应位置的锁定信息清理掉
ReelLockPosUtil.removeReelLockPosInfo(oldLockInfo.getBarcode());
log.info("清理锁定库位:库位号[" + oldLockInfo.getLockPosName() + "]上物料[" + oldLockInfo.getBarcode() + "]锁定的库位");
EnLog.info("Clear locked position: pos[" + oldLockInfo.getLockPosName() + "] locked by barcode[" + oldLockInfo.getBarcode() + "]");
}
}
log.info(okMsg + oldLockInfo);
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
errorMsg = "[" + barcode.getBarcode() + "]库位["+reelLocInfo.getLockPosName()+"]已被锁定,暂停入库";
lineMsg = errorMsg;
DeviceMessageUtil.updateLineMsg(lineMsg,code,cids, reelLocInfo.getLockPosName(),"smfcore.linemsg.posLock",new String[]{barcode.getBarcode(),reelLocInfo.getLockPosName()});
resultMap.put("result", "107");
resultMap.put("msg", errorMsg);
return resultMap;
}
resultMap.put("result", "0");
resultMap.put("msg", "ok");
DataLog newTask = taskService.addPutInTaskToExecute(storage, barcode, pos);
okMsg = "[" + barcode.getBarcode() + "]锁定库位[" + pos.getPosName() + "]优先级[" + pos.getPriority() + "] 上个库位号[" + lastPosId + "]";
log.info(okMsg);
resultMap.put("pos", pos.getPosName());
resultMap.put("barcode", barcode.getBarcode());
resultMap.put("cid", storage.getCid());
resultMap.put("taskId", newTask.getId());
} else {
resultMap.put("result", "104");
String size = getBarcodeSize(barcode);
// errorMsg = "[" + barcode.getBarcode() + "]未找到可用的[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]仓位";
errorMsg = "[" + barcode.getBarcode() + "]Not found available[" + size + "]Position";
resultMap.put("msg", errorMsg);
loadingUtil.updateItemState(barcode.getBarcode(),"",INITEM_STATUS.NG,errorMsg);
}
}
} catch (ValidateException ve) {
errorMsg= MessageUtils.getText(ve.getMsgKey(),ve.getMsgParam(),new Locale("en","US"),ve.getDefaultMsg());
if(ObjectUtil.isNotEmpty(apiBarcode)){
log.info("Failed to find empty storage space:" + errorMsg+",update state");
loadingUtil.updateItemState(apiBarcode,"", INITEM_STATUS.NG,errorMsg);
}else{
log.info("Failed to find empty storage space:" + errorMsg);
Barcode barcode = new Barcode();
barcode.setBarcode(code);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
}
resultMap.put("result", "105");
resultMap.put("msg", errorMsg);
} catch (ApiException apiException) {
errorMsg = apiException.getMessage();
log.info("API 错误:" + errorMsg);
EnLog.info("API error: " + errorMsg);
String exMsg = MessageUtils.getText(apiException.getMsgKey(), apiException.getMsgParam(), new Locale("en", "US"), apiException.getDefaultMsg());
log.info(apiException.getMsgKey() + "获取到exMsg=" + exMsg);
EnLog.info(apiException.getMsgKey() + " got exMsg=" + exMsg);
resultMap.put("result", "120");
if (ObjectUtil.isEmpty(errorMsg) && ObjectUtil.isNotEmpty(apiException.getMessage())) {
// errorMsg=apiException.getMessage();
errorMsg = exMsg;
}
Barcode barcode = new Barcode();
barcode.setBarcode(code);
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.API001NG, errorMsg);
resultMap.put("msg", errorMsg);
}
catch (Exception e) {
errorMsg = e.getMessage();
log.info("Failed to find empty storage space,", e);
Barcode barcode = new Barcode();
barcode.setBarcode(code);
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.NG,errorMsg);
resultMap.put("result", "105");
resultMap.put("msg", errorMsg);
}
}
// }
//没入成功
if (!errorMsg.isEmpty()) {
//有错误,记录日志
AlarmInfo alarmInfo = new AlarmInfo();
alarmInfo.setBoxId("0");
alarmInfo.setStorageName("流水线");
alarmInfo.setInOutStatus("1");
alarmInfo.setAlarmType("入库");
Date date = new Date();
alarmInfo.setStartTime(date);
alarmInfo.setEndTime(date);
String msg = "[" + code + "]" + errorMsg;
alarmInfo.setAlarmMsg(msg);
alarmInfoDao.save(alarmInfo);
lineMsg = errorMsg;
DeviceMessageUtil.updateLineMsg(lineMsg, code, cids, "", "", null);
} else {
lineMsg = okMsg;
}
return resultMap;
}
private String getBarcodeSize(Barcode barcode){
// 310*80 pcb 330*120 tray 386*86 shoe box 400*60 Pizza box 其他的都是料盘
String size = barcode.getPlateSize() + "x" + barcode.getHeight();
if (size.equals("310x80")) {
size = "pcb";
} else if (size.equals("330x120")) {
size = "tray";
} else if (size.equals("386x86")) {
size = "shoe box";
} else if (size.equals("400x70")) {
size = "Pizza box";
}
return size;
}
private Barcode ApiCheck(String rfid,Barcode barcode) throws ApiException {
barcode.setToXray(false);
if (ObjectUtil.isEmpty(rfid)) {
return barcode;
}
Boolean useAPi=dataCache.getCache(Constants.CACHE_API_TEST);
if(useAPi==null){
useAPi=false;
}
if(!useAPi) {
return barcode;
}
//是否启用
if (!MicronApi.isEnable()) {
return barcode;
}
InListItem item=loadingUtil.GetInlistItem(barcode.getBarcode());
if(item!=null ){
log.info("条码[" + barcode.getBarcode() + "]获取库位号,已存在inListItem, 状态="+item.getState());
EnLog.info("Barcode[" + barcode.getBarcode() + "] get put-in position, inListItem exists, state=" + item.getState());
if(item.getState()==INITEM_STATUS.XRayEnd){
//更改状态为入库中
barcode.setToXray(false);
loadingUtil.updateItemState(barcode.getBarcode(),"",INITEM_STATUS.PutIn);
return barcode;
}
}
barcode.setInListName("");
String operationId = "";
InList inList = loadingUtil.getInlist();
if (inList == null) {
log.error("启用API,且未找到入库单,提示:No select for ML5 Loading");
EnLog.error("API enabled but no inList found: No select for ML5 Loading");
//如果启用api,且没有入库单,需要报警提示:No select for ML5 Loading
throw new ValidateException("smfcore.noSelectForML5Loading","No select for ML5 Loading");
// return barcode;
}
if (!inList.isValidRfid(rfid)) {
return barcode;
}
//如果入库单已手动结束,不再接收新任务
if(inList.isManualFinish()){
log.info("当前入库单[" + inList.getName() + "]已手动结束,不需要再验证:"+barcode.getBarcode());
EnLog.info("Current inList[" + inList.getName() + "] is manually finished, skip verification: " + barcode.getBarcode());
return barcode;
}
operationId = inList.getOperationId();
if (ObjectUtil.isEmpty(operationId)) {
log.info("条码[" + barcode.getBarcode() + "]获取库位号,operationId 为空,不需要接口验证");
EnLog.info("Barcode[" + barcode.getBarcode() + "] get put-in position, operationId is empty, skip API verification");
return barcode;
}
barcode = MicronApi.API001(operationId,rfid, barcode);
if (barcode == null) {
throw new ApiException("smfcore.api.fail", "{0} Failed to get data", new String[]{"API001 " });
}
//判断是否忽略去Xray
Boolean xrayBypass=dataCache.getCache(Constants.CACHE_API_XRAY_BYPASSS);
if(xrayBypass==null){
xrayBypass=false;
}
if (barcode.isToXray()) {
if(xrayBypass){
log.info("条码[" + barcode.getBarcode() + "]获取库位号,需要去点料, 勾选了 Xray Bypass,继续入库 ");
EnLog.info("Barcode[" + barcode.getBarcode() + "] requires Xray counting, Xray Bypass checked, continue put-in");
barcode.setInListName(inList.getName());
barcode.setToXray(false);
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.PutIn);
}else {
//判断点料机是否在线
if (MicronDataCache.DeviceOnLine("CI")) {
barcode.setToXray(true);
barcode.setInListName(inList.getName());
barcodeManager.saveBarcode(barcode);
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.XRay);
log.info("条码[" + barcode.getBarcode() + "]获取库位号,需要去点料,点料机CI当前在线,返回需要点料");
EnLog.info("Barcode[" + barcode.getBarcode() + "] requires Xray counting, CI is online, return need counting");
} else {
log.error("条码[" + barcode.getBarcode() + "]获取库位号,需要去点料,点料机CI未连接,直接异常");
EnLog.error("Barcode[" + barcode.getBarcode() + "] requires Xray counting, CI is offline, throw exception");
throw new ApiException("smfcore.micron.xray.offline", "{0} required counting partial quantity, Xray counter is not online", new String[]{barcode.getBarcode()});
}
}
} else {
barcode.setInListName(inList.getName());
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.PutIn,barcode.isToXray());
}
return barcode;
}
}
...@@ -19,13 +19,10 @@ import io.swagger.annotations.ApiOperation; ...@@ -19,13 +19,10 @@ import io.swagger.annotations.ApiOperation;
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.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
...@@ -76,6 +73,19 @@ public class ML5SDeviceController { ...@@ -76,6 +73,19 @@ public class ML5SDeviceController {
dto.setCurrLoading(""); dto.setCurrLoading("");
} else { } else {
dto.setCurrLoading(inList.getName()); dto.setCurrLoading(inList.getName());
dto.setLoadingCreateDate(inList.getCreateDate());
dto.setLoadingScanQty(inList.getInListItems().size());
int putOkCount = 0;
for (InListItem item : inList.getInListItems()
) {
String output = item.getAppendData("output");
if (ObjectUtil.isNotEmpty(output)) {
putOkCount++;
}
}
dto.setLoadingIsShelfQty(putOkCount);
} }
return dto; return dto;
} }
...@@ -114,4 +124,6 @@ public class ML5SDeviceController { ...@@ -114,4 +124,6 @@ public class ML5SDeviceController {
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!