Commit 589e95ec LN

API002返回值修改:success: 0=failed|1=success|2=warning,当是success=2时表示warning,重试时此物料不需要重发

1 个父辈 8db12cdb
...@@ -27,6 +27,8 @@ public class INITEM_STATUS { ...@@ -27,6 +27,8 @@ public class INITEM_STATUS {
/**入库正常完成*/ /**入库正常完成*/
public static String Success="Success"; public static String Success="Success";
/**入库完成warning状态,不需要重发*/
public static String Warning="Warning";
/**入库通知失败 新页面显示提交失败的*/ /**入库通知失败 新页面显示提交失败的*/
public static String Fail="Fail"; public static String Fail="Fail";
......
...@@ -100,7 +100,7 @@ public class InListItem extends BasePo implements Serializable { ...@@ -100,7 +100,7 @@ public class InListItem extends BasePo implements Serializable {
public boolean isEnd() { public boolean isEnd() {
return state.equalsIgnoreCase(INITEM_STATUS.Success) || state.equalsIgnoreCase(INITEM_STATUS.Cancel) return state.equalsIgnoreCase(INITEM_STATUS.Success) || state.equalsIgnoreCase(INITEM_STATUS.Cancel)
|| state.equalsIgnoreCase(INITEM_STATUS.API001NG) ||state.equalsIgnoreCase(INITEM_STATUS.NG); || state.equalsIgnoreCase(INITEM_STATUS.API001NG) ||state.equalsIgnoreCase(INITEM_STATUS.NG)||state.equalsIgnoreCase(INITEM_STATUS.Warning);
} }
public boolean isCancel() { public boolean isCancel() {
......
...@@ -245,12 +245,12 @@ public class MicronApi { ...@@ -245,12 +245,12 @@ public class MicronApi {
return msg; return msg;
} }
public static Map<String,String> API002(String rfid, String operationId, List<StoragePos> storagePos) { public static Map<String,Api002MResult> API002(String rfid, String operationId, List<StoragePos> storagePos) {
String jobId=operationId+"_"+rfid; String jobId=operationId+"_"+rfid;
String url = config.getUrl(config.api_name_002); String url = config.getUrl(config.api_name_002);
Map<String, String> resultMap = new HashMap<>(); Map<String, Api002MResult> resultMap = new HashMap<>();
try { try {
...@@ -316,29 +316,33 @@ public class MicronApi { ...@@ -316,29 +316,33 @@ public class MicronApi {
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 + "");
//API002修改处理逻辑,返回状态 success 改为:0=failed|1=success|2=warning,当是success=2时表示warning,重试时此物料不需要重发
MicronResult result = HttpHelper.postMicronJson(url, paramsMap,2*60*1000); MicronResult result = HttpHelper.postMicronJson(url, paramsMap,2*60*1000);
// "error": <ErrCode>, // "error": <ErrCode>,
// "message": <ErrMessage>, // "message": <ErrMessage>,
// "detail": <ErrDetail> // "detail": <ErrDetail>
String errMsg=getDErrorMsg(result); String errMsg=getDErrorMsg(result);
resultMap.put("msg",errMsg); resultMap.put("msg",Api002MResult.newObj(errMsg));
// if (result.isOk()&& result.statusIsSuccess()) { // if (result.isOk()&& result.statusIsSuccess()) {
if (result.isOk() ) { if (result.isOk() ) {
List<Object> resultList = result.getResult("materialStatusList"); List<Object> resultList = result.getResult("materialStatusList");
for (Object Obj : for (Object Obj :
resultList) { resultList) {
MaterialStatus s= JsonUtil.toObj(JsonUtil.toJsonStr( Obj) ,MaterialStatus.class); Api002MResult s= JsonUtil.toObj(JsonUtil.toJsonStr( Obj) , Api002MResult.class);
// if (s.getMaterialStatus().toUpperCase().equals("SUCCESS")) { // if (s.getMaterialStatus().toUpperCase().equals("SUCCESS")) {
if(s.isSuccess()){ if(s.isSuccess()){
resultMap.put(s.getSerialNum(), "true"); resultMap.put(s.getSerialNum(), s);
}else if(s.isWarning()){
resultMap.put(s.getSerialNum(),s);
} }
else if(ObjectUtil.isNotEmpty(s.getDescription())){ else if(ObjectUtil.isNotEmpty(s.getDescription())){
resultMap.put(s.getSerialNum(), s.getDescription()); resultMap.put(s.getSerialNum(),s);
} }
else { else {
resultMap.put(s.getSerialNum(), errMsg); s.setDescription(errMsg);
resultMap.put(s.getSerialNum(), s);
} }
} }
} }
...@@ -348,7 +352,7 @@ public class MicronApi { ...@@ -348,7 +352,7 @@ public class MicronApi {
} }
else { else {
String msg = MessageUtils.getText("smfcore.api.fail", new String[]{"API002 : " + result.getResponseData()}, MessageUtils.getDefaultLocal(), "{0} Failed to get data"); String msg = MessageUtils.getText("smfcore.api.fail", new String[]{"API002 : " + result.getResponseData()}, MessageUtils.getDefaultLocal(), "{0} Failed to get data");
resultMap.put("msg", msg); resultMap.put("msg", Api002MResult.newObj(msg));
log.info("API002 ,接口通信失败:" + msg); log.info("API002 ,接口通信失败:" + msg);
return resultMap; return resultMap;
// log.info("API002 ,接口通信失败"); // log.info("API002 ,接口通信失败");
...@@ -360,7 +364,7 @@ public class MicronApi { ...@@ -360,7 +364,7 @@ public class MicronApi {
catch (Exception e) { catch (Exception e) {
//超时返回:API002 interface time out //超时返回:API002 interface time out
log.error(url + "出错", e); log.error(url + "出错", e);
resultMap.put("msg", "API002 interface time out"); resultMap.put("msg", Api002MResult.newObj("API002 interface time out"));
return resultMap; return resultMap;
} }
// return new HashMap<>(); // return new HashMap<>();
......
package com.neotel.smfcore.custom.micron1053.api.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Api002MResult implements Serializable {
public static Api002MResult newObj(String msg) {
Api002MResult m = new Api002MResult();
m.setDescription(msg);
return m;
}
private String serialNum;
private String partNumber;
private String reservedLinePrepOrderId;
private String description;
/**
*success: 0=failed|1=success|2=warning,当是success=2时表示warning,重试时此物料不需要重发
*/
private int success = -1;
private String materialStatus;
public boolean isSuccess() {
return success == 1;
}
public boolean isWarning() {
return success == 2;
}
}
...@@ -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.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.custom.micron1053.api.MicronApi; import com.neotel.smfcore.custom.micron1053.api.MicronApi;
import com.neotel.smfcore.custom.micron1053.api.bean.Api002MResult;
import com.neotel.smfcore.custom.micron1053.bean.ML5NgReelInfo; import com.neotel.smfcore.custom.micron1053.bean.ML5NgReelInfo;
import com.neotel.smfcore.custom.micron1053.loading.Bean.LoadingInfo; import com.neotel.smfcore.custom.micron1053.loading.Bean.LoadingInfo;
import com.neotel.smfcore.custom.micron1053.loading.dto.MaterialLoadingDto; import com.neotel.smfcore.custom.micron1053.loading.dto.MaterialLoadingDto;
...@@ -440,7 +441,7 @@ public class LoadingUtil { ...@@ -440,7 +441,7 @@ public class LoadingUtil {
} }
} }
Map<String, String> resultMap = MicronApi.API002(rfid, inList.getOperationId(), posList); Map<String, Api002MResult> resultMap = MicronApi.API002(rfid, inList.getOperationId(), posList);
List<InListItem> inListItems = new ArrayList<>(); List<InListItem> inListItems = new ArrayList<>();
boolean isEnd = true; boolean isEnd = true;
...@@ -457,21 +458,24 @@ public class LoadingUtil { ...@@ -457,21 +458,24 @@ public class LoadingUtil {
if (item.getState() == INITEM_STATUS.Success || item.isNg()) { if (item.getState() == INITEM_STATUS.Success || item.isNg()) {
} else { } else {
String newS = INITEM_STATUS.Fail; String newS = INITEM_STATUS.Fail;
String msg=resultMap.get("msg"); String msg="" ;
if(resultMap.containsKey("msg")) {
msg=resultMap.get("msg").getDescription();
}
if (resultMap.containsKey(item.getRi())) { if (resultMap.containsKey(item.getRi())) {
String reStr=resultMap.get(item.getRi()); Api002MResult mResult=resultMap.get(item.getRi());
Boolean result = reStr.equalsIgnoreCase("true");
if (result == null) { if (mResult.isSuccess()) {
result = false;
}
if (result) {
newS = INITEM_STATUS.Success; newS = INITEM_STATUS.Success;
msg=""; msg="";
}else{ }
if(ObjectUtil.isEmpty(reStr)){ else if(mResult.isWarning()){
msg=resultMap.get("msg"); newS = INITEM_STATUS.Warning;
}else{ msg=mResult.getDescription();
msg=reStr; }
else{
if(ObjectUtil.isNotEmpty(mResult.getDescription())){
msg=mResult.getDescription();
} }
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!