|
@@ -2,31 +2,38 @@ package com.sckj.iron.socketio;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
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.dto.RealtimeData;
|
|
|
+import com.sckj.iron.dto.TrendData;
|
|
|
import com.sckj.iron.entity.TIronData;
|
|
|
import com.sckj.iron.entity.TIronParam;
|
|
|
+import com.sckj.iron.entity.TL2Data;
|
|
|
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 com.sckj.opc.opcua.L2DataServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.expression.EvaluationException;
|
|
|
+import org.springframework.expression.ParseException;
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Timer;
|
|
|
-import java.util.TimerTask;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Author feng
|
|
@@ -57,6 +64,19 @@ public class DeviceEventListener extends EventListener {
|
|
|
@Resource
|
|
|
TIronParamServiceImpl ironParamService;
|
|
|
|
|
|
+ //参数
|
|
|
+ @Resource
|
|
|
+ TL2DataServiceImpl tl2DataService;
|
|
|
+
|
|
|
+ //实时数据
|
|
|
+ @Resource
|
|
|
+ RealtimeData realtimeData;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TrendData trendData;
|
|
|
+
|
|
|
+ private L2Data mL2Data;
|
|
|
|
|
|
// 1.创建表达式解析器
|
|
|
private SpelExpressionParser parser = new SpelExpressionParser();
|
|
@@ -72,20 +92,32 @@ public class DeviceEventListener extends EventListener {
|
|
|
//定时器,用于铁口开口超时记录
|
|
|
private Timer timer = new Timer();
|
|
|
|
|
|
+ //前2次出铁数据
|
|
|
private List<TIronData> oldIronDataList;
|
|
|
|
|
|
//是否出铁中
|
|
|
+ //1 出铁中 0 出铁结束
|
|
|
private boolean ironLoading = false;
|
|
|
|
|
|
- //出铁标记
|
|
|
+ //1号出铁标记
|
|
|
private static final String IRON_OPERATE_TAG = "AOD25606.PV";
|
|
|
|
|
|
+ //锅炉运行情况
|
|
|
+ private static final String glyxqk = "glyxqk";
|
|
|
+ //预判和确认出铁
|
|
|
+ private static final String ypqrct = "lqct";
|
|
|
+
|
|
|
+
|
|
|
+ //铁量差计算
|
|
|
+ private static final String tlc = "tlc";
|
|
|
+ @Autowired
|
|
|
+ private L2DataServiceImpl l2DataServiceImpl;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
mSteps = ironStepService.getTreeSteps();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/***
|
|
|
* L1数据项
|
|
|
* @param opcData
|
|
@@ -97,9 +129,41 @@ public class DeviceEventListener extends EventListener {
|
|
|
}
|
|
|
//出铁操作
|
|
|
operate(opcData);
|
|
|
+ //趋势数据
|
|
|
+ trenddata(opcData);
|
|
|
+
|
|
|
//实时数据
|
|
|
+ realtime(opcData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //趋势数据
|
|
|
+ private void trenddata(OPCData opcData) {
|
|
|
+ //
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //实时数据显示
|
|
|
+ //
|
|
|
+ private void realtime(OPCData opcData) {
|
|
|
+ //铁水温度
|
|
|
+ //铁水流速
|
|
|
+ //铁水成分
|
|
|
+ //铁水流量
|
|
|
+ if (opcData.getPointName().contains("CL510104.CPV")) {
|
|
|
+ // trendData.put("ironTemp",opcData.getData());
|
|
|
+
|
|
|
+ } else if (opcData.getPointName().contains("WZ540101.PV")) {
|
|
|
+// trendData.put("ironSpeed1",opcData.getData());
|
|
|
+ realtimeData.setIronSpeed1(opcData.getData());
|
|
|
+ } else if (opcData.getPointName().contains("WZ540201.PV")) {
|
|
|
+// trendData.put("ironTemp2",opcData.getData());
|
|
|
+ realtimeData.setIronSpeed2(opcData.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(mL2Data)) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- //趋势数据
|
|
|
}
|
|
|
|
|
|
|
|
@@ -112,11 +176,73 @@ public class DeviceEventListener extends EventListener {
|
|
|
if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
+ this.mL2Data = l2Data;
|
|
|
+ TL2Data tl2Data = new TL2Data();
|
|
|
//出铁操作
|
|
|
+ BeanUtils.copyProperties(l2Data, tl2Data);
|
|
|
|
|
|
- //实时数据
|
|
|
+ //将L2实时数据保存到数据库
|
|
|
+ tl2DataService.saveOrUpdate(tl2Data);
|
|
|
+
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ if (NODE.equalsIgnoreCase(stepDTO.getNodeType())) {
|
|
|
+ //处理子项
|
|
|
+ for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
+ if (tlc.equals(child.getIdentifier())) {
|
|
|
+ List<TL2Data> latest2Data = tl2DataService.getLatest2Data();
|
|
|
+ if (latest2Data.size() >= 2) {
|
|
|
+ HashMap[] hashMaps = new HashMap[6];
|
|
|
+ child.setExtraInfo(hashMaps);
|
|
|
+ //理论出铁量 = 矿批 × 综合品位 × 1.06
|
|
|
+ //铁量差 = 理论出铁量 - 实际出铁量
|
|
|
+ TL2Data tl2Data1Last = latest2Data.get(0);
|
|
|
+ double llLast = tl2Data1Last.getTotalDry() * 1.0 * 1.06;
|
|
|
+ double ironWeightLast = tl2Data1Last.getIronWeight();
|
|
|
+ double tlcLast = llLast - ironWeightLast;
|
|
|
+
|
|
|
+ TL2Data tl2Data1LastLast = latest2Data.get(1);
|
|
|
+ double llLastLast = tl2Data1LastLast.getTotalDry() * 1.0 * 1.06;
|
|
|
+ double ironWeightLastLast = tl2Data1Last.getIronWeight();
|
|
|
+ double tlcLastLast = llLastLast - ironWeightLastLast;
|
|
|
+
|
|
|
+ //铁量差在合理范围内
|
|
|
+ // 上一次铁量差:-30 上上次铁量差:20 t
|
|
|
+ // 理论出铁量:1500 t 理论出铁量:1400 t
|
|
|
+ // 实际出铁量:1530 t 实际出铁量: 1380 t
|
|
|
+
|
|
|
+ hashMaps[0] = new HashMap();
|
|
|
+ hashMaps[0].put("value", tlcLast);
|
|
|
+ hashMaps[0].put("desc", String.format("上一次铁量差:%st", tlcLast));
|
|
|
+
|
|
|
+ hashMaps[1] = new HashMap();
|
|
|
+ hashMaps[1].put("value", tlcLastLast);
|
|
|
+ hashMaps[1].put("desc", String.format("上上次铁量差:%st", tlcLastLast));
|
|
|
+
|
|
|
+ hashMaps[2] = new HashMap();
|
|
|
+ hashMaps[2].put("value", llLast);
|
|
|
+ hashMaps[2].put("desc", String.format("理论出铁量:%st", llLast));
|
|
|
+
|
|
|
+ hashMaps[3] = new HashMap();
|
|
|
+ hashMaps[3].put("value", llLastLast);
|
|
|
+ hashMaps[3].put("desc", String.format("理论出铁量:%st", llLastLast));
|
|
|
+
|
|
|
+ hashMaps[4] = new HashMap();
|
|
|
+ hashMaps[4].put("value", ironWeightLast);
|
|
|
+ hashMaps[4].put("desc", String.format("t实际出铁量:%st", ironWeightLast));
|
|
|
+
|
|
|
+ hashMaps[5] = new HashMap();
|
|
|
+ hashMaps[5].put("value", ironWeightLastLast);
|
|
|
+ hashMaps[5].put("desc", String.format("t实际出铁量:%st", ironWeightLastLast));
|
|
|
+
|
|
|
+ child.setPassResult(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setStepResult(mSteps);
|
|
|
|
|
|
- //趋势数据
|
|
|
}
|
|
|
|
|
|
|
|
@@ -131,11 +257,68 @@ public class DeviceEventListener extends EventListener {
|
|
|
if (NODE.equalsIgnoreCase(stepDTO.getNodeType())) {
|
|
|
//处理子项
|
|
|
for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
- //plc的point和step的point一致
|
|
|
- if (Objects.equals(child.getPointName(), pointName)) {
|
|
|
- //3.创建变量上下文,设置变量
|
|
|
+ for (IronStepVO childchild : child.getChilds()) {
|
|
|
+ //plc的point和step的point一致
|
|
|
+ String newPointName = childchild.getPointName();
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(newPointName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(newPointName.contains(".")){
|
|
|
+ newPointName = "channel." + newPointName;
|
|
|
+ }else{
|
|
|
+ newPointName = "channel.device." + newPointName;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.equals(newPointName, pointName)) {
|
|
|
+ //3.创建变量上下文,设置变量
|
|
|
+ childchild.setData(data);
|
|
|
+// if ("glyc".equals(child.getIdentifier())) {
|
|
|
+// //高炉压差正常
|
|
|
+//
|
|
|
+// if (ObjectUtils.isEmpty(child.getExtraInfo())) {
|
|
|
+// child.setExtraInfo(new HashMap[4]);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (opcData.getPointName().contains("FI1001.PV")) {
|
|
|
+// //送风流量
|
|
|
+// child.getExtraInfo()[0] = new HashMap<>();
|
|
|
+// child.getExtraInfo()[0].put("value", data.toString());
|
|
|
+// child.getExtraInfo()[0].put("desc", String.format("送风流量:%sm3/min", data.toString()));
|
|
|
+// } else if (opcData.getPointName().contains("PI1003.PV")) {
|
|
|
+// //送风压力
|
|
|
+// child.getExtraInfo()[1] = new HashMap<>();
|
|
|
+// child.getExtraInfo()[1].put("value", data.toString());
|
|
|
+// child.getExtraInfo()[1].put("desc", String.format("送风压力:%skPa", data.toString()));
|
|
|
+// } else if (opcData.getPointName().contains("PC7801.PV")) {
|
|
|
+// //选择后炉顶压力
|
|
|
+// child.getExtraInfo()[2] = new HashMap<>();
|
|
|
+// child.getExtraInfo()[2].put("value", data.toString());
|
|
|
+// child.getExtraInfo()[2].put("desc", String.format("炉顶压力:%skPa", data.toString()));
|
|
|
+// }
|
|
|
+// //压差
|
|
|
+// BigDecimal bdSfyl = new BigDecimal(child.getExtraInfo()[1].getOrDefault("value", "0").toString());
|
|
|
+// BigDecimal bdLdyl = new BigDecimal(child.getExtraInfo()[2].getOrDefault("value", "0").toString());
|
|
|
+// child.getExtraInfo()[3] = new HashMap<>();
|
|
|
+// BigDecimal subtract = bdSfyl.subtract(bdLdyl);
|
|
|
+// child.getExtraInfo()[3].put("value", bdSfyl.subtract(bdLdyl));
|
|
|
+// child.getExtraInfo()[3].put("desc", String.format("压差:%skPa", bdSfyl.subtract(bdLdyl)));
|
|
|
+// child.setPassResult(1);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String newPointName = child.getPointName();
|
|
|
+ if(ObjectUtils.isEmpty(newPointName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(newPointName.contains(".")){
|
|
|
+ newPointName = "channel." + newPointName;
|
|
|
+ }else{
|
|
|
+ newPointName = "channel.device." + newPointName;
|
|
|
+ }
|
|
|
+ if (Objects.equals(newPointName, pointName)) {
|
|
|
child.setData(data);
|
|
|
- //log.info("pointName:{},data:{},tj:{},result:{}", pointName, data, child.getStepTj(), result);
|
|
|
}
|
|
|
// else {
|
|
|
// if (ObjectUtils.isNotEmpty(child.getData())) {
|
|
@@ -149,9 +332,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
|
|
|
setStepResult(mSteps);
|
|
|
|
|
|
-// log.info("==========================================");
|
|
|
-// log.info("steps after:{}", JSON.toJSONString(mSteps));
|
|
|
-// log.info("==========================================");
|
|
|
|
|
|
ironReady(opcData);
|
|
|
|
|
@@ -166,6 +346,19 @@ public class DeviceEventListener extends EventListener {
|
|
|
//发现第一个pass是false,后续都为false,包括父项和子项
|
|
|
for (IronStepVO stepDTO : mSteps) {
|
|
|
for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
+ for (IronStepVO childChild : child.getChilds()) {
|
|
|
+ //子项的子项 验证是否通过
|
|
|
+ validateStepTjPass(childChild);
|
|
|
+
|
|
|
+ if (!foundFalsePass && 0 == childChild.getPassResult()) {
|
|
|
+ foundFalsePass = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (foundFalsePass) {
|
|
|
+ childChild.setPassResult(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//子项验证是否通过
|
|
|
validateStepTjPass(child);
|
|
|
if (!foundFalsePass && 0 == child.getPassResult()) {
|
|
@@ -185,16 +378,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //锅炉运行情况
|
|
|
- private static final String glyxqk = "glyxqk";
|
|
|
- //预判和确认出铁
|
|
|
- private static final String ypqrct = "ypqrct";
|
|
|
-
|
|
|
-
|
|
|
- //理论铁量、铁量差计算
|
|
|
- private static final String tlcjs = "tlcjs";
|
|
|
- //出铁方式(单铁口 双铁口)
|
|
|
- private static final String ctfs = "ctfs";
|
|
|
|
|
|
private void ironReady(OPCData opcData) {
|
|
|
//通过“预判和确认出铁”标记开始出铁
|
|
@@ -229,7 +412,7 @@ public class DeviceEventListener extends EventListener {
|
|
|
//根据PLC订阅的数据,AOD25606.PV=1为出铁中,AOD25606.PV=0出铁结束的信号,进行判断
|
|
|
//为1表示开始出铁,此时如果未超过10分钟,就取消定时器
|
|
|
//出铁结束
|
|
|
- if (IRON_OPERATE_TAG.equalsIgnoreCase(opcData.getPointName())) {
|
|
|
+ if (opcData.getPointName().contains(IRON_OPERATE_TAG)) {
|
|
|
|
|
|
//1:出铁中
|
|
|
//0:出铁结束
|
|
@@ -265,55 +448,12 @@ public class DeviceEventListener extends EventListener {
|
|
|
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;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String stepNameNew = parser.parseExpression(stepVO.getStepName().contains("#")?stepVO.getStepName():"'"+stepVO.getStepName()+"'").getValue(ctx, String.class);
|
|
|
+ stepVO.setStepName(stepNameNew);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("stepName:{}",stepVO.getStepName());
|
|
|
}
|
|
|
}
|
|
|
|