Ver código fonte

功率曲线查询优化

wangb 5 dias atrás
pai
commit
efcee0daa1

+ 32 - 20
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/PerformanceCurvefittingService.java

@@ -119,22 +119,23 @@ public class PerformanceCurvefittingService {
         String strdate = DateUtils.toDate1(new Date());
         Date date = DateUtils.parseDate(strdate);
         Calendar calendar = Calendar.getInstance();
-
         int year = calendar.get(Calendar.YEAR);
         int month = calendar.get(Calendar.MONTH) + 1;
 
         Arrays.stream(wts).forEach(wt -> {
             Map<Double, Double> doubleMap = new HashMap<>();
             switch (dateType) {
-
                 case "1":
-//                    String dayCurve = redisService.get("dayCurve_" + wt);
-//                    List<ProEconWtCurveFitting> daylist = JSONObject.parseObject(dayCurve, new TypeReference<List<ProEconWtCurveFitting>>() {
-//                    });
-                    DateTime dateTime = DateUtil.parse(recorddate);
-                    List<ProEconWtCurveFitting> daylist = proEconWtCurveFittingService.getProEconWtCurveFittingList(wt, dateTime);
+                    List<ProEconWtCurveFitting> daylist = new ArrayList<>();
+                    if (strdate.equals(recorddate)) {
+                        String dayCurve = redisService.get("dayCurve_" + wt);
+                        daylist = JSONObject.parseObject(dayCurve, new TypeReference<List<ProEconWtCurveFitting>>() {
+                        });
+                    } else {
+                        DateTime dateTime = DateUtil.parse(recorddate);
+                        daylist = proEconWtCurveFittingService.getProEconWtCurveFittingList(wt, dateTime);
 //                    List<ProEconWtCurveFitting> daylist = proEconWtCurveFittingService.getProEconWtCurveFittingList(wt,date);
-
+                    }
                     if (null != daylist) {
                         daylist.stream().forEach(w -> {
                             doubleMap.put(w.getSpeed(), w.getActualPower());
@@ -142,16 +143,21 @@ public class PerformanceCurvefittingService {
                     }
                     zzsglMap.put(wt, doubleMap);
                     break;
-                case "2":
 
-//                    String monthCurve = redisService.get("monthCurve_" + wt);
-//                    List<ProEconWtCurveFittingMonth> monthlist = JSONObject.parseObject(monthCurve, new TypeReference<List<ProEconWtCurveFittingMonth>>() {
-//                    });
+                case "2":
+                    List<ProEconWtCurveFittingMonth> monthlist = new ArrayList<>();
+                    DateTime parse = DateUtil.parse(strdate, "yyyy-MM");
                     DateTime dateMonth = DateUtil.parse(recorddate, "yyyy-MM");
-                    int year1 = DateUtil.year(dateMonth);
-                    int month1 = DateUtil.month(dateMonth);
-                    List<ProEconWtCurveFittingMonth> monthlist = proEconWtCurveFittingMonthService.getProEconWtCurveFittingMonthList(wt, String.valueOf(month1 + 1), String.valueOf(year1));
+                    if (parse.equals(dateMonth)) {
+                        String monthCurve = redisService.get("monthCurve_" + wt);
+                        monthlist = JSONObject.parseObject(monthCurve, new TypeReference<List<ProEconWtCurveFittingMonth>>() {
+                        });
+                    } else {
+                        int year1 = DateUtil.year(dateMonth);
+                        int month1 = DateUtil.month(dateMonth);
+                        monthlist = proEconWtCurveFittingMonthService.getProEconWtCurveFittingMonthList(wt, String.valueOf(month1 + 1), String.valueOf(year1));
 //                                        List<ProEconWtCurveFittingMonth> monthlist = proEconWtCurveFittingMonthService.getProEconWtCurveFittingMonthList(wt,String.valueOf(month),String.valueOf(year));
+                    }
 
                     if (null != monthlist) {
                         monthlist.stream().forEach(w -> {
@@ -160,14 +166,20 @@ public class PerformanceCurvefittingService {
                     }
                     zzsglMap.put(wt, doubleMap);
                     break;
+
                 case "3":
-//                    String yearCurve = redisService.get("yearCurve_" + wt);
-//                    List<ProEconWtCurveFittingYear> yearslist = JSONObject.parseObject(yearCurve, new TypeReference<List<ProEconWtCurveFittingYear>>() {
-//                    });
+                    List<ProEconWtCurveFittingYear> yearslist = new ArrayList<>();
+                    DateTime parse2 = DateUtil.parse(strdate, "yyyy");
                     DateTime dateYear = DateUtil.parse(recorddate, "yyyy");
-                    int year2 = DateUtil.year(dateYear);
-                    List<ProEconWtCurveFittingYear> yearslist = proEconWtCurveFittingYearService.getProEconWtCurveFittingYearList(wt, String.valueOf(year));
+                    if (parse2.equals(dateYear)) {
+                        String yearCurve = redisService.get("yearCurve_" + wt);
+                        yearslist = JSONObject.parseObject(yearCurve, new TypeReference<List<ProEconWtCurveFittingYear>>() {
+                        });
+                    } else {
+                        int year2 = DateUtil.year(dateYear);
+                        yearslist = proEconWtCurveFittingYearService.getProEconWtCurveFittingYearList(wt, String.valueOf(year));
 //                                        List<ProEconWtCurveFittingYear>  yearslist = proEconWtCurveFittingYearService.getProEconWtCurveFittingYearList(wt,String.valueOf(year));
+                    }
 
                     if (null != yearslist) {
                         yearslist.stream().forEach(w -> {