|
@@ -5,21 +5,24 @@ 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.camera.util.LocalDateUtils;
|
|
|
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.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 com.sckj.opc.opcua.OPCDAServiceImpl;
|
|
|
import com.sckj.opc.service.OPCDataServiceImpl;
|
|
|
+import com.sckj.warn.service.ITExceptionLogService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -33,6 +36,9 @@ import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @Author feng
|
|
@@ -68,47 +74,17 @@ public class DeviceEventListener extends EventListener {
|
|
|
TL2DataServiceImpl tl2DataService;
|
|
|
|
|
|
@Resource
|
|
|
- private L2DataServiceImpl l2DataServiceImpl;
|
|
|
+ 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 mContext = new StandardEvaluationContext();
|
|
|
-
|
|
|
- //出铁步骤
|
|
|
- private List<IronStepVO> mSteps;
|
|
|
-
|
|
|
- private static final String NODE = "node";
|
|
|
+ ITExceptionLogService iTExceptionLogService;
|
|
|
|
|
|
- //定时器,用于铁口开口超时记录
|
|
|
- private Timer timer = new Timer();
|
|
|
+ @Resource
|
|
|
+ OPCDAServiceImpl opcdaService;
|
|
|
|
|
|
- //是否出铁中
|
|
|
- //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";
|
|
@@ -135,12 +111,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
//铁量差计算
|
|
|
private static final String tlc = "tlc";
|
|
|
|
|
|
- //最近任一铁口出铁结束时间
|
|
|
- private Date lastIronEndTimeRecently;
|
|
|
-
|
|
|
- @Resource(name = "taskExecutor")
|
|
|
- ThreadPoolTaskExecutor taskExecutor;
|
|
|
-
|
|
|
//铁水成分
|
|
|
public static final String IRON_ELEMENT = "ironElement";
|
|
|
//铁水温度
|
|
@@ -163,10 +133,58 @@ public class DeviceEventListener extends EventListener {
|
|
|
//预计出铁结束时间
|
|
|
private static final String PLAN_END_TIME = "planEndTime";
|
|
|
|
|
|
+ //实时数据
|
|
|
+ Map<String, Object> mRealtimeData = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
+ //实时状态
|
|
|
+ Map<String, Object> mRealtimeStatus = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
+ // 1.创建表达式解析器
|
|
|
+ private SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
+
|
|
|
+ // 2.创建变量上下文,设置变量
|
|
|
+ private StandardEvaluationContext mContext = new StandardEvaluationContext();
|
|
|
+
|
|
|
+ //出铁步骤
|
|
|
+ private List<IronStepVO> mSteps;
|
|
|
+
|
|
|
+ //出铁参数
|
|
|
+ private Map<String, TIronParam> mIronParamMap;
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ //最近任一铁口出铁结束时间
|
|
|
+ private Date mIronEndTimeRecently;
|
|
|
+
|
|
|
+ @Resource(name = "taskExecutor")
|
|
|
+ ThreadPoolTaskExecutor taskExecutor;
|
|
|
+
|
|
|
+ private float speed1, speed2;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
+ timer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ opcdaService.subscribeAvailable();
|
|
|
+ }
|
|
|
+ }, 10 * 1000);
|
|
|
mSteps = ironStepService.getTreeSteps();
|
|
|
+ List<TIronParam> mIronParams = ironParamService.lambdaQuery().eq(TIronParam::getStatus, "1").eq(TIronParam::getParamType, "iron_judge").orderByAsc(TIronParam::getSort).list();
|
|
|
+ if (ObjectUtils.isNotEmpty(mIronParams)) {
|
|
|
+ mIronParamMap = mIronParams.stream()
|
|
|
+ .collect(Collectors.toMap(TIronParam::getParamName, ironParam -> ironParam, (existing, replacement) -> existing));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/***
|
|
@@ -175,20 +193,17 @@ public class DeviceEventListener extends EventListener {
|
|
|
*/
|
|
|
@Subscribe
|
|
|
public void onMessageEvent(OPCData opcData) {
|
|
|
- if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.mOPCData = opcData;
|
|
|
//异步保存OPC数据
|
|
|
- taskExecutor.submit(() -> opcDataService.save(mOPCData));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ opcDataService.save(opcData);
|
|
|
+ });
|
|
|
//出铁操作
|
|
|
- operate();
|
|
|
-
|
|
|
- //趋势数据
|
|
|
- trenddata();
|
|
|
+ taskExecutor.submit(() -> operate(opcData));
|
|
|
|
|
|
//实时数据
|
|
|
- realtime();
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ setRealtimeDataAndStatus(opcData, null);
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
@@ -198,110 +213,225 @@ public class DeviceEventListener extends EventListener {
|
|
|
*/
|
|
|
@Subscribe
|
|
|
public void onL2MessageEvent(L2Data l2Data) {
|
|
|
- if (SocketUtil.clientUserIds.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.mL2Data = l2Data;
|
|
|
- realtime();
|
|
|
-
|
|
|
TL2Data tl2Data = new TL2Data();
|
|
|
//出铁操作
|
|
|
BeanUtils.copyProperties(l2Data, tl2Data);
|
|
|
-
|
|
|
//将L2实时数据保存到数据库
|
|
|
- tl2DataService.saveOrUpdate(tl2Data);
|
|
|
-
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ tl2DataService.saveOrUpdate(tl2Data);
|
|
|
+ });
|
|
|
//将L2实时数据保存到Redis
|
|
|
- RedisUtils.addFixedElement(IRON_ELEMENT, l2Data, 6);
|
|
|
-
|
|
|
- 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);
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ RedisUtils.addFixedElement(IRON_ELEMENT, l2Data, 6);
|
|
|
+ PushData.send2TrendIronElement(RedisUtils.getFixedElement(IRON_ELEMENT));
|
|
|
+ });
|
|
|
+
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ setRealtimeDataAndStatus(null, l2Data);
|
|
|
+ });
|
|
|
+
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ setStepResult(mSteps);
|
|
|
+ PushData.send2Operation(mSteps, ironLoading1);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ //1号铁口正在出铁的操作项目
|
|
|
+ private void taphole1Start(L2Data mL2Data) {
|
|
|
+ //通过“预判和确认出铁”标记开始出铁
|
|
|
+ boolean isReady = false;
|
|
|
+
|
|
|
+ for (IronStepVO stepDTO : mSteps) {
|
|
|
+ if (ypqrct.equalsIgnoreCase(stepDTO.getIdentifier()) && 1 == stepDTO.getPassResult()) {
|
|
|
+ isReady = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //炉前在接受到炉内出铁要求后,10分钟内打开铁口,未打开系统告警并记录
|
|
|
+ if (isReady) {
|
|
|
+ TimerTask task = new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ System.out.println("倒计时结束!10分钟已到。");
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
+ // 出铁预警,打开系统告警并记录
|
|
|
+ PushData.send2Warn("请立即打开铁口");
|
|
|
+ log.info("准备出铁但是未及时出铁口,此处数据库记录");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 倒计时10分钟(600秒)
|
|
|
+ long delay = 10 * 60 * 1000; // 10分钟转换为毫秒
|
|
|
+ // 在指定延迟后执行任务
|
|
|
+ timer.schedule(task, delay);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- //趋势数据
|
|
|
- private void trenddata() {
|
|
|
+ //由 0 -> 1 表明1号铁口开始出铁
|
|
|
//
|
|
|
+ //根据理论铁量、实时铁水流速,推测距离出铁结束的剩余时间
|
|
|
+ //剩余时间=总时间-已经流去的时间
|
|
|
+// mContext.lookupVariable("");
|
|
|
+ //计算理论铁量= 矿批 × 综合品位 × 1.06,其中矿批是指L2中的干量
|
|
|
+
|
|
|
+// Date ironTime = mOPCData.getServerTime();
|
|
|
+// lastIronEndTimeRecently
|
|
|
+ //获取总干量
|
|
|
+ BigDecimal totalDry = new BigDecimal(ObjectUtils.defaultIfNull(mL2Data.getTotalDry(), "0"));
|
|
|
+ //计算出理论铁量
|
|
|
+ BigDecimal multiply = totalDry.multiply(new BigDecimal(1.0)).multiply(new BigDecimal(1.0));
|
|
|
+ //
|
|
|
+ float totalSpeed = speed1 + speed2;
|
|
|
+ if (totalSpeed > 0) {
|
|
|
+ //理论时间
|
|
|
+ BigDecimal divide = multiply.divide(new BigDecimal(totalSpeed), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ String plainString = divide.toPlainString();
|
|
|
+ log.info("理论出铁时间:{}min", plainString);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始计算打泥量,通过打泥量公式
|
|
|
+ //打泥量公式关联因素:铁口深度、钻杆直径、
|
|
|
+ //
|
|
|
+
|
|
|
+ timer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //堵口预警
|
|
|
+ if (speed1 > 20 || speed2 > 20) {
|
|
|
+ /// 流速过大可能是由于铁口深度不足或发生跑大流问题,则提示将当前铁口堵口
|
|
|
+ PushData.send2Warn("流速过快,堵口");
|
|
|
+ } else if ((speed1 < 20 || speed2 < 20) && (ironLoading2 || ironLoading3 || ironLoading4)) {
|
|
|
+ //若流速过小,但其它铁口正在出铁,则提示将当前铁口堵口
|
|
|
+ PushData.send2Warn("当前铁口堵口");
|
|
|
+ } else if ((speed1 < 20 || speed2 < 20) && (!ironLoading2 && !ironLoading3 && !ironLoading4)) {
|
|
|
+ //若流速过小且其他铁口均未出铁,则提示先将其它铁口打开,再进行堵口
|
|
|
+ PushData.send2Warn("先将其它铁口打开,再进行堵口");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 10 * 60 * 1000);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //1号铁口结束出铁的操作项目
|
|
|
+ private void taphole1End() {
|
|
|
+ //由 1-> 0 表明1号铁口结束出铁
|
|
|
+ totalWeight = BigDecimal.ZERO;
|
|
|
+ try {
|
|
|
+ timer.cancel(); // 终止定时器
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ recordAfter();
|
|
|
+ recordBlock();
|
|
|
+
|
|
|
+ //出铁结束后,查询最近两次的数据
|
|
|
+ LambdaQueryWrapper<TIronData> queryWrapper = new QueryWrapper<TIronData>().lambda().orderByDesc(TIronData::getCtcsbh);
|
|
|
+ List<TIronData> oldIronDataList = ironDataService.list(queryWrapper);
|
|
|
+
|
|
|
+ //开始出铁诊断
|
|
|
+ //获取开口耗时、出铁时间、实际出铁量、平均铁水流速、平均铁水温度等数据,进行阈值判定,诊断出铁是否正常
|
|
|
+
|
|
|
+ //1分钟延迟
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //出铁后,记录炉次、开口时间、鱼雷罐车车号、铁口深度、铁水流速
|
|
|
+ private void recordAfter() {
|
|
|
+ ironAfterService.add(null);
|
|
|
+ }
|
|
|
|
|
|
+ //堵口后,记录堵口时间、出铁量,打泥量、是否喷溅、是否跑泥
|
|
|
+ private void recordBlock() {
|
|
|
+ ironBlockService.add(null);
|
|
|
}
|
|
|
|
|
|
|
|
|
- //实时数据显示
|
|
|
- private void realtime() {
|
|
|
+ private BigDecimal totalWeight = BigDecimal.ZERO;
|
|
|
+
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 设置实时数据值和状态
|
|
|
+ */
|
|
|
+ private synchronized void setRealtimeDataAndStatus(OPCData opcData, L2Data l2Data) {
|
|
|
//铁水温度
|
|
|
//铁水流速
|
|
|
//铁水成分
|
|
|
//铁水流量
|
|
|
//WI5401.PV 1TH-1号车总重
|
|
|
//WI5402.PV 1TH-2号车TPC总重
|
|
|
- if (ObjectUtils.isNotEmpty(mOPCData)) {
|
|
|
- if (mOPCData.getPointName().contains(TAG_IRON_TEMP)) {
|
|
|
+ if (ObjectUtils.isNotEmpty(opcData)) {
|
|
|
+ if (opcData.getPointName().contains(TAG_IRON_TEMP)) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setValue(opcData.getData());
|
|
|
realtimeData.setUnit("℃");
|
|
|
realtimeData.setDesc("铁水温度");
|
|
|
- realtimeData.setTime(mOPCData.getServerTime().toString());
|
|
|
+ realtimeData.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
mRealtimeData.put(IRON_TEMP, realtimeData);
|
|
|
//redis添加数据
|
|
|
RedisUtils.addFixedElement(IRON_TEMP, realtimeData, 6);
|
|
|
- }
|
|
|
-
|
|
|
- if (mOPCData.getPointName().contains(TAG_CAR11) || mOPCData.getPointName().contains(TAG_CAR12)) {
|
|
|
+ PushData.send2TrendIronTemp(RedisUtils.getFixedElement(IRON_TEMP));
|
|
|
+ } else if (opcData.getPointName().contains(TAG_CAR11) || opcData.getPointName().contains(TAG_CAR12)) {
|
|
|
// 1TH-1号车受铁速度
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setValue(opcData.getData());
|
|
|
realtimeData.setUnit("t/s");
|
|
|
|
|
|
RealtimeData ironSpeed = (RealtimeData) mRealtimeData.get(IRON_SPEED);
|
|
@@ -316,12 +446,14 @@ public class DeviceEventListener extends EventListener {
|
|
|
speeds = (RealtimeData[]) ironSpeed.getValue();
|
|
|
}
|
|
|
|
|
|
- if (mOPCData.getPointName().contains(TAG_CAR11)) {
|
|
|
+ if (opcData.getPointName().contains(TAG_CAR11)) {
|
|
|
realtimeData.setDesc("1号车");
|
|
|
speeds[0] = realtimeData;
|
|
|
+ speed1 = Float.parseFloat(opcData.getData().toString());
|
|
|
} else {
|
|
|
realtimeData.setDesc("2号车");
|
|
|
speeds[1] = realtimeData;
|
|
|
+ speed2 = Float.parseFloat(opcData.getData().toString());
|
|
|
}
|
|
|
|
|
|
//只在两个都有数据的时候才添加
|
|
@@ -329,75 +461,62 @@ public class DeviceEventListener extends EventListener {
|
|
|
&& ObjectUtils.isNotEmpty(speeds[0]) && ObjectUtils.isNotEmpty(speeds[0].getValue())
|
|
|
&& ObjectUtils.isNotEmpty(speeds[1]) && ObjectUtils.isNotEmpty(speeds[1].getValue())
|
|
|
) {
|
|
|
- ironSpeed.setTime(mOPCData.getServerTime().toString());
|
|
|
+ ironSpeed.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
RedisUtils.addFixedElement(IRON_SPEED, ironSpeed, 6);
|
|
|
+ PushData.send2TrendIronSpeed(RedisUtils.getFixedElement(IRON_SPEED));
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- ironWeight.setTime(mOPCData.getServerTime().toString());
|
|
|
- RedisUtils.addFixedElement(IRON_WEIGHT, ironWeight, 6);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (mOPCData.getPointName().contains(TAG_TAPHOLE1_STATUS)) {
|
|
|
+ } else if (opcData.getPointName().contains(TAG_TAPHOLE1_STATUS)) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setValue(opcData.getData());
|
|
|
realtimeData.setDesc("出铁状态");
|
|
|
mRealtimeStatus.put(IRON_STATUS, realtimeData);
|
|
|
- }
|
|
|
|
|
|
-// if (mOPCData.getPointName().contains(CAR_STATUS)) {
|
|
|
-// RealtimeData realtimeData = new RealtimeData();
|
|
|
-// realtimeData.setValue(mOPCData.getData());
|
|
|
-// realtimeData.setDesc("鱼雷罐车到位状态");
|
|
|
-// mRealtimeDataMap.put(CAR_STATUS, realtimeData);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// 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);
|
|
|
-// }
|
|
|
-
|
|
|
- if (mOPCData.getPointName().contains(FLUSH_STATUS)) {
|
|
|
+ ironLoading1 = "1".equals(opcData.getData().toString());
|
|
|
+
|
|
|
+ if (ironLoading1) {
|
|
|
+ taphole1Start(l2Data);
|
|
|
+ } else {
|
|
|
+ taphole1End();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (opcData.getPointName().contains(TAG_TAPHOLE2_STATUS)) {
|
|
|
+ ironLoading2 = "1".equals(opcData.getData().toString());
|
|
|
+ if (!ironLoading2) {
|
|
|
+ mIronEndTimeRecently = opcData.getServerTime();
|
|
|
+ }
|
|
|
+ } else if (opcData.getPointName().contains(TAG_TAPHOLE3_STATUS)) {
|
|
|
+ ironLoading3 = "1".equals(opcData.getData().toString());
|
|
|
+ if (!ironLoading3) {
|
|
|
+ mIronEndTimeRecently = opcData.getServerTime();
|
|
|
+ }
|
|
|
+ } else if (opcData.getPointName().contains(TAG_TAPHOLE4_STATUS)) {
|
|
|
+ ironLoading4 = "1".equals(opcData.getData().toString());
|
|
|
+ if (!ironLoading4) {
|
|
|
+ mIronEndTimeRecently = opcData.getServerTime();
|
|
|
+ }
|
|
|
+ } else if (opcData.getPointName().contains(TAG_IRON_WEIGHT11) || opcData.getPointName().contains(TAG_IRON_WEIGHT12)) {
|
|
|
+ //铁水流量
|
|
|
+ RealtimeData ironWeight = new RealtimeData();
|
|
|
+ ironWeight.setDesc("铁水流量");
|
|
|
+ ironWeight.setUnit("t");
|
|
|
+ BigDecimal bigDecimalNew = new BigDecimal(opcData.getData().toString());
|
|
|
+ totalWeight = totalWeight.add(bigDecimalNew);
|
|
|
+ ironWeight.setValue(totalWeight);
|
|
|
+ mRealtimeData.put(IRON_WEIGHT, ironWeight);
|
|
|
+ log.info(">>>>>>>>>>>>>{}:{},total:{}", opcData.getPointName(), opcData.getData(), totalWeight.toPlainString());
|
|
|
+
|
|
|
+ ironWeight.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
+ RedisUtils.addFixedElement(IRON_WEIGHT, ironWeight, 6);
|
|
|
+ PushData.send2TrendIronWeight(RedisUtils.getFixedElement(IRON_WEIGHT));
|
|
|
+
|
|
|
+ } else if (opcData.getPointName().contains(FLUSH_STATUS)) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setValue(opcData.getData());
|
|
|
realtimeData.setDesc("冲渣状态");
|
|
|
mRealtimeStatus.put(FLUSH_STATUS, realtimeData);
|
|
|
- }
|
|
|
-
|
|
|
- if (mOPCData.getPointName().contains(PLAN_END_TIME)) {
|
|
|
+ } else if (opcData.getPointName().contains(PLAN_END_TIME)) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(mOPCData.getData());
|
|
|
+ realtimeData.setValue(opcData.getData());
|
|
|
realtimeData.setDesc("预计出铁结束时间");
|
|
|
mRealtimeData.put(PLAN_END_TIME, realtimeData);
|
|
|
}
|
|
@@ -409,13 +528,14 @@ public class DeviceEventListener extends EventListener {
|
|
|
PushData.send2Warn(AjaxResult.success("预警出铁"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(mL2Data)) {
|
|
|
+ if (ObjectUtils.isNotEmpty(l2Data)) {
|
|
|
//铁水成分
|
|
|
//预计出铁结束时间
|
|
|
- String elementSi = mL2Data.getElementSi();
|
|
|
- String elementS = mL2Data.getElementS();
|
|
|
+ String elementSi = l2Data.getElementSi();
|
|
|
+ String elementS = l2Data.getElementS();
|
|
|
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
realtimeData.setValue(elementSi);
|
|
@@ -446,10 +566,7 @@ public class DeviceEventListener extends EventListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void operate() {
|
|
|
- if (ObjectUtils.isEmpty(mOPCData)) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ private synchronized void operate(OPCData mOPCData) {
|
|
|
String pointName = mOPCData.getPointName();
|
|
|
Object data = mOPCData.getData();
|
|
|
for (IronStepVO stepDTO : mSteps) {
|
|
@@ -497,9 +614,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
setStepResult(mSteps);
|
|
|
|
|
|
|
|
|
- ironReady();
|
|
|
-
|
|
|
-
|
|
|
PushData.send2Operation(mSteps, ironLoading1);
|
|
|
|
|
|
}
|
|
@@ -543,87 +657,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //炉前在接受到炉内出铁要求后,10分钟内打开铁口,未打开系统告警并记录
|
|
|
- if (isReady) {
|
|
|
- TimerTask task = new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- System.out.println("倒计时结束!10分钟已到。");
|
|
|
- timer.cancel(); // 终止定时器
|
|
|
- // 打开系统告警并记录
|
|
|
- PushData.send2Warn("warn");
|
|
|
- log.info("准备出铁但是未及时出铁口,此处数据库记录");
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- // 倒计时10分钟(600秒)
|
|
|
- long delay = 10 * 60 * 1000; // 10分钟转换为毫秒
|
|
|
- // 在指定延迟后执行任务
|
|
|
- timer.schedule(task, delay);
|
|
|
- }
|
|
|
-
|
|
|
- //根据PLC订阅的数据,AOD25606.PV=1为出铁中,AOD25606.PV=0出铁结束的信号,进行判断
|
|
|
- //为1表示开始出铁,此时如果未超过10分钟,就取消定时器
|
|
|
- //出铁结束
|
|
|
- if (mOPCData.getPointName().contains(TAG_TAPHOLE1_STATUS)) {
|
|
|
- //1:出铁中
|
|
|
- //0:出铁结束
|
|
|
- ironLoading1 = "1".equals(mOPCData.getData());
|
|
|
-
|
|
|
- if ("1".equals(mOPCData.getData())) {
|
|
|
- //由 0 -> 1
|
|
|
- //表明1号铁口正在出铁
|
|
|
- //根据理论铁量、实时铁水流速,推测距离出铁结束的剩余时间
|
|
|
- //剩余时间=总时间-已经流去的时间
|
|
|
-// mContext.lookupVariable("");
|
|
|
- //计算理论铁量= 矿批 × 综合品位 × 1.06,其中矿批是指L2中的干量
|
|
|
-
|
|
|
-// Date ironTime = mOPCData.getServerTime();
|
|
|
-// lastIronEndTimeRecently
|
|
|
-
|
|
|
-
|
|
|
- } else if ("0".equals(mOPCData.getData())) {
|
|
|
- //由 1-> 0
|
|
|
- try {
|
|
|
- timer.cancel(); // 终止定时器
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- recordAfter();
|
|
|
- recordBlock();
|
|
|
-
|
|
|
- //出铁结束后,查询最近两次的数据
|
|
|
- LambdaQueryWrapper<TIronData> queryWrapper = new QueryWrapper<TIronData>().lambda().orderByDesc(TIronData::getCtcsbh);
|
|
|
- List<TIronData> oldIronDataList = ironDataService.list(queryWrapper);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/***
|
|
|
* 判断是否通过
|
|
|
* @param stepVO
|
|
@@ -640,11 +673,12 @@ public class DeviceEventListener extends EventListener {
|
|
|
}
|
|
|
stepVO.setStepName(flowName);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("stepId:{},identifier:{},stepName:{}", stepVO.getStepId(), stepVO.getIdentifier(), flowName);
|
|
|
+ //log.info("stepId:{},identifier:{},stepName:{}", stepVO.getStepId(), stepVO.getIdentifier(), flowName);
|
|
|
}
|
|
|
|
|
|
//非流程必须项,直接放行
|
|
|
- if ("0".equals(stepVO.getRequired())) {
|
|
|
+ //正在出铁中,直接发行
|
|
|
+ if ("0".equals(stepVO.getRequired()) || ironLoading1) {
|
|
|
stepVO.setPassResult(1);
|
|
|
return;
|
|
|
}
|
|
@@ -661,15 +695,6 @@ public class DeviceEventListener extends EventListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //出铁后,记录炉次、开口时间、鱼雷罐车车号、铁口深度、铁水流速
|
|
|
- private void recordAfter() {
|
|
|
- ironAfterService.add(null);
|
|
|
- }
|
|
|
-
|
|
|
- //堵口后,记录堵口时间、出铁量,打泥量、是否喷溅、是否跑泥
|
|
|
- private void recordBlock() {
|
|
|
- ironBlockService.add(null);
|
|
|
- }
|
|
|
|
|
|
/***
|
|
|
* 用户端点击触发
|