Commit 51dcbdc6 zshaohui

Merge remote-tracking branch 'origin/smf-core-21088' into smf-core-21088

2 个父辈 fc7b2b26 26e15dcc
...@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.luxsan.api; ...@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.luxsan.api;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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;
...@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -1010,9 +1012,10 @@ public class LuxsanApi extends DefaultSmfApiListener { ...@@ -1010,9 +1012,10 @@ public class LuxsanApi extends DefaultSmfApiListener {
} }
public static List<GetBoxNGResult> getBoxNGsnList(GetBoxNGsnListRequest request) { public static List<GetBoxNGResult> getBoxNGsnList(GetBoxNGsnListRequest request) {
log.info("getBoxNGsnList接口请求参数为:" + JSON.toJSONString(request));
String resultStr = null;
try { try {
log.info("getBoxNGsnList接口请求参数为:" + JSON.toJSONString(request)); resultStr = HttpHelper.postJson(getBoxNGsnListUrl, request);
String resultStr = HttpHelper.postJson(getBoxNGsnListUrl, request);
log.info("getBoxNGsnList接口返回结果为:" + resultStr); log.info("getBoxNGsnList接口返回结果为:" + resultStr);
JSONObject resultJson = JsonUtil.toObj(resultStr, JSONObject.class); JSONObject resultJson = JsonUtil.toObj(resultStr, JSONObject.class);
if (resultJson != null) { if (resultJson != null) {
...@@ -1023,9 +1026,12 @@ public class LuxsanApi extends DefaultSmfApiListener { ...@@ -1023,9 +1026,12 @@ public class LuxsanApi extends DefaultSmfApiListener {
if (StringUtils.isEmpty(errorMessage)) { if (StringUtils.isEmpty(errorMessage)) {
errorMessage = ""; errorMessage = "";
} }
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}],失败原因[{1}]", new String[]{getBoxNGsnListUrl, errorMessage}); log.error(String.format("接口请求失败[%s],失败原因[%s]", getBoxNGsnListUrl, errorMessage));
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}],失败原因[{1}]", new String[]{"getBoxNGsnList", errorMessage});
} else { } else {
List<GetBoxNGResult> resultList = JSONObject.parseArray(dataJson.getString("data"), GetBoxNGResult.class); JSONArray arrayData = dataJson.getJSONArray("data");
System.out.println(arrayData);
List<GetBoxNGResult> resultList = JSONObject.parseArray(JSONArray.toJSONString(arrayData), GetBoxNGResult.class);
if (resultList != null && !resultList.isEmpty()) { if (resultList != null && !resultList.isEmpty()) {
return resultList; return resultList;
} }
...@@ -1033,10 +1039,11 @@ public class LuxsanApi extends DefaultSmfApiListener { ...@@ -1033,10 +1039,11 @@ public class LuxsanApi extends DefaultSmfApiListener {
} }
} }
} catch (ApiException e) { } catch (ApiException e) {
log.error("getBoxNGsnList接口请求失败:" + e.getMessage()); log.error(String.format("接口返回值格式错误[%s]", getBoxNGsnListUrl));
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()}); throw new ValidateException("smfcore.api.error", "接口返回值格式错误[{0}]", new String[]{"getBoxNGsnList"});
} }
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"getBoxNGsnListUrl"}); log.error(String.format("接口请求失败[%s]", getBoxNGsnListUrl));
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"getBoxNGsnList"});
} }
......
...@@ -340,15 +340,6 @@ public class LineController { ...@@ -340,15 +340,6 @@ public class LineController {
public ResultBean getBoxNGsnList(@RequestBody GetBoxNGsnListRequest result){ public ResultBean getBoxNGsnList(@RequestBody GetBoxNGsnListRequest result){
log.info("机种["+result.getModel()+"]和CartonId:" + result.getCarton_id()); log.info("机种["+result.getModel()+"]和CartonId:" + result.getCarton_id());
List<GetBoxNGResult> boxNGsnList = LuxsanApi.getBoxNGsnList(result); List<GetBoxNGResult> boxNGsnList = LuxsanApi.getBoxNGsnList(result);
// List<GetBoxNGResult> boxNGsnList = new ArrayList<>();
// for (int i = 0; i < 10; i++) {
// GetBoxNGResult getBoxNGResult = new GetBoxNGResult();
// getBoxNGResult.setSN("SN" + i);
// getBoxNGResult.setNGREASON("REASON");
// getBoxNGResult.setROW((int)(Math.random() * 15));
// getBoxNGResult.setCOLUMN((int)(Math.random() * 15));
// boxNGsnList.add(getBoxNGResult);
// }
return ResultBean.newOkResult(boxNGsnList); return ResultBean.newOkResult(boxNGsnList);
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!