From 83eb556b86fac1aae7f9d4ea3ea343e8ea9f8b0b Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期四, 06 七月 2023 08:32:14 +0800 Subject: [PATCH] RGV control --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 1916 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 1,575 insertions(+), 341 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 c5b916c..5727e33 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -9,7 +9,7 @@ import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.BasCrnErrorMapper; -import com.zy.asrs.mapper.WaitPakinMapper; +import com.zy.asrs.mapper.BasRgvErrMapper; import com.zy.asrs.mapper.WrkMastMapper; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; @@ -26,30 +26,26 @@ import com.zy.core.cache.MessageQueue; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.*; -import com.zy.core.model.CrnSlave; -import com.zy.core.model.DevpSlave; -import com.zy.core.model.LedSlave; -import com.zy.core.model.Task; +import com.zy.core.model.*; import com.zy.core.model.command.CrnCommand; import com.zy.core.model.command.LedCommand; +import com.zy.core.model.command.RgvCommand; import com.zy.core.model.protocol.CrnProtocol; +import com.zy.core.model.protocol.RgvProtocol; import com.zy.core.model.protocol.StaProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.BarcodeThread; import com.zy.core.thread.LedThread; +import com.zy.core.thread.RgvThread; import com.zy.core.thread.SiemensDevpThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -72,13 +68,13 @@ @Autowired private WrkDetlService wrkDetlService; @Autowired - private WaitPakinMapper waitPakinMapper; - @Autowired private LocMastService locMastService; @Autowired private StaDescService staDescService; @Autowired private BasCrnpService basCrnpService; + @Autowired + private BasRgvService basRgvService; @Autowired private BasDevpService basDevpService; @Autowired @@ -87,6 +83,12 @@ private BasErrLogService basErrLogService; @Autowired private BasCrnErrorMapper basCrnErrorMapper; + @Autowired + private BasRgvErrMapper basRgvErrMapper; + @Autowired + private BasRgvErrLogService basRgvErrLogService; + @Autowired + private BasRgvPathService basRgvPathService; @Value("${wms.url}") private String wmsUrl; @@ -95,7 +97,7 @@ * 缁勬墭 * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2 */ - public void generateStoreWrkFile() { + public synchronized void generateStoreWrkFile() { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鍏ュ簱鍙� @@ -106,9 +108,10 @@ continue; } String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { + + if (!Cools.isEmpty(barcode)) { log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); - if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { continue; } } else { @@ -116,6 +119,7 @@ } // 鑾峰彇鍏ュ簱绔欎俊鎭� +// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); if (staProtocol == null) { @@ -125,13 +129,18 @@ } // 鍏ュ嚭搴撴ā寮忓垽鏂� - if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } +// if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } +// if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { +// continue; +// } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 - if (staProtocol.isAutoing() && staProtocol.isLoading() + if (staProtocol.isAutoing() + && staProtocol.isLoading() && staProtocol.isInEnable() - && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) - && staProtocol.isPakMk()){// && !Cools.isEmpty(barcode)) { + && !staProtocol.isEmptyMk() + && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) + && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) { // if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { // log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); @@ -180,73 +189,21 @@ barcodeThread.setBarcode(""); staProtocol.setWorkNo(dto.getWorkNo().shortValue()); - staProtocol.setStaNo(dto.getStaNo().shortValue()); + + if(Cools.isEmpty(dto.getRgvNo()) || dto.getRgvNo() <= 0) { + staProtocol.setStaNo(dto.getStaNo().shortValue()); + } else {//濡傛灉瀛樺湪RGV缂栧彿锛岃鏄庨渶瑕丷GV鎺ラ┏锛屽厛涓嬪彂浠诲姟鍒癛GV婧愮珯 + staProtocol.setStaNo(dto.getRgvSstaNo().shortValue()); + } + devpThread.setPakMk(staProtocol.getSiteId(), false); boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (!result) { throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } - - -// // 妫�绱㈠簱浣� -// LocTypeDto locTypeDto = new LocTypeDto(staProtocol); -// List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); -// StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos, locTypeDto, 0); -// // 宸ヤ綔鍙� -// int workNo = startupDto.getWorkNo(); -// // 鎻掑叆宸ヤ綔鏄庣粏妗� -// wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); -// -// // 鎻掑叆宸ヤ綔涓绘。 -// wrkMast = new WrkMast(); -// wrkMast.setWrkNo(workNo); -// wrkMast.setIoTime(new Date()); -// wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 -// wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱 -// wrkMast.setIoPri(10D); // 浼樺厛绾э細10 -// wrkMast.setCrnNo(startupDto.getCrnNo()); -// wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); -// wrkMast.setStaNo(startupDto.getStaNo()); -// wrkMast.setLocNo(startupDto.getLocNo()); -// wrkMast.setBarcode(barcode); // 鎵樼洏鐮� -// wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 -// wrkMast.setPicking("N"); // 鎷f枡 -// wrkMast.setExitMk("N"); // 閫�鍑� -// wrkMast.setEmptyMk("N"); // 绌烘澘 -// wrkMast.setLinkMis("N"); -// // 鎿嶄綔浜哄憳鏁版嵁 -// wrkMast.setAppeTime(new Date()); -// wrkMast.setModiTime(new Date()); -// Integer insert = wrkMastMapper.insert(wrkMast); -// if (insert == 0) { -// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); -// } -// // 鏇存柊鐩爣搴撲綅鐘舵�� -// LocMast locMast = locMastService.selectById(startupDto.getLocNo()); -// locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 -// locMast.setModiTime(new Date()); -// if (!locMastService.updateById(locMast)){ -// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); -// } -// // 灏嗗叆搴撻�氱煡妗d慨鏀逛负宸插惎鍔� -// if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { -// throw new CoolException("淇敼鍏ュ簱閫氱煡妗g姸鎬佷负宸插惎鍔ㄥけ璐�"); -// } -// -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 -// barcodeThread.setBarcode(""); -// staProtocol.setWorkNo((short) workNo); -// staProtocol.setStaNo(startupDto.getStaNo().shortValue()); -// devpThread.setPakMk(staProtocol.getSiteId(), false); -// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); -// if (!result) { -// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); -// } } catch (Exception e) { e.printStackTrace(); @@ -265,7 +222,7 @@ * wms鍏ュ簱 * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 1 ==>> 2 */ - public void generateStoreWrkFile0() { + public synchronized void generateStoreWrkFile0() { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鍏ュ簱鍙� @@ -280,7 +237,9 @@ } // // 鍏ュ嚭搴撴ā寮忓垽鏂� - if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } + if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { + continue; + } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() @@ -288,7 +247,9 @@ && staProtocol.isPakMk()) { // 鍒ゆ柇閲嶅宸ヤ綔妗� WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); - if (wrkMast == null) { continue; } + if (wrkMast == null) { + continue; + } // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- @@ -319,7 +280,7 @@ /** * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 */ - public synchronized void stnToCrnStnPick(){ + public synchronized void stnToCrnStnPick() { for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鎷f枡鍏ュ簱鍙� for (DevpSlave.Sta pickSta : devp.getPickSta()) { @@ -350,7 +311,7 @@ // // 鍏ュ嚭搴撴ā寮忓垽鏂� // if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){ + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()) { // WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); if (wrkMast == null) { @@ -358,7 +319,7 @@ continue; } if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) - || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { continue; } @@ -441,8 +402,7 @@ /** * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 */ - @Async - public void crnStnToOutStn() { + public synchronized void crnStnToOutStn() { for (CrnSlave crnSlave : slaveProperties.getCrn()) { // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯 for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { @@ -505,43 +465,43 @@ /** * 鍏ュ嚭搴� ===>> 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 */ - public synchronized void crnIoExecute(){ + public synchronized void crnIoExecute() { for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { continue; } + if (crnProtocol == null) { + continue; + } BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); if (basCrnp == null) { log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); continue; } -// //鍫嗗灈鏈哄洖鍘熺偣浠诲姟涓� -// if(crnThread.isBackHpFlag()){ -// continue; -// } - // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� - if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO - && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) { + if (crnProtocol.getStatusType() == CrnStatusType.IDLE + && crnProtocol.getTaskNo() == 0 + && crnProtocol.getModeType() == CrnModeType.AUTO + && crnProtocol.getLoaded() == 0 + && crnProtocol.getForkPos() == 0) { // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡 if (crnProtocol.getLastIo().equals("I")) { if (basCrnp.getInEnable().equals("Y")) { - this.crnStnToLoc(crn, crnProtocol); // 鍏ュ簱 + this.crnStnToLoc1(crn, crnProtocol); // 鍏ュ簱 crnProtocol.setLastIo("O"); } else if (basCrnp.getOutEnable().equals("Y")) { - this.locToCrnStn(crn, crnProtocol); // 鍑哄簱 + this.locToCrnStn1(crn, crnProtocol); // 鍑哄簱 crnProtocol.setLastIo("I"); } } // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡 else if (crnProtocol.getLastIo().equals("O")) { if (basCrnp.getOutEnable().equals("Y")) { - this.locToCrnStn(crn, crnProtocol); // 鍑哄簱 + this.locToCrnStn1(crn, crnProtocol); // 鍑哄簱 crnProtocol.setLastIo("I"); } else if (basCrnp.getInEnable().equals("Y")) { - this.crnStnToLoc(crn, crnProtocol); // 鍏ュ簱 + this.crnStnToLoc1(crn, crnProtocol); // 鍏ュ簱 crnProtocol.setLastIo("O"); } } @@ -554,9 +514,231 @@ } /** + * 鎼滅储RGV杞︺�傞�氳繃鐩爣绔欐悳绱㈠摢鍙拌溅鍙敤 + */ + public synchronized Integer searchRgvNo(Integer staNo) { + BasDevp basDevp = basDevpService.selectById(staNo); + if (basDevp == null) { + return null;//鐩爣绔欎笉瀛樺湪 + } + //璺緞鍊� + int path = basDevp.getLocType3().intValue(); + + ArrayList<RgvThread> list = new ArrayList<>(); + for (RgvSlave rgv : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + BasRgv basRgv = basRgvService.selectById(rgv.getId()); + if (basRgv == null) { + log.error("{}鍙稲GV灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", rgv.getId()); + continue; + } + + list.add(rgvThread); + } + + if (list.size() > 1) { + //瓒呰繃涓ゅ彴杞︼紝鎸夌収閰嶇疆鐨勮鍒欒繘琛屽垎閰� + for (RgvThread rgvThread : list) { + //鑾峰彇杞﹁締閰嶇疆鐨勮矾寰勮鍒� + BasRgvPath basRgvPath = basRgvPathService.selectByRgvNo(rgvThread.getSlave().getId()); + if (basRgvPath == null) { + continue; + } + //鐩爣绔欐槸鍚﹀寘鍚綋鍓嶈矾寰勪腑 + List<Integer> rgvPath = JSON.parseArray(basRgvPath.getPath(), Integer.class); + if (rgvPath.contains(path)) { + //褰撳墠璺緞涓寘鍚洰鏍囩珯锛屽垯閫夊畾杩欏彴杞� + return rgvThread.getSlave().getId(); + } + } + }else { + //灏忎簬鎴栫瓑浜�1鍙拌溅锛屽垎閰嶅叏璺緞 + BasRgvPath basRgvPath = basRgvPathService.selectByRgvNo(0);//鑾峰彇榛樿璺緞 + if (basRgvPath == null) { + return null; + } + List<Integer> rgvPath = JSON.parseArray(basRgvPath.getPath(), Integer.class); + if (rgvPath.contains(path)) { + //褰撳墠璺緞涓寘鍚洰鏍囩珯锛屽垯閫夊畾杩欏彴杞� + return list.get(0).getSlave().getId(); + } + } + + return null; + } + + /** + * 缁戝畾灏忚溅鏂规硶 + */ + public synchronized void rgvBindSte() { + //鑾峰彇绛夊緟缁戝畾RGV鐨勪换鍔� + List<WrkMast> wrkMasts = wrkMastMapper.selectWaitBindRGV(); + for (WrkMast wrkMast : wrkMasts) { + //鐩爣绔� + Integer staNo = wrkMast.getStaNo(); + //閫氳繃鐩爣绔欐悳绱gv鍙� + Integer rgvNo = this.searchRgvNo(staNo); + if (rgvNo == null) {//鏈壘鍒板彲鐢ㄧ殑rgv + continue; + } + + wrkMast.setRgvNo(rgvNo);//缁戝畾rgv鍙� + wrkMast.setRgvDstaNo(wrkMast.getSourceStaNo());//璁剧疆RGV鍓嶅線宸ヤ綔妗f簮绔欏彇璐� + if (wrkMastMapper.updateById(wrkMast)==0){ + log.error("缁戝畾灏忚溅鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo()); + } + } + } + + /** + * 鍏ュ嚭搴� ===>> RGV鍏ュ嚭搴撲綔涓氫笅鍙� + */ + public synchronized void rgvIoExecute() { + for (RgvSlave rgv : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + BasRgv basRgv = basRgvService.selectById(rgv.getId()); + if (basRgv == null) { + log.error("{}鍙稲GV灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", rgv.getId()); + continue; + } + + // 鍙湁褰揜GV绌洪棽銆佽嚜鍔�, + if (rgvProtocol.getStatusType() == RgvStatusType.IDLE + && rgvProtocol.getModeType() == RgvModeType.AUTO +// && rgvProtocol.getTaskNo1() == 0 && rgvProtocol.getTaskNo2() == 0 +// && rgvProtocol.getLoaded1() == 0 && rgvProtocol.getLoaded2() == 0 + ) { + + //鏌ユ壘鏄惁瀛樺湪鍏ュ嚭搴撳伐浣滀腑绛夊緟RGV鎼繍鐨勪换鍔� + List<WrkMast> wrkMasts = wrkMastMapper.selectIoRgvNo(rgv.getId()); + for (WrkMast wrkMast : wrkMasts) { + if (wrkMast.getWrkSts() == 2) {//2.璁惧涓婅蛋1 => 3.RGV鍙栬揣涓� + if (rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getLoaded1() != 0) {//RGV鏄惁鏃犱换鍔°�丷GV鏄惁鏃犺揣 + continue; + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH); // 宸ヤ綅1浠诲姟妯″紡: 鍙栬揣 + rgvCommand.setDestinationStaNo1(wrkMast.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 1); //宸ヤ綅1浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getRgvNo(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋1 => 3.RGV鍙栬揣涓� + Date now = new Date(); + wrkMast.setWrkSts(3L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋1 => 3.RGV鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } + } else if (wrkMast.getWrkSts() == 4) {//4.RGV鍙栬揣瀹屾垚 => 5.RGV鏀捐揣涓� + if (rgvProtocol.getTaskNo1() == 0 || !rgvProtocol.getTaskNo1().equals(wrkMast.getWrkNo().shortValue())) {//RGV蹇呴』鏈変换鍔′笖浠诲姟鍜屽綋鍓嶅伐浣滄。涓�鑷� + continue; + } + if (rgvProtocol.getLoaded1() == 0) {//RGV蹇呴』鏈夌墿 + continue; + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.PUT); // 宸ヤ綅1浠诲姟妯″紡: 鏀捐揣 + rgvCommand.setDestinationStaNo1(wrkMast.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 1); //宸ヤ綅1浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getRgvNo(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 4.RGV鍙栬揣瀹屾垚 => 5.RGV鏀捐揣涓� + Date now = new Date(); + wrkMast.setWrkSts(5L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 4.RGV鍙栬揣瀹屾垚 => 5.RGV鏀捐揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } + } else if (wrkMast.getWrkSts() == 23) {//23.璁惧涓婅蛋1 => 24.RGV鍙栬揣涓� + if (rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getLoaded1() != 0) {//RGV鏄惁鏃犱换鍔°�丷GV鏄惁鏃犺揣 + continue; + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH); // 宸ヤ綅1浠诲姟妯″紡: 鍙栬揣 + rgvCommand.setDestinationStaNo1(wrkMast.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 1); //宸ヤ綅1浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getRgvNo(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 23.璁惧涓婅蛋1 => 24.RGV鍙栬揣涓� + Date now = new Date(); + wrkMast.setWrkSts(24L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 23.璁惧涓婅蛋1 => 24.RGV鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } + } else if (wrkMast.getWrkSts() == 25) {//25.RGV鍙栬揣瀹屾垚 => 26.RGV鏀捐揣涓� + if (rgvProtocol.getTaskNo1() == 0 || !rgvProtocol.getTaskNo1().equals(wrkMast.getWrkNo().shortValue())) {//RGV蹇呴』鏈変换鍔′笖浠诲姟鍜屽綋鍓嶅伐浣滄。涓�鑷� + continue; + } + if (rgvProtocol.getLoaded1() == 0) {//RGV蹇呴』鏈夌墿 + continue; + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.PUT); // 宸ヤ綅1浠诲姟妯″紡: 鏀捐揣 + rgvCommand.setDestinationStaNo1(wrkMast.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 1); //宸ヤ綅1浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getRgvNo(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 25.RGV鍙栬揣瀹屾垚 => 26.RGV鏀捐揣涓� + Date now = new Date(); + wrkMast.setWrkSts(26L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 25.RGV鍙栬揣瀹屾垚 => 26.RGV鏀捐揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } + } + } + + } + } + } + + /** * 鍥炲師鐐癸紝鍫嗗灈鏈烘病鏈夋墽琛屼腑浠诲姟锛岃澶囧瓨鍦ㄥ叆搴撲换鍔℃椂鍙洖鍘熺偣 */ - public synchronized void crnRebackHp(CrnProtocol crnProtocol, CrnThread crnThread){ + public synchronized void crnRebackHp(CrnProtocol crnProtocol, CrnThread crnThread) { // for (CrnSlave crn : slaveProperties.getCrn()) { // // 鑾峰彇鍫嗗灈鏈轰俊鎭� // CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -569,50 +751,50 @@ // log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); // continue; // } - if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { - if(crnProtocol.getBay() ==1 && crnProtocol.getLevel()==1){ - return; - } - - // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�3,12 - if (wrkMastMapper.selectWorking(crnProtocol.getCrnNo()) != null) { - return; - } - - //鍫嗗灈鏈烘湁鎵ц涓换鍔★紝杩囨护3,4,11,12 - if (wrkMastMapper.selectCrnWorking(crnProtocol.getCrnNo()) != null) { - return; - } - - //杈撻�佺嚎娌℃湁鍏ュ簱浠诲姟锛岃繃婊�2 - if (wrkMastMapper.selectDevWorking(crnProtocol.getCrnNo()) == null) { - return; - } - log.info("鍫嗗灈鏈哄彫鍥炲師鐐�==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満鏈夊叆搴撲换鍔�,鍙洖鍘熺偣"); - // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- - CrnCommand crnCommand = new CrnCommand(); - crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� - crnCommand.setTaskNo((short) 9999); // 宸ヤ綔鍙� - crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� - crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡: 鍥炲師鐐� - crnCommand.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 - crnCommand.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 - crnCommand.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 - crnCommand.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� - crnCommand.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� - crnCommand.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� - if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { - log.error("鍫嗗灈鏈哄洖鍘熺偣鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); - } - crnThread.setBackHpFlag(true); + if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { + return; } + + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�3,12 + if (wrkMastMapper.selectWorking(crnProtocol.getCrnNo()) != null) { + return; + } + + //鍫嗗灈鏈烘湁鎵ц涓换鍔★紝杩囨护3,4,11,12 + if (wrkMastMapper.selectCrnWorking(crnProtocol.getCrnNo()) != null) { + return; + } + + //杈撻�佺嚎娌℃湁鍏ュ簱浠诲姟锛岃繃婊�2 + if (wrkMastMapper.selectDevWorking(crnProtocol.getCrnNo()) == null) { + return; + } + log.info("鍫嗗灈鏈哄彫鍥炲師鐐�==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満鏈夊叆搴撲换鍔�,鍙洖鍘熺偣"); + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo((short) 9999); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡: 鍥炲師鐐� + crnCommand.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄洖鍘熺偣鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); + } + crnThread.setBackHpFlag(true); + } // } } /** * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� */ - public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){ + public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) { for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { boolean flag = false; // 鑾峰彇鍫嗗灈鏈哄叆搴撶珯淇℃伅 @@ -630,7 +812,7 @@ continue; } if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() - && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) { + && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) { flag = true; } if (!flag) { @@ -638,7 +820,7 @@ } // 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。 WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); - if(null == wrkMast) { + if (null == wrkMast) { // log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); continue; } @@ -693,9 +875,9 @@ // moveLocForDeepLocPakin(slave, shallowLoc, wrkMast); } continue; - } else if (shallowLoc.getLocSts().equals("Q")){ - WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); - if (null != waitWrkMast && waitWrkMast.getWrkSts()==4) { + } else if (shallowLoc.getLocSts().equals("Q")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); + if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { continue; } } @@ -742,26 +924,160 @@ } /** + * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� + * 2022-12-03 TQS淇敼锛屽厛閬嶅巻鏌ヨ鍚屽彴鍫嗗灈鏈哄伐浣滄。鎵�鏈夌珯鐐瑰叆搴撲换鍔IST锛屾牴鎹伐浣滄。浠诲姟鎺掑簭浼樺厛绾ч珮浜� 鏍规嵁鍫嗗灈鏈哄叆搴撶珯鐐规帓搴� + */ + public synchronized void crnStnToLoc1(CrnSlave slave, CrnProtocol crnProtocol) { + List<WrkMast> wrkMasts = wrkMastMapper.selectPakInStep12(slave.getId()); + for(WrkMast wrkMast : wrkMasts){ + if (wrkMast == null) { + continue; + } + + CrnSlave.CrnStn crnStn = null; + for (CrnSlave.CrnStn crnStn1 : slave.getCrnInStn()){ + if(crnStn1.getStaNo() == wrkMast.getStaNo()){ + crnStn = crnStn1; + break; + } else { + continue; + } + } + if(Cools.isEmpty(crnStn)){ + continue; + } + + boolean flag = false; + // 鑾峰彇鍫嗗灈鏈哄叆搴撶珯淇℃伅 + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); + if (staDetl == null) { + log.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); + continue; + } + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() + && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) { + flag = true; + } + if (!flag) { + continue; + } + + // 鑾峰彇搴撲綅淇℃伅 + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + if (locMast == null) { + log.error("鏌ヨ搴撳瓨鏃犳暟鎹�--搴撲綅鍙穥}", wrkMast.getLocNo()); + continue; + } + if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) { + log.error("鍏ュ簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), locMast.getLocSts()); + continue; + } + + // 鍫嗗灈鏈烘帶鍒惰繃婊� + if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { + continue; + } + + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(slave.getId()) != null) { + continue; + } + + // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� + if (Utils.isDeepLoc(slaveProperties, wrkMast.getLocNo())) { + String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getLocNo()); + LocMast shallowLoc = locMastService.selectById(shallowLocNo); + // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 + if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); + if (null == waitWrkMast) { + log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); + } else { + waitWrkMast.setIoPri(15D); + waitWrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(waitWrkMast) == 0) { + log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + } + continue; + } + + } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { + // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� + if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { + wrkMast.setUpdMk("Y"); + wrkMast.setIoPri(14D); + wrkMastMapper.updateById(wrkMast); + // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑 + moveLocForDeepLoc(slave, shallowLoc); + // 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�) +// moveLocForDeepLocPakin(slave, shallowLoc, wrkMast); + } + continue; + } else if (shallowLoc.getLocSts().equals("Q")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); + if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { + continue; + } + } + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� + Date now = new Date(); + wrkMast.setWrkSts(3L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } + } + + } + + /** * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� * 2022-06-09 TQS淇敼锛屾煡璇㈠伐浣滄。LIST锛岄亶鍘嗕笅鍙戯紝闃叉绗竴涓换鍔″牭濉炲嚭搴� */ - public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){ + public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗� // WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); List<WrkMast> wrkMasts = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo()); - for (WrkMast wrkMast : wrkMasts){ + for (WrkMast wrkMast : wrkMasts) { if (wrkMast == null) { continue; } // 宸ヤ綔妗g姸鎬佸垽鏂� - if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null){ + if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) { log.error("鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); continue; } // 鑾峰彇婧愬簱浣嶄俊鎭� LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); - if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) { + if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) { log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts()); continue; } @@ -789,7 +1105,7 @@ // continue; } // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵�� - if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y") + if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- @@ -809,7 +1125,7 @@ if (null == waitWrkMast) { log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); } else { - if(waitWrkMast.getWrkSts() == 11) { + if (waitWrkMast.getWrkSts() == 11) { waitWrkMast.setIoPri(15D); waitWrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(waitWrkMast) == 0) { @@ -821,20 +1137,23 @@ } } } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { - WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); +// WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); + //2022-08-16 modify,涓嶆牴鎹畊pdmk鏍囪绉诲簱浠诲姟(瀹规槗琚彇娑堝鑷村牭濉�)锛屾煡璇㈠伐浣滄。鏄惁瀛樺湪浠诲姟 + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� - if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk()) - || Cools.isEmpty(waitWrkMast)) { +// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk()) +// || Cools.isEmpty(waitWrkMast)) { + if (Cools.isEmpty(waitWrkMast)) { wrkMast.setUpdMk("Y"); wrkMastMapper.updateById(wrkMast); // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑 moveLocForDeepLoc(slave, shallowLoc); } - log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛�", wrkMast.getWrkNo()); + log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo); continue; - } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")){ - WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); - if (null != waitWrkMast && waitWrkMast.getWrkSts()==4) { + } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); + if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { continue; } } @@ -876,127 +1195,822 @@ } } -// /** -// * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� -// */ -// public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){ -// for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { -// // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗� -// WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); -// if (wrkMast == null) { -// continue; -// } -// // 宸ヤ綔妗g姸鎬佸垽鏂� -// if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null){ -// log.error("鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); -// continue; -// } -// // 鑾峰彇婧愬簱浣嶄俊鎭� -// LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); -// if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) { -// log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts()); -// continue; -// } -// // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅 -// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); -// StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); -// if (staProtocol == null) { -// continue; -// } else { -// staProtocol = staProtocol.clone(); -// } -// -//// // 鍏ュ嚭搴撴ā寮忓垽鏂� -//// if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } -// -// -// // 鏌ヨ绔欑偣璇︾粏淇℃伅 -// BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); -// if (staDetl == null) { -// log.error("鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); -// continue; -// } -// // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵�� -// if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y") -// && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鍫嗗灈鏈烘帶鍒惰繃婊� -// if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { + /** + * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� + * 2022-12-03 TQS淇敼锛屽厛閬嶅巻鏌ヨ宸ヤ綔妗f墍鏈夌珯鐐瑰嚭搴撲换鍔IST锛屾牴鎹伐浣滄。浠诲姟鎺掑簭浼樺厛绾ч珮浜� 鏍规嵁鍫嗗灈鏈哄叆搴撶珯鐐规帓搴� + */ + public synchronized void locToCrnStn1(CrnSlave slave, CrnProtocol crnProtocol) { + List<WrkMast> wrkMasts = wrkMastMapper.selectPakOutStep12(slave.getId()); + for (WrkMast wrkMast : wrkMasts) { + if (wrkMast == null) { + continue; + } + + CrnSlave.CrnStn crnStn = null; + for (CrnSlave.CrnStn crnStn1 : slave.getCrnOutStn()){ + if(crnStn1.getStaNo() == wrkMast.getSourceStaNo()){ + crnStn = crnStn1; + break; + } else { + continue; + } + } + if(Cools.isEmpty(crnStn)){ + continue; + } + + // 宸ヤ綔妗g姸鎬佸垽鏂� + if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) { + log.error("鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); + continue; + } + // 鑾峰彇婧愬簱浣嶄俊鎭� + LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); + if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) { + log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts()); + continue; + } + // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅 + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); + if (staProtocol == null) { + break; // continue; -// } -// -// // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� -// if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) { -// String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo()); -// LocMast shallowLoc = locMastService.selectById(shallowLocNo); -// // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 -// if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { -// WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); -// if (null == waitWrkMast) { -// log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); -// } else { -// if(waitWrkMast.getWrkSts() == 11) { -// waitWrkMast.setIoPri(15D); -// waitWrkMast.setModiTime(new Date()); -// if (wrkMastMapper.updateById(waitWrkMast) == 0) { -// log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); -// } -// continue; -// } else { -// -// } -// } -// } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { -// // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� -// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { -// wrkMast.setUpdMk("Y"); -// wrkMastMapper.updateById(wrkMast); -// // 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�) -// moveLocForDeepLoc(slave, shallowLoc); -// } -// log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛�", wrkMast.getWrkNo()); + } else { + staProtocol = staProtocol.clone(); + } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } + if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { + continue; + } + + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); + if (staDetl == null) { + log.error("鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo()); + break; +// continue; + } + // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵�� + if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") + && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + + // 鍫嗗灈鏈烘帶鍒惰繃婊� + if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { +// continue; + break; + } + + // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� + if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) { + String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo()); + LocMast shallowLoc = locMastService.selectById(shallowLocNo); + // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 + if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); + if (null == waitWrkMast) { + log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); + } else { + if (waitWrkMast.getWrkSts() == 11) { + waitWrkMast.setIoPri(15D); + waitWrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(waitWrkMast) == 0) { + log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + } + continue; + } else { + + } + } + } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { +// WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); + //2022-08-16 modify,涓嶆牴鎹畊pdmk鏍囪绉诲簱浠诲姟(瀹规槗琚彇娑堝鑷村牭濉�)锛屾煡璇㈠伐浣滄。鏄惁瀛樺湪浠诲姟 + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); + // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� +// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk()) +// || Cools.isEmpty(waitWrkMast)) { + if (Cools.isEmpty(waitWrkMast)) { + wrkMast.setUpdMk("Y"); + wrkMastMapper.updateById(wrkMast); + // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑 + moveLocForDeepLoc(slave, shallowLoc); + } + log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo); + continue; + } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) { + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); + if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { + continue; + } + } + } + + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(slave.getId()) != null) { + break; +// return; + } + + // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔� + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� + Date now = new Date(); + wrkMast.setWrkSts(12L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + break; + } + } + } + + } + + /** + * 鏌ユ壘宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級,涓擱GV鍏ュ簱鎺ラ┏绔欑鍚堢殑鐨勫叆搴撳伐浣滄。锛屾彁鍙栧嚭鏈�澶�2绗� + * @param slave + * @return + */ + public synchronized List<WrkMast> getRgvInTask(RgvSlave slave){ + List<WrkMast> wrkMastTask = new ArrayList<>(); + List<Integer> staNos = new ArrayList<>(); + for (RgvSlave.RgvStn rgvStn : slave.getRgvInSStn()) { + staNos.add(rgvStn.getStaNo()); + } + if(staNos.size() < 1){ + return null; + } + List<WrkMast> wrkMasts = wrkMastMapper.selectRgvInStep1(slave.getId(), staNos); + for(WrkMast wrkMast : wrkMasts){ + Integer plcId = 0; + for (RgvSlave.RgvStn rgvStn : slave.getRgvInSStn()) { + if(rgvStn.getStaNo() == wrkMast.getRgvSstaNo()){ + plcId = rgvStn.getDevpPlcId(); + break; + } + } + + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, plcId); + //鍒ゆ柇RGV鍏ュ簱婧愮珯鐐癸紝鑷姩銆佹湁鐗╋紝鏈変换鍔″彿锛屽彲鍑� + boolean flag1 = false; + StaProtocol staProtocol1 = devpThread.getStation().get(wrkMast.getRgvSstaNo()); + if (staProtocol1 == null) { + continue; + } else { + staProtocol1 = staProtocol1.clone(); + } + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl1 = basDevpService.selectById(wrkMast.getRgvSstaNo()); + if (staDetl1 == null) { + log.error("RGV鍏ュ簱 ===>> 杈撻�佹満婧愮珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", wrkMast.getRgvSstaNo()); + continue; + } + if (staProtocol1.isAutoing() && staProtocol1.isLoading() && staProtocol1.getWorkNo().intValue() == wrkMast.getWrkNo() + && staProtocol1.isOutEnable() && staDetl1.getOutEnable() != null && staDetl1.getOutEnable().equals("Y")) { + flag1 = true; + } + + //鍒ゆ柇RGV鍏ュ簱鐩爣绔欑偣锛岃嚜鍔ㄣ�佹棤鐗╋紝娌℃湁浠诲姟鍙凤紝鍙叆 + boolean flag2 = false; + StaProtocol staProtocol2 = devpThread.getStation().get(wrkMast.getRgvDstaNo()); + if (staProtocol2 == null) { + continue; + } else { + staProtocol2 = staProtocol2.clone(); + } + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl2 = basDevpService.selectById(wrkMast.getRgvSstaNo()); + if (staDetl2 == null) { + log.error("RGV鍏ュ簱 ===>> 杈撻�佹満婧愮珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", wrkMast.getRgvSstaNo()); + continue; + } + if (staProtocol2.isAutoing() && staProtocol2.isLoading() && staProtocol2.getWorkNo().intValue() == wrkMast.getWrkNo() + && staProtocol2.isInEnable() && staDetl2.getCanining() != null && staDetl2.getCanining().equals("Y")) { + flag2 = true; + } + + if(flag1 && flag2){ + wrkMastTask.add(wrkMast); + if(wrkMastTask.size() >= 2) break; + } + } + return wrkMastTask; + } + + /** + * 鍏ュ簱 ===>> RGV鍏ュ簱绔欏埌绔� + */ + public synchronized void rgvInStn(RgvSlave slave, RgvProtocol rgvProtocol) { + WrkMast wrkMast = wrkMastMapper.selectRgvInSteNo(slave.getId()); + + + //鏌ユ壘宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級,涓擱GV鍏ュ簱鎺ラ┏绔欑鍚堢殑鐨勫叆搴撳伐浣滄。锛屾彁鍙栧嚭鏈�澶�2绗� + List<WrkMast> wrkMastTask = getRgvInTask(slave); + if(wrkMastTask.size() <= 0){ + return; + } + + // RGV鎺у埗杩囨护锛� 蹇呴』婊¤冻鑷姩銆佺┖闂诧紝娌℃湁浠诲姟鍙� + if (!rgvProtocol.getStatusType().equals(CrnStatusType.IDLE) + || rgvProtocol.getModeType() != RgvModeType.AUTO + || rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getTaskNo2() != 0) { + return; + } + + // 宸茬粡瀛樺湪RGV鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if(wrkMastMapper.selectRgvInWorking(slave.getId()).size() > 0){ + return; + } + + if(wrkMastTask.size() == 2){ + //鏈�2绗擱GV寰呭叆搴撲换鍔★紝2涓伐浣嶏紝鍙栬揣銆佹斁璐т换鍔″悓鏃朵笅鍙� + WrkMast wrkMast1 = wrkMastTask.get(0); + WrkMast wrkMast2 = wrkMastTask.get(1); + if(Cools.isEmpty(wrkMast1) || Cools.isEmpty(wrkMast2)){ + log.error("宸ヤ綔妗GV鍏ュ簱鏁版嵁涓虹┖"); + return; + } + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(slave.getId()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH_PUT); // 宸ヤ綅1浠诲姟妯″紡: 鍙栨斁璐� + rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� + rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setAckFinish2((short) 0); // 宸ヤ綅2浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo2(wrkMast2.getWrkNo().shortValue()); // 宸ヤ綅2宸ヤ綔鍙� + rgvCommand.setTaskMode2(RgvTaskModeType.FETCH_PUT); // 宸ヤ綅2浠诲姟妯″紡: 鍙栨斁璐� + rgvCommand.setSourceStaNo2(wrkMast2.getRgvSstaNo().shortValue()); //宸ヤ綅2婧愮珯鐐� + rgvCommand.setDestinationStaNo2(wrkMast2.getRgvDstaNo().shortValue()); //宸ヤ綅2鐩爣绔欑偣 + rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(2, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", slave.getId(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� + Date now = new Date(); + wrkMast1.setWrkSts(6L); + wrkMast1.setCrnStrTime(now); + wrkMast1.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast1) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); + } + + wrkMast2.setWrkSts(6L); + wrkMast2.setCrnStrTime(now); + wrkMast2.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast2) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast2.getWrkNo()); + } + } + } else if(wrkMastTask.size() == 1){ + //鍙湁1绗擱GV寰呭叆搴撲换鍔★紝鍏堜笅鍙戝彇璐т换鍔★紝鍙栬揣鍚庡啀鍒ゆ柇鏄惁鏈変笅涓�绗斿緟鍏ュ簱浠诲姟 + WrkMast wrkMast1 = wrkMastTask.get(0); + if(Cools.isEmpty(wrkMast1)){ + log.error("宸ヤ綔妗GV鍏ュ簱鏁版嵁涓虹┖"); + return; + } + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(slave.getId()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH); // 宸ヤ綅1浠诲姟妯″紡: 鍙栬揣 + rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� + rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2浠诲姟纭锛� step=4锛屽伐浣�1纭锛� step=5锛屽伐浣�2浠诲姟纭 + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", slave.getId(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� + Date now = new Date(); + wrkMast1.setWrkSts(6L); + wrkMast1.setCrnStrTime(now); + wrkMast1.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast1) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); + } + } + } + } + + /** + * 鍑哄簱 ===>> RGV鍑哄簱绔欏埌绔� + */ + public synchronized void rgvOutStn(RgvSlave slave, RgvProtocol rgvProtocol) { + //鏌ユ壘宸ヤ綔鐘舵�佷负14锛堝嚭搴撳畬鎴愶級,涓擱GV鍑哄簱鎺ラ┏绔欑鍚堢殑鐨勫嚭搴撳伐浣滄。锛屾彁鍙栧嚭鏈�澶�2绗� + List<WrkMast> wrkMastTask = getRgvOutTask(slave); + if(wrkMastTask.size() <= 0){ + return; + } + + // RGV鎺у埗杩囨护锛� 蹇呴』婊¤冻鑷姩銆佺┖闂诧紝娌℃湁浠诲姟鍙� + if (!rgvProtocol.getStatusType().equals(CrnStatusType.IDLE) + || rgvProtocol.getModeType() != RgvModeType.AUTO + || rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getTaskNo2() != 0) { + return; + } + + // 宸茬粡瀛樺湪RGV鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if(wrkMastMapper.selectRgvOutWorking(slave.getId()).size() > 0){ + return; + } + + if(wrkMastTask.size() == 2){ + //鏈�2绗擱GV寰呭叆搴撲换鍔★紝2涓伐浣嶏紝鍙栬揣銆佹斁璐т换鍔″悓鏃朵笅鍙� + WrkMast wrkMast1 = wrkMastTask.get(0); + WrkMast wrkMast2 = wrkMastTask.get(1); + if(Cools.isEmpty(wrkMast1) || Cools.isEmpty(wrkMast2)){ + log.error("宸ヤ綔妗GV鍏ュ簱鏁版嵁涓虹┖"); + return; + } + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(slave.getId()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH_PUT); // 宸ヤ綅1浠诲姟妯″紡: 鍙栨斁璐� + rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� + rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setAckFinish2((short) 0); // 宸ヤ綅2浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo2(wrkMast2.getWrkNo().shortValue()); // 宸ヤ綅2宸ヤ綔鍙� + rgvCommand.setTaskMode2(RgvTaskModeType.FETCH_PUT); // 宸ヤ綅2浠诲姟妯″紡: 鍙栨斁璐� + rgvCommand.setSourceStaNo2(wrkMast2.getRgvSstaNo().shortValue()); //宸ヤ綅2婧愮珯鐐� + rgvCommand.setDestinationStaNo2(wrkMast2.getRgvDstaNo().shortValue()); //宸ヤ綅2鐩爣绔欑偣 + rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(2, rgvCommand))) { + //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", slave.getId(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 14.鍑哄簱瀹屾垚 => 16.RGV鍑哄簱鍙栬揣涓� + Date now = new Date(); + wrkMast1.setWrkSts(16L); + wrkMast1.setCrnStrTime(now); + wrkMast1.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast1) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 14.鍑哄簱瀹屾垚 => 16.RGV鍑哄簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); + } + + wrkMast2.setWrkSts(16L); + wrkMast2.setCrnStrTime(now); + wrkMast2.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast2) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 14.鍑哄簱瀹屾垚 => 16.RGV鍑哄簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast2.getWrkNo()); + } + } + } else if(wrkMastTask.size() == 1){ + //鍙湁1绗擱GV寰呭叆搴撲换鍔★紝鍏堜笅鍙戝彇璐т换鍔★紝鍙栬揣鍚庡啀鍒ゆ柇鏄惁鏈変笅涓�绗斿緟鍏ュ簱浠诲姟 + WrkMast wrkMast1 = wrkMastTask.get(0); + if(Cools.isEmpty(wrkMast1)){ + log.error("宸ヤ綔妗GV鍏ュ簱鏁版嵁涓虹┖"); + return; + } + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + RgvCommand rgvCommand = new RgvCommand(); + rgvCommand.setRgvNo(slave.getId()); // RGV缂栧彿 + rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� + rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� + rgvCommand.setTaskMode1(RgvTaskModeType.FETCH); // 宸ヤ綅1浠诲姟妯″紡: 鍙栬揣 + rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� + rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 + rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 + if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(4, rgvCommand))) { + //step=2,宸ヤ綅1銆�2浠诲姟纭锛� step=4锛屽伐浣�1纭锛� step=5锛屽伐浣�2浠诲姟纭 + log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", slave.getId(), JSON.toJSON(rgvCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 14.鍑哄簱瀹屾垚 => 16.RGV鍑哄簱鍙栬揣涓� + Date now = new Date(); + wrkMast1.setWrkSts(16L); + wrkMast1.setCrnStrTime(now); + wrkMast1.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast1) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 14.鍑哄簱瀹屾垚 => 16.RGV鍑哄簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); + } + } + } + } + + /** + * 鏌ユ壘宸ヤ綔鐘舵�佷负14锛堝嚭搴撳畬鎴愶級,涓擱GV鍑哄簱鎺ラ┏绔欑鍚堢殑鐨勫嚭搴撳伐浣滄。锛屾彁鍙栧嚭鏈�澶�2绗� + * @param slave + * @return + */ + public synchronized List<WrkMast> getRgvOutTask(RgvSlave slave){ + List<WrkMast> wrkMastTask = new ArrayList<>(); + List<Integer> staNos = new ArrayList<>(); + for (RgvSlave.RgvStn rgvStn : slave.getRgvOutSStn()) { + staNos.add(rgvStn.getStaNo()); + } + if(staNos.size() < 1){ + return null; + } + List<WrkMast> wrkMasts = wrkMastMapper.selectRgvOutStep1(slave.getId(), staNos); + for(WrkMast wrkMast : wrkMasts){ + Integer plcId = 0; + for (RgvSlave.RgvStn rgvStn : slave.getRgvOutSStn()) { + if(rgvStn.getStaNo() == wrkMast.getRgvSstaNo()){ + plcId = rgvStn.getDevpPlcId(); + break; + } + } + + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, plcId); + //鍒ゆ柇RGV鍑哄簱婧愮珯鐐癸紝鑷姩銆佹湁鐗╋紝鏈変换鍔″彿锛屽彲鍑� + boolean flag1 = false; + StaProtocol staProtocol1 = devpThread.getStation().get(wrkMast.getRgvSstaNo()); + if (staProtocol1 == null) { + continue; + } else { + staProtocol1 = staProtocol1.clone(); + } + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl1 = basDevpService.selectById(wrkMast.getRgvSstaNo()); + if (staDetl1 == null) { + log.error("RGV鍑哄簱 ===>> 杈撻�佹満婧愮珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", wrkMast.getRgvSstaNo()); + continue; + } + if (staProtocol1.isAutoing() && staProtocol1.isLoading() && staProtocol1.getWorkNo().intValue() == wrkMast.getWrkNo() + && staProtocol1.isOutEnable() && staDetl1.getOutEnable() != null && staDetl1.getOutEnable().equals("Y")) { + flag1 = true; + } + + //鍒ゆ柇RGV鍑哄簱鐩爣绔欑偣锛岃嚜鍔ㄣ�佹棤鐗╋紝娌℃湁浠诲姟鍙凤紝鍙叆 + boolean flag2 = false; + StaProtocol staProtocol2 = devpThread.getStation().get(wrkMast.getRgvDstaNo()); + if (staProtocol2 == null) { + continue; + } else { + staProtocol2 = staProtocol2.clone(); + } + // 鏌ヨ绔欑偣璇︾粏淇℃伅 + BasDevp staDetl2 = basDevpService.selectById(wrkMast.getRgvSstaNo()); + if (staDetl2 == null) { + log.error("RGV鍑哄簱 ===>> 杈撻�佹満婧愮珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", wrkMast.getRgvSstaNo()); + continue; + } + if (staProtocol2.isAutoing() && staProtocol2.isLoading() && staProtocol2.getWorkNo().intValue() == wrkMast.getWrkNo() + && staProtocol2.isInEnable() && staDetl2.getCanining() != null && staDetl2.getCanining().equals("Y")) { + flag2 = true; + } + + if(flag1 && flag2){ + wrkMastTask.add(wrkMast); + if(wrkMastTask.size() >= 2) break; + } + } + return wrkMastTask; + } + + /** + * 鏍规嵁RGV瀹屾垚淇″彿锛屾墽琛屽宸ヤ綔妗g殑瀹屾垚鎿嶄綔锛屽拰RGV鐨勪换鍔′笅鍙� + */ + public synchronized void rgvFinished() { + Date now = new Date(); + for (RgvSlave rgv : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + //鍒ゆ柇RGV鏄惁绌洪棽锛屽伐浣�1鏄惁绌洪棽锛屽伐浣�1鏄惁鏈夌墿锛屾槸鍚︿负鐢佃剳妯″紡锛屽伐浣�1鏄惁鏈夊伐浣滃彿 + if (rgvProtocol.statusType1 == RgvStatusType.FETCHWAITING + && rgvProtocol.getModeType() == RgvModeType.AUTO + && rgvProtocol.getTaskNo1() != 0 + && rgvProtocol.getStatus() != 0 + && rgvProtocol.getStatus1() != 0 + ) { + WrkMast wrkMast1 = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); + if (wrkMast1 == null) { + log.error("RGV宸ヤ綅1澶勪簬绛夊緟纭涓斿彇璐т换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgv.getId(), rgvProtocol.getTaskNo1()); + continue; + } + + if (wrkMast1.getWrkSts() == 3) {//3.RGV鍙栬揣涓� => 4.RGV鍙栬揣瀹屾垚 + wrkMast1.setWrkSts(4L); + }else if(wrkMast1.getWrkSts() == 5){//5.RGV鏀捐揣涓� => 6.RGV鏀捐揣瀹屾垚 + rgvProtocol.setTaskNo1((short) 0);//鍏ュ簱浠诲姟瀹屾垚锛屾竻绌轰换鍔″彿 + wrkMast1.setWrkSts(6L); + } else if (wrkMast1.getWrkSts() == 24) {//24.RGV鍙栬揣涓� => 25.RGV鍙栬揣瀹屾垚 + wrkMast1.setWrkSts(25L);// + } else if (wrkMast1.getWrkSts() == 26) {//26.RGV鏀捐揣涓� => 27.RGV鏀捐揣瀹屾垚 + rgvProtocol.setTaskNo1((short) 0);//鍑哄簱浠诲姟瀹屾垚锛屾竻绌轰换鍔″彿 + wrkMast1.setWrkSts(27L);//27.RGV鏀捐揣瀹屾垚 + } + + wrkMast1.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast1) == 0) { + log.error("宸ヤ綅1淇敼宸ヤ綔妗g姸鎬佸け璐ワ紒锛侊紝宸ヤ綔鍙�={}", wrkMast1.getWrkNo()); + } + +// //宸ヤ綅1鍙栬揣瀹屾垚鍚庯紝宸ヤ綅2鏄棤璐х┖闂茬姸鎬佹椂锛屽噯澶囩粰宸ヤ綅2鍙戜换鍔★紝纭鏄惁鏈夊緟鎵цRGV浠诲姟 +// if (rgvProtocol.getModeType() == RgvModeType.AUTO +// && rgvProtocol.getTaskNo1() > 0 && rgvProtocol.getTaskNo2() == 0 +// && rgvProtocol.getLoaded1() > 0 && rgvProtocol.getLoaded2() == 0 +// && rgvProtocol.getStatusType2() == RgvStatusType.IDLE +// ) { +// WrkMast wrkMast1 = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); +// if (wrkMast1 == null) { +// log.error("RGV宸ヤ綅1澶勪簬绛夊緟纭涓斿彇璐т换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgv.getId(), rgvProtocol.getTaskNo1()); // continue; // } -// } +// List<WrkMast> wrkMastTask = new ArrayList<>(); +// List<WrkMast> list = new ArrayList<>(); +// Integer type = 0;//1鍏ュ簱锛�2鍑哄簱 +// if(wrkMast1.getWrkSts()==6L){ +// wrkMastTask = getRgvInTask(rgv); +// list = wrkMastMapper.selectRgvInWorking(rgv.getId()); +// type = 1; +// } else if(wrkMast1.getWrkSts()==16L){ +// wrkMastTask = getRgvOutTask(rgv); +// list = wrkMastMapper.selectRgvOutWorking(rgv.getId()); +// type = 2; +// } +// if(wrkMastTask.size() > 0){//鏈夌户缁墽琛屼换鍔★紝涓嬪彂鍙栬揣浠诲姟缁欏伐浣�2 +// // 宸茬粡瀛樺湪RGV鎵ц浠诲姟鏃讹紝鍒欒繃婊� +// if (list.size() > 1) { +// continue; +// } +// WrkMast wrkMast2 = wrkMastTask.get(0); +// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- +// RgvCommand rgvCommand = new RgvCommand(); +// rgvCommand.setRgvNo(rgv.getId()); // RGV缂栧彿 +// rgvCommand.setAckFinish2((short) 0); // 宸ヤ綅2浠诲姟瀹屾垚纭浣� +// rgvCommand.setTaskNo2(wrkMast2.getWrkNo().shortValue()); // 宸ヤ綅2宸ヤ綔鍙� +// rgvCommand.setTaskMode2(RgvTaskModeType.FETCH); // 宸ヤ綅2浠诲姟妯″紡: 鍙栬揣 +// rgvCommand.setSourceStaNo2(wrkMast2.getRgvSstaNo().shortValue()); //宸ヤ綅2婧愮珯鐐� +// rgvCommand.setDestinationStaNo2(wrkMast2.getRgvDstaNo().shortValue()); //宸ヤ綅2鐩爣绔欑偣 +// rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 +// if (!MessageQueue.offer(SlaveType.Crn, wrkMast2.getRgvNo(), new Task(5, rgvCommand))) { +// //step=2,宸ヤ綅1銆�2鍐欎换鍔★紱 step=4锛屽伐浣�1鍐欎换鍔★紱 step=5锛屽伐浣�2鍐欎换鍔� +// log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", rgv.getId(), JSON.toJSON(rgvCommand)); +// } else { +// // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� +// Date now = new Date(); +// wrkMast2.setWrkSts(type==1 ? 6L : 16L); +// wrkMast2.setCrnStrTime(now); +// wrkMast2.setModiTime(now); +// if (wrkMastMapper.updateById(wrkMast2) == 0) { +// log.error("宸ヤ綅2淇敼宸ヤ綔妗g姸鎬� 2/14.璁惧涓婅蛋 => 6/16.RGV鍏ュ簱鍙栬揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast2.getWrkNo()); +// } +// } +// } else {//娌℃湁缁х画鎵ц浠诲姟锛屼笅鍙戞斁璐т换鍔$粰宸ヤ綅1 +// if(type == 1 && wrkMast1.getWrkSts() != 6L){//RGV鍏ュ簱鍙栬揣涓� +// continue; +// } +// if(type == 2 && wrkMast1.getWrkSts() != 16L){//RGV鍑哄簱鍙栬揣涓� +// continue; +// } // -// // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� -// if (wrkMastMapper.selectWorking(slave.getId()) != null) { -// return; -// } +// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- +// RgvCommand rgvCommand = new RgvCommand(); +// rgvCommand.setRgvNo(rgv.getId()); // RGV缂栧彿 +// rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� +// rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� +// rgvCommand.setTaskMode1(RgvTaskModeType.PUT); // 宸ヤ綅1浠诲姟妯″紡: 鏀捐揣 +// rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� +// rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 +// rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 +// if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(4, rgvCommand))) { +// //step=2,宸ヤ綅1銆�2浠诲姟纭锛� step=4锛屽伐浣�1纭锛� step=5锛屽伐浣�2浠诲姟纭 +// log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", rgv.getId(), JSON.toJSON(rgvCommand)); +// } else { +// // 淇敼宸ヤ綔妗g姸鎬� 6.RGV鍏ュ簱鍙栬揣涓� => 7.RGV鍏ュ簱鏀捐揣涓� +// Date now = new Date(); +// wrkMast1.setWrkSts(type==1 ? 7L : 17L); +// wrkMast1.setCrnEndTime(now); +// wrkMast1.setModiTime(now); +// if (wrkMastMapper.updateById(wrkMast1) == 0) { +// log.error("淇敼宸ヤ綔妗g姸鎬� 6/16.RGV鍏ュ簱鍙栬揣涓� => 7/17.RGV鍏ュ簱鏀捐揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); +// } +// log.error("RGV鍛戒护涓嬪彂鎴愬姛锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", rgv.getId(), JSON.toJSON(rgvCommand)); +// } +// } +// } else if (rgvProtocol.getModeType() == RgvModeType.AUTO +// && rgvProtocol.getTaskNo1() > 0 && rgvProtocol.getTaskNo2() > 0 +// && rgvProtocol.getLoaded1() > 0 && rgvProtocol.getLoaded2() > 0 +// && rgvProtocol.statusType2 == RgvStatusType.FETCHWAITING){ +// // 宸ヤ綅2鐘舵�侊細涔熸槸鍙栬揣瀹屾垚绛夊緟纭91 骞朵笖 浠诲姟瀹屾垚浣� = 1, 宸ヤ綅1銆�2鍚屾椂涓嬪彂鏀捐揣浠诲姟 +// WrkMast wrkMast1 = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); +// WrkMast wrkMast2 = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo2().intValue()); +// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- +// RgvCommand rgvCommand = new RgvCommand(); +// rgvCommand.setRgvNo(rgv.getId()); // RGV缂栧彿 +// rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣� +// rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 宸ヤ綅1宸ヤ綔鍙� +// rgvCommand.setTaskMode1(RgvTaskModeType.PUT); // 宸ヤ綅1浠诲姟妯″紡: 鏀捐揣 +// rgvCommand.setSourceStaNo1(wrkMast1.getRgvSstaNo().shortValue()); //宸ヤ綅1婧愮珯鐐� +// rgvCommand.setDestinationStaNo1(wrkMast1.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣 +// rgvCommand.setAckFinish2((short) 0); // 宸ヤ綅2浠诲姟瀹屾垚纭浣� +// rgvCommand.setTaskNo2(wrkMast2.getWrkNo().shortValue()); // 宸ヤ綅2宸ヤ綔鍙� +// rgvCommand.setTaskMode2(RgvTaskModeType.PUT); // 宸ヤ綅2浠诲姟妯″紡: 鏀捐揣 +// rgvCommand.setSourceStaNo2(wrkMast2.getRgvSstaNo().shortValue()); //宸ヤ綅2婧愮珯鐐� +// rgvCommand.setDestinationStaNo2(wrkMast2.getRgvDstaNo().shortValue()); //宸ヤ綅2鐩爣绔欑偣 +// rgvCommand.setCommand((short) 0); //宸ヤ綅1銆�2浠诲姟纭 +// if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(2, rgvCommand))) { +// //step=2,宸ヤ綅1銆�2浠诲姟纭锛� step=4锛屽伐浣�1纭锛� step=5锛屽伐浣�2浠诲姟纭 +// log.error("RGV鍛戒护涓嬪彂澶辫触锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", rgv.getId(), JSON.toJSON(rgvCommand)); +// } else { +// // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 6.RGV鍏ュ簱鍙栬揣涓� +// Date now = new Date(); +// wrkMast1.setWrkSts(wrkMast1.getWrkSts()==6L ? 7L : 17L); +// wrkMast1.setCrnStrTime(now); +// wrkMast1.setModiTime(now); +// if (wrkMastMapper.updateById(wrkMast1) == 0) { +// log.error("淇敼宸ヤ綔妗g姸鎬� 6/16.RGV鍏ュ簱鍙栬揣涓� => 7/17.RGV鍏ュ簱鏀捐揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast1.getWrkNo()); +// } // -// // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔� -// CrnCommand crnCommand = new CrnCommand(); -// crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� -// crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� -// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� -// crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 -// crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 -// crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 -// crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 -// crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺� -// crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� -// crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� -// if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { -// log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); -// } else { -// // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� -// Date now = new Date(); -// wrkMast.setWrkSts(12L); -// wrkMast.setCrnStrTime(now); -// wrkMast.setModiTime(now); -// if (wrkMastMapper.updateById(wrkMast) == 0) { -// log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); +// wrkMast2.setWrkSts(wrkMast2.getWrkSts()==6L ? 7L : 17L); +// wrkMast2.setCrnStrTime(now); +// wrkMast2.setModiTime(now); +// if (wrkMastMapper.updateById(wrkMast2) == 0) { +// log.error("淇敼宸ヤ綔妗g姸鎬� 6/16.RGV鍏ュ簱鍙栬揣涓� => 7/17.RGV鍏ュ簱鏀捐揣涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast2.getWrkNo()); +// } // } // } -// } -// } -// } + } + + } + } + + /** + * 鍏ュ嚭搴� ===>> RGV鍑哄簱绔欏埌鍫嗗灈鏈哄叆搴撶珯/绯荤粺鍏ュ簱绔� + * rgvInDStnToCrnStn + */ + public synchronized void rgvDestStnToCrnStn() { + for (RgvSlave rgvSlave : slaveProperties.getRgv()) { + // 閬嶅巻鍏ュ簱浠诲姟鐨凴GV鍑哄簱绔� + for (RgvSlave.RgvStn rgvStn : rgvSlave.getRgvDestStn()) { + // 鑾峰彇RGV鍑哄簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, rgvStn.getDevpPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(rgvStn.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { + // 鏌ヨ宸ヤ綔妗ist +// List<WrkMast> wrkMasts = wrkMastMapper.selectRgvInStep2(staProtocol.getSiteId()); + List<WrkMast> wrkMasts = wrkMastMapper.selectRgvDestStep2(staProtocol.getSiteId()); + for(WrkMast wrkMast : wrkMasts){ + // 鍒ゆ柇宸ヤ綔妗f潯浠� + if (wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null + || wrkMast.getRgvSstaNo() == null || wrkMast.getRgvDstaNo() == null) { + continue; + } + + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, wrkMast.getRgvNo()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + // 鍒ゆ柇RGV鐘舵�佺瓑寰呯‘璁�,宸ヤ綅1 + if (rgvProtocol.modeType == RgvModeType.AUTO && rgvProtocol.getTaskNo1().equals(wrkMast.getWrkNo().shortValue()) + && rgvProtocol.statusType1 == RgvStatusType.WAITING) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + // 涓嬪彂绔欑偣淇℃伅 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + if (!MessageQueue.offer(SlaveType.Devp, rgvStn.getDevpPlcId(), new Task(2, staProtocol))) { + continue; + } + // 鏇存柊宸ヤ綔妗g姸鎬佷负2,14 + wrkMast.setWrkSts(wrkMast.getWrkSts()==7L ? 2L : 14L); + wrkMast.setOnlineYn("Y"); + wrkMast.setCrnEndTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) != 0) { + // 澶嶄綅RGV宸ヤ綅1 + rgvThread.setResetFlag1(true); + } else { + log.error("RGV宸ヤ綅1鎺ラ┏锛屾洿鏂板伐浣滄。鐨勫伐浣滅姸鎬佷负{}澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkSts()==7L ? 2L : 14L, wrkMast.getWrkNo()); + } + } + // 鍒ゆ柇RGV鐘舵�佺瓑寰呯‘璁�,宸ヤ綅2 + if (rgvProtocol.modeType == RgvModeType.AUTO && rgvProtocol.getTaskNo2().equals(wrkMast.getWrkNo().shortValue()) + && rgvProtocol.statusType2 == RgvStatusType.WAITING) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + // 涓嬪彂绔欑偣淇℃伅 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + if (!MessageQueue.offer(SlaveType.Devp, rgvStn.getDevpPlcId(), new Task(2, staProtocol))) { + continue; + } + // 鏇存柊宸ヤ綔妗g姸鎬佷负2,14 + wrkMast.setWrkSts(wrkMast.getWrkSts()==7L ? 2L : 14L); + wrkMast.setOnlineYn("Y"); + wrkMast.setCrnEndTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) != 0) { + // 澶嶄綅RGV宸ヤ綅2 + rgvThread.setResetFlag2(true); + } else { + log.error("RGV宸ヤ綅2鎺ラ┏锛屾洿鏂板伐浣滄。鐨勫伐浣滅姸鎬佷负{}澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkSts()==7L ? 2L : 14L, wrkMast.getWrkNo()); + } + } + } + + } + } + } + } + + /** + * 鍑哄簱 ===>> RGV鍑哄簱绔欏埌绯荤粺鍑哄簱绔� + */ + public synchronized void rgvOutDStnToOutStn() { + for (RgvSlave rgvSlave : slaveProperties.getRgv()) { + // 閬嶅巻鍑哄簱浠诲姟鐨凴GV鍑哄簱绔� + for (RgvSlave.RgvStn rgvStn : rgvSlave.getRgvDestStn()) { + // 鑾峰彇RGV鍑哄簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, rgvStn.getDevpPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(rgvStn.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { + // 鏌ヨ宸ヤ綔妗ist + List<WrkMast> wrkMasts = wrkMastMapper.selectRgvOutStep2(staProtocol.getSiteId()); + for(WrkMast wrkMast : wrkMasts){ + // 鍒ゆ柇宸ヤ綔妗f潯浠� + if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null + || wrkMast.getRgvSstaNo() == null || wrkMast.getRgvDstaNo() == null) { + continue; + } + + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, wrkMast.getRgvNo()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + // 鍒ゆ柇RGV鐘舵�佺瓑寰呯‘璁�,宸ヤ綅1 + if (rgvProtocol.modeType == RgvModeType.AUTO && rgvProtocol.getTaskNo1().equals(wrkMast.getWrkNo().shortValue()) + && rgvProtocol.statusType1 == RgvStatusType.WAITING) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + // 涓嬪彂绔欑偣淇℃伅 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + if (!MessageQueue.offer(SlaveType.Devp, rgvStn.getDevpPlcId(), new Task(2, staProtocol))) { + continue; + } + // 鏇存柊宸ヤ綔妗g姸鎬佷负14 + wrkMast.setWrkSts(14L); + wrkMast.setOnlineYn("Y"); //鎺у埗WMS灏嗗伐浣滅姸鎬�14杞�15鐨勬椂鏈猴紝鍙湁RGV杩愭惉瀹屾垚鍚庢墠鍙互杞� + wrkMast.setCrnEndTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) != 0) { + // 澶嶄綅RGV宸ヤ綅1 + rgvThread.setResetFlag1(true); + } else { + log.error("RGV宸ヤ綅1鎺ラ┏锛屾洿鏂板伐浣滄。鐨勫伐浣滅姸鎬佷负2澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); + } + } + // 鍒ゆ柇RGV鐘舵�佺瓑寰呯‘璁�,宸ヤ綅2 + if (rgvProtocol.modeType == RgvModeType.AUTO && rgvProtocol.getTaskNo2().equals(wrkMast.getWrkNo().shortValue()) + && rgvProtocol.statusType2 == RgvStatusType.WAITING) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + // 涓嬪彂绔欑偣淇℃伅 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + if (!MessageQueue.offer(SlaveType.Devp, rgvStn.getDevpPlcId(), new Task(2, staProtocol))) { + continue; + } + // 鏇存柊宸ヤ綔妗g姸鎬佷负14 + wrkMast.setWrkSts(14L); + wrkMast.setOnlineYn("Y"); //鎺у埗WMS灏嗗伐浣滅姸鎬�14杞�15鐨勬椂鏈猴紝鍙湁RGV杩愭惉瀹屾垚鍚庢墠鍙互杞� + wrkMast.setCrnEndTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) != 0) { + // 澶嶄綅RGV宸ヤ綅2 + rgvThread.setResetFlag2(true); + } else { + log.error("RGV宸ヤ綅2鎺ラ┏锛屾洿鏂板伐浣滄。鐨勫伐浣滅姸鎬佷负2澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); + } + } + } + + } + } + } + } /** * 搴撲綅绉昏浆 */ - public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){ + public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) { // 鑾峰彇宸ヤ綔妗d俊鎭� WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); if (null == wrkMast) { @@ -1064,19 +2078,20 @@ /** * 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣� */ - @Async - public void storeFinished() { + public synchronized void storeFinished() { for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { continue; } + if (crnProtocol == null) { + continue; + } // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { - if(crnProtocol.getTaskNo()==9999){ + if (crnProtocol.getTaskNo() == 9999) { // 鍫嗗灈鏈哄浣� crnThread.setResetFlag(true); - }else { + } else { // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); if (wrkMast == null) { @@ -1104,10 +2119,141 @@ } /** + * 寮傚父淇℃伅璁板綍 + */ + public synchronized void recErr() { + try { + this.recCrnErr(); + this.recRgvErr(); + } catch (Exception e) { + log.error("recErr fail", e); + } + } + + /** + * RGV寮傚父淇℃伅璁板綍 + */ + public synchronized void recRgvErr() { + Date now = new Date(); + for (RgvSlave rgv : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + if (true) { + // 鏈変换鍔� + if (rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getTaskNo2() != 0) { + Integer taskNo = rgvProtocol.getTaskNo1() > 0 ? rgvProtocol.getTaskNo1().intValue() : rgvProtocol.getTaskNo2().intValue(); + BasRgvErrLog latest = basRgvErrLogService.findLatestByTaskNo(rgv.getId(), taskNo); + // 鏈夊紓甯� + if (latest == null) { + if (rgvProtocol.getAlarm() != null && rgvProtocol.getAlarm() > 0) { + WrkMast wrkMast = wrkMastMapper.selectById(taskNo); + if (wrkMast == null) { + continue; + } + BasRgvErr rgvErr = basRgvErrMapper.selectById(rgvProtocol.getAlarm()); + String errName = rgvErr == null ? String.valueOf(rgvProtocol.getAlarm()) : rgvErr.getErrName(); + BasRgvErrLog basRgvErrLog = new BasRgvErrLog( + null, // 缂栧彿 + wrkMast.getWrkNo(), // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + wrkMast.getWrkSts(), // 宸ヤ綔鐘舵�� + wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨� + rgv.getId(), // 鍫嗗灈鏈� + null, // plc + wrkMast.getLocNo(), // 鐩爣搴撲綅 + wrkMast.getStaNo(), // 鐩爣绔� + wrkMast.getSourceStaNo(), // 婧愮珯 + wrkMast.getSourceLocNo(), // 婧愬簱浣� + wrkMast.getBarcode(), // 鏉$爜 + (int) rgvProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "浠诲姟涓紓甯�" // 澶囨敞 + ); + + if (!basRgvErrLogService.insert(basRgvErrLog)) { + log.error("RGV寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", rgv.getId(), errName); + } + } + } else { + // 寮傚父淇 + if (rgvProtocol.getAlarm() == null || rgvProtocol.getAlarm() == 0) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basRgvErrLogService.updateById(latest)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", rgv.getId(), latest.getId()); + } + } + } + // 鏃犱换鍔� + } else { + BasRgvErrLog latest = basRgvErrLogService.findLatest(rgv.getId()); + // 鏈夊紓甯� + if (rgvProtocol.getAlarm() != null && rgvProtocol.getAlarm() > 0) { + // 璁板綍鏂板紓甯� + if (latest == null || (latest.getErrCode() != rgvProtocol.getAlarm().intValue())) { + BasRgvErr rgvErr = basRgvErrMapper.selectById(rgvProtocol.getAlarm()); + String errName = rgvErr == null ? String.valueOf(rgvProtocol.getAlarm()) : rgvErr.getErrName(); + BasRgvErrLog basRgvErrLog = new BasRgvErrLog( + null, // 缂栧彿 + null, // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + null, // 宸ヤ綔鐘舵�� + null, // 鍏ュ嚭搴撶被鍨� + rgv.getId(), // 鍫嗗灈鏈� + null, // plc + null, // 鐩爣搴撲綅 + null, // 鐩爣绔� + null, // 婧愮珯 + null, // 婧愬簱浣� + null, // 鏉$爜 + (int) rgvProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "鏃犱换鍔″紓甯�" // 澶囨敞 + ); + + if (!basRgvErrLogService.insert(basRgvErrLog)) { + log.error("RGV寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", rgv.getId(), errName); + } + } + // 鏃犲紓甯� + } else { + // 寮傚父淇 + if (latest != null && latest.getStatus() == 1) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basRgvErrLogService.updateById(latest)) { + log.error("RGV寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", rgv.getId(), latest.getId()); + } + } + } + } + } + + } + } + + /** * 鍫嗗灈鏈哄紓甯镐俊鎭褰� */ - @Async - public void recCrnErr(){ + public synchronized void recCrnErr() { Date now = new Date(); for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� @@ -1129,7 +2275,7 @@ continue; } BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); - String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); + String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); BasErrLog basErrLog = new BasErrLog( null, // 缂栧彿 wrkMast.getWrkNo(), // 宸ヤ綔鍙� @@ -1168,7 +2314,7 @@ } } } - // 鏃犱换鍔� + // 鏃犱换鍔� } else { BasErrLog latest = basErrLogService.findLatest(crn.getId()); // 鏈夊紓甯� @@ -1176,7 +2322,7 @@ // 璁板綍鏂板紓甯� if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); - String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); + String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); BasErrLog basErrLog = new BasErrLog( null, // 缂栧彿 null, // 宸ヤ綔鍙� @@ -1191,7 +2337,7 @@ null, // 婧愮珯 null, // 婧愬簱浣� null, // 鏉$爜 - (int)crnProtocol.getAlarm(), // 寮傚父鐮� + (int) crnProtocol.getAlarm(), // 寮傚父鐮� errName, // 寮傚父 1, // 寮傚父鎯呭喌 now, // 娣诲姞鏃堕棿 @@ -1204,7 +2350,7 @@ log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); } } - // 鏃犲紓甯� + // 鏃犲紓甯� } else { // 寮傚父淇 if (latest != null && latest.getStatus() == 1) { @@ -1222,14 +2368,12 @@ } } - // ------------------------------------------------------------------------------- /** * 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐� */ - @Async - public void storeEmptyPlt(){ + public synchronized void storeEmptyPlt() { for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻绌烘澘鍏ュ簱鍙� for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { @@ -1241,9 +2385,6 @@ } else { staProtocol = staProtocol.clone(); } - -// // 鍏ュ嚭搴撴ā寮忓垽鏂� - if ( emptyInSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } // 绔欑偣鏉′欢鍒ゆ柇 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() @@ -1275,14 +2416,12 @@ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } } catch (Exception e) { e.printStackTrace(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - - // // 妫�绱㈠簱浣� @@ -1348,8 +2487,7 @@ /** * 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣� */ - @Async - public void ledExecute() { + public synchronized void ledExecute() { for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1368,7 +2506,9 @@ // 鑾峰彇宸ヤ綔妗f暟鎹� WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); // if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } - if (null == wrkMast) { continue; } + if (null == wrkMast) { + continue; + } wrkMasts.add(wrkMast); // 缁勮鍛戒护 LedCommand ledCommand = new LedCommand(); @@ -1406,7 +2546,7 @@ ledCommand.setLocNo(wrkMast.getLocNo()); ledCommand.setStaNo(wrkMast.getStaNo()); // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); - if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10 ) { + if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()))); } @@ -1421,12 +2561,22 @@ } // 鍛戒护涓嬪彂 ------------------------------------------------------------------------------- if (!commands.isEmpty()) { - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { - log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); - continue; + if (led.getId() == 7) { + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + continue; + } else { + ledThread.setLedMk(false); + } } else { - ledThread.setLedMk(false); + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + continue; + } else { + ledThread.setLedMk(false); + } } + } try { @@ -1453,35 +2603,7 @@ /** * 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅 */ - @Async - public void ledReset() { -// for (LedSlave led : slaveProperties.getLed()) { -// // 鑾峰彇杈撻�佺嚎plc绾跨▼ -// DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); -// // 鍛戒护闆嗗悎 -// boolean reset = true; -// for (Integer staNo : led.getStaArr()) { -// // 鑾峰彇鍙夎溅绔欑偣 -// StaProtocol staProtocol = devpThread.getStation().get(staNo); -// if (staProtocol == null) { -// continue; -// } else { -// staProtocol = staProtocol.clone(); -// } -// if (staProtocol.getWorkNo() != 0) { -// reset = false; -// break; -// } -// } -// // 鑾峰彇led绾跨▼ -// LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); -// // led鏄剧ず榛樿鍐呭 -// if (reset) { -// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { -// log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); -// } -// } -// } + public synchronized void ledReset() { for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1502,11 +2624,20 @@ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); // led鏄剧ず榛樿鍐呭 if (reset && !ledThread.isLedMk()) { - ledThread.setLedMk(true); - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { - log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); - } else { + if (led.getId() == 7) { + ledThread.setLedMk(true); + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + } else { + } + } else { + ledThread.setLedMk(true); + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + } else { + + } } } } @@ -1517,7 +2648,7 @@ * tip锛氬悓姝� */ @Transactional - public synchronized void moveLocForDeepLocPakin(CrnSlave crn, LocMast shallowLoc, WrkMast pakinWrkMast){ + public synchronized void moveLocForDeepLocPakin(CrnSlave crn, LocMast shallowLoc, WrkMast pakinWrkMast) { LocMast loc = locMastService.selectById(pakinWrkMast.getLocNo()); // 鑾峰彇宸ヤ綔鍙� @@ -1536,7 +2667,7 @@ wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘 wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 + wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘 wrkMast.setBarcode(shallowLoc.getBarcode()); // 鎵樼洏鐮� wrkMast.setLinkMis("N"); wrkMast.setCtnNo("Y"); // 鍏ュ簱闃诲搴撲綅绉昏浆鏍囪 @@ -1566,7 +2697,7 @@ if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { shallowLoc.setLocSts("S"); // S.鍏ュ簱棰勭害锛屽叆搴撻樆濉炲簱浣嶇Щ杞� shallowLoc.setModiTime(now); - if (!locMastService.updateById(shallowLoc)){ + if (!locMastService.updateById(shallowLoc)) { throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); } } else { @@ -1592,7 +2723,7 @@ * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増) * tip锛氬悓姝� */ - private void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc){ + private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) { try { List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); LocMast loc = null; @@ -1707,9 +2838,16 @@ } /** + * 鍒濆鍖朢GV鍦板浘 + */ + public synchronized void initRgvMap() { + + } + + /** * 鍫嗗灈鏈烘紨绀� ===>> 搴撲綅绉昏浆 */ - public synchronized void crnDemoOfLocMove1(){ + public synchronized void crnDemoOfLocMove1() { try { for (CrnSlave crn : slaveProperties.getCrn()) { if (!crn.getDemo()) { @@ -1810,7 +2948,7 @@ /** * 鍫嗗灈鏈哄懡浠や笅鍙戝悗锛屽紓姝ヤ慨鏀瑰伐浣滄。鐘舵�� */ - public synchronized void crnIoWrkMast(){ + public synchronized void crnIoWrkMast() { for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -1823,7 +2961,9 @@ if (crnProtocol.getStatusType() != CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { // 鑾峰彇宸ヤ綔妗� WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); - if (wrkMast == null) { continue; } + if (wrkMast == null) { + continue; + } // 鍏ュ簱 if (wrkMast.getWrkSts() == 1 || wrkMast.getWrkSts() == 2) { log.warn("鍫嗗灈鏈洪潪绌洪棽鎯呭喌涓嬶紝寮�濮嬩慨鏀瑰伐浣滄。鐘舵�併�俒id:{},鏃堕棿锛歿}] >>>>> 鍫嗗灈鏈哄綋鍓嶇姸鎬佷负锛歿}銆備换鍔″彿:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); @@ -1834,7 +2974,7 @@ if (wrkMastMapper.updateById(wrkMast) == 0) { log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } - log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); + log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); } // 鍑哄簱銆佺Щ搴� if (wrkMast.getWrkSts() == 11) { @@ -1846,7 +2986,7 @@ if (wrkMastMapper.updateById(wrkMast) == 0) { log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } - log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); + log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); } @@ -1858,7 +2998,7 @@ /** * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁� */ - public void ioConvert() { + public synchronized void ioConvert() { try { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { @@ -1877,8 +3017,8 @@ devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING; WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() - && !devpThread.getStation().get(inSta.getStaNo()+1).isLoading() - && devpThread.getStation().get(inSta.getStaNo()+1).getWorkNo()==0) { + && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() + && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { // 鍑哄簱妯″紡 devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE; } @@ -1886,6 +3026,24 @@ } else { // 鍏ュ簱妯″紡 devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; + } + break; + case 401://1F + if (pakout != null) { + if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) { + // 鍑哄簱鍒囨崲涓� + devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING; + WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); + if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() + && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() + && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { + // 鍑哄簱妯″紡 + devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE; + } + } + } else { + // 鍏ュ簱妯″紡 + devpThread.ioModeOf4F = IoModeType.PAKIN_MODE; } break; } @@ -1900,7 +3058,7 @@ } - public void outOfDevp() { + public synchronized void outOfDevp() { List<WrkMast> wrkMasts = wrkMastMapper.selectPick(); for (WrkMast wrkMast : wrkMasts) { if (basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())) == 0) { @@ -1914,4 +3072,80 @@ } + public synchronized void autoEmptyOut() { + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); + Integer autoOutSite = 12; + //濡傛灉绔欑偣鍙嚭绂佺敤锛屽垯涓嶇敓鎴愮┖鐩樺嚭搴撲换鍔� + StaProtocol staProtocol = devpThread.getStation().get(autoOutSite); + if (staProtocol == null) { + return; + } else { + staProtocol = staProtocol.clone(); + } + if (staProtocol.isAutoing() //鑷姩 + && !staProtocol.isLoading() //鏃犵墿 + && staProtocol.isOutEnable() //鍙嚭淇″彿 + && staProtocol.getWorkNo() == 0 + ) { + WrkMast pakoutEmpty = wrkMastMapper.selectPakoutEmpty(autoOutSite); + if (null != pakoutEmpty) { + return; + } + try { + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/auto/emptyOut/v1") + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { + JSONObject data = (JSONObject) jsonObject.get("data"); + log.info((String) data.get("msg")); + } else { + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyOut/v1","", response); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } + } + + public synchronized void autoEmptyIn() { + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); + Integer autoInSite = 12; + StaProtocol staProtocol = devpThread.getStation().get(autoInSite); + if (staProtocol == null) { + return; + } else { + staProtocol = staProtocol.clone(); + } + if (staProtocol.isAutoing() //鑷姩 + && staProtocol.isLoading() //鏈夌墿 + && staProtocol.isInEnable() //鍙叆淇″彿 + && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) //宸ヤ綔鍙蜂负0鎴栬�呭伐浣滃彿鏄�9991~9999锛堣緭閫佹満鐣欑敤锛� + ) { + + try { + LocTypeDto locTypeDto = new LocTypeDto((short) 1, (short) 1, (short) 1); + + + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/auto/emptyIn/v1") + .setJson(JSON.toJSONString(locTypeDto)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { + log.info((String) jsonObject.get("msg")); + } else { + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyIn/v1", JSON.toJSONString(locTypeDto), response); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } + } } -- Gitblit v1.9.1