Commit 9b209f68 LN

1.PartNumber不可为空

2.日志修改
3.ExpirationDate修改
4.生成批号修改
5.验证失败时不入库。
1 个父辈 6d74379e
package com.neotel.smfcore.common.exception; package com.neotel.smfcore.common.exception;
import lombok.Data;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import java.text.MessageFormat; import java.text.MessageFormat;
...@@ -7,6 +8,7 @@ import java.text.MessageFormat; ...@@ -7,6 +8,7 @@ import java.text.MessageFormat;
/** /**
* Created by kangmor on 2015/11/12. * Created by kangmor on 2015/11/12.
*/ */
@Data
public class ApiException extends Exception { public class ApiException extends Exception {
public ApiException(String message){ public ApiException(String message){
super(message); super(message);
......
...@@ -293,12 +293,8 @@ public class HttpHelper { ...@@ -293,12 +293,8 @@ public class HttpHelper {
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET); String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
log.info("Request to [" + url + "] response: code="+code+",responseContent="+responseContent); log.info("Request to [" + url + "] response: code="+code+",responseContent="+responseContent);
MicronResult result = JsonUtil.toObj(responseContent, MicronResult.class); MicronResult result = new MicronResult(code,responseContent);
if (result == null) {
result = new MicronResult();
}
result.setHttpCode(code);
result.setResponseData(responseContent);
response.close(); response.close();
httpClient.close(); httpClient.close();
return result; return result;
...@@ -313,14 +309,39 @@ public class HttpHelper { ...@@ -313,14 +309,39 @@ public class HttpHelper {
if (ObjectUtil.isEmpty(url)) { if (ObjectUtil.isEmpty(url)) {
return new MicronResult(); return new MicronResult();
} }
String responseContent = postJson(url, params); // String responseContent = postJson(url, params);
MicronResult result = JsonUtil.toObj(responseContent, MicronResult.class);
if (result == null) { HttpPost httpPost = new HttpPost(url);
result = new MicronResult(); httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
// 设置请求参数
if (params != null) {
try {
ObjectMapper mapper = new ObjectMapper();
String requestBody = mapper.writeValueAsString(params);
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
} catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] Json failed:" + e.getMessage());
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] json exception:" + e.getMessage());
}
}
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
int code = response.getStatusLine().getStatusCode();
log.info("Request to [" + url + "] response: code=" + code + ",responseContent=" + responseContent);
MicronResult result = new MicronResult(code, responseContent);
response.close();
httpClient.close();
return result;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} }
result.setResponseData(responseContent);
return result;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} }
......
...@@ -94,6 +94,29 @@ public class Barcode extends BasePo implements Serializable { ...@@ -94,6 +94,29 @@ public class Barcode extends BasePo implements Serializable {
* 批次 * 批次
*/ */
private String batch=""; private String batch="";
public String getMbatch() {
try {
//如果是1T开头,返回括号里面的
if (batch.contains("(") && batch.contains(")")) {
String batchstr = "1T" + batch;
if (fullCode.contains(batchstr)) {
//解析
int index1 = batch.indexOf("(");
int index2 = batch.indexOf(")");
String result = batch.substring(index1 + 1, index2);
return result;
}
}
} catch (Exception ex) {
}
return batch;
}
/** /**
* 等级 * 等级
*/ */
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mks.api.response.APIException;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ApiException; import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
...@@ -325,6 +326,7 @@ public class RobotBoxHandler extends BaseDeviceHandler { ...@@ -325,6 +326,7 @@ public class RobotBoxHandler extends BaseDeviceHandler {
//返回108=已有待完成的出入库任务,直接NG //返回108=已有待完成的出入库任务,直接NG
//返回110=接口验证失败,需要去XRay重新点料 //返回110=接口验证失败,需要去XRay重新点料
//返回120=API验证错误。
String code = request.getParameter("code"); String code = request.getParameter("code");
...@@ -614,7 +616,14 @@ public class RobotBoxHandler extends BaseDeviceHandler { ...@@ -614,7 +616,14 @@ public class RobotBoxHandler extends BaseDeviceHandler {
resultMap.put("result", "105"); resultMap.put("result", "105");
errorMsg= MessageUtils.getText(ve.getMsgKey(),ve.getMsgParam(),new Locale("en","US"),ve.getDefaultMsg()); errorMsg= MessageUtils.getText(ve.getMsgKey(),ve.getMsgParam(),new Locale("en","US"),ve.getDefaultMsg());
resultMap.put("msg", errorMsg); resultMap.put("msg", errorMsg);
} catch (Exception e) { } catch (ApiException apiException){
errorMsg = apiException.getMessage();
log.info("API 错误:" + errorMsg);
resultMap.put("result", "120");
errorMsg= MessageUtils.getText(apiException.getMsgKey(),apiException.getMsgParam(),new Locale("en","US"),apiException.getDefaultMsg());
resultMap.put("msg", errorMsg);
}
catch (Exception e) {
errorMsg = e.getMessage(); errorMsg = e.getMessage();
log.info("Failed to find empty storage space,", e); log.info("Failed to find empty storage space,", e);
resultMap.put("result", "105"); resultMap.put("result", "105");
......
package com.neotel.smfcore.custom.micron1053.api; package com.neotel.smfcore.custom.micron1053.api;
import cn.hutool.core.convert.Convert;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.micron1053.util.MicronDataCache; import com.neotel.smfcore.custom.micron1053.util.MicronDataCache;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Data @Data
@Slf4j
public class AMaterialBean { public class AMaterialBean {
private String serialNum; private String serialNum;
...@@ -18,48 +24,65 @@ public class AMaterialBean { ...@@ -18,48 +24,65 @@ public class AMaterialBean {
private String mfgName; private String mfgName;
private Integer qty; private Integer qty;
private String expirationDateStr; private String expirationDateStr;
private String msLevel; private LocalDateTime expirationDate;
private Integer msLevel;
private String containerType; private String containerType;
private String arraySize; private Integer arraySize;
private String panelNum; private Integer panelNum;
public static AMaterialBean toBean(Barcode barcode){ public static AMaterialBean toBean(Barcode barcode) {
AMaterialBean bean=new AMaterialBean(); AMaterialBean bean = new AMaterialBean();
bean.serialNum=barcode.getBarcode(); bean.serialNum = barcode.getBarcode();
bean.partNumber=barcode.getPartNumber(); bean.partNumber = barcode.getPartNumber();
bean.sapItem=true; bean.sapItem = true;
bean.mfgPartNum=barcode.getMpn(); bean.mfgPartNum = barcode.getMpn();
bean.mfgLotNum=barcode.getBatch(); bean.mfgLotNum = barcode.getMbatch();
bean.mfgName=barcode.getProvider(); bean.mfgName = barcode.getProvider();
bean.qty=barcode.getAmount(); bean.qty = barcode.getAmount();
bean.expirationDateStr=barcode.getExpireDateStr(); bean.expirationDateStr = barcode.getExpireDateStr();
bean.msLevel=barcode.getMsl(); bean.expirationDate = barcode.getExpireDate().toInstant().atZone(ZoneId.systemDefault())
if(bean.msLevel.startsWith("E")){ .toLocalDateTime();
bean.msLevel=bean.msLevel.substring(1); try {
}else if(bean.msLevel.startsWith("7E")){
bean.msLevel=bean.msLevel.substring(2); String msLevelStr = barcode.getMsl();
if (msLevelStr.startsWith("E")) {
bean.msLevel = ToInt(msLevelStr.substring(1), 0);
} else if (msLevelStr.startsWith("7E")) {
bean.msLevel = ToInt(msLevelStr.substring(2), 0);
}
} catch (Exception ex) {
} }
String reelType= MicronDataCache.GetReelType(barcode.getPlateSize(),barcode.getHeight());
bean.containerType=reelType;//类型 String reelType = MicronDataCache.GetReelType(barcode.getPlateSize(), barcode.getHeight());
bean.arraySize=barcode.getQ1Item();//1Q bean.containerType = reelType;//类型
bean.panelNum=barcode.getQItem();//Q bean.arraySize = ToInt(barcode.getQ1Item(), 0);//1Q
bean.panelNum = ToInt(barcode.getQItem(), 0);//Q
return bean; return bean;
} }
public static int ToInt(String str,int defValue) {
try {
return Convert.toInt((str));
} catch (Exception ex) {
log.info("转为数字出错:" + ex.toString());
}
return defValue;
}
public Map<String,Object> toMap(){ public Map<String,Object> toMap(){
Map<String,Object> resultMap=new HashMap<>(); Map<String,Object> resultMap=new HashMap<>();
resultMap.put("serialNum", serialNum); resultMap.put("serialNum", serialNum);
resultMap.put("partNumber", panelNum); resultMap.put("partNumber", partNumber);
resultMap.put("sapItem", sapItem); resultMap.put("sapItem", sapItem);
resultMap.put("mfgPartNum", mfgPartNum); resultMap.put("mfgPartNum", mfgPartNum);
resultMap.put("mfgLotNum", mfgLotNum); resultMap.put("mfgLotNum", mfgLotNum);
resultMap.put("mfgName", mfgName); resultMap.put("mfgName", mfgName);
resultMap.put("qty", qty); resultMap.put("qty", qty);
resultMap.put("expirationDateStr", expirationDateStr); resultMap.put("expirationDate", DateTimeFormatter.ISO_DATE_TIME.format(expirationDate));
resultMap.put("msLevel", msLevel); resultMap.put("msLevel", msLevel);
resultMap.put("containerType", containerType);//类型 resultMap.put("containerType", containerType);//类型
......
...@@ -73,6 +73,9 @@ public class MicronApi { ...@@ -73,6 +73,9 @@ public class MicronApi {
public static Barcode API001(String operationId, Barcode barcode) throws ApiException { public static Barcode API001(String operationId, Barcode barcode) throws ApiException {
String url = config.getUrl(config.api_name_001); String url = config.getUrl(config.api_name_001);
if (ObjectUtil.isEmpty(url)) {
return barcode;
}
try { try {
// Body= // Body=
...@@ -100,20 +103,33 @@ public class MicronApi { ...@@ -100,20 +103,33 @@ public class MicronApi {
paramsMap.put("material", bean.toMap()); paramsMap.put("material", bean.toMap());
String paramStr = JsonUtil.toJsonStr(paramsMap); String paramStr = JsonUtil.toJsonStr(paramsMap);
log.info("调用MES接口 API001: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API001: url=" + url + ",body=" + paramStr + "");
MicronResult result = HttpHelper.postMicronJson(url, paramsMap); MicronResult result = HttpHelper.postMicronJson(url, paramsMap);
// "serialNum": <SerialNum>, // "serialNum": <SerialNum>,
// "partNumber": <PartNumber>, // "partNumber": <PartNumber>,
// "mamQty": <Qty>, //From MAM attribute // "mamQty": <Qty>, //From MAM attribute
// "xrayReq": true|false, //From MAM attribute // "xrayReq": true|false, //From MAM attribute
// "status": "Success" // "status": "Success"
String partNumber = result.getResult("partNumber");
String serialNum = result.getResult("serialNum");
Boolean xrayReq = result.getResult("xrayReq");
Integer mamQty = result.getResult("Qty");
if (xrayReq != null && xrayReq == true) {
barcode.setToXray(true); // url=[http://istio-ingressgateway-istio-system.apps.ose-dev45.micron.com/material/validation/label],body=[{"material":{"mfgPartNum":"22-5019CC2353","serialNum":"P2UATCTRL001","expirationDateStr":"12/31/2025","panelNum":null,"containerType":"reel","qty":10000,"partNumber":null,"sapItem":true,"arraySize":null,"mfgLotNum":"(TKSA66.002CC)","mfgName":"PHISON","msLevel":"3"},"operationId":"OPS63"}]
// 2023-08-17 09:53:58.011 INFO [HttpHelper.java:174] - Request to [http://istio-ingressgateway-istio-system.apps.ose-dev45.micron.com/material/validation/label] response: code=500,responseContent={
// "transactionId": "14b6d13c-fe7f-4f83-8ffb-1d8d48367e71",
// "error": 102,
// "message": "Server error exception",
// "detail": "Value cannot be null. (Parameter 'value')"
// }
if (result.statusIsSuccess()) {
String partNumber = result.getResult("partNumber");
String serialNum = result.getResult("serialNum");
Boolean xrayReq = result.getResult("xrayReq");
Integer mamQty = result.getResult("Qty");
if (xrayReq != null && xrayReq == true) {
barcode.setToXray(true);
}
log.info("API001 ,barcode=" + barcode.getBarcode() + ",返回结果:partNumber=" + partNumber + ", serialNum=" + serialNum + ", xrayReq=" + xrayReq + ", Qty=" + mamQty);
} }
return barcode; return barcode;
...@@ -130,6 +146,7 @@ public class MicronApi { ...@@ -130,6 +146,7 @@ public class MicronApi {
public static Map<String,Boolean> API002(String jobId, String operationId, List<StoragePos> storagePos) { public static Map<String,Boolean> API002(String jobId, String operationId, List<StoragePos> storagePos) {
String url = config.getUrl(config.api_name_002); String url = config.getUrl(config.api_name_002);
try { try {
// "jobId": <JobId>, // "jobId": <JobId>,
...@@ -212,7 +229,7 @@ public class MicronApi { ...@@ -212,7 +229,7 @@ public class MicronApi {
// "status": "Success" // "status": "Success"
// } // }
String paramStr = JsonUtil.toJsonStr(paramsMap); String paramStr = JsonUtil.toJsonStr(paramsMap);
log.info("调用MES接口 API002: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API002: url=" + url + ",body=" + paramStr + "");
MicronResult result = HttpHelper.postMicronJson(url, paramsMap); MicronResult result = HttpHelper.postMicronJson(url, paramsMap);
List<MaterialStatus> resultList =result.getResult("materialStatusList"); List<MaterialStatus> resultList =result.getResult("materialStatusList");
...@@ -226,7 +243,9 @@ public class MicronApi { ...@@ -226,7 +243,9 @@ public class MicronApi {
} }
} }
return resultMap; return resultMap;
} catch (Exception e) { }
catch (Exception e) {
log.error(url + "出错", e); log.error(url + "出错", e);
} }
return new HashMap<>(); return new HashMap<>();
...@@ -255,7 +274,7 @@ public class MicronApi { ...@@ -255,7 +274,7 @@ public class MicronApi {
return list; return list;
} }
try { try {
log.info("调用MES接口 API004: url=[" + url + "]"); log.info("调用MES接口 API004: url=" + url + "");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
// dispatchMode: MCLPRETASK|PCBPRETASK|LINEPREP // dispatchMode: MCLPRETASK|PCBPRETASK|LINEPREP
// Http Status code: // Http Status code:
...@@ -331,7 +350,7 @@ public class MicronApi { ...@@ -331,7 +350,7 @@ public class MicronApi {
url = MessageFormat.format(url,operationId,linePrepOrderId); url = MessageFormat.format(url,operationId,linePrepOrderId);
try { try {
log.info("调用MES接口 API005: url=[" + url + "]"); log.info("调用MES接口 API005: url=" + url + "");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
materialList = result.getResult("materials"); materialList = result.getResult("materials");
} catch (Exception e) { } catch (Exception e) {
...@@ -367,7 +386,7 @@ public class MicronApi { ...@@ -367,7 +386,7 @@ public class MicronApi {
paramMap.put("pretasks", pretasks); paramMap.put("pretasks", pretasks);
String paramStr = JsonUtil.toJsonStr(paramMap); String paramStr = JsonUtil.toJsonStr(paramMap);
log.info("调用MES接口 API006: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API006: url=" + url + ",body=" + paramStr + "");
MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap); MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap);
String responseData = micronResult.getResponseData(); String responseData = micronResult.getResponseData();
...@@ -408,9 +427,9 @@ public class MicronApi { ...@@ -408,9 +427,9 @@ public class MicronApi {
paramMap.put("dispatchedMaterials", materialList); paramMap.put("dispatchedMaterials", materialList);
String paramStr = JsonUtil.toJsonStr(paramMap); String paramStr = JsonUtil.toJsonStr(paramMap);
log.info("调用MES接口 API007: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API007: url=" + url + ",body=" + paramStr + "");
MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap); MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap);
return micronResult.getStatus().equals("Success"); return micronResult.statusIsSuccess();
} catch (ApiException e) { } catch (ApiException e) {
log.error(url + "出错", e); log.error(url + "出错", e);
} }
...@@ -428,7 +447,7 @@ public class MicronApi { ...@@ -428,7 +447,7 @@ public class MicronApi {
paramMap.put("newQty",newQty); paramMap.put("newQty",newQty);
String paramStr = JsonUtil.toJsonStr(paramMap); String paramStr = JsonUtil.toJsonStr(paramMap);
log.info("调用MES接口 API008: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API008: url=" + url + ",body=" + paramStr + "");
MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap); MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap);
// Http Status code: // Http Status code:
...@@ -469,7 +488,7 @@ public class MicronApi { ...@@ -469,7 +488,7 @@ public class MicronApi {
paramMap.put("materials",materialList); paramMap.put("materials",materialList);
String paramStr = JsonUtil.toJsonStr(paramMap); String paramStr = JsonUtil.toJsonStr(paramMap);
log.info("调用MES接口 API009: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API009: url=" + url + ",body=" + paramStr + "");
MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap); MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap);
return true; return true;
...@@ -490,7 +509,7 @@ public class MicronApi { ...@@ -490,7 +509,7 @@ public class MicronApi {
paramMap.put("materials", materialList); paramMap.put("materials", materialList);
String paramStr = JsonUtil.toJsonStr(paramMap); String paramStr = JsonUtil.toJsonStr(paramMap);
log.info("调用MES接口 API010: url=[" + url + "],body=[" + paramStr + "]"); log.info("调用MES接口 API010: url=" + url + ",body=" + paramStr + "");
MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap); MicronResult micronResult = HttpHelper.postMicronJson(url, paramMap);
JSONObject jsonObject = JSONObject.parseObject(micronResult.getResponseData()); JSONObject jsonObject = JSONObject.parseObject(micronResult.getResponseData());
...@@ -518,7 +537,7 @@ public class MicronApi { ...@@ -518,7 +537,7 @@ public class MicronApi {
} }
url = MessageFormat.format(url,mode,userName,source); url = MessageFormat.format(url,mode,userName,source);
try { try {
log.info("调用MES接口 Api011: url=[" + url + "] "); log.info("调用MES接口 Api011: url=" + url + " ");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
String operationId=result.getResult("operationId"); String operationId=result.getResult("operationId");
log.info(" Api011 ,mode="+mode+",userName="+userName+", 获取到 operationId="+operationId); log.info(" Api011 ,mode="+mode+",userName="+userName+", 获取到 operationId="+operationId);
...@@ -536,7 +555,7 @@ public class MicronApi { ...@@ -536,7 +555,7 @@ public class MicronApi {
url = MessageFormat.format(url,id,operationId,skipSap); url = MessageFormat.format(url,id,operationId,skipSap);
try { try {
log.info("调用MES接口 API101: url=[" + url + "] "); log.info("调用MES接口 API101: url=" + url + " ");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
return true; return true;
} catch (ApiException e) { } catch (ApiException e) {
...@@ -551,7 +570,7 @@ public class MicronApi { ...@@ -551,7 +570,7 @@ public class MicronApi {
url = MessageFormat.format(url, id, operationId); url = MessageFormat.format(url, id, operationId);
try { try {
log.info("调用MES接口 API102: url=[" + url + "] "); log.info("调用MES接口 API102: url=" + url + " ");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
return true; return true;
} catch (ApiException e) { } catch (ApiException e) {
...@@ -566,7 +585,7 @@ public class MicronApi { ...@@ -566,7 +585,7 @@ public class MicronApi {
url = MessageFormat.format(url, purchaseOrder, packagingSlip, operationId, skipSap); url = MessageFormat.format(url, purchaseOrder, packagingSlip, operationId, skipSap);
try { try {
log.info("调用MES接口 API103: url=[" + url + "] "); log.info("调用MES接口 API103: url=" + url + " ");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
return true; return true;
} catch (ApiException e) { } catch (ApiException e) {
...@@ -581,7 +600,7 @@ public class MicronApi { ...@@ -581,7 +600,7 @@ public class MicronApi {
url = MessageFormat.format(url, linePrepOrderId, operationId); url = MessageFormat.format(url, linePrepOrderId, operationId);
try { try {
log.info("调用MES接口 API201: url=[" + url + "] "); log.info("调用MES接口 API201: url=" + url + " ");
MicronResult result = HttpHelper.postMicronJson(url, null); MicronResult result = HttpHelper.postMicronJson(url, null);
return true; return true;
} catch (ApiException e) { } catch (ApiException e) {
...@@ -597,7 +616,7 @@ public class MicronApi { ...@@ -597,7 +616,7 @@ public class MicronApi {
url = MessageFormat.format(url, badgeId); url = MessageFormat.format(url, badgeId);
try { try {
log.info("调用MES接口 API202: url=[" + url + "] "); log.info("调用MES接口 API202: url=" + url + " ");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
return true; return true;
} catch (ApiException e) { } catch (ApiException e) {
......
...@@ -20,45 +20,59 @@ public class MicronResult implements Serializable { ...@@ -20,45 +20,59 @@ public class MicronResult implements Serializable {
// Status : <Success|Fail> // Status : <Success|Fail>
// Message : <Error Message> // Message : <Error Message>
// } // }
private Integer httpCode=0; private Integer httpCode = 0;
private String status; // private String status;
private String message; // private String message;
private String responseData; private String responseData;
public boolean isSuccess() { public MicronResult(int httpCode, String responseData) {
if (ObjectUtil.isNotEmpty(status) && status.equalsIgnoreCase("Success")) { this.httpCode = httpCode;
this.responseData = responseData;
}
public boolean isOk() {
if (httpCode == 200) {
return true; return true;
} }
return false; return false;
} }
public boolean isOk(){ public boolean statusIsSuccess()throws ApiException {
if(httpCode==200){ String status = getResult("status");
if (ObjectUtil.isNotEmpty(status) && status.toString().equalsIgnoreCase("SUCCESS")) {
return true; return true;
} }
return false; return false;
} }
private Map<String, Object> resultMap=null;
public <T> T getResult( String key) throws ApiException { private Map<String, Object> resultMap = null;
public <T> T getResult(String key) throws ApiException {
if (ObjectUtil.isEmpty(responseData)) { if (ObjectUtil.isEmpty(responseData)) {
return null; return null;
} }
if(resultMap==null){ if (resultMap == null) {
resultMap = JsonUtil.toMap(responseData); resultMap = JsonUtil.toMap(responseData);
} }
Object resultStatus = resultMap.get("status"); Object resultStatus = resultMap.get("status");
if (resultStatus != null && !resultStatus.toString().equalsIgnoreCase("SUCCESS")) { if (resultStatus == null || (!resultStatus.toString().equalsIgnoreCase("SUCCESS"))) {
Object msgObj = resultMap.get("message") ; //失败
if(ObjectUtil.isEmpty(msgObj)){ String message = resultMap.get("message").toString();
throw new ApiException("smfcore.api.error", "status="+resultStatus); message = (message == null ? "" : message);
}else{ Object error = resultMap.get("error");
throw new ApiException("smfcore.api.error", msgObj.toString()); error = (error == null) ? "" : error;
} String detail = resultMap.get("detail").toString();
detail = (detail == null ? "" : detail);
log.error(" smfcore.api.error : error=" + error + "" + ",message=" + message + ",detial=" + detail);
throw new ApiException("smfcore.api.error", "api.error: error={0},message={1},detial={2}", new String[]{error.toString(), message, detail});
} }
if (key != null && !key.isEmpty()) { if (key != null && !key.isEmpty()) {
Object value = resultMap.get(key); Object value = resultMap.get(key);
......
...@@ -19,6 +19,7 @@ import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; ...@@ -19,6 +19,7 @@ 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.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.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.micron1053.api.AMaterialBean;
import com.neotel.smfcore.custom.micron1053.util.MicronDataCache; import com.neotel.smfcore.custom.micron1053.util.MicronDataCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.annotation.AnonymousPostMapping; import com.neotel.smfcore.security.annotation.AnonymousPostMapping;
...@@ -209,29 +210,31 @@ public class NeotelController { ...@@ -209,29 +210,31 @@ public class NeotelController {
objMap.put("slot", storagePos.getPosName()); objMap.put("slot", storagePos.getPosName());
objMap.put("materialStatus", "Available"); objMap.put("materialStatus", "Available");
Barcode barcode = storagePos.getBarcode(); Barcode barcode = storagePos.getBarcode();
Map<String, Object> resultMap = new HashMap<>();
if (barcode != null) {
resultMap.put("serialNum", barcode.getBarcode()); if (barcode != null) {
resultMap.put("partNumber", barcode.getPartNumber());
resultMap.put("sapItem", Boolean.TRUE);
resultMap.put("mfgPartNum", barcode.getMpn());
resultMap.put("mfgLotNum", barcode.getBatch());
resultMap.put("mfgName", barcode.getProvider());
resultMap.put("qty", barcode.getAmount());
resultMap.put("expirationDateStr", barcode.getExpireDateStr());
String msgLevel=barcode.getMsl();
if(msgLevel.startsWith("E")){ // resultMap.put("serialNum", barcode.getBarcode());
msgLevel=msgLevel.substring(1); // resultMap.put("partNumber", barcode.getPartNumber());
}else if(msgLevel.startsWith("7E")){ // resultMap.put("sapItem", Boolean.TRUE);m
msgLevel=msgLevel.substring(2); // resultMap.put("mfgPartNum", barcode.getMpn());
} // resultMap.put("mfgLotNum", barcode.getMbatch());
resultMap.put("msLevel", msgLevel); // resultMap.put("mfgName", barcode.getProvider());
String reelType= MicronDataCache.GetReelType(barcode.getPlateSize(),barcode.getHeight()); // resultMap.put("qty", barcode.getAmount());
resultMap.put("containerType", reelType);//类型 // resultMap.put("expirationDate", barcode.getExpireDateStr());
resultMap.put("arraySize", barcode.getQ1Item());//1Q // String msgLevel=barcode.getMsl();
resultMap.put("panelNum", barcode.getQItem());//Q //
// if(msgLevel.startsWith("E")){
// msgLevel=msgLevel.substring(1);
// }else if(msgLevel.startsWith("7E")){
// msgLevel=msgLevel.substring(2);
// }
// resultMap.put("msLevel", msgLevel);
// String reelType= MicronDataCache.GetReelType(barcode.getPlateSize(),barcode.getHeight());
// resultMap.put("containerType", reelType);//类型
// resultMap.put("arraySize", barcode.getQ1Item());//1Q
// resultMap.put("panelNum", barcode.getQItem());//Q
AMaterialBean bean=AMaterialBean.toBean(barcode);
Map<String, Object> resultMap = bean.toMap();
objMap.put("material", resultMap); objMap.put("material", resultMap);
} }
......
...@@ -353,6 +353,7 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\ ...@@ -353,6 +353,7 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\
smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F
smfcore.api.fail={0} Failed to get data smfcore.api.fail={0} Failed to get data
smfcore.micron.apiClose=Not yet open smfcore.micron.apiClose=Not yet open
smfcore.api.error=api.error: error={0},message={1},detial={2}
#smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0} #smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1} #smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
#smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F #smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F
......
...@@ -28,7 +28,7 @@ public class ApplicationTests { ...@@ -28,7 +28,7 @@ public class ApplicationTests {
private void saveLanguageFile(String type){ private void saveLanguageFile(String type){
try { try {
String url = "http://192.168.1.108/smf-core/api/translation/getLanguageMsgList"; String url = "http://192.168.1.33/smf-core/api/translation/getLanguageMsgList";
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("type",type); params.put("type",type);
System.out.println("开始获取最新["+type+"]翻译资源..."); System.out.println("开始获取最新["+type+"]翻译资源...");
...@@ -46,7 +46,7 @@ public class ApplicationTests { ...@@ -46,7 +46,7 @@ public class ApplicationTests {
File projectJsonFile = new File(projectDir,"src/main/resources/"+filename); File projectJsonFile = new File(projectDir,"src/main/resources/"+filename);
System.out.println("生成翻译资源文件到" + projectJsonFile.getAbsolutePath()); System.out.println("生成翻译资源文件到" + projectJsonFile.getAbsolutePath());
FileUtil.writeString(jsonTxt,projectJsonFile, CharsetUtil.CHARSET_UTF_8); FileUtil.writeString(jsonTxt,projectJsonFile, CharsetUtil.CHARSET_UTF_8);
// try(FileWriter fw = new FileWriter(projectJsonFile)){ // try(FileWriter fw = new FileWriter(projectJsonFile)){4r
// fw.write(jsonTxt); // fw.write(jsonTxt);
// } // }
File targetJsonFile = new File(projectDir,"target/classes/"+filename); File targetJsonFile = new File(projectDir,"target/classes/"+filename);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!