Commit 92dc9d31 LN

api004问题修改

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