From cd280ead41b98ee60154038e36d9b83cc25e7d16 Mon Sep 17 00:00:00 2001 From: lsh <1> Date: 星期三, 20 十二月 2023 12:55:25 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/utils/PostMesDataUtils.java | 40 +++++++++++++++++++--------------------- 1 files changed, 19 insertions(+), 21 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..dad036d 100644 --- a/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java +++ b/src/main/java/com/zy/asrs/utils/PostMesDataUtils.java @@ -2,8 +2,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.core.common.SpringUtils; 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,57 +15,53 @@ @Slf4j public class PostMesDataUtils extends AbstractHandler<String> { - @Autowired - private ApiLogService apiLogService; - @Value("${mes.url}") - private String mesUrl; - - 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("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", URL+"/"+mesPath, JSON.toJSONString(combParam), response); // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return FAIL.setMsg(e.getMessage()); } finally { try { // 淇濆瓨鎺ュ彛鏃ュ織 + ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class); apiLogService.save( - "涓婃姤mes绯荤粺", - mesUrl +"/"+ mesPath, + "涓婃姤"+name, + URL +"/"+ mesPath, null, "127.0.0.1", JSON.toJSONString(combParam), response, success ); - } catch (Exception e) { log.error("", e); } + } catch (Exception e) { + log.error("", e); } } } return SUCCESS; -- Gitblit v1.9.1