Kaynağa Gözat

1.实时折线图、图例图完善

wangxiaofei 2 ay önce
ebeveyn
işleme
3d30fd880e

+ 1 - 1
taphole-common/src/main/java/com/sckj/common/eventbus/EventListener.java → taphole-common/src/main/java/com/sckj/common/eventbus/AbstractEventListener.java

@@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
  * @Date 2024-11-19 上午 11:08
  * @Description TODO
  */
-public abstract class EventListener implements InitializingBean, DisposableBean {
+public abstract class AbstractEventListener implements InitializingBean, DisposableBean {
 
     @Autowired
     protected AsyncEventBus asyncEventBus;

+ 3 - 3
taphole-iron/src/main/java/com/sckj/iron/constant/StepConstans.java

@@ -10,9 +10,6 @@ public class StepConstans {
     //预判和确认出铁
     public static final String STEP_LNCT = "lnct";
 
-    //炉前出铁操作
-    public static final String STEP_LQCTCZ = "lqctcz";
-
     //铁量差
     public static final String STEP_TLC = "tlc";
 
@@ -39,4 +36,7 @@ public class StepConstans {
 
     //上上次铁次号
     public static final String ssctch = "ssctch";
+
+    //近两次铁量差
+    public static final String tlcjlc = "tlcjlc";
 }

+ 251 - 56
taphole-iron/src/main/java/com/sckj/iron/service/impl/TIronVisualScreenServiceImpl.java

@@ -41,19 +41,15 @@ public class TIronVisualScreenServiceImpl {
      * @return
      */
     public Map<String, Object> getIronLegend(Map<String, Object> result) {
-        java.util.Date startTime = new java.util.Date();
 
         // L2类
-        TL2Data preL2 = tl2DataService.lambdaQuery()
-                .le(TL2Data::getIronStarttime, new SimpleDateFormat("yyyyMMddHHmmss").format(startTime))
-                .orderByDesc(TL2Data::getIronStarttime)
-                .last("limit 1").one();
-
-        result.put("elementS", RealtimeData.builder().desc("铁水成分-硫").value(preL2.getElementS()).build());
-        result.put("elementSi", RealtimeData.builder().desc("铁水成分-硅").value(preL2.getElementSi()).build());
-        result.put("mudWeight", RealtimeData.builder().desc("泥炮量").value(preL2.getMudWeight()).unit("L").build());
-        result.put("pollMm", RealtimeData.builder().desc("钻杆直径").value(preL2.getPollMm()).unit("mm").build());
-        result.put("openDepth", RealtimeData.builder().desc("开口深度").value(preL2.getOpenDepth()).unit("mm").build());
+        CompletableFuture<TL2Data> preL2Future = CompletableFuture.supplyAsync(() ->
+                tl2DataService.lambdaQuery()
+                        .le(TL2Data::getIronStarttime, new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date()))
+                        .eq(TL2Data::getTapholeId,"1")
+                        .orderByDesc(TL2Data::getIronStarttime)
+                        .last("limit 1").one()
+        );
 
         // 1. 计算起止时间
         int hours = 24;
@@ -62,52 +58,247 @@ public class TIronVisualScreenServiceImpl {
         java.util.Calendar cal = java.util.Calendar.getInstance();
         cal.setTime(endTime);
         cal.add(java.util.Calendar.HOUR_OF_DAY, -hours);
-        startTime = cal.getTime();
-        List<OPCData> list = opcDataService.lambdaQuery()
-                .in(OPCData::getPointName, Arrays.asList(
-                        "BF4_1TH_2_TPC_CARNO",                      // 1TH-2号车混铁车车号
-                        "BF4_1TH_1_TPC_CARNO"                       // 1TH-1号车混铁车车号
-                ))
-                .between(OPCData::getServerTime, startTime, endTime)
-                .orderByAsc(OPCData::getServerTime)
-                .list();
-        if (ObjectUtils.isNotEmpty(list)) {
-            RealtimeData ironWeight = (RealtimeData) result.getOrDefault("ironWeight", RealtimeData.builder().desc("铁水流量").unit("t").value(0).build());
-            List<Map<String, Object>> collect = list.stream().map(item -> {
-                Map<String, Object> map = new HashMap<>();
-                map.put("data", item.getData());
-                map.put("createTime", sdfMinute.format(item.getSourceTime()));
-                return map;
-            }).collect(Collectors.toList());
-
-            Map<String, Object> extraMap = new HashMap<>();
-            extraMap.put("mark", collect);
-            ironWeight.setExtra(extraMap);
-
-            result.put("ironWeight", ironWeight);
+        java.util.Date startTime = cal.getTime();
+
+
+        // 1. 生成完整的每一分钟时间点
+        java.util.List<String> xAxis = new java.util.ArrayList<>();
+        java.util.Calendar cursor = java.util.Calendar.getInstance();
+        cursor.setTime(startTime);
+        while (!cursor.getTime().after(endTime)) {
+            xAxis.add(sdfMinute.format(cursor.getTime()));
+            cursor.add(java.util.Calendar.MINUTE, 1);
         }
 
-        List<TL2Data> list1 = tl2DataService.lambdaQuery()
-                .between(TL2Data::getIronStarttime,
-                        new SimpleDateFormat("yyyyMMddHHmmss").format(startTime),
-                        new SimpleDateFormat("yyyyMMddHHmmss").format(endTime))
-                .orderByAsc(TL2Data::getIronStarttime)
-                .list();
-
-        if (ObjectUtils.isNotEmpty(list1)) {
-            RealtimeData ironCosttime = (RealtimeData) result.getOrDefault("ironCosttime", RealtimeData.builder().desc("出铁时间").unit("min").value(0).build());
-            List<Map<String, Object>> collect = list1.stream().map(item -> {
-                Map<String, Object> map = new HashMap<>();
-                map.put("data", String.format("第%s次出铁(%s号铁口)%s分钟",item.getIronNo(),item.getTapholeId(),item.getIronCosttime()));
-                map.put("createTime", TimeUtils.formatPartialDateString(item.getIronStarttime()));
-                return map;
-            }).collect(Collectors.toList());
-
-            Map<String, Object> extraMap = new HashMap<>();
-            extraMap.put("mark", collect);
-            ironCosttime.setExtra(extraMap);
-
-            result.put("ironCosttime", ironCosttime);
+        //获取指定时间范围内的数据
+        CompletableFuture<List<OPCData>> opcDataFuture = CompletableFuture.supplyAsync(() ->
+                opcDataService.lambdaQuery()
+                        .in(OPCData::getPointName, Arrays.asList(
+                                "BF4_1TH_1_MIR_NWT",                        // 四高炉1TH-1号车铁水净重
+                                "BF4_1TH_2_MIR_NWT",                     // 四高炉1TH-2号车铁水净重
+                                "BF4_1_IRONNOTCH_TAPPING",                      // 四高炉1TH-2号车铁水净重
+                                "BF4_1TH_2_TPC_CARNO",                      // 1TH-2号车混铁车车号
+                                "BF4_1TH_1_TPC_CARNO"                       // 1TH-1号车混铁车车号
+                        ))
+                        .between(OPCData::getServerTime, startTime, endTime)
+                        .orderByAsc(OPCData::getServerTime)
+                        .list()
+        );
+
+        //获取指定时间范围的L2数据
+        CompletableFuture<List<TL2Data>> l2DataFuture = CompletableFuture.supplyAsync(() ->
+                tl2DataService.lambdaQuery()
+                        .between(TL2Data::getIronStarttime,
+                                new SimpleDateFormat("yyyyMMddHHmmss").format(startTime),
+                                new SimpleDateFormat("yyyyMMddHHmmss").format(endTime))
+                        .eq(TL2Data::getTapholeId, "1")
+                        .orderByAsc(TL2Data::getIronStarttime)
+                        .list()
+        );
+
+
+        //获取上一个有效状态数据
+        CompletableFuture<OPCData> preTappingFuture = CompletableFuture.supplyAsync(() ->
+                opcDataService.lambdaQuery()
+                        .eq(OPCData::getPointName, "BF4_1_IRONNOTCH_TAPPING")
+                        .isNotNull(OPCData::getData)
+                        .lt(OPCData::getServerTime, startTime)
+                        .orderByDesc(OPCData::getServerTime)
+                        .last("limit 1").one()
+        );
+
+        Integer preTappingVal = null;
+
+
+        try {
+            CompletableFuture.allOf(preTappingFuture, preL2Future, opcDataFuture).join();
+            Map<String, List<OPCData>> opcDataMap = opcDataFuture.get().stream()
+                    .collect(Collectors.groupingBy(OPCData::getPointName));
+
+            TL2Data preL2 = preL2Future.get();
+
+
+            OPCData preTapping = preTappingFuture.get();
+
+            if (preTapping != null && preTapping.getData() != null) {
+                Object v = preTapping.getData();
+                if (v instanceof Number) preTappingVal = ((Number) v).intValue();
+                else if (v instanceof String) {
+                    String str = ((String) v).trim();
+                    if (!str.isEmpty()) {
+                        try {
+                            preTappingVal = Integer.parseInt(str);
+                        } catch (Exception ignore) {
+                        }
+                    }
+                }
+            }
+
+            result.put("elementS", RealtimeData.builder().desc("铁水成分-硫").value(preL2.getElementS()).build());
+            result.put("elementSi", RealtimeData.builder().desc("铁水成分-硅").value(preL2.getElementSi()).build());
+            result.put("mudWeight", RealtimeData.builder().desc("泥炮量").value(preL2.getMudWeight()).unit("L").build());
+            result.put("pollMm", RealtimeData.builder().desc("钻杆直径").value(preL2.getPollMm()).unit("mm").build());
+            result.put("openDepth", RealtimeData.builder().desc("开口深度").value(preL2.getOpenDepth()).unit("mm").build());
+
+            //BF4_1TH_1_MIR_NWT 1号车净重
+            CompletableFuture<List<IronTrendL1DTO>> weight1ListFuture = CompletableFuture.supplyAsync(() ->
+                    opcDataMap.getOrDefault("BF4_1TH_1_MIR_NWT", new ArrayList<>())
+                            .stream().map(item -> {
+                                IronTrendL1DTO dto = new IronTrendL1DTO();
+                                dto.setData(item.getData());
+                                dto.setCreateTime(item.getSourceTime());
+                                return dto;
+                            }).collect(Collectors.toList())
+            );
+
+            //BF4_1TH_2_MIR_NWT 2号车净重
+            CompletableFuture<List<IronTrendL1DTO>> weight2ListFuture = CompletableFuture.supplyAsync(() ->
+                    opcDataMap.getOrDefault("BF4_1TH_2_MIR_NWT", new ArrayList<>())
+                            .stream().map(item -> {
+                                IronTrendL1DTO dto = new IronTrendL1DTO();
+                                dto.setData(item.getData());
+                                dto.setCreateTime(item.getSourceTime());
+                                return dto;
+                            }).collect(Collectors.toList())
+            );
+
+            //BF4_1TH_1_TPC_CARNO 2号车净重
+            CompletableFuture<List<IronTrendL1DTO>> car1ListFuture = CompletableFuture.supplyAsync(() ->
+                    opcDataMap.getOrDefault("BF4_1TH_1_TPC_CARNO", new ArrayList<>())
+                            .stream().map(item -> {
+                                IronTrendL1DTO dto = new IronTrendL1DTO();
+                                dto.setData(item.getData());
+                                dto.setCreateTime(item.getSourceTime());
+                                return dto;
+                            }).collect(Collectors.toList())
+            );
+
+            //BF4_1TH_2_TPC_CARNO 2号车净重
+            CompletableFuture<List<IronTrendL1DTO>> car2ListFuture = CompletableFuture.supplyAsync(() ->
+                    opcDataMap.getOrDefault("BF4_1TH_2_TPC_CARNO", new ArrayList<>())
+                            .stream().map(item -> {
+                                IronTrendL1DTO dto = new IronTrendL1DTO();
+                                dto.setData(item.getData());
+                                dto.setCreateTime(item.getSourceTime());
+                                return dto;
+                            }).collect(Collectors.toList())
+            );
+            //BF4_1TH_2_TPC_CARNO 2号车净重
+            CompletableFuture<List<IronTrendL1DTO>> tapping1ListFuture = CompletableFuture.supplyAsync(() ->
+                    opcDataMap.getOrDefault("BF4_1_IRONNOTCH_TAPPING", new ArrayList<>())
+                            .stream().map(item -> {
+                                IronTrendL1DTO dto = new IronTrendL1DTO();
+                                dto.setData(item.getData());
+                                dto.setCreateTime(item.getSourceTime());
+                                return dto;
+                            }).collect(Collectors.toList())
+            );
+
+            // 等待所有转换完成
+            CompletableFuture.allOf(
+                    car1ListFuture,
+                    car2ListFuture,
+                    tapping1ListFuture,
+                    weight1ListFuture,
+                    weight2ListFuture
+            ).join();
+
+
+            // 构建每分钟tappingMap
+            Map<String, Integer> tappingMap = new LinkedHashMap<>();
+            List<OPCData> tappingList = opcDataMap.getOrDefault("BF4_1_IRONNOTCH_TAPPING", new ArrayList<>());
+            Map<String, Integer> rawTappingMap = new LinkedHashMap<>();
+            for (OPCData item : tappingList) {
+                if (item.getServerTime() != null && item.getData() != null) {
+                    String min = sdfMinute.format(item.getServerTime());
+                    Integer val = null;
+                    Object v = item.getData();
+                    if (v instanceof Number) val = ((Number) v).intValue();
+                    else if (v instanceof String) {
+                        String str = ((String) v).trim();
+                        if (!str.isEmpty()) {
+                            try {
+                                val = Integer.parseInt(str);
+                            } catch (Exception ignore) {
+                            }
+                        }
+                    }
+                    if (val != null) rawTappingMap.put(min, val);
+                }
+            }
+            Integer last = preTappingVal;
+            for (String t : xAxis) {
+                Integer v = rawTappingMap.getOrDefault(t, last);
+                tappingMap.put(t, v);
+                if (v != null) last = v;
+            }
+            List<IronTrendL1DTO> weight1List = weight1ListFuture.get();
+            List<IronTrendL1DTO> weight2List = weight2ListFuture.get();
+            List<IronTrendL1DTO> car1List = car1ListFuture.get();
+            List<IronTrendL1DTO> car2List = car2ListFuture.get();
+
+            int ironWeightScale = 2; // 可调整为0、1、2等
+            List<List<Object>> ironFlowArr = buildIronFlowMinuteArray(xAxis, tappingMap, weight1List, weight2List, ironWeightScale);
+
+            if (ObjectUtils.isNotEmpty(ironFlowArr)) {
+                List<Map<String, Object>> mapList = new ArrayList<>();
+                for (List<Object> objects : ironFlowArr) {
+                    String string = objects.get(0).toString();
+                    String data = objects.get(1).toString();
+                    for (IronTrendL1DTO ironTrendL1DTO : car1List) {
+                        if (sdfMinute.format(ironTrendL1DTO.getCreateTime()).equals(string)) {
+                            Map<String, Object> map = new HashMap<>();
+                            map.put("value", ironTrendL1DTO.getData());
+                            map.put("xAxis", sdfMinute.format(ironTrendL1DTO.getCreateTime()));
+                            map.put("yAxis", data);
+                            mapList.add(map);
+                        }
+                    }
+                    for (IronTrendL1DTO ironTrendL1DTO : car2List) {
+                        if (sdfMinute.format(ironTrendL1DTO.getCreateTime()).equals(string)) {
+                            Map<String, Object> map = new HashMap<>();
+                            map.put("value", ironTrendL1DTO.getData());
+                            map.put("xAxis", sdfMinute.format(ironTrendL1DTO.getCreateTime()));
+                            map.put("yAxis", data);
+                            mapList.add(map);
+                        }
+                    }
+                }
+                RealtimeData ironWeight = (RealtimeData) result.getOrDefault("ironWeight", RealtimeData.builder().desc("铁水流量").unit("t").value(0).build());
+                Map<String, Object> extraMap = new HashMap<>();
+                extraMap.put("mark", mapList);
+                ironWeight.setExtra(extraMap);
+
+                result.put("ironWeight", ironWeight);
+            }
+
+
+            List<TL2Data> tl2DataList = l2DataFuture.get();
+            if (ObjectUtils.isNotEmpty(tl2DataList)) {
+                RealtimeData ironCosttime = (RealtimeData) result.getOrDefault("ironCosttime", RealtimeData.builder().desc("出铁时间").unit("min").value(0).build());
+                List<List<Map<String, Object>>> collect = tl2DataList.stream().map(item -> {
+                    List<Map<String, Object>> mapList = new ArrayList<>();
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("name", String.format("第%s次出铁(%s号铁口)%s分钟", item.getIronNo(), item.getTapholeId(), item.getIronCosttime()));
+                    map.put("xAxis", TimeUtils.formatPartialDateString(item.getIronStarttime()));
+                    mapList.add(map);
+
+                    map = new HashMap<>();
+                    map.put("xAxis", TimeUtils.formatPartialDateString(item.getIronEndtime()));
+                    mapList.add(map);
+
+                    return mapList;
+                }).collect(Collectors.toList());
+
+                Map<String, Object> extraMap = new HashMap<>();
+                extraMap.put("mark", collect);
+                ironCosttime.setExtra(extraMap);
+                result.put("ironCosttime", ironCosttime);
+            }
+
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
 
 
@@ -155,6 +346,7 @@ public class TIronVisualScreenServiceImpl {
                         .between(TL2Data::getIronStarttime,
                                 new SimpleDateFormat("yyyyMMddHHmmss").format(startTime),
                                 new SimpleDateFormat("yyyyMMddHHmmss").format(endTime))
+                        .eq(TL2Data::getTapholeId,"1")
                         .orderByAsc(TL2Data::getIronStarttime)
                         .list()
         );
@@ -314,6 +506,7 @@ public class TIronVisualScreenServiceImpl {
                     // tappingMap补齐每一分钟,前面无数据用前置值补齐
                     // 先查区间前最近一条tapping
                     Integer preTappingVal = 0;
+
                     OPCData preTapping = opcDataService.lambdaQuery()
                             .eq(OPCData::getPointName, "BF4_1_IRONNOTCH_TAPPING")
                             .isNotNull(OPCData::getData)
@@ -324,6 +517,7 @@ public class TIronVisualScreenServiceImpl {
                     // L2类
                     TL2Data preL2 = tl2DataService.lambdaQuery()
                             .lt(TL2Data::getIronStarttime, new SimpleDateFormat("yyyyMMddHHmmss").format(startTime))
+                            .eq(TL2Data::getTapholeId,"1")
                             .orderByDesc(TL2Data::getIronStarttime)
                             .last("limit 1").one();
 
@@ -337,7 +531,7 @@ public class TIronVisualScreenServiceImpl {
                     result.put("openDepth", buildMinuteArray(elemenList, xAxis, "openDepth", preL2 != null ? preL2.getOpenDepth() : null));
 
 
-                    // 统计出铁累计重量递增曲线
+                    //
                     if (preTapping != null && preTapping.getData() != null) {
                         Object v = preTapping.getData();
                         if (v instanceof Number) preTappingVal = ((Number) v).intValue();
@@ -379,6 +573,7 @@ public class TIronVisualScreenServiceImpl {
                         tappingMap.put(t, v);
                         if (v != null) last = v;
                     }
+
                     int ironWeightScale = 2; // 可调整为0、1、2等
                     List<List<Object>> ironFlowArr = buildIronFlowMinuteArray(xAxis, tappingMap, weight1List, weight2List, ironWeightScale);
                     result.put("ironWeight", ironFlowArr);

+ 43 - 25
taphole-iron/src/main/java/com/sckj/iron/socketio/DeviceEventListener.java

@@ -7,7 +7,7 @@ import com.google.common.util.concurrent.AtomicDouble;
 import com.google.gson.Gson;
 import com.sckj.common.config.GlobalConfig;
 import com.sckj.common.enums.RefreshItemEnum;
-import com.sckj.common.eventbus.EventListener;
+import com.sckj.common.eventbus.AbstractEventListener;
 import com.sckj.common.manager.ScheduledTaskManager;
 import com.sckj.common.socketio.SocketUtil;
 import com.sckj.common.util.RedisUtils;
@@ -37,17 +37,19 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
 import org.springframework.expression.Expression;
 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.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -63,7 +65,7 @@ import java.util.stream.Collectors;
  */
 @Component
 @Slf4j
-public class DeviceEventListener extends EventListener { //
+public class DeviceEventListener extends AbstractEventListener { //
 
     //步骤数据
     @Resource
@@ -252,7 +254,11 @@ public class DeviceEventListener extends EventListener { //
     // 新增成员变量
     private double lastIronLoading1 = -1;
 
-    @PostConstruct
+    private String mCalcHitMud;
+
+
+    //    @PostConstruct
+    @EventListener(ApplicationReadyEvent.class)
     public void init() {
         taskExecutor.submit(() -> {
             mSteps = ironStepService.getTreeSteps();
@@ -273,7 +279,6 @@ public class DeviceEventListener extends EventListener { //
         });
 
 
-
         taskExecutor.submit(() -> {
             getSchedules();
 
@@ -305,13 +310,14 @@ public class DeviceEventListener extends EventListener { //
                 scheduledTaskManager.addTask(getIronChart.getName(), getIronChart.getDelay(), getIronChart.getPeriod(), TimeUnit.SECONDS, () -> {
                     PushData.send2Chart(tIronVisualScreenService.getIronChart(new TrendRequest()));
                 });
+
             }
 
             //图例数据
             TIronSchedule getIronLegend = scheduleMap.get(TaskNameConstants.TASKNAME_IRON_LEGEND);
             if (getIronLegend != null && "1".equals(getIronLegend.getStatus())) {
                 scheduledTaskManager.addTask(getIronLegend.getName(), getIronLegend.getDelay(), getIronLegend.getPeriod(), TimeUnit.SECONDS, () -> {
-                    mRealtimeLegend.put("ironCosttime",  RealtimeData.builder().desc("出铁时间").value(getIronElapsedMinute()).unit("min").build());
+                    mRealtimeLegend.put("ironCosttime", RealtimeData.builder().desc("出铁时间").value(getIronElapsedMinute()).unit("min").build());
                     PushData.send2Legend(tIronVisualScreenService.getIronLegend(mRealtimeLegend));
                 });
             }
@@ -506,10 +512,10 @@ public class DeviceEventListener extends EventListener { //
                         if ("glyc".equals(child.getIdentifier())) {
                             for (IronStepVO grandChild : child.getChilds()) {
                                 if ("ls".equals(grandChild.getIdentifier())) {
-                                    mContext.setVariable("ls",RedisUtils.getFixedLatestElement("materialSpeed"));
+                                    mContext.setVariable("ls", RedisUtils.getFixedLatestElement("materialSpeed"));
                                 }
                             }
-                        } else  if (StepConstans.STEP_TLC.equals(child.getIdentifier())) {
+                        } else if (StepConstans.STEP_TLC.equals(child.getIdentifier())) {
                             if (latest2DataList.size() >= 2) {
                                 //铁量差 = 理论出铁量 - 实际出铁量
                                 TL2Data tl2Data1Last = latest2DataList.get(0);
@@ -519,12 +525,15 @@ public class DeviceEventListener extends EventListener { //
 
                                 TL2Data tl2Data1Grand = latest2DataList.get(1);
                                 //
-                                BigDecimal theoryWeightGrand = new BigDecimal(tl2Data1Grand.getTheoryWeight()).add(theoryWeightLast).setScale(2, BigDecimal.ROUND_HALF_UP);
+                                BigDecimal theoryWeightGrand = new BigDecimal(tl2Data1Grand.getTheoryWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
                                 //
-                                BigDecimal ironWeightGrand = new BigDecimal(tl2Data1Grand.getIronWeight()).add(ironWeightLast).setScale(2, BigDecimal.ROUND_HALF_UP);
-                                //近两次铁量差=近两次
+                                BigDecimal ironWeightGrand = new BigDecimal(tl2Data1Grand.getIronWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
+
                                 BigDecimal tlcGrand = theoryWeightGrand.subtract(ironWeightGrand).setScale(2, BigDecimal.ROUND_HALF_UP);
 
+                                //近两次铁量差=近两次
+                                BigDecimal tlcjlc = tlcLast.add(tlcGrand);
+
                                 for (IronStepVO grandChild : child.getChilds()) {
                                     if (StepConstans.sctlc.equals(grandChild.getIdentifier())) {
                                         grandChild.setData(tlcLast);
@@ -538,10 +547,12 @@ public class DeviceEventListener extends EventListener { //
                                         grandChild.setData(ironWeightLast);
                                     } else if (StepConstans.sscsj.equals(grandChild.getIdentifier())) {
                                         grandChild.setData(ironWeightGrand);
-                                    }else if (StepConstans.sctch.equals(grandChild.getIdentifier())) {
+                                    } else if (StepConstans.sctch.equals(grandChild.getIdentifier())) {
                                         grandChild.setData(tl2Data1Last.getIronNo());
-                                    }else if (StepConstans.ssctch.equals(grandChild.getIdentifier())) {
+                                    } else if (StepConstans.ssctch.equals(grandChild.getIdentifier())) {
                                         grandChild.setData(tl2Data1Grand.getIronNo());
+                                    } else if (StepConstans.tlcjlc.equals(grandChild.getIdentifier())) {
+                                        grandChild.setData(tlcjlc);
                                     }
                                 }
 
@@ -648,7 +659,7 @@ public class DeviceEventListener extends EventListener { //
                         if (count >= triggerCount1) {
                             PushData.send2Warn(WarnData.warnClose("铁水流速过快告警", closureAlarmUrl));
                             taskExecutor.submit(() -> {
-                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("7000").exceptionDesc("铁水流速过快告警").build());
+                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("7000").exceptionDesc(String.format("流速%s吨/分钟",mContext.lookupVariable(ExpressionConstants.rtIronSpeed))).build());
                                 //推送预警列表
                                 getExceptionList();
                             });
@@ -670,7 +681,7 @@ public class DeviceEventListener extends EventListener { //
                         if (count >= triggerCount2) {
                             PushData.send2Warn(WarnData.warnClose("铁水流速过慢告警", closureAlarmUrl));
                             taskExecutor.submit(() -> {
-                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc("铁水流速过慢告警").build());
+                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc(String.format("流速%s吨/分钟",mContext.lookupVariable(ExpressionConstants.rtIronSpeed))).build());
                                 //推送预警列表
                                 getExceptionList();
                             });
@@ -692,7 +703,7 @@ public class DeviceEventListener extends EventListener { //
                         if (count >= triggerCount3) {
                             PushData.send2Warn(WarnData.warnClose("铁水流速过慢告警", closureAlarmUrl));
                             taskExecutor.submit(() -> {
-                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc("铁水流速过慢告警").build());
+                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc(String.format("流速%s吨/分钟",mContext.lookupVariable(ExpressionConstants.rtIronSpeed))).build());
                                 //推送预警列表
                                 getExceptionList();
                             });
@@ -727,9 +738,9 @@ public class DeviceEventListener extends EventListener { //
                             mContext.setVariable(ExpressionConstants.rtIronCosttime, getIronElapsedMinute());
                             //计算打泥量
                             BigDecimal bigDecimal = new BigDecimal(expression.getValue(mContext).toString());
-                            String formattedResult = bigDecimal.toBigInteger().toString();
-                            log.info("计算结果: {}", formattedResult);
-                            PushData.send2IronHitMud(formattedResult);
+                            mCalcHitMud = bigDecimal.toBigInteger().toString();
+                            log.info("计算结果: {}", mCalcHitMud);
+                            PushData.send2IronHitMud(mCalcHitMud);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
@@ -815,7 +826,8 @@ public class DeviceEventListener extends EventListener { //
             //出铁预警
             PushData.send2CancelWarn(WarnData.warnTapping("出铁结束", ""));
             //清空打泥量
-            PushData.send2IronHitMud("");
+            mCalcHitMud = "";
+            PushData.send2IronHitMud(mCalcHitMud);
 
             // 出铁诊断模型
             TIronSchedule tappingTest = scheduleMap.get(TaskNameConstants.TASKNAME_TAPPING_TEST);
@@ -896,7 +908,7 @@ public class DeviceEventListener extends EventListener { //
                             tappingWarnCountMap.put(modelKey, count);
                             if (count >= triggerCount) {
                                 PushData.send2Warn(WarnData.warnTapping("急需出铁告警", tappingAlramUrl));
-                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("10000").exceptionDesc("急需出铁告警").build());
+                                exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("10000").exceptionDesc("压差异常,当前压差:" + mContext.lookupVariable("yc")).build());
                                 tappingWarnCountMap.put(modelKey, 0);
                                 //推送预警列表
                                 getExceptionList();
@@ -1215,7 +1227,7 @@ public class DeviceEventListener extends EventListener { //
             lastStep = mSteps.get(mSteps.size() - 1);
         }
         // 1. 如果最后一个步骤为lqctcz且passResult为1,并且ironLoading1为1,则所有步骤passResult都保持为1
-        if (lastStep != null && StepConstans.STEP_LQCTCZ.equals(lastStep.getIdentifier()) && lastStep.getPassResult() == 1 && ironLoading1.get() == 1) {
+        if (lastStep != null && StepConstans.STEP_LNCT.equals(lastStep.getIdentifier()) && lastStep.getPassResult() == 1 && ironLoading1.get() == 1) {
             setAllStepPassResult(mSteps, 1);
             lastIronLoading1 = ironLoading1.get();
             return;
@@ -1379,23 +1391,27 @@ public class DeviceEventListener extends EventListener { //
                 //
                 List<TL2Data> tl2DataList = tl2DataService.getTappedLatest2Datas();
                 getTheoryWeight(tl2DataList);
-            } else if (StepConstans.STEP_LQCTCZ.equals(stepDTO.getIdentifier()) && stepDTO.getPassResult() == 1) {
+            } else if (StepConstans.STEP_LNCT.equals(stepDTO.getIdentifier()) && stepDTO.getPassResult() == 1) {
 
                 //炉前出铁操作,10分钟内打开铁口,未打开系统告警并记录
                 if ("1".equals(scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getStatus())) {
+
+                    LocalDateTime ldtStartTime = LocalDateTime.now();
+
                     scheduledTaskManager.addTask(scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getName(), StandardConstans.STANDARD_OPEN_HOUR * 60, scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getPeriod(), TimeUnit.SECONDS, () -> {
+                        LocalDateTime ldtEndTime = LocalDateTime.now();
+                        long minutesBetween = Duration.between(ldtStartTime, ldtEndTime).toMinutes();
                         log.info("开口预警");
                         // 出铁预警,打开系统告警并记录
                         PushData.send2Warn(WarnData.warnOpen("急需开口告警", openAlarmUrl));
                         taskExecutor.submit(() -> {
-                            exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("12000").exceptionDesc("急需开口告警").build());
+                            exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("12000").exceptionDesc(String.format("开口耗时:%s分钟", minutesBetween)).build());
                             //推送预警列表
                             getExceptionList();
                         });
                     });
                 }
 
-
             }
 
             for (IronStepVO child : stepDTO.getChilds()) {
@@ -1469,6 +1485,8 @@ public class DeviceEventListener extends EventListener { //
         PushData.send2RealtimeStatus(mRealtimeStatus);
         //获取最新出铁次数
         getIronTimeNo();
+        //获取打泥量
+        PushData.send2IronHitMud(mCalcHitMud);
     }
 
 

+ 3 - 3
taphole-l2-start/src/main/java/com/sckj/l2start/listener/L2EventListener.java

@@ -1,7 +1,7 @@
 package com.sckj.l2start.listener;
 
 import com.google.common.eventbus.Subscribe;
-import com.sckj.common.eventbus.EventListener;
+import com.sckj.common.eventbus.AbstractEventListener;
 import com.sckj.common.util.RedisUtils;
 import com.sckj.l2.entity.TL2Data;
 import com.sckj.l2.entity.TL2Material;
@@ -20,7 +20,7 @@ import java.util.List;
  */
 @Component
 @Slf4j
-public class L2EventListener extends EventListener {
+public class L2EventListener extends AbstractEventListener {
     //参数
     @Resource
     TL2DataServiceImpl tl2DataService;
@@ -42,7 +42,7 @@ public class L2EventListener extends EventListener {
             return;
         }
 //        log.info("onL2DataMessageEvent");
-        log.info("{}",dataList);
+        log.info("onL2DataMessageEvent >> {}",dataList);
 //        log.info("onL2DataMessageEvent");
         if (dataList.size() >= 23) {
             TL2Material tl2Material = new TL2Material();