From 97c788f31a57b4e8c3fc8091dc29aab598adeebb Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期日, 04 一月 2026 08:07:00 +0800
Subject: [PATCH] #1
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 624 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 433 insertions(+), 191 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 5142e6d..13af51d 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -5,15 +5,12 @@
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.entity.*;
import com.zy.asrs.mapper.BasCrnErrorMapper;
-import com.zy.asrs.mapper.WaitPakinMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
-import com.zy.common.constant.RedisConstantType;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.MatDto;
import com.zy.common.model.SearchLocParam;
@@ -29,24 +26,21 @@
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
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.command.LiftCommand;
import com.zy.core.model.protocol.CrnProtocol;
-import com.zy.core.model.protocol.RgvProtocol;
+import com.zy.core.model.protocol.LiftProtocol;
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.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.*;
@@ -74,8 +68,6 @@
private WrkDetlService wrkDetlService;
@Autowired
private WrkDetlLogService wrkDetlLogService;
- @Autowired
- private WaitPakinMapper waitPakinMapper;
@Autowired
private LocMastService locMastService;
@Autowired
@@ -132,21 +124,22 @@
continue;
}
+ String barcode = barcodeThread.getBarcode();
+ if (Cools.isEmpty(barcode)){
+ continue;
+ }
+
if (staProtocol.isAutoing()
&& staProtocol.isInEnable()
&& !staProtocol.isEmptyMk()
&& staProtocol.getWorkNo() == 9999
- && staProtocol.isPakMk() && (staProtocol.getEmptyInType() != 1 && staProtocol.getEmptyInType() != 2)) {
+ && staProtocol.isPakMk()) {
News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�");
- 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) 9992);
-// staProtocol.setStaNo(inSta.getBackSta().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ if ("NG".endsWith(barcode) || "No Read".equals(barcode) || "empty".equals(barcode)) {
News.info("" + mark + " - 2" + " - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo());
// led 寮傚父鏄剧ず
if (ledThread != null) {
@@ -156,11 +149,6 @@
continue;
}
} else {
-// 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 寮傚父鏄剧ず
if (ledThread != null) {
@@ -175,19 +163,12 @@
//杩囨护鍒ゆ柇锛岄槻姝㈡嫞鏂欏啀鍏ュ簱璐х墿锛岀粡杩囧叆搴撶珯鍐嶅叆搴撴椂锛岃閫�鍥炲埌閫�搴撶珯
WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode);
if (wrkMast1 != null) {
- if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104) {
+ if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104|| wrkMast1.getIoType() == 53 || wrkMast1.getIoType() == 57 || wrkMast1.getIoType() == 54) {
continue;
}
}
if (wrkMast != null) {
- News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
-// 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绔欑偣淇℃伅澶辫触");
-// }
+ News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 3.寮�濮嬫墽琛屽叆搴撲换鍔� 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
// led 寮傚父鏄剧ず
if (ledThread != null) {
@@ -197,16 +178,21 @@
continue;
}
- if (inSta.getStaNo() == 1002 || inSta.getStaNo() == 1007) {
- //妫�娴嬫槸鍚︽湁鍑哄簱浠诲姟
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
- .in("io_type", 101, 103, 107)
- .in("sta_no", 1003, 1004)
- );
- if (!wrkMasts.isEmpty()) {
- News.error("" + mark + " - 4" + " - 鍏ュ簱锛屾娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode);
- continue;
- }
+ LiftProtocol liftProtocol = devpThread.getLiftStatus();
+ if(liftProtocol == null) {
+ continue;
+ }
+
+ if (liftProtocol.getMode() != 1) {
+ continue;
+ }
+
+ if (liftProtocol.getDeviceStatus() != 0) {
+ continue;
+ }
+
+ if (liftProtocol.getWorkNo() > 0) {
+ continue;
}
try {
@@ -227,59 +213,51 @@
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();
-
- int sourceStaNo = dto.getSourceStaNo();
- if (sourceStaNo == 1007) {
- staNo = 2002;
+ WrkMast currentWrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", dto.getWorkNo()));
+ if (currentWrkMast == null) {
+ throw new CoolException("WMS鐢熸垚浠诲姟鍚庯紝WCS鏌ヨ涓虹┖");
}
- if (inSta.getStaNo() == 1002) {
- staNo = 2002;
- }
+ Integer staNo = Utils.getStaNoByLocNo(dto.getLocNo());
+
+ LiftCommand command = new LiftCommand();
+ command.setWorkNo(dto.getWorkNo());
+ command.setSourceStaNo(inSta.getStaNo());
+ command.setTargetStaNo(staNo);
barcodeThread.setBarcode("");
- staProtocol.setWorkNo(dto.getWorkNo().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));
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command));
+ if (result) {
+ News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",command.toString());
+ }
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();
-// }
+ currentWrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+ currentWrkMast.setCrnStrTime(new Date());
+ wrkMastService.updateById(currentWrkMast);
+ Thread.sleep(3000); // 寤舵椂3S
} else {
News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
-// 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) {
String errorMsg = jsonObject.getString("msg");
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+ }
+
+ //鎵樼洏閫�鍥�
+// LiftCommand command = new LiftCommand();
+// command.setWorkNo(9998);
+// command.setSourceStaNo(inSta.getStaNo());
+// command.setTargetStaNo(inSta.getBackSta());
+ Integer back = 999;
+
+ barcodeThread.setBarcode("");
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back));
+ if (!result) {
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
}
@@ -339,17 +317,18 @@
continue;
}
- WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
+ WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
// WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
-// if (wrkMast == null) {
-// // 鏃犳嫞鏂欐暟鎹�
-// continue;
-// }
+ if (wrkMast == null) {
+ // 鏃犳嫞鏂欐暟鎹�
+ continue;
+ }
if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
|| Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) {
continue;
}
+
// 鑾峰彇鐩爣绔�
Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
@@ -358,11 +337,6 @@
.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, pickSta.getLed());
// led 寮傚父鏄剧ず
@@ -370,6 +344,23 @@
String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + pickSta.getBackSta().shortValue() + "绔欑偣";
MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg));
}
+ continue;
+ }
+
+ LiftProtocol liftProtocol = devpThread.getLiftStatus();
+ if(liftProtocol == null) {
+ continue;
+ }
+
+ if (liftProtocol.getMode() != 1) {
+ continue;
+ }
+
+ if (liftProtocol.getDeviceStatus() != 0) {
+ continue;
+ }
+
+ if (liftProtocol.getWorkNo() > 0) {
continue;
}
@@ -382,7 +373,7 @@
param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
.setUri(wmsUrl)
- .setPath("/rpc/pakin/pick/loc/v1")
+ .setPath("/rpc/pakin/loc/returnWarehouse")
.setJson(JSON.toJSONString(param))
.build()
.doPost();
@@ -395,26 +386,30 @@
continue;
}
- if(newWrkMast.getWrkSts() != 53 && newWrkMast.getWrkSts() != 57) {
+ if(newWrkMast.getIoType() != 53 && newWrkMast.getIoType() != 57) {
News.error("" + mark + " - 3" + " - 鎷i�夌洏鐐瑰洖搴撳伐浣滄。绫诲瀷寮傚父锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
continue;
}
- if (wrkMast.getWrkSts() != 2) {
+ if (newWrkMast.getWrkSts() != 2) {
News.error("" + mark + " - 3" + " - 鎷i�夌洏鐐瑰洖搴撳伐浣滄。鐘舵�佸紓甯革紒锛侊紒 [plc缂栧彿锛歿}]", devp.getId());
continue;
}
- LocMast locMast = locMastService.selectById(newWrkMast.getLocNo());
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo(newWrkMast.getWrkNo().shortValue());
- staProtocol.setStaNo(newWrkMast.getStaNo().shortValue());
- staProtocol.setPalletSize(locMast.getLocType2());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ Integer staNo = Utils.getStaNoByLocNo(newWrkMast.getLocNo());
+ LiftCommand command = new LiftCommand();
+ command.setWorkNo(newWrkMast.getWrkNo());
+ command.setSourceStaNo(pickSta.getStaNo());
+ command.setTargetStaNo(staNo);
+
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command));
if (!result) {
- News.error("" + mark + " - 3" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
+
+ newWrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+ newWrkMast.setCrnStrTime(new Date());
+ wrkMastService.updateById(newWrkMast);
} else {
News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/pick/loc/v1", JSON.toJSONString(param), response);
}
@@ -433,6 +428,142 @@
e.printStackTrace();
}
News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
+ }
+
+ /**
+ * 鎵ц鍑哄簱浠诲姟
+ */
+ public synchronized void executeOutTask() {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
+ if(devpThread == null) {
+ return;
+ }
+
+ LiftProtocol liftProtocol = devpThread.getLiftStatus();
+ if(liftProtocol == null) {
+ return;
+ }
+
+ if (liftProtocol.getMode() != 1) {
+ return;
+ }
+
+ if (liftProtocol.getDeviceStatus() != 0) {
+ return;
+ }
+
+ if (liftProtocol.getWorkNo() > 0) {
+ return;
+ }
+
+ //妫�娴嬪嚭搴撶珯鏄惁鍙嚭
+ StaProtocol staProtocol = devpThread.getStation().get(100);
+ if (staProtocol == null) {
+ return;
+ }
+
+ if (!staProtocol.isAutoing()) {
+ return;
+ }
+
+ if (staProtocol.isLoading()) {
+ return;
+ }
+
+// if (!staProtocol.isOutEnable()) {
+// return;
+// }
+
+ //妫�鏌ユ槸鍚︽湁姝e湪鎵ц鐨勪换鍔�
+ List<WrkMast> workingWrkMast = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", 3, 12));
+ if (!workingWrkMast.isEmpty()) {
+ return;
+ }
+
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 11).orderBy("create_time"));
+ if (wrkMasts.isEmpty()) {
+ return;
+ }
+
+ WrkMast wrkMast = wrkMasts.get(0);
+ Integer sourceStaNo = Utils.getStaNoByLocNo(wrkMast.getSourceLocNo());
+
+ LiftCommand command = new LiftCommand();
+ command.setWorkNo(wrkMast.getWrkNo());
+ command.setSourceStaNo(sourceStaNo);
+ command.setTargetStaNo(100);
+
+ boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, command));
+ if (!result) {
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+ }
+
+ wrkMast.setWrkSts(12L);// 12.璁惧鎵ц涓�
+ wrkMast.setCrnStrTime(new Date());
+ wrkMastService.updateById(wrkMast);
+ }
+
+ /**
+ * 妫�娴嬩换鍔″畬鎴�
+ */
+ public synchronized void deviceFinished() {
+ // 鏍规嵁plc閬嶅巻
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ if (devpThread == null) {
+ continue;
+ }
+
+ LiftProtocol liftProtocol = devpThread.getLiftStatus();
+ if (liftProtocol == null) {
+ continue;
+ }
+
+// if (liftProtocol.getWorkNo() <= 0) {
+// continue;
+// }
+
+ if (liftProtocol.getMode() != 1) {
+ continue;
+ }
+
+ if (liftProtocol.getDeviceStatus() != 0) {
+ continue;
+ }
+
+// WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", liftProtocol.getWorkNo()));
+// if (wrkMast == null) {
+// continue;
+// }
+
+ List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", 3,12));
+ for (WrkMast wrkMast : wrkMastList) {
+ if (wrkMast.getWrkSts() == 3) {
+ String locNo = wrkMast.getLocNo();
+ Integer staNo = Utils.getStaNoByLocNo(locNo);
+ StaProtocol staProtocol = devpThread.getStation().get(staNo);
+ if (staProtocol.getWorkNo() <= 0 || !staProtocol.isLoading() || !staProtocol.isAutoing() || !Integer.valueOf(staProtocol.getWorkNo()).equals(wrkMast.getWrkNo())){
+ continue;
+ }
+ wrkMast.setWrkSts(4L);
+ wrkMast.setCrnEndTime(new Date());
+ //wrkMast.setIoTime(new Date());
+ wrkMastService.updateById(wrkMast);
+ }else if (wrkMast.getWrkSts() == 12) {
+ Integer targetStaNo = wrkMast.getStaNo();
+ StaProtocol staProtocol = devpThread.getStation().get(targetStaNo);
+ if (staProtocol.getWorkNo() <= 0 || !staProtocol.isLoading() || !staProtocol.isAutoing() || !Integer.valueOf(staProtocol.getWorkNo()).equals(wrkMast.getWrkNo())){
+ continue;
+ }
+ wrkMast.setWrkSts(14L);
+ wrkMast.setCrnEndTime(new Date());
+ //wrkMast.setIoTime(new Date());
+ wrkMastService.updateById(wrkMast);
+ }else {
+ News.error("鏈煡鐨勫伐浣滅姸鎬�");
+ }
+ }
+ }
}
/**
@@ -567,8 +698,6 @@
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
// 鍛戒护闆嗗悎
List<LedCommand> commands = new ArrayList<>();
-// // 宸ヤ綔妗i泦鍚�
-// List<WrkMast> wrkMasts = new ArrayList<>();
List<Integer> workNoList = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
@@ -586,8 +715,7 @@
String barcode = null;
// 鑾峰彇宸ヤ綔妗f暟鎹�
- WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
-// if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
+ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no",staProtocol.getWorkNo()).in("io_type",101,103,104,107));
if (null == wrkMast) {
List<WrkMastLog> wrkMastLogs = wrkMastLogService.selectList(new EntityWrapper<WrkMastLog>()
.eq("wrk_no", staProtocol.getWorkNo())
@@ -659,63 +787,47 @@
ledCommand.setLocNo(locNo);
ledCommand.setStaNo(targetStaNo);
ledCommand.setBarcode(barcode);
-// ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
+
+ // 淇敼寮�濮嬶細澶勭悊澶氫釜wrkDetl锛屼笉鍚堝苟
if (ioType != 110 && ioType != 10) {
List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkNo);
if (!wrkDetls.isEmpty()) {
- WrkDetl wrkDetl = wrkDetls.get(0);
- double anfme = 0D;
- double weight = 0D;
- for (WrkDetl detl : wrkDetls) {
- anfme += detl.getAnfme();
- weight += detl.getWeight();
- wrkDetl.setAnfme(anfme);
- wrkDetl.setWeight(weight);
- }
-
+ // 鑾峰彇搴撳瓨淇℃伅
List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
.eq("loc_no", wrkMast.getSourceLocNo()));
double totalAnfme = 0D;
double totalWeight = 0D;
for (LocDetl locDetl : locDetls) {
totalAnfme += locDetl.getAnfme();
- totalWeight += locDetl.getWeight();
+// totalWeight += locDetl.getWeight();
}
- wrkDetl.setStockNum(totalAnfme);
- wrkDetl.setStockNum2(totalWeight);
- 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()
- , wrkDetl.getCstateid$()
- ));
-
- }else {
+ // 涓烘瘡涓猈rkDetl鍒涘缓鐙珛鐨凪atDto
+ for (WrkDetl wrkDetl : wrkDetls) {
+ // 娉ㄦ剰锛氳繖閲屼娇鐢ㄦ瘡涓獁rkDetl鐨勫師濮嬫暟鎹紝涓嶅悎骞�
+ ledCommand.getMatDtos().add(new MatDto(
+ wrkDetl.getMatnr()
+ , wrkDetl.getMaktx()
+ , wrkDetl.getAnfme() // 浣跨敤鍗曚釜鐗╂枡鐨勬暟閲忥紝涓嶇疮鍔�
+ , wrkDetl.getWeight() // 浣跨敤鍗曚釜鐗╂枡鐨勯噸閲忥紝涓嶇疮鍔�
+ , totalAnfme // 搴撳瓨鎬绘暟锛堣繖涓槸姝e父鐨勶級
+ , totalWeight // 搴撳瓨鎬婚噸閲忥紙杩欎釜鏄甯哥殑锛�
+ , wrkDetl.getSpecs()
+ , wrkDetl.getSku()
+ , wrkDetl.getZpallet()
+ , wrkDetl.getModel()
+ , wrkDetl.getSupp()
+ , wrkDetl.getKpCstmrName()
+ , wrkDetl.getOrderNo()
+ , wrkDetl.getBatch()
+// , wrkDetl.getCstateid$()
+ ));
+ }
+ } else {
List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectTodayByWrkNo(wrkNo);
- if(!wrkDetlLogs.isEmpty()) {
- WrkDetlLog wrkDetlLog = wrkDetlLogs.get(0);
-
- double anfme = 0D;
- double weight = 0D;
- for (WrkDetlLog detl : wrkDetlLogs) {
- anfme += detl.getAnfme();
- weight += detl.getWeight();
- wrkDetlLog.setAnfme(anfme);
- wrkDetlLog.setWeight(weight);
- }
-
+ if (!wrkDetlLogs.isEmpty()) {
+ // 鑾峰彇搴撳瓨淇℃伅
List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
.eq("loc_no", sourceLocNo));
double totalAnfme = 0D;
@@ -724,29 +836,33 @@
totalAnfme += locDetl.getAnfme();
totalWeight += locDetl.getWeight();
}
- wrkDetlLog.setStockNum(totalAnfme);
- wrkDetlLog.setStockNum2(totalWeight);
- ledCommand.getMatDtos().add(new MatDto(
- wrkDetlLog.getMatnr()
- , wrkDetlLog.getMaktx()
- , wrkDetlLog.getAnfme()
- , wrkDetlLog.getWeight()
- , wrkDetlLog.getStockNum()
- , wrkDetlLog.getStockNum2()
- , wrkDetlLog.getSpecs()
- , wrkDetlLog.getSku()
- , wrkDetlLog.getZpallet()
- , wrkDetlLog.getModel()
- , wrkDetlLog.getSupp()
- , wrkDetlLog.getKpCstmrName()
- , wrkDetlLog.getOrderNo()
- , wrkDetlLog.getCstateid$()
- ));
+ // 涓烘瘡涓猈rkDetlLog鍒涘缓鐙珛鐨凪atDto
+ for (WrkDetlLog wrkDetlLog : wrkDetlLogs) {
+ // 娉ㄦ剰锛氳繖閲屼娇鐢ㄦ瘡涓獁rkDetlLog鐨勫師濮嬫暟鎹紝涓嶅悎骞�
+ ledCommand.getMatDtos().add(new MatDto(
+ wrkDetlLog.getMatnr()
+ , wrkDetlLog.getMaktx()
+ , wrkDetlLog.getAnfme() // 浣跨敤鍗曚釜鐗╂枡鐨勬暟閲忥紝涓嶇疮鍔�
+ , wrkDetlLog.getWeight() // 浣跨敤鍗曚釜鐗╂枡鐨勯噸閲忥紝涓嶇疮鍔�
+ , totalAnfme // 搴撳瓨鎬绘暟
+ , totalWeight // 搴撳瓨鎬婚噸閲�
+ , wrkDetlLog.getSpecs()
+ , wrkDetlLog.getSku()
+ , wrkDetlLog.getZpallet()
+ , wrkDetlLog.getModel()
+ , wrkDetlLog.getSupp()
+ , wrkDetlLog.getKpCstmrName()
+ , wrkDetlLog.getOrderNo()
+ , wrkDetlLog.getBatch()
+// , wrkDetlLog.getCstateid$()
+ ));
+ }
}
}
-
}
+ // 淇敼缁撴潫
+
commands.add(ledCommand);
}
Set<Integer> workNos = new HashSet<>(workNoList);
@@ -756,29 +872,11 @@
if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
continue;
}
-// 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
-// if (!commands.isEmpty()) {
-// if (led.getId() < 7) {
-// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
-// News.error(""+mark+" - 2"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
-// continue;
-// } else {
-// ledThread.setLedMk(false);
-// }
-// } else {
-// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
-// News.error(""+mark+" - 3"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
-// continue;
-// } else {
-// ledThread.setLedMk(false);
-// }
-// }
-//
-// }
+
// 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
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());
+ News.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触--->鍑哄簱锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
continue;
} else {
ledThread.setLedMk(false);
@@ -826,10 +924,14 @@
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
StaProtocol staProtocol = devpThread.getStation().get(staNo);
+ StaProtocol staProtocol1 = devpThread.getStation().get(122);
if (staProtocol == null) {
continue;
}
- if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) {
+ if (staProtocol1 == null) {
+ continue;
+ }
+ if ((staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) || (staProtocol1.getWorkNo() != 0 || staProtocol1.isLoading())) {
reset = false;
break;
}
@@ -840,7 +942,7 @@
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());
+ News.error("" + mark + " - 1" + " - {}鍙稬ED鍛戒护涓嬪彂澶辫触--->澶嶄綅锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
} else {
}
@@ -848,4 +950,144 @@
}
News.infoNoLog("" + mark + " - 0" + " - 鎵ц瀹屾垚锛氬叾浠� ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅");
}
-}
+
+ public void ledExecuteIn(Integer mark) {
+ for (LedSlave led : slaveProperties.getLed()) {
+ // 鍛戒护闆嗗悎
+ List<LedCommand> commands = new ArrayList<>();
+ List<Integer> workNoList = new ArrayList<>();
+
+ // 鍏ュ簱宸ヤ綔妗� - 杩欓噷鍙兘闇�瑕佹坊鍔犳洿澶氭煡璇㈡潯浠讹紝纭繚鍙幏鍙栬LED瀵瑰簲鐨勫伐浣滄。
+ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+ .eq("wrk_sts", 3)
+ .in("io_type", 1, 53, 54, 57)
+ // 鍙兘闇�瑕佹坊鍔燣ED鍏宠仈鏉′欢锛屼緥濡傜珯鐐圭紪鍙风瓑
+ );
+
+ if (wrkMast == null) {
+ continue; // 娌℃湁宸ヤ綔妗o紝缁х画澶勭悊涓嬩竴涓狶ED
+ }
+
+ Integer wrkNo = wrkMast.getWrkNo();
+ Integer ioType = wrkMast.getIoType();
+ String sourceLocNo = wrkMast.getSourceLocNo();
+ String locNo = wrkMast.getLocNo();
+ Integer targetStaNo = wrkMast.getStaNo();
+ String barcode = wrkMast.getBarcode();
+
+ workNoList.add(wrkNo);
+
+ // 缁勮鍛戒护
+ LedCommand ledCommand = new LedCommand();
+ ledCommand.setWorkNo(wrkNo);
+ ledCommand.setIoType(ioType);
+
+ // 鍏ュ簱妯″紡 - 淇浜哻ase 54鍜�57鐨勬弿杩�
+ switch (ioType) {
+ case 1:
+ ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
+ break;
+ case 53:
+ ledCommand.setTitle("鎷f枡鍏ュ簱");
+ break;
+ case 54:
+ ledCommand.setTitle("骞舵澘鍏ュ簱"); // 淇锛氬簲璇ユ槸骞舵澘鍏ュ簱锛屼笉鏄洏鐐瑰叆搴�
+ break;
+ case 57:
+ ledCommand.setTitle("鐩樼偣鍏ュ簱"); // 淇锛氬簲璇ユ槸鐩樼偣鍏ュ簱锛屼笉鏄苟鏉垮叆搴�
+ break;
+ default:
+ // 鍙�夌殑閿欒澶勭悊
+ continue; // 璺宠繃涓嶆敮鎸佺殑ioType
+ }
+
+ ledCommand.setSourceLocNo(sourceLocNo);
+ ledCommand.setLocNo(locNo);
+ ledCommand.setStaNo(targetStaNo);
+ ledCommand.setBarcode(barcode);
+
+ List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkNo);
+
+ // 鍗充娇wrkDetls涓虹┖锛屼篃搴旇澶勭悊LED鍛戒护锛堝彲鑳芥煇浜涘叆搴撶被鍨嬩笉闇�瑕佺墿鏂欐槑缁嗭級
+ if (!wrkDetls.isEmpty()) {
+ // 鑾峰彇搴撳瓨淇℃伅
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("loc_no", sourceLocNo)); // 浣跨敤sourceLocNo鑰屼笉鏄痺rkMast.getSourceLocNo()
+ double totalAnfme = 0D;
+ double totalWeight = 0D;
+ for (LocDetl locDetl : locDetls) {
+ totalAnfme += locDetl.getAnfme();
+ totalWeight += locDetl.getWeight(); // 濡傛灉鏁版嵁搴撴湁weight瀛楁锛屽簲璇ュ姞涓�
+ }
+
+ // 涓烘瘡涓猈rkDetl鍒涘缓鐙珛鐨凪atDto
+ for (WrkDetl wrkDetl : wrkDetls) {
+ ledCommand.getMatDtos().add(new MatDto(
+ wrkDetl.getMatnr(),
+ wrkDetl.getMaktx(),
+ wrkDetl.getAnfme(), // 浣跨敤鍗曚釜鐗╂枡鐨勬暟閲�
+ wrkDetl.getWeight(), // 浣跨敤鍗曚釜鐗╂枡鐨勯噸閲�
+ totalAnfme, // 搴撳瓨鎬绘暟
+ totalWeight, // 搴撳瓨鎬婚噸閲�
+ wrkDetl.getSpecs(),
+ wrkDetl.getSku(),
+ wrkDetl.getZpallet(),
+ wrkDetl.getModel(),
+ wrkDetl.getSupp(),
+ wrkDetl.getKpCstmrName(),
+ wrkDetl.getOrderNo(),
+ wrkDetl.getBatch()
+ ));
+ }
+ }
+
+ // 鍗充娇娌℃湁鐗╂枡鏄庣粏锛屼篃搴旇娣诲姞LED鍛戒护锛堟煇浜涘叆搴撶被鍨嬪彲鑳戒笉闇�瑕佹樉绀虹墿鏂欙級
+ commands.add(ledCommand);
+
+ Set<Integer> workNos = new HashSet<>(workNoList);
+ // 鑾峰彇LED绾跨▼
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
+
+ if (ledThread == null) {
+ News.error("鏈壘鍒癓ED绾跨▼锛歔id锛歿}]", led.getId());
+ continue;
+ }
+
+ // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
+ 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鏍囪
+ // 娉ㄦ剰锛氳繖閲屽彧闇�瑕佹洿鏂板綋鍓嶅伐浣滄。锛屼笉闇�瑕佸惊鐜�
+ WrkMast wrkMastToUpdate = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkNo));
+ if (wrkMastToUpdate != null) {
+ wrkMastToUpdate.setOveMk("Y");
+ wrkMastToUpdate.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMastToUpdate) == 0) {
+ News.errorNoLog("" + mark + " - 4" + " - 鏇存柊宸ヤ綔妗eけ璐�");
+ throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
+ }
+ }
+
+ // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚�
+ ledThread.setWorkNos(workNos);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1