From eb60587fd357e7af1b940f9764de336a65175eb4 Mon Sep 17 00:00:00 2001 From: lty <876263681@qq.com> Date: 星期三, 05 三月 2025 18:03:15 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/jxjdzwcs' into jxjdzwcs --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 171 +++++++++++++++++++++++++------------------------------- 1 files changed, 77 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 45bf0dc..5b8eaa2 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -109,7 +109,7 @@ private SiteController siteController; - public void generateStoreWrkFile1() throws IOException, InterruptedException { + public synchronized void generateStoreWrkFile1() throws IOException, InterruptedException { try { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { @@ -198,68 +198,82 @@ .build() .doPost(); JSONObject jsonObject = JSON.parseObject(response); - if (!Cools.isEmpty(response)&&!Cools.isEmpty(jsonObject.get("ReturnStatus"))&&jsonObject.get("ReturnStatus").equals(0) && !Cools.isEmpty(jsonObject.get("Result").toString())) { - Result result = JSON.parseObject(jsonObject.get("Result").toString(), Result.class); - // 鍒涙柊涓�涓叆搴撳伐浣滄。 - TaskWrk taskWrk = taskWrkService.selectByTaskNo(result.getTaskNo()); - if (Cools.isEmpty(taskWrk)) { - taskWrk = createTask1(result, BoxNo); + if(back){ + if(staProtocol.getWorkNo()>=9801&&staProtocol.getWorkNo()<=9825){ + staProtocol.setStaNo((short)105); + } else if (staProtocol.getWorkNo()>=9826&&staProtocol.getWorkNo()<=9850) { + staProtocol.setStaNo((short)107); + }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { + staProtocol.setStaNo((short)109); + }else{ + staProtocol.setStaNo((short)110); + } + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + }else{ + if (!Cools.isEmpty(response)&&!Cools.isEmpty(jsonObject.get("ReturnStatus"))&&jsonObject.get("ReturnStatus").equals(0) && !Cools.isEmpty(jsonObject.get("Result").toString())) { + Result result = JSON.parseObject(jsonObject.get("Result").toString(), Result.class); + // 鍒涙柊涓�涓叆搴撳伐浣滄。 + TaskWrk taskWrk = taskWrkService.selectByTaskNo(result.getTaskNo()); if (Cools.isEmpty(taskWrk)) { - log.error("搴撲綅寮傚父锛屽簱浣嶅彿锛�={}", taskWrk.getOriginTargetPoint()); - } else { - taskWrkService.insert(taskWrk); - StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() - .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); - staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); - staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - HashMap<String, Object> hashMap = new HashMap<>(); - hashMap.put("TaskNo",taskWrk.getTaskNo()); - try { - //寮�濮嬩笂鎶�,浠诲姟寮�濮嬫椂锛學CS鍥炶皟WMS - response = new HttpHandler.Builder() - .setUri(wmsUrl) - .setPath(taskStatusFeedbackPath) - .setJson(JSON.toJSONString(hashMap)) - .build() - .doPost(); - JSONObject jsonObject1 = JSON.parseObject(response); - Boolean bool = false; - if(jsonObject1.get("ReturnStatus").equals(0)){ - bool = true; - } - apiLogService.save("wcs寮�濮嬪叆搴撲换鍔′笂鎶ms" - , wmsUrl + TaskExecCallback - , null - , "127.0.0.1" - , JSON.toJSONString(hashMap) - , response - , bool - ); - } catch (Exception e) { + taskWrk = createTask1(result, BoxNo); + if (Cools.isEmpty(taskWrk)) { + log.error("搴撲綅寮傚父锛屽簱浣嶅彿锛�={}", taskWrk.getOriginTargetPoint()); + } else { + taskWrkService.insert(taskWrk); + StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() + .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); + staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); + staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + HashMap<String, Object> hashMap = new HashMap<>(); + hashMap.put("TaskNo",taskWrk.getTaskNo()); + try { + //寮�濮嬩笂鎶�,浠诲姟寮�濮嬫椂锛學CS鍥炶皟WMS + response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath(taskStatusFeedbackPath) + .setJson(JSON.toJSONString(hashMap)) + .build() + .doPost(); + JSONObject jsonObject1 = JSON.parseObject(response); + Boolean bool = false; + if(jsonObject1.get("ReturnStatus").equals(0)){ + bool = true; + } + apiLogService.save("wcs寮�濮嬪叆搴撲换鍔′笂鎶ms" + , wmsUrl + TaskExecCallback + , null + , "127.0.0.1" + , JSON.toJSONString(hashMap) + , response + , bool + ); + } catch (Exception e) { + } } - } - } else { + } else { // staProtocol.setWorkNo((short) 9991); - if(staProtocol.getWorkNo()>=9801&&staProtocol.getWorkNo()<=9825){ - staProtocol.setStaNo((short)105); - } else if (staProtocol.getWorkNo()>=9826&&staProtocol.getWorkNo()<=9850) { - staProtocol.setStaNo((short)107); - }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { - staProtocol.setStaNo((short)109); - }else{ - staProtocol.setStaNo((short)110); + if(staProtocol.getWorkNo()>=9801&&staProtocol.getWorkNo()<=9825){ + staProtocol.setStaNo((short)105); + } else if (staProtocol.getWorkNo()>=9826&&staProtocol.getWorkNo()<=9850) { + staProtocol.setStaNo((short)107); + }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { + staProtocol.setStaNo((short)109); + }else{ + staProtocol.setStaNo((short)110); + } + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); } + + } else { +// staProtocol.setWorkNo((short) 9991); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); devpThread.setPakMk(staProtocol.getSiteId(), false); MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); } - - } else { -// staProtocol.setWorkNo((short) 9991); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); } } catch (Exception e) { log.error("璇锋眰鍏ュ簱璋冪敤鎺ュ彛澶辫触"); @@ -297,7 +311,7 @@ } } - public void generateStoreWrkFile() throws IOException, InterruptedException { + public synchronized void generateStoreWrkFile() throws IOException, InterruptedException { try { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { @@ -574,7 +588,7 @@ /** * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 */ - public void crnStnToOutStn() { + public synchronized void crnStnToOutStn() { for (CrnSlave crnSlave : slaveProperties.getCrn()) { // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯 for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { @@ -679,7 +693,7 @@ /** * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� */ - public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) throws IOException { + public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) throws IOException { for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { List<StaDesc> staDescs = staDescMapper.selectList(new EntityWrapper<StaDesc>().eq("crn_no", slave.getId()).eq("crn_stn", crnStn.getStaNo())); for (StaDesc staDesc : staDescs) { @@ -764,7 +778,7 @@ * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� * 2022-06-09 TQS淇敼锛屾煡璇㈠伐浣滄。LIST锛岄亶鍘嗕笅鍙戯紝闃叉绗竴涓换鍔″牭濉炲嚭搴� */ - public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { + public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { List<TaskWrk> taskWrksInitial = taskWrkMapper.selectPakOut(slave.getId(), null); if (taskWrksInitial.size() == 0) { return; @@ -849,36 +863,6 @@ command.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� command.setCommand((short) 1); - if(Cools.isEmpty(taskWrk.getMarkStart())||taskWrk.getMarkStart()==0){ - HashMap<String, Object> hashMap = new HashMap<>(); - hashMap.put("TaskNo",taskWrk.getTaskNo()); - String response = ""; - try { - //寮�濮嬩笂鎶�,鍑哄簱浠诲姟寮�濮嬫椂锛學CS鍥炶皟WMS - response = new HttpHandler.Builder() - .setUri(wmsUrl) - .setPath(taskStatusFeedbackPath) - .setJson(JSON.toJSONString(hashMap)) - .build() - .doPost(); - JSONObject jsonObject = JSON.parseObject(response); - Boolean bool = false; - if(jsonObject.get("ReturnStatus").equals(0)){ - bool = true; - taskWrk.setMarkStart(1); - } - apiLogService.save("wcs寮�濮嬩换鍔′笂鎶ms" - , wmsUrl + TaskExecCallback - , null - , "127.0.0.1" - , JSON.toJSONString(hashMap) - , response - , bool - ); - } catch (Exception e) { - } - } - if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, command), false)) { log.error("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(command)); throw new CoolException("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐�"); @@ -887,7 +871,6 @@ // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� Date now = new Date(); taskWrk.setWrkSts(12); - taskWrk.setStatus(2); taskWrk.setModiTime(now); if (taskWrkMapper.updateById(taskWrk) == 0) { log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", taskWrk.getWrkNo()); @@ -933,7 +916,7 @@ /** * 搴撲綅绉昏浆 */ - public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) { + public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) { for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑绉诲簱宸ヤ綔妗� List<TaskWrk> taskWrks = taskWrkMapper.selectList(new EntityWrapper<TaskWrk>() @@ -1080,7 +1063,7 @@ /** * 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣� */ - public void storeFinished() throws InterruptedException { + public synchronized void storeFinished() throws InterruptedException { for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -1154,7 +1137,7 @@ /** * 鍫嗗灈鏈哄紓甯镐俊鎭褰� */ - public void recCrnErr() { + public synchronized void recCrnErr() { Date now = new Date(); for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� @@ -1270,7 +1253,7 @@ } //鑷姩娲惧彂浠诲姟 - public void autoDistribute() { + public synchronized void autoDistribute() { Config config = configService.selectByCode("autoDistribute"); if (config == null) { return; -- Gitblit v1.9.1