From 4fdf9914b7ef3732d8da79ccc788f615486b8007 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期二, 29 七月 2025 10:07:46 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 1338 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 975 insertions(+), 363 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 dd6e2f0..686be44 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; @@ -13,7 +14,7 @@ import com.zy.asrs.mapper.WrkMastMapper; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; -import com.zy.asrs.utils.VersionUtils; +import com.zy.common.constant.RedisConstantType; import com.zy.common.model.LocTypeDto; import com.zy.common.model.MatDto; import com.zy.common.model.SearchLocParam; @@ -22,23 +23,26 @@ import com.zy.common.utils.CollectionUtils; import com.zy.common.utils.HttpHandler; import com.zy.common.utils.News; +import com.zy.common.utils.RedisUtil; import com.zy.core.CrnThread; import com.zy.core.DevpThread; 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 com.zy.system.entity.Config; +import com.zy.system.service.ConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -87,6 +91,14 @@ private BasErrLogService basErrLogService; @Autowired private BasCrnErrorMapper basCrnErrorMapper; + @Autowired + private WrkMastService wrkMastService; + @Autowired + private WrkMastLogService wrkMastLogService; + @Autowired + private ConfigService configService; + @Autowired + private RedisUtil redisUtil; @Value("${wms.url}") private String wmsUrl; @@ -117,50 +129,27 @@ //LED LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); - // 鍏ュ嚭搴撴ā寮忓垽鏂� -// if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } -// if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { -// continue; -// } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (!staProtocol.isLoading()){ continue; } - String barcode11 = barcodeThread.getBarcode(); - if (Cools.isEmpty(barcode11)){ - if (staProtocol.isAutoing()&& !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 9999 && staProtocol.isPakMk() && staProtocol.getStamp()==2){ - staProtocol.setStamp(3); - News.info(""+mark+" - 7"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode11, inSta.getStaNo()); - staProtocol.setWorkNo((short) 9989); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - // led 寮傚父鏄剧ず - if (ledThread != null) { - String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; - MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); - } - continue; - } - } - if (staProtocol.isAutoing() && staProtocol.isInEnable() - && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) - && staProtocol.isPakMk() && staProtocol.getStamp()>=2 && staProtocol.getStamp()!=3) {// && !Cools.isEmpty(barcode)) { + + if (staProtocol.isAutoing() + && staProtocol.isInEnable() + && !staProtocol.isEmptyMk() + && staProtocol.getWorkNo() == 9999 + && staProtocol.isPakMk()) { News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); -// try { -// Thread.sleep(300); -// }catch (Exception e){} 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)) { - staProtocol.setWorkNo((short) 9999); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - +// 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()); // led 寮傚父鏄剧ず if (ledThread != null) { @@ -170,10 +159,10 @@ continue; } } else { - staProtocol.setWorkNo((short) 9999); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); +// 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+" - 3"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); // led 寮傚父鏄剧ず @@ -195,13 +184,13 @@ } if (wrkMast != null) { News.error(""+mark+" - 4"+" - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo()); - staProtocol.setWorkNo((short)9999); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } +// staProtocol.setWorkNo((short)9992); +// staProtocol.setStaNo(inSta.getBackSta().shortValue()); +// devpThread.setPakMk(staProtocol.getSiteId(), false); +// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); +// if (!result) { +// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); +// } // led 寮傚父鏄剧ず if (ledThread != null) { @@ -209,6 +198,18 @@ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); } continue; + } + + if (inSta.getStaNo() == 1005) { + //妫�娴嬫槸鍚︽湁鍑哄簱浠诲姟 + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("io_type", 101, 103, 107) + .in("sta_no", 1003, 1007) + ); + if (!wrkMasts.isEmpty()) { + News.error(""+mark+" - 4"+" - 1003绔欏叆搴擄紝妫�娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode); + continue; + } } try { @@ -229,39 +230,48 @@ 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())); + + short staNo = dto.getStaNo().shortValue(); + if (inSta.getStaNo() == 1002) { + staNo = 2002; + } + barcodeThread.setBarcode(""); staProtocol.setWorkNo(dto.getWorkNo().shortValue()); - staProtocol.setStaNo(dto.getStaNo().shortValue()); + staProtocol.setStaNo(staNo); + staProtocol.setPalletSize(locMast.getLocType2()); devpThread.setPakMk(staProtocol.getSiteId(), false); boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (!result) { throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } - // led 鍏ュ簱淇℃伅鏄剧ず - 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, inSta.getLed(), new Task(3, commands)); -// ledThread.errorReset(); - } +// // led 鍏ュ簱淇℃伅鏄剧ず +// 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, inSta.getLed(), new Task(3, commands)); +//// ledThread.errorReset(); +// } } else { News.error(""+mark+" - 5"+" - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); - staProtocol.setWorkNo((short)9999); - staProtocol.setStaNo(inSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } +// staProtocol.setWorkNo((short)9992); +// staProtocol.setStaNo(inSta.getBackSta().shortValue()); +// devpThread.setPakMk(staProtocol.getSiteId(), false); +// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); +// if (!result) { +// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); +// } // led 寮傚父鏄剧ず if (ledThread != null) { @@ -278,7 +288,7 @@ }else { News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() - +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()+"銆佸叆搴撳嵃璁帮細" + staProtocol.getStamp()); + +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); } } @@ -305,17 +315,15 @@ staProtocol = staProtocol.clone(); } -// // 鍏ュ嚭搴撴ā寮忓垽鏂� - if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { - continue; - } - // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (!staProtocol.isLoading()){ continue; } - if (staProtocol.isAutoing() && staProtocol.isInEnable() - && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999) + + if (staProtocol.isAutoing() + && staProtocol.isInEnable() + && !staProtocol.isEmptyMk() + && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()) { News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); // 鍒ゆ柇閲嶅宸ヤ綔妗� @@ -345,7 +353,7 @@ }else { News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isLoading()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() - +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()+"銆佸叆搴撳嵃璁帮細" + staProtocol.getStamp()); + +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); } } } @@ -360,21 +368,6 @@ for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鎷f枡鍏ュ簱鍙� for (DevpSlave.Sta pickSta : devp.getPickSta()) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); - if (barcodeThread == null) { - continue; - } - String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); - if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { - continue; - } - } else { - continue; - } - // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); @@ -384,13 +377,30 @@ staProtocol = staProtocol.clone(); } -// // 鍏ュ嚭搴撴ā寮忓垽鏂� -// if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } - - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()) { + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.getWorkNo() > 0 + && staProtocol.isPakMk()) { News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); - WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); -// WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); + +// // 鑾峰彇鏉$爜鎵弿浠俊鎭� +// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); +// if (barcodeThread == null) { +// continue; +// } +// String barcode = barcodeThread.getBarcode(); +// if(!Cools.isEmpty(barcode)) { +// News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); +// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { +// continue; +// } +// } else { +// continue; +// } + +// WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); + WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); if (wrkMast == null) { // 鏃犳嫞鏂欐暟鎹� continue; @@ -416,11 +426,11 @@ .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)); +// 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, pickSta.getLed()); // led 寮傚父鏄剧ず @@ -453,6 +463,7 @@ wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� wrkMast.setSourceLocNo(""); // 婧愬簱浣嶆竻绌� wrkMast.setModiTime(now); + wrkMast.setUpdMk("");//鍏佽鍐嶆绉诲簱 if (wrkMastMapper.updateById(wrkMast) == 0) { throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); } @@ -471,9 +482,153 @@ 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枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); + } + + /** + * 鎷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) { @@ -532,9 +687,13 @@ // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + 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; } @@ -624,59 +783,147 @@ } /** - * 鍥炲師鐐癸紝鍫嗗灈鏈烘病鏈夋墽琛屼腑浠诲姟锛岃澶囧瓨鍦ㄥ叆搴撲换鍔℃椂鍙洖鍘熺偣 + * 鍫嗗灈鏈烘棤浠诲姟涓ゅ垎閽燂紝鍥炲叆搴撳彛寰呮満 */ - public synchronized void crnRebackHp(CrnProtocol crnProtocol, CrnThread crnThread) { -// for (CrnSlave crn : slaveProperties.getCrn()) { -// // 鑾峰彇鍫嗗灈鏈轰俊鎭� -// CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); -// CrnProtocol crnProtocol = crnThread.getCrnProtocol(); -// if (crnProtocol == null) { -// continue; -// } -// BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); -// if (basCrnp == null) { -// 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; + public synchronized void crnMove() { + for (CrnSlave crn : slaveProperties.getCrn()) { + if (crn.getId() == 1) { + continue; } - // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�3,12 - if (wrkMastMapper.selectWorking(crnProtocol.getCrnNo()) != null) { - return; + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); + if (basCrnp == null) { + log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); + continue; } - //鍫嗗灈鏈烘湁鎵ц涓换鍔★紝杩囨护3,4,11,12 - if (wrkMastMapper.selectCrnWorking(crnProtocol.getCrnNo()) != null) { - return; - } + if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { + continue; + } - //杈撻�佺嚎娌℃湁鍏ュ簱浠诲姟锛岃繃婊�2 - if (wrkMastMapper.selectDevWorking(crnProtocol.getCrnNo()) == null) { - return; + if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60 * 2) { + continue; + } + + Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); + if (object != null) { + continue; + } + + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .eq("crn_no", crn.getId()) + .notIn("wrk_sts", 5, 14, 15) + ); + if (!wrkMasts.isEmpty()) { + continue; + } + + CrnSlave.CrnStn crnStn = crn.getCrnInStn().get(0); + + News.info("鍫嗗灈鏈烘棤浠诲姟鑷姩鍥炲叆搴撳彛寰呮満==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満"); + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo((short) 9999); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.CRN_MOVE); // 浠诲姟妯″紡: 鍫嗗灈鏈虹Щ鍔� + crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY((short) 1); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { + News.error("鍫嗗灈鏈虹Щ鍔ㄥ懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); + } + crnThread.setBackHpFlag(true); + redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); + try { + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } } - News.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))) { - News.error("鍫嗗灈鏈哄洖鍘熺偣鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); - } - crnThread.setBackHpFlag(true); } -// } + } + + /** + * 鍫嗗灈鏈烘湁鍏ュ簱浠诲姟鏃讹紝鍥炲叆搴撳彛寰呮満 + */ + public synchronized void crnMoveByInTask() { + for (CrnSlave crn : slaveProperties.getCrn()) { + if (crn.getId() == 1) { + continue; + } + + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); + if (basCrnp == null) { + log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); + continue; + } + + if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { + continue; + } + + if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60) { + continue; + } + + Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); + if (object != null) { + continue; + } + + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .eq("crn_no", crn.getId()) + .eq("wrk_sts", 2) + ); + if (wrkMasts.isEmpty()) { + continue; + } + + CrnSlave.CrnStn crnStn = crn.getCrnInStn().get(0); + + News.info("鍫嗗灈鏈烘湁鍏ュ簱浠诲姟鏃讹紝鍥炲叆搴撳彛寰呮満==>>" + crnProtocol.getCrnNo() + "鍙峰爢鍨涙満"); + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo((short) 9999); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.CRN_MOVE); // 浠诲姟妯″紡: 鍫嗗灈鏈虹Щ鍔� + crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY((short) 1); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { + News.error("鍫嗗灈鏈虹Щ鍔ㄥ懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); + } + crnThread.setBackHpFlag(true); + redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); + try { + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } /** @@ -741,6 +988,17 @@ continue; } + if (crnProtocol.getCrnNo() == 1) { + //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬� + if (Utils.getLaneByLocNo(wrkMast.getLocNo()) != crnProtocol.getCrnLane()) { + //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц + List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); + if (!currentWrkMasts.isEmpty()) { + continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� + } + } + } + // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� if (Utils.isDeepLoc(slaveProperties, wrkMast.getLocNo())) { News.warnNoLog(""+mark+" - 1"+" - 8"+" - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}",wrkMast.getWrkNo()); @@ -748,21 +1006,27 @@ 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); } else { - waitWrkMast.setIoPri(15D); - waitWrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(waitWrkMast) == 0) { - News.error(""+mark+" - 1"+" - 11"+" - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + 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()); + } + continue; } - 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)){ @@ -780,7 +1044,7 @@ } 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()); @@ -788,7 +1052,7 @@ } } } - News.warnNoLog(""+mark+" - 1"+" - 15"+" - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}",wrkMast.getWrkNo().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()); @@ -839,6 +1103,20 @@ */ 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()); + } + + 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()); @@ -869,6 +1147,18 @@ staProtocol = staProtocol.clone(); } + if (wrkMast.getStaNo() == 1003 || wrkMast.getStaNo() == 1007) { + //妫�娴嬫槸鍚︽湁鍏ュ簱浠诲姟 + List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("io_type", 1, 53, 57) + .in("source_sta_no", 1005) + ); + if (!inWrkMasts.isEmpty()) { + News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦ㄥ叆搴撲换鍔★紝绛夊緟鍏ュ簱浠诲姟鎵ц瀹屾垚鍐嶅嚭搴擄紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo()); + continue; + } + } + // // 鍏ュ嚭搴撴ā寮忓垽鏂� // if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } // if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { @@ -885,13 +1175,40 @@ } // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵�� if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") - && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { + && staProtocol.getWorkNo() == 0) { + + //鏍规嵁鍙傛暟鍒ゆ柇鏄惁鏍¢獙鍙嚭淇″彿 + String crnOutVerifyOut = "Y"; + Config crnOutVerifyOutEnableConfig = configService.selectOne(new EntityWrapper<Config>() + .eq("code", "crnOutVerifyOutEnable")); + if(crnOutVerifyOutEnableConfig != null) { + crnOutVerifyOut = crnOutVerifyOutEnableConfig.getValue(); + } + + if (crnOutVerifyOut.equals("Y")) { + if (!staProtocol.isOutEnable()) { + continue; + } + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- // 鍫嗗灈鏈烘帶鍒惰繃婊� if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { // continue; break; + } + + if (crnProtocol.getCrnNo() == 1) { + //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬� + if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) { + //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц + List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); + if (!currentWrkMasts.isEmpty()) { + continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔� + } + } } // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� @@ -901,7 +1218,7 @@ 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); @@ -918,7 +1235,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); @@ -939,7 +1256,7 @@ 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()); @@ -1267,7 +1584,6 @@ * 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣� */ public synchronized void storeFinished(Integer mark) { - for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -1461,13 +1777,43 @@ 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.getStamp()>=2) { + && 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); @@ -1476,6 +1822,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") @@ -1495,31 +1842,7 @@ 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)9999); - 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)) { @@ -1530,9 +1853,115 @@ } } catch (Exception e) { e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } else { + News.errorNoLog(""+mark+" - 4"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); + } + } + } + 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(1007); + 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); + 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() @@ -1615,24 +2044,39 @@ ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); ledCommand.setLocNo(wrkMast.getLocNo()); ledCommand.setStaNo(wrkMast.getStaNo()); + ledCommand.setBarcode(wrkMast.getBarcode()); // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); - try{ - if (wrkMast.getIoType()>100){ - for (WrkDetl wrkDetl : wrkDetls){ - LocDetl locDetl = locDetlService.selectMatnrSpecs(wrkDetl.getMatnr(), wrkDetl.getSpecs(), wrkMast.getSourceLocNo()); - wrkDetl.setWeight(locDetl.getAnfme()); - } - }else { - for (WrkDetl wrkDetl : wrkDetls){ - wrkDetl.setWeight(wrkDetl.getAnfme()); - } - } - }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.getSpecs()))); +// try{ +// if (wrkMast.getIoType()>100){ +// for (WrkDetl wrkDetl : wrkDetls){ +// LocDetl locDetl = locDetlService.selectMatnrSpecs(wrkDetl.getMatnr(), wrkDetl.getSpecs(), wrkMast.getSourceLocNo()); +// wrkDetl.setWeight(locDetl.getAnfme()); +// } +// }else { +// for (WrkDetl wrkDetl : wrkDetls){ +// wrkDetl.setWeight(wrkDetl.getAnfme()); +// } +// } +// }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() + ))); } commands.add(ledCommand); } @@ -1772,10 +2216,11 @@ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); for (LocDetl locDetl : locDetls) { WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(locDetl); wrkDetl.setWrkNo(workNo); wrkDetl.setIoTime(now); wrkDetl.setAnfme(locDetl.getAnfme()); - VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 +// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 wrkDetl.setAppeTime(now); wrkDetl.setModiTime(now); if (!wrkDetlService.insert(wrkDetl)) { @@ -1875,7 +2320,8 @@ wrkMast.setCrnNo(crn.getId()); wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 婧愬簱浣� wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅 - wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘 +// wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘 + wrkMast.setFullPlt(shallowLoc.getLocSts().equals("D") ? "N" : "Y"); // 婊℃澘 wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘 @@ -1886,22 +2332,26 @@ int res = wrkMastMapper.insert(wrkMast); if (res == 0) { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 2"+" - 淇濆瓨宸ヤ綔妗eけ璐�"); - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); +// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); + return true; } // 宸ヤ綔妗f槑缁嗕繚瀛� if (shallowLoc.getLocSts().equals("F")) { List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); + for (LocDetl locDetl : locDetls) { WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(locDetl); wrkDetl.setWrkNo(workNo); wrkDetl.setIoTime(new Date()); wrkDetl.setAnfme(locDetl.getAnfme()); - VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 +// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 wrkDetl.setAppeTime(new Date()); wrkDetl.setModiTime(new Date()); if (!wrkDetlService.insert(wrkDetl)) { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 3"+" - 淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); - throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); +// throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + return true; } } } @@ -1911,11 +2361,13 @@ shallowLoc.setModiTime(new Date()); if (!locMastService.updateById(shallowLoc)) { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 4"+" - 鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); - throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); +// throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); + return true; } } else { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 5"+" - 婧愬簱浣嶅嚭搴撳け璐�"); - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); +// throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); + return true; } // 淇敼鐩爣搴撲綅鐘舵�� if (loc.getLocSts().equals("O")) { @@ -1923,11 +2375,13 @@ loc.setModiTime(new Date()); if (!locMastService.updateById(loc)) { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 6"+" - 鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); - throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); +// throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); + return true; } } else { News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 7"+" - 绉昏浆澶辫触"); - throw new CoolException("绉昏浆澶辫触"); +// throw new CoolException("绉昏浆澶辫触"); + return true; } } catch (Exception e){ News.error(""+mark+"moveLocForDeepLoc"+" - 8"+" - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e); @@ -1970,6 +2424,11 @@ LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); LocMast loc = locMastService.queryDemoLoc(crn.getId()); if (null == sourceLoc || null == loc) { + continue; + } + + Integer ctnType = 1; + if (ctnType.equals(loc.getCtnType())) { continue; } @@ -2027,6 +2486,7 @@ // 淇敼鐩爣搴撲綅鐘舵�� if (loc.getLocSts().equals("O")) { loc.setLocSts("S"); // S.鍏ュ簱棰勭害 + loc.setCtnType(1); loc.setModiTime(new Date()); if (!locMastService.updateById(loc)) { throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); @@ -2094,161 +2554,313 @@ } } - /** - * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁� - */ - public synchronized void ioConvert() { - try { - // 鏍规嵁杈撻�佺嚎plc閬嶅巻 - for (DevpSlave devp : slaveProperties.getDevp()) { - SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + // RGV ===>> 鎵ц瀵筊GV鎿嶄綔 + public synchronized void rgvExecute(Integer mark) { + ArrayList<Integer> list = new ArrayList<Integer>(){{add(2003);add(2002);}}; + for (Integer staNo : list) { + Integer devpId = null; + Integer rgvStaNoDevpId = null; + Integer rgvStaNo = null; + if (staNo == 2003) { + devpId = 1; + rgvStaNo = 2002; + rgvStaNoDevpId = 2; + }else { + devpId = 2; + rgvStaNo = 2003; + rgvStaNoDevpId = 1; + } - for (DevpSlave.Sta inSta : devp.getInSta()) { - if (inSta.getStaNo() == 2) { + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devpId); + if (devpThread == null) { + continue; + } + StaProtocol staProtocol = devpThread.getStation().get(staNo); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.getWorkNo() > 0 + ) { + WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() + .eq("wrk_no", staProtocol.getWorkNo())); + + if (wrkMast == null) { + continue; + } + + if (wrkMast.getWrkSts() == 201) { + continue; + } + + SiemensDevpThread devpThread2 = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, rgvStaNoDevpId); + if (devpThread2 == null) { + continue; + } + StaProtocol staProtocolRgvStaNo = devpThread2.getStation().get(rgvStaNo); + if (staProtocolRgvStaNo == null) { + continue; + } + + if (!staProtocolRgvStaNo.isAutoing()) { + continue; + } + + if (staProtocolRgvStaNo.isLoading()) { + continue; + } + + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, 1); + if (rgvThread == null) { + continue; + } + + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + + if (rgvProtocol.statusType1 != RgvStatusType.IDLE && rgvProtocol.getTaskNo1() != 0) { + continue; + } + + Object object = redisUtil.get(RedisConstantType.RGV_MOVE_LOCK + wrkMast.getWrkNo()); + if (object != null) { + continue; + } + + RgvCommand command = new RgvCommand(); + command.setRgvNo(1); // RGV缂栧彿 + command.setAckFinish1((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskNo1(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + command.setTaskMode1(RgvTaskModeType.FETCH_PUT); // 浠诲姟妯″紡: 鍙栨斁璐� + command.setSourceStaNo1(staNo.shortValue()); // 婧愮珯 + command.setDestinationStaNo1(rgvStaNo.shortValue()); // 鐩爣绔� + command.setCommand((short) 0); + + boolean result = MessageQueue.offer(SlaveType.Rgv, 1, new Task(4, command)); + if (!result) { + throw new CoolException("RGV鎸囦护涓嬪彂澶辫触"); + } + + wrkMast.setWrkSts(201L);//201.RGV鎼繍涓� + wrkMast.setModiTime(new Date()); + wrkMastService.updateById(wrkMast); + redisUtil.set(RedisConstantType.RGV_MOVE_LOCK + wrkMast.getWrkNo(), "lock", 60 * 60); + } + } + } + + // RGV ===>> 鎵ц瀵筊GV宸ヤ綔妗g殑瀹屾垚鎿嶄綔 + public synchronized void rgvFinished(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 = null; + Integer devpStaNo = null; + String locNo = null; + Long updateWrkSts = null; + if (wrkMast.getIoType() < 100) { + //鍏ュ簱 + updateWrkSts = 2L; + devpId = 1; + devpStaNo = 2003; + locNo = wrkMast.getLocNo(); + }else { + //鍑哄簱 + updateWrkSts = 15L; + devpId = 2; + devpStaNo = 2002; + locNo = wrkMast.getSourceLocNo(); + } + + // 鑾峰彇鍏ュ簱绔欎俊鎭� + 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 + ) { + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() + .eq("loc_no", locNo)); + 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, devpId, new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + wrkMastMapper.updateWrkSts(updateWrkSts, wrkMast.getWrkNo()); + rgvThread.setResetFlag1(true); + } + } + } + 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; } - WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); - switch (inSta.getStaNo()) { - case 203://1F - if (pakout != null) { - if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { - // 鍑哄簱鍒囨崲涓� - 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.ioModeOf2F = IoModeType.PAKOUT_MODE; - } - } - } 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; + + 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); - } - - } catch (Exception e) { - e.printStackTrace(); - } - - - } - - public synchronized void outOfDevp(Integer mark) { - - List<WrkMast> wrkMasts = wrkMastMapper.selectPick(); - if (wrkMasts.size()!=0){ - News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛宱utOfDevp"); - } - for (WrkMast wrkMast : wrkMasts) { - if (basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())) == 0) { - wrkMast.setCtnNo("Y"); - if (wrkMastMapper.updateById(wrkMast) == 0) { - News.error(""+mark+" - 1"+" - 淇敼{}宸ヤ綔妗eけ璐ワ紝ctn_no", wrkMast.getWrkNo()); + wrkMastService.delete(new EntityWrapper<WrkMast>() + .eq("wrk_no", wrkMast.getWrkNo())); } } } - News.infoNoLog(""+mark+" - 0"+" - outOfDevp鎵ц瀹屾垚"); + News.infoNoLog(""+mark+" - 0"+" - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); } - - 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"); - News.info((String) data.get("msg")); - } else { - News.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)) { - News.info((String) jsonObject.get("msg")); - } else { - News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyIn/v1", JSON.toJSONString(locTypeDto), response); - } - } catch (Exception e) { - e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - } - } - } +// /** +// * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁� +// */ +// public synchronized void ioConvert() { +// try { +// // 鏍规嵁杈撻�佺嚎plc閬嶅巻 +// for (DevpSlave devp : slaveProperties.getDevp()) { +// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); +// +// for (DevpSlave.Sta inSta : devp.getInSta()) { +// if (inSta.getStaNo() == 2) { +// continue; +// } +// WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); +// switch (inSta.getStaNo()) { +// case 101://1F +// if (pakout != null) { +// if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { +// // 鍑哄簱鍒囨崲涓� +// 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.ioModeOf2F = IoModeType.PAKOUT_MODE; +// } +// } +// } else { +// // 鍏ュ簱妯″紡 +// devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; +// } +// break; +// } +// } +// +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// +// } } -- Gitblit v1.9.1