瀏覽代碼

代码提交

全业务考评 1 年之前
父節點
當前提交
023cf90db8

+ 158 - 12
power-fitting-JN/src/main/java/com.gyee.power.fitting/common/spring/InitialRunner.java

@@ -30,6 +30,7 @@ public class InitialRunner implements CommandLineRunner {
     GyeeConfig config;
     @Resource
     private WindturbineService windturbineService;
+
     @Resource
     private WindpowerstationService windpowerstationService;
     @Resource
@@ -46,6 +47,8 @@ public class InitialRunner implements CommandLineRunner {
      * 场站所有信息
      **/
     public static List<Windpowerstation> wpList = new ArrayList<>();
+
+
     /**
      * <MHS_FDC, 麻黄山风电场>
      **/
@@ -102,22 +105,115 @@ public class InitialRunner implements CommandLineRunner {
     /** key: NG01_01, speed, power**/
     public static Map<String, Map<Double, Double>> zsllglMap = new HashMap<>();
 
+
+
+
+
+    //--------------------------------------new-------------------------------------------
+
+
+    @Resource
+    private ProBasicEquipmentService proBasicEquipmentService;
+
+    @Resource
+    private ProBasicPowerstationService proBasicPowerstationService ;
+
+    @Resource
+    private ProBasicEquipmentPointService proBasicEquipmentPointService;
+
+    @Resource
+    private ProEconEquipmentmodelService proEconEquipmentmodelService;
+
+    @Resource
+    private ProBasicModelPowerService proBasicModelPowerService;
+
+    /**
+     * 场站所有信息
+     **/
+    public static List<ProBasicPowerstation> wpNewList = new ArrayList<>();
+
+    /**
+     * <MHS_FDC, 麻黄山风电场>
+     **/
+    public static Map<String, String> stationNewMap = new HashMap<>();
+
+    /**
+     * 所有的风机
+     **/
+    public static List<ProBasicEquipment> wtNewList = new ArrayList<>();
+    /**
+     * key:wtId NG01_01
+     **/
+    public static Map<String, ProBasicEquipment> wtNewMap = new HashMap<>();
+
+    /**场站的风机  key:NSS_FDC**/
+    public static Map<String, List<ProBasicEquipment>> wpNewMap = new HashMap<>();
+
+    /**
+     * 光伏
+     */
+    public static List<ProBasicPowerstation> gfwpNewList = new ArrayList<>();
+
+    public static Map<String, String> gfstationNewMap = new HashMap<>();
+    public static List<ProBasicEquipment> gfwtNewList = new ArrayList<>();
+    public static Map<String, ProBasicEquipment> gfwtNewMap = new HashMap<>();
+    public static Map<String, List<ProBasicEquipment>> gfwpNewMap = new HashMap<>();
+    /**
+     * 光照强度-场站
+     */
+    public static Map<String, ProBasicPowerstationPoint> zfsNewMap = new HashMap<>();
+    /**
+     * 组件温度-场站
+     */
+    public static Map<String, ProBasicPowerstationPoint> zjwdNewMap = new HashMap<>();
+    /**
+     * 功率-场站
+     */
+    public static Map<String, List<ProBasicEquipmentPoint>> zglNewMap = new HashMap<>();
+    /**
+     * 所有设备型号
+     **/
+    public static List<ProEconEquipmentmodel> equipmentNewList = new ArrayList<>();
+
+    /**
+     * key: NG01_01
+     **/
+    public static Map<String, List<ProBasicEquipmentPoint>> pointNewMap = new HashMap<>();
+    @Resource
+    public static Map<String, ProEconEquipmentmodel> equipmentNewMap = new HashMap<>();
+
+    /** key: NG01_01, speed, power**/
+    public static Map<String, Map<Double, Double>> zsllglNewMap = new HashMap<>();
+
+
+    //---------------------------------------------------------------------------------
+
+
+
+
+
+
     @Override
     public void run(String... args) {
         System.out.println(">>>>>>>>>>>>>>>服务启动,正在缓存数据<<<<<<<<<<<<<<");
 
-        cacheStation();
-        cachePoints();
-        cacheEquipment();
-        // 耗时缓存
-        new Thread(){
-            @Override
-            public void run() {
-                super.run();
-                cacheModelPower();
-                cacheZSLLGL(null);
-            }
-        }.start();
+//        cacheStation();
+//        cachePoints();
+//        cacheEquipment();
+//        // 耗时缓存
+//        new Thread(){
+//            @Override
+//            public void run() {
+//                super.run();
+//                cacheModelPower();
+//                cacheZSLLGL(null);
+//            }
+//        }.start();
+
+
+        cacheNewStation();
+        cacheNewPoints();
+        cacheNewEquipment();
 
         System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
     }
@@ -149,6 +245,28 @@ public class InitialRunner implements CommandLineRunner {
         log.info("场站数据缓存完成");
     }
 
+
+    /**
+     * 缓存场站、风机数据
+     * 数据新增或删除后需要更新,故每次清空
+     */
+    public void cacheNewStation() {
+        List<ProBasicPowerstation> stations = proBasicPowerstationService.list();
+        wpNewList = stations.stream().filter(f -> f.getId().contains("FDC")).collect(Collectors.toList());
+        wpNewList.forEach(obj -> {
+            List<ProBasicEquipment> wts =proBasicEquipmentService.list().stream().filter(w -> w.getWindpowerstationId().equals(obj.getId())).collect(Collectors.toList());;
+            stationNewMap.put(obj.getId(), obj.getName());
+            wpNewMap.put(obj.getId(), wts);
+            wtNewList.addAll(wts);
+
+            wts.forEach(u -> wtNewMap.put(u.getId(), u));
+        });
+        log.info("场站数据缓存完成");
+    }
+
+
+
+
     /**
      * 缓存测点数据
      */
@@ -161,6 +279,20 @@ public class InitialRunner implements CommandLineRunner {
             log.error("cachePoints", "测点数据缓存失败");
     }
 
+
+
+    /**
+     * 缓存测点数据
+     */
+    private void cacheNewPoints() {
+        List<ProBasicEquipmentPoint> list = new ArrayList<>();
+        wpNewList.stream().forEach(d -> list.addAll(proBasicEquipmentPointService.selectList(d.getId(), config.getPoints())));
+        pointNewMap.putAll(list.stream().collect(Collectors.groupingBy(u -> u.getWindturbineId())));
+        log.info("cachePoints: " + pointMap.size());
+        if (pointMap.size() == 0)
+            log.error("cachePoints", "测点数据缓存失败");
+    }
+
     /**
      * 缓存设备型号
      */
@@ -171,6 +303,17 @@ public class InitialRunner implements CommandLineRunner {
         log.info("设备型号数据缓存完成");
     }
 
+    /**
+     * 缓存设备型号
+     */
+    private void cacheNewEquipment() {
+        equipmentNewList.addAll(proEconEquipmentmodelService.list());
+        for (ProEconEquipmentmodel eq : equipmentNewList)
+            equipmentNewMap.put(eq.getId(), eq);
+        log.info("设备型号数据缓存完成");
+    }
+
+
     private void cacheModelPower() {
         List<Modelpowerdetails> lsMPD = modelpowerdetailsService.selectList();
         modelPowerDetailMap.putAll(lsMPD.stream().collect(Collectors.groupingBy(u -> u.getModelid())));
@@ -193,4 +336,7 @@ public class InitialRunner implements CommandLineRunner {
         log.info("自算功率数据缓存完成");
     }
 
+
+
+
 }

+ 25 - 29
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/newfj/NewDataFittingController.java

@@ -1,38 +1,34 @@
 package com.gyee.power.fitting.controller.newfj;
 
 
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.power.fitting.model.custom.NewDataFittingVo;
+import com.gyee.power.fitting.service.custom.curve.NewDataFittingService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 @RestController
 @CrossOrigin
 @RequestMapping("/new/power/fitting")
 public class NewDataFittingController {
-    
-    
-    
-//    * @param station       场站
-//     * @param wtIds         风机
-//     * @param st 			开始时间
-//     * @param et 			结束时间
-//     * @param interval		时间间隔
-//            
-//     * @param maxs     最大风速
-//     * @param mins     最小风速
-//     * @param maxp     最大功率
-//     * @param minp     最小功率
-//     * @param isfbw    非并网
-//     * @param isfhl    非合理值
-//     * @param isbw     并网后10分钟
-//     * @param istj     停机前10分钟
-//     * @param isglpc   功率曲线偏差
-//     * @param isqfh    是否欠符合
-//     * @param qfhdj    欠符合等级
-//            
-//     * @param dimension 多项式
-//     * @param mode  拟合方式  0:单台拟合  1:合并拟合  2:同名拟合
-
-
-    
+
+
+
+    @Autowired
+    private NewDataFittingService newDataFittingService;
+
+    /**
+     * 功率曲线拟合
+     * @param newDataFittingVo
+     * @return
+     */
+    @GetMapping("/data")
+    public JSONObject dataFitting(@RequestBody NewDataFittingVo newDataFittingVo ) {
+
+        newDataFittingService.newDataFitting(newDataFittingVo);
+
+        return null;
+    }
+
+
 }

+ 80 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/NewDataFittingVo.java

@@ -0,0 +1,80 @@
+package com.gyee.power.fitting.model.custom;
+
+import lombok.Data;
+
+@Data
+public class NewDataFittingVo {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 场站
+     */
+    private String station;
+    /**
+     * 风机
+     */
+    private String wtIds;
+    /**
+     * 开始时间
+     */
+    private Long st;
+    /**
+     * 结束时间
+     */
+    private Long et;
+    /**
+     * 时间间隔
+     */
+    private Integer interval;
+    /**
+     * 最大风速
+     */
+    private Double maxs;
+    /**
+     * 最小风速
+     */
+    private Double mins;
+    /**
+     * 最大功率
+     */
+    private Double maxp;
+    /**
+     * 最小功率
+     */
+    private Double minp;
+    /**
+     * 非并网
+     */
+    private Boolean isfbw;
+    /**
+     * 非合理值
+     */
+    private Boolean isfhl;
+    /**
+     * 并网后10分钟
+     */
+    private Boolean isbw;
+    /**
+     * 停机前10分钟
+     */
+    private Boolean istj;
+    /**
+     * 功率曲线偏差
+     */
+    private Boolean isglpc;
+    /**
+     * 是否欠符合
+     */
+    private Boolean isqfh;
+    /**
+     * 欠符合等级
+     */
+    private Integer qfhdj;
+    /**
+     * 多项式
+     */
+    private String dimension;
+    /**
+     *  拟合方式  0:单台拟合  1:合并拟合  2:同名拟合
+     */
+    private String mode;
+}

+ 20 - 17
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PowerPointData.java

@@ -37,45 +37,48 @@ public class PowerPointData {
     @Desc(des = "时间", remark = "1")
     private String time = "1970-01-01 00:00:00";
 
-    //功率
-    @Desc(des = "功率", uniformCode = "AI130", remark = "1")
+    //功率 AI114
+    @Desc(des = "功率", uniformCode = "AI114", remark = "1")
     private double power = 0;
 
-    //风速
-    @Desc(des = "风速", uniformCode = "AI022", remark = "1")
+    //风速 AI066
+    @Desc(des = "风速", uniformCode = "AI066", remark = "1")
     private double speed = 0;
 
-    //转速
-    @Desc(des = "转速",  uniformCode = "AI128", remark = "1")
+    //转速 AI060
+    @Desc(des = "转速",  uniformCode = "AI060", remark = "1")
     private double rr = 0;
 
     //明细状态
     // 0-待机  1-手动停机  2-正常发电  3-缺陷降出力  4-限电降出力  5-限电停机  6-故障停机
-    // 7-场内受累停机  8-检修停机  9-场内受累检修  10-电网受累  11-环境受累  12-风机离线
-    @Desc(des = "风机状态",  uniformCode = "ZTMX", remark = "1")
+    // 7-场内受累停机  8-检修停机  9-场内受累检修  10-电网受累  11-环境受累  12-风机离线 MXZT
+    @Desc(des = "风机状态",  uniformCode = "MXZT", remark = "1")
     private int mxzt = 0;
 
-    //电量
+    //电量 RFDL
     @Desc(des = "电量",  uniformCode = "RFDL", remark = "1")
     private double dl = 0;
 
-    //欠发状态
-    @Desc(des = "欠发状态",  uniformCode = "RSSQFZT", remark = "1")
+    //欠发状态 SSQFZT
+    @Desc(des = "欠发状态",  uniformCode = "SSQFZT", remark = "1")
     private int qfzt = 0;
 
-    //风向
-    @Desc(des = "风向",  uniformCode = "AI008", remark = "1")
+    //风向 AI067
+    @Desc(des = "风向",  uniformCode = "AI067", remark = "1")
     private double fx = 0;
 
     //对风误差
-    @Desc(des = "对风误差",  uniformCode = "AI036", remark = "1")
+    @Desc(des = "对风误差",  uniformCode = "AI073", remark = "1")
     private double dfwc = 0;
 
-    //偏航角度
-    @Desc(des = "偏航角度",  uniformCode = "AI034", remark = "1")
+    //偏航角度 AI073
+    @Desc(des = "偏航角度",  uniformCode = "AI073", remark = "1")
     private double angle = 0;
 
-    @Desc(des = "环境温度",  uniformCode = "AI056", remark = "1")
+    /**
+     * AI072
+     */
+    @Desc(des = "环境温度",  uniformCode = "AI072", remark = "1")
     private double hjwd = 0;
 
     //是否过滤  0:不过滤 1:过滤

+ 4 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentPointService.java

@@ -3,6 +3,8 @@ package com.gyee.power.fitting.service;
 import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 设备测点 服务类
@@ -13,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ProBasicEquipmentPointService extends IService<ProBasicEquipmentPoint> {
 
+    List<ProBasicEquipmentPoint> selectList(String station, List<String> points);
+
 }

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

@@ -0,0 +1,154 @@
+package com.gyee.power.fitting.service.custom.curve;
+
+
+import com.gyee.power.fitting.common.config.GyeeConfig;
+import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
+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.ProBasicEquipmentPoint;
+import com.gyee.power.fitting.model.anno.AnnotationTool;
+import com.gyee.power.fitting.model.anno.FixedVo;
+import com.gyee.power.fitting.model.custom.NewDataFittingVo;
+import com.gyee.power.fitting.model.custom.PowerPointData;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import lombok.extern.slf4j.Slf4j;
+import lombok.val;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class NewDataFittingService {
+    @Autowired
+    private GyeeConfig config;
+
+    @Autowired
+    private RemoteServiceBuilder remoteService;
+
+
+
+
+
+
+    public Powerfittinganalysis newDataFitting(NewDataFittingVo vo) {
+
+         Map<String,String>  prepareMap = new HashMap<>();
+
+         Map<String,String>  processMap = new HashMap<>();
+
+         Map<String,String>  fittingMap = new HashMap<>();
+
+
+        //1.数据获取
+        List<String> wtIds = Arrays.asList(vo.getWtIds().split(","));
+        for (int k = 0; k < wtIds.size(); k++) {
+            String wt = wtIds.get(k);
+            List<List<TsDoubleData>> result = new ArrayList<>();
+
+            try {
+                List<String> points = config.getPoints();
+                Map<String, List<ProBasicEquipmentPoint>> collect = InitialRunner.pointNewMap.get(wt).stream().collect(Collectors.groupingBy(w -> w.getUniformCode()));
+                if (collect.size() < 8)
+                    continue;
+                for (int i = 0; i < points.size(); i++) {
+                    ProBasicEquipmentPoint point = collect.get(points.get(i)).get(0);
+                    log.info("测点:" + point.getId() + "----" + point.getName());
+                    List<TsDoubleData> data = remoteService.adapter().getHistorySnap(point.getId(), vo.getSt(), vo.getEt(), vo.getInterval());
+                    if (data == null || data.size() < 0)
+                        break;
+                    result.add(data);
+                    TimeUnit.MILLISECONDS.sleep(200);
+                }
+                if (result.size() != points.size())
+                    continue;
+
+                String content = assemble(result);
+                // 处理的数据保存在本地
+                String wtCode = InitialRunner.wtNewMap.get(wt).getNemCode();
+                String fileName = config.getFilePathPrepare() + vo.getStation() + "_" + wtCode + "_" + System.currentTimeMillis() / 1000 + ".csv";
+                boolean flag = FileUtil.writeFile(fileName, content);
+                prepareMap.put(fileName,content);//保存拿到的数据
+
+                System.out.println("数据准备完成:" + wt);
+
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        //2.数据筛选
+
+//        for (String key : prepareMap.keySet()){
+//
+//
+//            /** 读取csv数据  转换成对象数组 **/
+//            List<PowerPointData> eis = new ArrayList<>();
+//            List<String> list = FileUtil.readFile(obj.getPath(), true);
+//            for (int i = 1; i < list.size(); i++) {
+//                eis.add(new PowerPointData(list.get(i).split(","), false));
+//            }
+//
+//            /** 风速  ->  保证功率  来自数据库 **/
+//            List<Modelpowerdetails> modelPowerList = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
+//            Map<Double, Double> modelPowerMap = modelPowerList.stream().collect(Collectors.toMap(Modelpowerdetails::getSpeed, Modelpowerdetails::getEnsurepower));
+//            /** 数据预处理 **/
+//            List<PowerPointData> data = PowerProcessALG.dataProcess(eis, modelPowerMap, maxs, mins, maxp, minp, isfbw, isfhl, isbw, istj, isglpc, isqfh, qfhdj);
+//            /** 静风频率 **/
+//            List<Double> ls = WindDirectionALG.frequency(data.stream().map(PowerPointData::getSpeed).collect(Collectors.toList()), 3);
+//            double frequency = ls.get(0);
+//            double speed = ls.get(1);
+//
+//            String content = assemble(data);
+//            String fileName = config.getFilePathProcess() + obj.getStation() + "_" + obj.getCode() + "_" + SnowFlakeUtil.generateIdL() / 100000 + ".csv";
+//            boolean flag = FileUtil.writeFile(fileName, content);
+//            if (flag) {  // TODO  保存数据库
+//                obj.setPath(fileName);
+//                obj.setFrequency(frequency);
+//                obj.setSpeedavg(speed);
+//                obj.setType(Constants.DATA_PROCESS);
+//                powerService.insertItem(obj);
+//            }
+//            System.out.println("功率曲线拟合数据预处理完成:" + obj.getWindturbine());
+//        }
+        //3.数据拟合
+
+        return null;
+
+    }
+
+
+    private String assemble(List<List<TsDoubleData>> list){
+        if (list.size() == 0)
+            return null;
+
+        StringBuilder sb = setTitle();
+        List<TsDoubleData> data = list.get(0);
+        for (int i = 0; i < data.size(); i++){
+            sb.append(DateUtil.format(data.get(i).getTs(), DateUtil.DATE_TIME_PATTERN)).append(",");
+            sb.append(data.get(i).getDoubleValue()).append(",");
+            for (int j = 1; j < list.size(); j++){
+                sb.append(list.get(j).get(i).getDoubleValue()).append(",");
+            }
+            sb.deleteCharAt(sb.lastIndexOf(","));
+            sb.append("\n");
+        }
+
+        return sb.toString();
+    }
+
+    private StringBuilder setTitle(){
+        StringBuilder sb = new StringBuilder();
+        val list = AnnotationTool.getFixedVoList(PowerPointData.class);
+        String columnName = list.stream().filter(f -> f.getRemark().equals("1")).map(FixedVo::getDes).collect(Collectors.joining(","));
+        sb.append(columnName).append("\n");
+        return sb;
+    }
+}
+

+ 21 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentPointServiceImpl.java

@@ -1,11 +1,15 @@
 package com.gyee.power.fitting.service.impl;
 
+import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
 import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 import com.gyee.power.fitting.mapper.ProBasicEquipmentPointMapper;
 import com.gyee.power.fitting.service.ProBasicEquipmentPointService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 设备测点 服务实现类
@@ -17,4 +21,21 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProBasicEquipmentPointServiceImpl extends ServiceImpl<ProBasicEquipmentPointMapper, ProBasicEquipmentPoint> implements ProBasicEquipmentPointService {
 
+
+    @Override
+    public List<ProBasicEquipmentPoint> selectList(String station, List<String> points) {
+        List<ProBasicEquipmentPoint> list = new ArrayList();
+
+        ExcludeQueryWrapper wrapper = new ExcludeQueryWrapper();
+        wrapper.eq("windpowerstation_id", station);
+        wrapper.in("uniform_code", points);
+
+        try{
+            list = baseMapper.selectList(wrapper);
+        }catch (Exception e){
+            log.error("ProBasicEquipmentPoint--selectList", e);
+        }
+
+        return list;
+    }
 }