|
@@ -1,15 +1,18 @@
|
|
|
package com.sckj.iron.socketio;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.corundumstudio.socketio.SocketIOClient;
|
|
|
import com.corundumstudio.socketio.annotation.OnEvent;
|
|
|
import com.google.common.eventbus.Subscribe;
|
|
|
import com.sckj.common.eventbus.EventListener;
|
|
|
import com.sckj.common.socketio.SocketUtil;
|
|
|
import com.sckj.iron.dto.IronStepDTO;
|
|
|
-import com.sckj.iron.service.impl.TIronStepServiceImpl;
|
|
|
-import com.sckj.iron.vo.IronOperataion;
|
|
|
+import com.sckj.iron.entity.TIronData;
|
|
|
+import com.sckj.iron.entity.TIronParam;
|
|
|
+import com.sckj.iron.service.impl.*;
|
|
|
import com.sckj.iron.vo.IronStepVO;
|
|
|
+import com.sckj.opc.dto.L2Data;
|
|
|
import com.sckj.opc.entity.OPCData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
@@ -19,11 +22,11 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import java.util.stream.Stream;
|
|
|
+import java.util.Timer;
|
|
|
+import java.util.TimerTask;
|
|
|
|
|
|
/**
|
|
|
* @Author feng
|
|
@@ -34,31 +37,26 @@ import java.util.stream.Stream;
|
|
|
@Slf4j
|
|
|
public class DeviceEventListener extends EventListener {
|
|
|
|
|
|
- private static final String TAG1 = "TAG1";
|
|
|
- private static final String TAG2 = "TAG2";
|
|
|
- private static final String TAG3 = "TAG3";
|
|
|
- private static final String TAG4 = "TAG4";
|
|
|
- private static final String TAG5 = "TAG5";
|
|
|
- private static final String TAG6 = "TAG6";
|
|
|
- private static final String TAG7 = "TAG7";
|
|
|
- private static final String TAG8 = "TAG8";
|
|
|
- private static final String TAG9 = "TAG9";
|
|
|
- private static final String TAG10 = "TAG10";
|
|
|
- private static final String TAG11 = "TAG11";
|
|
|
- private static final String TAG12 = "TAG12";
|
|
|
- private static final String TAG13 = "TAG13";
|
|
|
- private static final String TAG14 = "TAG14";
|
|
|
- private static final String TAG15 = "TAG15";
|
|
|
-
|
|
|
+ //步骤数据
|
|
|
@Resource
|
|
|
TIronStepServiceImpl ironStepService;
|
|
|
|
|
|
- @Deprecated
|
|
|
- private Map<String, IronOperataion> operateMap = new ConcurrentHashMap<>();
|
|
|
+ //出铁数据
|
|
|
+ @Resource
|
|
|
+ TIronDataServiceImpl ironDataService;
|
|
|
+
|
|
|
+ //出铁后
|
|
|
+ @Resource
|
|
|
+ TIronAfterServiceImpl ironAfterService;
|
|
|
+
|
|
|
+ //堵口后
|
|
|
+ @Resource
|
|
|
+ TIronBlockServiceImpl ironBlockService;
|
|
|
|
|
|
- private Map<SocketIOClient, IronOperataion> operateMap2 = new ConcurrentHashMap<>();
|
|
|
+ //参数
|
|
|
+ @Resource
|
|
|
+ TIronParamServiceImpl ironParamService;
|
|
|
|
|
|
- private Map<SocketIOClient, List<IronStepDTO>> operateMap3 = new ConcurrentHashMap<>();
|
|
|
|
|
|
// 1.创建表达式解析器
|
|
|
private SpelExpressionParser parser = new SpelExpressionParser();
|
|
@@ -66,674 +64,326 @@ public class DeviceEventListener extends EventListener {
|
|
|
// 2.创建变量上下文,设置变量
|
|
|
private StandardEvaluationContext ctx = new StandardEvaluationContext();
|
|
|
|
|
|
+ //出铁步骤
|
|
|
private List<IronStepVO> mSteps;
|
|
|
|
|
|
+ private static final String NODE = "node";
|
|
|
+
|
|
|
+ //定时器,用于铁口开口超时记录
|
|
|
+ private Timer timer = new Timer();
|
|
|
+
|
|
|
+ private List<TIronData> oldIronDataList;
|
|
|
+
|
|
|
+ //是否出铁中
|
|
|
+ private boolean ironLoading = false;
|
|
|
+
|
|
|
+ //出铁标记
|
|
|
+ private static final String IRON_OPERATE_TAG = "AOD25606.PV";
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
- mSteps = ironStepService.getSteps();
|
|
|
+ mSteps = ironStepService.getTreeSteps();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /***
|
|
|
+ * L1数据项
|
|
|
+ * @param opcData
|
|
|
+ */
|
|
|
@Subscribe
|
|
|
public void onMessageEvent(OPCData opcData) {
|
|
|
- if (SocketUtil.connectMap.isEmpty()) {
|
|
|
+ if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
+ //出铁操作
|
|
|
+ operate(opcData);
|
|
|
+ //实时数据
|
|
|
|
|
|
- operate3(opcData);
|
|
|
-
|
|
|
-// for (Map.Entry<SocketIOClient, String> entry : SocketUtil.clientUserIds.entrySet()) {
|
|
|
-// //根据在线用户初始化炼铁操作数据
|
|
|
-// if (!operateMap2.containsKey(entry.getKey())) {
|
|
|
-// operateMap2.put(entry.getKey(), new IronOperataion());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// for (Map.Entry<SocketIOClient, String> entry : SocketUtil.clientUserIds.entrySet()) {
|
|
|
-// //根据在线用户初始化炼铁操作数据
|
|
|
-// if (!operateMap3.containsKey(entry.getKey())) {
|
|
|
-// operateMap3.put(entry.getKey(), ironStepService.getSteps());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// for (Map.Entry<SocketIOClient, List<IronStepDTO>> entry : operateMap3.entrySet()) {
|
|
|
-// //根据公共数据和私有数据进行填充
|
|
|
-// List<IronStepDTO> ironOperate = entry.getValue();
|
|
|
-//// if (!operateMap3.containsKey(entry.getKey())) {
|
|
|
-//// operateMap3.put()
|
|
|
-//// }
|
|
|
-//
|
|
|
-// operate3(ironOperate, opcData, entry.getKey());
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// for (Map.Entry<SocketIOClient, IronOperataion> entry : operateMap2.entrySet()) {
|
|
|
-// //根据公共数据和私有数据进行填充
|
|
|
-// IronOperataion ironOperate = entry.getValue();
|
|
|
-// operate2(ironOperate, opcData, entry.getKey());
|
|
|
-// }
|
|
|
-// for (Map.Entry<String, SocketIOClient> entry : SocketUtil.connectMap.entrySet()) {
|
|
|
-// //根据在线用户初始化炼铁操作数据
|
|
|
-// if (!operateMap.containsKey(entry.getKey())) {
|
|
|
-// operateMap.put(entry.getKey(), new IronOperataion());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// for (Map.Entry<String, IronOperataion> entry : operateMap.entrySet()) {
|
|
|
-// //根据公共数据和私有数据进行填充
|
|
|
-// IronOperataion ironOperate = entry.getValue();
|
|
|
-// operate(ironOperate, opcData, entry.getKey());
|
|
|
-// }
|
|
|
+ //趋势数据
|
|
|
}
|
|
|
|
|
|
- @Deprecated
|
|
|
- private void operate(IronOperataion ironOperate, OPCData opcData, String userId) {
|
|
|
- String identifier = opcData.getPointName();
|
|
|
- try {
|
|
|
- identifier = identifier.split("\\.")[2];
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return;
|
|
|
- }
|
|
|
- Object data = opcData.getData();
|
|
|
-
|
|
|
- //出铁
|
|
|
- if (TAG1.equals(identifier)
|
|
|
- || TAG2.equals(identifier)
|
|
|
- || TAG3.equals(identifier)
|
|
|
- || TAG4.equals(identifier)
|
|
|
- || TAG5.equals(identifier)
|
|
|
- || TAG6.equals(identifier)
|
|
|
- || TAG7.equals(identifier)
|
|
|
- || TAG8.equals(identifier)
|
|
|
- || TAG9.equals(identifier)
|
|
|
- || TAG10.equals(identifier)
|
|
|
- ) {
|
|
|
- //ylgcdw 鱼雷罐车到位
|
|
|
- if (identifier.equals(TAG1)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setYlgcdw("0");
|
|
|
- } else {
|
|
|
- ironOperate.setYlgcdw("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //tbxtzc 铁摆系统正常
|
|
|
- if (identifier.equals(TAG2)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setTbxtzc("0");
|
|
|
- } else {
|
|
|
- ironOperate.setTbxtzc("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //npkkjzbwb 泥炮、开口机准备完毕
|
|
|
- if (identifier.equals(TAG3)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setNpkkjzbwb("0");
|
|
|
- } else {
|
|
|
- ironOperate.setNpkkjzbwb("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //炉前准备
|
|
|
- if ("1".equals(ironOperate.getYlgcdw())
|
|
|
- && "1".equals(ironOperate.getTbxtzc())
|
|
|
- && "1".equals(ironOperate.getNpkkjzbwb())
|
|
|
- && "1".equals(ironOperate.getRydw())
|
|
|
- ) {
|
|
|
- ironOperate.setLqzb("1");
|
|
|
- } else {
|
|
|
- log.info("lqzb failed => ylgcdw:{},tbxtzc:{},npkkjzbwb:{},rydw:{}", ironOperate.getYlgcdw(), ironOperate.getTbxtzc(), ironOperate.getNpkkjzbwb(), ironOperate.getRydw());
|
|
|
-
|
|
|
- ironOperate.setRydw("0");
|
|
|
- ironOperate.setLqzb("0");
|
|
|
-
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- ironOperate.setWwtj("0");
|
|
|
-
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
-
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-// if (identifier.contains(TAG4)) {
|
|
|
-// ironOperate.setRydw(data);
|
|
|
-// }
|
|
|
-
|
|
|
- //水闸泵已开启,水闸槽水量正常
|
|
|
- if (identifier.equals(TAG4)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setSzbykq("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //除尘开启出铁模式
|
|
|
- if (identifier.equals(TAG5)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtmskq("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //主沟盖板吊装机处于待机位
|
|
|
- if (identifier.equals(TAG6)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- } else {
|
|
|
- ironOperate.setZggbdj("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //外围条件
|
|
|
- if ("1".equals(ironOperate.getSzbykq())
|
|
|
- && "1".equals(ironOperate.getCtmskq())
|
|
|
- && "1".equals(ironOperate.getZggbdj())
|
|
|
- ) {
|
|
|
- ironOperate.setWwtj("1");
|
|
|
- } else {
|
|
|
- log.info("wwtj failed => szbykq:{},ctmskq:{},zggbdj:{}", ironOperate.getSzbykq(), ironOperate.getCtmskq(), ironOperate.getZggbdj());
|
|
|
-
|
|
|
- ironOperate.setWwtj("0");
|
|
|
-
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
-
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ("0".equals(ironOperate.getLqsqct())) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //高炉运行情况
|
|
|
- if (identifier.equals(TAG7)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- } else {
|
|
|
- ironOperate.setGlyxqk("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //理论铁量、铁铁差计算
|
|
|
- if (identifier.equals(TAG8)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- } else {
|
|
|
- ironOperate.setTlcjs("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //出铁口模式
|
|
|
- if (identifier.equals(TAG9)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtfs("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //炉内出铁条件
|
|
|
- if ("1".equals(ironOperate.getLqsqct())
|
|
|
- && "1".equals(ironOperate.getGlyxqk())
|
|
|
- && "1".equals(ironOperate.getTlcjs())
|
|
|
- && "1".equals(ironOperate.getCtfs())
|
|
|
- ) {
|
|
|
- ironOperate.setLncttj("1");
|
|
|
- } else {
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- log.info("lncttj failed => glyxqk:{},tlcjs:{},ctkms:{}", ironOperate.getGlyxqk(), ironOperate.getTlcjs(), ironOperate.getCtfs());
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if ("1".equals(ironOperate.getYpqrct())) {
|
|
|
- ironOperate.setLqctcz("1");
|
|
|
- } else {
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
- }
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- }
|
|
|
-
|
|
|
- //glyxqk 高炉运行情况
|
|
|
- //tlcjs 理论铁量、铁铁差计算
|
|
|
- //ctkms 出铁口模式
|
|
|
-
|
|
|
- //趋势
|
|
|
- if (Stream.of("TAG5", "TAG6", "TAG7", "TAG8").anyMatch(identifier::contains)) {
|
|
|
- // PushData.sendToTrend(JSON.toJSONString(opcData));
|
|
|
- //铁水成分
|
|
|
- //铁水流速
|
|
|
- //铁水流量
|
|
|
- //铁水温度
|
|
|
+ /***
|
|
|
+ * L2数据项
|
|
|
+ * @param l2Data
|
|
|
+ */
|
|
|
+ @Subscribe
|
|
|
+ public void onL2MessageEvent(L2Data l2Data) {
|
|
|
+ if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ //出铁操作
|
|
|
|
|
|
//实时数据
|
|
|
- if (Stream.of("TAG9", "TAG10").anyMatch(identifier::contains)) {
|
|
|
-// PushData.sendToRealtime(JSON.toJSONString(opcData));
|
|
|
- //除铁中
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- }
|
|
|
+
|
|
|
+ //趋势数据
|
|
|
}
|
|
|
|
|
|
- private void operate2(IronOperataion ironOperate, OPCData opcData, SocketIOClient socketIOClient) {
|
|
|
- String identifier = opcData.getPointName();
|
|
|
- try {
|
|
|
- identifier = identifier.split("\\.")[2];
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+
|
|
|
+ private void operate(OPCData opcData) {
|
|
|
+ if (ObjectUtils.isEmpty(opcData)) {
|
|
|
return;
|
|
|
}
|
|
|
+ String pointName = opcData.getPointName();
|
|
|
Object data = opcData.getData();
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ //log.info("nodetype:{},pointname:{},opc pointname:{}",stepDTO.getNodeType(),stepDTO.getPointName(),pointName);
|
|
|
+ if (NODE.equalsIgnoreCase(stepDTO.getNodeType())) {
|
|
|
+ //处理子项
|
|
|
+ for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
+ //plc的point和step的point一致
|
|
|
+ if (Objects.equals(child.getPointName(), pointName)) {
|
|
|
+ //3.创建变量上下文,设置变量
|
|
|
+ child.setData(data);
|
|
|
+ //log.info("pointName:{},data:{},tj:{},result:{}", pointName, data, child.getStepTj(), result);
|
|
|
+ }
|
|
|
+// else {
|
|
|
+// if (ObjectUtils.isNotEmpty(child.getData())) {
|
|
|
+// ctx.setVariable(child.getIdentifier(), child.getData());
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- //出铁
|
|
|
- if (TAG1.equals(identifier)
|
|
|
- || TAG2.equals(identifier)
|
|
|
- || TAG3.equals(identifier)
|
|
|
- || TAG4.equals(identifier)
|
|
|
- || TAG5.equals(identifier)
|
|
|
- || TAG6.equals(identifier)
|
|
|
- || TAG7.equals(identifier)
|
|
|
- || TAG8.equals(identifier)
|
|
|
- || TAG9.equals(identifier)
|
|
|
- || TAG10.equals(identifier)
|
|
|
- ) {
|
|
|
- //ylgcdw 鱼雷罐车到位
|
|
|
- if (identifier.equals(TAG1)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setYlgcdw("0");
|
|
|
- } else {
|
|
|
- ironOperate.setYlgcdw("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //tbxtzc 铁摆系统正常
|
|
|
- if (identifier.equals(TAG2)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setTbxtzc("0");
|
|
|
- } else {
|
|
|
- ironOperate.setTbxtzc("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //npkkjzbwb 泥炮、开口机准备完毕
|
|
|
- if (identifier.equals(TAG3)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setNpkkjzbwb("0");
|
|
|
- } else {
|
|
|
- ironOperate.setNpkkjzbwb("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //炉前准备
|
|
|
- if ("1".equals(ironOperate.getYlgcdw())
|
|
|
- && "1".equals(ironOperate.getTbxtzc())
|
|
|
- && "1".equals(ironOperate.getNpkkjzbwb())
|
|
|
- && "1".equals(ironOperate.getRydw())
|
|
|
- ) {
|
|
|
- ironOperate.setLqzb("1");
|
|
|
- } else {
|
|
|
- log.info("lqzb failed => ylgcdw:{},tbxtzc:{},npkkjzbwb:{},rydw:{}", ironOperate.getYlgcdw(), ironOperate.getTbxtzc(), ironOperate.getNpkkjzbwb(), ironOperate.getRydw());
|
|
|
-
|
|
|
- ironOperate.setRydw("0");
|
|
|
- ironOperate.setLqzb("0");
|
|
|
-
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- ironOperate.setWwtj("0");
|
|
|
-
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
-
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-// if (identifier.contains(TAG4)) {
|
|
|
-// ironOperate.setRydw(data);
|
|
|
-// }
|
|
|
-
|
|
|
- //水闸泵已开启,水闸槽水量正常
|
|
|
- if (identifier.equals(TAG4)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setSzbykq("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //除尘开启出铁模式
|
|
|
- if (identifier.equals(TAG5)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtmskq("1");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //主沟盖板吊装机处于待机位
|
|
|
- if (identifier.equals(TAG6)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- } else {
|
|
|
- ironOperate.setZggbdj("1");
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //外围条件
|
|
|
- if ("1".equals(ironOperate.getSzbykq())
|
|
|
- && "1".equals(ironOperate.getCtmskq())
|
|
|
- && "1".equals(ironOperate.getZggbdj())
|
|
|
- ) {
|
|
|
- ironOperate.setWwtj("1");
|
|
|
- } else {
|
|
|
- log.info("wwtj failed => szbykq:{},ctmskq:{},zggbdj:{}", ironOperate.getSzbykq(), ironOperate.getCtmskq(), ironOperate.getZggbdj());
|
|
|
-
|
|
|
- ironOperate.setWwtj("0");
|
|
|
-
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
-
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
-
|
|
|
- return;
|
|
|
+ setStepResult(mSteps);
|
|
|
|
|
|
- }
|
|
|
+// log.info("==========================================");
|
|
|
+// log.info("steps after:{}", JSON.toJSONString(mSteps));
|
|
|
+// log.info("==========================================");
|
|
|
|
|
|
- if ("0".equals(ironOperate.getLqsqct())) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
+ ironReady(opcData);
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
+ PushData.send2Operation(mSteps, ironLoading);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- //高炉运行情况
|
|
|
- if (identifier.equals(TAG7)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- } else {
|
|
|
- ironOperate.setGlyxqk("1");
|
|
|
+ //计算每步结果
|
|
|
+ private void setStepResult(List<IronStepVO> mSteps) {
|
|
|
+ boolean foundFalsePass = false;
|
|
|
+ //发现第一个pass是false,后续都为false,包括父项和子项
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
+ //子项验证是否通过
|
|
|
+ validateStepTjPass(child);
|
|
|
+ if (!foundFalsePass && 0 == child.getPassResult()) {
|
|
|
+ foundFalsePass = true;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //理论铁量、铁铁差计算
|
|
|
- if (identifier.equals(TAG8)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- } else {
|
|
|
- ironOperate.setTlcjs("1");
|
|
|
+ //子项
|
|
|
+ if (foundFalsePass) {
|
|
|
+ child.setPassResult(0);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //出铁口模式
|
|
|
- if (identifier.equals(TAG9)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtfs("1");
|
|
|
- }
|
|
|
+ //父项
|
|
|
+ validateStepTjPass(stepDTO);
|
|
|
+ //父项
|
|
|
+ if (foundFalsePass) {
|
|
|
+ stepDTO.setPassResult(0);
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //炉内出铁条件
|
|
|
- if ("1".equals(ironOperate.getLqsqct())
|
|
|
- && "1".equals(ironOperate.getGlyxqk())
|
|
|
- && "1".equals(ironOperate.getTlcjs())
|
|
|
- && "1".equals(ironOperate.getCtfs())
|
|
|
- ) {
|
|
|
- ironOperate.setLqsqct(ironOperate.getLqsqct());
|
|
|
- ironOperate.setLncttj("1");
|
|
|
- } else {
|
|
|
- ironOperate.setLncttj("0");
|
|
|
-
|
|
|
- log.info("lncttj failed => glyxqk:{},tlcjs:{},ctkms:{}", ironOperate.getGlyxqk(), ironOperate.getTlcjs(), ironOperate.getCtfs());
|
|
|
+ //锅炉运行情况
|
|
|
+ private static final String glyxqk = "glyxqk";
|
|
|
+ //预判和确认出铁
|
|
|
+ private static final String ypqrct = "ypqrct";
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ //理论铁量、铁量差计算
|
|
|
+ private static final String tlcjs = "tlcjs";
|
|
|
+ //出铁方式(单铁口 双铁口)
|
|
|
+ private static final String ctfs = "ctfs";
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
+ private void ironReady(OPCData opcData) {
|
|
|
+ //通过“预判和确认出铁”标记开始出铁
|
|
|
+ boolean isReady = false;
|
|
|
|
|
|
- if ("1".equals(ironOperate.getYpqrct())) {
|
|
|
- ironOperate.setLqctcz("1");
|
|
|
- } else {
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ if (ypqrct.equalsIgnoreCase(stepDTO.getIdentifier()) && 1 == stepDTO.getPassResult()) {
|
|
|
+ isReady = true;
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
}
|
|
|
|
|
|
- //glyxqk 高炉运行情况
|
|
|
- //tlcjs 理论铁量、铁铁差计算
|
|
|
- //ctkms 出铁口模式
|
|
|
-
|
|
|
- //趋势
|
|
|
- if (Stream.of("TAG5", "TAG6", "TAG7", "TAG8").anyMatch(identifier::contains)) {
|
|
|
- // PushData.sendToTrend(JSON.toJSONString(opcData));
|
|
|
- //铁水成分
|
|
|
- //铁水流速
|
|
|
- //铁水流量
|
|
|
- //铁水温度
|
|
|
- }
|
|
|
+ //炉前在接受到炉内出铁要求后,10分钟内打开铁口,未打开系统告警并记录
|
|
|
+ if (isReady) {
|
|
|
+ TimerTask task = new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ System.out.println("倒计时结束!10分钟已到。");
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
+ // 打开系统告警并记录
|
|
|
+ PushData.send2Warn("warn");
|
|
|
+ log.info("准备出铁但是未及时出铁口,此处数据库记录");
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- //实时数据
|
|
|
- if (Stream.of("TAG9", "TAG10").anyMatch(identifier::contains)) {
|
|
|
-// PushData.sendToRealtime(JSON.toJSONString(opcData));
|
|
|
- //除铁中
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
+ // 倒计时10分钟(600秒)
|
|
|
+ long delay = 10 * 60 * 1000; // 10分钟转换为毫秒
|
|
|
+ // 在指定延迟后执行任务
|
|
|
+ timer.schedule(task, delay);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- private void operate3(OPCData opcData) {
|
|
|
- String pointName = opcData.getPointName();
|
|
|
- Object data = opcData.getData();
|
|
|
+ //根据PLC订阅的数据,AOD25606.PV=1为出铁中,AOD25606.PV=0出铁结束的信号,进行判断
|
|
|
+ //为1表示开始出铁,此时如果未超过10分钟,就取消定时器
|
|
|
+ //出铁结束
|
|
|
+ if (IRON_OPERATE_TAG.equalsIgnoreCase(opcData.getPointName())) {
|
|
|
|
|
|
- for (IronStepVO stepDTO : mSteps) {
|
|
|
- //log.info("nodetype:{},pointname:{},opc pointname:{}",stepDTO.getNodeType(),stepDTO.getPointName(),pointName);
|
|
|
- if ("node".equalsIgnoreCase(stepDTO.getNodeType())) {
|
|
|
- //处理子项
|
|
|
- for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
- if (Objects.equals(child.getPointName(), pointName)) {
|
|
|
- //3.创建变量上下文,设置变量
|
|
|
- ctx.setVariable(child.getIdentifier(), data);
|
|
|
- child.setData(data);
|
|
|
-
|
|
|
- boolean result = false;
|
|
|
-
|
|
|
- if (ObjectUtils.isNotEmpty(child.getStepTj())) {
|
|
|
- try {
|
|
|
- result = parser.parseExpression(child.getStepTj()).getValue(ctx, Boolean.class);
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ //1:出铁中
|
|
|
+ //0:出铁结束
|
|
|
+ ironLoading = "1".equals(opcData.getData());
|
|
|
|
|
|
- child.setPass(result);
|
|
|
-
|
|
|
- //log.info("pointName:{},data:{},tj:{},result:{}", pointName, data, child.getStepTj(), result);
|
|
|
- }
|
|
|
- }
|
|
|
+ if ("0".equals(opcData.getData())) {
|
|
|
try {
|
|
|
- boolean result = false;
|
|
|
- if (ObjectUtils.isNotEmpty(stepDTO.getStepTj())) {
|
|
|
- try {
|
|
|
- result = parser.parseExpression(stepDTO.getStepTj()).getValue(ctx, Boolean.class);
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- stepDTO.setPass(result);
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
} catch (Exception e) {
|
|
|
- stepDTO.setPass(false);
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ recordAfter();
|
|
|
+ recordBlock();
|
|
|
|
|
|
+ //出铁结束后,查询最近两次的数据
|
|
|
+ LambdaQueryWrapper<TIronData> queryWrapper = new QueryWrapper<TIronData>().lambda().orderByDesc(TIronData::getCtcsbh);
|
|
|
+ oldIronDataList = ironDataService.list(queryWrapper);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- log.info("==========================================");
|
|
|
- //log.info("steps before:{}", JSON.toJSONString(mSteps));
|
|
|
- log.info("==========================================");
|
|
|
-
|
|
|
- boolean foundFalsePass = false;
|
|
|
-
|
|
|
- //发现第一个pass是false,后续的手动操作都为false,包括父项和子项
|
|
|
- for (IronStepVO stepDTO : mSteps) {
|
|
|
- for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
- if (!foundFalsePass && !child.isPass()) {
|
|
|
- foundFalsePass = true;
|
|
|
- }
|
|
|
- if (foundFalsePass) {
|
|
|
- child.setPass(false);
|
|
|
+ /***
|
|
|
+ * 判断是否通过
|
|
|
+ * @param stepVO
|
|
|
+ */
|
|
|
+ private void validateStepTjPass(IronStepVO stepVO) {
|
|
|
+ ctx.setVariable(stepVO.getIdentifier(), stepVO.getData());
|
|
|
+ if (ObjectUtils.isNotEmpty(stepVO.getStepTj())) {
|
|
|
+ boolean result = false;
|
|
|
+ try {
|
|
|
+ result = parser.parseExpression(stepVO.getStepTj()).getValue(ctx, Boolean.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ stepVO.setPassResult(result ? 1 : 0);
|
|
|
+ } else {
|
|
|
+ //stepTj为空
|
|
|
+ //理论铁量、铁量差计算
|
|
|
+ //出铁方式(单铁口 双铁口)
|
|
|
+ if (tlcjs.equalsIgnoreCase(stepVO.getIdentifier())
|
|
|
+ || ctfs.equalsIgnoreCase(stepVO.getIdentifier())
|
|
|
+ ) {
|
|
|
+ for (int i = 0, size = mSteps.size(); i < size; i++) {
|
|
|
+ IronStepVO ironStepVO = mSteps.get(i);
|
|
|
+ for (int j = 0, childSize = ironStepVO.getChilds().size(); j < childSize; j++) {
|
|
|
+ IronStepVO child = ironStepVO.getChilds().get(j);
|
|
|
+ if (tlcjs.equalsIgnoreCase(child.getIdentifier())) {
|
|
|
+ IronStepVO beforeItem = ironStepVO.getChilds().get(j - 1);
|
|
|
+ if (1 == beforeItem.getPassResult()) {
|
|
|
+ TIronParam ironParam = ironParamService.lambdaQuery().last("limit 1").one();
|
|
|
+ oldIronDataList = ironDataService.lambdaQuery().orderByDesc(TIronData::getCtcsbh).last("limit 2").list();
|
|
|
+ if (ObjectUtils.isNotEmpty(oldIronDataList)) {
|
|
|
+ //处理理论铁量、铁量差计算
|
|
|
+ //出铁方式(单铁口 双铁口)
|
|
|
+ String ctl_append = "";
|
|
|
+ for (TIronData tIronData : oldIronDataList) {
|
|
|
+ String ctl = tIronData.getCtl();
|
|
|
+ ctl_append += ctl + ",";
|
|
|
+ }
|
|
|
+ child.setData(ctl_append);
|
|
|
+ child.setPassResult(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (ctfs.equalsIgnoreCase(child.getIdentifier())) {
|
|
|
+ IronStepVO beforeItem = ironStepVO.getChilds().get(j - 1);
|
|
|
+ if (1 == beforeItem.getPassResult()) {
|
|
|
+ String[] split = beforeItem.getData().toString().split(",");
|
|
|
+ if (ObjectUtils.isNotEmpty(split)) {
|
|
|
+ boolean ismanzu = true;
|
|
|
+ child.setData(2);
|
|
|
+ child.setPassResult(1);
|
|
|
+ for (String ctl : split) {
|
|
|
+ Float float_num = Float.valueOf(ctl);
|
|
|
+ if (float_num < 200) {
|
|
|
+ child.setData(1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (foundFalsePass) {
|
|
|
- stepDTO.setPass(false);
|
|
|
- }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- log.info("==========================================");
|
|
|
- log.info("steps after:{}", JSON.toJSONString(mSteps));
|
|
|
- log.info("==========================================");
|
|
|
-
|
|
|
+ //出铁后,记录炉次、开口时间、鱼雷罐车车号、铁口深度、铁水流速
|
|
|
+ private void recordAfter() {
|
|
|
+ ironAfterService.add(null);
|
|
|
+ }
|
|
|
|
|
|
- PushData.send2Operation(mSteps);
|
|
|
+ //堵口后,记录堵口时间、出铁量,打泥量、是否喷溅、是否跑泥
|
|
|
+ private void recordBlock() {
|
|
|
+ ironBlockService.add(null);
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * 用户端点击触发
|
|
|
+ * @param client
|
|
|
+ * @param message
|
|
|
+ */
|
|
|
@OnEvent(value = PushData.IRON_CONFIRM)
|
|
|
public void confirmIron(SocketIOClient client, IronStepDTO message) {
|
|
|
- if (ObjectUtils.isEmpty(message) || ObjectUtils.isEmpty(client)) {
|
|
|
+ String userId;
|
|
|
+ if (ObjectUtils.isEmpty(client) || ObjectUtils.isEmpty(userId = SocketUtil.clientUserIds.get(client))) {
|
|
|
+ log.info("该客户已下线");
|
|
|
+ PushData.send2Operation("该客户已下线", false);
|
|
|
return;
|
|
|
}
|
|
|
- log.info("---> {}", SocketUtil.clientUserIds.get(client));
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(message)) {
|
|
|
+ log.info("请求数据为空");
|
|
|
+ PushData.send2Operation("请求数据为空", false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ log.info("--->userId : {}", userId);
|
|
|
for (IronStepVO stepDTO : mSteps) {
|
|
|
for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
- if (child.getStepId().equals(message.getStepId())) {
|
|
|
- ctx.setVariable(child.getIdentifier(), message.getData());
|
|
|
- child.setPass(message.isPass());
|
|
|
- PushData.send2Operation(mSteps);
|
|
|
+ if (validateUserData(message, userId, child)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ if (validateUserData(message, userId, stepDTO)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private boolean validateUserData(IronStepDTO message, String userId, IronStepVO stepDTO) {
|
|
|
+ if (stepDTO.getStepId().equals(message.getStepId())) {
|
|
|
+ stepDTO.setData(message.getData());
|
|
|
+ setStepResult(mSteps);
|
|
|
+ PushData.send2Operation(mSteps, ironLoading);
|
|
|
+ //这里手动记录时间
|
|
|
+ log.info("userId:{},stepId:{},identifier:{},data:{},pass:{}", userId, message.getStepId(), message.getIdentifier(), message.getData(), message.isPass());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/***
|
|
|
* 数据库更改后调用接口刷新步骤
|
|
|
- * @param steps
|
|
|
*/
|
|
|
@Subscribe
|
|
|
- public void onIronStep(List<IronStepVO> steps) {
|
|
|
- if (ObjectUtils.isNotEmpty(steps)) {
|
|
|
- this.mSteps = steps;
|
|
|
+ public void onIronStep(Boolean refresh) {
|
|
|
+ if (ObjectUtils.isNotEmpty(refresh) && refresh) {
|
|
|
+ mSteps = ironStepService.getTreeSteps();
|
|
|
+ log.info("流程步骤数据刷新:{}", LocalDateTime.now());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-// @OnEvent(value = PushData.IRON_CONFIRM)
|
|
|
-// public void confirmIron(SocketIOClient client, IronOperataion message) {
|
|
|
-// if (ObjectUtils.isEmpty(message) || ObjectUtils.isEmpty(client)) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// log.info("---> {}", SocketUtil.clientUserIds.get(client));
|
|
|
-// log.info("人员到位(rydw):{},{}", message.getUserId(), message.getRydw());
|
|
|
-// log.info("炉前申请出铁(rydw):{},{}", message.getUserId(), message.getLqsqct());
|
|
|
-// log.info("预判和确认出铁(rydw):{},{}", message.getUserId(), message.getYpqrct());
|
|
|
-// IronOperataion ironOperataion = operateMap2.get(client);
|
|
|
-// if (ObjectUtils.isNotEmpty(ironOperataion)) {
|
|
|
-// if (ObjectUtils.isNotEmpty(message.getRydw())) {
|
|
|
-// ironOperataion.setRydw(message.getRydw());
|
|
|
-// }
|
|
|
-// if (ObjectUtils.isNotEmpty(message.getLqsqct())) {
|
|
|
-// ironOperataion.setLqsqct(message.getLqsqct());
|
|
|
-// }
|
|
|
-// if (ObjectUtils.isNotEmpty(message.getYpqrct())) {
|
|
|
-// ironOperataion.setYpqrct(message.getYpqrct());
|
|
|
-// }
|
|
|
-// PushData.send2Operation(ironOperataion, client);
|
|
|
-// } else {
|
|
|
-// log.info("失效的会话");
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
}
|