Browse Source

新增升压站数据查询接口(electrical/electricaltestingpoint)

tianye 2 năm trước cách đây
mục cha
commit
f2e40a192f

+ 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;
+}

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

@@ -0,0 +1,27 @@
+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="electricaltestingpointai2")
+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="electricaltestingpointdi2")
+    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);
+
+}
+

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

@@ -0,0 +1,17 @@
+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);
+    List<ElectricalTestingPointDIEntity> findByUniformcode(String id);
+    //
+    List<ElectricalTestingPointDIEntity> findAllByWindpowerstationid(String windpowerstationid);
+}

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

@@ -0,0 +1,49 @@
+package com.gyee.wisdom.dataadapter.controller.thing;
+
+
+import com.gyee.wisdom.dataadapter.dto.ElectricalTest;
+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<ElectricalTest> 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<ElectricalTest> list = new ArrayList<>();
+        if (type.equals("AI")){
+           list = electricalTestingPointService.queryByUniformcodeNameWindpowerstationidAI(uniformcode, name, windpowerstationid);
+        }
+
+        if(type.equals("DI")){
+           list = electricalTestingPointService.queryByUniformcodeNameWindpowerstationidDI(uniformcode, name, windpowerstationid);
+
+        }
+
+
+        if (type.equals("")){
+           list = electricalTestingPointService.queryByUniformcodeNameWindpowerstationidAI(uniformcode, name, windpowerstationid);
+           List<ElectricalTest> list2 = electricalTestingPointService.queryByUniformcodeNameWindpowerstationidDI(uniformcode, name, windpowerstationid);
+           list.addAll(list2);
+        }
+        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.ElectricalTest;
+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 JpaElectricalTestingPointAIDao;
+
+    @Autowired
+    protected ElectricalTestingPointDIDao JpaElectricalTestingPointDIDao;
+
+
+    //uniformcode,name,windpowerstationid
+    public List<ElectricalTest>  queryByUniformcodeNameWindpowerstationidAI(String uniformcode, String name, String windpowerstationid){
+        List<ElectricalTest> list = new ArrayList<>();
+        List<ElectricalTestingPointAI> electricalTestingPointAIS = JpaElectricalTestingPointAIDao.findByUniformcodeNameWindpowerstationid(uniformcode,name,windpowerstationid);
+        for (ElectricalTestingPointAI ElectricalTestingPointAI : electricalTestingPointAIS){
+            ElectricalTest test = new ElectricalTest();
+            test.setId(ElectricalTestingPointAI.getId());
+            test.setName(ElectricalTestingPointAI.getName());
+            test.setUniformcode(ElectricalTestingPointAI.getUniformcode());
+            test.setWindpowerstationid(ElectricalTestingPointAI.getWindpowerstationid());
+            list.add(test);
+        }
+        return list;
+    }
+
+    public List<ElectricalTest> queryByUniformcodeNameWindpowerstationidDI(String uniformcode,String name,String windpowerstationid) {
+        List<ElectricalTest> list = new ArrayList<>();
+        List<ElectricalTestingPointDI> electricalTestingPointDIS = JpaElectricalTestingPointDIDao.findByUniformcodeNameWindpowerstationid(uniformcode, name, windpowerstationid);
+        for (ElectricalTestingPointDI electricalTestingPointDI : electricalTestingPointDIS) {
+            ElectricalTest test = new ElectricalTest();
+            test.setId(electricalTestingPointDI.getId());
+            test.setName(electricalTestingPointDI.getName());
+            test.setUniformcode(electricalTestingPointDI.getUniformcode());
+            test.setWindpowerstationid(electricalTestingPointDI.getWindpowerstationid());
+            list.add(test);
+        }
+        return list;
+    }
+}

+ 20 - 0
data-adapter/src/main/java/com/gyee/wisdom/dataadapter/dto/ElectricalTest.java

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