From 1653b45e28383156055e55a8ba36471f739c528d Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期二, 14 一月 2025 14:57:06 +0800 Subject: [PATCH] 优化MES库存同步逻辑及AGV告警字段 --- src/main/java/com/zy/asrs/task/handler/ReportDataHandler.java | 41 ++++++++++++++++++++++++++++++++++------- 1 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/handler/ReportDataHandler.java b/src/main/java/com/zy/asrs/task/handler/ReportDataHandler.java index 139d6f1..a378f4e 100644 --- a/src/main/java/com/zy/asrs/task/handler/ReportDataHandler.java +++ b/src/main/java/com/zy/asrs/task/handler/ReportDataHandler.java @@ -2,9 +2,11 @@ import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.core.common.Cools; import com.core.exception.CoolException; +import com.zy.asrs.entity.MesLocDetl; import com.zy.asrs.entity.ReportData; import com.zy.asrs.entity.ReportDataLog; import com.zy.asrs.service.ApiLogService; @@ -57,6 +59,9 @@ @Value("${mes.pakoutReportPath}") private String pakoutReportPath; + @Value("${mes.stock}") + private String stock; + @Transactional public ReturnT<String> start(ReportData data, Map<String, Object> mesTokenInfo) { @@ -76,20 +81,21 @@ mesPath = orderReportPath; break; } - doHttpRequest(data.getReportJson(), mesTokenInfo, data.getMemo(), url, mesPath, null, "127.0.0.1"); - reportDataService.deleteById(data.getId()); ReportDataLog reportDataLog = new ReportDataLog(); + String result = doHttpRequest(data.getReportJson(), mesTokenInfo, data.getMemo(), url, mesPath, null, "127.0.0.1"); + reportDataService.deleteById(data.getId()); BeanUtil.copyProperties(data, reportDataLog); reportDataLog.setReportTime(new Date()); reportDataLog.setReportDataId(data.getId()); + reportDataLog.setThreeCode(result); reportDataLogService.insert(reportDataLog); } return SUCCESS; } - private JSONObject doHttpRequest(String requestParam, Map<String, Object> headParam, String namespace, String url, String path, String appkey, String ip) { - String response = ""; + private String doHttpRequest(String requestParam, Map<String, Object> headParam, String namespace, String url, String path, String appkey, String ip) { + String response = "fail"; boolean success = false; try { @@ -102,14 +108,35 @@ throw new CoolException("mes鎺ュ彛璋冪敤澶辫触锛岃繑鍥炰俊鎭�:" + jsonObject); } success = true; - return jsonObject; + return null; } catch (Exception e) { - log.error(e.getMessage()); - throw new CoolException(e.getMessage()); + log.error("mes鎺ュ彛璋冪敤澶辫触锛岃繑鍥炰俊鎭細{}", e.getMessage()); + //throw new CoolException(e.getMessage()); } finally { apiLogService.save(namespace, url + path, appkey, ip, requestParam, response, success); } + return response; + } + + @Transactional + public ReturnT<String> stock(Map<String, Object> mesTokenInfo) { + String result = doHttpRequest("{}", mesTokenInfo, "鍚屾MES搴撳瓨", url, stock, null, "127.0.0.1"); + JSONObject jsonObject = JSONObject.parseObject(result); + Object o = jsonObject.get("data"); + if (o != null) { + JSONObject jsonObject1 = JSONObject.parseObject(o.toString()); + Object o1 = jsonObject1.get("list"); + if (o1 != null) { + JSONArray jsonArray = JSONArray.parseArray(o1.toString()); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject2 = jsonArray.getJSONObject(i); + } + } + } + MesLocDetl mesLocDetl=new MesLocDetl(); + + return SUCCESS; } } -- Gitblit v1.9.1