guoqiang 7 months ago
parent
commit
bf0db6ab33

+ 17 - 78
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -2,22 +2,13 @@ package org.jeecg.modules.fpgJob;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.dataRepository.entity.PointData;
-import org.jeecg.modules.device.entity.DeviceInformation;
-import org.jeecg.modules.device.service.IDeviceInformationService;
-import org.jeecg.modules.deviceConn.opc.utils.OpcUaServerUtils;
-import org.jeecg.modules.devicePoint.entity.DevicePoint;
-import org.jeecg.modules.devicePoint.service.IDevicePointService;
-import org.jeecg.modules.events.service.ILeanEventsHostService;
-import org.jeecg.modules.gatherData.entity.FpgGatherData;
-import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
-import org.jeecg.modules.leanEventWarn.service.ILeanEventWarnInfoService;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
@@ -30,13 +21,7 @@ import java.util.List;
 public class LeanModelStatistics {
 
     @Autowired
-    IDeviceInformationService deviceInformationService;
-
-    @Autowired
-    IDevicePointService devicePointService;
-
-    @Autowired
-    IFpgGatherDataService fpgGatherDataService;
+    IFpgLeanModelService fpgLeanModelService;
 
     @Autowired
     MongoTemplate mongoTemplate;
@@ -44,79 +29,33 @@ public class LeanModelStatistics {
     @Autowired
     RedisTemplate redisTemplate;
 
-    @Autowired
-    ILeanEventsHostService leanEventsHostService;
-
-    @Autowired
-    ILeanEventWarnInfoService leanEventWarnInfoService;
+    @Scheduled(fixedDelay = 1000)
+    public void t1(){
+        opc("1000");
+    } // 1ms
 
     // 精益模型统计数据
     public void opc(String freq){
-        // 获取所有运行中设备(峰平谷)
-        LambdaQueryWrapper<DeviceInformation> opcquery = new LambdaQueryWrapper<DeviceInformation>().eq(DeviceInformation::getStatus, "0").eq(DeviceInformation::getFreq, freq);
-        List<DeviceInformation> opclist = deviceInformationService.list(opcquery);
+        // 峰平谷精益模型配置获取
+        LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
+        List<FpgLeanModel> opclist = fpgLeanModelService.list(leanmodelQuery);
+        log.info("峰平谷模型");
+
         //获取当前时间
         Date curentDate = new Date();
-        //遍历设备集合
+      /*  //遍历设备集合
         opclist.forEach(opcConn -> {
             //获取设备下所有点位
             List<DevicePoint> opcPoints = devicePointService.list( new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId,opcConn.getId()));
             OpcUaClient opcUaClient = null;
             String readText = "";
             try {
-                //与设备建立连接
-                opcUaClient = OpcUaServerUtils.connectOpcUaServer(opcConn);
-                //遍历设备下所有点位
-                 for (DevicePoint opcPoint : opcPoints) {
-                    try {
-                        //读取点位数据
-                        String nodeValue = OpcUaServerUtils.readNodeValue(opcUaClient, opcPoint.getNameindex(), opcPoint.getItemid());
-                        if (oConvertUtils.isEmpty(nodeValue)) {
-                            nodeValue = "";
-                        }
-                        //处理boolean类型数据 true为1 false为0
-                        readText = nodeValue.equals("true")?"1":nodeValue.equals("false")?"0":nodeValue;
-                        //将点位数据存入点位信息对象中
-                        opcPoint.setTestResult(nodeValue);
-                        //设置点位状态为正常
-                        opcPoint.setGatherStatus("0");
-                        //如果点位状态异常则恢复为正常
-                        if(opcPoint.getGatherStatus().equals(1)){
-                            opcPoint.setGatherStatus("0");
-                        }
-                    } catch (Exception e) {
-                        //打印点位异常日志
-                        log.error(e.getMessage());
-                        //设置点位状态为异常
-                        opcPoint.setGatherStatus("1");
-                    } finally {
-                        //将点位数据存入mongo中
-                        mongoTemplate.insert(new PointData(opcPoint, freq, readText, curentDate),  opcPoint.getId());
-                        //更新数据库点位信息
-                        devicePointService.updateById(opcPoint);
-                        // 存入采集设备
-                        FpgGatherData fpgGatherData = new FpgGatherData();
-                        fpgGatherData.setDeviceInformationId(opcConn.getId()); // 设备ID
-                        fpgGatherData.setDeviceRegionId(opcConn.getDeviceRegionId()); // 区域id
-                        fpgGatherData.setDevicePointId(opcPoint.getId()); // 采集点ID
-                        fpgGatherData.setCreateTime(curentDate); // 创建时间
-                        fpgGatherDataService.addC(fpgGatherData);
-                        if(oConvertUtils.isEmpty(opcConn.getId())){
-                            return;
-                        }
-                        String deviceInformationId = opcConn.getId();
-                    }
-                }
+
             } catch (Exception e) {
                 log.error(e.getMessage());
             } finally {
-                //更新数据库设备信息
-                deviceInformationService.updateById(opcConn);
-                //关闭连接
-                if(opcUaClient != null) {
-                    opcUaClient.disconnect();
-                }
+
             }
-        });
+        });*/
     }
 }

+ 1 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/DbWatch.java

@@ -20,6 +20,7 @@ import java.util.Calendar;
 @EnableAsync
 @Component
 @Slf4j
+
 public class DbWatch {
 
 

+ 2 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -26,10 +26,11 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
+//@EnableScheduling
 @Slf4j
 @EnableAsync
 @Component
-//@EnableScheduling
+
 public class OpcGatherWatch {
 
     @Autowired

+ 2 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java

@@ -19,10 +19,11 @@ import org.springframework.stereotype.Component;
 import java.util.Date;
 import java.util.List;
 
+//@EnableScheduling
 @Slf4j
 @EnableAsync
 @Component
-//@EnableScheduling
+
 public class modBusGatherWatch {
 
     @Autowired

+ 2 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

@@ -21,10 +21,11 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-@EnableScheduling
+//@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j
+
 public class s7gatherWatch {
 
     @Autowired