From ee51a946795e372e5d7ed025a71dabd27048975c Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 02 七月 2021 11:14:00 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 80 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 75 insertions(+), 5 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 f8b3fb2..30b2c4c 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.Cools; +import com.core.common.DateUtils; import com.core.exception.CoolException; import com.zy.asrs.domain.enums.WorkNoType; import com.zy.asrs.entity.*; @@ -57,8 +58,8 @@ @Transactional public class MainServiceImpl { - @Autowired - private RowLastnoService rowLastnoService; + + public static final long COMMAND_TIMEOUT = 5 * 1000; @Autowired private CommonService commonService; @@ -99,6 +100,9 @@ for (DevpSlave.Sta inSta : devp.getInSta()) { // 鑾峰彇鏉$爜鎵弿浠俊鎭� BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); + if (barcodeThread == null) { + continue; + } String barcode = barcodeThread.getBarcode(); if(!Cools.isEmpty(barcode)) { log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); @@ -223,7 +227,7 @@ staProtocol = staProtocol.clone(); } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 - if (staProtocol.isAutoing() && staProtocol.isLoading() + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999) && staProtocol.isPakMk()) { // 鍒ゆ柇閲嶅宸ヤ綔妗� @@ -493,7 +497,7 @@ // 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。 WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); if(null == wrkMast) { - log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); +// log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo()); continue; } // 鑾峰彇搴撲綅淇℃伅 @@ -512,6 +516,11 @@ continue; } + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(slave.getId()) != null) { + return; + } + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� @@ -527,6 +536,19 @@ if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { + +// long startTime = System.currentTimeMillis(); +// while ((System.currentTimeMillis() - startTime) < COMMAND_TIMEOUT) { +// +// if (true) { +// break; +// } +// +// try{ +// Thread.sleep(500); +// }catch(Exception ignore){} +// } + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� Date now = new Date(); wrkMast.setWrkSts(3L); @@ -1072,7 +1094,7 @@ // 鑾峰彇led绾跨▼ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); // led鏄剧ず榛樿鍐呭 - if (!ledThread.isResetStatus() && reset) { + 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()); } @@ -1332,5 +1354,53 @@ } } + /** + * 鍫嗗灈鏈哄懡浠や笅鍙戝悗锛屽紓姝ヤ慨鏀瑰伐浣滄。鐘舵�� + */ + public synchronized void crnIoWrkMast(){ + for (CrnSlave crn : slaveProperties.getCrn()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + Date now = new Date(); + // 鍫嗗灈鏈烘鍦ㄨ繍琛� + if (crnProtocol.getStatusType() != CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + // 鑾峰彇宸ヤ綔妗� + WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); + 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()); + // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� + wrkMast.setWrkSts(3L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); + } + // 鍑哄簱銆佺Щ搴� + if (wrkMast.getWrkSts() == 11) { + log.warn("鍫嗗灈鏈洪潪绌洪棽鎯呭喌涓嬶紝寮�濮嬩慨鏀瑰伐浣滄。鐘舵�併�俒id:{},鏃堕棿锛歿}] >>>>> 鍫嗗灈鏈哄綋鍓嶇姸鎬佷负锛歿}銆備换鍔″彿:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); + // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� + wrkMast.setWrkSts(12L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); + } + + + } + + } + } + } -- Gitblit v1.9.1