3 Achegas 663fddd159 ... badf7d46c6

Autor SHA1 Mensaxe Data
  tianye badf7d46c6 Merge remote-tracking branch 'origin/master' %!s(int64=2) %!d(string=hai) anos
  tianye 65bd08f22b 新增升压站数据查询接口(electrical/electricaltestingpoint) %!s(int64=2) %!d(string=hai) anos
  tianye f2e40a192f 新增升压站数据查询接口(electrical/electricaltestingpoint) %!s(int64=2) %!d(string=hai) anos
Modificáronse 15 ficheiros con 578 adicións e 95 borrados
  1. 28 0
      common/data/src/main/java/com/gyee/wisdom/common/data/alarm/ElectricalTestingPointAI.java
  2. 28 0
      common/data/src/main/java/com/gyee/wisdom/common/data/alarm/ElectricalTestingPointDI.java
  3. 11 0
      dao/dao-interface/src/main/java/com/gyee/wisdom/dao/alarm/ElectricalTestingPointAIDao.java
  4. 10 0
      dao/dao-interface/src/main/java/com/gyee/wisdom/dao/alarm/ElectricalTestingPointDIDao.java
  5. 67 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/Entity/ElectricalTestingPointAIEntity.java
  6. 66 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/Entity/ElectricalTestingPointDIEntity.java
  7. 58 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/JpaElectricalTestingPointAIDao.java
  8. 53 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/JpaElectricalTestingPointDIDao.java
  9. 17 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/repository/ElectricalTestingPointAIRepository.java
  10. 14 0
      dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/repository/ElectricalTestingPointDIRepository.java
  11. 60 59
      dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaosLatestDao.java
  12. 51 0
      data-adapter/src/main/java/com/gyee/wisdom/dataadapter/controller/thing/ElectricalTestingPointController.java
  13. 52 0
      data-adapter/src/main/java/com/gyee/wisdom/dataadapter/domain/thing/ElectricalTestingPointService.java
  14. 17 0
      data-adapter/src/main/java/com/gyee/wisdom/dataadapter/dto/ElectricalDto.java
  15. 46 36
      data-adapter/src/main/java/com/gyee/wisdom/dataadapter/runner/SpringStartAfter.java

+ 28 - 0
common/data/src/main/java/com/gyee/wisdom/common/data/alarm/ElectricalTestingPointAI.java

@@ -0,0 +1,28 @@
+package com.gyee.wisdom.common.data.alarm;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class ElectricalTestingPointAI implements Serializable {
+    private static final long serialVersionUID = -7009408032434108640L;
+    private String id;
+    private String code;
+    private String name;
+    private String model;
+    private String valueUnit;
+    private String englishName;
+    private String typeId;
+    private String modelId;
+    private String maxVal;
+    private String minVal;
+    private String reasonablemaxval;
+    private String reasonableminval;
+    private String electricalId;
+    private String uniformCode;
+    private String shortId;
+    private String longId;
+    private String windPowerStationId;
+    private String realtimeId;
+}

+ 28 - 0
common/data/src/main/java/com/gyee/wisdom/common/data/alarm/ElectricalTestingPointDI.java

@@ -0,0 +1,28 @@
+package com.gyee.wisdom.common.data.alarm;
+
+import lombok.Data;
+
+import java.io.Serializable;
+@Data
+public class ElectricalTestingPointDI implements Serializable {
+    private static final long serialVersionUID = -7009408032434108640L;
+
+    private String id;
+    private String code;
+    private String name;
+    private String model;
+    private String valueUnit;
+    private String englishName;
+    private String typeId;
+    private String modelId;
+    private String maxVal;
+    private String minVal;
+    private String reasonablemaxval;
+    private String reasonableminval;
+    private String electricalId;
+    private String uniformCode;
+    private String shortId;
+    private String longId;
+    private String windPowerStationId;
+    private String realtimeId;
+}

+ 11 - 0
dao/dao-interface/src/main/java/com/gyee/wisdom/dao/alarm/ElectricalTestingPointAIDao.java

@@ -0,0 +1,11 @@
+package com.gyee.wisdom.dao.alarm;
+
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointAI;
+
+import java.util.List;
+
+    public interface ElectricalTestingPointAIDao {
+        List<ElectricalTestingPointAI> findByUniformcodeNameWindpowerstationid(String  uniformcode, String  name, String windpowerstationid);
+
+
+    }

+ 10 - 0
dao/dao-interface/src/main/java/com/gyee/wisdom/dao/alarm/ElectricalTestingPointDIDao.java

@@ -0,0 +1,10 @@
+package com.gyee.wisdom.dao.alarm;
+
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointDI;
+
+
+import java.util.List;
+
+public interface ElectricalTestingPointDIDao {
+    List<ElectricalTestingPointDI> findByUniformcodeNameWindpowerstationid(String  uniformcode, String  name, String windpowerstationid);
+}

+ 67 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/Entity/ElectricalTestingPointAIEntity.java

@@ -0,0 +1,67 @@
+package com.gyee.wisdom.dao.sql.alarm.Entity;
+
+import com.gyee.wisdom.common.data.ToData;
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointAI;
+import com.gyee.wisdom.common.data.alarm.WindturbineTestingpointAi;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.beans.BeanUtils;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+
+@Data
+@Entity
+@NoArgsConstructor
+@Table(name="electricaltestingpointai")
+public class ElectricalTestingPointAIEntity implements ToData<ElectricalTestingPointAI>, Serializable {
+    @Id
+    @Column(name = "id")
+    private String id;
+    @Column(name = "code")
+    private String code;
+    @Column(name = "name")
+    private String name;
+    @Column(name = "model")
+    private String model;
+    @Column(name = "valueunit")
+    private String valueUnit;
+    @Column(name = "englishname")
+    private String englishName;
+    @Column(name = "typeid")
+    private String typeId;
+    @Column(name = "modelid")
+    private String modelId;
+    @Column(name = "maxval")
+    private String maxVal;
+    @Column(name = "minval")
+    private String minVal;
+    @Column(name = "reasonablemaxval")
+    private String reasonablemaxval;
+    @Column(name = "reasonableminval")
+    private String reasonableminval;
+    @Column(name = "electricalid")
+    private String electricalId;
+    @Column(name = "uniformcode")
+    private String uniformCode;
+    @Column(name = "shortid")
+    private String shortId;
+    @Column(name = "longid")
+    private String longId;
+    @Column(name = "windpowerstationid")
+    private String windPowerStationId;
+    @Column(name = "realtimeid")
+    private String realtimeId;
+
+    @Override
+    public ElectricalTestingPointAI toData() {
+        ElectricalTestingPointAI electricalTestingPointAI = new ElectricalTestingPointAI();
+        BeanUtils.copyProperties(this,electricalTestingPointAI);
+        return electricalTestingPointAI;
+    }
+
+}

+ 66 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/Entity/ElectricalTestingPointDIEntity.java

@@ -0,0 +1,66 @@
+package com.gyee.wisdom.dao.sql.alarm.Entity;
+
+import com.gyee.wisdom.common.data.ToData;
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointDI;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.beans.BeanUtils;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+
+@Data
+@Entity
+@NoArgsConstructor
+@Table(name = "electricaltestingpointdi")
+public class ElectricalTestingPointDIEntity implements ToData<ElectricalTestingPointDI>, Serializable {
+    @Id
+    @Column(name = "id")
+    private String id;
+    @Column(name = "code")
+    private String code;
+    @Column(name = "name")
+    private String name;
+    @Column(name = "model")
+    private String model;
+    @Column(name = "valueunit")
+    private String valueUnit;
+    @Column(name = "englishname")
+    private String englishName;
+    @Column(name = "typeid")
+    private String typeId;
+    @Column(name = "modelid")
+    private String modelId;
+    @Column(name = "maxval")
+    private String maxVal;
+    @Column(name = "minval")
+    private String minVal;
+    @Column(name = "reasonablemaxval")
+    private String reasonablemaxval;
+    @Column(name = "reasonableminval")
+    private String reasonableminval;
+    @Column(name = "electricalid")
+    private String electricalId;
+    @Column(name = "uniformcode")
+    private String uniformCode;
+    @Column(name = "shortid")
+    private String shortId;
+    @Column(name = "longid")
+    private String longId;
+    @Column(name = "windpowerstationid")
+    private String windPowerStationId;
+    @Column(name = "realtimeid")
+    private String realtimeId;
+
+    @Override
+    public ElectricalTestingPointDI toData() {
+        ElectricalTestingPointDI electricalTestingPointDI = new ElectricalTestingPointDI();
+        BeanUtils.copyProperties(this, electricalTestingPointDI);
+        return electricalTestingPointDI;
+    }
+
+}

+ 58 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/JpaElectricalTestingPointAIDao.java

@@ -0,0 +1,58 @@
+package com.gyee.wisdom.dao.sql.alarm;
+
+import com.gyee.wisdom.common.data.DataUtil;
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointAI;
+import com.gyee.wisdom.dao.alarm.ElectricalTestingPointAIDao;
+import com.gyee.wisdom.dao.sql.alarm.Entity.ElectricalTestingPointAIEntity;
+import com.gyee.wisdom.dao.sql.alarm.repository.ElectricalTestingPointAIRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+@Component
+public class JpaElectricalTestingPointAIDao implements ElectricalTestingPointAIDao {
+
+    @Autowired
+    private ElectricalTestingPointAIRepository ElectricalTestingPointAIRepository;
+
+    @Override
+    public List<ElectricalTestingPointAI> findByUniformcodeNameWindpowerstationid(String uniformcode, String name, String windpowerstationid) {
+
+        return findTest(uniformcode,name,windpowerstationid);
+    }
+
+    public List<ElectricalTestingPointAI> findTest(String uniformcode, String name, String windpowerstationid) {
+        Specification querySpecifi = new Specification<ElectricalTestingPointAIEntity>() {
+            @Override
+            public Predicate toPredicate(Root<ElectricalTestingPointAIEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+
+                List<Predicate> predicates = new ArrayList<>();
+                if (uniformcode != null && !uniformcode.trim().equals("")) {
+                    predicates.add(criteriaBuilder.like(root.get("uniformCode"), "%" + uniformcode + "%" ));
+                }
+                if (name != null && !name.trim().equals("")) {
+                    predicates.add(criteriaBuilder.like(root.get("name"),"%" + name + "%" ));
+                }
+                if (windpowerstationid != null && !windpowerstationid.trim().equals("")) {
+                    predicates.add(criteriaBuilder.equal(root.get("windPowerStationId"), windpowerstationid));
+                }
+                return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+            }
+        };
+
+        List<ElectricalTestingPointAIEntity> all = ElectricalTestingPointAIRepository.findAll(querySpecifi);
+        return DataUtil.convertDataList(all);
+    }
+
+
+
+}

+ 53 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/JpaElectricalTestingPointDIDao.java

@@ -0,0 +1,53 @@
+package com.gyee.wisdom.dao.sql.alarm;
+
+import com.gyee.wisdom.common.data.DataUtil;
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointDI;
+import com.gyee.wisdom.dao.alarm.ElectricalTestingPointDIDao;
+import com.gyee.wisdom.dao.sql.alarm.Entity.ElectricalTestingPointDIEntity;
+import com.gyee.wisdom.dao.sql.alarm.repository.ElectricalTestingPointDIRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class JpaElectricalTestingPointDIDao implements ElectricalTestingPointDIDao {
+    @Autowired
+    private ElectricalTestingPointDIRepository ElectricalTestingPointDIRepository;
+
+
+    @Override
+    public List<ElectricalTestingPointDI> findByUniformcodeNameWindpowerstationid(String uniformcode, String name, String windpowerstationid) {
+
+        return findTest(uniformcode,name,windpowerstationid);
+    }
+
+    public List<ElectricalTestingPointDI> findTest(String uniformcode, String name, String windpowerstationid) {
+        Specification querySpecifi = new Specification<ElectricalTestingPointDIEntity>() {
+            @Override
+            public Predicate toPredicate(Root<ElectricalTestingPointDIEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+
+                List<Predicate> predicates = new ArrayList<>();
+                if (uniformcode != null && !uniformcode.trim().equals("")) {
+                    predicates.add(criteriaBuilder.like(root.get("uniformCode"), "%" + uniformcode + "%" ));
+                }
+                if (name != null && !name.trim().equals("")) {
+                    predicates.add(criteriaBuilder.like(root.get("name"),"%" + name + "%" ));
+                }
+                if (windpowerstationid != null && !windpowerstationid.trim().equals("")) {
+                    predicates.add(criteriaBuilder.equal(root.get("windPowerStationId"), windpowerstationid));
+                }
+                return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+            }
+        };
+
+        List<ElectricalTestingPointDIEntity> all = ElectricalTestingPointDIRepository.findAll(querySpecifi);
+        return DataUtil.convertDataList(all);
+    }
+}

+ 17 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/repository/ElectricalTestingPointAIRepository.java

@@ -0,0 +1,17 @@
+package com.gyee.wisdom.dao.sql.alarm.repository;
+
+import com.gyee.wisdom.common.data.point.ElectricalTestingPoint;
+import com.gyee.wisdom.dao.sql.alarm.Entity.ElectricalTestingPointAIEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface ElectricalTestingPointAIRepository extends JpaRepository<ElectricalTestingPointAIEntity, String>, JpaSpecificationExecutor {
+    List<ElectricalTestingPointAIEntity> findByUniformCodeAndNameAndWindPowerStationId(String uniformcode, String name, String windpowerstationid);
+
+}
+

+ 14 - 0
dao/dao-sql/src/main/java/com/gyee/wisdom/dao/sql/alarm/repository/ElectricalTestingPointDIRepository.java

@@ -0,0 +1,14 @@
+package com.gyee.wisdom.dao.sql.alarm.repository;
+
+
+import com.gyee.wisdom.dao.sql.alarm.Entity.ElectricalTestingPointDIEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface ElectricalTestingPointDIRepository extends JpaRepository<ElectricalTestingPointDIEntity, String>, JpaSpecificationExecutor {
+    ElectricalTestingPointDIEntity findAllById(String id);
+}

+ 60 - 59
dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaosLatestDao.java

@@ -56,18 +56,18 @@ public class TaosLatestDao implements ILatestDao {
         Statement st = config.getInstance().createStatement();
         StringBuilder sb = new StringBuilder();
         sb.append("insert into ");
-        for (TsPointData obj : list){
+        for (TsPointData obj : list) {
             long time = obj.getTsData().getTs();
-            String point =config.getTableName(obj.getTagName()) ;
+            String point = config.getTableName(obj.getTagName());
             double value = obj.getTsData().getDoubleValue().get();
-           // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
+            // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
             sb.append(point).append(" values (");
             sb.append(time).append(",").append(value).append(")");
         }
 
         val i = st.executeUpdate(sb.toString());
 
-        return i==list.size()? list.size() : 0;
+        return i == list.size() ? list.size() : 0;
     }
 
     @Override
@@ -75,11 +75,11 @@ public class TaosLatestDao implements ILatestDao {
         Statement st = config.getInstance().createStatement();
         StringBuilder sb = new StringBuilder();
         sb.append("insert into ");
-        for (TsPointData obj : list){
+        for (TsPointData obj : list) {
             long time = obj.getTsData().getTs();
             String point = obj.getTagName();
             String value = obj.getTsData().getStringValue().get();
-           // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
+            // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
             sb.append(point).append(" values (");
             sb.append(time).append(",'").append(value).append("') ");
         }
@@ -93,11 +93,11 @@ public class TaosLatestDao implements ILatestDao {
         Statement st = config.getInstance().createStatement();
         StringBuilder sb = new StringBuilder();
         sb.append("insert into ");
-        for (TsPointData obj : list){
+        for (TsPointData obj : list) {
             long time = obj.getTsData().getTs();
             String point = obj.getTagName();
             boolean value = obj.getTsData().getBooleanValue().get();
-           // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
+            // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
             sb.append(point).append(" values (");
             sb.append(time).append(",").append(value).append(")");
         }
@@ -111,7 +111,7 @@ public class TaosLatestDao implements ILatestDao {
         Statement st = config.getInstance().createStatement();
         StringBuilder sb = new StringBuilder();
         sb.append("insert into ");
-        for (TsPointData obj : list){
+        for (TsPointData obj : list) {
             long time = obj.getTsData().getTs();
             String point = obj.getTagName();
             long value = obj.getTsData().getLongValue().get();
@@ -131,11 +131,12 @@ public class TaosLatestDao implements ILatestDao {
 
     @Override
     public int writeCoordinateLatest(List<TsPointData> list) throws Exception {
-            return 0;
+        return 0;
     }
 
     /**
      * 由于taos数据库中全部是DOUBLE类型,故不需要区分类型
+     *
      * @param dataList
      * @return
      * @throws Exception
@@ -147,32 +148,32 @@ public class TaosLatestDao implements ILatestDao {
         Map<TsDataType, List<TsPointData>> pointGroup = dataList.stream().collect(Collectors.groupingBy(TsPointData::findDataType));
         for (Map.Entry<TsDataType, List<TsPointData>> entry : pointGroup.entrySet()) {
             List<TsPointData> pointDataList = entry.getValue();
-//            if (entry.getKey() == TsDataType.DOUBLE) {
+            if (entry.getKey() == TsDataType.DOUBLE) {
                 int count = writeDoubleLatest(pointDataList);
                 writeCount = writeCount + count;
-//            } else if (entry.getKey() == TsDataType.BOOLEAN) {
-//                int count = writeBooleanLatest(pointDataList);
-//                writeCount = writeCount + count;
-//            } else if (entry.getKey() == TsDataType.STRING) {
-//                int count = writeStringLatest(pointDataList);
-//                writeCount = writeCount + count;
-//            } else if (entry.getKey() == TsDataType.BLOB) {
-//                int count = writeBlobLatest(pointDataList);
-//                writeCount = writeCount + count;
-//            } else if (entry.getKey() == TsDataType.COORDINATE) {
-//                int count = writeCoordinateLatest(pointDataList);
-//                writeCount = writeCount + count;
-//            } else if (entry.getKey() == TsDataType.LONG) {
-//                int count = writeLongLatest(pointDataList);
-//                writeCount = writeCount + count;
-//            }
+            } else if (entry.getKey() == TsDataType.BOOLEAN) {
+                int count = writeBooleanLatest(pointDataList);
+                writeCount = writeCount + count;
+            } else if (entry.getKey() == TsDataType.STRING) {
+                int count = writeStringLatest(pointDataList);
+                writeCount = writeCount + count;
+            } else if (entry.getKey() == TsDataType.BLOB) {
+                int count = writeBlobLatest(pointDataList);
+                writeCount = writeCount + count;
+            } else if (entry.getKey() == TsDataType.COORDINATE) {
+                int count = writeCoordinateLatest(pointDataList);
+                writeCount = writeCount + count;
+            } else if (entry.getKey() == TsDataType.LONG) {
+                int count = writeLongLatest(pointDataList);
+                writeCount = writeCount + count;
+            }
+            }
+            return writeCount > 0 ? true : false;
         }
-        return writeCount > 0 ? true : false;
-    }
 
-    public Map<String, TsData> getDoubleTsDataSnapshots(String... tagNames) throws Exception {
-        Map<String, TsData> tsDataMap = new HashMap<>();
-        Statement st = config.getInstance().createStatement();
+        public Map<String, TsData> getDoubleTsDataSnapshots (String...tagNames) throws Exception {
+            Map<String, TsData> tsDataMap = new HashMap<>();
+            Statement st = config.getInstance().createStatement();
 //        for (String tag : tagNames) {
 //            String tableName = config.getTableName(tag);
 //
@@ -181,39 +182,39 @@ public class TaosLatestDao implements ILatestDao {
 //                tsDataMap.put(tag, new DoubleTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getDouble(2)));
 //            }
 //        }
-         String inString = Arrays.stream(tagNames).map(s -> "'" + s + "'").collect(Collectors.joining(","));
-        ResultSet rs = st.executeQuery("select last_row(*) from by_fdc.windturbine  where point in ("+ inString+") group by tbname;");
+            String inString = Arrays.stream(tagNames).map(s -> "'" + s + "'").collect(Collectors.joining(","));
+            ResultSet rs = st.executeQuery("select last_row(*) from by_fdc.windturbine  where point in (" + inString + ") group by tbname;");
 
-        while (rs.next()){
-            tsDataMap.put(rs.getString(3).toUpperCase(), new DoubleTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getDouble(2)));
+            while (rs.next()) {
+                tsDataMap.put(rs.getString(3).toUpperCase(), new DoubleTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getDouble(2)));
+            }
+            return tsDataMap;
         }
-        return tsDataMap;
-    }
 
-    public Map<String, TsData> getLongTsDataSnapshots(String... tagNames) throws Exception {
-        Map<String, TsData> tsDataMap = new HashMap<>();
-        Statement st = config.getInstance().createStatement();
-        for (String tag : tagNames) {
-            String tableName = config.getTableName(tag);
-            ResultSet rs = st.executeQuery("select last_row(*) from " + tableName);
-            while (rs.next()) {
-                tsDataMap.put(tag, new LongTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getLong(2)));
+        public Map<String, TsData> getLongTsDataSnapshots (String...tagNames) throws Exception {
+            Map<String, TsData> tsDataMap = new HashMap<>();
+            Statement st = config.getInstance().createStatement();
+            for (String tag : tagNames) {
+                String tableName = config.getTableName(tag);
+                ResultSet rs = st.executeQuery("select last_row(*) from " + tableName);
+                while (rs.next()) {
+                    tsDataMap.put(tag, new LongTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getLong(2)));
+                }
             }
+            return tsDataMap;
         }
-        return tsDataMap;
-    }
 
-    public Map<String, TsData> getBooleanTsDataSnapshots(String... tagNames) throws Exception {
-        Map<String, TsData> tsDataMap = new HashMap<>();
-        Statement st = config.getInstance().createStatement();
-        for (String tag : tagNames) {
-            String tableName = config.getTableName(tag);
-            ResultSet rs = st.executeQuery("select last_row(*) from " + tableName);
-            while (rs.next()) {
-                tsDataMap.put(tag, new BooleanTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getBoolean(2)));
+        public Map<String, TsData> getBooleanTsDataSnapshots (String...tagNames) throws Exception {
+            Map<String, TsData> tsDataMap = new HashMap<>();
+            Statement st = config.getInstance().createStatement();
+            for (String tag : tagNames) {
+                String tableName = config.getTableName(tag);
+                ResultSet rs = st.executeQuery("select last_row(*) from " + tableName);
+                while (rs.next()) {
+                    tsDataMap.put(tag, new BooleanTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getBoolean(2)));
+                }
             }
+            return tsDataMap;
         }
-        return tsDataMap;
-    }
 
-}
+    }

+ 51 - 0
data-adapter/src/main/java/com/gyee/wisdom/dataadapter/controller/thing/ElectricalTestingPointController.java

@@ -0,0 +1,51 @@
+package com.gyee.wisdom.dataadapter.controller.thing;
+
+
+import com.gyee.wisdom.common.utils.StringUtil;
+import com.gyee.wisdom.dataadapter.dto.ElectricalDto;
+import com.gyee.wisdom.dataadapter.domain.thing.ElectricalTestingPointService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+@RequestMapping("/electrical")
+@CrossOrigin
+public class ElectricalTestingPointController {
+    @Autowired
+    protected ElectricalTestingPointService electricalTestingPointService;
+
+
+    @GetMapping("/electricaltestingpoint")
+    public List<ElectricalDto> getElectricalTestingPoint(
+//            @RequestParam(value = "pagenum",required = true) Integer pageNum,
+//            @RequestParam(value = "pagesize",required = true) Integer pageSize,
+            @RequestParam(value = "windpowerstationid", required = true) String windpowerstationid,
+            @RequestParam(value = "name", required = false) String name,
+            @RequestParam(value = "uniformcode", required = false) String uniformcode,
+            @RequestParam(value = "type", required = false) String type
+    ) {
+        List<ElectricalDto> list = new ArrayList<>();
+        if (StringUtil.isBlank(type)){
+            list = electricalTestingPointService.getElectricalDtoAI(uniformcode, name, windpowerstationid);
+            List<ElectricalDto> list2 = electricalTestingPointService.getElectricalDtoDI(uniformcode, name, windpowerstationid);
+            list.addAll(list2);
+        }
+       else if (type.equals("AI")){
+           list = electricalTestingPointService.getElectricalDtoAI(uniformcode, name, windpowerstationid);
+        }
+       else if(type.equals("DI")){
+           list = electricalTestingPointService.getElectricalDtoDI(uniformcode, name, windpowerstationid);
+
+        }
+       else{
+
+        }
+
+        return list;
+
+    }
+
+}

+ 52 - 0
data-adapter/src/main/java/com/gyee/wisdom/dataadapter/domain/thing/ElectricalTestingPointService.java

@@ -0,0 +1,52 @@
+package com.gyee.wisdom.dataadapter.domain.thing;
+
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointAI;
+import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointDI;
+import com.gyee.wisdom.dao.alarm.ElectricalTestingPointAIDao;
+import com.gyee.wisdom.dao.alarm.ElectricalTestingPointDIDao;
+import com.gyee.wisdom.dataadapter.dto.ElectricalDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class ElectricalTestingPointService {
+
+    @Autowired
+    protected ElectricalTestingPointAIDao electricalTestingPointAIDao;
+
+    @Autowired
+    protected ElectricalTestingPointDIDao electricalTestingPointDIDao;
+
+
+    //uniformcode,name,windpowerstationid
+    public List<ElectricalDto>  getElectricalDtoAI(String uniformcode, String name, String windpowerstationid){
+        List<ElectricalDto> list = new ArrayList<>();
+        List<ElectricalTestingPointAI> electricalTestingPointAIS = electricalTestingPointAIDao.findByUniformcodeNameWindpowerstationid(uniformcode,name,windpowerstationid);
+        for (ElectricalTestingPointAI ElectricalTestingPointAI : electricalTestingPointAIS){
+            ElectricalDto data = new ElectricalDto();
+            data.setId(ElectricalTestingPointAI.getId());
+            data.setName(ElectricalTestingPointAI.getName());
+            data.setUniformcode(ElectricalTestingPointAI.getUniformCode());
+            data.setWindpowerstationid(ElectricalTestingPointAI.getWindPowerStationId());
+            list.add(data);
+        }
+        return list;
+    }
+
+    public List<ElectricalDto> getElectricalDtoDI(String uniformcode,String name,String windpowerstationid) {
+        List<ElectricalDto> list = new ArrayList<>();
+        List<ElectricalTestingPointDI> electricalTestingPointDIS = electricalTestingPointDIDao.findByUniformcodeNameWindpowerstationid(uniformcode, name, windpowerstationid);
+        for (ElectricalTestingPointDI electricalTestingPointDI : electricalTestingPointDIS) {
+            ElectricalDto data = new ElectricalDto();
+            data.setId(electricalTestingPointDI.getId());
+            data.setName(electricalTestingPointDI.getName());
+            data.setUniformcode(electricalTestingPointDI.getUniformCode());
+            data.setWindpowerstationid(electricalTestingPointDI.getWindPowerStationId());
+            list.add(data);
+        }
+        return list;
+    }
+}

+ 17 - 0
data-adapter/src/main/java/com/gyee/wisdom/dataadapter/dto/ElectricalDto.java

@@ -0,0 +1,17 @@
+package com.gyee.wisdom.dataadapter.dto;
+
+import lombok.Data;
+
+import javax.persistence.Column;
+import java.io.Serializable;
+
+@Data
+public class ElectricalDto implements Serializable {
+
+    //返回值类型(标签点名、场站ID、中文描述、统一编码)
+    private String id;
+    private String name;
+    private String uniformcode;
+    private String windpowerstationid;
+
+}

+ 46 - 36
data-adapter/src/main/java/com/gyee/wisdom/dataadapter/runner/SpringStartAfter.java

@@ -55,33 +55,30 @@ public class SpringStartAfter implements ApplicationRunner {
     @Override
     public void run(ApplicationArguments args) throws Exception {
 
-     // initDatabase("HNJ_FDC");
-
-//        Random r = new Random();
-//        Long ts = new Date().getTime();
-//        final List<TsPoint> allTsPoint = thingsPointDao.getAllTsPoint().stream().filter(s -> !s.getThingId().equals("BY_FDC")).collect(Collectors.toList());
-//        List<TsPointData> dataList = new ArrayList<>();
-//        for (TsPoint point :
-//                allTsPoint) {
-//            TsPointData tsPointData = new TsPointData();
-//            tsPointData.setTagName(point.getId());
-//            GeneralTsData generalTsData = new GeneralTsData();
-//            Double speed = r.nextDouble() * 6 + 3;
-//            generalTsData.setDoubleValue(java.util.Optional.of(speed));
-//            ts = ts + 1000;
-//            generalTsData.setTs(ts);
-//            tsPointData.setTsData(generalTsData);
-//            dataList.add(tsPointData);
-//        }
-//
-//
-//
-//
-//        while (true) {
-//            Thread.sleep(999);
-//            writeThread(dataList).run();
-//
-//        }
+        // initDatabase("HNJ_FDC");
+
+        Random r = new Random();
+        Long ts = new Date().getTime();
+        final List<TsPoint> allTsPoint = thingsPointDao.getAllTsPoint().stream().filter(s -> !s.getThingId().equals("BY_FDC")).collect(Collectors.toList());
+        List<TsPointData> dataList = new ArrayList<>();
+        for (TsPoint point :
+                allTsPoint) {
+            TsPointData tsPointData = new TsPointData();
+            tsPointData.setTagName(point.getId());
+            GeneralTsData generalTsData = new GeneralTsData();
+            Double speed = r.nextDouble() * 6 + 3;
+            generalTsData.setDoubleValue(java.util.Optional.of(speed));
+            ts = ts + 1000;
+            generalTsData.setTs(ts);
+            tsPointData.setTsData(generalTsData);
+            dataList.add(tsPointData);
+        }
+
+        while (true) {
+            Thread.sleep(999);
+            writeThread(dataList).run();
+
+        }
 
 
     }
@@ -96,12 +93,25 @@ public class SpringStartAfter implements ApplicationRunner {
                 Long ts = new Date().getTime();
                 for (TsPointData tsPointData :
                         list) {
+
+
                     GeneralTsData generalTsData = new GeneralTsData();
-                    Double speed = r.nextDouble() * 6 + 3;
-                    generalTsData.setDoubleValue(java.util.Optional.of(speed));
 
-                    generalTsData.setTs(ts);
-                    tsPointData.setTsData(generalTsData);
+                    if (tsPointData.getTagName().contains("_DI00")) {
+                        boolean speed = new Random().nextBoolean();
+                        generalTsData.setDoubleValue(java.util.Optional.of(speed ? 1.0 : 0.0));
+
+                        generalTsData.setTs(ts);
+                        tsPointData.setTsData(generalTsData);
+                    } else {
+                        Double speed = r.nextDouble() * 6 + 3;
+                        generalTsData.setDoubleValue(java.util.Optional.of(speed));
+
+                        generalTsData.setTs(ts);
+                        tsPointData.setTsData(generalTsData);
+                    }
+
+
                 }
                 boolean b = latestDao.writeLatest(list);
             }
@@ -116,11 +126,11 @@ public class SpringStartAfter implements ApplicationRunner {
             final List<Windturbine> windturbines = windturbineService.queryWindturbine(stationName, "MY-1500");
 
             log.error("查询风机完毕" + windturbines.size());
-           // Class.forName("com.taosdata.jdbc.TSDBDriver");
-           // String jdbcUrl = "jdbc:TAOS://" + serverIp + ":" + serverPort + "/" + dbName + "?user=" + userName + "&password=" + password;
+            // Class.forName("com.taosdata.jdbc.TSDBDriver");
+            // String jdbcUrl = "jdbc:TAOS://" + serverIp + ":" + serverPort + "/" + dbName + "?user=" + userName + "&password=" + password;
 
-           Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
-           String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort + "/" + dbName + "?user=" + userName + "&password=" + password;
+            Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
+            String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort + "/" + dbName + "?user=" + userName + "&password=" + password;
 
             Properties connProps = new Properties();
             connProps.setProperty("charset", "UTF-8");
@@ -137,7 +147,7 @@ public class SpringStartAfter implements ApplicationRunner {
             statement.executeUpdate(createSTableSql);
 
 
-            final List<TsPoint> allTsPoint = thingsPointDao.getAllTsPoint().stream().filter(s->s.getTsDataType()== TsDataType.BOOLEAN).collect(Collectors.toList());
+            final List<TsPoint> allTsPoint = thingsPointDao.getAllTsPoint().stream().filter(s -> s.getTsDataType() == TsDataType.BOOLEAN).collect(Collectors.toList());
 
             Date st = new Date();
             for (Windturbine data :