فهرست منبع

opc 采集存库

guoqiang 7 ماه پیش
والد
کامیت
9e8a28e47c

+ 1 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/service/IFpgGatherDataService.java

@@ -11,4 +11,5 @@ import org.jeecg.modules.gatherData.entity.FpgGatherData;
  */
 public interface IFpgGatherDataService extends IService<FpgGatherData> {
 
+    void addC(FpgGatherData fpgGatherData);
 }

+ 6 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/service/impl/FpgGatherDataServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.gatherData.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
 import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
 import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
@@ -16,4 +18,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class FpgGatherDataServiceImpl extends ServiceImpl<FpgGatherDataMapper, FpgGatherData> implements IFpgGatherDataService {
 
+    @Override
+    public void addC(FpgGatherData fpgGatherData) {
+        baseMapper.insert(fpgGatherData);
+    }
 }

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

@@ -10,6 +10,8 @@ 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.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.scheduling.annotation.EnableAsync;
@@ -17,6 +19,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
 
@@ -32,6 +36,9 @@ public class OpcGatherWatch {
     @Autowired
     IDevicePointService devicePointService;
 
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
+
     @Autowired
     MongoTemplate mongoTemplate;
 
@@ -74,7 +81,7 @@ public class OpcGatherWatch {
 
     //opc数据采集
     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);
         //获取当前时间
@@ -116,6 +123,13 @@ public class OpcGatherWatch {
                         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);
                     }
                 }
             } catch (Exception e) {