Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

全业务考评 před 1 rokem
rodič
revize
bb1747dfdd
18 změnil soubory, kde provedl 452 přidání a 135 odebrání
  1. 3 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/common/config/MybatisPlusConfig.java
  2. 2 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/alarm/AlarmTsController.java
  3. 181 3
      power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/gf/PhotovoltaicAnalysisController.java
  4. 122 102
      power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/CalculateTask.java
  5. 3 3
      power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/InverterPowerAnalysis2.java
  6. 1 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/PhotovoltaicAnalysisTask.java
  7. 2 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/StateCauseMapper.java
  8. 67 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/Device.java
  9. 20 8
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/StateCause.java
  10. 1 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PhotovoltaicInfo.java
  11. 2 2
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PowerPointData.java
  12. 18 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/vo/PageMap.java
  13. 2 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IStateCauseService.java
  14. 4 2
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentService.java
  15. 1 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/NewIvPvCurveFittingService.java
  16. 20 7
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentServiceImpl.java
  17. 2 2
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/StateCauseServiceImpl.java
  18. 1 1
      power-fitting-JN/src/main/resources/mapper/AlarmTsXmlMapper.xml

+ 3 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/common/config/MybatisPlusConfig.java

@@ -12,6 +12,8 @@ public class MybatisPlusConfig {
      */
     @Bean
     public PaginationInterceptor paginationInterceptor() {
-        return new PaginationInterceptor();
+        PaginationInterceptor interceptor = new PaginationInterceptor();
+        interceptor.setDbType(DbType.POSTGRE_SQL);
+        return interceptor;
     }
 }

+ 2 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/alarm/AlarmTsController.java

@@ -12,10 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 
-@Controller
+@RestController
 @RequestMapping("/alarm")
 @Api(value = "预警", tags = "预警")
 public class AlarmTsController {

+ 181 - 3
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/gf/PhotovoltaicAnalysisController.java

@@ -1,13 +1,19 @@
 package com.gyee.power.fitting.controller.gf;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
+import com.gyee.power.fitting.dispersionanalysis.InverterPowerAnalysis2;
+import com.gyee.power.fitting.model.Device;
 import com.gyee.power.fitting.model.PhotovoltaicAnalysis;
+import com.gyee.power.fitting.model.ProBasicEquipment;
+import com.gyee.power.fitting.model.StateCause;
 import com.gyee.power.fitting.service.IPhotovoltaicAnalysisService;
+import com.gyee.power.fitting.service.IStateCauseService;
 import com.gyee.power.fitting.service.ProBasicEquipmentService;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -15,8 +21,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.Map;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
@@ -35,7 +41,136 @@ public class PhotovoltaicAnalysisController {
     private IPhotovoltaicAnalysisService photovoltaicAnalysisService;
     @Resource
     private ProBasicEquipmentService proBasicEquipmentService;
+    @Resource
+    private IStateCauseService stateCauseService;
+    @Resource
+    private InverterPowerAnalysis2 inverterPowerAnalysis;
+
+    //状态转换
+    @GetMapping("/state_transition")
+    public JSONObject stateTransition(
+            @RequestParam("stationId") String stationId,
+            @RequestParam("startTime") Long startTime,
+            @RequestParam("endTime") Long endTime,
+            @RequestParam("type") String type,
+            @RequestParam("pageNum") int pageNum,
+            @RequestParam("pageSize") int pageSize) {
+
+        List<ProBasicEquipment> equipments = proBasicEquipmentService.getStationMap(type).get(stationId);
+        if (equipments == null) return JsonResult.successData(ResultCode.SUCCESS, new HashMap<>());
+        Map<String, String> stringMap = equipments.stream().collect(Collectors.toMap(ProBasicEquipment::getId, ProBasicEquipment::getNemCode));
+        List<String> collect = equipments.stream().map(ProBasicEquipment::getId).collect(Collectors.toList());
+
+        List<String> pageItems = collect.subList(pageSize * (pageNum - 1), Math.min(collect.size(), pageSize * pageNum));
 
+        QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
+//        Page<StateCause> page = new Page<>(pageNum, pageSize);
+        scWrapper.eq("state_type", "8种状态").in("equipment_id", pageItems)
+                .ge("start_time", startTime).lt("end_time", endTime)
+                .orderByAsc("equipment_id,start_time");
+        List<StateCause> list = stateCauseService.list(scWrapper);
+        Map<String, List<StateCause>> listMap = list.stream().peek(sc -> sc.setEquipmentId(stringMap.get(sc.getEquipmentId()))).collect(Collectors.groupingBy(StateCause::getEquipmentId,LinkedHashMap::new,Collectors.toList()));
+//        PageMap<StateCause> stateCauses = (PageMap<StateCause>) stateCauseService.page(page, scWrapper);
+
+//        stateCauses.setRecordMap(stateCauses.getRecords().stream().collect(Collectors.groupingBy(StateCause::getEquipmentId)));
+//        stateCauses.setRecords(Collections.emptyList());
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("total", collect.size());
+        map.put("size", listMap.size());
+        map.put("current", pageNum);
+        map.put("data", listMap);
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+
+    //状态时间
+    @GetMapping("/state_time")
+    public JSONObject stateTime(
+            @RequestParam("stationId") String stationId,
+            @RequestParam("startTime") Long startTime,
+            @RequestParam("endTime") Long endTime,
+            @RequestParam("type") String type,
+            @RequestParam("pageNum") int pageNum,
+            @RequestParam("pageSize") int pageSize) {
+
+        Map<String, List<ProBasicEquipment>> stationMap = proBasicEquipmentService.getStationMap(type);
+        List<ProBasicEquipment> equipments = stationMap.get(stationId);
+        if (equipments == null) return JsonResult.successData(ResultCode.SUCCESS, new HashMap<>());
+        Map<String, String> stringMap = equipments.stream().collect(Collectors.toMap(ProBasicEquipment::getId, ProBasicEquipment::getNemCode));
+        List<String> collect = equipments.stream().map(ProBasicEquipment::getId).collect(Collectors.toList());
+
+        List<String> pageItems = collect.subList(pageSize * (pageNum - 1), Math.min(collect.size(), pageSize * pageNum));
+
+        QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
+//        Page<StateCause> page = new Page<>(pageNum, pageSize);
+        scWrapper.select("equipment_id,event,sum(time)/3600 hour");
+        scWrapper.eq("state_type", "8种状态").in("equipment_id", pageItems)
+                .ge("start_time", startTime).lt("end_time", endTime);
+        scWrapper.groupBy("equipment_id,event").orderByAsc("equipment_id");
+        List<StateCause> causePage = stateCauseService.list(scWrapper);
+        Map<String, List<StateCause>> listMap = causePage.stream().peek(sc -> sc.setEquipmentId(stringMap.get(sc.getEquipmentId()))).collect(Collectors.groupingBy(StateCause::getEquipmentId,LinkedHashMap::new,Collectors.toList()));
+        List<Device> deviceList = statecauses2Devices(listMap);
+        /*PageMap<StateCause> pageMap = new PageMap<>();
+        pageMap.
+        PageMap<StateCause> stateCauses = (PageMap<StateCause>) causePage;
+
+        Map<String, Map<Short, Double>> collect = stateCauses.getRecords().stream().collect(Collectors.groupingBy(StateCause::getEquipmentId,
+                Collectors.groupingBy(StateCause::getEvent, Collectors.summingDouble(t -> t.getTime() / (60 * 24.0)))));
+
+        stateCauses.setRecordMap(collect);
+        stateCauses.setRecords(Collections.emptyList());*/
+
+//        protected long total;
+//        protected long size;
+//        protected long current;
+        Map<String, Object> map = new HashMap<>();
+        map.put("total", collect.size());
+        map.put("size", deviceList.size());
+        map.put("current", pageNum);
+        map.put("data", deviceList);
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+
+    private List<Device> statecauses2Devices(Map<String, List<StateCause>> listMap) {
+        List<Device> deviceList = new ArrayList<>();
+        listMap.forEach((wt, scs) -> {
+            Device device = new Device();
+            device.setStationId(scs.get(0).getStationId());
+            device.setDeviceId(wt);
+            AtomicReference<Double> sum = new AtomicReference<>((double) 0);
+            scs.forEach(sc -> {
+                sum.updateAndGet(v -> v + sc.getHour());
+                switch (sc.getEvent()) {
+                    case 0:
+                        device.setStandbyTime(sc.getHour());
+                        break;
+                    case 1:
+                        device.setGridConnectionTime(sc.getHour());
+                        break;
+                    case 2:
+                        device.setFaultTime(sc.getHour());
+                        break;
+                    case 3:
+                        device.setMaintenanceTime(sc.getHour());
+                        break;
+                    case 4:
+                        device.setPowerLimitTime(sc.getHour());
+                        break;
+                    case 5:
+                        device.setStressedTime(sc.getHour());
+                        break;
+                    case 6:
+                        device.setOfflineTime(sc.getHour());
+                        break;
+                }
+            });
+            device.setTotal(NumberUtil.round(sum.get(),2).doubleValue());
+            deviceList.add(device);
+        });
+        return deviceList;
+    }
+
+    //性能等级评估
     @GetMapping("/analysis")
     public JSONObject photovoltaicAnalysis(
             @RequestParam("stationId") String stationId,
@@ -68,9 +203,52 @@ public class PhotovoltaicAnalysisController {
         Page<PhotovoltaicAnalysis> page = new Page<>(pageNum, pageSize);
         Page<PhotovoltaicAnalysis> list = photovoltaicAnalysisService.page(page, wrapper);
 
-        Map<String, String> collect = proBasicEquipmentService.getStationMap("IN");
+        Map<String, String> collect = proBasicEquipmentService.getWtNcMap("IN");
 
         list.setRecords(list.getRecords().stream().peek(pa -> pa.setEquipmentId(collect.get(pa.getEquipmentId()))).collect(Collectors.toList()));
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
+
+    //逆变器分析
+    @GetMapping("/analysis/inverter")
+    public JSONObject photovoltaicInverterAnalysis(
+            @RequestParam("stationId") String stationId,
+            @RequestParam("time") String time,
+            @RequestParam("timeType") String timeType,
+            @RequestParam("pageNum") int pageNum,
+            @RequestParam("pageSize") int pageSize) {
+
+        Date date, startDate, endDate;
+
+        if ("year".equals(timeType)) {
+            date = DateUtil.parse(time, "yyyy");
+            startDate = DateUtil.beginOfYear(date);
+            endDate = DateUtil.endOfYear(date);
+        } else if ("month".equals(timeType)) {
+            date = DateUtil.parse(time, "yyyy-MM");
+            startDate = DateUtil.beginOfMonth(date);
+            endDate = DateUtil.endOfMonth(date);
+        } else {
+            date = DateUtil.parse(time);
+            startDate = DateUtil.beginOfDay(date);
+            endDate = DateUtil.endOfDay(date);
+        }
+
+        QueryWrapper<PhotovoltaicAnalysis> wrapper = new QueryWrapper<>();
+        wrapper.select("station_id,equipment_id,avg(average_light_intensity) average_light_intensity,avg(average_power)" +
+                        " average_power,avg(scatter) scatter,avg(equivalent_generating_time_stan) equivalent_generating_time_stan")
+                .between("data_date", startDate, endDate)
+                .eq("station_id", stationId)
+                .groupBy("station_id,equipment_id").orderByAsc("equipment_id");
+        Page<PhotovoltaicAnalysis> page = new Page<>(pageNum, pageSize);
+        Page<PhotovoltaicAnalysis> list = photovoltaicAnalysisService.page(page, wrapper);
+
+        Map<String, String> collect = proBasicEquipmentService.getWtNcMap("IN");
+
+        list.setRecords(list.getRecords().stream().peek(pa -> {
+            pa.setEquipmentId(collect.get(pa.getEquipmentId()));
+            pa.setScatterStatus(inverterPowerAnalysis.analyzeInverterStatus(pa.getScatter(),pa.getAveragePower()));
+        }).collect(Collectors.toList()));
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
 }

+ 122 - 102
power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/CalculateTask.java

@@ -1,6 +1,9 @@
 package com.gyee.power.fitting.dispersionanalysis;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateRange;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
@@ -35,120 +38,137 @@ public class CalculateTask {
     //秒 分 时 日 月 周
     @Scheduled(cron = "0 0 2 * * ?")
     public void doTask() {
-        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList();
+        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList(null);
         Map<String, ProBasicEquipmentPoint> sbztMap = proBasicEquipmentPointService.getEquipmentMapByUniformcode("SBZT");
         Map<String, ProBasicEquipmentPoint> mxztMap = proBasicEquipmentPointService.getEquipmentMapByUniformcode("MXZT");
         //获取最新更新时间
         QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
-        scWrapper.select("last_row(end_time) end_time").groupBy("equipment_id");
-        List<StateCause> scList = stateCauseService.list(scWrapper);
-        Map<String, StateCause> stateCauseMap;
-        if (scList.isEmpty()) {
-            stateCauseMap = new HashMap<>();
-        } else {
-            stateCauseMap = scList.stream().collect(Collectors.toMap(StateCause::getEquipmentId, Function.identity()));
-        }
+        scWrapper.select("equipment_id,last_row(end_time) end_time");
+        StateCause sc = stateCauseService.getOne(scWrapper);
+        DateRange dateRange = getDateRange(sc);
+        if (dateRange == null) return;
 
-        String equipmentId, tbName;
-        long starttime, endtime = DateUtil.date().getTime();
         List<StateCause> stateCauseList = new ArrayList<>();
-
-        for (ProBasicEquipment equipment : equipmentList) {
-            equipmentId = equipment.getId();
-            StateCause stateCause = stateCauseMap.get(equipmentId);
-            if (stateCause == null) {
-                starttime = DateUtil.yesterday().getTime();
-            } else {
-                starttime = stateCause.getEndTime() != null ? stateCause.getEndTime().getTime() - 6000 : DateUtil.yesterday().getTime();
-            }
-            List<TsDoubleData> datas8 = getDatas(sbztMap.get(equipmentId).getNemCode(), starttime, endtime);
-
-            tbName = equipmentId + "_SC_CI08";
-            if (CollUtil.isNotEmpty(datas8)) {
-                TsDoubleData remove = datas8.remove(0);
-                long ts0 = remove != null ? remove.getTs() : starttime;
-                long ts1;
-                int doubleValue0 = remove != null ? (int) remove.getDoubleValue() : 7;
-                int doubleValue1;
-                for (TsDoubleData data : datas8) {
-                    ts1 = data.getTs();
-                    doubleValue1 = (int) data.getDoubleValue();
-                    if (doubleValue1 == doubleValue0) continue;
-
-                    //0待机, 1运行, 2故障, 3检修, 4限电, 5受累, 6离线
-                    if (doubleValue1 == 1) {
-                        stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 2) {
-                        stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 3) {
-                        stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 4) {
-                        stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 5) {
-                        stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 6) {
-                        stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
-                    } else {
-                        stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+        long starttime, endtime;
+        for (DateTime time : dateRange) {
+            starttime = time.getTime();
+            endtime = DateUtil.endOfDay(time).getTime();
+
+            String equipmentId, tbName;
+            for (ProBasicEquipment equipment : equipmentList) {
+                equipmentId = equipment.getId();
+
+                tbName = equipmentId + "_SC_CI08";
+                List<TsDoubleData> datas8 = getDatas(sbztMap.get(equipmentId).getNemCode(), starttime, endtime);
+
+                if (CollUtil.isNotEmpty(datas8)) {
+
+                    long ts0 = endtime;
+                    long ts1;
+                    int doubleValue0 = (int) datas8.get(0).getDoubleValue();
+                    int doubleValue1 = 0;
+                    for (TsDoubleData data : datas8) {
+                        ts1 = data.getTs();
+                        doubleValue1 = (int) data.getDoubleValue();
+                        if (doubleValue1 == doubleValue0) continue;
+
+                        //0待机, 1运行, 2故障, 3检修, 4限电, 5受累, 6离线
+                        if (doubleValue0 == 1) {
+                            stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 2) {
+                            stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 3) {
+                            stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 4) {
+                            stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 5) {
+                            stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 6) {
+                            stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
+                        } else {
+                            stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+                        }
+                        ts0 = ts1;
+                        doubleValue0 = doubleValue1;
                     }
-                    if (ts1 <= starttime) break;
-                    ts0 = ts1;
-                    doubleValue0 = doubleValue1;
-
+                    if (ts0 > starttime) {
+                        stateCauseList.add(new StateCause(tbName, doubleValue1, starttime, ts0, ts0 - starttime));
+                    }
+                }else {
+                    System.out.println(equipmentId+":8种状态:"+sbztMap.get(equipmentId).getNemCode());
                 }
-            }
-
-            List<TsDoubleData> datas14 = getDatas(mxztMap.get(equipmentId).getNemCode(), starttime, endtime);
 
-            tbName = equipmentId + "_SC_CI14";
-            if (CollUtil.isNotEmpty(datas14)) {
-                TsDoubleData remove = datas14.remove(0);
-                long ts0 = remove != null ? remove.getTs() : starttime;
-                long ts1;
-                int doubleValue0 = remove != null ? (int) remove.getDoubleValue() : 7;
-                int doubleValue1;
-                for (TsDoubleData data : datas14) {
-                    ts1 = data.getTs();
-                    doubleValue1 = (int) data.getDoubleValue();
-                    if (doubleValue1 == doubleValue0) continue;
-
-                    //0待机, 1手动停机, 2正常发电, 3发电降出力, 4故障, 5故障受累, 6检修, 7检修受累, 8限电降出力, 9限电停机, 10电网受累, 11环境受累, 12通讯中断, 13设备离线
-                    if (doubleValue1 == 1) {
-                        stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 2) {
-                        stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 3) {
-                        stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 4) {
-                        stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 5) {
-                        stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 6) {
-                        stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 7) {
-                        stateCauseList.add(new StateCause(tbName, 7, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 8) {
-                        stateCauseList.add(new StateCause(tbName, 8, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 9) {
-                        stateCauseList.add(new StateCause(tbName, 9, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 10) {
-                        stateCauseList.add(new StateCause(tbName, 10, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 11) {
-                        stateCauseList.add(new StateCause(tbName, 11, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 12) {
-                        stateCauseList.add(new StateCause(tbName, 12, ts1, ts0, ts0 - ts1));
-                    } else if (doubleValue1 == 13) {
-                        stateCauseList.add(new StateCause(tbName, 13, ts1, ts0, ts0 - ts1));
-                    } else {
-                        stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+                tbName = equipmentId + "_SC_CI14";
+                List<TsDoubleData> datas14 = getDatas(mxztMap.get(equipmentId).getNemCode(), starttime, endtime);
+
+                if (CollUtil.isNotEmpty(datas14)) {
+
+                    long ts0 = endtime;
+                    long ts1;
+                    int doubleValue0 = (int) datas14.get(0).getDoubleValue();
+                    int doubleValue1 = 0;
+                    for (TsDoubleData data : datas14) {
+                        ts1 = data.getTs();
+                        doubleValue1 = (int) data.getDoubleValue();
+                        if (doubleValue1 == doubleValue0) continue;
+
+                        //0待机, 1手动停机, 2正常发电, 3发电降出力, 4故障, 5故障受累, 6检修, 7检修受累, 8限电降出力, 9限电停机, 10电网受累, 11环境受累, 12通讯中断, 13设备离线
+                        if (doubleValue0 == 1) {
+                            stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 2) {
+                            stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 3) {
+                            stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 4) {
+                            stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 5) {
+                            stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 6) {
+                            stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 7) {
+                            stateCauseList.add(new StateCause(tbName, 7, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 8) {
+                            stateCauseList.add(new StateCause(tbName, 8, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 9) {
+                            stateCauseList.add(new StateCause(tbName, 9, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 10) {
+                            stateCauseList.add(new StateCause(tbName, 10, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 11) {
+                            stateCauseList.add(new StateCause(tbName, 11, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 12) {
+                            stateCauseList.add(new StateCause(tbName, 12, ts1, ts0, ts0 - ts1));
+                        } else if (doubleValue0 == 13) {
+                            stateCauseList.add(new StateCause(tbName, 13, ts1, ts0, ts0 - ts1));
+                        } else {
+                            stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+                        }
+                        ts0 = ts1;
+                        doubleValue0 = doubleValue1;
                     }
-                    if (ts1 <= starttime) break;
-                    ts0 = ts1;
-                    doubleValue0 = doubleValue1;
+                    if (ts0 > starttime) {
+                        stateCauseList.add(new StateCause(tbName, doubleValue1, starttime, ts0, ts0 - starttime));
+                    }
+                }else {
+                    System.out.println(equipmentId+":14种状态:"+sbztMap.get(equipmentId).getNemCode());
                 }
+
             }
         }
-        stateCauseService.saveBatch(stateCauseList);
+
+        int i = stateCauseService.saveBatch(stateCauseList);
+        System.out.println("计算完成" + i);
+    }
+
+    private DateRange getDateRange(StateCause sc) {
+        DateTime startTime;
+        DateTime endTime = DateUtil.beginOfDay(DateUtil.yesterday());
+        if (sc == null) {
+            startTime = endTime;
+        } else {
+            startTime = DateUtil.offsetDay(DateUtil.beginOfDay(DateUtil.date(sc.getEndTime())), 1);
+            if (startTime.isAfter(endTime)) return null;
+        }
+        return DateUtil.range(startTime, endTime, DateField.DAY_OF_YEAR);
     }
 
     private List<TsDoubleData> getDatas(String nemCode, long starttime, long endtime) {
@@ -165,7 +185,7 @@ public class CalculateTask {
     //秒 分 时 日 月 周
 //    @Scheduled(cron = "0 11 10 * * ?")
     public void creatStables() {
-        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList();
+        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList(null);
 
         String equipmentId, tbName;
         List<StateCause> stateCauseList = new ArrayList<>();

+ 3 - 3
power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/InverterPowerAnalysis2.java

@@ -41,11 +41,11 @@ public class InverterPowerAnalysis2 {
 
     // 根据复杂规则分析逆变器状态
     public String analyzeInverterStatus(double powerDeviation, double averagePower) {
-        if (powerDeviation < 0.1 && averagePower > 800) {
+        if (powerDeviation < 5 && averagePower > 200) {
             return "运行稳定";
-        } else if (powerDeviation < 0.2 && averagePower > 600) {
+        } else if (powerDeviation < 8 && averagePower > 35) {
             return "运行良好";
-        } else if (powerDeviation < 0.3 && averagePower > 400) {
+        } else if (powerDeviation < 20 && averagePower > 20) {
             return "运行水平有待提高";
         } else {
             return "必须整改";

+ 1 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/PhotovoltaicAnalysisTask.java

@@ -222,7 +222,7 @@ public class PhotovoltaicAnalysisTask {
         DateTime startTime;
         DateTime endTime = DateUtil.beginOfDay(DateUtil.yesterday());
         if (paList == null || paList.getDataDate() == null) {
-            startTime = DateUtil.beginOfMonth(DateUtil.date());
+            startTime = endTime;
         } else {
             startTime = DateUtil.offsetDay(paList.getDataDate(), 1);
             if (startTime.isAfter(endTime)) return null;

+ 2 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/StateCauseMapper.java

@@ -1,5 +1,6 @@
 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.StateCause;
 import org.apache.ibatis.annotations.Insert;
@@ -14,6 +15,7 @@ import org.apache.ibatis.annotations.Update;
  * @author gfhd
  * @since 2023-05-04
  */
+@DS("jsfw")
 @Mapper
 public interface StateCauseMapper extends BaseMapper<StateCause> {
     @Insert("insert into ${entity}")

+ 67 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/Device.java

@@ -0,0 +1,67 @@
+package com.gyee.power.fitting.model;
+
+import lombok.Data;
+
+@Data
+public class Device {
+    private String stationId;
+    private String deviceId;
+    //0待机, 1并网, 2故障, 3检修, 4限电, 5受累, 6离线
+    private Double standbyTime;//0待机
+    private Double gridConnectionTime;//1并网
+    private Double faultTime;//2故障
+    private Double maintenanceTime;//3检修
+    private Double powerLimitTime;//4限电
+    private Double stressedTime;//5受累
+    private Double offlineTime;//6离线
+    private Double total;
+
+    public Double getStandbyTime() {
+        if (standbyTime==null) {
+            standbyTime = 0.0;
+        }
+        return standbyTime;
+    }
+
+    public Double getGridConnectionTime() {
+        if (gridConnectionTime==null) {
+            gridConnectionTime = 0.0;
+        }
+        return gridConnectionTime;
+    }
+
+    public Double getFaultTime() {
+        if (faultTime==null) {
+            faultTime = 0.0;
+        }
+        return faultTime;
+    }
+
+    public Double getMaintenanceTime() {
+        if (maintenanceTime==null) {
+            maintenanceTime = 0.0;
+        }
+        return maintenanceTime;
+    }
+
+    public Double getPowerLimitTime() {
+        if (powerLimitTime==null) {
+            powerLimitTime = 0.0;
+        }
+        return powerLimitTime;
+    }
+
+    public Double getStressedTime() {
+        if (stressedTime==null) {
+            stressedTime = 0.0;
+        }
+        return stressedTime;
+    }
+
+    public Double getOfflineTime() {
+        if (offlineTime==null) {
+            offlineTime = 0.0;
+        }
+        return offlineTime;
+    }
+}

+ 20 - 8
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/StateCause.java

@@ -1,5 +1,6 @@
 package com.gyee.power.fitting.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import java.io.Serializable;
@@ -24,12 +25,12 @@ public class StateCause implements Serializable {
     /**
      * 开始时间
      */
-    private Timestamp startTime;
+    private Long startTime;
 
     /**
      * 结束时间
      */
-    private Timestamp endTime;
+    private Long endTime;
 
     /**
      * 事件-运行、限电、故障、受累、计划检修、待机
@@ -65,17 +66,28 @@ public class StateCause implements Serializable {
 
     private String stateType;
 
+    @TableField(exist = false)
+    private Double hour;
+
     public StateCause() {
     }
 
     public StateCause(String tbname, int event, long startTime, long endTime, long time) {
         this.tbname = tbname;
         this.event = (short) event;
-        this.startTime = new Timestamp(startTime);
-        this.endTime = new Timestamp(endTime);
+        this.startTime = startTime;
+        this.endTime = endTime;
         this.time = time / 1000;
     }
 
+    public Double getHour() {
+        return hour;
+    }
+
+    public void setHour(Double hour) {
+        this.hour = hour;
+    }
+
     public String getTbname() {
         return tbname;
     }
@@ -108,19 +120,19 @@ public class StateCause implements Serializable {
         this.event = event;
     }
 
-    public Date getStartTime() {
+    public Long getStartTime() {
         return startTime;
     }
 
-    public void setStartTime(Timestamp startTime) {
+    public void setStartTime(Long startTime) {
         this.startTime = startTime;
     }
 
-    public Timestamp getEndTime() {
+    public Long getEndTime() {
         return endTime;
     }
 
-    public void setEndTime(Timestamp endTime) {
+    public void setEndTime(Long endTime) {
         this.endTime = endTime;
     }
 

+ 1 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PhotovoltaicInfo.java

@@ -18,7 +18,7 @@ public class PhotovoltaicInfo {
     @Desc(des = "组件温度" ,uniformCode = "QXZZJWD")
     @JsonProperty("T")
     private double T;
-    @Desc(des = "光照强度",uniformCode = "RPJGZD")
+    @Desc(des = "光照强度",uniformCode = "GCGZQD")
     @JsonProperty("S")
     private double S;
 

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

@@ -68,7 +68,7 @@ public class PowerPointData {
     private double dl = 0;
 
     //欠发状态 SSQFZT
-    @Desc(des = "欠发状态",  uniformCode = "RQFZT", remark = "1")
+    @Desc(des = "欠发状态",  uniformCode = "RQFDL", remark = "1")
     private int qfzt = 0;
 
 
@@ -81,7 +81,7 @@ public class PowerPointData {
     private double dfwc = 0;
 
     //偏航角度 AI073
-    @Desc(des = "偏航角度",  uniformCode = "AI073", remark = "1")
+    @Desc(des = "偏航角度",  uniformCode = "AI028", remark = "1")
     private double angle = 0;
 
     /**

+ 18 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/vo/PageMap.java

@@ -0,0 +1,18 @@
+package com.gyee.power.fitting.model.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class PageMap<T> extends Page<T> {
+    protected Map recordMap = new HashMap<>();
+
+    public Map getRecordMap() {
+        return recordMap;
+    }
+
+    public void setRecordMap(Map recordMap) {
+        this.recordMap = recordMap;
+    }
+}

+ 2 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IStateCauseService.java

@@ -1,5 +1,6 @@
 package com.gyee.power.fitting.service;
 
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.power.fitting.model.StateCause;
 
@@ -13,6 +14,7 @@ import java.util.List;
  * @author gfhd
  * @since 2023-05-04
  */
+@DS("jsfw")
 public interface IStateCauseService extends IService<StateCause> {
     int saveBatch(List<StateCause> entityList);
 

+ 4 - 2
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentService.java

@@ -21,7 +21,9 @@ public interface ProBasicEquipmentService extends IService<ProBasicEquipment> {
 
     List<ProBasicEquipment> selectList(String station);
 
-    Map<String, String> getStationMap(String type);
+    Map<String, String> getWtNcMap(String type);
 
-    List<ProBasicEquipment> getCacheList();
+    Map<String, List<ProBasicEquipment>> getStationMap(String type);
+
+    List<ProBasicEquipment> getCacheList(String type);
 }

+ 1 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/NewIvPvCurveFittingService.java

@@ -655,7 +655,7 @@ public class NewIvPvCurveFittingService {
         //总辐射
         //        List<TsDoubleData> zfsDatas = adpClient.getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
 
-        List<TsDoubleData> zfsDatas = remoteService.adapterfd().getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
+        List<TsDoubleData> zfsDatas = remoteService.adaptergf().getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
 
         //组件温度
         //        List<TsDoubleData> zjwdDatas = adpClient.getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);

+ 20 - 7
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.gyee.power.fitting.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
@@ -49,19 +50,31 @@ public class ProBasicEquipmentServiceImpl extends ServiceImpl<ProBasicEquipmentM
         return list;
     }
 
-    @Cacheable("getStationMap")
-    public Map<String, String> getStationMap(String type) {
-        QueryWrapper<ProBasicEquipment> eWrapper = new QueryWrapper<>();
-        eWrapper.eq("spare1", type);
-        List<ProBasicEquipment> eList = baseMapper.selectList(eWrapper);
+    @Cacheable("getWtNcMap")
+    public Map<String, String> getWtNcMap(String type) {
+        QueryWrapper<ProBasicEquipment> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(type), "spare1", type);
+        wrapper.orderByAsc("order_num");
+        List<ProBasicEquipment> eList = baseMapper.selectList(wrapper);
         Map<String, String> collect = eList.stream().collect(Collectors.toMap(ProBasicEquipment::getId, ProBasicEquipment::getNemCode));
         return collect;
     }
 
+    @Cacheable("getStationMap")
+    public Map<String, List<ProBasicEquipment>> getStationMap(String type) {
+        QueryWrapper<ProBasicEquipment> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(type), "spare1", type);
+        wrapper.orderByAsc("order_num");
+        List<ProBasicEquipment> eList = baseMapper.selectList(wrapper);
+        Map<String, List<ProBasicEquipment>> collect = eList.stream().collect(Collectors.groupingBy(ProBasicEquipment::getWindpowerstationId));
+        return collect;
+    }
+
     @Cacheable("getCacheList")
-    public List<ProBasicEquipment> getCacheList() {
+    public List<ProBasicEquipment> getCacheList(String type) {
         QueryWrapper<ProBasicEquipment> wrapper = new QueryWrapper<>();
-        wrapper.orderByAsc("id");
+        wrapper.eq(StrUtil.isNotBlank(type), "spare1", type);
+        wrapper.orderByAsc("order_num");
         return baseMapper.selectList(wrapper);
     }
 }

+ 2 - 2
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/StateCauseServiceImpl.java

@@ -29,8 +29,8 @@ public class StateCauseServiceImpl extends ServiceImpl<StateCauseMapper, StateCa
         for (List<StateCause> targets : split) {
             StringBuilder sb = new StringBuilder();
             for (StateCause target : targets) {
-                sb.append(target.getTbname()).append(" values(").append(target.getStartTime().getTime())
-                        .append(",").append(target.getEndTime().getTime()).append(",'").append(target.getEvent())
+                sb.append(target.getTbname()).append(" values(").append(target.getStartTime())
+                        .append(",").append(target.getEndTime()).append(",'").append(target.getEvent())
                         .append("','").append(target.getAdvanceState()).append("','").append(target.getAfterState())
                         .append("','").append(target.getUserFlag()).append("',").append(target.getTime())
                         .append(") ");

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

@@ -10,7 +10,7 @@
 
             <if test="date !=null">
                 AND ts in
-                <foreach item="item" collection="date" separator="," open="(" close=")" index="">'${item}'</foreach>
+                <foreach item="item" collection="date" separator="," open="(" close=")" index="">${item}</foreach>
             </if>
 
             <if test="deviceid !=null">