소스 검색

场站信息新增逆变器

hxf 1 년 전
부모
커밋
37f6306aa2

+ 27 - 4
neim-biz/src/main/java/com/jiayue/biz/controller/InverterInfoController.java

@@ -1,8 +1,10 @@
 package com.jiayue.biz.controller;
 
+import com.jiayue.biz.domain.InverterInfo;
 import com.jiayue.biz.domain.PvModuleModel;
 import com.jiayue.biz.domain.StationInfo;
 import com.jiayue.biz.domain.WeatherStationInfo;
+import com.jiayue.biz.service.InverterInfoService;
 import com.jiayue.biz.service.PvModuleModelService;
 import com.jiayue.biz.service.StationInfoService;
 import com.jiayue.biz.service.WeatherStationInfoService;
@@ -15,10 +17,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -33,6 +32,8 @@ import java.util.stream.Collectors;
 public class InverterInfoController extends BaseController {
     private final PvModuleModelService pvModuleModelService;
     private final StationInfoService stationInfoService;
+
+    private final InverterInfoService inverterInfoService;
     @GetMapping("/getPvModuleModel")
     public AjaxResult getPvModuleModel() {
         List<PvModuleModel> pvModuleModels = pvModuleModelService.list();
@@ -63,4 +64,26 @@ public class InverterInfoController extends BaseController {
         }
         return AjaxResult.success(list);
     }
+
+    //新增逆变器
+    @PostMapping("/addInverterInfo")
+    public void addInverterInfo(InverterInfo inverterInfo, String stationId){
+        inverterInfoService.addInverterInfo(inverterInfo,stationId);
+
+    }
+
+    //修改逆变器
+    @PutMapping("/updateInverterInfo")
+    public void updateInverterInfo(InverterInfo inverterInfo,String stationId){
+        inverterInfoService.updateInverterInfo(inverterInfo,stationId);
+
+    }
+    //删除逆变器
+    @DeleteMapping("/deleteInverterInfo")
+    public void deleteInverterInfo(InverterInfo inverterInfo,String stationId){
+        inverterInfoService.deleteInverterInfo(inverterInfo,stationId);
+    }
+
+
+
 }

+ 2 - 0
neim-biz/src/main/java/com/jiayue/biz/domain/StationInfo.java

@@ -20,6 +20,8 @@ public class StationInfo {
     private StationBasicInfo stationBasicInfo;
     //风机信息
     private List<FanTower> fanTowerList;
+    //逆变器
+    private List<InverterInfo> inverterInfos;
     //塔信息
     private List<Equipment> equipment;
     //环境检测仪

+ 20 - 0
neim-biz/src/main/java/com/jiayue/biz/service/InverterInfoService.java

@@ -0,0 +1,20 @@
+package com.jiayue.biz.service;
+
+import com.jiayue.biz.domain.InverterInfo;
+import com.jiayue.biz.domain.StationInfo;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+public interface InverterInfoService {
+    //新增逆变器
+    void addInverterInfo(InverterInfo inverterInfo, String stationId);
+
+    //修改逆变器
+    void updateInverterInfo(InverterInfo inverterInfo,String stationId);
+    //删除逆变器
+    void deleteInverterInfo(InverterInfo inverterInfo,String stationId);
+
+
+}

+ 0 - 57
neim-biz/src/main/java/com/jiayue/biz/service/impl/HomePageServiceImpl.java

@@ -122,63 +122,6 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
 
 
         }
-
-//        //风速数据
-//        List<ProphaseAnemometryData> prophaseAnemometryDataList = new ArrayList<>();
-//        //空气密度
-//        List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
-//        if (!month.equals("")) {
-//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
-//            try {
-//                Date startDate = sdf.parse(month);
-//                Date endDate = DateTimeUtil.endOfMonth(startDate);
-//                prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
-//                weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
-//            } catch (ParseException e) {
-//                e.printStackTrace();
-//            }
-//        } else {
-//            // 最新一天数据
-//            List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
-//            Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
-//            DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
-//            prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
-//            weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
-//
-//        }
-//        //时间和空气密度map
-//        Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
-//
-//
-//        for (String height : heights) {
-//            //根据层高获取时间和风速map
-//            Map<Timestamp, Float> timeAndWsMap = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toMap(ProphaseAnemometryData::getTs, ProphaseAnemometryData::getWsAve));
-//
-//            if (!timeAndWsMap.isEmpty() && !timeAndAirMap.isEmpty()) {
-//                ArrayList<BigDecimal> wsSumList = new ArrayList<>();
-//                ArrayList<BigDecimal> wpdSumList = new ArrayList<>();
-//                //遍历空气密度
-//                for (Map.Entry<Timestamp, Float> airAndTime : timeAndAirMap.entrySet()) {
-//                    //过滤风速map
-//                    Map<Timestamp, Float> map = timeAndWsMap.entrySet().stream().filter(t -> t.getKey().getTime() == airAndTime.getKey().getTime()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-//                    if (!map.isEmpty()) {
-//                        BigDecimal wpdCalculate = CalculationUtil.getWpdCalculate(BigDecimal.valueOf(airAndTime.getValue()), BigDecimal.valueOf(map.get(airAndTime.getKey())));
-//                        wpdSumList.add(wpdCalculate);
-//                        wsSumList.add(BigDecimal.valueOf(map.get(airAndTime.getKey())));
-//                    }
-//                }
-//                if (wsSumList.size() > 0) {
-//                    BigDecimal wpdAve = BigDecimal.valueOf(wsSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
-//                    wsList.add(wpdAve);
-//                }
-//                if (wpdSumList.size() > 0) {
-//                    BigDecimal wpdAve = BigDecimal.valueOf(wpdSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
-//                    wpdList.add(wpdAve);
-//                }
-//                heightList.add(height + "m");
-//
-//            }
-//        }
         dataMap.put("ws", wsList);
         dataMap.put("wpd", wpdList);
         dataMap.put("height", heightList);

+ 53 - 0
neim-biz/src/main/java/com/jiayue/biz/service/impl/InverterInfoServiceImpl.java

@@ -0,0 +1,53 @@
+package com.jiayue.biz.service.impl;
+
+import com.jiayue.biz.domain.InverterInfo;
+import com.jiayue.biz.domain.StationInfo;
+import com.jiayue.biz.service.InverterInfoService;
+import com.jiayue.biz.service.StationInfoService;
+import lombok.AllArgsConstructor;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+@Service
+@AllArgsConstructor
+public class InverterInfoServiceImpl implements InverterInfoService {
+
+
+    private StationInfoService stationInfoService;
+
+    //新增逆变器
+    public void addInverterInfo(InverterInfo inverterInfo,String stationId){
+        inverterInfo.setId(UUID.randomUUID().toString());
+        StationInfo oneStationInfo = stationInfoService.getOneStationInfo(stationId);
+        oneStationInfo.getInverterInfos().add(inverterInfo);
+        stationInfoService.saveStation(oneStationInfo);
+
+    }
+
+    //修改逆变器
+    public void updateInverterInfo(InverterInfo inverterInfo,String stationId){
+        StationInfo oneStationInfo = stationInfoService.getOneStationInfo(stationId);
+        List<InverterInfo> inverterInfos = oneStationInfo.getInverterInfos().stream().map(s -> {
+            if (s.getId().equals(inverterInfo.getId())) {
+                s = inverterInfo;
+            }
+            return s;
+        }).collect(Collectors.toList());
+        oneStationInfo.setInverterInfos(inverterInfos);
+        stationInfoService.saveStation(oneStationInfo);
+
+    }
+    //删除逆变器
+    public void deleteInverterInfo(InverterInfo inverterInfo,String stationId){
+        StationInfo oneStationInfo = stationInfoService.getOneStationInfo(stationId);
+        List<InverterInfo> collect = oneStationInfo.getInverterInfos().stream().filter(s -> s.getId().equals(inverterInfo.getId())).collect(Collectors.toList());
+        oneStationInfo.getInverterInfos().remove(collect.get(0));
+        stationInfoService.saveStation(oneStationInfo);
+    }
+
+
+}

+ 1 - 1
neim-biz/src/main/java/com/jiayue/biz/service/impl/RealTimeDisplayServiceImpl.java

@@ -511,7 +511,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
             for (ProphaseWeatherData prophaseWeatherDatum : prophaseWeatherData) {
                 List<ProphaseAnemometryData> anemometryData = prophaseAnemometryData.stream().filter(p -> p.getTs().getTime() == prophaseWeatherDatum.getTs().getTime()).collect(Collectors.toList());
                 if (anemometryData.size() > 0) {
-                    tenMinuteWpdSum = tenMinuteWpdSum.add(BigDecimal.valueOf(0.5).multiply(CalculationUtil.power(BigDecimal.valueOf(anemometryData.get(0).getWsAve()), 3)).multiply(BigDecimal.valueOf(prophaseWeatherDatum.getAirDensity())));
+                    tenMinuteWpdSum = tenMinuteWpdSum.add(CalculationUtil.getWpdCalculate(CalculationUtil.getBigDecimal(prophaseWeatherDatum.getAirDensity()),CalculationUtil.getBigDecimal(anemometryData.get(0).getWsAve())));
                     tenMinuteWsSum = tenMinuteWsSum.add(BigDecimal.valueOf(anemometryData.get(0).getWsAve()));
                 }
             }