Browse Source

bug修改

wangb 1 week ago
parent
commit
cee494fb2d

+ 25 - 13
runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/homepage/EconomyHomePageController.java

@@ -120,27 +120,27 @@ public class EconomyHomePageController {
     /**
      * 首页 发电量
      */
-    @GetMapping(value = "/generating-capacity")
-    @ApiOperation(value = "首页-发电量", notes = "首页-发电量")
-    public ResultMsg getHomeGeneratingCapacity(@RequestParam(value = "companyId", required = false) String companyId) throws Exception {
-
-        Map<String, Object> map = economyPointHomePageService.getGeneratingCapacity2(companyId);
-        if (null != map) {
-            return ResultMsg.ok(map);
-        } else {
-            return ResultMsg.error();
-        }
-    }
+//    @GetMapping(value = "/generating-capacity")
+//    @ApiOperation(value = "首页-发电量", notes = "首页-发电量")
+//    public ResultMsg getHomeGeneratingCapacity(@RequestParam(value = "companyId", required = false) String companyId) throws Exception {
+//
+//        Map<String, Object> map = economyPointHomePageService.getGeneratingCapacity2(companyId);
+//        if (null != map) {
+//            return ResultMsg.ok(map);
+//        } else {
+//            return ResultMsg.error();
+//        }
+//    }
 
 
     /**
      * 首页 发电量
      */
-    @GetMapping(value = "/generating-capacity2")
+    @GetMapping(value = "/generating-capacity")
     @ApiOperation(value = "首页-发电量", notes = "首页-发电量")
     public ResultMsg getHomeGeneratingCapacity2(@RequestParam(value = "companyId", required = false) String companyId) throws Exception {
 
-        Map<String, Object> map = economyPointHomePageService.getGeneratingCapacity2(companyId);
+        Map<String, Object> map = economyPointHomePageService.getGeneratingCapacity(companyId);
         if (null != map) {
             return ResultMsg.ok(map);
         } else {
@@ -152,6 +152,18 @@ public class EconomyHomePageController {
     /**
      * 首页 右侧模块
      */
+//    @GetMapping(value = "/home-right")
+//    @ApiOperation(value = "首页-右侧模块", notes = "首页-右侧模块")
+//    public ResultMsg getHomeRight(@RequestParam(value = "companyId", required = false) String companyId) throws Exception {
+//
+//        Map<String, Object> map = economyPointHomePageService.getHomeRight(companyId);
+//        if (null != map) {
+//            return ResultMsg.ok(map);
+//        } else {
+//            return ResultMsg.error();
+//        }
+//    }
+
     @GetMapping(value = "/home-right")
     @ApiOperation(value = "首页-右侧模块", notes = "首页-右侧模块")
     public ResultMsg getHomeRight(@RequestParam(value = "companyId", required = false) String companyId) throws Exception {

+ 542 - 237
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/homepage/EconomyPointHomePageService.java

@@ -21,6 +21,7 @@ import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.Month;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
@@ -71,6 +72,10 @@ public class EconomyPointHomePageService {
     private IStationInfoMinService iStationInfoMinService;
 
 
+    @Resource
+    private IStationInfoDayService iStationInfoDayService;
+
+
     /**
      * 指标率相应类
      */
@@ -126,6 +131,11 @@ public class EconomyPointHomePageService {
 
     private List<Map<String, Object>> stainfo = null;//场站性息
 
+    /**
+     * 15分钟发电量
+     */
+    private Map<String, GeneratingCapacityVo> generatingCapacity15min = new HashMap<>();
+
 
     /**
      * 经济运行首页聚合方法
@@ -1552,107 +1562,260 @@ public class EconomyPointHomePageService {
     }
 
 
-    public Map<String, Object> getGeneratingCapacity2(String companyId) {
-        Map<String, Object> allmap = new HashMap<>();
-        List<GeneratingCapacityVo> ls = new ArrayList<>();
-        LocalDate now = LocalDate.now();
-        QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
-        qw.lambda().eq(ProEconPowerstationInfoDay1::getRecordDate, now)
-                .eq(ProEconPowerstationInfoDay1::getForeignKeyId, companyId);
-        List<ProEconPowerstationInfoDay1> day1s = proEconPowerstationInfoDay1Service.list(qw);
-        for (ProEconPowerstationInfoDay1 day1 : day1s) {
-            GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
-            rfdl.setName("日发电量");
-            rfdl.setValue(day1.getRfdl());
-            rfdl.setTotal(day1.getRllfdl());
-            BigDecimal rbfb = (day1.getRfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getRllfdl().compareTo(BigDecimal.ZERO) == 0)
-                    ? BigDecimal.ZERO
-                    : day1.getRllfdl().divide(day1.getRfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-            rfdl.setBfb(rbfb);
-            rfdl.setBfb(rbfb);
-            ls.add(rfdl);
-
-            GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
-            yfdl.setName("月发电量");
-            yfdl.setValue(day1.getYfdl());
-            yfdl.setTotal(day1.getYllfdl());
-            BigDecimal ybfb = (day1.getYfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getYllfdl().compareTo(BigDecimal.ZERO) == 0)
-                    ? BigDecimal.ZERO
-                    : day1.getYllfdl().divide(day1.getYfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-            rfdl.setBfb(rbfb);
-            yfdl.setBfb(ybfb);
-            ls.add(yfdl);
-
-            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
-            nfdl.setName("年发电量");
-            nfdl.setValue(day1.getNfdl().divide(new BigDecimal(1000)));
-            nfdl.setTotal(day1.getNllfdl().divide(new BigDecimal(1000)));
-            BigDecimal nbfb = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
-                    ? BigDecimal.ZERO
-                    : day1.getNllfdl().divide(day1.getNfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-            rfdl.setBfb(rbfb);
-            nfdl.setBfb(nbfb);
-            ls.add(nfdl);
-
-            Map<String, Object> zbtqdb = new HashMap<>();
-            List<ColumnVo> ls1 = new ArrayList<>();
-            ColumnVo cl1 = new ColumnVo();
-            cl1.setName("指标名称");
-            cl1.setField("wtId");
-            ColumnVo cl2 = new ColumnVo();
-            cl2.setName(String.valueOf(LocalDate.now().getYear()));
-            cl2.setField("recodedate");
-            ColumnVo cl3 = new ColumnVo();
-            cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
-            cl3.setField("recodedate2");
-            ColumnVo cl4 = new ColumnVo();
-            cl4.setName("涨跌%");
-            cl4.setField("operation");
-            ls1.add(cl1);
-            ls1.add(cl2);
-            ls1.add(cl3);
-            ls1.add(cl4);
-
-            List<ComparetqVo> ls2 = new ArrayList<>();
-            ComparetqVo cv = new ComparetqVo();
-            cv.setWtId("发电量");
-            cv.setRecodedate(String.valueOf(day1.getNfdl().divide(new BigDecimal(1000))));
-            cv.setRecodedate2(String.valueOf(0));
-            cv.setOperation("100");
-            ComparetqVo cv1 = new ComparetqVo();
-            cv1.setWtId("上网电量");
-            cv1.setRecodedate(String.valueOf(0.00));
-            cv1.setRecodedate2(String.valueOf(0));
-            cv1.setOperation("0");
-            ComparetqVo cv2 = new ComparetqVo();
-            cv2.setWtId("网购电量");
-            cv2.setRecodedate(String.valueOf(0.00));
-            cv2.setRecodedate2(String.valueOf(0));
-            cv2.setOperation("0");
-            ComparetqVo cv3 = new ComparetqVo();
-            cv3.setWtId("损失电量");
-            cv3.setRecodedate(String.valueOf(0.00));
-            cv3.setRecodedate2(String.valueOf(0));
-            cv3.setOperation("0");
-            ComparetqVo cv4 = new ComparetqVo();
-            cv4.setWtId("场用电量");
-            cv4.setRecodedate(String.valueOf(0.00));
-            cv4.setRecodedate2(String.valueOf(0));
-            cv4.setOperation("0");
-            ls2.add(cv);
-            ls2.add(cv1);
-            ls2.add(cv2);
-            ls2.add(cv3);
-            ls2.add(cv4);
-
-            zbtqdb.put("column", ls1);
-            zbtqdb.put("data", ls2);
-            allmap.put("fdl", ls);
-            allmap.put("zbtqdb", zbtqdb);
-        }
-
-        return allmap;
-    }
+//    public Map<String, Object> getGeneratingCapacity2(String companyId) {
+//        Map<String, Object> allmap = new HashMap<>();
+//        List<GeneratingCapacityVo> ls = new ArrayList<>();
+//        LocalDate now = LocalDate.now();
+//        QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
+//        qw.lambda().eq(ProEconPowerstationInfoDay1::getRecordDate, now)
+//                .eq(ProEconPowerstationInfoDay1::getForeignKeyId, companyId);
+//        List<ProEconPowerstationInfoDay1> day1s = proEconPowerstationInfoDay1Service.list(qw);
+//        for (ProEconPowerstationInfoDay1 day1 : day1s) {
+//            GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
+//            rfdl.setName("日发电量");
+//            rfdl.setValue(day1.getRfdl());
+//            rfdl.setTotal(day1.getRllfdl());
+//            BigDecimal rbfb = (day1.getRfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getRllfdl().compareTo(BigDecimal.ZERO) == 0)
+//                    ? BigDecimal.ZERO
+//                    : day1.getRllfdl().divide(day1.getRfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+//            rfdl.setBfb(rbfb);
+//            rfdl.setBfb(rbfb);
+//            ls.add(rfdl);
+//
+//            GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
+//            yfdl.setName("月发电量");
+//            yfdl.setValue(day1.getYfdl());
+//            yfdl.setTotal(day1.getYllfdl());
+//            BigDecimal ybfb = (day1.getYfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getYllfdl().compareTo(BigDecimal.ZERO) == 0)
+//                    ? BigDecimal.ZERO
+//                    : day1.getYllfdl().divide(day1.getYfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+//            rfdl.setBfb(rbfb);
+//            yfdl.setBfb(ybfb);
+//            ls.add(yfdl);
+//
+//            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
+//            nfdl.setName("年发电量");
+//            nfdl.setValue(day1.getNfdl().divide(new BigDecimal(1000)));
+//            nfdl.setTotal(day1.getNllfdl().divide(new BigDecimal(1000)));
+//            BigDecimal nbfb = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
+//                    ? BigDecimal.ZERO
+//                    : day1.getNllfdl().divide(day1.getNfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+//            rfdl.setBfb(rbfb);
+//            nfdl.setBfb(nbfb);
+//            ls.add(nfdl);
+//
+//            Map<String, Object> zbtqdb = new HashMap<>();
+//            List<ColumnVo> ls1 = new ArrayList<>();
+//            ColumnVo cl1 = new ColumnVo();
+//            cl1.setName("指标名称");
+//            cl1.setField("wtId");
+//            ColumnVo cl2 = new ColumnVo();
+//            cl2.setName(String.valueOf(LocalDate.now().getYear()));
+//            cl2.setField("recodedate");
+//            ColumnVo cl3 = new ColumnVo();
+//            cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
+//            cl3.setField("recodedate2");
+//            ColumnVo cl4 = new ColumnVo();
+//            cl4.setName("涨跌%");
+//            cl4.setField("operation");
+//            ls1.add(cl1);
+//            ls1.add(cl2);
+//            ls1.add(cl3);
+//            ls1.add(cl4);
+//
+//            List<ComparetqVo> ls2 = new ArrayList<>();
+//            ComparetqVo cv = new ComparetqVo();
+//            cv.setWtId("发电量");
+//            cv.setRecodedate(String.valueOf(day1.getNfdl().divide(new BigDecimal(1000))));
+//            cv.setRecodedate2(String.valueOf(0));
+//            cv.setOperation("100");
+//            ComparetqVo cv1 = new ComparetqVo();
+//            cv1.setWtId("上网电量");
+//            cv1.setRecodedate(String.valueOf(0.00));
+//            cv1.setRecodedate2(String.valueOf(0));
+//            cv1.setOperation("0");
+//            ComparetqVo cv2 = new ComparetqVo();
+//            cv2.setWtId("网购电量");
+//            cv2.setRecodedate(String.valueOf(0.00));
+//            cv2.setRecodedate2(String.valueOf(0));
+//            cv2.setOperation("0");
+//            ComparetqVo cv3 = new ComparetqVo();
+//            cv3.setWtId("损失电量");
+//            cv3.setRecodedate(String.valueOf(0.00));
+//            cv3.setRecodedate2(String.valueOf(0));
+//            cv3.setOperation("0");
+//            ComparetqVo cv4 = new ComparetqVo();
+//            cv4.setWtId("场用电量");
+//            cv4.setRecodedate(String.valueOf(0.00));
+//            cv4.setRecodedate2(String.valueOf(0));
+//            cv4.setOperation("0");
+//            ls2.add(cv);
+//            ls2.add(cv1);
+//            ls2.add(cv2);
+//            ls2.add(cv3);
+//            ls2.add(cv4);
+//
+//            zbtqdb.put("column", ls1);
+//            zbtqdb.put("data", ls2);
+//            allmap.put("fdl", ls);
+//            allmap.put("zbtqdb", zbtqdb);
+//        }
+//
+//        return allmap;
+//    }
+
+
+//    public Map<String, Object> getHomeRight(String companyId) {
+//        Map<String, Object> allmap = new HashMap<>();
+//        LocalDate now = LocalDate.now();
+//        Date currentDate = DateUtils.getCurrentDate();
+//        Date monthFirst = DateUtils.getMonthFirst(currentDate);
+//        double hoursDiff = DateUtils.hoursDiff2(currentDate, monthFirst);
+//        QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
+//        qw.lambda().eq(ProEconPowerstationInfoDay1::getRecordDate, now)
+//                .eq(ProEconPowerstationInfoDay1::getForeignKeyId, companyId);
+//        List<ProEconPowerstationInfoDay1> day1s = proEconPowerstationInfoDay1Service.list(qw);
+//        Map<String, Object> sbklyl = new HashMap<>();
+//        for (ProEconPowerstationInfoDay1 day1 : day1s) {
+//            Map<String, Object> zbtqdb = new HashMap<>();
+//            String[] title = {"排名", "名称", "风能利用率%", "去年同期%", "涨跌%"};
+//            List<ColumnVo> ls1 = getTitle(title);
+//            String[] title2 = {"排名", "名称", "设备利用率%", "去年同期%", "涨跌%"};
+//            List<ColumnVo> ls3 = getTitle(title2);
+//            List<HomeRightVo> ls2 = new ArrayList<>();
+//            HomeRightVo hv = new HomeRightVo();
+//            hv.setIndex("1");
+//            hv.setName("惠安风场");
+//            BigDecimal fnlyl = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
+//                    ? BigDecimal.ZERO
+//                    : day1.getNfdl().divide(day1.getNllfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+//            hv.setFnlyl(String.valueOf(fnlyl));
+//            hv.setYearTq("0");
+//            hv.setOperation(String.valueOf(fnlyl));
+//            ls2.add(hv);
+//
+//            zbtqdb.put("column", ls1);
+//            zbtqdb.put("data", ls2);
+//            sbklyl.put("column", ls3);
+//            allmap.put("fnlyl", zbtqdb);
+//
+//        }
+//
+//        QueryWrapper<ProEconPowerstationInfoDay2> qw2 = new QueryWrapper<>();
+//        qw2.lambda().eq(ProEconPowerstationInfoDay2::getRecordDate, now)
+//                .eq(ProEconPowerstationInfoDay2::getForeignKeyId, companyId);
+//        List<ProEconPowerstationInfoDay2> list = iProEconPowerstationInfoDay2Service.list(qw2);
+//        for (ProEconPowerstationInfoDay2 day2 : list) {
+//            List<HomeRightVo> ls3 = new ArrayList<>();
+//            HomeRightVo hv2 = new HomeRightVo();
+//            hv2.setIndex("1");
+//            hv2.setName("惠安风场");
+//            BigDecimal hoursDiffDecimal = BigDecimal.valueOf(hoursDiff);
+//            BigDecimal result = hoursDiffDecimal.subtract(day2.getNhjgztjxs()).subtract(day2.getNhjjxtjxs());
+//            BigDecimal ysbklyl = result.divide(hoursDiffDecimal, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+//            hv2.setFnlyl(String.valueOf(ysbklyl));
+//            hv2.setYearTq("0");
+//            hv2.setOperation(String.valueOf(ysbklyl));
+//            ls3.add(hv2);
+//            sbklyl.put("data", ls3);
+//            allmap.put("sbklyl", sbklyl);
+//        }
+//
+//        Map<String, Object> lgxzkh = new HashMap<>();
+//        String[] title = {"排名", "名称", "考核分数", "去年同期%", "涨跌%"};
+//        List<ColumnVo> ls1 = getTitle(title);
+//        List<HomeRightVo> ls2 = new ArrayList<>();
+//        HomeRightVo hv = new HomeRightVo();
+//        hv.setIndex("1");
+//        hv.setName("惠安风场");
+//        hv.setFnlyl("98");
+//        hv.setYearTq("0");
+//        hv.setOperation("100");
+//        ls2.add(hv);
+//
+//        lgxzkh.put("column", ls1);
+//        lgxzkh.put("data", ls2);
+//        allmap.put("lgxzkh", lgxzkh);
+//
+//        return allmap;
+//
+//    }
+
+//    public Map<String, Object> getHomeRight(String companyId) {
+//        Map<String, Object> allmap = new HashMap<>();
+//        LocalDate now = LocalDate.now();
+//        Date currentDate = DateUtils.getCurrentDate();
+//        Date monthFirst = DateUtils.getMonthFirst(currentDate);
+//        double hoursDiff = DateUtils.hoursDiff2(currentDate, monthFirst);
+//        QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
+//        qw.lambda().eq(ProEconPowerstationInfoDay1::getRecordDate, now)
+//                .eq(ProEconPowerstationInfoDay1::getForeignKeyId, companyId);
+//        List<ProEconPowerstationInfoDay1> day1s = proEconPowerstationInfoDay1Service.list(qw);
+//        Map<String, Object> sbklyl = new HashMap<>();
+//        for (ProEconPowerstationInfoDay1 day1 : day1s) {
+//            Map<String, Object> zbtqdb = new HashMap<>();
+//            String[] title = {"排名", "名称", "风能利用率%", "去年同期%", "涨跌%"};
+//            List<ColumnVo> ls1 = getTitle(title);
+//            String[] title2 = {"排名", "名称", "设备利用率%", "去年同期%", "涨跌%"};
+//            List<ColumnVo> ls3 = getTitle(title2);
+//            List<HomeRightVo> ls2 = new ArrayList<>();
+//            HomeRightVo hv = new HomeRightVo();
+//            hv.setIndex("1");
+//            hv.setName("惠安风场");
+//            BigDecimal fnlyl = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
+//                    ? BigDecimal.ZERO
+//                    : day1.getNfdl().divide(day1.getNllfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+//            hv.setFnlyl(String.valueOf(fnlyl));
+//            hv.setYearTq("0");
+//            hv.setOperation(String.valueOf(fnlyl));
+//            ls2.add(hv);
+//
+//            zbtqdb.put("column", ls1);
+//            zbtqdb.put("data", ls2);
+//            sbklyl.put("column", ls3);
+//            allmap.put("fnlyl", zbtqdb);
+//
+//        }
+//
+//        QueryWrapper<ProEconPowerstationInfoDay2> qw2 = new QueryWrapper<>();
+//        qw2.lambda().eq(ProEconPowerstationInfoDay2::getRecordDate, now)
+//                .eq(ProEconPowerstationInfoDay2::getForeignKeyId, companyId);
+//        List<ProEconPowerstationInfoDay2> list = iProEconPowerstationInfoDay2Service.list(qw2);
+//        for (ProEconPowerstationInfoDay2 day2 : list) {
+//            List<HomeRightVo> ls3 = new ArrayList<>();
+//            HomeRightVo hv2 = new HomeRightVo();
+//            hv2.setIndex("1");
+//            hv2.setName("惠安风场");
+//            BigDecimal hoursDiffDecimal = BigDecimal.valueOf(hoursDiff);
+//            BigDecimal result = hoursDiffDecimal.subtract(day2.getNhjgztjxs()).subtract(day2.getNhjjxtjxs());
+//            BigDecimal ysbklyl = result.divide(hoursDiffDecimal, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+//            hv2.setFnlyl(String.valueOf(ysbklyl));
+//            hv2.setYearTq("0");
+//            hv2.setOperation(String.valueOf(ysbklyl));
+//            ls3.add(hv2);
+//            sbklyl.put("data", ls3);
+//            allmap.put("sbklyl", sbklyl);
+//        }
+//
+//        Map<String, Object> lgxzkh = new HashMap<>();
+//        String[] title = {"排名", "名称", "考核分数", "去年同期%", "涨跌%"};
+//        List<ColumnVo> ls1 = getTitle(title);
+//        List<HomeRightVo> ls2 = new ArrayList<>();
+//        HomeRightVo hv = new HomeRightVo();
+//        hv.setIndex("1");
+//        hv.setName("惠安风场");
+//        hv.setFnlyl("98");
+//        hv.setYearTq("0");
+//        hv.setOperation("100");
+//        ls2.add(hv);
+//
+//        lgxzkh.put("column", ls1);
+//        lgxzkh.put("data", ls2);
+//        allmap.put("lgxzkh", lgxzkh);
+//
+//        return allmap;
+//
+//    }
 
 
     public Map<String, Object> getHomeRight(String companyId) {
@@ -1666,37 +1829,34 @@ public class EconomyPointHomePageService {
                 .eq(ProEconPowerstationInfoDay1::getForeignKeyId, companyId);
         List<ProEconPowerstationInfoDay1> day1s = proEconPowerstationInfoDay1Service.list(qw);
         Map<String, Object> sbklyl = new HashMap<>();
-        for (ProEconPowerstationInfoDay1 day1 : day1s) {
-            Map<String, Object> zbtqdb = new HashMap<>();
-            String[] title = {"排名", "名称", "风能利用率%", "去年同期%", "涨跌%"};
-            List<ColumnVo> ls1 = getTitle(title);
-            String[] title2 = {"排名", "名称", "设备利用率%", "去年同期%", "涨跌%"};
-            List<ColumnVo> ls3 = getTitle(title2);
-            List<HomeRightVo> ls2 = new ArrayList<>();
-            HomeRightVo hv = new HomeRightVo();
-            hv.setIndex("1");
-            hv.setName("惠安风场");
-            BigDecimal fnlyl = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
-                    ? BigDecimal.ZERO
-                    : day1.getNfdl().divide(day1.getNllfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-            hv.setFnlyl(String.valueOf(fnlyl));
-            hv.setYearTq("0");
-            hv.setOperation(String.valueOf(fnlyl));
-            ls2.add(hv);
-
-            zbtqdb.put("column", ls1);
-            zbtqdb.put("data", ls2);
-            sbklyl.put("column", ls3);
-            allmap.put("fnlyl", zbtqdb);
+        GeneratingCapacityVo genCap = generatingCapacity15min.get("年发电量");
 
-        }
+        Map<String, Object> zbtqdb = new HashMap<>();
+        String[] title = {"排名", "名称", "风能利用率%", "去年同期%", "涨跌%"};
+        List<ColumnVo> ls1 = getTitle(title);
+        String[] title2 = {"排名", "名称", "设备利用率%", "去年同期%", "涨跌%"};
+        List<ColumnVo> ls3 = getTitle(title2);
+        List<HomeRightVo> ls2 = new ArrayList<>();
+        HomeRightVo hv = new HomeRightVo();
+        hv.setIndex("1");
+        hv.setName("惠安风场");
+        Double fnlyl = calDivide(genCap.getValue(), genCap.getTotal());
+        hv.setFnlyl(String.valueOf(fnlyl));
+        hv.setYearTq("0");
+        hv.setOperation(String.valueOf(fnlyl));
+        ls2.add(hv);
+
+        zbtqdb.put("column", ls1);
+        zbtqdb.put("data", ls2);
+        sbklyl.put("column", ls3);
+        allmap.put("fnlyl", zbtqdb);
 
         QueryWrapper<ProEconPowerstationInfoDay2> qw2 = new QueryWrapper<>();
         qw2.lambda().eq(ProEconPowerstationInfoDay2::getRecordDate, now)
                 .eq(ProEconPowerstationInfoDay2::getForeignKeyId, companyId);
         List<ProEconPowerstationInfoDay2> list = iProEconPowerstationInfoDay2Service.list(qw2);
         for (ProEconPowerstationInfoDay2 day2 : list) {
-            List<HomeRightVo> ls3 = new ArrayList<>();
+            List<HomeRightVo> ls4 = new ArrayList<>();
             HomeRightVo hv2 = new HomeRightVo();
             hv2.setIndex("1");
             hv2.setName("惠安风场");
@@ -1706,27 +1866,10 @@ public class EconomyPointHomePageService {
             hv2.setFnlyl(String.valueOf(ysbklyl));
             hv2.setYearTq("0");
             hv2.setOperation(String.valueOf(ysbklyl));
-            ls3.add(hv2);
-            sbklyl.put("data", ls3);
+            ls4.add(hv2);
+            sbklyl.put("data", ls4);
             allmap.put("sbklyl", sbklyl);
         }
-
-        Map<String, Object> lgxzkh = new HashMap<>();
-        String[] title = {"排名", "名称", "考核分数", "去年同期%", "涨跌%"};
-        List<ColumnVo> ls1 = getTitle(title);
-        List<HomeRightVo> ls2 = new ArrayList<>();
-        HomeRightVo hv = new HomeRightVo();
-        hv.setIndex("1");
-        hv.setName("惠安风场");
-        hv.setFnlyl("98");
-        hv.setYearTq("0");
-        hv.setOperation("100");
-        ls2.add(hv);
-
-        lgxzkh.put("column", ls1);
-        lgxzkh.put("data", ls2);
-        allmap.put("lgxzkh", lgxzkh);
-
         return allmap;
 
     }
@@ -1797,8 +1940,8 @@ public class EconomyPointHomePageService {
                 .filter(ls -> ls.getYear().equals(String.valueOf(year)) && ls.getProjectId().equals(companyId) && ls.getMonth() == null)
                 .collect(Collectors.toList());
         pd.setNfdljh(pp2.get(0).getGeneratingCapacity());
-        pd.setNfdlsj(days1.get(0).getNfdl().doubleValue()/1000);
-        Double njd = calDivide(pd.getNfdlsj()/1000, pd.getNfdljh());
+        pd.setNfdlsj(days1.get(0).getNfdl().doubleValue() / 1000);
+        Double njd = calDivide(pd.getNfdlsj() / 1000, pd.getNfdljh());
         pd.setNjd(njd * 100);
         pd.setNwcl(njd);
         allmap.put("planData", pd);
@@ -1960,108 +2103,270 @@ public class EconomyPointHomePageService {
     }
 
 
+//    public Map<String, Object> getGeneratingCapacity(String companyId) {
+//        Map<String, Object> allmap = new HashMap<>();
+//        List<GeneratingCapacityVo> ls = new ArrayList<>();
+//        LocalDate now = LocalDate.now();
+//        LocalDate tomorrow = LocalDate.now().plusDays(1);
+//        QueryWrapper<StationInfoMin> qw = new QueryWrapper<>();
+//        qw.lambda().between(StationInfoMin::getRecordDate, now,tomorrow)
+//                .eq(StationInfoMin::getStationId, companyId)
+//                .orderByDesc(StationInfoMin::getRecordDate);
+//        List<StationInfoMin> day1s = iStationInfoMinService.list(qw);
+//        StationInfoMin day1 = day1s.get(0);
+//        GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
+//            rfdl.setName("日发电量");
+////            rfdl.setValue(day1.getRfdl());
+////            rfdl.setTotal(day1.getRllfdl());
+////            Double rbfb = (day1.getRfdl()== 0 || day1.getRllfdl() == 0)
+////                    ? 0.0
+////                    : calDivide(day1.getRllfdl(), day1.getRfdl());
+////            rfdl.setBfb(rbfb);
+//            ls.add(rfdl);
+//
+//            GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
+//            yfdl.setName("月发电量");
+////            yfdl.setValue(day1.getYfdl());
+////            yfdl.setTotal(day1.getYllfdl());
+////            BigDecimal ybfb = (day1.getYfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getYllfdl().compareTo(BigDecimal.ZERO) == 0)
+////                    ? BigDecimal.ZERO
+////                    : day1.getYllfdl().divide(day1.getYfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+////            rfdl.setBfb(rbfb);
+////            yfdl.setBfb(ybfb);
+////            ls.add(yfdl);
+////
+////            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
+////            nfdl.setName("年发电量");
+////            nfdl.setValue(day1.getNfdl().divide(new BigDecimal(1000)));
+////            nfdl.setTotal(day1.getNllfdl().divide(new BigDecimal(1000)));
+////            BigDecimal nbfb = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
+////                    ? BigDecimal.ZERO
+////                    : day1.getNllfdl().divide(day1.getNfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+////            rfdl.setBfb(rbfb);
+////            nfdl.setBfb(nbfb);
+////            ls.add(nfdl);
+////
+////            Map<String, Object> zbtqdb = new HashMap<>();
+////            List<ColumnVo> ls1 = new ArrayList<>();
+////            ColumnVo cl1 = new ColumnVo();
+////            cl1.setName("指标名称");
+////            cl1.setField("wtId");
+////            ColumnVo cl2 = new ColumnVo();
+////            cl2.setName(String.valueOf(LocalDate.now().getYear()));
+////            cl2.setField("recodedate");
+////            ColumnVo cl3 = new ColumnVo();
+////            cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
+////            cl3.setField("recodedate2");
+////            ColumnVo cl4 = new ColumnVo();
+////            cl4.setName("涨跌%");
+////            cl4.setField("operation");
+////            ls1.add(cl1);
+////            ls1.add(cl2);
+////            ls1.add(cl3);
+////            ls1.add(cl4);
+////
+////            List<ComparetqVo> ls2 = new ArrayList<>();
+////            ComparetqVo cv = new ComparetqVo();
+////            cv.setWtId("发电量");
+////            cv.setRecodedate(String.valueOf(day1.getNfdl().divide(new BigDecimal(1000))));
+////            cv.setRecodedate2(String.valueOf(0));
+////            cv.setOperation("100");
+////            ComparetqVo cv1 = new ComparetqVo();
+////            cv1.setWtId("上网电量");
+////            cv1.setRecodedate(String.valueOf(0.00));
+////            cv1.setRecodedate2(String.valueOf(0));
+////            cv1.setOperation("0");
+////            ComparetqVo cv2 = new ComparetqVo();
+////            cv2.setWtId("网购电量");
+////            cv2.setRecodedate(String.valueOf(0.00));
+////            cv2.setRecodedate2(String.valueOf(0));
+////            cv2.setOperation("0");
+////            ComparetqVo cv3 = new ComparetqVo();
+////            cv3.setWtId("损失电量");
+////            cv3.setRecodedate(String.valueOf(0.00));
+////            cv3.setRecodedate2(String.valueOf(0));
+////            cv3.setOperation("0");
+////            ComparetqVo cv4 = new ComparetqVo();
+////            cv4.setWtId("场用电量");
+////            cv4.setRecodedate(String.valueOf(0.00));
+////            cv4.setRecodedate2(String.valueOf(0));
+////            cv4.setOperation("0");
+////            ls2.add(cv);
+////            ls2.add(cv1);
+////            ls2.add(cv2);
+////            ls2.add(cv3);
+////            ls2.add(cv4);
+////
+////            zbtqdb.put("column", ls1);
+////            zbtqdb.put("data", ls2);
+////            allmap.put("fdl", ls);
+////            allmap.put("zbtqdb", zbtqdb);
+//
+//
+//        return allmap;
+//    }
+
+
     public Map<String, Object> getGeneratingCapacity(String companyId) {
         Map<String, Object> allmap = new HashMap<>();
-        List<GeneratingCapacityVo> ls = new ArrayList<>();
-        LocalDate now = LocalDate.now();
-        LocalDate tomorrow = LocalDate.now().plusDays(1);
         QueryWrapper<StationInfoMin> qw = new QueryWrapper<>();
-        qw.lambda().between(StationInfoMin::getRecordDate, now,tomorrow)
-                .eq(StationInfoMin::getStationId, companyId)
-                .orderByDesc(StationInfoMin::getRecordDate);
+        qw.lambda().ge(StationInfoMin::getRecordDate, LocalDateTime.now().toLocalDate().atStartOfDay())
+                .le(StationInfoMin::getRecordDate, LocalDateTime.now())
+                .orderByDesc(StationInfoMin::getRecordDate)
+                .last("LIMIT 1")
+                .eq(StationInfoMin::getStationId, companyId);
+
+        QueryWrapper<StationInfoMin> qw2 = new QueryWrapper<>();
+        qw2.lambda().ge(StationInfoMin::getRecordDate, LocalDateTime.now().minusYears(1).toLocalDate().atStartOfDay())
+                .le(StationInfoMin::getRecordDate, LocalDateTime.now().minusYears(1).toLocalDate())
+                .orderByDesc(StationInfoMin::getRecordDate)
+                .last("LIMIT 1")
+                .eq(StationInfoMin::getStationId, companyId);
+
+        Map<String, Object> zbtqdb = new HashMap<>();
+        List<ColumnVo> ls1 = new ArrayList<>();
+        ColumnVo cl1 = new ColumnVo();
+        cl1.setName("指标名称");
+        cl1.setField("wtId");
+        ColumnVo cl2 = new ColumnVo();
+        cl2.setName(String.valueOf(LocalDate.now().getYear()));
+        cl2.setField("recodedate");
+        ColumnVo cl3 = new ColumnVo();
+        cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
+        cl3.setField("recodedate2");
+        ColumnVo cl4 = new ColumnVo();
+        cl4.setName("涨跌%");
+        cl4.setField("operation");
+        ls1.add(cl1);
+        ls1.add(cl2);
+        ls1.add(cl3);
+        ls1.add(cl4);
+
         List<StationInfoMin> day1s = iStationInfoMinService.list(qw);
-        StationInfoMin day1 = day1s.get(0);
-        GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
+        List<GeneratingCapacityVo> ls = new ArrayList<>();
+        if (null == day1s || day1s.isEmpty()) {
+            GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
             rfdl.setName("日发电量");
-//            rfdl.setValue(day1.getRfdl());
-//            rfdl.setTotal(day1.getRllfdl());
-//            Double rbfb = (day1.getRfdl()== 0 || day1.getRllfdl() == 0)
-//                    ? 0.0
-//                    : calDivide(day1.getRllfdl(), day1.getRfdl());
-//            rfdl.setBfb(rbfb);
+            rfdl.setValue(0.0);
+            rfdl.setTotal(0.0);
+            rfdl.setBfb(0.0);
             ls.add(rfdl);
-
+            generatingCapacity15min.put(rfdl.getName(), rfdl);
             GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
             yfdl.setName("月发电量");
-//            yfdl.setValue(day1.getYfdl());
-//            yfdl.setTotal(day1.getYllfdl());
-//            BigDecimal ybfb = (day1.getYfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getYllfdl().compareTo(BigDecimal.ZERO) == 0)
-//                    ? BigDecimal.ZERO
-//                    : day1.getYllfdl().divide(day1.getYfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-//            rfdl.setBfb(rbfb);
-//            yfdl.setBfb(ybfb);
-//            ls.add(yfdl);
-//
-//            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
-//            nfdl.setName("年发电量");
-//            nfdl.setValue(day1.getNfdl().divide(new BigDecimal(1000)));
-//            nfdl.setTotal(day1.getNllfdl().divide(new BigDecimal(1000)));
-//            BigDecimal nbfb = (day1.getNfdl().compareTo(BigDecimal.ZERO) == 0 || day1.getNllfdl().compareTo(BigDecimal.ZERO) == 0)
-//                    ? BigDecimal.ZERO
-//                    : day1.getNllfdl().divide(day1.getNfdl(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
-//            rfdl.setBfb(rbfb);
-//            nfdl.setBfb(nbfb);
-//            ls.add(nfdl);
-//
-//            Map<String, Object> zbtqdb = new HashMap<>();
-//            List<ColumnVo> ls1 = new ArrayList<>();
-//            ColumnVo cl1 = new ColumnVo();
-//            cl1.setName("指标名称");
-//            cl1.setField("wtId");
-//            ColumnVo cl2 = new ColumnVo();
-//            cl2.setName(String.valueOf(LocalDate.now().getYear()));
-//            cl2.setField("recodedate");
-//            ColumnVo cl3 = new ColumnVo();
-//            cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
-//            cl3.setField("recodedate2");
-//            ColumnVo cl4 = new ColumnVo();
-//            cl4.setName("涨跌%");
-//            cl4.setField("operation");
-//            ls1.add(cl1);
-//            ls1.add(cl2);
-//            ls1.add(cl3);
-//            ls1.add(cl4);
-//
-//            List<ComparetqVo> ls2 = new ArrayList<>();
-//            ComparetqVo cv = new ComparetqVo();
-//            cv.setWtId("发电量");
-//            cv.setRecodedate(String.valueOf(day1.getNfdl().divide(new BigDecimal(1000))));
-//            cv.setRecodedate2(String.valueOf(0));
-//            cv.setOperation("100");
-//            ComparetqVo cv1 = new ComparetqVo();
-//            cv1.setWtId("上网电量");
-//            cv1.setRecodedate(String.valueOf(0.00));
-//            cv1.setRecodedate2(String.valueOf(0));
-//            cv1.setOperation("0");
-//            ComparetqVo cv2 = new ComparetqVo();
-//            cv2.setWtId("网购电量");
-//            cv2.setRecodedate(String.valueOf(0.00));
-//            cv2.setRecodedate2(String.valueOf(0));
-//            cv2.setOperation("0");
-//            ComparetqVo cv3 = new ComparetqVo();
-//            cv3.setWtId("损失电量");
-//            cv3.setRecodedate(String.valueOf(0.00));
-//            cv3.setRecodedate2(String.valueOf(0));
-//            cv3.setOperation("0");
-//            ComparetqVo cv4 = new ComparetqVo();
-//            cv4.setWtId("场用电量");
-//            cv4.setRecodedate(String.valueOf(0.00));
-//            cv4.setRecodedate2(String.valueOf(0));
-//            cv4.setOperation("0");
-//            ls2.add(cv);
-//            ls2.add(cv1);
-//            ls2.add(cv2);
-//            ls2.add(cv3);
-//            ls2.add(cv4);
-//
-//            zbtqdb.put("column", ls1);
-//            zbtqdb.put("data", ls2);
-//            allmap.put("fdl", ls);
-//            allmap.put("zbtqdb", zbtqdb);
+            yfdl.setValue(0.0);
+            yfdl.setTotal(0.0);
+            yfdl.setBfb(0.0);
+            ls.add(yfdl);
+            generatingCapacity15min.put(yfdl.getName(), yfdl);
+            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
+            nfdl.setName("年发电量");
+            nfdl.setValue(0.0);
+            nfdl.setTotal(0.0);
+            nfdl.setBfb(0.0);
+            ls.add(nfdl);
+            generatingCapacity15min.put(nfdl.getName(), nfdl);
+        } else {
+            StationInfoMin day1 = day1s.get(0);
+            GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
+            rfdl.setName("日发电量");
+            rfdl.setValue(day1.getRfdl());
+            Double llgl = day1.getLlgl();
+            rfdl.setTotal(calDivide(llgl, 4.0));
+            Double rbfb = calDivide(rfdl.getValue(), rfdl.getTotal());
+            rfdl.setBfb(rbfb * 100);
+            ls.add(rfdl);
+            generatingCapacity15min.put(rfdl.getName(), rfdl);
+            GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
+            yfdl.setName("月发电量");
+            yfdl.setValue(CacheContext.yfdl.add(new BigDecimal(rfdl.getValue())).doubleValue());
+            yfdl.setTotal(calDivide(CacheContext.yllfdl.add(new BigDecimal(rfdl.getTotal())).doubleValue(), 4.0));
+            Double ybfb = calDivide(yfdl.getValue(), yfdl.getTotal());
+            yfdl.setBfb(ybfb * 100);
+            ls.add(yfdl);
+            generatingCapacity15min.put(yfdl.getName(), yfdl);
+            GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
+            nfdl.setName("年发电量");
+            nfdl.setValue(CacheContext.nfdl.add(new BigDecimal(yfdl.getValue())).doubleValue());
+            nfdl.setTotal(calDivide(CacheContext.nllfdl.add(new BigDecimal(yfdl.getTotal())).doubleValue(), 4.0));
+            Double nbfb = calDivide(nfdl.getValue(), nfdl.getTotal());
+            nfdl.setBfb(nbfb * 100);
+            ls.add(nfdl);
+            generatingCapacity15min.put(nfdl.getName(), nfdl);
+        }
+        List<StationInfoMin> day2s = iStationInfoMinService.list(qw2);
+        QueryWrapper<StationInfoDay> thisYear = new QueryWrapper<>();
+        thisYear.select("station_id,max(record_date) as record_date,sum(swdl) as swdl,sum(gwdl) as gwdl,sum(cydl) as cydl,sum(zhcydl) as zhcydl")
+                .apply("to_char(record_date,'yyyy') = '" + (LocalDate.now().getYear()) + "'")
+                .groupBy("station_id");
+        List<StationInfoDay> list = iStationInfoDayService.list(thisYear);
+
+        QueryWrapper<StationInfoDay> lastYear = new QueryWrapper<>();
+        lastYear.select("station_id,max(record_date) as record_date,sum(swdl) as swdl,sum(gwdl) as gwdl,sum(cydl) as cydl,sum(zhcydl) as zhcydl")
+                .apply("record_date<= '" + LocalDate.now().minusYears(1) + "'")
+                .groupBy("station_id");
+        List<StationInfoDay> list2 = iStationInfoDayService.list(lastYear);
+
+        List<ComparetqVo> ls2 = new ArrayList<>();
+        ComparetqVo cv = new ComparetqVo();
+        cv.setWtId("发电量");
+        ComparetqVo cv1 = new ComparetqVo();
+        cv1.setWtId("上网电量");
+        ComparetqVo cv2 = new ComparetqVo();
+        cv2.setWtId("购网电量");
+        ComparetqVo cv4 = new ComparetqVo();
+        cv4.setWtId("厂用电量");
+        cv.setRecodedate(generatingCapacity15min.get("年发电量").getValue());
+
+        if (null == day2s || day2s.isEmpty()) {
+            cv.setRecodedate2(0);
+            cv.setOperation(100);
+        } else {
+            cv.setRecodedate2(day2s.get(0).getRfdl());
+            cv.setOperation(calDivide(cv.getRecodedate() - cv.getRecodedate2(), cv.getRecodedate2()));
+        }
 
+        if (null == list2 || list2.isEmpty()) {
+            cv1.setRecodedate2(0);
+            cv1.setOperation(100);
+            cv2.setRecodedate2(0);
+            cv2.setOperation(100);
+            cv4.setRecodedate2(0);
+            cv4.setOperation(100);
+        } else {
+            cv1.setRecodedate2(list2.get(0).getSwdl());
+            cv2.setRecodedate2(list2.get(0).getGwdl());
+            cv4.setRecodedate2(list2.get(0).getCydl());
+        }
+
+        if (null == list || list.isEmpty()) {
+            cv1.setRecodedate(0);
+            cv1.setOperation(-100);
+            cv2.setRecodedate(0);
+            cv2.setOperation(-100);
+            cv4.setRecodedate(0);
+            cv4.setOperation(-100);
+        } else {
+            cv1.setRecodedate(list.get(0).getSwdl());
+            cv1.setOperation(100);
+            cv2.setRecodedate(list.get(0).getGwdl());
+            cv2.setOperation(100);
+            cv4.setRecodedate(list.get(0).getCydl());
+            cv4.setOperation(100);
+        }
+
+        ls2.add(cv);
+        ls2.add(cv1);
+        ls2.add(cv2);
+        ls2.add(cv4);
+
+        zbtqdb.put("column", ls1);
+        zbtqdb.put("data", ls2);
+
+        allmap.put("fdl", ls);
+        allmap.put("zbtqdb", zbtqdb);
 
         return allmap;
     }
 
-
 }