From 8cedbe419f6e561b4e8069bbaa8013ce4443fd09 Mon Sep 17 00:00:00 2001 From: 1 <1@123> Date: 星期六, 03 五月 2025 09:53:06 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 137 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 126 insertions(+), 11 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 d0fc70b..fa6d1e3 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -16,20 +16,21 @@ import com.zy.asrs.utils.RouteUtils; import com.zy.asrs.utils.TrackRangeUtils; import com.zy.asrs.utils.Utils; +import com.zy.common.model.MatDto; import com.zy.common.service.CommonService; +import com.zy.common.utils.CollectionUtils; import com.zy.common.utils.HttpHandler; import com.zy.core.CrnThread; import com.zy.core.DevpThread; import com.zy.core.cache.*; import com.zy.core.enums.*; -import com.zy.core.model.CrnSlave; -import com.zy.core.model.DevpSlave; -import com.zy.core.model.RgvSlave; -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.protocol.*; 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; @@ -42,6 +43,7 @@ import java.io.IOException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; /** * 绔嬩綋浠撳簱WCS绯荤粺涓绘祦绋嬩笟鍔� @@ -192,7 +194,7 @@ String barcode = barcodeThread.getBarcode(); if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) { // 璇锋眰wms鎺ュ彛锛岃幏鍙栧伐浣滃彿鍜岀洰鏍囧簱浣� - ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), 0); + ToWmsDTO toWmsDTO = new ToWmsDTO(staProtocol.getSiteId(),staProtocol.getGrossWt(),barcode, 0); TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); if (!Cools.isEmpty(taskWrk1)) { log.info("鎵樼洏鐮侊細" + barcode + "浠诲姟妗e瓨鍦�"); @@ -515,7 +517,7 @@ } } } else { - TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>()); + TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("IO_TYPE",1).eq("WRK_STS",1).eq("START_POINT",staProtocol.getSiteId().toString())); if (!Cools.isEmpty(taskWrk1)) { if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { @@ -603,7 +605,7 @@ if (offer) { log.info("涓嬪彂杈撻�佺嚎浠诲姟鎴愬姛锛歵askWrk:" + JSON.toJSONString(taskWrk)); Date now = new Date(); - taskWrk.setStatus(5); + taskWrk.setStatus(9); taskWrk.setWrkSts(14); taskWrk.setModiTime(now); taskWrk.setCompleteTime(now); @@ -795,7 +797,7 @@ HashMap<String, Object> headParam = new HashMap<>(); headParam.put("taskNo", taskWrk.getTaskNo()); headParam.put("status", taskWrk.getStatus()); - headParam.put("ioType", taskWrk.getIoType()); + headParam.put("ioType", taskWrk.getIoTypeWms()); headParam.put("barcode", taskWrk.getBarcode()); String response; response = new HttpHandler.Builder() @@ -915,7 +917,7 @@ HashMap<String, Object> headParam = new HashMap<>(); headParam.put("taskNo", taskWrk.getTaskNo()); headParam.put("status", taskWrk.getStatus()); - headParam.put("ioType", taskWrk.getIoType()); + headParam.put("ioType", taskWrk.getIoTypeWms()); headParam.put("barcode", taskWrk.getBarcode()); String response; response = new HttpHandler.Builder() @@ -1019,7 +1021,7 @@ HashMap<String, Object> headParam = new HashMap<>(); headParam.put("taskNo", taskWrk.getTaskNo()); headParam.put("status", taskWrk.getStatus()); - headParam.put("ioType", taskWrk.getIoType()); + headParam.put("ioType", taskWrk.getIoTypeWms()); headParam.put("barcode", taskWrk.getBarcode()); String response; response = new HttpHandler.Builder() @@ -1133,7 +1135,7 @@ HashMap<String, Object> headParam = new HashMap<>(); headParam.put("taskNo", taskWrk.getTaskNo()); headParam.put("status", taskWrk.getStatus()); - headParam.put("ioType", taskWrk.getIoType()); + headParam.put("ioType", taskWrk.getIoTypeWms()); headParam.put("barcode", taskWrk.getBarcode()); String response; log.error("wcs瀹岀粨浠诲姟涓婃姤wms==銆�", headParam); @@ -1641,5 +1643,118 @@ return true; } + /** + * 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣� + */ + public synchronized void ledExecute(Integer mark) { + + for (LedSlave led : slaveProperties.getLed()) { + // 鑾峰彇杈撻�佺嚎plc绾跨▼ + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); + // 鍛戒护闆嗗悎 + List<LedCommand> commands = new ArrayList<>(); + // 宸ヤ綔妗i泦鍚� + List<WrkMast> wrkMasts = new ArrayList<>(); + for (Integer staNo : led.getStaArr()) { + // 鑾峰彇鍙夎溅绔欑偣 + StaProtocol staProtocol = devpThread.getStation().get(staNo); + if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + // 鑾峰彇宸ヤ綔妗f暟鎹� + LedCommand ledCommand = new LedCommand(); + +// +// ledCommand.setWorkNo(wrkMast.getWrkNo()); +// ledCommand.setIoType(wrkMast.getIoType()); +// ledCommand.setTitle("绌烘澘鍑哄簱"); +// ledCommand.setEmptyMk(true); +// ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); +// ledCommand.setLocNo(wrkMast.getLocNo()); +// ledCommand.setStaNo(wrkMast.getStaNo()); + MatDto matDto = new MatDto(); + ledCommand.getMatDtos().add(matDto); + commands.add(ledCommand); + } + Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); + // 鑾峰彇LED绾跨▼ + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); + // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护 + if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { + continue; + } + // 鍛戒护涓嬪彂 ------------------------------------------------------------------------------- + if (!commands.isEmpty()) { + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { +// News.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + continue; + }else { + ledThread.setLedMk(false); + } + } + + try { + // 淇敼涓绘。led鏍囪 + for (WrkMast wrkMast : wrkMasts) { + wrkMast.setOveMk("Y"); + wrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) == 0) { +// News.errorNoLog(""+mark+" - 4"+" - 鏇存柊宸ヤ綔妗eけ璐�"); + throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�"); + } + } + + // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚� + ledThread.setWorkNos(workNos); + + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + + } +// News.infoNoLog(""+mark+" - 0"+" - 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣ㄦ墽琛屽畬鎴�"); + } + + /** + * 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅 + */ + public synchronized void ledReset(Integer mark) { + +// News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); + 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; + } + if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { + reset = false; + break; + } + } + // 鑾峰彇led绾跨▼ + 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(4, new ArrayList<>()))) { +// News.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + } else { + + } + } + } +// News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚锛氬叾浠� ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); + } + } -- Gitblit v1.9.1