Commit 92dc9d31 LN

api004问题修改

1 个父辈 61b1a9c1
...@@ -82,7 +82,7 @@ public class MicronApi { ...@@ -82,7 +82,7 @@ public class MicronApi {
} }
public static boolean Debug=true; public static boolean Debug=false;
public static Barcode API001(String operationId,String rfid, Barcode barcode) throws ApiException { public static Barcode API001(String operationId,String rfid, Barcode barcode) throws ApiException {
...@@ -321,8 +321,13 @@ public class MicronApi { ...@@ -321,8 +321,13 @@ public class MicronApi {
try { try {
log.info("调用MES接口 API004: url=" + url + ""); log.info("调用MES接口 API004: url=" + url + "");
MicronResult result = HttpHelper.getMicronJson(url); MicronResult result = HttpHelper.getMicronJson(url);
if (result.isOk()&& result.statusIsSuccess()) { if (result.isOk() ) {
return result.getResult("dispatchIds"); List<DispatchId> resultDis= result.getResult("dispatchIds",false);
if(resultDis==null||resultDis.size()<=0){
log.info("API004 ,接口通信失败");
throw new ApiException("smfcore.api.fail", "{0} Failed to get data", new String[]{"API004"});
}
return resultDis;
}else{ }else{
log.info("API004 ,接口通信失败"); log.info("API004 ,接口通信失败");
...@@ -581,6 +586,9 @@ public class MicronApi { ...@@ -581,6 +586,9 @@ public class MicronApi {
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);
......
...@@ -51,7 +51,12 @@ public class MicronResult implements Serializable { ...@@ -51,7 +51,12 @@ public class MicronResult implements Serializable {
private Map<String, Object> resultMap = null; private Map<String, Object> resultMap = null;
public <T> T getResult(String key) throws ApiException {
public <T> T getResult(String key ) throws ApiException {
return getResult(key,true);
}
public <T> T getResult(String key,boolean needCheck) throws ApiException {
if (ObjectUtil.isEmpty(responseData)) { if (ObjectUtil.isEmpty(responseData)) {
throw new ApiException("smfcore.api.fail", "{0} Failed to get data", new String[]{"API"}); throw new ApiException("smfcore.api.fail", "{0} Failed to get data", new String[]{"API"});
...@@ -60,19 +65,21 @@ public class MicronResult implements Serializable { ...@@ -60,19 +65,21 @@ public class MicronResult implements Serializable {
if (resultMap == null) { if (resultMap == null) {
resultMap = JsonUtil.toMap(responseData); resultMap = JsonUtil.toMap(responseData);
} }
if(needCheck) {
Object resultStatus = resultMap.get("status");
if (resultStatus == null || (!resultStatus.toString().equalsIgnoreCase("SUCCESS"))) {
//失败
String message = resultMap.get("message").toString();
message = (message == null ? "" : message);
Object error = resultMap.get("error");
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});
Object resultStatus = resultMap.get("status"); }
if (resultStatus == null || (!resultStatus.toString().equalsIgnoreCase("SUCCESS"))) {
//失败
String message = resultMap.get("message").toString();
message = (message == null ? "" : message);
Object error = resultMap.get("error");
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()) {
...@@ -92,6 +99,18 @@ public class MicronResult implements Serializable { ...@@ -92,6 +99,18 @@ public class MicronResult implements Serializable {
} catch (Exception ex) { } catch (Exception ex) {
} }
try {
for(String mKey :resultMap.keySet()){
Object mvalue=resultMap.get(mKey);
if(key.equalsIgnoreCase(mKey)){
return (T)mvalue;
}
}
} catch (Exception ex) {
}
} }
} }
return null; return null;
......
...@@ -109,7 +109,7 @@ public class LoadingController { ...@@ -109,7 +109,7 @@ public class LoadingController {
@ApiOperation("lOADING页面获取列表详情数据") @ApiOperation("lOADING页面获取列表详情数据")
@GetMapping("/detial") @GetMapping("/detial")
@AnonymousAccess @AnonymousAccess
public ResultBean detial(@RequestBody Map<String,Object> params ) { public ResultBean detial(@RequestParam Map<String,Object> params ) {
//参数:mType 物料类型:pcb/shoebox/pizzaBox/reel/tray //参数:mType 物料类型:pcb/shoebox/pizzaBox/reel/tray
//参数:state 状态: success/xray/failure //参数:state 状态: success/xray/failure
......
package com.neotel.smfcore.custom.micron1053.task; package com.neotel.smfcore.custom.micron1053.task;
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.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
...@@ -25,6 +26,7 @@ import com.neotel.smfcore.custom.micron1053.api.MicronConfig; ...@@ -25,6 +26,7 @@ import com.neotel.smfcore.custom.micron1053.api.MicronConfig;
import com.neotel.smfcore.custom.micron1053.api.bean.DispatchId; import com.neotel.smfcore.custom.micron1053.api.bean.DispatchId;
import com.neotel.smfcore.custom.micron1053.api.bean.Material; import com.neotel.smfcore.custom.micron1053.api.bean.Material;
import com.neotel.smfcore.custom.micron1053.api.bean.TrackStatus; import com.neotel.smfcore.custom.micron1053.api.bean.TrackStatus;
import com.neotel.smfcore.custom.micron1053.bean.MicronResult;
import com.neotel.smfcore.custom.micron1053.task.bean.PreTask; import com.neotel.smfcore.custom.micron1053.task.bean.PreTask;
import com.neotel.smfcore.custom.micron1053.task.bean.dto.MaterialDispatchStatus; import com.neotel.smfcore.custom.micron1053.task.bean.dto.MaterialDispatchStatus;
import com.neotel.smfcore.custom.micron1053.task.bean.dto.TaskDto; import com.neotel.smfcore.custom.micron1053.task.bean.dto.TaskDto;
...@@ -87,7 +89,8 @@ public class MicronPreTaskController { ...@@ -87,7 +89,8 @@ public class MicronPreTaskController {
@ApiOperation("出库页面展示") @ApiOperation("出库页面展示")
@AnonymousAccess @AnonymousAccess
@GetMapping("/getTaskId") @GetMapping("/getTaskId")
public ResultBean task(String mode) { public ResultBean task(String mode) throws ApiException{
//判断是否验证 //判断是否验证
if (!MicronApi.isEnable()) { if (!MicronApi.isEnable()) {
return ResultBean.newErrorResult(9, "smfcore.micron.apiClose", " Not yet open"); return ResultBean.newErrorResult(9, "smfcore.micron.apiClose", " Not yet open");
...@@ -102,31 +105,37 @@ public class MicronPreTaskController { ...@@ -102,31 +105,37 @@ public class MicronPreTaskController {
dto.setItemList(itemList); dto.setItemList(itemList);
List<MaterialDispatchStatus> statusList = getStatusList(itemList); List<MaterialDispatchStatus> statusList = getStatusList(itemList);
dto.setStatusList(statusList); dto.setStatusList(statusList);
} else if (dto != null) { } else if (dto != null &&dto.getType()==1) {
return ResultBean.newOkResult(dto); return ResultBean.newOkResult(dto);
} else { } else {
dto = new TaskDto(); String operationId = "";
//获取operatorationId if (dto == null) {
// String source = micronConfig.api_011_Source; //==null需要获取operationId
String operationId = MicronApi.Api011(mode, SecurityUtils.getLoginUsername(), ""); dto = new TaskDto();
if (StringUtils.isNotBlank(operationId)) { dto.setType(0);
//获取Pre Task ID dto.setMode(mode);
List<DispatchId> dispatchIdList = MicronApi.Api004(operationId); operationId = MicronApi.Api011(mode, SecurityUtils.getLoginUsername(), "");
if (dispatchIdList != null && !dispatchIdList.isEmpty()) {
dto.setMode(mode); if (StringUtils.isNotBlank(operationId)) {
dto.setOperationId(operationId); dto.setOperationId(operationId);
dto.setType(1);
dto.setDispatchIdList(dispatchIdList);
dataCache.updateCache(key, dto); dataCache.updateCache(key, dto);
log.info("mode=" + mode + ",获取到数据:operationId=" + operationId + ",保存数据到cache " + key);
} else { } else {
return ResultBean.newErrorResult(-1,"smfcore.api.fail", "{0} Failed to get data",new String[]{"API004"}); return ResultBean.newErrorResult(-1, "smfcore.api.fail", "Api011 获取数据失败", new String[]{"API011"});
} }
} else { } else {
operationId = dto.getOperationId();
}
// throw new ValidateException("smfcore.api011.fail", "Api011 获取数据失败"); //获取Pre Task ID
return ResultBean.newErrorResult(-1, "smfcore.api.fail", "Api011 获取数据失败", new String[]{"API011"}); List<DispatchId> dispatchIdList = MicronApi.Api004(operationId);
if (dispatchIdList != null && !dispatchIdList.isEmpty()) {
dto.setType(1);
dto.setDispatchIdList(dispatchIdList);
dataCache.updateCache(key, dto);
log.info("mode=" + mode + ",获取到数据:operationId=" + operationId + ",保存数据到cache " + key);
} else {
return ResultBean.newErrorResult(-1, "smfcore.api.fail", "{0} Failed to get data", new String[]{"API004"});
} }
} }
......
...@@ -8,7 +8,10 @@ import java.util.List; ...@@ -8,7 +8,10 @@ import java.util.List;
@Data @Data
public class TaskDto { public class TaskDto {
private int type=1;//1=勾选页面勾选数据,2=已开始出库 /**
*0=勾选数据还未获取,1=勾选页面勾选数据,2=已开始出库
*/
private int type=1;//
private String mode; private String mode;
private String operationId; private String operationId;
private List<LiteOrderItem> itemList; private List<LiteOrderItem> itemList;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!