From 5c50696e9514c45960e08e84ce8c7ccec52a60e4 Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期三, 31 五月 2023 09:28:51 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/utils/PostMesDataUtils.java | 35 ++++++++++++++++------------------- 1 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java b/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java index 0d6d4d6..65ff408 100644 --- a/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java +++ b/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.core.exception.CoolException; import com.zy.asrs.service.ApiLogService; +import com.zy.asrs.service.impl.ApiLogServiceImpl; import com.zy.asrs.task.AbstractHandler; import com.zy.asrs.task.core.ReturnT; import com.zy.common.utils.HttpHandler; @@ -13,50 +14,46 @@ @Slf4j public class PostMesDataUtils extends AbstractHandler<String> { - @Autowired - private ApiLogService apiLogService; - @Value("${mes.url}") - private String mesUrl; + private ApiLogService apiLogService = new ApiLogServiceImpl(); - public ReturnT<String> postMesData(String mesPath, Object combParam){ + public ReturnT<String> postMesData(String name,String URL,String mesPath, Object combParam){ +// if (true){ +// System.out.println("name:"+name+",URL:"+URL+",mesPath:"+mesPath+",combParam:"+combParam); +// return SUCCESS; +// } if(combParam != null){ String response = ""; boolean success = false; try { -// Map<String, Object> map = new HashMap<>(); +// Map<String, Object> map = new HashMap<>() // map.put("appkey","ea1f0459efc02a79f046f982767939ae"); response = new HttpHandler.Builder() // .setHeaders(map) - .setUri(mesUrl) + .setUri(URL) .setPath(mesPath) .setJson(JSON.toJSONString(combParam)) .build() .doPost(); + System.out.println("response:"+response); JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { -// if (jsonObject.getDate("isComplete").equals(true)){ success = true; -// }else if (jsonObject.getDate("isComplete").equals(false)){ -// success = false; -// }else { -// log.error("杩斿洖鍊煎嚭閿�!!!url锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+"/"+mesPath, JSON.toJSONString(combParam), response); -// throw new CoolException("杩斿洖鍊煎嚭閿�"); -// } } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+"/"+mesPath, JSON.toJSONString(combParam), response); - throw new CoolException("涓婃姤mes绯荤粺澶辫触"); + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", URL+"/"+mesPath, JSON.toJSONString(combParam), response); + throw new CoolException("涓婃姤"+name); } } catch (Exception e) { - log.error("fail", e); + log.error("涓婃姤澶辫触"); // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return FAIL.setMsg(e.getMessage()); } finally { try { // 淇濆瓨鎺ュ彛鏃ュ織 apiLogService.save( - "涓婃姤mes绯荤粺", - mesUrl +"/"+ mesPath, + "涓婃姤"+name, + URL +"/"+ mesPath, null, "127.0.0.1", JSON.toJSONString(combParam), -- Gitblit v1.9.1