From 78e0773dba0613bf4fb18a20e0cef5086e1b834f Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 24 十二月 2020 10:37:21 +0800
Subject: [PATCH] #newVersion
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 1 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..ef829aa 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -6,6 +6,7 @@
import com.core.common.Cools;
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.*;
@@ -28,7 +29,7 @@
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.DevpThread;
import com.zy.core.thread.LedThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -94,6 +95,10 @@
private BasDevpService basDevpService;
@Autowired
private LocDetlService locDetlService;
+ @Autowired
+ private BasErrLogService basErrLogService;
+ @Autowired
+ private BasCrnErrorMapper basCrnErrorMapper;
@Autowired
private JdbcTemplate jdbcTemplate;
@@ -721,8 +726,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());
+ }
+ }
+ }
+ }
+ }
+ }
}
--
Gitblit v1.9.1