From 61ceac3d348b5d2a58cba2bfde1002674368002e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 24 十二月 2020 16:54:14 +0800
Subject: [PATCH] #newVersion
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 143 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 119 insertions(+), 24 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 2972a72..1869f0d 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -5,7 +5,9 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
+import com.zy.asrs.domain.enums.WorkNoType;
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.*;
@@ -15,6 +17,7 @@
import com.zy.common.service.CommonService;
import com.zy.common.utils.CollectionUtils;
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.*;
@@ -28,7 +31,6 @@
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
-import com.zy.core.thread.DevpThread;
import com.zy.core.thread.LedThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -56,24 +58,6 @@
@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();
- }
- }
-
@Autowired
private CommonService commonService;
@Autowired
@@ -94,6 +78,10 @@
private BasDevpService basDevpService;
@Autowired
private LocDetlService locDetlService;
+ @Autowired
+ private BasErrLogService basErrLogService;
+ @Autowired
+ private BasCrnErrorMapper basCrnErrorMapper;
@Autowired
private JdbcTemplate jdbcTemplate;
@@ -140,11 +128,11 @@
}
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);
+ // 宸ヤ綔鍙�
+ int workNo = startupDto.getWorkNo();
// 鎻掑叆宸ヤ綔鏄庣粏妗�
wrkDetlService.createWorkDetail(workNo, waitPakins, barcode);
@@ -721,8 +709,115 @@
/**
* 鍫嗗灈鏈哄紓甯镐俊鎭褰�
*/
+ @Async
public void recCrnErr(){
+ 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) {
+ if (crnProtocol.getAlarm1() != null && crnProtocol.getAlarm1() > 0) {
+ WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo());
+ BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
+ 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(), // 鏉$爜
+ crnProtocol.getAlarm1().intValue(), // 寮傚父鐮�
+ crnError.getErrName(), // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "浠诲姟涓紓甯�" // 澶囨敞
+ );
+ if (!basErrLogService.insert(basErrLog)) {
+ log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), crnError.getErrName());
+ }
+ }
+ } else {
+ // 寮傚父淇
+ if (crnProtocol.getAlarm1() == null || crnProtocol.getAlarm1() == 0) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basErrLogService.updateById(latest)) {
+ log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ }
+ }
+ }
+ // 鏃犱换鍔�
+ } else {
+ BasErrLog latest = basErrLogService.findLatest(crn.getId());
+ // 鏈夊紓甯�
+ if (crnProtocol.getAlarm1() != null && crnProtocol.getAlarm1() > 0) {
+ // 璁板綍鏂板紓甯�
+ if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm1().intValue())) {
+ BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
+ BasErrLog basErrLog = new BasErrLog(
+ null, // 缂栧彿
+ null, // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ null, // 宸ヤ綔鐘舵��
+ null, // 鍏ュ嚭搴撶被鍨�
+ crn.getId(), // 鍫嗗灈鏈�
+ null, // plc
+ null, // 鐩爣搴撲綅
+ null, // 鐩爣绔�
+ null, // 婧愮珯
+ null, // 婧愬簱浣�
+ null, // 鏉$爜
+ crnProtocol.getAlarm1().intValue(), // 寮傚父鐮�
+ crnError.getErrName(), // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "鏃犱换鍔″紓甯�" // 澶囨敞
+ );
+ if (!basErrLogService.insert(basErrLog)) {
+ log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), crnError.getErrName());
+ }
+ }
+ // 鏃犲紓甯�
+ } else {
+ // 寮傚父淇
+ if (latest != null && latest.getStatus() == 1) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basErrLogService.updateById(latest)) {
+ log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ }
+ }
+ }
+ }
+ }
+ }
}
@@ -747,10 +842,10 @@
// 绔欑偣鏉′欢鍒ゆ柇
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);
+ // 宸ヤ綔鍙�
+ int workNo = startupDto.getWorkNo();
try {
// 鎻掑叆宸ヤ綔涓绘。
@@ -949,7 +1044,7 @@
String locNo = loc.getLocNo();
// 鑾峰彇宸ヤ綔鍙�
- int workNo = commonService.getWorkNo(0);
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
// 淇濆瓨宸ヤ綔妗�
WrkMast wrkMast = new WrkMast();
wrkMast.setWrkNo(workNo);
--
Gitblit v1.9.1