|
@@ -1,29 +1,38 @@
|
|
|
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.core.AjaxResult;
|
|
|
import com.sckj.common.eventbus.EventListener;
|
|
|
import com.sckj.common.socketio.SocketUtil;
|
|
|
+import com.sckj.common.util.RedisUtils;
|
|
|
import com.sckj.iron.dto.IronStepDTO;
|
|
|
-import com.sckj.iron.service.impl.TIronStepServiceImpl;
|
|
|
-import com.sckj.iron.vo.IronOperataion;
|
|
|
+import com.sckj.iron.dto.RealtimeData;
|
|
|
+import com.sckj.iron.dto.TrendData;
|
|
|
+import com.sckj.iron.entity.TIronData;
|
|
|
+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 com.sckj.opc.service.OPCDataServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import java.util.stream.Stream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Author feng
|
|
@@ -34,706 +43,717 @@ 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;
|
|
|
|
|
|
- private Map<SocketIOClient, IronOperataion> operateMap2 = new ConcurrentHashMap<>();
|
|
|
+ //出铁后
|
|
|
+ @Resource
|
|
|
+ TIronAfterServiceImpl ironAfterService;
|
|
|
+
|
|
|
+ //堵口后
|
|
|
+ @Resource
|
|
|
+ TIronBlockServiceImpl ironBlockService;
|
|
|
+
|
|
|
+ //参数
|
|
|
+ @Resource
|
|
|
+ TIronParamServiceImpl ironParamService;
|
|
|
+
|
|
|
+ //参数
|
|
|
+ @Resource
|
|
|
+ TL2DataServiceImpl tl2DataService;
|
|
|
|
|
|
- private Map<SocketIOClient, List<IronStepDTO>> operateMap3 = new ConcurrentHashMap<>();
|
|
|
+ @Resource
|
|
|
+ private L2DataServiceImpl l2DataServiceImpl;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ OPCDataServiceImpl opcDataService;
|
|
|
+
|
|
|
+ //实时数据
|
|
|
+ Map<String, Object> mRealtimeData = new HashMap<>();
|
|
|
+
|
|
|
+ //实时状态
|
|
|
+ Map<String, Object> mRealtimeStatus = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TrendData trendData;
|
|
|
+
|
|
|
+ //L1
|
|
|
+ private OPCData mOPCData;
|
|
|
+
|
|
|
+ //L2
|
|
|
+ private L2Data mL2Data;
|
|
|
|
|
|
// 1.创建表达式解析器
|
|
|
private SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
|
|
|
// 2.创建变量上下文,设置变量
|
|
|
- private StandardEvaluationContext ctx = new StandardEvaluationContext();
|
|
|
+ private StandardEvaluationContext mContext = new StandardEvaluationContext();
|
|
|
|
|
|
+ //出铁步骤
|
|
|
private List<IronStepVO> mSteps;
|
|
|
|
|
|
+ private static final String NODE = "node";
|
|
|
+
|
|
|
+ //定时器,用于铁口开口超时记录
|
|
|
+ private Timer timer = new Timer();
|
|
|
+
|
|
|
+ //是否出铁中
|
|
|
+ //1 出铁中 0 出铁结束
|
|
|
+ private boolean ironLoading1 = false;
|
|
|
+ private boolean ironLoading2 = false;
|
|
|
+ private boolean ironLoading3 = false;
|
|
|
+ private boolean ironLoading4 = false;
|
|
|
+
|
|
|
+ //1号出铁状态标记
|
|
|
+ private static final String TAG_TAPHOLE1_STATUS = "AOD25606.PV";
|
|
|
+ //2号出铁状态标记
|
|
|
+ private static final String TAG_TAPHOLE2_STATUS = "AOD25622.PV";
|
|
|
+ //3号出铁状态标记
|
|
|
+ private static final String TAG_TAPHOLE3_STATUS = "AOD25706.PV";
|
|
|
+ //4号出铁状态标记
|
|
|
+ private static final String TAG_TAPHOLE4_STATUS = "AOD25722.PV";
|
|
|
+ //铁水温度
|
|
|
+ private static final String TAG_IRON_TEMP = "CL510104.CPV";
|
|
|
+ //1TH-1号车受铁速度
|
|
|
+ private static final String TAG_CAR11 = "WZ540101.PV";
|
|
|
+ //1TH-2号车受铁速度
|
|
|
+ private static final String TAG_CAR12 = "WZ540201.PV";
|
|
|
+ //1TH-1号车总重
|
|
|
+ private static final String TAG_IRON_WEIGHT11 = "WI5401.PV";
|
|
|
+ //1TH-2号车TPC总重
|
|
|
+ private static final String TAG_IRON_WEIGHT12 = "WI5402.PV";
|
|
|
+
|
|
|
+ //预判和确认出铁
|
|
|
+ private static final String ypqrct = "lnct";
|
|
|
+
|
|
|
+ //铁量差计算
|
|
|
+ private static final String tlc = "tlc";
|
|
|
+
|
|
|
+ //最近任一铁口出铁结束时间
|
|
|
+ private Date lastIronEndTimeRecently;
|
|
|
+
|
|
|
+ @Resource(name = "taskExecutor")
|
|
|
+ ThreadPoolTaskExecutor taskExecutor;
|
|
|
+
|
|
|
+ //铁水成分
|
|
|
+ public static final String IRON_ELEMENT = "ironElement";
|
|
|
+ //铁水温度
|
|
|
+ public static final String IRON_TEMP = "ironTemp";
|
|
|
+ //铁水流速
|
|
|
+ public static final String IRON_SPEED = "ironSpeed";
|
|
|
+ //重量
|
|
|
+ public static final String IRON_WEIGHT = "ironWeight";
|
|
|
+ //出铁状态
|
|
|
+ private static final String IRON_STATUS = "ironStatus";
|
|
|
+
|
|
|
+ //鱼雷罐车
|
|
|
+ private static final String CAR_STATUS = "ylgc";
|
|
|
+ //拔炮
|
|
|
+ private static final String GUN_STATUS = "npkkj";
|
|
|
+ //摆动溜咀
|
|
|
+ private static final String MOUTH_STATUS = "bdlz";
|
|
|
+ //冲渣状态
|
|
|
+ private static final String FLUSH_STATUS = "flushStatus";
|
|
|
+ //预计出铁结束时间
|
|
|
+ private static final String PLAN_END_TIME = "planEndTime";
|
|
|
+
|
|
|
+
|
|
|
@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;
|
|
|
}
|
|
|
+ this.mOPCData = opcData;
|
|
|
+ //异步保存OPC数据
|
|
|
+ taskExecutor.submit(() -> opcDataService.save(mOPCData));
|
|
|
+ //出铁操作
|
|
|
+ operate();
|
|
|
|
|
|
- operate3(opcData);
|
|
|
+ //趋势数据
|
|
|
+ trenddata();
|
|
|
+
|
|
|
+ //实时数据
|
|
|
+ realtime();
|
|
|
|
|
|
-// 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();
|
|
|
+ /***
|
|
|
+ * L2数据项
|
|
|
+ * @param l2Data
|
|
|
+ */
|
|
|
+ @Subscribe
|
|
|
+ public void onL2MessageEvent(L2Data l2Data) {
|
|
|
+ if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
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");
|
|
|
- }
|
|
|
- }
|
|
|
+ this.mL2Data = l2Data;
|
|
|
+ realtime();
|
|
|
|
|
|
+ TL2Data tl2Data = new TL2Data();
|
|
|
+ //出铁操作
|
|
|
+ BeanUtils.copyProperties(l2Data, tl2Data);
|
|
|
|
|
|
- //炉前准备
|
|
|
- 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");
|
|
|
+ //将L2实时数据保存到数据库
|
|
|
+ tl2DataService.saveOrUpdate(tl2Data);
|
|
|
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- ironOperate.setWwtj("0");
|
|
|
+ //将L2实时数据保存到Redis
|
|
|
+ RedisUtils.addFixedElement(IRON_ELEMENT, l2Data, 6);
|
|
|
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
+ 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
|
|
|
+ final String sctlc = "sctlc";
|
|
|
+ final String ssctlc = "ssctlc";
|
|
|
+ final String scll = "scll";
|
|
|
+ final String sscll = "sscll";
|
|
|
+ final String scsj = "scsj";
|
|
|
+ final String sscsj = "sscsj";
|
|
|
+
|
|
|
+ //child.setPassResult(1);
|
|
|
+ for (IronStepVO childChild : child.getChilds()) {
|
|
|
+ if (sctlc.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(tlcLast);
|
|
|
+ } else if (ssctlc.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(tlcLastLast);
|
|
|
+ } else if (scll.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(llLast);
|
|
|
+ } else if (sscll.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(llLastLast);
|
|
|
+ } else if (scsj.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(ironWeightLast);
|
|
|
+ } else if (sscsj.equals(childChild.getIdentifier())) {
|
|
|
+ childChild.setData(ironWeightLastLast);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setStepResult(mSteps);
|
|
|
+ }
|
|
|
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
+ //趋势数据
|
|
|
+ private void trenddata() {
|
|
|
+ //
|
|
|
|
|
|
- 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");
|
|
|
+ //实时数据显示
|
|
|
+ private void realtime() {
|
|
|
+ //铁水温度
|
|
|
+ //铁水流速
|
|
|
+ //铁水成分
|
|
|
+ //铁水流量
|
|
|
+ //WI5401.PV 1TH-1号车总重
|
|
|
+ //WI5402.PV 1TH-2号车TPC总重
|
|
|
+ if (ObjectUtils.isNotEmpty(mOPCData)) {
|
|
|
+ if (mOPCData.getPointName().contains(TAG_IRON_TEMP)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setUnit("℃");
|
|
|
+ realtimeData.setDesc("铁水温度");
|
|
|
+ realtimeData.setTime(mOPCData.getServerTime().toString());
|
|
|
+ mRealtimeData.put(IRON_TEMP, realtimeData);
|
|
|
+ //redis添加数据
|
|
|
+ RedisUtils.addFixedElement(IRON_TEMP, realtimeData, 6);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mOPCData.getPointName().contains(TAG_CAR11) || mOPCData.getPointName().contains(TAG_CAR12)) {
|
|
|
+// 1TH-1号车受铁速度
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setUnit("t/s");
|
|
|
+
|
|
|
+ RealtimeData ironSpeed = (RealtimeData) mRealtimeData.get(IRON_SPEED);
|
|
|
+ RealtimeData[] speeds = null;
|
|
|
+ if (ObjectUtils.isEmpty(ironSpeed)) {
|
|
|
+ ironSpeed = new RealtimeData();
|
|
|
+ ironSpeed.setDesc("铁水流速");
|
|
|
+ speeds = new RealtimeData[2];
|
|
|
+ ironSpeed.setValue(speeds);
|
|
|
+ mRealtimeData.put(IRON_SPEED, ironSpeed);
|
|
|
} else {
|
|
|
- ironOperate.setSzbykq("1");
|
|
|
+ speeds = (RealtimeData[]) ironSpeed.getValue();
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //除尘开启出铁模式
|
|
|
- if (identifier.equals(TAG5)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
+ if (mOPCData.getPointName().contains(TAG_CAR11)) {
|
|
|
+ realtimeData.setDesc("1号车");
|
|
|
+ speeds[0] = realtimeData;
|
|
|
} else {
|
|
|
- ironOperate.setCtmskq("1");
|
|
|
+ realtimeData.setDesc("2号车");
|
|
|
+ speeds[1] = realtimeData;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //主沟盖板吊装机处于待机位
|
|
|
- if (identifier.equals(TAG6)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- } else {
|
|
|
- ironOperate.setZggbdj("1");
|
|
|
+ //只在两个都有数据的时候才添加
|
|
|
+ if (ObjectUtils.isNotEmpty(speeds)
|
|
|
+ && ObjectUtils.isNotEmpty(speeds[0]) && ObjectUtils.isNotEmpty(speeds[0].getValue())
|
|
|
+ && ObjectUtils.isNotEmpty(speeds[1]) && ObjectUtils.isNotEmpty(speeds[1].getValue())
|
|
|
+ ) {
|
|
|
+ ironSpeed.setTime(mOPCData.getServerTime().toString());
|
|
|
+ RedisUtils.addFixedElement(IRON_SPEED, ironSpeed, 6);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //外围条件
|
|
|
- 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");
|
|
|
+ if (mOPCData.getPointName().contains(TAG_IRON_WEIGHT11) || mOPCData.getPointName().contains(TAG_IRON_WEIGHT12)) {
|
|
|
+// 铁水流量
|
|
|
+ RealtimeData ironWeight = (RealtimeData) mRealtimeData.get(IRON_WEIGHT);
|
|
|
+ if (ObjectUtils.isEmpty(ironWeight)) {
|
|
|
+ ironWeight = new RealtimeData();
|
|
|
+ ironWeight.setDesc("铁水流量");
|
|
|
+ ironWeight.setUnit("t");
|
|
|
+ ironWeight.setValue(new BigDecimal(String.valueOf(mOPCData.getData())));
|
|
|
+ mRealtimeData.put(IRON_WEIGHT, ironWeight);
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
-
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ ironWeight.setTime(mOPCData.getServerTime().toString());
|
|
|
+ RedisUtils.addFixedElement(IRON_WEIGHT, ironWeight, 6);
|
|
|
+ } else {
|
|
|
+ BigDecimal bigDecimalOld = ((BigDecimal) ironWeight.getValue());
|
|
|
+ BigDecimal bigDecimalNew = new BigDecimal(mOPCData.getData().toString());
|
|
|
+ BigDecimal add = bigDecimalOld.add(bigDecimalNew);
|
|
|
+ ironWeight.setValue(add);
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
+ ironWeight.setTime(mOPCData.getServerTime().toString());
|
|
|
+ RedisUtils.addFixedElement(IRON_WEIGHT, ironWeight, 6);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return;
|
|
|
|
|
|
+ if (mOPCData.getPointName().contains(TAG_TAPHOLE1_STATUS)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setDesc("出铁状态");
|
|
|
+ mRealtimeStatus.put(IRON_STATUS, realtimeData);
|
|
|
}
|
|
|
|
|
|
- if ("0".equals(ironOperate.getLqsqct())) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
+// if (mOPCData.getPointName().contains(CAR_STATUS)) {
|
|
|
+// RealtimeData realtimeData = new RealtimeData();
|
|
|
+// realtimeData.setValue(mOPCData.getData());
|
|
|
+// realtimeData.setDesc("鱼雷罐车到位状态");
|
|
|
+// mRealtimeDataMap.put(CAR_STATUS, realtimeData);
|
|
|
+// }
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+// if (mOPCData.getPointName().contains(TAG_IRON_STATUS1)) {
|
|
|
+// RealtimeData realtimeData = new RealtimeData();
|
|
|
+// realtimeData.setValue(mOPCData.getData());
|
|
|
+// realtimeData.setDesc("拔炮状态");
|
|
|
+// mRealtimeDataMap.put(GUN_STATUS, realtimeData);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// if (mOPCData.getPointName().contains(TAG_IRON_STATUS1)) {
|
|
|
+// RealtimeData realtimeData = new RealtimeData();
|
|
|
+// realtimeData.setValue(mOPCData.getData());
|
|
|
+// realtimeData.setDesc("摆动溜咀");
|
|
|
+// mRealtimeDataMap.put(MOUTH_STATUS, realtimeData);
|
|
|
+// }
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- return;
|
|
|
+ if (mOPCData.getPointName().contains(FLUSH_STATUS)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setDesc("冲渣状态");
|
|
|
+ mRealtimeStatus.put(FLUSH_STATUS, realtimeData);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //高炉运行情况
|
|
|
- if (identifier.equals(TAG7)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- } else {
|
|
|
- ironOperate.setGlyxqk("1");
|
|
|
- }
|
|
|
+ if (mOPCData.getPointName().contains(PLAN_END_TIME)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setDesc("预计出铁结束时间");
|
|
|
+ mRealtimeData.put(PLAN_END_TIME, realtimeData);
|
|
|
}
|
|
|
|
|
|
- //理论铁量、铁铁差计算
|
|
|
- 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");
|
|
|
- }
|
|
|
+ float yc = Float.valueOf(ObjectUtils.defaultIfNull(mContext.lookupVariable("yc"), "0").toString());
|
|
|
+ if (yc > 190) {
|
|
|
+ log.info("预警出铁");
|
|
|
+ PushData.send2Warn(AjaxResult.success("预警出铁"));
|
|
|
}
|
|
|
|
|
|
- //炉内出铁条件
|
|
|
- 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());
|
|
|
+ if (ObjectUtils.isNotEmpty(mL2Data)) {
|
|
|
+ //铁水成分
|
|
|
+ //预计出铁结束时间
|
|
|
+ String elementSi = mL2Data.getElementSi();
|
|
|
+ String elementS = mL2Data.getElementS();
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(elementSi);
|
|
|
+ realtimeData.setUnit("%");
|
|
|
+ realtimeData.setDesc("硅");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ RealtimeData realtimeData2 = new RealtimeData();
|
|
|
+ realtimeData2.setValue(elementS);
|
|
|
+ realtimeData2.setUnit("%");
|
|
|
+ realtimeData2.setDesc("硫");
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
- return;
|
|
|
- }
|
|
|
+ List<RealtimeData> realtimeDataList = new ArrayList<>();
|
|
|
+ realtimeDataList.add(realtimeData);
|
|
|
+ realtimeDataList.add(realtimeData2);
|
|
|
|
|
|
- if ("1".equals(ironOperate.getYpqrct())) {
|
|
|
- ironOperate.setLqctcz("1");
|
|
|
- } else {
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
- }
|
|
|
+ RealtimeData realtimeData3 = new RealtimeData();
|
|
|
+ realtimeData3.setValue(realtimeDataList);
|
|
|
+ realtimeData3.setDesc("铁水成分");
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, userId);
|
|
|
+ mRealtimeData.put(IRON_ELEMENT, realtimeData3);
|
|
|
}
|
|
|
|
|
|
- //glyxqk 高炉运行情况
|
|
|
- //tlcjs 理论铁量、铁铁差计算
|
|
|
- //ctkms 出铁口模式
|
|
|
-
|
|
|
- //趋势
|
|
|
- if (Stream.of("TAG5", "TAG6", "TAG7", "TAG8").anyMatch(identifier::contains)) {
|
|
|
- // PushData.sendToTrend(JSON.toJSONString(opcData));
|
|
|
- //铁水成分
|
|
|
- //铁水流速
|
|
|
- //铁水流量
|
|
|
- //铁水温度
|
|
|
- }
|
|
|
+ //推送实时数据
|
|
|
+ PushData.send2RealtimeData(mRealtimeData);
|
|
|
+ //推送实时状态
|
|
|
+ PushData.send2RealtimeStatus(mRealtimeStatus);
|
|
|
|
|
|
- //实时数据
|
|
|
- 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() {
|
|
|
+ if (ObjectUtils.isEmpty(mOPCData)) {
|
|
|
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");
|
|
|
- }
|
|
|
- }
|
|
|
+ String pointName = mOPCData.getPointName();
|
|
|
+ Object data = mOPCData.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()) {
|
|
|
+ for (IronStepVO childchild : child.getChilds()) {
|
|
|
|
|
|
- //tbxtzc 铁摆系统正常
|
|
|
- if (identifier.equals(TAG2)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setTbxtzc("0");
|
|
|
- } else {
|
|
|
- ironOperate.setTbxtzc("1");
|
|
|
- }
|
|
|
- }
|
|
|
+ //plc的point和step的point一致
|
|
|
+ String newPointName = childchild.getPointName();
|
|
|
|
|
|
- //npkkjzbwb 泥炮、开口机准备完毕
|
|
|
- if (identifier.equals(TAG3)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setNpkkjzbwb("0");
|
|
|
- } else {
|
|
|
- ironOperate.setNpkkjzbwb("1");
|
|
|
- }
|
|
|
- }
|
|
|
+ if (ObjectUtils.isEmpty(newPointName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
+ if (newPointName.contains(".")) {
|
|
|
+ newPointName = "channel." + newPointName;
|
|
|
+ } else {
|
|
|
+ newPointName = "channel.device." + newPointName;
|
|
|
+ }
|
|
|
|
|
|
- //炉前准备
|
|
|
- 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());
|
|
|
+ if (Objects.equals(newPointName, pointName)) {
|
|
|
+ //3.创建变量上下文,设置变量
|
|
|
+ childchild.setData(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- ironOperate.setRydw("0");
|
|
|
- ironOperate.setLqzb("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- ironOperate.setWwtj("0");
|
|
|
+ setStepResult(mSteps);
|
|
|
|
|
|
- ironOperate.setLqsqct("0");
|
|
|
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
+ ironReady();
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ PushData.send2Operation(mSteps, ironLoading1);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
+ //计算每步结果
|
|
|
+ private void setStepResult(List<IronStepVO> mSteps) {
|
|
|
+ boolean foundFalsePass = false;
|
|
|
+ //发现第一个pass是false,后续都为false,包括父项和子项
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
+ for (IronStepVO childChild : child.getChilds()) {
|
|
|
+ //子项的子项 验证是否通过
|
|
|
+ validateStepPass(childChild);
|
|
|
|
|
|
-// if (identifier.contains(TAG4)) {
|
|
|
-// ironOperate.setRydw(data);
|
|
|
-// }
|
|
|
+ if (!foundFalsePass && 0 == childChild.getPassResult()) {
|
|
|
+ foundFalsePass = true;
|
|
|
+ }
|
|
|
|
|
|
- //水闸泵已开启,水闸槽水量正常
|
|
|
- if (identifier.equals(TAG4)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setSzbykq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setSzbykq("1");
|
|
|
+ if (foundFalsePass) {
|
|
|
+ childChild.setPassResult(0);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //除尘开启出铁模式
|
|
|
- if (identifier.equals(TAG5)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtmskq("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtmskq("1");
|
|
|
+ //子项验证是否通过
|
|
|
+ validateStepPass(child);
|
|
|
+ if (!foundFalsePass && 0 == child.getPassResult()) {
|
|
|
+ foundFalsePass = true;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //主沟盖板吊装机处于待机位
|
|
|
- if (identifier.equals(TAG6)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setZggbdj("0");
|
|
|
- } else {
|
|
|
- ironOperate.setZggbdj("1");
|
|
|
+ //子项
|
|
|
+ if (foundFalsePass) {
|
|
|
+ child.setPassResult(0);
|
|
|
}
|
|
|
}
|
|
|
+ //父项
|
|
|
+ validateStepPass(stepDTO);
|
|
|
+ //父项
|
|
|
+ if (foundFalsePass) {
|
|
|
+ stepDTO.setPassResult(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //外围条件
|
|
|
- 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;
|
|
|
+ private void ironReady() {
|
|
|
+ if (ObjectUtils.isEmpty(mOPCData)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //通过“预判和确认出铁”标记开始出铁
|
|
|
+ boolean isReady = false;
|
|
|
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ if (ypqrct.equalsIgnoreCase(stepDTO.getIdentifier()) && 1 == stepDTO.getPassResult()) {
|
|
|
+ isReady = true;
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if ("0".equals(ironOperate.getLqsqct())) {
|
|
|
- ironOperate.setGlyxqk("0");
|
|
|
- ironOperate.setTlcjs("0");
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- ironOperate.setLncttj("0");
|
|
|
+ //炉前在接受到炉内出铁要求后,10分钟内打开铁口,未打开系统告警并记录
|
|
|
+ if (isReady) {
|
|
|
+ TimerTask task = new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ System.out.println("倒计时结束!10分钟已到。");
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
+ // 打开系统告警并记录
|
|
|
+ PushData.send2Warn("warn");
|
|
|
+ log.info("准备出铁但是未及时出铁口,此处数据库记录");
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
+ // 倒计时10分钟(600秒)
|
|
|
+ long delay = 10 * 60 * 1000; // 10分钟转换为毫秒
|
|
|
+ // 在指定延迟后执行任务
|
|
|
+ timer.schedule(task, delay);
|
|
|
+ }
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ //根据PLC订阅的数据,AOD25606.PV=1为出铁中,AOD25606.PV=0出铁结束的信号,进行判断
|
|
|
+ //为1表示开始出铁,此时如果未超过10分钟,就取消定时器
|
|
|
+ //出铁结束
|
|
|
+ if (mOPCData.getPointName().contains(TAG_TAPHOLE1_STATUS)) {
|
|
|
+ //1:出铁中
|
|
|
+ //0:出铁结束
|
|
|
+ ironLoading1 = "1".equals(mOPCData.getData());
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
+ if ("1".equals(mOPCData.getData())) {
|
|
|
+ //由 0 -> 1
|
|
|
+ //表明1号铁口正在出铁
|
|
|
+ //根据理论铁量、实时铁水流速,推测距离出铁结束的剩余时间
|
|
|
+ //剩余时间=总时间-已经流去的时间
|
|
|
+// mContext.lookupVariable("");
|
|
|
+ //计算理论铁量= 矿批 × 综合品位 × 1.06,其中矿批是指L2中的干量
|
|
|
|
|
|
+// Date ironTime = mOPCData.getServerTime();
|
|
|
+// lastIronEndTimeRecently
|
|
|
|
|
|
- //高炉运行情况
|
|
|
- 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");
|
|
|
+ } else if ("0".equals(mOPCData.getData())) {
|
|
|
+ //由 1-> 0
|
|
|
+ try {
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
+ recordAfter();
|
|
|
+ recordBlock();
|
|
|
|
|
|
- //出铁口模式
|
|
|
- if (identifier.equals(TAG9)) {
|
|
|
- if ("0".equals(data)) {
|
|
|
- ironOperate.setCtfs("0");
|
|
|
- } else {
|
|
|
- ironOperate.setCtfs("1");
|
|
|
- }
|
|
|
+ //出铁结束后,查询最近两次的数据
|
|
|
+ LambdaQueryWrapper<TIronData> queryWrapper = new QueryWrapper<TIronData>().lambda().orderByDesc(TIronData::getCtcsbh);
|
|
|
+ List<TIronData> oldIronDataList = ironDataService.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
- //炉内出铁条件
|
|
|
- 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());
|
|
|
+ }
|
|
|
|
|
|
- ironOperate.setYpqrct("0");
|
|
|
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ if (mOPCData.getPointName().contains(TAG_TAPHOLE1_STATUS)
|
|
|
+ || mOPCData.getPointName().contains(TAG_TAPHOLE2_STATUS)
|
|
|
+ || mOPCData.getPointName().contains(TAG_TAPHOLE3_STATUS)
|
|
|
+ || mOPCData.getPointName().contains(TAG_TAPHOLE4_STATUS)
|
|
|
+ ) {
|
|
|
+ lastIronEndTimeRecently = mOPCData.getServerTime();
|
|
|
+ }
|
|
|
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
- return;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if ("1".equals(ironOperate.getYpqrct())) {
|
|
|
- ironOperate.setLqctcz("1");
|
|
|
+ /***
|
|
|
+ * 判断是否通过
|
|
|
+ * @param stepVO
|
|
|
+ */
|
|
|
+ private void validateStepPass(IronStepVO stepVO) {
|
|
|
+ //根据唯一名称设置环境变量
|
|
|
+ mContext.setVariable(stepVO.getIdentifier(), stepVO.getData());
|
|
|
+ String flowName = "";
|
|
|
+ try {
|
|
|
+ if ("calc".equalsIgnoreCase(stepVO.getNodeType())) {
|
|
|
+ flowName = parser.parseExpression(stepVO.getStepNameExpression()).getValue(mContext, String.class);
|
|
|
} else {
|
|
|
- ironOperate.setLqctcz("0");
|
|
|
+ flowName = parser.parseExpression("'" + stepVO.getStepName() + "'").getValue(mContext, String.class);
|
|
|
}
|
|
|
-
|
|
|
- PushData.send2Operation(ironOperate, socketIOClient);
|
|
|
+ stepVO.setStepName(flowName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("stepId:{},identifier:{},stepName:{}", stepVO.getStepId(), stepVO.getIdentifier(), flowName);
|
|
|
}
|
|
|
|
|
|
- //glyxqk 高炉运行情况
|
|
|
- //tlcjs 理论铁量、铁铁差计算
|
|
|
- //ctkms 出铁口模式
|
|
|
-
|
|
|
- //趋势
|
|
|
- if (Stream.of("TAG5", "TAG6", "TAG7", "TAG8").anyMatch(identifier::contains)) {
|
|
|
- // PushData.sendToTrend(JSON.toJSONString(opcData));
|
|
|
- //铁水成分
|
|
|
- //铁水流速
|
|
|
- //铁水流量
|
|
|
- //铁水温度
|
|
|
+ //非流程必须项,直接放行
|
|
|
+ if ("0".equals(stepVO.getRequired())) {
|
|
|
+ stepVO.setPassResult(1);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- //实时数据
|
|
|
- if (Stream.of("TAG9", "TAG10").anyMatch(identifier::contains)) {
|
|
|
-// PushData.sendToRealtime(JSON.toJSONString(opcData));
|
|
|
- //除铁中
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
- //
|
|
|
+ if (ObjectUtils.isNotEmpty(stepVO.getStepCondition())) {
|
|
|
+ boolean result = false;
|
|
|
+ try {
|
|
|
+ result = parser.parseExpression(stepVO.getStepCondition()).getValue(mContext, Boolean.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ stepVO.setPassResult(result ? 1 : 0);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private void operate3(OPCData opcData) {
|
|
|
- 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()) {
|
|
|
- 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) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- child.setPass(result);
|
|
|
+ }
|
|
|
|
|
|
- //log.info("pointName:{},data:{},tj:{},result:{}", pointName, data, child.getStepTj(), result);
|
|
|
- }
|
|
|
- }
|
|
|
- try {
|
|
|
- boolean result = false;
|
|
|
- if (ObjectUtils.isNotEmpty(stepDTO.getStepTj())) {
|
|
|
- try {
|
|
|
- result = parser.parseExpression(stepDTO.getStepTj()).getValue(ctx, Boolean.class);
|
|
|
- } catch (Exception e) {
|
|
|
+ //出铁后,记录炉次、开口时间、鱼雷罐车车号、铁口深度、铁水流速
|
|
|
+ private void recordAfter() {
|
|
|
+ ironAfterService.add(null);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- stepDTO.setPass(result);
|
|
|
- } catch (Exception e) {
|
|
|
- stepDTO.setPass(false);
|
|
|
- }
|
|
|
+ //堵口后,记录堵口时间、出铁量,打泥量、是否喷溅、是否跑泥
|
|
|
+ private void recordBlock() {
|
|
|
+ ironBlockService.add(null);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ /***
|
|
|
+ * 用户端点击触发
|
|
|
+ * @param client
|
|
|
+ * @param message
|
|
|
+ */
|
|
|
+ @OnEvent(value = PushData.IRON_CONFIRM)
|
|
|
+ public void confirmIron(SocketIOClient client, IronStepDTO message) {
|
|
|
+ String userId;
|
|
|
+ if (ObjectUtils.isEmpty(client) || ObjectUtils.isEmpty(userId = SocketUtil.clientUserIds.get(client))) {
|
|
|
+ log.info("该客户已下线");
|
|
|
+ PushData.send2Operation("该客户已下线", false);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- log.info("==========================================");
|
|
|
- //log.info("steps before:{}", JSON.toJSONString(mSteps));
|
|
|
- log.info("==========================================");
|
|
|
+ if (ObjectUtils.isEmpty(message)) {
|
|
|
+ log.info("请求数据为空");
|
|
|
+ PushData.send2Operation("请求数据为空", false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- boolean foundFalsePass = false;
|
|
|
|
|
|
- //发现第一个pass是false,后续的手动操作都为false,包括父项和子项
|
|
|
+ log.info("--->userId : {}", userId);
|
|
|
for (IronStepVO stepDTO : mSteps) {
|
|
|
for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
- if (!foundFalsePass && !child.isPass()) {
|
|
|
- foundFalsePass = true;
|
|
|
- }
|
|
|
- if (foundFalsePass) {
|
|
|
- child.setPass(false);
|
|
|
+ if (validateManualData(message, userId, child)) {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
- if (foundFalsePass) {
|
|
|
- stepDTO.setPass(false);
|
|
|
+ if (validateManualData(message, userId, stepDTO)) {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- log.info("==========================================");
|
|
|
- log.info("steps after:{}", JSON.toJSONString(mSteps));
|
|
|
- log.info("==========================================");
|
|
|
+ private boolean validateManualData(IronStepDTO message, String userId, IronStepVO stepDTO) {
|
|
|
+ if (Objects.equals(stepDTO.getStepId(), message.getStepId()) && Objects.equals(stepDTO.getIdentifier(), message.getIdentifier()) && Objects.equals("2", stepDTO.getConfirmMode())) {
|
|
|
+ stepDTO.setData(message.getData());
|
|
|
+ setStepResult(mSteps);
|
|
|
+ PushData.send2Operation(mSteps, ironLoading1);
|
|
|
+ //这里手动记录时间
|
|
|
+ log.info("userId:{},stepId:{},identifier:{},data:{},pass:{}", userId, message.getStepId(), message.getIdentifier(), message.getData(), message.isPass());
|
|
|
|
|
|
|
|
|
- PushData.send2Operation(mSteps);
|
|
|
- }
|
|
|
+ if (Objects.equals(message.getIdentifier(), CAR_STATUS)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(message.getData());
|
|
|
+ realtimeData.setDesc("鱼雷罐车到位状态");
|
|
|
+ mRealtimeStatus.put(CAR_STATUS, realtimeData);
|
|
|
+ }
|
|
|
|
|
|
- @OnEvent(value = PushData.IRON_CONFIRM)
|
|
|
- public void confirmIron(SocketIOClient client, IronStepDTO message) {
|
|
|
- if (ObjectUtils.isEmpty(message) || ObjectUtils.isEmpty(client)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- log.info("---> {}", SocketUtil.clientUserIds.get(client));
|
|
|
- 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);
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (Objects.equals(message.getIdentifier(), GUN_STATUS)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(message.getData());
|
|
|
+ realtimeData.setDesc("拔炮状态");
|
|
|
+ mRealtimeStatus.put(GUN_STATUS, realtimeData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (Objects.equals(message.getIdentifier(), MOUTH_STATUS)) {
|
|
|
+ RealtimeData realtimeData = new RealtimeData();
|
|
|
+ realtimeData.setValue(message.getData());
|
|
|
+ realtimeData.setDesc("摆动溜嘴状态");
|
|
|
+ mRealtimeStatus.put(MOUTH_STATUS, realtimeData);
|
|
|
}
|
|
|
+
|
|
|
+ PushData.send2RealtimeStatus(mRealtimeStatus);
|
|
|
+
|
|
|
+ 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("失效的会话");
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
}
|