From 8c48ae1e3efea1c024c605bf22de7b1cf62599a5 Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期六, 23 十一月 2024 15:04:53 +0800 Subject: [PATCH] 优化AGV任务更新逻辑及环境配置 --- src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java | 49 +++++++++++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java b/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java index adfe4fc..4dfd8fe 100644 --- a/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java +++ b/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Slf4j @@ -48,7 +49,7 @@ add(101); add(12); add(53); - add(101); + add(103); add(108); add(111); add(112); @@ -59,6 +60,8 @@ @Value("${agvBasDev.maxWorkNum}") private int maxWrokNum; + @Value("${mes.report}") + private Boolean flag; @Value("${mes.url}") private String url; @Value("${mes.getTokenUrl}") @@ -353,11 +356,7 @@ } //TODO //鏆傛椂鍔犱笂trycatch - try { - reportMes(agvWrkMast, agvWrkDetlListOld); - } catch (Exception e) { - e.printStackTrace(); - } + reportMes(agvWrkMast, agvWrkDetlListOld); return SUCCESS; } @@ -517,7 +516,7 @@ log.error("" + e.getMessage()); } //TODO 寮犺秴 - //reportMes(agvWrkMast, agvWrkDetlListOld); + reportMes(agvWrkMast, agvWrkDetlListOld); return SUCCESS; } @@ -534,7 +533,11 @@ agvWrkMast.setWrkSts(202L); agvWrkMast.setModiTime(new Date()); - agvWrkMastService.updateById(agvWrkMast); + boolean b = agvWrkMastService.updateById(agvWrkMast); + if (!b) { + log.info("鏇存柊浠诲姟鐘舵�佸け璐�,{}", agvWrkMast.getWrkNo()); + throw new CoolException("鏇存柊浠诲姟鐘舵�佸け璐�"); + } if (agvWrkMast.getIoType() == 1) { //淇敼AGV鍏ュ簱閫氱煡妗g姸鎬佸叆鍑虹姸鎬佷负Y agvWaitPakinService.updateIoStatus(agvWrkMast.getWrkNo(), "Y"); @@ -542,7 +545,7 @@ return SUCCESS; } catch (Exception e) { //TODO - //log.error("淇敼AGV鍏ュ簱閫氱煡妗g姸鎬佸叆鍑虹姸鎬佷负Y" + e.getMessage()); + log.error("淇敼AGV鍏ュ簱閫氱煡妗g姸鎬佸叆鍑虹姸鎬佷负Y,{}", e.getMessage()); } return FAIL; } @@ -692,20 +695,26 @@ } private void reportMes(AgvWrkMast agvWrkMast, List<AgvWrkDetl> agvWrkDetls) { + if (!flag) { + return; + } if (Cools.isEmpty(agvWrkDetls)) { return; } //鍖哄垎涓嶅悓浠诲姟绫诲瀷鐨勪笂鎶ユ柟寮� if (IN_TYPE_LIST.contains(agvWrkMast.getIoType())) { - reportMesPakinOrder(agvWrkMast, agvWrkDetls); + String barcode = agvWrkMast.getBarcode(); + if (barcode.startsWith("20") || barcode.startsWith("21") || barcode.startsWith("40")) { + reportMesPakinOrder(agvWrkMast, agvWrkDetls); + } } - if (OUT_TYPE_List.contains(agvWrkMast.getIoType())) { - reportMesPakoutOrder(agvWrkMast, agvWrkDetls); - } - if (MOVE_TYPE_List.contains(agvWrkMast.getIoType())) { - generateMesParam(agvWrkMast, agvWrkDetls); - } +// if (OUT_TYPE_List.contains(agvWrkMast.getIoType())) { +// reportMesPakoutOrder(agvWrkMast, agvWrkDetls); +// } +// if (MOVE_TYPE_List.contains(agvWrkMast.getIoType())) { +// generateMesParam(agvWrkMast, agvWrkDetls); +// } } private void reportMesPakinOrder(AgvWrkMast agvWrkMast, List<AgvWrkDetl> agvWrkDetls) { @@ -742,9 +751,9 @@ } else { MesPakinReportParam mesPakinReportParam = new MesPakinReportParam(); - mesPakinReportParam.setInboundOrderCode(agvWrkDetl.getOrderNo()); + //mesPakinReportParam.setInboundOrderCode(agvWrkDetl.getOrderNo()); mesPakinReportParam.setBizType("0"); - mesPakinReportParam.setInventoryAttr(new MesPakinReportParam.InventoryAttr(agvWrkDetl.getThreeCode().trim(), agvWrkDetl.getMatnr(), agvWrkMast.getLocNo())); + mesPakinReportParam.setInventoryAttr(new MesPakinReportParam.InventoryAttr(null, agvWrkDetl.getMatnr(), agvWrkMast.getLocNo())); mesPakinReportParam.setNoQrCodeExecAmount(new MesPakinReportParam.NoQrCodeExecAmount(agvWrkDetl.getAnfme(), agvWrkDetl.getUnit(), null)); doHttpRequest(mesPakinReportParam, getMesTokenInfo(), "涓婃姤mes鍏ュ簱淇℃伅", url, pakinReportPath, null, "127.0.0.1"); @@ -864,13 +873,13 @@ boolean success = false; try { - response = new HttpHandler.Builder().setUri(url).setPath(path).setHeaders(headParam).setJson(JSONObject.toJSONString(requestParam)).setHttps(true).build().doPost(); + response = new HttpHandler.Builder().setUri(url).setPath(path).setTimeout(30, TimeUnit.SECONDS).setHeaders(headParam).setJson(JSONObject.toJSONString(requestParam)).setHttps(true).build().doPost(); JSONObject jsonObject = JSON.parseObject(response); if (Cools.isEmpty(jsonObject.get("code")) || Integer.parseInt(jsonObject.get("code").toString()) != 200) { log.info("mes鎺ュ彛璋冪敤澶辫触锛岃繑鍥炰俊鎭細" + jsonObject); //TODO 寮犺秴 - //throw new CoolException("mes鎺ュ彛璋冪敤澶辫触锛岃繑鍥炰俊鎭�:" + jsonObject); + throw new CoolException("mes鎺ュ彛璋冪敤澶辫触锛岃繑鍥炰俊鎭�:" + jsonObject); } success = true; return jsonObject; -- Gitblit v1.9.1