From e22952465f1ab08a58f84c2f01e7d4e89b6bd61e Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期一, 18 八月 2025 17:10:34 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 1061 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 772 insertions(+), 289 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 1f7926c..ef9d076 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.Cools; import com.core.common.DateUtils; +import com.core.common.R; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.BasCrnErrorMapper; @@ -61,7 +62,6 @@ */ @Slf4j @Service("mainService") -@Transactional public class MainServiceImpl { public static final long COMMAND_TIMEOUT = 5 * 1000; @@ -130,7 +130,7 @@ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 - if (!staProtocol.isLoading()){ + if (!staProtocol.isLoading()) { continue; } @@ -138,18 +138,18 @@ && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 9999 - && staProtocol.isPakMk()) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); + && staProtocol.isPakMk() && (staProtocol.getEmptyInType() != 1 && staProtocol.getEmptyInType() != 2)) { + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�"); String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); - if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + if (!Cools.isEmpty(barcode)) { + News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); + if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { // staProtocol.setWorkNo((short) 9992); // staProtocol.setStaNo(inSta.getBackSta().shortValue()); // devpThread.setPakMk(staProtocol.getSiteId(), false); // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - News.info(""+mark+" - 2"+" - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); + News.info("" + mark + " - 2" + " - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); // led 寮傚父鏄剧ず if (ledThread != null) { String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; @@ -163,7 +163,7 @@ // devpThread.setPakMk(staProtocol.getSiteId(), false); // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - News.info(""+mark+" - 3"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); + News.info("" + mark + " - 3" + " - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); // led 寮傚父鏄剧ず if (ledThread != null) { String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; @@ -176,13 +176,13 @@ WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); //杩囨护鍒ゆ柇锛岄槻姝㈡嫞鏂欏啀鍏ュ簱璐х墿锛岀粡杩囧叆搴撶珯鍐嶅叆搴撴椂锛岃閫�鍥炲埌閫�搴撶珯 WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode); - if (wrkMast1 !=null){ - if (wrkMast1.getIoType()==103 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()==104){ + if (wrkMast1 != null) { + if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104) { continue; } } if (wrkMast != null) { - News.error(""+mark+" - 4"+" - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo()); + News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo()); // staProtocol.setWorkNo((short)9992); // staProtocol.setStaNo(inSta.getBackSta().shortValue()); // devpThread.setPakMk(staProtocol.getSiteId(), false); @@ -206,7 +206,7 @@ .in("sta_no", 1003, 1007) ); if (!wrkMasts.isEmpty()) { - News.error(""+mark+" - 4"+" - 1003绔欏叆搴擄紝妫�娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode); + News.error("" + mark + " - 4" + " - 1003绔欏叆搴擄紝妫�娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode); continue; } } @@ -233,6 +233,12 @@ .eq("loc_no", dto.getLocNo())); short staNo = dto.getStaNo().shortValue(); + + int sourceStaNo = dto.getSourceStaNo(); + if (sourceStaNo == 1007) { + staNo = 2002; + } + if (inSta.getStaNo() == 1002) { staNo = 2002; } @@ -263,7 +269,7 @@ //// ledThread.errorReset(); // } } else { - News.error(""+mark+" - 5"+" - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); // staProtocol.setWorkNo((short)9992); // staProtocol.setStaNo(inSta.getBackSta().shortValue()); // devpThread.setPakMk(staProtocol.getSiteId(), false); @@ -284,15 +290,15 @@ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - }else { - News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() - +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() - +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); + } else { + News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isAutoing() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk()); } } } - News.infoNoLog(""+mark+" - 0"+" - 缁勬墭 ===銆嬫墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 缁勬墭 ===銆嬫墽琛屽畬鎴�"); } @@ -315,7 +321,7 @@ } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 - if (!staProtocol.isLoading()){ + if (!staProtocol.isLoading()) { continue; } @@ -324,7 +330,7 @@ && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�"); // 鍒ゆ柇閲嶅宸ヤ綔妗� WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); if (wrkMast == null) { @@ -343,20 +349,20 @@ wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 wrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 1"+" - 鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo()); + News.error("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo()); } } else { - News.error(""+mark+" - 2"+" - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); + News.error("" + mark + " - 2" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); } - }else { - News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isLoading()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() - +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() - +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); + } else { + News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk()); } } } - News.infoNoLog(""+mark+" - 0"+" - wms鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - wms鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); } @@ -381,7 +387,7 @@ && staProtocol.isInEnable() && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�"); // // 鑾峰彇鏉$爜鎵弿浠俊鎭� // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); @@ -434,7 +440,7 @@ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); // led 寮傚父鏄剧ず if (ledThread != null) { - String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+pickSta.getBackSta().shortValue()+"绔欑偣"; + String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + pickSta.getBackSta().shortValue() + "绔欑偣"; MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg)); } continue; @@ -489,94 +495,234 @@ devpThread.setPakMk(staProtocol.getSiteId(), false); boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (!result) { - News.error(""+mark+" - 3"+" - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); + News.error("" + mark + " - 3" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); } - }else { - News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isLoading()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() - +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()); + } else { + News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk()); } } } - News.infoNoLog(""+mark+" - 0"+" - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); + } + + /** + * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱-鏉$爜 + */ + public synchronized void stnToCrnStnPickBarcode(Integer mark) { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鎷f枡鍏ュ簱鍙� + for (DevpSlave.Sta insta : devp.getInSta()) { + // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(insta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.getWorkNo() > 0 + && staProtocol.isPakMk()) { + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�"); + + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, insta.getBarcode()); + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", insta.getBarcode(), barcode); + if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + continue; + } + } else { + continue; + } + + WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); + if (wrkMast == null) { + // 鏃犳嫞鏂欐暟鎹� + continue; + } + if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { + continue; + } + + // 鎷c�佺洏銆佸苟 浣滀笟绔欒浆鎹� +// int stnNo = 0; +// if (wrkMast.getStaNo() == 109) { +// stnNo = 127; +// } else if (wrkMast.getStaNo() == 113) { +// stnNo = 128; +// } else { +// log.error("{}鍙蜂换鍔℃暟鎹紓甯革紒", wrkMast.getWrkNo()); +// } + // 鑾峰彇鐩爣绔� + Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() + .eq("type_no", wrkMast.getIoType() - 50) + .eq("stn_no", insta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯 + .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿 + StaDesc staDesc = staDescService.selectOne(wrapper); + if (Cools.isEmpty(staDesc)) { +// News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); +// staProtocol.setWorkNo((short) 9989); +// staProtocol.setStaNo((short) (pickSta.getStaNo().shortValue()-(short)1)); +// devpThread.setPakMk(staProtocol.getSiteId(), false); +// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + //LED + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, insta.getLed()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + insta.getBackSta().shortValue() + "绔欑偣"; + MessageQueue.offer(SlaveType.Led, insta.getLed(), new Task(5, errorMsg)); + } + continue; + } + + try { + // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。 + if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { + throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触"); + } + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { + throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); + } + + Date now = new Date(); + // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�) + Integer staNo = staDesc.getCrnStn(); + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoTime(now); + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 + wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 + wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 婧愮珯 + wrkMast.setStaNo(staNo); // 鐩爣绔� + wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� + wrkMast.setSourceLocNo(""); // 婧愬簱浣嶆竻绌� + wrkMast.setModiTime(now); + wrkMast.setUpdMk("");//鍏佽鍐嶆绉诲簱 + if (wrkMastMapper.updateById(wrkMast) == 0) { + throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + } + // 鏇存柊鏄庣粏妗o_time (鍘嗗彶妗e叧鑱斾娇鐢級 + wrkDetlService.updateIoTime(wrkMast.getWrkNo(), now); + // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + locMast.setLocSts("Q"); + locMast.setModiTime(new Date()); + if (!locMastService.updateById(locMast)) { + throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�"); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + continue; + } + + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + staProtocol.setPalletSize(locMast.getLocType2()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + News.error("" + mark + " - 3" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); + } + + } else { + News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk()); + } + + } + + } + News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); } /** * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 */ public synchronized void crnStnToOutStn(Integer mark) { + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .eq("wrk_sts", 12) + ); - for (CrnSlave crnSlave : slaveProperties.getCrn()) { - // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯 - for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { - // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅 - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); - StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); - if (staProtocol == null) { - continue; - } else { - staProtocol = staProtocol.clone(); + for (WrkMast wrkMast : wrkMasts) { + // 鍒ゆ柇宸ヤ綔妗f潯浠� + if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) { + continue; + } + + Integer devpId = null; + Integer sourceStaNo = wrkMast.getSourceStaNo(); + for (CrnSlave crnSlave : slaveProperties.getCrn()) { + for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { + if (crnStn.getStaNo().equals(sourceStaNo)) { + devpId = crnStn.getDevpPlcId(); + break; + } } - if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { - // 鏌ヨ宸ヤ綔妗� - WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId()); - if (wrkMast == null) { + } + + if (devpId == null) { + News.error("" + mark + " - 0" + " - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯锛屾湭鎵惧埌瀵瑰簲PLC"); + continue; + } + + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpId); + StaProtocol staProtocol = devpThread.getStation().get(sourceStaNo); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + + if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue()) + && (crnProtocol.statusType == CrnStatusType.PUTTING || crnProtocol.statusType == CrnStatusType.WAITING)) { + //鏀捐揣涓� 鎴� 绛夊緟纭 + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�"); + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() + .eq("loc_no", wrkMast.getSourceLocNo())); + + // 涓嬪彂绔欑偣淇℃伅 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + staProtocol.setPalletSize(locMast.getLocType2()); + if (!MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol))) { continue; } - // 鍒ゆ柇宸ヤ綔妗f潯浠� - if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) { - continue; + + // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触 + wrkMast.setWrkSts(14L); + wrkMast.setCrnEndTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) != 0) { + News.info("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14鎴愬姛锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); + } else { + News.error("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); } - // 鍒ゆ柇鍚婅溅鏄惁瀹為檯宸插畬鎴愶紝涓旂數鑴戠姸鎬佸湪move涓紝浠ュ鐢佃剳杩涜鏇存柊宸ヤ綔妗� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol.statusType == CrnStatusType.FETCHING || crnProtocol.statusType == CrnStatusType.PUTTING) { - // 绉诲姩涓� - continue; - } - // 鍒ゆ柇鍫嗗灈鏈虹姸鎬佺瓑寰呯‘璁� - if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue()) - && crnProtocol.statusType == CrnStatusType.WAITING - && crnProtocol.forkPosType == CrnForkPosType.HOME) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); - - // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- - - LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() - .eq("loc_no", wrkMast.getSourceLocNo())); - - // 涓嬪彂绔欑偣淇℃伅 - staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); - staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); - staProtocol.setPalletSize(locMast.getLocType2()); - if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) { - continue; - } - - // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触 - wrkMast.setWrkSts(14L); - wrkMast.setCrnEndTime(new Date()); - if (wrkMastMapper.updateById(wrkMast) != 0) { - // 澶嶄綅鍫嗗灈鏈� - crnThread.setResetFlag(true); - } else { - News.error(""+mark+" - 1"+" - 鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); - } - - }else { - News.errorNoLog(""+mark+" - 6"+" - 鍫嗗灈鏈轰俊鎭笉绗﹀悎鍏ュ簱鏉′欢锛侊紒锛�" - +" 鍫嗗灈鏈虹姸鎬侊細"+crnProtocol.modeType+"==鑷姩AUTO锛�" + CrnModeType.AUTO - +"銆佸爢鍨涙満浠诲姟鍙凤細"+crnProtocol.getTaskNo()+"==宸ヤ綔妗d换鍔″彿锛�" + wrkMast.getWrkNo().shortValue() - +"銆佺姸鎬佹灇涓撅細"+crnProtocol.statusType+"==WAITING锛�90 //浠诲姟瀹屾垚绛夊緟WCS纭)锛�" + CrnStatusType.WAITING - +"銆佽揣鍙変綅缃細"+crnProtocol.forkPosType+"==HOME锛�0 // 璐у弶鍘熶綅锛�" + CrnForkPosType.HOME); - } - } } } - News.infoNoLog(""+mark+" - 0"+" - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 ===銆嬫墽琛屽畬鎴�"); + + News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 ===銆嬫墽琛屽畬鎴�"); } /** @@ -593,7 +739,7 @@ } BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); if (basCrnp == null) { - News.error(""+mark+" - 1"+" - {}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); + News.error("" + mark + " - 1" + " - {}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); continue; } @@ -602,41 +748,47 @@ // continue; // } + //鍫嗗灈鏈哄洖鍘熺偣浠诲姟涓� + Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); + if (object != null) { + continue; + } + // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛屽爢鍨涙満鍏ュ嚭搴撲綔涓氫笅鍙�"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽爢鍨涙満鍏ュ嚭搴撲綔涓氫笅鍙�"); // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡 if (crnProtocol.getLastIo().equals("I")) { if (basCrnp.getInEnable().equals("Y")) { //mark - 1 - .... - this.crnStnToLoc(crn, crnProtocol,mark); // 鍏ュ簱 + this.crnStnToLoc(crn, crnProtocol, mark); // 鍏ュ簱 crnProtocol.setLastIo("O"); } else if (basCrnp.getOutEnable().equals("Y")) { //mark - 2 - .... - this.locToCrnStn(crn, crnProtocol,mark); // 鍑哄簱 + this.locToCrnStn(crn, crnProtocol, mark); // 鍑哄簱 crnProtocol.setLastIo("I"); } } // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡 else if (crnProtocol.getLastIo().equals("O")) { if (basCrnp.getOutEnable().equals("Y")) { - this.locToCrnStn(crn, crnProtocol,mark); // 鍑哄簱 + this.locToCrnStn(crn, crnProtocol, mark); // 鍑哄簱 crnProtocol.setLastIo("I"); } else if (basCrnp.getInEnable().equals("Y")) { - this.crnStnToLoc(crn, crnProtocol,mark); // 鍏ュ簱 + this.crnStnToLoc(crn, crnProtocol, mark); // 鍏ュ簱 crnProtocol.setLastIo("O"); } } } // 搴撲綅绉昏浆 //mark - 3 - .... - this.locToLoc(crn, crnProtocol,mark); - this.locToLoc111(crn, crnProtocol,mark); + this.locToLoc(crn, crnProtocol, mark); + this.locToLoc111(crn, crnProtocol, mark); // this.crnRebackHp(crnProtocol, crnThread); } - News.infoNoLog(""+mark+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂鎵ц瀹屾垚"); + News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂鎵ц瀹屾垚"); } /** @@ -669,14 +821,14 @@ continue; } - Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); + Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); if (object != null) { continue; } List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() .eq("crn_no", crn.getId()) - .eq("wrk_sts", 2) + .notIn("wrk_sts", 5, 14, 15) ); if (!wrkMasts.isEmpty()) { continue; @@ -701,7 +853,7 @@ News.error("鍫嗗灈鏈虹Щ鍔ㄥ懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); } crnThread.setBackHpFlag(true); - redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); + redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 10); try { Thread.sleep(500); } catch (Exception e) { @@ -737,26 +889,26 @@ continue; } - if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60 * 2) { + if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60) { continue; } - Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); + Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); if (object != null) { continue; } List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() .eq("crn_no", crn.getId()) - .notIn("wrk_sts", 5, 14, 15) + .eq("wrk_sts", 2) ); - if (!wrkMasts.isEmpty()) { + if (wrkMasts.isEmpty()) { continue; } CrnSlave.CrnStn crnStn = crn.getCrnInStn().get(0); - News.info("鍫嗗灈鏈烘棤浠诲姟鑷姩鍥炲叆搴撳彛寰呮満==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満"); + News.info("鍫嗗灈鏈烘湁鍏ュ簱浠诲姟鏃讹紝鍥炲叆搴撳彛寰呮満==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満"); // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� @@ -773,7 +925,7 @@ News.error("鍫嗗灈鏈虹Щ鍔ㄥ懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); } crnThread.setBackHpFlag(true); - redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); + redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 10); try { Thread.sleep(500); } catch (Exception e) { @@ -786,15 +938,15 @@ /** * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� */ - public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) { - News.warnNoLog(""+mark+" - 1"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽叆搴�"); + public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) { + News.warnNoLog("" + mark + " - 1" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽叆搴�"); for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { boolean flag = false; // 鑾峰彇鍫嗗灈鏈哄叆搴撶珯淇℃伅 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); if (staProtocol == null) { - News.infoNoLog(""+mark+" - 1"+" - 1"+" - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц)锛歴taProtocol="+staProtocol); + News.infoNoLog("" + mark + " - 1" + " - 1" + " - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц)锛歴taProtocol=" + staProtocol); continue; } else { staProtocol = staProtocol.clone(); @@ -802,7 +954,7 @@ // 鏌ヨ绔欑偣璇︾粏淇℃伅 BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); if (staDetl == null) { - News.error(""+mark+" - 1"+" - 2"+" - 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); + News.error("" + mark + " - 1" + " - 2" + " - 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); continue; } if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() @@ -810,27 +962,27 @@ flag = true; } if (!flag) { - News.errorNoLog(""+mark+" - 1"+" - 3"+" - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(浠ヤ笅闇�瑕佸叏true):" - +"鑷姩淇″彿"+staProtocol.isAutoing()+"鏈夌墿淇″彿"+staProtocol.isLoading() - +"宸ヤ綔鍙�>0"+staProtocol.getWorkNo()+"鍙叆淇″彿"+staProtocol.isInEnable() - +"鑳藉叆淇″彿锛坵ms璁剧疆锛�.equals(\"Y\")"+staDetl.getCanining()); + News.errorNoLog("" + mark + " - 1" + " - 3" + " - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(浠ヤ笅闇�瑕佸叏true):" + + "鑷姩淇″彿" + staProtocol.isAutoing() + "鏈夌墿淇″彿" + staProtocol.isLoading() + + "宸ヤ綔鍙�>0" + staProtocol.getWorkNo() + "鍙叆淇″彿" + staProtocol.isInEnable() + + "鑳藉叆淇″彿锛坵ms璁剧疆锛�.equals(\"Y\")" + staDetl.getCanining()); continue; } // 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。 WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); if (null == wrkMast) { - News.infoNoLog(""+mark+" - 1"+" - 4"+" - 鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); + News.infoNoLog("" + mark + " - 1" + " - 4" + " - 鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); // log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); continue; } // 鑾峰彇搴撲綅淇℃伅 LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); if (locMast == null) { - News.error(""+mark+" - 1"+" - 5"+" - 鏌ヨ搴撳瓨鏃犳暟鎹�--搴撲綅鍙穥}", wrkMast.getLocNo()); + News.error("" + mark + " - 1" + " - 5" + " - 鏌ヨ搴撳瓨鏃犳暟鎹�--搴撲綅鍙穥}", wrkMast.getLocNo()); continue; } if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) { - News.error(""+mark+" - 1"+" - 6"+" - 鍏ュ簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), locMast.getLocSts()); + News.error("" + mark + " - 1" + " - 6" + " - 鍏ュ簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), locMast.getLocSts()); continue; } @@ -850,39 +1002,43 @@ if (Utils.getLaneByLocNo(wrkMast.getLocNo()) != crnProtocol.getCrnLane()) { //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); - if (!currentWrkMasts.isEmpty()) { - continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� - } +// if (!currentWrkMasts.isEmpty()) { +// continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� +// } } } // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� if (Utils.isDeepLoc(slaveProperties, wrkMast.getLocNo())) { - News.warnNoLog(""+mark+" - 1"+" - 8"+" - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}",wrkMast.getWrkNo()); + News.warnNoLog("" + mark + " - 1" + " - 8" + " - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}", wrkMast.getWrkNo()); String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getLocNo()); LocMast shallowLoc = locMastService.selectById(shallowLocNo); // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { - News.warnNoLog(""+mark+" - 1"+" - 9"+" - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warn("" + mark + " - 1" + " - 9" + " - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); if (null == waitWrkMast) { - News.error(""+mark+" - 1"+" - 10"+" - {}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); + News.error("" + mark + " - 1" + " - 10" + " - {}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); } else { if (waitWrkMast.getWrkSts() != 14 && waitWrkMast.getIoType() > 100) { waitWrkMast.setIoPri(15D); waitWrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(waitWrkMast) == 0) { - News.error(""+mark+" - 1"+" - 11"+" - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + News.error("" + mark + " - 1" + " - 11" + " - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); } continue; + } + + if (waitWrkMast.getWrkSts() < 5 && waitWrkMast.getIoType() < 100) { + continue;//鏈変换鍔$姝㈡惉杩愶紝鏈夊彲鑳芥祬搴撲綅鐘舵�佽繕鏈彉鏇村畬鎴� } } } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { - News.warnNoLog(""+mark+" - 1"+" - 12"+" - // F銆丏 搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warn("" + mark + " - 1" + " - 12" + " - // F銆丏 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { - if (moveLocForDeepLoc(slave, shallowLoc,mark)){ + if (moveLocForDeepLoc(slave, shallowLoc, mark)) { wrkMast.setUpdMk("Y"); wrkMast.setIoPri(14D); wrkMastMapper.updateById(wrkMast); @@ -897,17 +1053,17 @@ } continue; } else if (shallowLoc.getLocSts().equals("Q")) { - News.warnNoLog(""+mark+" - 1"+" - 13"+" - // Q 搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warn("" + mark + " - 1" + " - 13" + " - // Q 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { - News.infoNoLog(""+mark+" - 1"+" - 14"+" - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}",waitWrkMast.getWrkSts()); + News.infoNoLog("" + mark + " - 1" + " - 14" + " - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}", waitWrkMast.getWrkSts()); continue; } } } - News.warnNoLog(""+mark+" - 1"+" - 15"+" - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}",wrkMast.getWrkNo().shortValue() - ,crnStn.getRow().shortValue(),crnStn.getBay().shortValue(),crnStn.getLev().shortValue() - ,locMast.getRow1().shortValue(),locMast.getBay1().shortValue(),locMast.getLev1().shortValue()); + News.info("" + mark + " - 1" + " - 15" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue() + , crnStn.getRow().shortValue(), crnStn.getBay().shortValue(), crnStn.getLev().shortValue() + , locMast.getRow1().shortValue(), locMast.getBay1().shortValue(), locMast.getLev1().shortValue()); // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); @@ -922,7 +1078,7 @@ crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 鐩爣搴撲綅鍒� crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 鐩爣搴撲綅灞� if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - News.error(""+mark+" - 1"+" - 16"+" - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + News.error("" + mark + " - 1" + " - 16" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { // long startTime = System.currentTimeMillis(); @@ -943,19 +1099,40 @@ wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 1"+" - 17"+" - 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + News.error("" + mark + " - 1" + " - 17" + " - 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } } } - News.infoNoLog(""+mark+" - 1"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍏ュ簱鎵ц瀹屾瘯"); + News.infoNoLog("" + mark + " - 1" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍏ュ簱鎵ц瀹屾瘯"); } /** * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� * 2022-06-09 TQS淇敼锛屾煡璇㈠伐浣滄。LIST锛岄亶鍘嗕笅鍙戯紝闃叉绗竴涓换鍔″牭濉炲嚭搴� */ - public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) { - News.warnNoLog(""+mark+" - 2"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽嚭搴�"); + public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) { + News.warnNoLog("" + mark + " - 2" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽嚭搴�"); + + int devpTaskStackOver = 20; + Config config = configService.selectOne(new EntityWrapper<Config>() + .eq("code", "devpTaskStackOver")); + if (config != null) { + devpTaskStackOver = Integer.parseInt(config.getValue()); + } + int devpCheckTaskStackOver = 2; + Config config2 = configService.selectOne(new EntityWrapper<Config>() + .eq("code", "devpCheckTaskStackOver")); + if (config2 != null) { + devpCheckTaskStackOver = Integer.parseInt(config2.getValue()); + } + + + Integer devpWorkingCount = commonService.queryDevpWorkingCount(); + if (devpWorkingCount > devpTaskStackOver) { + News.warn("" + mark + " - 2" + " - 0" + " - 杈撻�佺嚎浠诲姟杩囪浇锛屽綋鍓嶈緭閫佺嚎鎵胯浇鏁伴噺:{}", devpWorkingCount); + return; + } + for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗� // WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); @@ -966,20 +1143,20 @@ } // 宸ヤ綔妗g姸鎬佸垽鏂� if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) { - News.error(""+mark+" - 2"+" - 1"+" - 鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); + News.error("" + mark + " - 2" + " - 1" + " - 鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); continue; } // 鑾峰彇婧愬簱浣嶄俊鎭� LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) { - News.error(""+mark+" - 2"+" - 2"+" - 鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts()); + News.error("" + mark + " - 2" + " - 2" + " - 鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts()); continue; } // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅 SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); if (staProtocol == null) { - News.infoNoLog(""+mark+" - 2"+" - 3"+" - 鍫嗗灈鏈哄嚭搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц,鍚﹀垯寰幆缁堟)锛歴taProtocol="+staProtocol); + News.infoNoLog("" + mark + " - 2" + " - 3" + " - 鍫嗗灈鏈哄嚭搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц,鍚﹀垯寰幆缁堟)锛歴taProtocol=" + staProtocol); break; // continue; } else { @@ -998,6 +1175,29 @@ } } + //zhangc + if (wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) { + if (wrkMast.getStaNo() == 1058) { + List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("wrk_sts", 12, 14) + .eq("sta_no", 1058) + ); + if (!Cools.isEmpty(inWrkMasts) && inWrkMasts.size() >= devpCheckTaskStackOver) { + News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦�1058绔欑偣锛屽瓨鍦ㄤ袱绗斿伐浣滀腑鐨勪换鍔★紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo()); + continue; + } + } else if (wrkMast.getStaNo() == 1062) { + List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("wrk_sts", 12, 14) + .eq("sta_no", 1062) + ); + if (!Cools.isEmpty(inWrkMasts) && inWrkMasts.size() >= devpCheckTaskStackOver) { + News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦�1062绔欑偣锛屽瓨鍦ㄤ袱绗斿伐浣滀腑鐨勪换鍔★紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo()); + continue; + } + } + } + // // 鍏ュ嚭搴撴ā寮忓垽鏂� // if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } // if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { @@ -1008,24 +1208,27 @@ // 鏌ヨ绔欑偣璇︾粏淇℃伅 BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); if (staDetl == null) { - News.error(""+mark+" - 2"+" - 5"+" - 鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); + News.error("" + mark + " - 2" + " - 5" + " - 鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); break; // continue; } // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵�� - if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") - && staProtocol.getWorkNo() == 0) { + if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) { //鏍规嵁鍙傛暟鍒ゆ柇鏄惁鏍¢獙鍙嚭淇″彿 String crnOutVerifyOut = "Y"; Config crnOutVerifyOutEnableConfig = configService.selectOne(new EntityWrapper<Config>() .eq("code", "crnOutVerifyOutEnable")); - if(crnOutVerifyOutEnableConfig != null) { + if (crnOutVerifyOutEnableConfig != null) { crnOutVerifyOut = crnOutVerifyOutEnableConfig.getValue(); } if (crnOutVerifyOut.equals("Y")) { if (!staProtocol.isOutEnable()) { + continue; + } + + if (staProtocol.getWorkNo() > 0) { continue; } } @@ -1040,24 +1243,34 @@ } if (crnProtocol.getCrnNo() == 1) { - //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬� - if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) { - //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц - List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); - if (!currentWrkMasts.isEmpty()) { - continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� + String turnCrnExecuteCurrentChannel = "Y"; + Config turnCrnExecuteCurrentChannelConfig = configService.selectOne(new EntityWrapper<Config>() + .eq("code", "turnCrnExecuteCurrentChannel") + ); + if (turnCrnExecuteCurrentChannelConfig != null) { + turnCrnExecuteCurrentChannel = turnCrnExecuteCurrentChannelConfig.getValue(); + } + + if(turnCrnExecuteCurrentChannel.equals("Y")) { + //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬� + if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) { + //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц + List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); + if (!currentWrkMasts.isEmpty()) { + continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� + } } } } // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) { - News.warnNoLog(""+mark+" - 2"+" - 6"+" - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}",wrkMast.getWrkNo()); + News.warnNoLog("" + mark + " - 2" + " - 6" + " - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}", wrkMast.getWrkNo()); String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo()); LocMast shallowLoc = locMastService.selectById(shallowLocNo); // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { - News.warnNoLog(""+mark+" - 2"+" - 7"+" - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warnNoLog("" + mark + " - 2" + " - 7" + " - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); if (null == waitWrkMast) { News.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); @@ -1066,7 +1279,7 @@ waitWrkMast.setIoPri(15D); waitWrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(waitWrkMast) == 0) { - News.error(""+mark+" - 2"+" - 8"+" - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + News.error("" + mark + " - 2" + " - 8" + " - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); } continue; } else { @@ -1074,7 +1287,7 @@ } } } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { - News.warnNoLog(""+mark+" - 2"+" - 9"+" - // F銆丏 搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warnNoLog("" + mark + " - 2" + " - 9" + " - // F銆丏 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); // WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); //2022-08-16 modify,涓嶆牴鎹畊pdmk鏍囪绉诲簱浠诲姟(瀹规槗琚彇娑堝鑷村牭濉�)锛屾煡璇㈠伐浣滄。鏄惁瀛樺湪浠诲姟 WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); @@ -1082,7 +1295,7 @@ // if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk()) // || Cools.isEmpty(waitWrkMast)) { if (Cools.isEmpty(waitWrkMast)) { - if (moveLocForDeepLoc(slave, shallowLoc,mark)){ + if (moveLocForDeepLoc(slave, shallowLoc, mark)) { wrkMast.setUpdMk("Y"); // wrkMast.setIoPri(14D); wrkMastMapper.updateById(wrkMast); @@ -1095,10 +1308,10 @@ News.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo); continue; } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) { - News.warnNoLog(""+mark+" - 2"+" - 10"+" - // Q銆丼 搴撲綅鐘舵��={}",shallowLoc.getLocSts()); + News.warnNoLog("" + mark + " - 2" + " - 10" + " - // Q銆丼 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts()); WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { - News.infoNoLog(""+mark+" - 2"+" - 11"+" - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}",waitWrkMast.getWrkSts()); + News.infoNoLog("" + mark + " - 2" + " - 11" + " - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}", waitWrkMast.getWrkSts()); continue; } } @@ -1110,9 +1323,9 @@ // return; } - News.warnNoLog(""+mark+" - 2"+" - 12"+" - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}",wrkMast.getWrkNo().shortValue() - ,sourceSta.getRow1().shortValue(),sourceSta.getBay1().shortValue(),sourceSta.getLev1().shortValue() - ,crnStn.getRow().shortValue(),crnStn.getBay().shortValue(),crnStn.getLev().shortValue()); + News.warnNoLog("" + mark + " - 2" + " - 12" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue() + , sourceSta.getRow1().shortValue(), sourceSta.getBay1().shortValue(), sourceSta.getLev1().shortValue() + , crnStn.getRow().shortValue(), crnStn.getBay().shortValue(), crnStn.getLev().shortValue()); // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔� CrnCommand crnCommand = new CrnCommand(); @@ -1127,7 +1340,7 @@ crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - News.error(""+mark+" - 2"+" - 13"+" - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + News.error("" + mark + " - 2" + " - 13" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� Date now = new Date(); @@ -1135,14 +1348,14 @@ wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 2"+" - 14"+" - 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + News.error("" + mark + " - 2" + " - 14" + " - 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } break; } } } } - News.infoNoLog(""+mark+" - 2"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍑哄簱鎵ц瀹屾瘯"); + News.infoNoLog("" + mark + " - 2" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍑哄簱鎵ц瀹屾瘯"); } // /** @@ -1265,17 +1478,17 @@ /** * 搴撲綅绉昏浆 */ - public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) { + public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) { // 鑾峰彇宸ヤ綔妗d俊鎭� WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); if (null == wrkMast) { return; } - News.warnNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�"); + News.warnNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�"); // 鑾峰彇婧愬簱浣嶄俊鎭� LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); if (null == sourceSta) { - News.error(""+mark+" - 3"+" - 1"+" - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); + News.error("" + mark + " - 3" + " - 1" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); return; } // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂� @@ -1285,7 +1498,7 @@ // 鑾峰彇鐩爣搴撲綅淇℃伅 LocMast sta = locMastService.selectById(wrkMast.getLocNo()); if (null == sta) { - News.error(""+mark+" - 3"+" - 2"+" - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); + News.error("" + mark + " - 3" + " - 2" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); return; } // 鑾峰彇鍫嗗灈鏈轰俊鎭� 骞� 鍒ゆ柇鏄惁鍙叆鍑� @@ -1304,9 +1517,9 @@ return; } - News.warnNoLog(""+mark+" - 3"+" - 3"+" - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}",wrkMast.getWrkNo().shortValue() - ,sourceSta.getRow1().shortValue(),sourceSta.getBay1().shortValue(),sourceSta.getLev1().shortValue() - ,sta.getRow1().shortValue(),sta.getBay1().shortValue(),sta.getLev1().shortValue()); + News.warnNoLog("" + mark + " - 3" + " - 3" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue() + , sourceSta.getRow1().shortValue(), sourceSta.getBay1().shortValue(), sourceSta.getLev1().shortValue() + , sta.getRow1().shortValue(), sta.getBay1().shortValue(), sta.getLev1().shortValue()); // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); @@ -1321,7 +1534,7 @@ crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 鐩爣搴撲綅鍒� crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 鐩爣搴撲綅灞� if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - News.error(""+mark+" - 3"+" - 4"+" - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + News.error("" + mark + " - 3" + " - 4" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� Date now = new Date(); @@ -1329,36 +1542,37 @@ wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 3"+" - 5"+" - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + News.error("" + mark + " - 3" + " - 5" + " - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } + crnProtocol.setLastIo("I"); } - News.infoNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�"); + News.infoNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�"); } /** * 搴撲綅绉昏浆 */ - public synchronized void locToLoc111(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) { + public synchronized void locToLoc111(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) { // 鑾峰彇宸ヤ綔妗d俊鎭� WrkMast wrkMast = wrkMastMapper.selectLocMove111(slave.getId()); if (null == wrkMast) { return; } - News.warnNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�"); + News.warnNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�"); // 鑾峰彇婧愬簱浣嶄俊鎭� LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo()); if (null == sourceLoc) { - News.error(""+mark+" - 3"+" - 1"+" - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); + News.error("" + mark + " - 3" + " - 1" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); return; } // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂� if (!sourceLoc.getLocSts().equals("R")) { - News.error(""+mark+" - 3"+" - 11"+" - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭簮搴撲綅鐘舵�佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); + News.error("" + mark + " - 3" + " - 11" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭簮搴撲綅鐘舵�佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); return; } - if(wrkMast.getIoType() != 111) { + if (wrkMast.getIoType() != 111) { // 鑾峰彇鐩爣搴撲綅淇℃伅 LocMast loc = locMastService.selectById(wrkMast.getLocNo()); if (null == loc) { @@ -1367,7 +1581,7 @@ } // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂� if (!loc.getLocSts().equals("S")) { - News.error(""+mark+" - 3"+" - 21"+" - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氱洰鏍囧簱浣嶇姸鎬佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); + News.error("" + mark + " - 3" + " - 21" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氱洰鏍囧簱浣嶇姸鎬佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); return; } } @@ -1387,9 +1601,9 @@ return; } - News.warnNoLog(""+mark+" - 3"+" - 3"+" - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}",wrkMast.getWrkNo().shortValue() - ,sourceLoc.getRow1().shortValue(),sourceLoc.getBay1().shortValue(),sourceLoc.getLev1().shortValue() - ,sourceLoc.getRow1().shortValue(),sourceLoc.getBay1().shortValue(),sourceLoc.getLev1().shortValue()); + News.warnNoLog("" + mark + " - 3" + " - 3" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue() + , sourceLoc.getRow1().shortValue(), sourceLoc.getBay1().shortValue(), sourceLoc.getLev1().shortValue() + , sourceLoc.getRow1().shortValue(), sourceLoc.getBay1().shortValue(), sourceLoc.getLev1().shortValue()); // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); @@ -1404,7 +1618,7 @@ crnCommand.setDestinationPosY(sourceLoc.getBay1().shortValue()); // 鐩爣搴撲綅鍒� crnCommand.setDestinationPosZ(sourceLoc.getLev1().shortValue()); // 鐩爣搴撲綅灞� if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - News.error(""+mark+" - 3"+" - 4"+" - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + News.error("" + mark + " - 3" + " - 4" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� Date now = new Date(); @@ -1412,10 +1626,10 @@ wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 3"+" - 5"+" - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + News.error("" + mark + " - 3" + " - 5" + " - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } } - News.infoNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�"); + News.infoNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�"); } @@ -1432,37 +1646,57 @@ } // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛屽宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); if (crnProtocol.getTaskNo() == 9999) { // 鍫嗗灈鏈哄浣� crnThread.setResetFlag(true); - } else { - // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); - if (wrkMast == null) { - News.error(""+mark+" - 1"+" - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo()); - continue; - } + redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 8);//闃叉鍥炲師鐐瑰悗涓嬪彂鎸囦护杩囧揩 + continue; + } + + // 鑾峰彇寰呯‘璁ゅ伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); + if (wrkMast == null) { + News.error("" + mark + " - 1" + " - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo()); + continue; + } + + Date now = new Date(); + if(wrkMast.getIoType() < 100){ // 鍏ュ簱 + 搴撲綅杞Щ ==> 4.鍏ュ簱瀹屾垚 - if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && (wrkMast.getIoType() == 11 || wrkMast.getIoType()==111))) { + if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111))) { wrkMast.setWrkSts(4L); } else { continue; } - Date now = new Date(); + wrkMast.setCrnEndTime(now); wrkMast.setModiTime(now); // 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 if (wrkMastMapper.updateById(wrkMast) > 0) { // 鍫嗗灈鏈哄浣� - News.warnNoLog(""+mark+" - 2"+" - 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 : 鍫嗗灈鏈哄彿={}",crnThread.getCrnProtocol().getCrnNo()); + News.warnNoLog("" + mark + " - 2" + " - 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 : 鍫嗗灈鏈哄彿={}", crnThread.getCrnProtocol().getCrnNo()); + crnThread.setResetFlag(true); + } + }else { + List<Long> list = new ArrayList<>(); + list.add(14L); + list.add(15L); + if (!list.contains(wrkMast.getWrkSts())) { + News.error("" + mark + " - 1" + " - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や絾宸ヤ綔妗g姸鎬佹湭瀹屾垚銆傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo()); + continue; + } + + wrkMast.setCrnEndTime(now); + if (wrkMastMapper.updateById(wrkMast) != 0) { + // 澶嶄綅鍫嗗灈鏈� crnThread.setResetFlag(true); } } } } - News.infoNoLog(""+mark+" - 0"+" - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); } /** @@ -1485,7 +1719,7 @@ BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue()); // 鏈夊紓甯� if (latest == null) { - News.warnNoLog(""+mark+" - 1"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏈変换鍔★紝鏈夊紓甯�"); + News.warnNoLog("" + mark + " - 1" + " - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏈変换鍔★紝鏈夊紓甯�"); if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); if (wrkMast == null) { @@ -1517,7 +1751,7 @@ "浠诲姟涓紓甯�" // 澶囨敞 ); if (!basErrLogService.insert(basErrLog)) { - News.error(""+mark+" - 2"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); + News.error("" + mark + " - 2" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); } } } else { @@ -1527,7 +1761,7 @@ latest.setUpdateTime(now); latest.setStatus(2); if (!basErrLogService.updateById(latest)) { - News.error(""+mark+" - 3"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); + News.error("" + mark + " - 3" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); } } } @@ -1536,7 +1770,7 @@ BasErrLog latest = basErrLogService.findLatest(crn.getId()); // 鏈夊紓甯� if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { - News.warnNoLog(""+mark+" - 4"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏃犱换鍔★紝鏈夊紓甯�"); + News.warnNoLog("" + mark + " - 4" + " - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏃犱换鍔★紝鏈夊紓甯�"); // 璁板綍鏂板紓甯� if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); @@ -1565,7 +1799,7 @@ "鏃犱换鍔″紓甯�" // 澶囨敞 ); if (!basErrLogService.insert(basErrLog)) { - News.error(""+mark+" - 5"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); + News.error("" + mark + " - 5" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); } } // 鏃犲紓甯� @@ -1576,7 +1810,7 @@ latest.setUpdateTime(now); latest.setStatus(2); if (!basErrLogService.updateById(latest)) { - News.error(""+mark+" - 6"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); + News.error("" + mark + " - 6" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); } } } @@ -1584,7 +1818,7 @@ } } - News.infoNoLog(""+mark+" - 0"+" - 鍫嗗灈鏈哄紓甯镐俊鎭褰曟墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈哄紓甯镐俊鎭褰曟墽琛屽畬鎴�"); } @@ -1608,11 +1842,17 @@ } LedThread ledThread = null; - if (!Cools.isEmpty(emptyInSta.getLed())) { + if (!Cools.isEmpty(emptyInSta.getLed())) { ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); } - if (!staProtocol.isLoading()){ + if (!staProtocol.isLoading()) { + continue; + } + + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); + if (barcodeThread == null) { continue; } @@ -1621,8 +1861,32 @@ && staProtocol.isInEnable() && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) - && staProtocol.isPakMk()) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�"); + && staProtocol.isPakMk() + && staProtocol.getEmptyInType() == 1 + ) { + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�"); + + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode); + if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + News.info("" + mark + " - 2" + " - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } + } else { + News.info("" + mark + " - 3" + " - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } try { LocTypeDto locTypeDto = new LocTypeDto(staProtocol); @@ -1631,6 +1895,7 @@ param.setIoType(10); param.setSourceStaNo(emptyInSta.getStaNo()); param.setLocType1(locTypeDto.getLocType1()); + param.setBarcode(barcode); String response = new HttpHandler.Builder() .setUri(wmsUrl) .setPath("/rpc/pakin/loc/v1") @@ -1641,61 +1906,148 @@ if (jsonObject.getInteger("code").equals(200)) { StartupDto dto = jsonObject.getObject("data", StartupDto.class); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() + .eq("loc_no", dto.getLocNo())); + // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 staProtocol.setWorkNo(dto.getWorkNo().shortValue()); staProtocol.setStaNo(dto.getStaNo().shortValue()); + staProtocol.setPalletSize(locMast.getLocType2()); devpThread.setPakMk(staProtocol.getSiteId(), false); boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (!result) { - News.errorNoLog(""+mark+" - 1"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触"); + News.errorNoLog("" + mark + " - 1" + " - 鏇存柊plc绔欑偣淇℃伅澶辫触"); throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } - - if (ledThread != null) { - // 鍛戒护闆嗗悎 - List<LedCommand> commands = new ArrayList<>(); - // 缁勮鍛戒护 - LedCommand ledCommand = new LedCommand(); - ledCommand.setWorkNo(dto.getWorkNo()); - ledCommand.setIoType(1); - ledCommand.setTitle("鍏ㄦ澘鍏ュ簱"); - ledCommand.setLocNo(dto.getLocNo()); - ledCommand.setStaNo(dto.getStaNo()); - commands.add(ledCommand); - MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands)); -// ledThread.errorReset(); } } else { - staProtocol.setWorkNo((short)9992); - staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - News.errorNoLog(""+mark+" - 2"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触"); - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } - if (ledThread != null) { String errorMsg = jsonObject.getString("msg"); if (!Cools.isEmpty(errorMsg)) { MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); } } - News.error(""+mark+" - 3"+" - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + News.error("" + mark + " - 3" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } } catch (Exception e) { e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - } else { - News.errorNoLog(""+mark+" - 4"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() - +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() - +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); + News.errorNoLog("" + mark + " - 4" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isAutoing() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk()); } } } - News.infoNoLog(""+mark+" - 0"+" - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�"); + } + + /** + * 绌烘墭鐩樺叆搴�-浜х嚎 + */ + public synchronized void storeEmptyPltLine(Integer mark) { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻绌烘澘鍏ュ簱鍙� + for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { + // 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + LedThread ledThread = null; + if (!Cools.isEmpty(emptyInSta.getLed())) { + ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); + } + + if (!staProtocol.isLoading()) { + continue; + } + + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); + if (barcodeThread == null) { + continue; + } + + // 绔欑偣鏉′欢鍒ゆ柇 + if (staProtocol.isAutoing() + && staProtocol.isInEnable() + && staProtocol.isEmptyMk() + && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) + && staProtocol.isPakMk() + && staProtocol.getEmptyInType() == 2 + ) { + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�"); + + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode); + if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + News.info("" + mark + " - 2" + " - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } + } else { + News.info("" + mark + " - 3" + " - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } + + WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() + .eq("barcode", barcode) + ); + if (wrkMast != null) { + continue; + } + + int workNo = commonService.getWorkNo(3); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast1 = new WrkMast(); + wrkMast1.setWrkNo(workNo); + wrkMast1.setIoTime(new Date()); + wrkMast1.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細璁惧涓婅蛋 + wrkMast1.setIoType(3); // 鍏ュ嚭搴撶姸鎬侊細3.绔欏埌绔� + wrkMast1.setIoPri(13D); // 浼樺厛绾� + wrkMast1.setSourceStaNo(emptyInSta.getStaNo()); + wrkMast1.setStaNo(1004); + wrkMast1.setBarcode(barcode); + // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast1.setAppeTime(new Date()); + wrkMast1.setModiTime(new Date()); + boolean res = wrkMastService.insert(wrkMast1); + if (!res) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); + } + + // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 + staProtocol.setWorkNo((short) workNo); + staProtocol.setStaNo((short) 2003); + staProtocol.setPalletSize((short) 1); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + News.errorNoLog("" + mark + " - 1" + " - 鏇存柊plc绔欑偣淇℃伅澶辫触"); + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + } else { + News.errorNoLog("" + mark + " - 4" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isAutoing() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk()); + } + } + } + News.infoNoLog("" + mark + " - 0" + " - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�"); } /** @@ -1724,7 +2076,7 @@ if (null == wrkMast) { continue; } - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�:鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�"); wrkMasts.add(wrkMast); // 缁勮鍛戒护 LedCommand ledCommand = new LedCommand(); @@ -1764,7 +2116,7 @@ ledCommand.setTitle("骞舵澘鍏ュ簱"); break; default: - News.error(""+mark+" - 1"+" - 浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); + News.error("" + mark + " - 1" + " - 浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); break; } ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); @@ -1788,21 +2140,64 @@ // }catch (Exception e){ // log.error("宸ヤ綔妗f鏄庣粏杈撳叆鐢佃鏈哄け璐�1锛氬紓甯镐俊鎭�==銆�"+e); // } - wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto( - wrkDetl.getMatnr() - , wrkDetl.getMaktx() - , wrkDetl.getAnfme() - , wrkDetl.getWeight() - , wrkDetl.getStockNum() - , wrkDetl.getStockNum2() - , wrkDetl.getSpecs() - , wrkDetl.getSku() - , wrkDetl.getZpallet() - , wrkDetl.getModel() - , wrkDetl.getSupp() - , wrkDetl.getKpCstmrName() - , wrkDetl.getOrderNo() - ))); + + if (!wrkDetls.isEmpty()) { + WrkDetl wrkDetl = wrkDetls.get(0); + double anfme = 0D; + double weight = 0D; + for (WrkDetl detl : wrkDetls) { + anfme += detl.getAnfme(); + weight += detl.getWeight(); + wrkDetl.setAnfme(anfme); + wrkDetl.setWeight(weight); + } + + List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() + .eq("loc_no", wrkMast.getSourceLocNo())); + double totalAnfme = 0D; + double totalWeight = 0D; + for (LocDetl locDetl : locDetls) { + totalAnfme += locDetl.getAnfme(); + totalWeight += locDetl.getWeight(); + } + wrkDetl.setStockNum(totalAnfme); + wrkDetl.setStockNum2(totalWeight); + + ledCommand.getMatDtos().add(new MatDto( + wrkDetl.getMatnr() + , wrkDetl.getMaktx() + , wrkDetl.getAnfme() + , wrkDetl.getWeight() + , wrkDetl.getStockNum() + , wrkDetl.getStockNum2() + , wrkDetl.getSpecs() + , wrkDetl.getSku() + , wrkDetl.getZpallet() + , wrkDetl.getModel() + , wrkDetl.getSupp() + , wrkDetl.getKpCstmrName() + , wrkDetl.getOrderNo() + , wrkDetl.getCstateid$() + )); + +// wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto( +// wrkDetl.getMatnr() +// , wrkDetl.getMaktx() +// , wrkDetl.getAnfme() +// , wrkDetl.getWeight() +// , wrkDetl.getStockNum() +// , wrkDetl.getStockNum2() +// , wrkDetl.getSpecs() +// , wrkDetl.getSku() +// , wrkDetl.getZpallet() +// , wrkDetl.getModel() +// , wrkDetl.getSupp() +// , wrkDetl.getKpCstmrName() +// , wrkDetl.getOrderNo() +// , wrkDetl.getCstateid$() +// ))); + } + } commands.add(ledCommand); } @@ -1837,7 +2232,7 @@ if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { News.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); continue; - }else { + } else { ledThread.setLedMk(false); } } @@ -1848,7 +2243,7 @@ wrkMast.setOveMk("Y"); wrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(wrkMast) == 0) { - News.errorNoLog(""+mark+" - 4"+" - 鏇存柊宸ヤ綔妗eけ璐�"); + News.errorNoLog("" + mark + " - 4" + " - 鏇存柊宸ヤ綔妗eけ璐�"); throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�"); } } @@ -1862,7 +2257,7 @@ } } - News.infoNoLog(""+mark+" - 0"+" - 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣ㄦ墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣ㄦ墽琛屽畬鎴�"); } /** @@ -1870,7 +2265,7 @@ */ public synchronized void ledReset(Integer mark) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�:鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ @@ -1894,13 +2289,13 @@ if (reset && !ledThread.isLedMk()) { ledThread.setLedMk(true); if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { - News.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + News.error("" + mark + " - 1" + " - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); } else { } } } - News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚锛氬叾浠� ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); + News.infoNoLog("" + mark + " - 0" + " - 鎵ц瀹屾垚锛氬叾浠� ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); } /** @@ -1984,10 +2379,10 @@ * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増) * tip锛氬悓姝� */ - private synchronized boolean moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc,Integer mark) { + private synchronized boolean moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc, Integer mark) { try { - News.warnNoLog(""+mark+"moveLocForDeepLoc"+" - 0"+" - 寮�濮嬫墽琛�:鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)"); + News.warnNoLog("" + mark + "moveLocForDeepLoc" + " - 0" + " - 寮�濮嬫墽琛�:鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)"); List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); LocMast loc = null; for (Integer row : rows) { @@ -2029,7 +2424,7 @@ } if (null == loc) { - News.error(""+mark+"moveLocForDeepLoc"+" - 1"+" - 鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo()); + News.error("" + mark + "moveLocForDeepLoc" + " - 1" + " - 鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo()); return false; // throw new CoolException("鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo()); } else { @@ -2057,7 +2452,7 @@ wrkMast.setModiTime(new Date()); int res = wrkMastMapper.insert(wrkMast); if (res == 0) { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 2"+" - 淇濆瓨宸ヤ綔妗eけ璐�"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 2" + " - 淇濆瓨宸ヤ綔妗eけ璐�"); // throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); return true; } @@ -2075,7 +2470,7 @@ wrkDetl.setAppeTime(new Date()); wrkDetl.setModiTime(new Date()); if (!wrkDetlService.insert(wrkDetl)) { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 3"+" - 淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 3" + " - 淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); // throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); return true; } @@ -2086,12 +2481,12 @@ shallowLoc.setLocSts("R"); // R.鍑哄簱棰勭害 shallowLoc.setModiTime(new Date()); if (!locMastService.updateById(shallowLoc)) { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 4"+" - 鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 4" + " - 鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); // throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); return true; } } else { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 5"+" - 婧愬簱浣嶅嚭搴撳け璐�"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 5" + " - 婧愬簱浣嶅嚭搴撳け璐�"); // throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); return true; } @@ -2100,23 +2495,23 @@ loc.setLocSts("S"); // S.鍏ュ簱棰勭害 loc.setModiTime(new Date()); if (!locMastService.updateById(loc)) { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 6"+" - 鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 6" + " - 鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); // throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); return true; } } else { - News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 7"+" - 绉昏浆澶辫触"); + News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 7" + " - 绉昏浆澶辫触"); // throw new CoolException("绉昏浆澶辫触"); return true; } - } catch (Exception e){ - News.error(""+mark+"moveLocForDeepLoc"+" - 8"+" - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e); + } catch (Exception e) { + News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e); } } } catch (Exception e) { - News.error(""+mark+"moveLocForDeepLoc"+" - 8"+" - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e); + News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e); // e.printStackTrace(); // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } @@ -2282,7 +2677,10 @@ // RGV ===>> 鎵ц瀵筊GV鎿嶄綔 public synchronized void rgvExecute(Integer mark) { - ArrayList<Integer> list = new ArrayList<Integer>(){{add(2003);add(2002);}}; + ArrayList<Integer> list = new ArrayList<Integer>() {{ + add(2003); + add(2002); + }}; for (Integer staNo : list) { Integer devpId = null; Integer rgvStaNoDevpId = null; @@ -2291,7 +2689,7 @@ devpId = 1; rgvStaNo = 2002; rgvStaNoDevpId = 2; - }else { + } else { devpId = 2; rgvStaNo = 2003; rgvStaNoDevpId = 1; @@ -2399,15 +2797,20 @@ // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 if (rgvProtocol.statusType1 == RgvStatusType.WAITING && rgvProtocol.getTaskNo1() != 0) { - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛屽RGV宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽RGV宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 WrkMast wrkMast = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); if (wrkMast == null) { - News.error(""+mark+" - 1"+" - RGV澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); + News.error("" + mark + " - 1" + " - RGV澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); continue; } if (wrkMast.getWrkSts() != 201) { + continue; + } + + if (wrkMast.getIoType() == 3) { + //绔欏埌绔欒蛋鍙﹀涓�涓柟娉� continue; } @@ -2421,7 +2824,7 @@ devpId = 1; devpStaNo = 2003; locNo = wrkMast.getLocNo(); - }else { + } else { //鍑哄簱 updateWrkSts = 15L; devpId = 2; @@ -2457,7 +2860,87 @@ } } } - News.infoNoLog(""+mark+" - 0"+" - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); + News.infoNoLog("" + mark + " - 0" + " - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); + } + + // RGV ===>> 鎵ц瀵筊GV宸ヤ綔妗g殑瀹屾垚鎿嶄綔 绔欏埌绔� + public synchronized void rgvFinished2(Integer mark) { + for (RgvSlave rgvSlave : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); + if (rgvThread == null) { + continue; + } + + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + + // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 + if (rgvProtocol.statusType1 == RgvStatusType.WAITING && rgvProtocol.getTaskNo1() != 0) { + News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽RGV宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); + // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); + if (wrkMast == null) { + News.error("" + mark + " - 1" + " - RGV澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); + continue; + } + + if (wrkMast.getWrkSts() != 201) { + continue; + } + + if (wrkMast.getIoType() != 3) { + //涓嶆槸绔欏埌绔� + continue; + } + + Integer devpId = 2; + Integer devpStaNo = 2002; + + // 鑾峰彇鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devpId); + StaProtocol staProtocol = devpThread.getStation().get(devpStaNo); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.getWorkNo() == 0 + ) { + + short locType2 = 1; + String barcode = wrkMast.getBarcode(); + if (barcode.startsWith("11")) { + locType2 = 1; + } else if (barcode.startsWith("13")) { + locType2 = 2; + } else if (barcode.startsWith("16")) { + locType2 = 3; + } else { + continue; + } + + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + staProtocol.setPalletSize(locType2); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + rgvThread.setResetFlag1(true); + + wrkMastService.delete(new EntityWrapper<WrkMast>() + .eq("wrk_no", wrkMast.getWrkNo())); + } + } + } + News.infoNoLog("" + mark + " - 0" + " - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); } // /** -- Gitblit v1.9.1