From 3c0129480a0493bd87bf38273b23eae3099c3f3d Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 21 十月 2025 15:03:39 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 3042 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 2,602 insertions(+), 440 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 14e9a7c..c525150 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1,46 +1,55 @@
package com.zy.asrs.service.impl;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
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;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.CollectionUtils;
+import com.zy.common.utils.HttpHandler;
+import com.zy.common.utils.News;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.CrnThread;
+import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
-import com.zy.core.model.CrnSlave;
-import com.zy.core.model.DevpSlave;
-import com.zy.core.model.LedSlave;
-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.command.RgvCommand;
import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
-import com.zy.core.thread.CrnThread;
-import com.zy.core.thread.DevpThread;
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.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.scheduling.annotation.Async;
+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.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -49,29 +58,9 @@
*/
@Slf4j
@Service("mainService")
-@Transactional
public class MainServiceImpl {
- @Autowired
- private RowLastnoService rowLastnoService;
-
- public void test(){
- try {
- // 宸ヤ綔鍙�
- int workNo = commonService.getWorkNo(0);
- System.out.println(workNo);
- if (workNo > 0) {
- throw new CoolException("21321");
- }
- RowLastno rowLastno = rowLastnoService.selectById(1);
- rowLastno.setCurrentRow(rowLastno.getCurrentRow() + 1);
- rowLastnoService.updateById(rowLastno);
- System.out.println(rowLastno.getCurrentRow());
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- }
+ public static final long COMMAND_TIMEOUT = 5 * 1000;
@Autowired
private CommonService commonService;
@@ -80,7 +69,11 @@
@Autowired
private WrkMastMapper wrkMastMapper;
@Autowired
+ private WrkMastLogService wrkMastLogService;
+ @Autowired
private WrkDetlService wrkDetlService;
+ @Autowired
+ private WrkDetlLogService wrkDetlLogService;
@Autowired
private WaitPakinMapper waitPakinMapper;
@Autowired
@@ -92,117 +85,218 @@
@Autowired
private BasDevpService basDevpService;
@Autowired
- private JdbcTemplate jdbcTemplate;
+ private LocDetlService locDetlService;
+ @Autowired
+ private BasErrLogService basErrLogService;
+ @Autowired
+ private BasCrnErrorMapper basCrnErrorMapper;
+ @Autowired
+ private WrkMastService wrkMastService;
+ @Autowired
+ private ConfigService configService;
+ @Autowired
+ private RedisUtil redisUtil;
+
+ @Value("${wms.url}")
+ private String wmsUrl;
/**
* 缁勬墭
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
*/
- @Async
- public void generateStoreWrkFile() {
+ public synchronized void generateStoreWrkFile(Integer mark) {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
for (DevpSlave devp : slaveProperties.getDevp()) {
// 閬嶅巻鍏ュ簱鍙�
for (DevpSlave.Sta inSta : devp.getInSta()) {
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
- String barcode = barcodeThread.getBarcode();
- if(!Cools.isEmpty(barcode)) {
- System.err.println(barcode);
- }
- // 鑾峰彇鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()).clone();
- if (staProtocol == null) {
+ if (barcodeThread == null) {
continue;
}
+
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+
+ //LED
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+
// 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
- if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
- && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 0
- && staProtocol.isPakMk() && !Cools.isEmpty(barcode)) {
- // 鍒ゆ柇閲嶅宸ヤ綔妗�
- WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
- if (wrkMast != null) {
- log.error("宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+ if (!staProtocol.isLoading()) {
+ continue;
+ }
+
+ if (staProtocol.isAutoing()
+ && staProtocol.isInEnable()
+ && !staProtocol.isEmptyMk()
+ && staProtocol.getWorkNo() == 9999
+ && staProtocol.isPakMk() && (staProtocol.getEmptyInType() != 1 && staProtocol.getEmptyInType() != 2)) {
+ 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));
+ News.info("" + mark + " - 2" + " - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo());
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+ }
+ 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) {
+ String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+ }
continue;
}
- // 鑾峰彇鍏ュ簱閫氱煡妗�
- List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N"));
- if (waitPakins.isEmpty()) {
- log.error("鏃犳鍏ュ簱鏉$爜鏁版嵁銆傛潯鐮佸彿={}", barcode);
+
+ // 鍒ゆ柇閲嶅宸ヤ綔妗�
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
+ //杩囨护鍒ゆ柇锛岄槻姝㈡嫞鏂欏啀鍏ュ簱璐х墿锛岀粡杩囧叆搴撶珯鍐嶅叆搴撴椂锛岃閫�鍥炲埌閫�搴撶珯
+ WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode);
+ if (wrkMast1 != null) {
+ if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104) {
+ 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绔欑偣淇℃伅澶辫触");
+// }
+
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode;
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+ }
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;
+ }
}
try {
- // 宸ヤ綔鍙�
- int workNo = commonService.getWorkNo(0);
- // 妫�绱㈠簱浣�
- List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList());
- StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos);
- // 鎻掑叆宸ヤ綔鏄庣粏妗�
- wrkDetlService.createWorkDetail(workNo, waitPakins, barcode);
+ LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
- // 鎻掑叆宸ヤ綔涓绘。
- wrkMast = new WrkMast();
- wrkMast.setWrkNo(workNo);
- wrkMast.setIoTime(new Date());
- wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋
- wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱
- wrkMast.setIoPri(10D); // 浼樺厛绾э細10
- wrkMast.setCrnNo(startupDto.getCrnNo());
- wrkMast.setSourceStaNo(startupDto.getSourceStaNo());
- wrkMast.setStaNo(startupDto.getStaNo());
- wrkMast.setLocNo(startupDto.getLocNo());
- wrkMast.setBarcode(barcode); // 鎵樼洏鐮�
- wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
- wrkMast.setPicking("N"); // 鎷f枡
- wrkMast.setExitMk("N"); // 閫�鍑�
- wrkMast.setEmptyMk("N"); // 绌烘澘
- wrkMast.setLinkMis("N");
-// wrkMast.setCtnType(sourceStaNo.getCtnType()); // 瀹瑰櫒绫诲瀷
- // 鎿嶄綔浜哄憳鏁版嵁
- wrkMast.setAppeTime(new Date());
- wrkMast.setModiTime(new Date());
- Integer insert = wrkMastMapper.insert(wrkMast);
- if (insert == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(barcode);
+ param.setIoType(1);
+ param.setSourceStaNo(inSta.getStaNo());
+ param.setLocType1(locTypeDto.getLocType1());
+ 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);
+
+ 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;
+ }
+
+ if (inSta.getStaNo() == 1002) {
+ staNo = 2002;
+ }
+
+ 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));
+ 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();
+// }
+ } 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));
+ }
}
- // 鏇存柊鐩爣搴撲綅鐘舵��
- LocMast locMast = locMastService.selectById(startupDto.getLocNo());
- locMast.setLocSts("S"); // S.鍏ュ簱棰勭害
- locMast.setModiTime(new Date());
- if (!locMastService.updateById(locMast)){
- throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
- }
- // 灏嗗叆搴撻�氱煡妗d慨鏀逛负宸插惎鍔�
- if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) {
- throw new CoolException("淇敼鍏ュ簱閫氱煡妗g姸鎬佷负宸插惎鍔ㄥけ璐�");
- }
-
- // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
-
-
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- barcodeThread.setBarcode("");
- staProtocol.setWorkNo((short) workNo);
- staProtocol.setStaNo(startupDto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
- }
-
-
} catch (Exception e) {
+ e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
+ } else {
+ News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isAutoing() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable()
+ + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo()
+ + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk());
}
-
}
}
+ News.infoNoLog("" + mark + " - 0" + " - 缁勬墭 ===銆嬫墽琛屽畬鎴�");
}
@@ -210,23 +304,36 @@
* wms鍏ュ簱
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 1 ==>> 2
*/
- @Async
- public void generateStoreWrkFile0() {
+ public synchronized void generateStoreWrkFile0(Integer mark) {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
for (DevpSlave devp : slaveProperties.getDevp()) {
// 閬嶅巻鍏ュ簱鍙�
for (DevpSlave.Sta inSta : devp.getInSta()) {
// 鑾峰彇鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()).clone();
- if (staProtocol == null) { continue; }
+ 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.isEmptyMk() && staProtocol.getWorkNo() == 0
+ if (!staProtocol.isLoading()) {
+ continue;
+ }
+
+ if (staProtocol.isAutoing()
+ && staProtocol.isInEnable()
+ && !staProtocol.isEmptyMk()
+ && staProtocol.getWorkNo() > 0
&& staProtocol.isPakMk()) {
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�");
// 鍒ゆ柇閲嶅宸ヤ綔妗�
WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
- if (wrkMast == null) { continue; }
+ if (wrkMast == null) {
+ continue;
+ }
// 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
@@ -240,261 +347,711 @@
wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋
wrkMast.setModiTime(new Date());
if (wrkMastMapper.updateById(wrkMast) == 0) {
- log.error("鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo());
+ News.error("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo());
}
} else {
- log.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ News.error("" + mark + " - 2" + " - 鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
}
+ } else {
+ News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable()
+ + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk() + "銆佸伐浣滃彿锛�" + staProtocol.getWorkNo()
+ + "銆侀攣瀹氭爣璁�" + staProtocol.isPakMk());
}
-
-
}
}
+ News.infoNoLog("" + mark + " - 0" + " - wms鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
/**
* 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱
*/
- @Async
- public void stnToCrnStnPick(){
- for (DevpSlave devp : slaveProperties.getDevp()) {
- // 閬嶅巻鎷f枡鍏ュ簱鍙�
- for (DevpSlave.Sta pickSta : devp.getPickSta()) {
- // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()).clone();
- if (staProtocol == null) { continue; }
- if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
- && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()){
- WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo().intValue());
- if (wrkMast == null) {
- // 鏃犳嫞鏂欐暟鎹�
+ public synchronized void stnToCrnStnPick(Integer mark) {
+ 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;
- }
- 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", wrkMast.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
- .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿
- StaDesc staDesc = staDescService.selectOne(wrapper);
- if (Cools.isEmpty(staDesc)) {
- log.error("鍏ュ簱璺緞涓嶅瓨鍦�");
- continue;
+ } else {
+ staProtocol = staProtocol.clone();
}
- try {
- // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
- if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
+ 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());
+// if (barcodeThread == null) {
+// continue;
+// }
+// String barcode = barcodeThread.getBarcode();
+// if(!Cools.isEmpty(barcode)) {
+// News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
+// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+// continue;
+// }
+// } else {
+// continue;
+// }
+
+// WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
+ if (wrkMast == null) {
+ // 鏃犳嫞鏂欐暟鎹�
+ continue;
}
- // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
- if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+ if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
+ || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) {
+ continue;
}
- // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�)
- Integer staNo = staDesc.getCrnStn();
- // 鏇存柊宸ヤ綔妗f暟鎹姸鎬�
- 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(new Date());
- if (wrkMastMapper.updateById(wrkMast) == 0) {
- throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+ // 鑾峰彇鐩爣绔�
+ 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));
+ }
+ continue;
}
- // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
+
+ 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)) {
+ 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.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());
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
+ }
+
+ /**
+ * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱-鏉$爜
+ */
+ public synchronized void stnToCrnStnPickBarcode(Integer mark) {
+ 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();
+ }
+
+ if (staProtocol.isAutoing()
+ && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && staProtocol.getWorkNo() > 0
+ && staProtocol.isPakMk()) {
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�");
+
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, insta.getBarcode());
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if (!Cools.isEmpty(barcode)) {
+ News.info("" + mark + " - 1" + " - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", insta.getBarcode(), barcode);
+ if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ continue;
+ }
+ } else {
+ continue;
+ }
+
+ WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
+ if (wrkMast == null) {
+ // 鏃犳嫞鏂欐暟鎹�
+ continue;
+ }
+ if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
+ || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) {
+ continue;
+ }
+
+ // 鎷c�佺洏銆佸苟 浣滀笟绔欒浆鎹�
+// int stnNo = 0;
+// if (wrkMast.getStaNo() == 109) {
+// stnNo = 127;
+// } else if (wrkMast.getStaNo() == 113) {
+// stnNo = 128;
+// } else {
+// log.error("{}鍙蜂换鍔℃暟鎹紓甯革紒", wrkMast.getWrkNo());
+// }
+ // 鑾峰彇鐩爣绔�
+ Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
+ .eq("type_no", wrkMast.getIoType() - 50)
+ .eq("stn_no", insta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
+ .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿
+ StaDesc staDesc = staDescService.selectOne(wrapper);
+ if (Cools.isEmpty(staDesc)) {
+// News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
+// staProtocol.setWorkNo((short) 9989);
+// staProtocol.setStaNo((short) (pickSta.getStaNo().shortValue()-(short)1));
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ //LED
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, insta.getLed());
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�" + insta.getBackSta().shortValue() + "绔欑偣";
+ MessageQueue.offer(SlaveType.Led, insta.getLed(), new Task(5, errorMsg));
+ }
+ continue;
+ }
+
+ try {
+ // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
+ if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
+ throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
+ }
+ // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+ if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
+ throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+ }
+
+ Date now = new Date();
+ // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�)
+ Integer staNo = staDesc.getCrnStn();
+ // 鏇存柊宸ヤ綔妗f暟鎹姸鎬�
+ wrkMast.setIoTime(now);
+ wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57
+ wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋
+ wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 婧愮珯
+ wrkMast.setStaNo(staNo); // 鐩爣绔�
+ wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣�
+ wrkMast.setSourceLocNo(""); // 婧愬簱浣嶆竻绌�
+ wrkMast.setModiTime(now);
+ wrkMast.setUpdMk("");//鍏佽鍐嶆绉诲簱
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+ }
+ // 鏇存柊鏄庣粏妗o_time (鍘嗗彶妗e叧鑱斾娇鐢級
+ wrkDetlService.updateIoTime(wrkMast.getWrkNo(), now);
+ // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
+ LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+ locMast.setLocSts("Q");
+ locMast.setModiTime(new Date());
+ if (!locMastService.updateById(locMast)) {
+ throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ continue;
+ }
+
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
- 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;
- }
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
- staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- log.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+ } else {
+ News.errorNoLog("" + mark + " - 6" + " - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒" + " 鑷姩淇″彿锛�" + staProtocol.isLoading() + "銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable()
+ + "銆佺┖鏉夸俊鍙凤細" + staProtocol.isEmptyMk());
}
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
}
+ News.infoNoLog("" + mark + " - 0" + " - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
/**
* 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯
*/
- @Async
- public void crnStnToOutStn() {
- for (CrnSlave crnSlave : slaveProperties.getCrn()) {
- // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯
- for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
- // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
- StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
- if (staProtocol == null) { continue; }
- if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
- // 鏌ヨ宸ヤ綔妗�
- WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
- if (wrkMast == null) {
+ public synchronized void crnStnToOutStn(Integer mark) {
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("wrk_sts", 12)
+ );
+
+ for (WrkMast wrkMast : wrkMasts) {
+ // 鍒ゆ柇宸ヤ綔妗f潯浠�
+ if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
+ continue;
+ }
+
+ Integer devpId = null;
+ Integer sourceStaNo = wrkMast.getSourceStaNo();
+ for (CrnSlave crnSlave : slaveProperties.getCrn()) {
+ for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
+ if (crnStn.getStaNo().equals(sourceStaNo)) {
+ devpId = crnStn.getDevpPlcId();
+ break;
+ }
+ }
+ }
+
+ if (devpId == null) {
+ News.error("" + mark + " - 0" + " - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯锛屾湭鎵惧埌瀵瑰簲PLC");
+ continue;
+ }
+
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpId);
+ StaProtocol staProtocol = devpThread.getStation().get(sourceStaNo);
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+
+ if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
+ CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+
+ if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
+ && (crnProtocol.statusType == CrnStatusType.PUTTING || crnProtocol.statusType == CrnStatusType.WAITING)) {
+ //鏀捐揣涓� 鎴� 绛夊緟纭
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛�");
+
+ // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+ 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(staNo);
+ staProtocol.setPalletSize(locMast.getLocType2());
+ if (!MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol))) {
continue;
}
- // 鍒ゆ柇宸ヤ綔妗f潯浠�
- if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
- continue;
+
+ // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触
+ wrkMast.setWrkSts(14L);
+ wrkMast.setCrnEndTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) != 0) {
+ News.info("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14鎴愬姛锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo());
+ } else {
+ News.error("" + mark + " - 1" + " - 鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo());
}
- // 鍒ゆ柇鍚婅溅鏄惁瀹為檯宸插畬鎴愶紝涓旂數鑴戠姸鎬佸湪move涓紝浠ュ鐢佃剳杩涜鏇存柊宸ヤ綔妗�
- CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
- CrnProtocol crnProtocol = crnThread.getCrnProtocol();
- if (crnProtocol.statusType == CrnStatusType.FETCHING || crnProtocol.statusType == CrnStatusType.PUTTING) {
- // 绉诲姩涓�
- continue;
- }
- // 鍒ゆ柇鍫嗗灈鏈虹姸鎬佺瓑寰呯‘璁�
- if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
- && crnProtocol.statusType == CrnStatusType.WAITING
- && crnProtocol.forkPosType == CrnForkPosType.HOME) {
-
- // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
-
- // 涓嬪彂绔欑偣淇℃伅
- staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
- staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
- if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) {
- continue;
- }
-
- // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触
- wrkMast.setWrkSts(14L);
- wrkMast.setCrnEndTime(new Date());
- if (wrkMastMapper.updateById(wrkMast) != 0) {
- // 澶嶄綅鍫嗗灈鏈�
- crnThread.setResetFlag(true);
- } else {
- log.error("鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo());
- }
-
- }
-
}
}
}
+
+ News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 ===銆嬫墽琛屽畬鎴�");
}
/**
* 鍏ュ嚭搴� ===>> 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂
*/
- @Async
- public void crnIoExecute(){
+ public synchronized void crnIoExecute(Integer mark) {
+
for (CrnSlave crn : slaveProperties.getCrn()) {
// 鑾峰彇鍫嗗灈鏈轰俊鎭�
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());
+ if (crnProtocol == null) {
continue;
}
+ BasCrnp basCrnp = basCrnpService.selectById(crn.getId());
+ if (basCrnp == null) {
+ News.error("" + mark + " - 1" + " - {}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId());
+ continue;
+ }
+
+// //鍫嗗灈鏈哄洖鍘熺偣浠诲姟涓�
+// if(crnThread.isBackHpFlag()){
+// 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) {
+ if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
+ && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽爢鍨涙満鍏ュ嚭搴撲綔涓氫笅鍙�");
// 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
if (crnProtocol.getLastIo().equals("I")) {
if (basCrnp.getInEnable().equals("Y")) {
- this.crnStnToLoc(crn, crnProtocol); // 鍏ュ簱
+ //mark - 1 - ....
+ this.crnStnToLoc(crn, crnProtocol, mark); // 鍏ュ簱
crnProtocol.setLastIo("O");
} else if (basCrnp.getOutEnable().equals("Y")) {
- this.locToCrnStn(crn, crnProtocol); // 鍑哄簱
+ //mark - 2 - ....
+ this.locToCrnStn(crn, crnProtocol, mark); // 鍑哄簱
crnProtocol.setLastIo("I");
}
}
// 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
else if (crnProtocol.getLastIo().equals("O")) {
if (basCrnp.getOutEnable().equals("Y")) {
- this.locToCrnStn(crn, crnProtocol); // 鍑哄簱
+ this.locToCrnStn(crn, crnProtocol, mark); // 鍑哄簱
crnProtocol.setLastIo("I");
} else if (basCrnp.getInEnable().equals("Y")) {
- this.crnStnToLoc(crn, crnProtocol); // 鍏ュ簱
+ this.crnStnToLoc(crn, crnProtocol, mark); // 鍏ュ簱
crnProtocol.setLastIo("O");
}
}
}
// 搴撲綅绉昏浆
- this.locToLoc(crn, crnProtocol);
+ //mark - 3 - ....
+ this.locToLoc(crn, crnProtocol, mark);
+ this.locToLoc111(crn, crnProtocol, mark);
+// this.crnRebackHp(crnProtocol, crnThread);
+
+ }
+ 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 + crn.getId());
+ 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", 10);
+ 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 + crn.getId());
+ 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", 10);
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
}
/**
* 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣�
*/
- @Async
- public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){
+ public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) {
+ News.warnNoLog("" + mark + " - 1" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽叆搴�");
for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) {
boolean flag = false;
// 鑾峰彇鍫嗗灈鏈哄叆搴撶珯淇℃伅
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
- StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
- if (staProtocol == null) { continue; }
+ StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
+ if (staProtocol == null) {
+ News.infoNoLog("" + mark + " - 1" + " - 1" + " - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц)锛歴taProtocol=" + staProtocol);
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
// 鏌ヨ绔欑偣璇︾粏淇℃伅
BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
if (staDetl == null) {
- log.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
+ News.error("" + mark + " - 1" + " - 2" + " - 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
continue;
}
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
- && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) {
+ && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
flag = true;
}
if (!flag) {
+ News.errorNoLog("" + mark + " - 1" + " - 3" + " - 鍫嗗灈鏈哄叆搴撶珯淇℃伅(浠ヤ笅闇�瑕佸叏true):"
+ + "鑷姩淇″彿" + staProtocol.isAutoing() + "鏈夌墿淇″彿" + staProtocol.isLoading()
+ + "宸ヤ綔鍙�>0" + staProtocol.getWorkNo() + "鍙叆淇″彿" + staProtocol.isInEnable()
+ + "鑳藉叆淇″彿锛坵ms璁剧疆锛�.equals(\"Y\")" + staDetl.getCanining());
continue;
}
// 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。
- WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue());
- if(null == wrkMast) {
- log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo());
+ if (null == wrkMast) {
+ News.infoNoLog("" + mark + " - 1" + " - 4" + " - 鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
+// log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
continue;
}
// 鑾峰彇搴撲綅淇℃伅
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
if (locMast == null) {
- log.error("鏌ヨ搴撳瓨鏃犳暟鎹�--搴撲綅鍙穥}", wrkMast.getLocNo());
+ News.error("" + mark + " - 1" + " - 5" + " - 鏌ヨ搴撳瓨鏃犳暟鎹�--搴撲綅鍙穥}", wrkMast.getLocNo());
continue;
}
if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) {
- log.error("鍏ュ簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), locMast.getLocSts());
+ News.error("" + mark + " - 1" + " - 6" + " - 鍏ュ簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), locMast.getLocSts());
continue;
}
// 鍫嗗灈鏈烘帶鍒惰繃婊�
if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+// News.infoNoLog(""+mark+" - 1"+" - 7"+" - 鍫嗗灈鏈烘帶鍒惰繃婊�:鍫嗗灈鏈烘槸鍚︾┖闂�={}锛屼换鍔″彿={}", crnProtocol.getStatusType(),crnProtocol.getTaskNo());
continue;
}
+
+ // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+ if (wrkMastMapper.selectWorking(slave.getId()) != null) {
+ continue;
+ }
+
+ if (crnProtocol.getCrnNo() == 1) {
+ //鍒ゆ柇鍫嗗灈鏈哄拰褰撳墠浠诲姟鏄惁澶勪簬涓�涓贩閬�
+ if (Utils.getLaneByLocNo(wrkMast.getLocNo()) != crnProtocol.getCrnLane()) {
+ //鍒ゆ柇鍫嗗灈鏈烘墍鍦ㄥ贩閬撴槸鍚﹀瓨鍦ㄥ叾浠栦换鍔★紝濡傚瓨鍦ㄥ垯浼樺厛鎵ц
+ List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false);
+// if (!currentWrkMasts.isEmpty()) {
+// continue;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔�
+// }
+ }
+ }
+
+ // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
+ if (Utils.isDeepLoc(slaveProperties, wrkMast.getLocNo())) {
+ News.warnNoLog("" + mark + " - 1" + " - 8" + " - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}", wrkMast.getWrkNo());
+ String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getLocNo());
+ LocMast shallowLoc = locMastService.selectById(shallowLocNo);
+ // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒
+ if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
+ News.warn("" + mark + " - 1" + " - 9" + " - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+ WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+ if (null == waitWrkMast) {
+ News.error("" + mark + " - 1" + " - 10" + " - {}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo);
+ } else {
+ if (waitWrkMast.getWrkSts() != 14 && waitWrkMast.getIoType() > 100) {
+ waitWrkMast.setIoPri(15D);
+ waitWrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(waitWrkMast) == 0) {
+ News.error("" + mark + " - 1" + " - 11" + " - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo());
+ }
+ continue;
+ }
+
+ if (waitWrkMast.getWrkSts() < 5 && waitWrkMast.getIoType() < 100) {
+ continue;//鏈変换鍔$姝㈡惉杩愶紝鏈夊彲鑳芥祬搴撲綅鐘舵�佽繕鏈彉鏇村畬鎴�
+ }
+ }
+
+ } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
+ News.warn("" + mark + " - 1" + " - 12" + " - // F銆丏 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+ // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
+ if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) {
+ if (moveLocForDeepLoc(slave, crnProtocol, shallowLoc, mark)) {
+ wrkMast.setUpdMk("Y");
+ wrkMast.setIoPri(14D);
+ wrkMastMapper.updateById(wrkMast);
+ }
+// wrkMast.setUpdMk("Y");
+// wrkMast.setIoPri(14D);
+// wrkMastMapper.updateById(wrkMast);
+// // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑
+// moveLocForDeepLoc(slave, shallowLoc,mark);
+ // 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�)
+// moveLocForDeepLocPakin(slave, shallowLoc, wrkMast);
+ }
+ continue;
+ } else if (shallowLoc.getLocSts().equals("Q")) {
+ News.warn("" + mark + " - 1" + " - 13" + " - // Q 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+ WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+ if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) {
+ News.infoNoLog("" + mark + " - 1" + " - 14" + " - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}", waitWrkMast.getWrkSts());
+ continue;
+ }
+ }
+ }
+ News.info("" + mark + " - 1" + " - 15" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue()
+ , crnStn.getRow().shortValue(), crnStn.getBay().shortValue(), crnStn.getLev().shortValue()
+ , locMast.getRow1().shortValue(), locMast.getBay1().shortValue(), locMast.getLev1().shortValue());
// 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
CrnCommand crnCommand = new CrnCommand();
crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
- crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
- crnCommand.setTaskMode(CrnTaskModeType.PAKIN); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+ crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 婧愬簱浣嶆帓
crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 婧愬簱浣嶅垪
crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 婧愬簱浣嶅眰
@@ -502,104 +1059,433 @@
crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 鐩爣搴撲綅鍒�
crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 鐩爣搴撲綅灞�
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
- log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+ News.error("" + mark + " - 1" + " - 16" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
} else {
+
+// long startTime = System.currentTimeMillis();
+// while ((System.currentTimeMillis() - startTime) < COMMAND_TIMEOUT) {
+//
+// if (true) {
+// break;
+// }
+//
+// try{
+// Thread.sleep(500);
+// }catch(Exception ignore){}
+// }
+
// 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓�
Date now = new Date();
wrkMast.setWrkSts(3L);
wrkMast.setCrnStrTime(now);
wrkMast.setModiTime(now);
if (wrkMastMapper.updateById(wrkMast) == 0) {
- log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ News.error("" + mark + " - 1" + " - 17" + " - 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
}
}
}
+ News.infoNoLog("" + mark + " - 1" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍏ュ簱鎵ц瀹屾瘯");
}
/**
* 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔�
+ * 2022-06-09 TQS淇敼锛屾煡璇㈠伐浣滄。LIST锛岄亶鍘嗕笅鍙戯紝闃叉绗竴涓换鍔″牭濉炲嚭搴�
*/
- @Async
- public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
+ public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) {
+ News.warnNoLog("" + mark + " - 2" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽嚭搴�");
+
+ int devpTaskStackOver = 20;
+ Config config = configService.selectOne(new EntityWrapper<Config>()
+ .eq("code", "devpTaskStackOver"));
+ if (config != null) {
+ devpTaskStackOver = Integer.parseInt(config.getValue());
+ }
+ int devpCheckTaskStackOver = 2;
+ Config config2 = configService.selectOne(new EntityWrapper<Config>()
+ .eq("code", "devpCheckTaskStackOver"));
+ if (config2 != null) {
+ 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) {
+ News.warn("" + mark + " - 2" + " - 0" + " - 杈撻�佺嚎浠诲姟杩囪浇锛屽綋鍓嶈緭閫佺嚎鎵胯浇鏁伴噺:{}", devpWorkingCount);
+ return;
+ }
+
for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
// 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗�
- WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId());
- if (wrkMast == null) {
- continue;
- }
- // 宸ヤ綔妗g姸鎬佸垽鏂�
- if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null){
- log.error("鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
- continue;
- }
- // 鑾峰彇婧愬簱浣嶄俊鎭�
- LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
- if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) {
- log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
- continue;
- }
- // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
- StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
- if (staProtocol == null) { continue; }
- // 鏌ヨ绔欑偣璇︾粏淇℃伅
- BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
- if (staDetl == null) {
- log.error("鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
- continue;
- }
- // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
- if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y")
- && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
- // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
-
- // 鍫嗗灈鏈烘帶鍒惰繃婊�
- if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+// WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
+ List<WrkMast> wrkMasts = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo());
+ for (WrkMast wrkMast : wrkMasts) {
+ if (wrkMast == null) {
continue;
}
-
- // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔�
- CrnCommand crnCommand = new CrnCommand();
- crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
- crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
- crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
- crnCommand.setTaskMode(CrnTaskModeType.PAKOUT); // 浠诲姟妯″紡: 搴撲綅绉昏浆
- crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓
- crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪
- crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰
- crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺�
- crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒�
- crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞�
- if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
- log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+ // 宸ヤ綔妗g姸鎬佸垽鏂�
+ if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) {
+ News.error("" + mark + " - 2" + " - 1" + " - 鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
+ continue;
+ }
+ // 鑾峰彇婧愬簱浣嶄俊鎭�
+ LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
+ if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
+ News.error("" + mark + " - 2" + " - 2" + " - 鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
+ continue;
+ }
+ // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
+ SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
+ StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
+ if (staProtocol == null) {
+ News.infoNoLog("" + mark + " - 2" + " - 3" + " - 鍫嗗灈鏈哄嚭搴撶珯淇℃伅(staProtocol!=null缁х画鎵ц,鍚﹀垯寰幆缁堟)锛歴taProtocol=" + staProtocol);
+ break;
+// continue;
} else {
- // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
- Date now = new Date();
- wrkMast.setWrkSts(12L);
- wrkMast.setCrnStrTime(now);
- wrkMast.setModiTime(now);
- if (wrkMastMapper.updateById(wrkMast) == 0) {
- log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ staProtocol = staProtocol.clone();
+ }
+
+ if (wrkMast.getStaNo() == 1003 || wrkMast.getStaNo() == 1007 || wrkMast.getStaNo() == 1004) {
+ //妫�娴嬫槸鍚︽湁鍏ュ簱浠诲姟
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("io_type", 1, 53, 57)
+ .notIn("wrk_sts", 3, 4, 5)
+ .in("source_sta_no", 1002, 1007)
+ );
+ if (!inWrkMasts.isEmpty()) {
+ News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦ㄥ叆搴撲换鍔★紝绛夊緟鍏ュ簱浠诲姟鎵ц瀹屾垚鍐嶅嚭搴擄紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo());
+ continue;
+ }
+ }
+
+ //zhangc
+ if (wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) {
+ if (wrkMast.getStaNo() == 1058) {
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("wrk_sts", 12, 14)
+ .eq("sta_no", 1058)
+ );
+ if (!Cools.isEmpty(inWrkMasts) && inWrkMasts.size() >= devpCheckTaskStackOver) {
+ News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦�1058绔欑偣锛屽瓨鍦ㄤ袱绗斿伐浣滀腑鐨勪换鍔★紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo());
+ continue;
+ }
+ } else if (wrkMast.getStaNo() == 1062) {
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("wrk_sts", 12, 14)
+ .eq("sta_no", 1062)
+ );
+ if (!Cools.isEmpty(inWrkMasts) && inWrkMasts.size() >= devpCheckTaskStackOver) {
+ News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦�1062绔欑偣锛屽瓨鍦ㄤ袱绗斿伐浣滀腑鐨勪换鍔★紝宸ヤ綔鍙�={}" + wrkMast.getWrkNo());
+ 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;
+ }
+ }
+
+// // 鍏ュ嚭搴撴ā寮忓垽鏂�
+// if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; }
+// if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
+// News.infoNoLog(""+mark+" - 2"+" - 4"+" - 鍏ュ嚭搴撴ā寮忥紙姝ゅ鍑哄簱鏂规硶锛屽嚭搴撴ā寮忕户缁�=="+devpThread.ioModeOf2F);
+// continue;
+// }
+
+ // 鏌ヨ绔欑偣璇︾粏淇℃伅
+ BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
+ if (staDetl == null) {
+ News.error("" + mark + " - 2" + " - 5" + " - 鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
+ break;
+// continue;
+ }
+ // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
+ if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) {
+
+ //鏍规嵁鍙傛暟鍒ゆ柇鏄惁鏍¢獙鍙嚭淇″彿
+ String crnOutVerifyOut = "Y";
+ Config crnOutVerifyOutEnableConfig = configService.selectOne(new EntityWrapper<Config>()
+ .eq("code", "crnOutVerifyOutEnable"));
+ if (crnOutVerifyOutEnableConfig != null) {
+ crnOutVerifyOut = crnOutVerifyOutEnableConfig.getValue();
+ }
+
+ if (crnOutVerifyOut.equals("Y")) {
+ if (!staProtocol.isOutEnable()) {
+ continue;
+ }
+
+ if (staProtocol.getWorkNo() > 0) {
+ continue;
+ }
+ }
+
+
+ // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+
+ // 鍫嗗灈鏈烘帶鍒惰繃婊�
+ if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+// continue;
+ break;
+ }
+
+ if (crnProtocol.getCrnNo() == 1) {
+ 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;//褰撳墠鍫嗗灈鏈烘墍鍦ㄥ贩閬撳瓨鍦ㄤ换鍔�
+ }
+ }
+ }
+ }
+
+ // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
+ if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) {
+ News.warnNoLog("" + mark + " - 2" + " - 6" + " - 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� : 寮�濮嬫墽琛� 浠诲姟鍙�={}", wrkMast.getWrkNo());
+ String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo());
+ LocMast shallowLoc = locMastService.selectById(shallowLocNo);
+ // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒
+ if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
+ News.warnNoLog("" + mark + " - 2" + " - 7" + " - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+ WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+ if (null == waitWrkMast) {
+ News.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo);
+ } else {
+ if (waitWrkMast.getWrkSts() == 11) {
+ waitWrkMast.setIoPri(15D);
+ waitWrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(waitWrkMast) == 0) {
+ News.error("" + mark + " - 2" + " - 8" + " - 璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo());
+ }
+ continue;
+ } else {
+
+ }
+ }
+ } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
+ News.warnNoLog("" + mark + " - 2" + " - 9" + " - // F銆丏 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+// WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+ //2022-08-16 modify,涓嶆牴鎹畊pdmk鏍囪绉诲簱浠诲姟(瀹规槗琚彇娑堝鑷村牭濉�)锛屾煡璇㈠伐浣滄。鏄惁瀛樺湪浠诲姟
+ WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
+ // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
+// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())
+// || Cools.isEmpty(waitWrkMast)) {
+ if (Cools.isEmpty(waitWrkMast)) {
+ if (moveLocForDeepLoc(slave, crnProtocol, shallowLoc, mark)) {
+ wrkMast.setUpdMk("Y");
+// wrkMast.setIoPri(14D);
+ wrkMastMapper.updateById(wrkMast);
+ }
+// wrkMast.setUpdMk("Y");
+// wrkMastMapper.updateById(wrkMast);
+// // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑
+// moveLocForDeepLoc(slave, shallowLoc,mark);
+ }
+ News.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo);
+ continue;
+ } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) {
+ News.warnNoLog("" + mark + " - 2" + " - 10" + " - // Q銆丼 搴撲綅={},搴撲綅鐘舵��={}", shallowLoc.getLocNo(), shallowLoc.getLocSts());
+ WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
+ if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) {
+ News.infoNoLog("" + mark + " - 2" + " - 11" + " - // F銆丏 宸ヤ綔鐘舵��(鍒ゆ柇鏉′欢涓�==4)={}", waitWrkMast.getWrkSts());
+ continue;
+ }
+ }
+ }
+
+ // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+ if (wrkMastMapper.selectWorking(slave.getId()) != null) {
+ break;
+// return;
+ }
+
+ News.warnNoLog("" + mark + " - 2" + " - 12" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue()
+ , sourceSta.getRow1().shortValue(), sourceSta.getBay1().shortValue(), sourceSta.getLev1().shortValue()
+ , crnStn.getRow().shortValue(), crnStn.getBay().shortValue(), crnStn.getLev().shortValue());
+
+ // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔�
+ CrnCommand crnCommand = new CrnCommand();
+ crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
+ crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
+// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+ crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+ crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓
+ crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪
+ crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰
+ crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺�
+ crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒�
+ crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞�
+ if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
+ News.error("" + mark + " - 2" + " - 13" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+ } else {
+ // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
+ Date now = new Date();
+ wrkMast.setWrkSts(12L);
+ wrkMast.setCrnStrTime(now);
+ wrkMast.setModiTime(now);
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ News.error("" + mark + " - 2" + " - 14" + " - 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ }
+ break;
}
}
}
}
+ News.infoNoLog("" + mark + " - 2" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 锛� 鍑哄簱鎵ц瀹屾瘯");
}
+
+// /**
+// * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔�
+// */
+// public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
+// for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
+// // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗�
+// WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
+// if (wrkMast == null) {
+// continue;
+// }
+// // 宸ヤ綔妗g姸鎬佸垽鏂�
+// if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null){
+// log.error("鏌ヨ宸ヤ綔妗f暟鎹笉绗﹀悎鏉′欢--鍏ュ嚭绫诲瀷/绔欑偣, 宸ヤ綔鍙�={}锛屾簮搴撲綅={}锛屽叆鍑虹被鍨�={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
+// continue;
+// }
+// // 鑾峰彇婧愬簱浣嶄俊鎭�
+// LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
+// if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) {
+// log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
+// continue;
+// }
+// // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
+// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
+// StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
+// if (staProtocol == null) {
+// continue;
+// } else {
+// staProtocol = staProtocol.clone();
+// }
+//
+//// // 鍏ュ嚭搴撴ā寮忓垽鏂�
+//// if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; }
+//
+//
+// // 鏌ヨ绔欑偣璇︾粏淇℃伅
+// BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
+// if (staDetl == null) {
+// log.error("鍑哄簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
+// continue;
+// }
+// // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
+// if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y")
+// && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
+// // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+//
+// // 鍫嗗灈鏈烘帶鍒惰繃婊�
+// if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+// continue;
+// }
+//
+// // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
+// if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) {
+// String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo());
+// LocMast shallowLoc = locMastService.selectById(shallowLocNo);
+// // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒
+// if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
+// WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+// if (null == waitWrkMast) {
+// log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo);
+// } else {
+// if(waitWrkMast.getWrkSts() == 11) {
+// waitWrkMast.setIoPri(15D);
+// waitWrkMast.setModiTime(new Date());
+// if (wrkMastMapper.updateById(waitWrkMast) == 0) {
+// log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo());
+// }
+// continue;
+// } else {
+//
+// }
+// }
+// } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
+// // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
+// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) {
+// wrkMast.setUpdMk("Y");
+// wrkMastMapper.updateById(wrkMast);
+// // 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�)
+// moveLocForDeepLoc(slave, shallowLoc);
+// }
+// log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛�", wrkMast.getWrkNo());
+// continue;
+// }
+// }
+//
+// // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+// if (wrkMastMapper.selectWorking(slave.getId()) != null) {
+// return;
+// }
+//
+// // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔�
+// CrnCommand crnCommand = new CrnCommand();
+// crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
+// crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
+// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+// crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓
+// crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪
+// crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰
+// crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺�
+// crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒�
+// crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞�
+// if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
+// log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+// } else {
+// // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
+// Date now = new Date();
+// wrkMast.setWrkSts(12L);
+// wrkMast.setCrnStrTime(now);
+// wrkMast.setModiTime(now);
+// if (wrkMastMapper.updateById(wrkMast) == 0) {
+// log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+// }
+// }
+// }
+// }
+// }
/**
* 搴撲綅绉昏浆
*/
- @Async
- public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){
+ public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) {
// 鑾峰彇宸ヤ綔妗d俊鎭�
WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId());
if (null == wrkMast) {
return;
}
+ News.warnNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�");
// 鑾峰彇婧愬簱浣嶄俊鎭�
LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
if (null == sourceSta) {
- log.error("宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
+ News.error("" + mark + " - 3" + " - 1" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
return;
}
// 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂�
@@ -609,7 +1495,7 @@
// 鑾峰彇鐩爣搴撲綅淇℃伅
LocMast sta = locMastService.selectById(wrkMast.getLocNo());
if (null == sta) {
- log.error("宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
+ News.error("" + mark + " - 3" + " - 2" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
return;
}
// 鑾峰彇鍫嗗灈鏈轰俊鎭� 骞� 鍒ゆ柇鏄惁鍙叆鍑�
@@ -622,6 +1508,15 @@
if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
return;
}
+
+ // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+ if (wrkMastMapper.selectWorking(slave.getId()) != null) {
+ return;
+ }
+
+ News.warnNoLog("" + mark + " - 3" + " - 3" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue()
+ , sourceSta.getRow1().shortValue(), sourceSta.getBay1().shortValue(), sourceSta.getLev1().shortValue()
+ , sta.getRow1().shortValue(), sta.getBay1().shortValue(), sta.getLev1().shortValue());
// 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
CrnCommand crnCommand = new CrnCommand();
@@ -636,7 +1531,7 @@
crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 鐩爣搴撲綅鍒�
crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 鐩爣搴撲綅灞�
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
- log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+ News.error("" + mark + " - 3" + " - 4" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
} else {
// 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
Date now = new Date();
@@ -644,59 +1539,283 @@
wrkMast.setCrnStrTime(now);
wrkMast.setModiTime(now);
if (wrkMastMapper.updateById(wrkMast) == 0) {
- log.error("銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ News.error("" + mark + " - 3" + " - 5" + " - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ }
+ crnProtocol.setLastIo("I");
+ }
+ News.infoNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�");
+
+ }
+
+ /**
+ * 搴撲綅绉昏浆
+ */
+ public synchronized void locToLoc111(CrnSlave slave, CrnProtocol crnProtocol, Integer mark) {
+ // 鑾峰彇宸ヤ綔妗d俊鎭�
+ WrkMast wrkMast = wrkMastMapper.selectLocMove111(slave.getId());
+ if (null == wrkMast) {
+ return;
+ }
+ News.warnNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�");
+ // 鑾峰彇婧愬簱浣嶄俊鎭�
+ LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo());
+ if (null == sourceLoc) {
+ News.error("" + mark + " - 3" + " - 1" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
+ return;
+ }
+ // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂�
+ if (!sourceLoc.getLocSts().equals("R")) {
+ News.error("" + mark + " - 3" + " - 11" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭簮搴撲綅鐘舵�佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
+ return;
+ }
+
+ if (wrkMast.getIoType() != 111) {
+ // 鑾峰彇鐩爣搴撲綅淇℃伅
+ LocMast loc = locMastService.selectById(wrkMast.getLocNo());
+ if (null == loc) {
+ News.error("" + mark + " - 3" + " - 2" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
+ return;
+ }
+ // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂�
+ if (!loc.getLocSts().equals("S")) {
+ News.error("" + mark + " - 3" + " - 21" + " - 宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氱洰鏍囧簱浣嶇姸鎬佷笉涓篟锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
+ return;
}
}
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭� 骞� 鍒ゆ柇鏄惁鍙叆鍑�
+ BasCrnp basCrnp = basCrnpService.selectById(slave.getId());
+ if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) {
+ return;
+ }
+
+ // 鍫嗗灈鏈烘帶鍒惰繃婊�
+ if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+ return;
+ }
+
+ // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+ if (wrkMastMapper.selectWorking(slave.getId()) != null) {
+ return;
+ }
+
+ News.warnNoLog("" + mark + " - 3" + " - 3" + " - 鍛戒护涓嬪彂 : 宸ヤ綔鍙�={},婧愭帓={},婧愬垪={},婧愬眰={},鐩爣鎺�={},鐩爣鍒�={},鐩爣灞�={}", wrkMast.getWrkNo().shortValue()
+ , sourceLoc.getRow1().shortValue(), sourceLoc.getBay1().shortValue(), sourceLoc.getLev1().shortValue()
+ , sourceLoc.getRow1().shortValue(), sourceLoc.getBay1().shortValue(), sourceLoc.getLev1().shortValue());
+
+ // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+ CrnCommand crnCommand = new CrnCommand();
+ crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
+ crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
+ crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+ crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+ crnCommand.setSourcePosX(sourceLoc.getRow1().shortValue()); // 婧愬簱浣嶆帓
+ crnCommand.setSourcePosY(sourceLoc.getBay1().shortValue()); // 婧愬簱浣嶅垪
+ crnCommand.setSourcePosZ(sourceLoc.getLev1().shortValue()); // 婧愬簱浣嶅眰
+ crnCommand.setDestinationPosX(sourceLoc.getRow1().shortValue()); // 鐩爣搴撲綅鎺�
+ crnCommand.setDestinationPosY(sourceLoc.getBay1().shortValue()); // 鐩爣搴撲綅鍒�
+ crnCommand.setDestinationPosZ(sourceLoc.getLev1().shortValue()); // 鐩爣搴撲綅灞�
+ if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
+ News.error("" + mark + " - 3" + " - 4" + " - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+ } else {
+ // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
+ Date now = new Date();
+ wrkMast.setWrkSts(12L);
+ wrkMast.setCrnStrTime(now);
+ wrkMast.setModiTime(now);
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ News.error("" + mark + " - 3" + " - 5" + " - 銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
+ }
+ }
+ News.infoNoLog("" + mark + " - 3" + " - 0" + " - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氬簱浣嶇Щ杞畬鎴�");
}
/**
* 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣�
*/
- @Async
- public void storeFinished() {
+ public synchronized void storeFinished(Integer mark) {
for (CrnSlave crn : slaveProperties.getCrn()) {
// 鑾峰彇鍫嗗灈鏈轰俊鎭�
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
- if (crnProtocol == null) { continue; }
+ if (crnProtocol == null) {
+ continue;
+ }
// 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1
if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) {
- // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。
- WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
- if (wrkMast == null) {
- log.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo());
- continue;
- }
- // 鍏ュ簱 + 搴撲綅杞Щ ==> 4.鍏ュ簱瀹屾垚
- if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)){
- wrkMast.setWrkSts(4L);
- } else {
- continue;
- }
- Date now = new Date();
- wrkMast.setCrnEndTime(now);
- wrkMast.setModiTime(now);
- // 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満
- if (wrkMastMapper.updateById(wrkMast) > 0) {
+ News.warnNoLog("" + mark + " - 0" + " - 寮�濮嬫墽琛屽宸ヤ綔妗g殑瀹屾垚鎿嶄綔");
+ if (crnProtocol.getTaskNo() == 9999) {
// 鍫嗗灈鏈哄浣�
crnThread.setResetFlag(true);
+ redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 8);//闃叉鍥炲師鐐瑰悗涓嬪彂鎸囦护杩囧揩
+ continue;
}
- // 瀹屾垚閫氱煡妗�
-// if (wrkMastMapper.updateWaitPakInStep2(wrkMast.getBarcode()) == 0) {
-// log.error("鍏ュ簱閫氱煡妗d慨鏀圭粨鏉熺姸鎬佸け璐ワ紝workNo=[{}]", wrkMast.getWrkNo());
-// }
+ // 鑾峰彇寰呯‘璁ゅ伐浣滄。
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
+ if (wrkMast == null) {
+ News.error("" + mark + " - 1" + " - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo());
+ continue;
+ }
+
+ Date now = new Date();
+ if (wrkMast.getIoType() < 100) {
+ // 鍏ュ簱 + 搴撲綅杞Щ ==> 4.鍏ュ簱瀹屾垚
+ if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111))) {
+ wrkMast.setWrkSts(4L);
+ } else {
+ continue;
+ }
+
+ wrkMast.setCrnEndTime(now);
+ wrkMast.setModiTime(now);
+ // 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ // 鍫嗗灈鏈哄浣�
+ News.warnNoLog("" + mark + " - 2" + " - 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 : 鍫嗗灈鏈哄彿={}", crnThread.getCrnProtocol().getCrnNo());
+ crnThread.setResetFlag(true);
+ }
+ } else {
+ List<Long> list = new ArrayList<>();
+ list.add(14L);
+ list.add(15L);
+ if (!list.contains(wrkMast.getWrkSts())) {
+ News.error("" + mark + " - 1" + " - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や絾宸ヤ綔妗g姸鎬佹湭瀹屾垚銆傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo());
+ continue;
+ }
+
+ wrkMast.setCrnEndTime(now);
+ if (wrkMastMapper.updateById(wrkMast) != 0) {
+ // 澶嶄綅鍫嗗灈鏈�
+ crnThread.setResetFlag(true);
+ }
+ }
}
}
+ News.infoNoLog("" + mark + " - 0" + " - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�");
}
/**
* 鍫嗗灈鏈哄紓甯镐俊鎭褰�
*/
- public void recCrnErr(){
+ public synchronized void recCrnErr(Integer mark) {
+ Date now = new Date();
+ for (CrnSlave crn : slaveProperties.getCrn()) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
+ CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+ if (crnProtocol == null) {
+ continue;
+ }
+ if (true) {
+// if (crnProtocol.getModeType() != CrnModeType.STOP) {
+ // 鏈変换鍔�
+ if (crnProtocol.getTaskNo() != 0) {
+ BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue());
+ // 鏈夊紓甯�
+ if (latest == null) {
+ News.warnNoLog("" + mark + " - 1" + " - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏈変换鍔★紝鏈夊紓甯�");
+ if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
+ WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo());
+ if (wrkMast == null) {
+ continue;
+ }
+ BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
+ String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName();
+ BasErrLog basErrLog = new BasErrLog(
+ null, // 缂栧彿
+ wrkMast.getWrkNo(), // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
+ wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
+ crn.getId(), // 鍫嗗灈鏈�
+ null, // plc
+ wrkMast.getLocNo(), // 鐩爣搴撲綅
+ wrkMast.getStaNo(), // 鐩爣绔�
+ wrkMast.getSourceStaNo(), // 婧愮珯
+ wrkMast.getSourceLocNo(), // 婧愬簱浣�
+ wrkMast.getBarcode(), // 鏉$爜
+ (int) crnProtocol.getAlarm(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "浠诲姟涓紓甯�" // 澶囨敞
+ );
+ if (!basErrLogService.insert(basErrLog)) {
+ News.error("" + mark + " - 2" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
+ }
+ }
+ } else {
+ // 寮傚父淇
+ if (crnProtocol.getAlarm() == null || crnProtocol.getAlarm() == 0) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basErrLogService.updateById(latest)) {
+ News.error("" + mark + " - 3" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ }
+ }
+ }
+ // 鏃犱换鍔�
+ } else {
+ BasErrLog latest = basErrLogService.findLatest(crn.getId());
+ // 鏈夊紓甯�
+ if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
+ News.warnNoLog("" + mark + " - 4" + " - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏃犱换鍔★紝鏈夊紓甯�");
+ // 璁板綍鏂板紓甯�
+ if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) {
+ BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
+ String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName();
+ BasErrLog basErrLog = new BasErrLog(
+ null, // 缂栧彿
+ null, // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ null, // 宸ヤ綔鐘舵��
+ null, // 鍏ュ嚭搴撶被鍨�
+ crn.getId(), // 鍫嗗灈鏈�
+ null, // plc
+ null, // 鐩爣搴撲綅
+ null, // 鐩爣绔�
+ null, // 婧愮珯
+ null, // 婧愬簱浣�
+ null, // 鏉$爜
+ (int) crnProtocol.getAlarm(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "鏃犱换鍔″紓甯�" // 澶囨敞
+ );
+ if (!basErrLogService.insert(basErrLog)) {
+ News.error("" + mark + " - 5" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
+ }
+ }
+ // 鏃犲紓甯�
+ } else {
+ // 寮傚父淇
+ if (latest != null && latest.getStatus() == 1) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basErrLogService.updateById(latest)) {
+ News.error("" + mark + " - 6" + " - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ }
+ }
+ }
+ }
+ }
+
+ }
+ News.infoNoLog("" + mark + " - 0" + " - 鍫嗗灈鏈哄紓甯镐俊鎭褰曟墽琛屽畬鎴�");
}
@@ -705,102 +1824,308 @@
/**
* 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�
*/
- @Async
- public void storeEmptyPlt(){
+ public synchronized void storeEmptyPlt(Integer mark) {
+
for (DevpSlave devp : slaveProperties.getDevp()) {
// 閬嶅巻绌烘澘鍏ュ簱鍙�
for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
// 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()).clone();
- if (staProtocol == null) { continue; }
+ 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.isLoading() && staProtocol.isInEnable()
- && staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 0 && staProtocol.isPakMk()) {
- // 宸ヤ綔鍙�
- int workNo = commonService.getWorkNo(0);
- // 妫�绱㈠簱浣�
- StartupDto startupDto = commonService.getLocNo(1, 10, emptyInSta.getStaNo(), null);
+ 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 {
- // 鎻掑叆宸ヤ綔涓绘。
- WrkMast wrkMast = new WrkMast();
- wrkMast.setWrkNo(workNo);
- wrkMast.setIoTime(new Date());
- wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋
- wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱
- wrkMast.setIoPri(10D); // 浼樺厛绾э細10
- wrkMast.setCrnNo(startupDto.getCrnNo());
- wrkMast.setSourceStaNo(startupDto.getSourceStaNo());
- wrkMast.setStaNo(startupDto.getStaNo());
- wrkMast.setLocNo(startupDto.getLocNo());
- wrkMast.setFullPlt("N"); // 婊℃澘
- wrkMast.setPicking("N"); // 鎷f枡
- wrkMast.setExitMk("N"); // 閫�鍑�
- wrkMast.setEmptyMk("Y"); // 绌烘澘
- wrkMast.setLinkMis("N");
-// wrkMast.setCtnType(sourceStaNo.getCtnType()); // 瀹瑰櫒绫诲瀷
- // 鎿嶄綔浜哄憳鏁版嵁
- wrkMast.setAppeTime(new Date());
- wrkMast.setModiTime(new Date());
- Integer insert = wrkMastMapper.insert(wrkMast);
- if (insert == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
- }
- // 鏇存柊鐩爣搴撲綅鐘舵��
- LocMast locMast = locMastService.selectById(startupDto.getLocNo());
- locMast.setLocSts("S"); // S.鍏ュ簱棰勭害
- locMast.setModiTime(new Date());
- if (!locMastService.updateById(locMast)){
- throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
- }
- // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+ LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo((short) workNo);
- staProtocol.setStaNo(startupDto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+ 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);
+
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("loc_no", dto.getLocNo()));
+
+ // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
+ staProtocol.setWorkNo(dto.getWorkNo().shortValue());
+ staProtocol.setStaNo(dto.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.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();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
-
+ } 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;
+ }
+
+ //妫�娴嬫槸鍚︽湁鍏ュ簱浠诲姟
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("io_type", 1, 53, 57)
+ .in("source_sta_no", 1002, 1007)
+ );
+ if (!inWrkMasts.isEmpty()) {
+ News.error("" + mark + " - 2" + " - 妫�娴嬪瓨鍦ㄥ叆搴撲换鍔★紝绛夊緟鍏ュ簱浠诲姟鎵ц瀹屾垚鍐嶅叆绌烘墭锛屽伐浣滃彿={}");
+ 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(1004);
+ 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);
+ staProtocol.setPalletSize((short) 1);
+ 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鏄剧ず鍣�
*/
- @Async
- public void ledExecute() {
+ 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<>();
+// // 宸ヤ綔妗i泦鍚�
+// List<WrkMast> wrkMasts = new ArrayList<>();
+ List<Integer> workNoList = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
- StaProtocol staProtocol = devpThread.getStation().get(staNo).clone();
- if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { continue; }
+ StaProtocol staProtocol = devpThread.getStation().get(staNo);
+ if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
+ continue;
+ } 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; }
- wrkMasts.add(wrkMast);
+// if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
+ if (null == wrkMast) {
+ 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鏄剧ず鍣�");
+ workNoList.add(wrkNo);
// 缁勮鍛戒护
LedCommand ledCommand = new LedCommand();
- ledCommand.setWorkNo(wrkMast.getWrkNo());
+ ledCommand.setWorkNo(wrkNo);
+ ledCommand.setIoType(ioType);
// 鍑哄簱妯″紡
- switch (wrkMast.getIoType()) {
+ switch (ioType) {
+ case 1:
+ ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
+ break;
+ case 10:
+ ledCommand.setTitle("绌烘澘鍏ュ簱");
+ break;
case 101:
ledCommand.setTitle("鍏ㄦ澘鍑哄簱");
break;
@@ -817,40 +2142,160 @@
ledCommand.setTitle("绌烘澘鍑哄簱");
ledCommand.setEmptyMk(true);
break;
+ case 53:
+ ledCommand.setTitle("鎷f枡鍏ュ簱");
+ break;
+ case 57:
+ ledCommand.setTitle("鐩樼偣鍏ュ簱");
+ break;
+ case 54:
+ ledCommand.setTitle("骞舵澘鍏ュ簱");
+ break;
default:
- log.error("浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
+ News.error("" + mark + " - 1" + " - 浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkNo, ioType);
break;
}
- ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
- ledCommand.setStaNo(wrkMast.getStaNo());
- if (wrkMast.getIoType() != 110) {
- List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
- wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMatnr(), wrkDetl.getAnfme())));
+ ledCommand.setSourceLocNo(sourceLocNo);
+ ledCommand.setLocNo(locNo);
+ ledCommand.setStaNo(targetStaNo);
+ ledCommand.setBarcode(barcode);
+// ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
+ 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());
// 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
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(1, commands))) {
- log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+ 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) {
- 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け璐�");
+ }
}
}
@@ -863,36 +2308,753 @@
}
}
+ News.infoNoLog("" + mark + " - 0" + " - 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣ㄦ墽琛屽畬鎴�");
}
/**
* 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅
*/
- @Async
- public void ledReset() {
+ 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).clone();
- if (staProtocol == null) {continue;}
- if (staProtocol.getWorkNo() != 0) {
+ 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.getDevpPlcId());
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
// led鏄剧ず榛樿鍐呭
- if (!ledThread.isResetStatus() && reset) {
- if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
- log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+ 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鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅");
+ }
+
+ /**
+ * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堝叆搴撶増)
+ * tip锛氬悓姝�
+ */
+ @Transactional
+ public synchronized void moveLocForDeepLocPakin(CrnSlave crn, LocMast shallowLoc, WrkMast pakinWrkMast) {
+ LocMast loc = locMastService.selectById(pakinWrkMast.getLocNo());
+
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(0);
+ Date now = new Date();
+ // 淇濆瓨宸ヤ綔妗�
+ WrkMast wrkMast = new WrkMast();
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setIoTime(now);
+ wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ wrkMast.setIoPri(15D);
+ wrkMast.setCrnNo(crn.getId());
+ wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 婧愬簱浣�
+ wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅
+ wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘
+ wrkMast.setBarcode(shallowLoc.getBarcode()); // 鎵樼洏鐮�
+ wrkMast.setLinkMis("N");
+ wrkMast.setCtnNo("Y"); // 鍏ュ簱闃诲搴撲綅绉昏浆鏍囪
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiTime(now);
+ int res = wrkMastMapper.insert(wrkMast);
+ if (res == 0) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+ // 宸ヤ綔妗f槑缁嗕繚瀛�
+ if (shallowLoc.getLocSts().equals("F")) {
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
+ for (LocDetl locDetl : locDetls) {
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(locDetl);
+ wrkDetl.setWrkNo(workNo);
+ wrkDetl.setIoTime(now);
+ wrkDetl.setAnfme(locDetl.getAnfme());
+// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setModiTime(now);
+ if (!wrkDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ }
+ }
+ // 淇敼婧愬簱浣嶇姸鎬�
+ if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) {
+ shallowLoc.setLocSts("S"); // S.鍏ュ簱棰勭害锛屽叆搴撻樆濉炲簱浣嶇Щ杞�
+ shallowLoc.setModiTime(now);
+ if (!locMastService.updateById(shallowLoc)) {
+ throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
+ }
+ } else {
+ throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�");
+ }
+// // 淇敼鐩爣搴撲綅鐘舵��
+// if (loc.getLocSts().equals("O")) {
+// loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+// loc.setModiTime(new Date());
+// if (!locMastService.updateById(loc)) {
+// throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+// }
+// } else {
+// throw new CoolException("绉昏浆澶辫触");
+// }
+ wrkMast.setLocNo(shallowLoc.getLocNo());
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ throw new CoolException("淇敼闃诲鍏ュ簱浠诲姟澶辫触");
+ }
+ }
+
+ /**
+ * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)
+ * tip锛氬悓姝�
+ */
+ 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());
+ LocMast loc = null;
+ 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);
+ if (!shallowLoc1.getLocSts().equals("O")) {
+ loc = null;
+ }
+ }
+ }
+ if (null != loc) {
+ break;
+ }
+ }
+ }
+ if (null == loc) {
+ for (Integer row : rows) {
+ if (Utils.isShallowLoc(slaveProperties, row)) {
+ 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")) {
+ loc = null;
+ }
+ }
+
+ if (null != loc) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (null == loc) {
+ News.error("" + mark + "moveLocForDeepLoc" + " - 1" + " - 鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo());
+ 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);
+ // 淇濆瓨宸ヤ綔妗�
+ WrkMast 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(shallowLoc.getLocNo()); // 婧愬簱浣�
+ wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅
+// wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘
+ wrkMast.setFullPlt(shallowLoc.getLocSts().equals("D") ? "N" : "Y"); // 婊℃澘
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘
+ wrkMast.setBarcode(shallowLoc.getBarcode()); // 鎵樼洏鐮�
+ wrkMast.setLinkMis("N");
+ wrkMast.setAppeTime(new Date());
+ wrkMast.setModiTime(new Date());
+ int res = wrkMastMapper.insert(wrkMast);
+ if (res == 0) {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 2" + " - 淇濆瓨宸ヤ綔妗eけ璐�");
+// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ return true;
+ }
+ // 宸ヤ綔妗f槑缁嗕繚瀛�
+ if (shallowLoc.getLocSts().equals("F")) {
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
+
+ for (LocDetl locDetl : locDetls) {
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(locDetl);
+ 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)) {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 3" + " - 淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+// throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ return true;
+ }
+ }
+ }
+ // 淇敼婧愬簱浣嶇姸鎬�
+ if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) {
+ shallowLoc.setLocSts("R"); // R.鍑哄簱棰勭害
+ shallowLoc.setModiTime(new Date());
+ if (!locMastService.updateById(shallowLoc)) {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 4" + " - 鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
+// throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
+ return true;
+ }
+ } else {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 5" + " - 婧愬簱浣嶅嚭搴撳け璐�");
+// throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�");
+ return true;
+ }
+ // 淇敼鐩爣搴撲綅鐘舵��
+ if (loc.getLocSts().equals("O")) {
+ loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+ loc.setModiTime(new Date());
+ if (!locMastService.updateById(loc)) {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 6" + " - 鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+// throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ return true;
+ }
+ } else {
+ News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 7" + " - 绉昏浆澶辫触");
+// throw new CoolException("绉昏浆澶辫触");
+ return true;
+ }
+ } catch (Exception e) {
+ News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e);
+ }
+ }
+
+
+ } catch (Exception e) {
+ News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e);
+// e.printStackTrace();
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ 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