浏览代码

综合场用电量优化

wangb 20 小时之前
父节点
当前提交
bc9e35d46b

+ 1 - 1
runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/specific/SpecificController.java

@@ -254,7 +254,7 @@ public class SpecificController {
 
     @GetMapping("/swdlList")
     @ResponseBody
-    @ApiOperation(value = "专题分析-购网电量", notes = "专题分析-购网电量")
+    @ApiOperation(value = "专题分析-上网电量", notes = "专题分析-上网电量")
     public R swdldlList(@RequestParam(value = "companys") String companys,
                         @RequestParam(value = "type") String type,
                         @RequestParam(value = "year") String year) throws ParseException {

+ 9 - 177
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/specific/SpecificService.java

@@ -1612,35 +1612,19 @@ public class SpecificService {
         QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
         currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
         currentqw.eq("to_char(record_date,'yyyy')", year);
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
         currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
-        currentqw.clear();
-        currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
-        currentqw.eq("to_char(record_date,'yyyy')", year);
-        currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        currentList.addAll(iStationInfoDayService.list(currentqw));
 
         int subYear = Integer.parseInt(year) - 1;
         QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
         sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
         sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
         sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
         sameperiodqw.clear();
-        sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
-        sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
-        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
+
         //合并当月与同期数据为返回结果
         List<SpecificTargetVo> resultList = new ArrayList<>();
         currentList.stream().forEach(i -> {
@@ -1657,9 +1641,7 @@ public class SpecificService {
         });
         resultList.stream().forEach(i -> {
             Optional<StationInfoDay> optional = sameperiodList.stream()
-                    .filter(j -> i.getWpid().equals(j.getStationId())
-                            && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
-                    .findFirst();
+                    .filter(j->i.getMonth().equals(j.getRecordDate().getMonth().getValue()+1)).findFirst();
 
             if (optional.isPresent()) {
                 StationInfoDay tqinfoday = optional.get();
@@ -1880,51 +1862,21 @@ public class SpecificService {
     public List<SpecificTarget> zhcydlList(String companys, String type, String year) {
         //获取年份所有当月的数据
         QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
-        currentqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
-//        currentqw.eq("location", "wp");
+        currentqw.select("station_id,max(record_date) record_date,sum(zhcydl) zhcydl");
         currentqw.eq("to_char(record_date,'yyyy')", year);
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
         currentqw.clear();
-        currentqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
-//        currentqw.eq("foreign_key_id", companys + type);
-        currentqw.eq("to_char(record_date,'yyyy')", year);
-        currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        currentList.addAll(iStationInfoDayService.list(currentqw));
 
         int subYear = Integer.parseInt(year) - 1;
         QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
-        sameperiodqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
-//        sameperiodqw.eq("location", "wp");
-        if (type.equals("-1")) {
+        sameperiodqw.select("station_id,max(record_date) record_date,sum(zhcydl) zhcydl");
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
         sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
         sameperiodqw.clear();
-        sameperiodqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
-//        sameperiodqw.eq("foreign_key_id", companys + type);
-        sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
-        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
 
         //合并当月与同期数据为返回结果
         List<SpecificTargetVo> resultList = new ArrayList<>();
@@ -1933,28 +1885,20 @@ public class SpecificService {
             SpecificTargetVo vo = new SpecificTargetVo();
             String wpid = i.getStationId();
             vo.setWpid(wpid);
-//            if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//            } else if (wpid.contains("_RGN")) {
-//                vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//            } else {
             vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
-//            }
             Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
             Date date = Date.from(instant);
             vo.setYear(DateUtils.getYear(date));
             vo.setMonth(DateUtils.getMonth(date));
-            vo.setCurrent(DoubleUtils.keepPrecision(i.getCydl().doubleValue() / 100, 2));
+            vo.setCurrent(DoubleUtils.keepPrecision(i.getZhcydl().doubleValue() / 1000, 2));
             resultList.add(vo);
         });
         resultList.stream().forEach(i -> {
             Optional<StationInfoDay> optional = sameperiodList.stream()
-                    //                    .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
-                    .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
-                    .findFirst();
+                    .filter(j->i.getMonth().equals(j.getRecordDate().getMonth().getValue()+1)).findFirst();
             if (optional.isPresent()) {
                 StationInfoDay tqinfoday = optional.get();
-                i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getCydl().doubleValue() / 100, 2));
+                i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getZhcydl().doubleValue() / 1000, 2));
                 i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
             } else {
                 i.setSameperiod(0.0);
@@ -1985,14 +1929,8 @@ public class SpecificService {
                 SpecificTarget vo = new SpecificTarget();
                 vo.setWpid(wpid);
                 int orderNum = 100;
-//                if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                    vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//                } else if (wpid.contains("_RGN")) {
-//                    vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//                } else {
                 vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
                 orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
-//                }
                 vo.setOrderNum(orderNum);
                 List<SpecificTargetVo> tempList = new ArrayList<>();
 
@@ -2003,20 +1941,13 @@ public class SpecificService {
                     } else {
                         SpecificTargetVo vo1 = new SpecificTargetVo();
                         vo1.setWpid(wpid);
-//                        if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                            vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
-//                        } else if (wpid.contains("_RGN")) {
-//                            vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
-//                        } else {
                         vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
-//                        }
                         vo1.setYear(Integer.parseInt(year));
                         vo1.setMonth(x);
                         tempList.add(vo1);
                     }
                 }
 
-
                 vo.setTargetList(tempList);
                 resultendList.add(vo);
 
@@ -2187,50 +2118,20 @@ public class SpecificService {
         //获取年份所有当月的数据
         QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
         currentqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
-//        currentqw.eq("location", "wp");
         currentqw.eq("to_char(record_date,'yyyy')", year);
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
         currentqw.clear();
-        currentqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
-//        currentqw.eq("foreign_key_id", companys + type);
-        currentqw.eq("to_char(record_date,'yyyy')", year);
-        currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        currentList.addAll(iStationInfoDayService.list(currentqw));
 
         int subYear = Integer.parseInt(year) - 1;
         QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
         sameperiodqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
-//        sameperiodqw.eq("location", "wp");
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
         sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
         sameperiodqw.clear();
-        sameperiodqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
-//        sameperiodqw.eq("foreign_key_id", companys + type);
-        sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
-        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
 
         //合并当月与同期数据为返回结果
         List<SpecificTargetVo> resultList = new ArrayList<>();
@@ -2239,13 +2140,7 @@ public class SpecificService {
             SpecificTargetVo vo = new SpecificTargetVo();
             String wpid = i.getStationId();
             vo.setWpid(wpid);
-//            if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//            } else if (wpid.contains("_RGN")) {
-//                vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//            } else {
             vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
-//            }
             Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
             Date date = Date.from(instant);
             vo.setYear(DateUtils.getYear(date));
@@ -2255,8 +2150,7 @@ public class SpecificService {
         });
         resultList.stream().forEach(i -> {
             Optional<StationInfoDay> optional = sameperiodList.stream()
-                    .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
-                    .findFirst();
+                    .filter(j->i.getMonth().equals(j.getRecordDate().getMonth().getValue()+1)).findFirst();
             if (optional.isPresent()) {
                 StationInfoDay tqinfoday = optional.get();
                 i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getGwdl().doubleValue() / 1000, 2));
@@ -2290,14 +2184,8 @@ public class SpecificService {
                 SpecificTarget vo = new SpecificTarget();
                 vo.setWpid(wpid);
                 int orderNum = 100;
-//                if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                    vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//                } else if (wpid.contains("_RGN")) {
-//                    vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//                } else {
                 vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
                 orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
-//                }
                 vo.setOrderNum(orderNum);
                 List<SpecificTargetVo> tempList = new ArrayList<>();
 
@@ -2308,13 +2196,7 @@ public class SpecificService {
                     } else {
                         SpecificTargetVo vo1 = new SpecificTargetVo();
                         vo1.setWpid(wpid);
-//                        if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                            vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
-//                        } else if (wpid.contains("_RGN")) {
-//                            vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
-//                        } else {
                         vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
-//                        }
                         vo1.setYear(Integer.parseInt(year));
                         vo1.setMonth(x);
                         tempList.add(vo1);
@@ -2492,50 +2374,20 @@ public class SpecificService {
         //获取年份所有当月的数据
         QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
         currentqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
-//        currentqw.eq("location", "wp");
         currentqw.eq("to_char(record_date,'yyyy')", year);
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
         currentqw.clear();
-        currentqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
-//        currentqw.eq("foreign_key_id", companys + type);
-        currentqw.eq("to_char(record_date,'yyyy')", year);
-        currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        currentList.addAll(iStationInfoDayService.list(currentqw));
 
         int subYear = Integer.parseInt(year) - 1;
         QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
         sameperiodqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
-//        sameperiodqw.eq("location", "wp");
-        if (type.equals("-1")) {
             currentqw.like("station_id", "_FDC_");
-        } else {
-            currentqw.like("station_id", "_GDC_");
-        }
-//        if (companys.endsWith("ZGS")) {
-//            currentqw.eq("company_id", companys);
-//        } else {
-//            currentqw.eq("region_id", companys);
-//        }
         sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
         sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
         List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
         sameperiodqw.clear();
-        sameperiodqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
-//        sameperiodqw.eq("foreign_key_id", companys + type);
-        sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
-        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
-        sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
 
         //合并当月与同期数据为返回结果
         List<SpecificTargetVo> resultList = new ArrayList<>();
@@ -2544,13 +2396,7 @@ public class SpecificService {
             SpecificTargetVo vo = new SpecificTargetVo();
             String wpid = i.getStationId();
             vo.setWpid(wpid);
-//            if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//            } else if (wpid.contains("_RGN")) {
-//                vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//            } else {
             vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
-//            }
             Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
             Date date = Date.from(instant);
             vo.setYear(DateUtils.getYear(date));
@@ -2560,8 +2406,7 @@ public class SpecificService {
         });
         resultList.stream().forEach(i -> {
             Optional<StationInfoDay> optional = sameperiodList.stream()
-                    .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
-                    .findFirst();
+                    .filter(j->i.getMonth().equals(j.getRecordDate().getMonth().getValue()+1)).findFirst();
             if (optional.isPresent()) {
                 StationInfoDay tqinfoday = optional.get();
                 i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getSwdl().doubleValue() / 1000, 2));
@@ -2595,14 +2440,8 @@ public class SpecificService {
                 SpecificTarget vo = new SpecificTarget();
                 vo.setWpid(wpid);
                 int orderNum = 100;
-//                if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
-//                    vo.setWpname(CacheContext.cpmap.get(companys).getAname());
-//                } else if (wpid.contains("_RGN")) {
-//                    vo.setWpname(CacheContext.rgmap.get(companys).getAname());
-//                } else {
                 vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
                 orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
-//                }
                 vo.setOrderNum(orderNum);
                 List<SpecificTargetVo> tempList = new ArrayList<>();
 
@@ -2613,20 +2452,13 @@ public class SpecificService {
                     } else {
                         SpecificTargetVo vo1 = new SpecificTargetVo();
                         vo1.setWpid(wpid);
-                        if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
-                            vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
-                        } else if (wpid.contains("_RGN")) {
-                            vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
-                        } else {
                             vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
-                        }
                         vo1.setYear(Integer.parseInt(year));
                         vo1.setMonth(x);
                         tempList.add(vo1);
                     }
                 }
 
-
                 vo.setTargetList(tempList);
                 resultendList.add(vo);