Parcourir la source

综合分析优化

wangb il y a 2 jours
Parent
commit
fe4dd9f53a

+ 6 - 6
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/bmk/BenchmarkingService.java

@@ -322,7 +322,7 @@ public class BenchmarkingService {
 
         }
         qw.select(String.valueOf(sb));
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
         if (StringUtils.isNotEmpty(companyid) && companyid.endsWith("ZGS")) {
             qw.eq("company_id", companyid);
         }
@@ -847,7 +847,7 @@ public class BenchmarkingService {
         }
         sb.append("sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
         qw.select(String.valueOf(sb));
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
 //
 //        if (companys.endsWith("RGN")) {
 //            qw.eq("region_id", companys);
@@ -1049,7 +1049,7 @@ public class BenchmarkingService {
 
         List<WxsslVo> resultList = new ArrayList<>();
         qw.select("record_date,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
         if (StringUtils.isNotEmpty(wpid)) {
             qw.eq("station_id", wpid);
         }
@@ -1179,7 +1179,7 @@ public class BenchmarkingService {
         Integer total = 0;
         qw.select("station_id,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
 
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
         if (StringUtils.isNotEmpty(wpids)) {
             List<String> wpList = Arrays.asList(wpids.split(","));
             qw.in("station_id", wpList);
@@ -1257,7 +1257,7 @@ public class BenchmarkingService {
         QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
         Integer total = 0;
         qw.select("project_id,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
         if (StringUtils.isNotEmpty(wpids)) {
             List<String> wpList = Arrays.asList(wpids.split(","));
             qw.in("station_id", wpList);
@@ -1347,7 +1347,7 @@ public class BenchmarkingService {
         Integer total = 0;
         qw.select("line_id,sum(rfdl) rfdl,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
 
-        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
+        qw.ge("record_date", DateUtils.parseDate(beginDate)).lt("record_date", DateUtils.parseDate(endDate));
 
         if (StringUtils.isNotEmpty(wpids)) {
             List<String> wpList = Arrays.asList(wpids.split(","));

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

@@ -539,32 +539,46 @@ public class SpecificService {
      * @param dqvo
      */
     private void setTnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) throws ParseException {
+        LocalDate now = LocalDate.now();
         String yearString = yearmonth.split("-")[0];
-        String year = String.valueOf(Integer.parseInt(yearString) - 1);
+        LocalDate firstDayOfYear = LocalDate.of(Integer.parseInt(yearString) - 1, 1, 1);
         QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
-        qw.select("sum(llfdl) as llfdl,sum(rfdl) as rfdl,sum(gzss) as gzss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(djss) djss,sum(xnss) as xnss,sum(slss) as slss");
-        qw.eq("to_char(record_date,'yyyy')", year);
-        qw.groupBy("to_char(record_date,'yyyy')");
+        qw.select("COALESCE(sum(llfdl), 0) as llfdl,COALESCE(sum(rfdl), 0) as rfdl,COALESCE(sum(gzss), 0) as gzss,COALESCE(sum(jhjxss), 0) as jhjxss,COALESCE(sum(fjhjxss), 0) as fjhjxss,COALESCE(sum(djss), 0) as djss,COALESCE(sum(xnss), 0) as xnss,COALESCE(sum(slss), 0) as slss");
+        qw.between("record_date", Date.from(firstDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(now.minusYears(1).atStartOfDay(ZoneId.systemDefault()).toInstant()));
         List<TurbineInfoDay> yearList = iTurbineInfoDayService.list(qw);
-
-        Optional<TurbineInfoDay> yearFirsts = yearList.stream().findFirst();
-        if (yearFirsts.isPresent()) {
-            TurbineInfoDay yearSpecific = yearFirsts.get();
-            dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getLlfdl() / 10000, 2));
-            dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getRfdl() / 10000, 2));
-            dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getJhjxss() / 10000 + yearSpecific.getFjhjxss() / 10000, 2));
-            dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getGzss() / 10000, 2));
-            dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getXnss() / 10000, 2));
-            dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getDjss() / 10000, 2));
-            dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getSlss() / 10000, 2));
-            if (dqvo.getYllfdl() != 0) {
-                dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
-                dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
-                dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
-                dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
-                dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
-                dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
+            Optional<TurbineInfoDay> yearFirsts = yearList.stream().findFirst();
+            if (yearFirsts.isPresent()) {
+                TurbineInfoDay yearSpecific = yearFirsts.get();
+                dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getLlfdl() / 1000, 2));
+                dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getRfdl() / 1000, 2));
+                dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getJhjxss() / 1000 + yearSpecific.getFjhjxss() / 1000, 2));
+                dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getGzss() / 1000, 2));
+                dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getXnss() / 1000, 2));
+                dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getDjss() / 1000, 2));
+                dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getSlss() / 1000, 2));
+                if (dqvo.getYllfdl() != 0) {
+                    dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
+                    dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
+                    dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
+                    dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
+                    dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
+                    dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
+                } else {
+                    dqvo.setNfnlyl(0.0);
+                    dqvo.setNwhssl(0.0);
+                    dqvo.setNgzssl(0.0);
+                    dqvo.setNxdssl(0.0);
+                    dqvo.setNxnssl(0.0);
+                    dqvo.setNslssl(0.0);
+                }
             } else {
+                dqvo.setNllfdl(0.0);
+                dqvo.setNsjfdl(0.0);
+                dqvo.setNwhssdl(0.0);
+                dqvo.setNgzssdl(0.0);
+                dqvo.setNxdssdl(0.0);
+                dqvo.setNxnssdl(0.0);
+                dqvo.setNslssdl(0.0);
                 dqvo.setNfnlyl(0.0);
                 dqvo.setNwhssl(0.0);
                 dqvo.setNgzssl(0.0);
@@ -572,21 +586,7 @@ public class SpecificService {
                 dqvo.setNxnssl(0.0);
                 dqvo.setNslssl(0.0);
             }
-        } else {
-            dqvo.setNllfdl(0.0);
-            dqvo.setNsjfdl(0.0);
-            dqvo.setNwhssdl(0.0);
-            dqvo.setNgzssdl(0.0);
-            dqvo.setNxdssdl(0.0);
-            dqvo.setNxnssdl(0.0);
-            dqvo.setNslssdl(0.0);
-            dqvo.setNfnlyl(0.0);
-            dqvo.setNwhssl(0.0);
-            dqvo.setNgzssl(0.0);
-            dqvo.setNxdssl(0.0);
-            dqvo.setNxnssl(0.0);
-            dqvo.setNslssl(0.0);
-        }
+
     }
 
 
@@ -974,7 +974,7 @@ public class SpecificService {
         List<StationInfoMonth> list = stationInfoMonthService.list(qw2);
         if (StringUtils.isNotEmpty(tqList)) {
             tqList.stream().forEach(i -> {
-                Optional<SpecificCenterVo> optionYear = yearresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId())||j.getWpid().equals(i.getForeignKeyId())).findFirst();
+                Optional<SpecificCenterVo> optionYear = yearresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId()) || j.getWpid().equals(i.getForeignKeyId())).findFirst();
                 if (optionYear.isPresent()) {
                     SpecificCenterVo rightVo = optionYear.get();
                     if (null != list && !list.isEmpty()) {