Quellcode durchsuchen

功率曲线修改

wangchangsheng vor 2 Jahren
Ursprung
Commit
15b23b0cb1

+ 7 - 1
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/performance/PerformanceCurvefittingController.java

@@ -29,11 +29,17 @@ public class PerformanceCurvefittingController {
     @Autowired
     private PerformanceCurvefittingService performanceCurvefittingService;
 
+    /**
+     *
+     * @param windturbineIds 风机ids
+     * @param type 0:全部;-1:风电;-2:光伏(暂时默认 -1;没有光伏的功率曲线)
+     * @param dateType 1:日;2:月;3:年
+     * @return
+     */
     @GetMapping("/curvefitting")
     @ResponseBody
     @CrossOrigin(origins = "*", maxAge = 3600)
     public R curvefitting(@RequestParam(value = "windturbineIds", required = true) String windturbineIds,
-                          //单风机0,多风机1
                           @RequestParam(value = "type", required = true) String type,
                           @RequestParam(value = "dateType", required = true) String dateType
     ) {

+ 11 - 29
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/PerformanceCurvefittingService.java

@@ -40,46 +40,28 @@ public class PerformanceCurvefittingService {
     public Map<String, List<CurveVo>> curvefitting(String windturbineIds, String type,String dateType) {
         Map<String, List<CurveVo>> resultMap = new HashMap<>();
         Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
+        if (type.equals("-1")) {
+            String zbzgl = redisService.get("ZLLGL");
+            Map<String, Map<Double, ZllglDTO>> zbzglMap = JSONObject.parseObject(zbzgl, new TypeReference<Map<String, Map<Double, ZllglDTO>>>() {
+            });
+            Map<String, Map<Double, Double>> znhglMap = getWtCurveFitting(windturbineIds, dateType);
 
-        String zbzgl = redisService.get("ZLLGL");
-        Map<String, Map<Double, ZllglDTO>>  zbzglMap = JSONObject.parseObject(zbzgl, new TypeReference<Map<String, Map<Double, ZllglDTO>>>() {
-        });
-        Map<String,Map<Double,Double>> znhglMap = getWtCurveFitting(windturbineIds,dateType);
-        if (type.equals("0")){
             List<CurveVo> tempList = new ArrayList<>();
-            if (znhglMap.containsKey(windturbineIds)){
+            if (znhglMap.containsKey(windturbineIds)) {
                 Map<Double, Double> zsglmap = znhglMap.get(windturbineIds);
                 Map<Double, ZllglDTO> bzglmap = zbzglMap.get(wtmap.get(windturbineIds).getModelId());
                 Set<Double> speeds = zsglmap.keySet();
-                speeds.stream().forEach(speed->{
+                speeds.stream().forEach(speed -> {
                     CurveVo vo = new CurveVo();
                     vo.setWtid(windturbineIds);
                     vo.setSpeed(speed);
-                    vo.setTheorypower(DoubleUtils.keepPrecision(zsglmap.get(speed),2));
-                    vo.setEnsurepower(DoubleUtils.keepPrecision(bzglmap.containsKey(speed)?bzglmap.get(speed).getEnsurePower():zsglmap.get(speed),2));
+                    vo.setTheorypower(DoubleUtils.keepPrecision(zsglmap.get(speed), 2));
+                    vo.setEnsurepower(DoubleUtils.keepPrecision(bzglmap.containsKey(speed) ? bzglmap.get(speed).getEnsurePower() : zsglmap.get(speed), 2));
                     tempList.add(vo);
                 });
-                SortUtils.sort(tempList,"speed",SortUtils.ASC);
-                resultMap.put(windturbineIds,tempList);
+                SortUtils.sort(tempList, "speed", SortUtils.ASC);
+                resultMap.put(windturbineIds, tempList);
             }
-        }else {
-            String[] wts = windturbineIds.split(",");
-            Arrays.stream(wts).forEach(wt->{
-                List<CurveVo> tempList = new ArrayList<>();
-                if(znhglMap.get(wt) == null || znhglMap.size() == 0)
-                    return;
-                Map<Double, Double> zsglmap = znhglMap.get(wt);
-                Set<Double> speeds = zsglmap.keySet();
-                speeds.stream().forEach(speed->{
-                    CurveVo vo = new CurveVo();
-                    vo.setWtid(wt);
-                    vo.setSpeed(speed);
-                    vo.setTheorypower(DoubleUtils.keepPrecision(zsglmap.get(speed),2));
-                    tempList.add(vo);
-                });
-                SortUtils.sort(tempList,"speed",SortUtils.ASC);
-                resultMap.put(wt,tempList);
-            });
         }
 
         return resultMap;