全业务考评 1 рік тому
батько
коміт
a0abdf37ad

+ 11 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/common/config/GyeeConfig.java

@@ -39,6 +39,9 @@ public class GyeeConfig {
     private String filePathFitting;
     /** 配置文件路径 **/
     private String filePathPower;
+   //报警、预警数据(原始数据)
+    private String filePathAlarm;
+
     /**
      * 数据压缩下载
      **/
@@ -118,4 +121,12 @@ public class GyeeConfig {
     public String getGfDataPath() {
         return getFilePathPrepare() + "gf" + File.separator;
     }
+
+    public String getFilePathAlarm() {
+        return  jarF.getParentFile().getAbsolutePath() + File.separator +filePathAlarm;
+    }
+
+    public void setFilePathAlarm(String filePathAlarm) {
+        this.filePathAlarm = filePathAlarm;
+    }
 }

+ 15 - 2
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/fj/DataFittingController.java

@@ -6,6 +6,7 @@ import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
 import com.gyee.power.fitting.model.ProEconPowerFittingAnalySis;
 import com.gyee.power.fitting.model.custom.PowerPointData;
+import com.gyee.power.fitting.model.vo.AlarmVo;
 import com.gyee.power.fitting.service.custom.curve.DataFittingService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -100,8 +101,20 @@ public class DataFittingController {
      * @return
      */
     @GetMapping("filter")
-    public JSONObject dataFittingFilter(String yk, String wk){
-        List<PowerPointData> list = fittingService.dataOrigin(yk, wk);
+    public JSONObject dataFittingFilter(String yk, String wk,String only){
+        List<PowerPointData> list = fittingService.dataOrigin(yk, wk,only);
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+    /**
+     * 获取故障或预警数据
+     * @param table
+     * @param only
+     * @return
+     */
+    @GetMapping("alarms")
+    public JSONObject getDataAlarms(String table,String only){
+        List<AlarmVo> list = fittingService.getDataAlarms(table,only);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 

+ 21 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/AlarmTsXmlMapper.java

@@ -0,0 +1,21 @@
+package com.gyee.power.fitting.mapper;
+
+
+
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.vo.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+@DS("slave")
+@Mapper
+public interface AlarmTsXmlMapper extends BaseMapper<AlarmTsXml> {
+
+    List<AlarmVo> findTagsByDeviceidInDate(@Param("superTableName") String superTableName, @Param("deviceid")  List<String> deviceid, @Param("date")List<String> date);
+
+}

+ 17 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/vo/AlarmTsXml.java

@@ -0,0 +1,17 @@
+package com.gyee.power.fitting.model.vo;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.sql.Timestamp;
+
+@Data
+@ToString
+public class AlarmTsXml {
+
+    private Timestamp ts;
+    private Integer val;
+    private Integer oval;
+    private Boolean confirmed;
+    private String tbName;
+}

+ 37 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/curve/DataFittingService.java

@@ -9,10 +9,12 @@ import com.gyee.power.fitting.common.util.DateUtil;
 import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.common.util.PowerFittingUtil;
 import com.gyee.power.fitting.common.util.SnowFlakeUtil;
+import com.gyee.power.fitting.mapper.AlarmTsXmlMapper;
 import com.gyee.power.fitting.model.*;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
 import com.gyee.power.fitting.model.anno.FixedVo;
 import com.gyee.power.fitting.model.custom.*;
+import com.gyee.power.fitting.model.vo.AlarmVo;
 import com.gyee.power.fitting.service.ProEconPowerFittingAnalySisService;
 import com.gyee.power.fitting.service.ProEconPowerModelService;
 import com.gyee.power.fitting.service.auth.TokenService;
@@ -49,6 +51,11 @@ public class DataFittingService {
     @Resource
     private TokenService tokenService;
 
+    @Resource
+    private AlarmTsXmlMapper alarmTsXmlMapper;
+
+
+
     /**
      * 曲线拟合
      * @param ids
@@ -339,7 +346,7 @@ public class DataFittingService {
      * @param wk
      * @return
      */
-    public List<PowerPointData> dataOrigin(String yk, String wk) {
+    public List<PowerPointData> dataOrigin(String yk, String wk,String only) {
         List<PowerPointData> list = new ArrayList<>();
 
         if (!StringUtils.isEmpty(yk)){
@@ -355,6 +362,35 @@ public class DataFittingService {
             }
         }
 
+        Map<String,List<PowerPointData>> map = new HashMap<>();
+        map.put(only,list);
+        dataScanService.setOnlyMap(map);
+        return list;
+    }
+
+    /**
+     *
+     * @param table
+     * @param only
+     * @return
+     */
+    public List<AlarmVo> getDataAlarms(String table, String only) {
+
+        List<PowerPointData> pointData =  dataScanService.getOnlyMap().get(only);
+
+        List<String> uniqueWtIds = pointData.stream()
+                .map(PowerPointData::getWtId)
+                .distinct()
+                .collect(Collectors.toList());
+
+
+        List<String> uniqueTimes = pointData.stream()
+                .map(PowerPointData::getTime)
+                .distinct()
+                .collect(Collectors.toList());
+
+        List<AlarmVo> list = alarmTsXmlMapper.findTagsByDeviceidInDate(table,uniqueWtIds, uniqueTimes);
+
         return list;
     }
 

+ 5 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/curve/DataScanService.java

@@ -17,4 +17,9 @@ public class DataScanService {
     public Map<String, List<PowerPointData>> mapYY;
 
     public Map<String, List<PowerPointData>> mapWY;
+
+    public Map<String,List<PowerPointData>> onlyMap;
+
+
+
 }

+ 36 - 18
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/ratedpower/RatedPowerService.java

@@ -1,17 +1,19 @@
 package com.gyee.power.fitting.service.custom.ratedpower;
 
+import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtil;
 import com.gyee.power.fitting.common.util.FileUtil;
-import com.gyee.power.fitting.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.*;
 import com.gyee.power.fitting.model.custom.PowerPointData;
-import com.gyee.power.fitting.service.PowerfittinganalysisService;
+import com.gyee.power.fitting.service.ProEconPowerFittingAnalySisService;
 import lombok.val;
+import org.apache.commons.collections4.list.TreeList;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
 
 /**
  * 额定功率分析
@@ -21,25 +23,39 @@ import java.util.Map;
 public class RatedPowerService {
 
     @Resource
-    private PowerfittinganalysisService powerService;
+    private ProEconPowerFittingAnalySisService powerService;
 
     public Object ratePowerAnalysis(String ids) {
         Map<String, Object> result = new HashMap<>();
-        List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list == null || list.size() == 0)
+        Map<String, ProEconEquipmentmodel> eqMap = InitialRunner.equipmentNewMap;
+        Map<String, ProBasicEquipment> wtMap = InitialRunner.wtNewMap;
+        List<ProEconPowerFittingAnalySis> list = powerService.listByIds(Arrays.asList(ids.split(",")));
+        if (list.size() == 0) {
             return result;
+        }
 
         List<PowerPointData> all = new ArrayList<>();
-        Map<String, Double> map = new HashMap<>();
-        for (Powerfittinganalysis obj : list){
-            List<PowerPointData> ls = csvParse(obj);
-            all.addAll(ls);
-            map.put(obj.getWindturbine(), ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble());
+        TreeList<Object> lst = new TreeList<>();
+        for (ProEconPowerFittingAnalySis obj : list){
+            String[] spid = obj.getProcessid().split(",");
+            for (String id : spid){
+                TreeMap<String, Object> mp = new TreeMap<>();
+                ProEconPowerFittingAnalySis item = powerService.getById(id);
+                List<PowerPointData> ls = csvParse(item);
+                all.addAll(ls);
+                double avg = ls.size() > 0 ? ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
+                mp.put("wt", InitialRunner.wtNewMap.get(item.getWindturbineId()).getNemCode());
+                mp.put("avg", new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue());
+                mp.put("count", ls.size());
+                lst.add(mp);
+            }
         }
-        double avgData = all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble();
+        double avg = all.size() > 0 ? all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
+        double avgData = new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue();
 
         result.put("avg", avgData);
-        result.put("data", map);
+        result.put("data", lst);
+        result.put("power", eqMap.get(wtMap.get(list.get(0).getWindturbineId()).getModelId()).getPowerProduction());
 
         return result;
     }
@@ -49,14 +65,16 @@ public class RatedPowerService {
      * @param obj
      * @return
      */
-    private List<PowerPointData> csvParse(Powerfittinganalysis obj){
+    private List<PowerPointData> csvParse(ProEconPowerFittingAnalySis obj){
         List<PowerPointData> list = new ArrayList<>();
         val content = FileUtil.readFile(obj.getPath(), true);
         for (int i = 1; i < content.size(); i++){
             String[] split = content.get(i).split(",");
             PowerPointData data = new PowerPointData(split, false);
-            if (data.getSpeed() >= 12.0)
+            if (data.getSpeed() >= 12.0){
+                data.setTime(DateUtil.format(data.getTime(), DateUtil.DATE_PATTERN));
                 list.add(data);
+            }
         }
 
         return list;

+ 2 - 0
power-fitting-JN/src/main/resources/application.yaml

@@ -12,6 +12,8 @@ gyee:
   file-path-download: data/zip/
   # 功率曲线离线数据保存路径
   file-path-power: data/power/
+  # 报警、预警数据(原始数据)
+  file-path-alarm: data/alarm/
   # 数据准备时由于数据量太大,初始一个默认间隔,用于适配器取数
   interval: 20
   # 当前是否是离线环境

+ 24 - 0
power-fitting-JN/src/main/resources/mapper/AlarmTsXmlMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gyee.power.fitting.mapper.AlarmTsXmlMapper">
+
+
+    <select id="findTagsByDeviceidInDate" resultType="com.gyee.power.fitting.model.vo.AlarmVo">
+
+        select * from ${superTableName}
+        <where>
+
+            <if test="date !=null">
+                AND ts in
+                <foreach item="item" collection="date" separator="," open="(" close=")" index="">'${item}'</foreach>
+            </if>
+
+            <if test="deviceid !=null">
+                AND deviceid in
+                <foreach item="item" collection="deviceid" separator="," open="(" close=")" index="">'${item}'</foreach>
+            </if>
+
+        </where>
+
+    </select>
+</mapper>