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 | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 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 3ca6779..686be44 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -505,6 +505,148 @@ } /** + * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱-鏉$爜 + */ + public synchronized void stnToCrnStnPickBarcode(Integer mark) { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鎷f枡鍏ュ簱鍙� + for (DevpSlave.Sta insta : devp.getInSta()) { + // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(insta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.getWorkNo() > 0 + && staProtocol.isPakMk()) { + News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�"); + + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, insta.getBarcode()); + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if(!Cools.isEmpty(barcode)) { + News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", insta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + continue; + } + } else { + continue; + } + + WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); + if (wrkMast == null) { + // 鏃犳嫞鏂欐暟鎹� + continue; + } + if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { + continue; + } + + // 鎷c�佺洏銆佸苟 浣滀笟绔欒浆鎹� +// int stnNo = 0; +// if (wrkMast.getStaNo() == 109) { +// stnNo = 127; +// } else if (wrkMast.getStaNo() == 113) { +// stnNo = 128; +// } else { +// log.error("{}鍙蜂换鍔℃暟鎹紓甯革紒", wrkMast.getWrkNo()); +// } + // 鑾峰彇鐩爣绔� + Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() + .eq("type_no", wrkMast.getIoType() - 50) + .eq("stn_no", insta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯 + .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿 + StaDesc staDesc = staDescService.selectOne(wrapper); + if (Cools.isEmpty(staDesc)) { +// News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); +// staProtocol.setWorkNo((short) 9989); +// staProtocol.setStaNo((short) (pickSta.getStaNo().shortValue()-(short)1)); +// devpThread.setPakMk(staProtocol.getSiteId(), false); +// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + //LED + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, insta.getLed()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+insta.getBackSta().shortValue()+"绔欑偣"; + MessageQueue.offer(SlaveType.Led, insta.getLed(), new Task(5, errorMsg)); + } + continue; + } + + try { + // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。 + if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { + throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触"); + } + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { + throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); + } + + Date now = new Date(); + // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�) + Integer staNo = staDesc.getCrnStn(); + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoTime(now); + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 + wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 + wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 婧愮珯 + wrkMast.setStaNo(staNo); // 鐩爣绔� + wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� + wrkMast.setSourceLocNo(""); // 婧愬簱浣嶆竻绌� + wrkMast.setModiTime(now); + wrkMast.setUpdMk("");//鍏佽鍐嶆绉诲簱 + if (wrkMastMapper.updateById(wrkMast) == 0) { + throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + } + // 鏇存柊鏄庣粏妗o_time (鍘嗗彶妗e叧鑱斾娇鐢級 + wrkDetlService.updateIoTime(wrkMast.getWrkNo(), now); + // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + locMast.setLocSts("Q"); + locMast.setModiTime(new Date()); + if (!locMastService.updateById(locMast)) { + throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�"); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + continue; + } + + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + staProtocol.setPalletSize(locMast.getLocType2()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + News.error(""+mark+" - 3"+" - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId()); + } + + }else { + News.errorNoLog(""+mark+" - 6"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isLoading()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()); + } + + } + + } + News.infoNoLog(""+mark+" - 0"+" - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�"); + } + + /** * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 */ public synchronized void crnStnToOutStn(Integer mark) { -- Gitblit v1.9.1