From 82344895b44d1fad95bfe3bfa81bbc74a4dc66a6 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期一, 17 十一月 2025 09:20:14 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 1586 ++++++++++++++++-----------------------------------------
1 files changed, 457 insertions(+), 1,129 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 cda7462..0006e50 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -6,7 +6,6 @@
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;
@@ -50,10 +49,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -62,7 +58,6 @@
*/
@Slf4j
@Service("mainService")
-@Transactional
public class MainServiceImpl {
public static final long COMMAND_TIMEOUT = 5 * 1000;
@@ -74,7 +69,11 @@
@Autowired
private WrkMastMapper wrkMastMapper;
@Autowired
+ private WrkMastLogService wrkMastLogService;
+ @Autowired
private WrkDetlService wrkDetlService;
+ @Autowired
+ private WrkDetlLogService wrkDetlLogService;
@Autowired
private WaitPakinMapper waitPakinMapper;
@Autowired
@@ -93,8 +92,6 @@
private BasCrnErrorMapper basCrnErrorMapper;
@Autowired
private WrkMastService wrkMastService;
- @Autowired
- private WrkMastLogService wrkMastLogService;
@Autowired
private ConfigService configService;
@Autowired
@@ -200,14 +197,14 @@
continue;
}
- if (inSta.getStaNo() == 1005) {
+ 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, 1007)
+ .in("sta_no", 1003, 1004)
);
if (!wrkMasts.isEmpty()) {
- News.error("" + mark + " - 4" + " - 1003绔欏叆搴擄紝妫�娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode);
+ News.error("" + mark + " - 4" + " - 鍏ュ簱锛屾娴嬪瓨鍦ㄥ嚭搴撲换鍔★紝绛夊緟鍑哄簱浠诲姟鎵ц瀹屾垚,鎵樼洏鐮�={}", barcode);
continue;
}
}
@@ -234,6 +231,12 @@
.eq("loc_no", dto.getLocNo()));
short staNo = dto.getStaNo().shortValue();
+
+ int sourceStaNo = dto.getSourceStaNo();
+ if (sourceStaNo == 1007) {
+ staNo = 2002;
+ }
+
if (inSta.getStaNo() == 1002) {
staNo = 2002;
}
@@ -365,24 +368,25 @@
* 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱
*/
public synchronized void stnToCrnStnPick(Integer mark) {
- for (DevpSlave devp : slaveProperties.getDevp()) {
- // 閬嶅巻鎷f枡鍏ュ簱鍙�
- for (DevpSlave.Sta pickSta : devp.getPickSta()) {
- // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
- SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
- if (staProtocol == null) {
- continue;
- } else {
- staProtocol = staProtocol.clone();
- }
+ try {
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 閬嶅巻鎷f枡鍏ュ簱鍙�
+ for (DevpSlave.Sta pickSta : devp.getPickSta()) {
+ // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
+ SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(pickSta.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" + " - 寮�濮嬫墽琛�");
+ if (staProtocol.isAutoing()
+ && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && staProtocol.getWorkNo() > 0
+ && staProtocol.isPakMk()) {
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�");
// // 鑾峰彇鏉$爜鎵弿浠俊鎭�
// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
@@ -400,106 +404,116 @@
// }
// WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
- WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
- if (wrkMast == null) {
- // 鏃犳嫞鏂欐暟鎹�
- continue;
- }
- if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
- || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) {
- continue;
- }
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
+ if (wrkMast == null) {
+ // 鏃犳嫞鏂欐暟鎹�
+ 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", pickSta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
- .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿
- StaDesc staDesc = staDescService.selectOne(wrapper);
- if (Cools.isEmpty(staDesc)) {
+ if (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57) {
+ if (wrkMast.getWrkSts() != 2) {
+ News.error("" + mark + " - 3" + " - 鎷i�夌洏鐐瑰洖搴撳伐浣滄。鐘舵�佸紓甯革紒锛侊紒 [plc缂栧彿锛歿}]", devp.getId());
+ 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());
+ }
+ 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>()
+ .eq("type_no", wrkMast.getIoType() - 50)
+ .eq("stn_no", pickSta.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, pickSta.getLed());
- // led 寮傚父鏄剧ず
- if (ledThread != null) {
- String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + pickSta.getBackSta().shortValue() + "绔欑偣";
- MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg));
+ //LED
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + pickSta.getBackSta().shortValue() + "绔欑偣";
+ MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg));
+ }
+ continue;
}
- continue;
+
+ try {
+ LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(wrkMast.getBarcode());
+ param.setSourceStaNo(pickSta.getStaNo());
+ param.setLocType1(locTypeDto.getLocType1());
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/rpc/pakin/pick/loc/v1")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(200)) {
+ WrkMast newWrkMast = wrkMastMapper.selectPakInStepBarcode(wrkMast.getBarcode());
+ if (newWrkMast == null) {
+ // 鏃犳嫞鏂欐暟鎹�
+ News.error("" + mark + " - 3" + " - 鎷i�夌洏鐐瑰洖搴撹幏鍙栧伐浣滄。澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ continue;
+ }
+
+ if(newWrkMast.getWrkSts() != 53 && newWrkMast.getWrkSts() != 57) {
+ News.error("" + mark + " - 3" + " - 鎷i�夌洏鐐瑰洖搴撳伐浣滄。绫诲瀷寮傚父锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ continue;
+ }
+
+ if (wrkMast.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));
+ if (!result) {
+ News.error("" + mark + " - 3" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ }
+ } else {
+ News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/pick/loc/v1", JSON.toJSONString(param), response);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable()
+ + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk());
}
-
- 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());
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
}
News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
@@ -508,51 +522,52 @@
* 鎷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) {
+ try {
+ 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();
}
- String barcode = barcodeThread.getBarcode();
- if (!Cools.isEmpty(barcode)) {
- News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", insta.getBarcode(), barcode);
- if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+
+ 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;
}
- } else {
- 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;
- }
+ 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�佺洏銆佸苟 浣滀笟绔欒浆鎹�
+ // 鎷c�佺洏銆佸苟 浣滀笟绔欒浆鎹�
// int stnNo = 0;
// if (wrkMast.getStaNo() == 109) {
// stnNo = 127;
@@ -561,87 +576,90 @@
// } 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)) {
+ // 鑾峰彇鐩爣绔�
+ 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け璐�");
+ //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;
}
- 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暟鎹姸鎬佸け璐�");
+ 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;
}
- // 鏇存柊鏄庣粏妗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("淇敼搴撲綅鐘舵�佸け璐�");
+ // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂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());
}
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- continue;
+
+ } else {
+ News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable()
+ + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk());
}
- 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());
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
}
News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
@@ -684,7 +702,7 @@
staProtocol = staProtocol.clone();
}
- if (staProtocol.isAutoing() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
+ if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
@@ -697,9 +715,14 @@
LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
.eq("loc_no", wrkMast.getSourceLocNo()));
+ short staNo = wrkMast.getStaNo().shortValue();
+ if (wrkMast.getStaNo() == 1004) {
+ staNo = 2003;
+ }
+
// 涓嬪彂绔欑偣淇℃伅
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
- staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
+ staProtocol.setStaNo(staNo);
staProtocol.setPalletSize(locMast.getLocType2());
if (!MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol))) {
continue;
@@ -743,6 +766,12 @@
// continue;
// }
+ //鍫嗗灈鏈哄洖鍘熺偣浠诲姟涓�
+ Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId());
+ if (object != null) {
+ continue;
+ }
+
// 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛�
if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
&& crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
@@ -778,150 +807,6 @@
}
News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂鎵ц瀹屾垚");
- }
-
- /**
- * 鍫嗗灈鏈烘棤浠诲姟涓ゅ垎閽燂紝鍥炲叆搴撳彛寰呮満
- */
- public synchronized void crnMove() {
- 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 * 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();
- }
- }
- }
- }
-
- /**
- * 鍫嗗灈鏈烘湁鍏ュ簱浠诲姟鏃讹紝鍥炲叆搴撳彛寰呮満
- */
- 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();
- }
- }
- }
}
/**
@@ -1027,7 +912,7 @@
News.warn("" + mark + " - 1" + " - 12" + " - // F銆丏 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
// 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) {
- if (moveLocForDeepLoc(slave, shallowLoc, mark)) {
+ if (moveLocForDeepLoc(slave, crnProtocol, shallowLoc, mark)) {
wrkMast.setUpdMk("Y");
wrkMast.setIoPri(14D);
wrkMastMapper.updateById(wrkMast);
@@ -1115,6 +1000,13 @@
devpCheckTaskStackOver = Integer.parseInt(config2.getValue());
}
+ int outNumber = 13;
+ Config config3 = configService.selectOne(new EntityWrapper<Config>()
+ .eq("code", "fullBoardOutboundNumber"));
+ if (config3 != null) {
+ outNumber = Integer.parseInt(config3.getValue());
+ }
+
Integer devpWorkingCount = commonService.queryDevpWorkingCount();
if (devpWorkingCount > devpTaskStackOver) {
@@ -1152,11 +1044,12 @@
staProtocol = staProtocol.clone();
}
- if (wrkMast.getStaNo() == 1003 || wrkMast.getStaNo() == 1007) {
+ if (wrkMast.getStaNo() == 1003 || wrkMast.getStaNo() == 1007 || wrkMast.getStaNo() == 1004) {
//妫�娴嬫槸鍚︽湁鍏ュ簱浠诲姟
List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
.in("io_type", 1, 53, 57)
- .in("source_sta_no", 1005)
+ .notIn("wrk_sts", 3, 4, 5)
+ .in("source_sta_no", 1002, 1007)
);
if (!inWrkMasts.isEmpty()) {
News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦ㄥ叆搴撲换鍔★紝绛夊緟鍏ュ簱浠诲姟鎵ц瀹屾垚鍐嶅嚭搴擄紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo());
@@ -1185,6 +1078,14 @@
continue;
}
}
+ }else if (wrkMast.getIoType() == 101) {
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("wrk_sts", 12, 14)
+ );
+ if (!Cools.isEmpty(inWrkMasts) && inWrkMasts.size() >= outNumber) {
+ News.error("" + mark + " - 4" + " - 妫�娴嬪埌鍏ㄦ澘鍑哄簱鐨勪换鍔″凡缁忓埌杈句笂绾匡紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo());
+ continue;
+ }
}
// // 鍏ュ嚭搴撴ā寮忓垽鏂�
@@ -1202,8 +1103,7 @@
// continue;
}
// 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
- if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
- && staProtocol.getWorkNo() == 0) {
+ if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) {
//鏍规嵁鍙傛暟鍒ゆ柇鏄惁鏍¢獙鍙嚭淇″彿
String crnOutVerifyOut = "Y";
@@ -1215,6 +1115,10 @@
if (crnOutVerifyOut.equals("Y")) {
if (!staProtocol.isOutEnable()) {
+ continue;
+ }
+
+ if (staProtocol.getWorkNo() > 0) {
continue;
}
}
@@ -1229,12 +1133,22 @@
}
if (crnProtocol.getCrnNo() == 1) {
- //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬�
- if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) {
- //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц
- List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false);
- if (!currentWrkMasts.isEmpty()) {
- continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔�
+ String turnCrnExecuteCurrentChannel = "Y";
+ Config turnCrnExecuteCurrentChannelConfig = configService.selectOne(new EntityWrapper<Config>()
+ .eq("code", "turnCrnExecuteCurrentChannel")
+ );
+ if (turnCrnExecuteCurrentChannelConfig != null) {
+ turnCrnExecuteCurrentChannel = turnCrnExecuteCurrentChannelConfig.getValue();
+ }
+
+ if (turnCrnExecuteCurrentChannel.equals("Y")) {
+ //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬�
+ if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) {
+ //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц
+ List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false);
+ if (!currentWrkMasts.isEmpty()) {
+ continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔�
+ }
}
}
}
@@ -1271,7 +1185,7 @@
// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())
// || Cools.isEmpty(waitWrkMast)) {
if (Cools.isEmpty(waitWrkMast)) {
- if (moveLocForDeepLoc(slave, shallowLoc, mark)) {
+ if (moveLocForDeepLoc(slave, crnProtocol, shallowLoc, mark)) {
wrkMast.setUpdMk("Y");
// wrkMast.setIoPri(14D);
wrkMastMapper.updateById(wrkMast);
@@ -1520,6 +1434,7 @@
if (wrkMastMapper.updateById(wrkMast) == 0) {
News.error("" + mark + " - 3" + " - 5" + " - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
}
+ crnProtocol.setLastIo("I");
}
News.infoNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�");
@@ -1625,6 +1540,7 @@
if (crnProtocol.getTaskNo() == 9999) {
// 鍫嗗灈鏈哄浣�
crnThread.setResetFlag(true);
+ redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 8);//闃叉鍥炲師鐐瑰悗涓嬪彂鎸囦护杩囧揩
continue;
}
@@ -1636,7 +1552,7 @@
}
Date now = new Date();
- if(wrkMast.getIoType() < 100){
+ if (wrkMast.getIoType() < 100) {
// 鍏ュ簱 + 搴撲綅杞Щ ==> 4.鍏ュ簱瀹屾垚
if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111))) {
wrkMast.setWrkSts(4L);
@@ -1652,7 +1568,7 @@
News.warnNoLog("" + mark + " - 2" + " - 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 : 鍫嗗灈鏈哄彿={}", crnThread.getCrnProtocol().getCrnNo());
crnThread.setResetFlag(true);
}
- }else {
+ } else {
List<Long> list = new ArrayList<>();
list.add(14L);
list.add(15L);
@@ -1795,230 +1711,6 @@
News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈哄紓甯镐俊鎭褰曟墽琛屽畬鎴�");
}
-
- // -------------------------------------------------------------------------------
-
- /**
- * 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�
- */
- public synchronized void storeEmptyPlt(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() == 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);
-
- SearchLocParam param = new SearchLocParam();
- 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")
- .setJson(JSON.toJSONString(param))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
- StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo(dto.getWorkNo().shortValue());
- staProtocol.setStaNo(dto.getStaNo().shortValue());
- 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 {
- if (ledThread != null) {
- String errorMsg = jsonObject.getString("msg");
- if (!Cools.isEmpty(errorMsg)) {
- MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg));
- }
- }
- News.error("" + mark + " - 3" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- } 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()
- + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk());
- }
- }
- }
- News.infoNoLog("" + mark + " - 0" + " - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�");
- }
-
/**
* 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�
*/
@@ -2029,8 +1721,9 @@
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
// 鍛戒护闆嗗悎
List<LedCommand> commands = new ArrayList<>();
- // 宸ヤ綔妗i泦鍚�
- List<WrkMast> wrkMasts = new ArrayList<>();
+// // 宸ヤ綔妗i泦鍚�
+// List<WrkMast> wrkMasts = new ArrayList<>();
+ List<Integer> workNoList = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
StaProtocol staProtocol = devpThread.getStation().get(staNo);
@@ -2039,20 +1732,48 @@
} else {
staProtocol = staProtocol.clone();
}
+ Integer wrkNo = null;
+ Integer ioType = null;
+ Integer targetStaNo = null;
+ String sourceLocNo = null;
+ String locNo = null;
+ String barcode = null;
+
// 鑾峰彇宸ヤ綔妗f暟鎹�
WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
// if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
if (null == wrkMast) {
- continue;
+ List<WrkMastLog> wrkMastLogs = wrkMastLogService.selectList(new EntityWrapper<WrkMastLog>()
+ .eq("wrk_no", staProtocol.getWorkNo())
+ .orderBy("modi_time", false)
+ );
+ if (wrkMastLogs.isEmpty()) {
+ continue;
+ }
+
+ WrkMastLog wrkMastLog = wrkMastLogs.get(0);
+ wrkNo = wrkMastLog.getWrkNo();
+ ioType = wrkMastLog.getIoType();
+ sourceLocNo = wrkMastLog.getSourceLocNo();
+ locNo = wrkMastLog.getLocNo();
+ targetStaNo = wrkMastLog.getStaNo();
+ barcode = wrkMastLog.getBarcode();
+ }else {
+ wrkNo = wrkMast.getWrkNo();
+ ioType = wrkMast.getIoType();
+ sourceLocNo = wrkMast.getSourceLocNo();
+ locNo = wrkMast.getLocNo();
+ targetStaNo = wrkMast.getStaNo();
+ barcode = wrkMast.getBarcode();
}
News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�:鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�");
- wrkMasts.add(wrkMast);
+ workNoList.add(wrkNo);
// 缁勮鍛戒护
LedCommand ledCommand = new LedCommand();
- ledCommand.setWorkNo(wrkMast.getWrkNo());
- ledCommand.setIoType(wrkMast.getIoType());
+ ledCommand.setWorkNo(wrkNo);
+ ledCommand.setIoType(ioType);
// 鍑哄簱妯″紡
- switch (wrkMast.getIoType()) {
+ switch (ioType) {
case 1:
ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
break;
@@ -2085,50 +1806,104 @@
ledCommand.setTitle("骞舵澘鍏ュ簱");
break;
default:
- News.error("" + mark + " - 1" + " - 浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
+ News.error("" + mark + " - 1" + " - 浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkNo, ioType);
break;
}
- ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
- ledCommand.setLocNo(wrkMast.getLocNo());
- ledCommand.setStaNo(wrkMast.getStaNo());
- ledCommand.setBarcode(wrkMast.getBarcode());
+ ledCommand.setSourceLocNo(sourceLocNo);
+ ledCommand.setLocNo(locNo);
+ ledCommand.setStaNo(targetStaNo);
+ ledCommand.setBarcode(barcode);
// 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.getStockNum()
- , wrkDetl.getStockNum2()
- , wrkDetl.getSpecs()
- , wrkDetl.getSku()
- , wrkDetl.getZpallet()
- , wrkDetl.getModel()
- , wrkDetl.getSupp()
- , wrkDetl.getKpCstmrName()
- , wrkDetl.getOrderNo()
- , wrkDetl.getCstateid$()
- )));
+ 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();
+ }
+ 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 {
+ 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);
+ }
+
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("loc_no", sourceLocNo));
+ double totalAnfme = 0D;
+ double totalWeight = 0D;
+ for (LocDetl locDetl : locDetls) {
+ 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$()
+ ));
+ }
+ }
+
}
commands.add(ledCommand);
}
- Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
+ Set<Integer> workNos = new HashSet<>(workNoList);
// 鑾峰彇LED绾跨▼
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
// 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
@@ -2166,12 +1941,15 @@
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け璐�");
+ for (Integer wrkNo : workNoList) {
+ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkNo));
+ if (wrkMast != null) {
+ wrkMast.setOveMk("Y");
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ News.errorNoLog("" + mark + " - 4" + " - 鏇存柊宸ヤ綔妗eけ璐�");
+ throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
+ }
}
}
@@ -2306,8 +2084,7 @@
* 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)
* tip锛氬悓姝�
*/
- private synchronized boolean moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc, Integer mark) {
-
+ private synchronized boolean moveLocForDeepLoc(CrnSlave crn, CrnProtocol crnProtocol, LocMast shallowLoc, Integer mark) {
try {
News.warnNoLog("" + mark + "moveLocForDeepLoc" + " - 0" + " - 寮�濮嬫墽琛�:鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)");
List<Integer> rows = locMastService.queryDistinctRow(crn.getId());
@@ -2315,8 +2092,13 @@
for (Integer row : rows) {
if (Utils.isDeepLoc(slaveProperties, row)) {
loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1());
-
if (loc != null) {
+ if (crn.getId() == 1) {
+ if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) {
+ continue;
+ }
+ }
+
if (Utils.isDeepLoc(slaveProperties, loc.getLocNo())) {
String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo());
LocMast shallowLoc1 = locMastService.selectById(shallowLocNo);
@@ -2336,6 +2118,12 @@
loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1());
if (null != loc) {//瀵瑰簲娣卞簱浣嶉潪鍦ㄥ簱鐘舵��,涓嶈兘绉诲簱
+ if (crn.getId() == 1) {
+ if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) {
+ continue;
+ }
+ }
+
String deepLoc = Utils.getDeepLoc(slaveProperties, loc.getLocNo());
LocMast deepLoc1 = locMastService.selectById(deepLoc);
if (!deepLoc1.getLocSts().equals("F") && !deepLoc1.getLocSts().equals("D")) {
@@ -2355,6 +2143,15 @@
return false;
// throw new CoolException("鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo());
} else {
+ String deepLoc2 = Utils.getDeepLoc2(slaveProperties, loc.getLocNo());
+ if (deepLoc2 != null) {
+ LocMast locnew = locMastService.selectById(deepLoc2);
+ if (locnew != null && locnew.getLocSts().equals("O")) {
+ loc = locnew;
+ }
+ }
+
+
try {
// 鑾峰彇宸ヤ綔鍙�
int workNo = commonService.getWorkNo(0);
@@ -2445,473 +2242,4 @@
return true;
}
- /**
- * 鍫嗗灈鏈烘紨绀� ===>> 搴撲綅绉昏浆
- */
- public synchronized void crnDemoOfLocMove1() {
- try {
- for (CrnSlave crn : slaveProperties.getCrn()) {
- if (!crn.getDemo()) {
- continue;
- } // 蹇呴』涓烘紨绀虹姸鎬�
-
- CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
- CrnProtocol crnProtocol = crnThread.getCrnProtocol();
- if (crnProtocol == null) {
- continue;
- }
-
- // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛�
- if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) {
- // 鑾峰彇绉诲簱宸ヤ綔妗d俊鎭�
- WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId());
- if (null != wrkMast) {
- continue;
- }
-
- 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;
- }
-
- String sourceLocNo = sourceLoc.getLocNo();
- String locNo = loc.getLocNo();
-
- // 鑾峰彇宸ヤ綔鍙�
- int workNo = commonService.getWorkNo(0);
- // 淇濆瓨宸ヤ綔妗�
- wrkMast = new WrkMast();
- wrkMast.setWrkNo(workNo);
- wrkMast.setIoTime(new Date());
- wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
- wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
- wrkMast.setIoPri(13D);
- wrkMast.setCrnNo(crn.getId());
- wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣�
- wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
- wrkMast.setFullPlt("N"); // 婊℃澘锛歒
- wrkMast.setPicking("N"); // 鎷f枡
- wrkMast.setExitMk("N"); // 閫�鍑�
- wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘
- wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮�
- wrkMast.setLinkMis("N");
- wrkMast.setAppeTime(new Date());
- wrkMast.setModiTime(new Date());
- int res = wrkMastMapper.insert(wrkMast);
- if (res == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
- }
- // 宸ヤ綔妗f槑缁嗕繚瀛�
-// List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
-// for (LocDetl locDetl : locDetls) {
-// WrkDetl wrkDetl = new WrkDetl();
-// wrkDetl.setWrkNo(workNo);
-// wrkDetl.setIoTime(new Date());
-// wrkDetl.setAnfme(locDetl.getAnfme());
-// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗
-// wrkDetl.setAppeTime(new Date());
-// wrkDetl.setModiTime(new Date());
-// if (!wrkDetlService.insert(wrkDetl)) {
-// throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
-// }
-// }
- // 淇敼婧愬簱浣嶇姸鎬�
- if (sourceLoc.getLocSts().equals("D")) {
- sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害
- sourceLoc.setModiTime(new Date());
- if (!locMastService.updateById(sourceLoc)) {
- throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
- }
- } else {
- throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�");
- }
- // 淇敼鐩爣搴撲綅鐘舵��
- if (loc.getLocSts().equals("O")) {
- loc.setLocSts("S"); // S.鍏ュ簱棰勭害
- loc.setCtnType(1);
- loc.setModiTime(new Date());
- if (!locMastService.updateById(loc)) {
- throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
- }
- } else {
- throw new CoolException("绉昏浆澶辫触");
- }
-
- }
- }
- } catch (Exception e) {
- News.error("鍫嗗灈鏈烘紨绀� ===>> 搴撲綅绉昏浆澶辫触", e);
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- }
-
- /**
- * 鍫嗗灈鏈哄懡浠や笅鍙戝悗锛屽紓姝ヤ慨鏀瑰伐浣滄。鐘舵��
- */
- 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) {
- News.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) {
- News.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
- }
- News.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo());
- }
- // 鍑哄簱銆佺Щ搴�
- if (wrkMast.getWrkSts() == 11) {
- News.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) {
- News.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
- }
- News.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo());
- }
-
-
- }
-
- }
- }
-
- // 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;
- }
-
- 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;
- }
-
- 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);
-
- wrkMastService.delete(new EntityWrapper<WrkMast>()
- .eq("wrk_no", wrkMast.getWrkNo()));
- }
- }
- }
- News.infoNoLog("" + mark + " - 0" + " - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�");
- }
-
-// /**
-// * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁�
-// */
-// 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