From 28a7821e43bd5763739fe67384cfea6693b3500b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 08 九月 2020 13:19:26 +0800
Subject: [PATCH] Merge branches 'gdwcs' and 'jswcs' of https://gitee.com/luxiaotao1123/zy-wcs into jswcs
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 41cf5bf..dc5ff4a 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -9,8 +9,10 @@
import com.zy.asrs.mapper.WaitPakinMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.*;
+import com.zy.common.model.MatDto;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
+import com.zy.common.utils.CollectionUtils;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
@@ -19,12 +21,14 @@
import com.zy.core.model.LedSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
+import com.zy.core.model.command.LedCommand;
import com.zy.core.model.protocol.CrnProtocol;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -32,8 +36,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -152,12 +155,10 @@
staProtocol.setWorkNo((short) workNo);
staProtocol.setStaNo(startupDto.getStaNo().shortValue());
staProtocol.setPakMk(false);
- staProtocol.setInreq1(false);
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- staProtocol.setPakMk(false);
}
@@ -203,11 +204,11 @@
// 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
+ staProtocol.setPakMk(false);
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- staProtocol.setPakMk(false);
}
@@ -229,7 +230,7 @@
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
if (staProtocol == null) { continue; }
- if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInreq1()
+ if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
&& staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()){
WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo().intValue());
if (wrkMast == null) {
@@ -282,7 +283,6 @@
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
staProtocol.setPakMk(false);
- staProtocol.setInreq1(false);
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
@@ -717,12 +717,13 @@
// 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
staProtocol.setWorkNo((short) workNo);
staProtocol.setStaNo(startupDto.getStaNo().shortValue());
+ staProtocol.setPakMk(false);
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- staProtocol.setPakMk(false);
+
}
@@ -738,17 +739,53 @@
for (LedSlave led : slaveProperties.getLed()) {
// 鑾峰彇杈撻�佺嚎plc绾跨▼
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
+ // 鍛戒护闆嗗悎
+ List<LedCommand> commands = new ArrayList<>();
+ // 宸ヤ綔妗i泦鍚�
+ List<WrkMast> wrkMasts = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
StaProtocol staProtocol = devpThread.getStation().get(staNo);
if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo()) { continue; }
// 鑾峰彇宸ヤ綔妗f暟鎹�
WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
-
-
-
+ if (wrkMast.getWrkSts() == 14L || wrkMast.getWrkSts() == 15L) {
+ wrkMasts.add(wrkMast);
+ // 娣诲姞鍛戒护
+ List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
+ LedCommand ledCommand = new LedCommand();
+ ledCommand.setWorkNo(wrkMast.getWrkNo());
+ ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
+ ledCommand.setStaNo(wrkMast.getStaNo());
+ wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMatnr(), wrkDetl.getAnfme())));
+ commands.add(ledCommand);
+ }
+ }
+ Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
+ // 鑾峰彇LED绾跨▼
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
+ // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
+ if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
+ continue;
+ }
+ // 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
+ if (!commands.isEmpty()) {
+ if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
+ continue;
+ }
}
+ // 淇敼涓绘。led鏍囪
+ for (WrkMast wrkMast : wrkMasts) {
+ wrkMast.setOveMk("Y");
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
+ }
+ }
+
+ // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚�
+ ledThread.setWorkNos(workNos);
}
}
--
Gitblit v1.9.1