From f2127fdb16215c3b1c439b808aa80e019e9252f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Fri, 4 Aug 2023 09:56:12 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=B8=A4=E7=A5=A8?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=90=88=E6=A0=BC=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standardTicket/service/impl/StandardTicketInfoServiceImpl.java | 4 +++- .../hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index ab8a946..4da8447 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -729,7 +729,9 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl createDept = userClient.getDataScope(bladeUser.getUserId()); - + log.info("================================================================"); + log.info("获取权限Id =======================> ", createDept); + log.info("================================================================"); StandardTicketInfoDto standardTicketInfoDto = new StandardTicketInfoDto(); BeanUtils.copyProperties(ticketCountQueryVo, standardTicketInfoDto); LambdaQueryWrapper queryWrapper = this.getQueryWrapper(standardTicketInfoDto); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java index 1b94fa1..915a6ea 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java @@ -405,7 +405,8 @@ public class TicketCountServiceImpl extends BaseServiceImpl getStandardTicketCountList(List createDept, List items, String ticketType, String dateTime, BladeUser user) { + private List + getStandardTicketCountList(List createDept, List items, String ticketType, String dateTime, BladeUser user) { List ticketInfoEntities = standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType, dateTime); if (CollectionUtils.isEmpty(ticketInfoEntities)) { @@ -459,6 +460,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); + evaluateEntityLambdaQueryWrapper.groupBy(TicketInfoEvaluateEntity::getTicketId); List evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); ticketCount.setTicketProportionNum(evaluateEntities.size()); @@ -549,6 +551,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); + evaluateEntityLambdaQueryWrapper.groupBy(TicketInfoEvaluateEntity::getTicketId); List evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); ticketCount.setTicketProportionNum(evaluateEntities.size()); From 199366015c6fadd77dc8b95be3a5350259640258 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 7 Aug 2023 08:33:55 +0800 Subject: [PATCH 02/19] =?UTF-8?q?#=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/controller/HomeController.java | 2 +- .../service/impl/AreaMonthReportServiceImpl.java | 153 ++++++++++----------- 2 files changed, 74 insertions(+), 81 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java index d09afd5..feace1e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java @@ -32,7 +32,7 @@ public class HomeController extends BladeController { @ApiOperation("首页站点数量") @GetMapping("/count") @ApiOperationSupport(order = 1) - public R> count() { + public R> count() { return R.data(service.count()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 77f6308..4ff4e8e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -48,6 +48,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.util.CellRangeAddress; import org.jfree.data.category.DefaultCategoryDataset; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; @@ -81,6 +82,7 @@ import java.util.stream.Collectors; /** * 区域月报实现类 + * @author ysj */ @Service @RequiredArgsConstructor @@ -185,7 +187,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 设置头信息 response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); - ServletOutputStream outputStream = null; + ServletOutputStream outputStream; try { //设置xlsx格式 response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); @@ -217,10 +219,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return R.fail("该机构不包含水站信息"); } List deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList()); - if (deptList == null) { - return R.fail("该机构不包含水站信息"); - } - List deptByUser = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); + List deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList()); if (!deptByUser.contains(deptId)){ return R.fail("该用户不包含该机构权限,请申请权限再试"); } @@ -231,7 +230,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { Integer commissionTime = stationEntityList.stream().map(s -> { Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); return (int) dur.toDays();}).reduce(Integer::max).get(); - List stationIds = stationEntityList.stream().map(s -> s.getId()).collect(Collectors.toList()); + List stationIds = stationEntityList.stream().map(BaseEntity::getId).collect(Collectors.toList()); //其它普通数据 map.put("year", year); Integer yearBefore = year - 1; @@ -295,7 +294,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); map.put("capacityProportionChart", capacityProportionChart); //各发电站发电量环比图+表格数据组装 - List deptIdsString = deptIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList()); + List deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); List planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); List powerPercentageVoList = new ArrayList<>(); //水电站,光伏站和带代运维数据近三年数据 @@ -306,22 +305,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { String monStartYearBefore = TimeUtils.getMon(yearBefore, month); String monStartMonBefore = TimeUtils.getMon(year, monthBefore); for (Map.Entry> deviceMap : powerMapThree.entrySet()) { - String deptNameByKey = ""; + String deptNameByKey; if (stationIds.contains(deviceMap.getKey())) { MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); powerVo.setDeptId(deviceMap.getKey()); List collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList()); - if (collect!=null) { - Long dept = collect.get(0).getRefDept(); - List dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList()); - deptNameByKey=dep.get(0).getDeptName(); - } + Long dept = collect.get(0).getRefDept(); + List dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList()); + deptNameByKey=dep.get(0).getDeptName(); powerVo.setDeptName(deptNameByKey); - BigDecimal powerYear = new BigDecimal(0); - BigDecimal powerYearBefore = new BigDecimal(0); - BigDecimal powerMonth = new BigDecimal(0); - BigDecimal powerMonthBefore = new BigDecimal(0); - BigDecimal powerMonthYearBefore = new BigDecimal(0); + BigDecimal powerYear; + BigDecimal powerYearBefore; + BigDecimal powerMonth; + BigDecimal powerMonthBefore; + BigDecimal powerMonthYearBefore; Double planGeneration = 0d; List planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(planGenerationById)) { @@ -379,38 +376,34 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart(powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400); map.put("powerChainHistogram", powerChainHistogram); //柱状图下添加的表格 - if (powerPercentageVoList != null) { - ArrayList> powerMap = new ArrayList<>(powerPercentageVoList.size()); - for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { - HashMap power = new HashMap<>(); - power.put("name", monPowerPercentageVo.getDeptName()); - power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); - power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); - powerMap.add(power); - } - map.put("power", powerMap); + ArrayList> powerMap = new ArrayList<>(powerPercentageVoList.size()); + for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { + HashMap power = new HashMap<>(); + power.put("name", monPowerPercentageVo.getDeptName()); + power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); + power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); + powerMap.add(power); } + map.put("power", powerMap); //表格总计 - List planYearAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year.toString()); - List planMonAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year + "-" + month); + List planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString()); + List planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month); getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); //发电情况统计表数据 - if (powerPercentageVoList != null) { - ArrayList> list = new ArrayList<>(powerPercentageVoList.size()); - for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { - HashMap temp = new HashMap<>(8); - temp.put("name", monPowerPercentageVo.getDeptName()); - temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore())); - temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore())); - temp.put("mon", String.valueOf(monPowerPercentageVo.getPowerMon())); - temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); - temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); - temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); - temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); - list.add(temp); - } - map.put("powerGeneration", list); + ArrayList> list = new ArrayList<>(powerPercentageVoList.size()); + for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { + HashMap temp = new HashMap<>(8); + temp.put("name", monPowerPercentageVo.getDeptName()); + temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore())); + temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore())); + temp.put("mon", String.valueOf(monPowerPercentageVo.getPowerMon())); + temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); + temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); + temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); + temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); + list.add(temp); } + map.put("powerGeneration", list); //本月缺陷 @@ -422,9 +415,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds); List monPhenomenonList = operPhenomenonService.list(wrapper); monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList()); - List monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals("1")).collect(Collectors.toList()); + List monConclusionList = monPhenomenonList.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList()); // 只填写二类及以上缺陷 - List monConclusionListBy = monConclusionList.stream().filter(s -> !s.getDefectGrading().equals("1")).collect(Collectors.toList()); + List monConclusionListBy = monConclusionList.stream().filter(s -> !"1".equals(s.getDefectGrading())).collect(Collectors.toList()); // 各电站缺陷处理统计表 monConclusionListBy.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectGrading)); ArrayList> checkList = new ArrayList<>(); @@ -438,13 +431,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { HashMap temp = new HashMap<>(); temp.put("name", createDeptName.getData()); String checkLevel=""; - if(operPhenomenonEntity.getDefectGrading().equals("1")) { + if("1".equals(operPhenomenonEntity.getDefectGrading())) { checkLevel="Ⅰ级缺陷"; } - if(operPhenomenonEntity.getDefectGrading().equals("2") ){ + if("2".equals(operPhenomenonEntity.getDefectGrading()) ){ checkLevel="Ⅱ级缺陷"; } - if(operPhenomenonEntity.getDefectGrading().equals("3") ){ + if("3".equals(operPhenomenonEntity.getDefectGrading()) ){ checkLevel="Ⅲ级缺陷"; } temp.put("level", checkLevel); @@ -490,14 +483,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { for (Map.Entry>> deptMapEntry : phenomenonMap.entrySet()) { R deptName1 = sysClient.getDeptName(deptMapEntry.getKey()); for (Map.Entry> levelList : deptMapEntry.getValue().entrySet()) { - Integer findShortagesYear = levelList.getValue().size(); - Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); - Double shortagesRate = 0d; + int findShortagesYear = levelList.getValue().size(); + int shortagesYear = (int) yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); + double shortagesRate = 0d; if (findShortagesYear != 0 && shortagesYear != 0) { shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); } - Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); - Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); + Integer findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); + Integer shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); checkChartRes.add(checkChartVo); } @@ -505,14 +498,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 总计 Map> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)); for (Map.Entry> levelPhenomenon : levelPhenomenonList.entrySet()) { - Integer findShortagesYear = levelPhenomenon.getValue().size(); - Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); - Double shortagesRate = 0d; + int findShortagesYear = levelPhenomenon.getValue().size(); + int shortagesYear = (int) Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); + double shortagesRate = 0d; if (findShortagesYear != 0 && shortagesYear != 0) { shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); } - Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); - Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); + Integer findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); + Integer shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); checkChartRes.add(checkChartVo); } @@ -521,13 +514,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { HashMap temp = new HashMap<>(); temp.put("deptName", checkChartRe.getDeptName()); String checkLevel=null; - if(checkChartRe.getCheckLevel().equals("1")) { + if("1".equals(checkChartRe.getCheckLevel())) { checkLevel="Ⅰ级缺陷"; } - if(checkChartRe.getCheckLevel().equals("2")) { + if("2".equals(checkChartRe.getCheckLevel())) { checkLevel="Ⅱ级缺陷"; } - if(checkChartRe.getCheckLevel().equals("3")) { + if("3".equals(checkChartRe.getCheckLevel())) { checkLevel="Ⅲ级缺陷"; } temp.put("checkLevel", checkLevel); @@ -571,23 +564,23 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { .filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(yearTicketCollect)) { //年合格率和数量 - Integer count = yearTicketCollect.size(); + int count = yearTicketCollect.size(); ticketChartCell.setTicketYear(count); - List ticketIds = yearTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); + List ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { - Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); + double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketYeaPercr(ticketYearPerc); } } if (CollectionUtils.isNotEmpty(monthTicketCollect)) { //月合格率和数量 - Integer count = monthTicketCollect.size(); + int count = monthTicketCollect.size(); ticketChartCell.setTicketMon(count); - List monthTicketIds = monthTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); + List monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { - Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); + double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketMonPerc(ticketMonthPerc); } } @@ -601,23 +594,23 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { .filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(yearOperateCollect)) { //年合格率和数量 - Integer count = yearOperateCollect.size(); + int count = yearOperateCollect.size(); ticketChartCell.setTicketYear(count); - List ticketIds = yearOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); + List ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { - Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); + double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketYeaPercr(ticketYearPerc); } } if (CollectionUtils.isNotEmpty(monthOperateCollect)) { //月合格率和数量 - Integer count = monthOperateCollect.size(); + int count = monthOperateCollect.size(); ticketChartCell.setTicketMon(count); - List monthTicketIds = monthOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); + List monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { - Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); + double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketMonPerc(ticketMonthPerc); } } @@ -711,7 +704,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); if (CollectionUtil.isNotEmpty(analyseData)) { BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null) - .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) + .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal()))) .reduce(BigDecimal.ZERO, BigDecimal::add); powerYear = powerYear.add(yearPower); } @@ -719,7 +712,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) { BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null) - .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) + .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal()))) .reduce(BigDecimal.ZERO, BigDecimal::add); powerYearBefore = powerYearBefore.add(powerBefore); } @@ -727,7 +720,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); if (CollectionUtil.isNotEmpty(analyseDataMonth)) { BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null) - .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) + .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal()))) .reduce(BigDecimal.ZERO, BigDecimal::add); powerMonth = powerMonth.add(powerBefore); } @@ -735,7 +728,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) { BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null) - .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) + .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal()))) .reduce(BigDecimal.ZERO, BigDecimal::add); powerMonthBefore = powerMonthBefore.add(powerBefore); } @@ -743,7 +736,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) { BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null) - .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) + .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal()))) .reduce(BigDecimal.ZERO, BigDecimal::add); powerMonthYearBefore = powerMonthYearBefore.add(powerBefore); } From 088a573ab2602a702db4252bd108576517006dd4 Mon Sep 17 00:00:00 2001 From: tyty Date: Mon, 7 Aug 2023 09:14:00 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E6=B0=B4=E7=94=B5=E7=AB=99=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 67ec81b..cd09018 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -204,7 +204,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { @Override public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId) { R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); - if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()!=null){ + if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ return R.fail("用户权限查询失败"); } R deptNameR = sysClient.getDeptName(deptId); From 4de24541a82a19828c90b7a875ca295c97eed0ab Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 7 Aug 2023 09:40:33 +0800 Subject: [PATCH 04/19] =?UTF-8?q?#=E6=95=B0=E6=8D=AE=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../census/controller/TargetController.java | 28 +++++--- .../operational/census/service/TargetService.java | 8 +-- .../census/service/impl/TargetServiceImpl.java | 81 ++++++++++++++-------- 3 files changed, 75 insertions(+), 42 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java index d1ea07f..1b9e41a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java @@ -33,15 +33,21 @@ public class TargetController { @ApiOperation("装机容量统计:区分填报/接入站点") @PostMapping("/installed-capacity") @ApiOperationSupport(order = 1) - public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.installedCapacity(stationName,type)); + public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.installedCapacity(stationName,type,current,size)); } @ApiOperation("发电量统计:区分填报/接入站点") @PostMapping("/electric-generation") @ApiOperationSupport(order = 2) - public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.electricGeneration(stationName,type)); + public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.electricGeneration(stationName,type,current,size)); } @@ -49,8 +55,11 @@ public class TargetController { @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @PostMapping("/complete-generation") @ApiOperationSupport(order = 3) - public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeGeneration(stationName,type)); + public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeGeneration(stationName,type,current,size)); } @@ -58,8 +67,11 @@ public class TargetController { @ApiOperation("两票统计:区分填报/平台业务数据") @PostMapping("/complete-ticket") @ApiOperationSupport(order = 4) - public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeTicket(areaName,type)); + public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeTicket(areaName,type,current,size)); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java index 6009791..0ad73ef 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java @@ -19,16 +19,16 @@ import java.util.List; public interface TargetService { // 获取站点装机容量 - List installedCapacity(String stationName,Integer type); + List installedCapacity(String stationName,Integer type,Integer current,Integer size); // 发电量统计 - List electricGeneration(String stationName,Integer type); + List electricGeneration(String stationName,Integer type,Integer current,Integer size); // 计划发电量/实际发电量统计 - List completeGeneration(String stationName,Integer type); + List completeGeneration(String stationName,Integer type,Integer current,Integer size); // 两票统计 - List completeTicket(String areaName,Integer type); + List completeTicket(String areaName,Integer type,Integer current,Integer size); // 缺陷率统计 List defect(String areaName, Integer type); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index fd77958..12f67a2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -118,7 +118,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List installedCapacity(String stationName,Integer type) { + public List installedCapacity(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -148,7 +148,7 @@ public class TargetServiceImpl implements TargetService { List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList()); + }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -156,7 +156,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List electricGeneration(String stationName,Integer type) { + public List electricGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -191,7 +191,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); if(CollectionUtil.isEmpty(targets)){ @@ -213,7 +213,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } // 查询填报数据 @@ -234,7 +234,7 @@ public class TargetServiceImpl implements TargetService { } item.setDetail("站点为填报数据,暂无设备装机发电量信息!"); return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -242,7 +242,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeGeneration(String stationName,Integer type) { + public List completeGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -292,7 +292,8 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0) + .skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ // 计划发电量 String mon = DateUtil.format(new Date(),"yyyy"); @@ -335,7 +336,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } String mon = DateUtil.format(new Date(),"yyyy"); List powers = powerService.list(Wrappers.lambdaQuery() @@ -357,7 +358,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -365,10 +366,10 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeTicket(String areaName,Integer type) { + public List completeTicket(String areaName,Integer type,Integer current,Integer size) { // 光伏/风电双票填报数据 if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){ - return this.getcompleteFillTicket(areaName,type); + return this.getcompleteFillTicket(areaName,type,current,size); } // 平台业务数据 List types; @@ -390,22 +391,42 @@ public class TargetServiceImpl implements TargetService { CountDownLatch countDownLatch = new CountDownLatch(areas.size()); List completeTickets = new ArrayList<>(); exe.execute(()-> { - for (Dept dept: areas) { - // 双票 - DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); - CompleteTicketVo completeTicketVo = new CompleteTicketVo(); - if (ObjectUtil.isEmpty(doublePass)) { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount("0"); - completeTicketVo.setCompleteCount("0"); - completeTicketVo.setCompleteRate("0.0"); - } else { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); - completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); - completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + if(StringUtil.isEmpty(areaName)){ + for (Dept dept: areas.stream().filter(area->area.getDeptName().equals(areaName)).collect(Collectors.toList())) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); + } + }else{ + for (Dept dept: areas) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); } - completeTickets.add(completeTicketVo); countDownLatch.countDown(); } }); @@ -417,7 +438,7 @@ public class TargetServiceImpl implements TargetService { Thread.currentThread().interrupt(); } exe.shutdown(); - return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).collect(Collectors.toList()); + return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -451,7 +472,7 @@ public class TargetServiceImpl implements TargetService { * @param type * @return */ - private List getcompleteFillTicket(String stationName, Integer type) { + private List getcompleteFillTicket(String stationName, Integer type,Integer current,Integer size) { List stations = stationService.list(Wrappers.lambdaQuery() .eq(StationEntity::getType, type) .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) @@ -478,7 +499,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** From 2669e18f3b7baf3d40b5acdfc80d6b56a23affff Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 7 Aug 2023 09:45:17 +0800 Subject: [PATCH 05/19] =?UTF-8?q?#=E6=95=B0=E6=8D=AE=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../census/controller/TargetController.java | 28 +++++--- .../operational/census/service/TargetService.java | 8 +-- .../census/service/impl/TargetServiceImpl.java | 81 ++++++++++++++-------- 3 files changed, 75 insertions(+), 42 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java index d1ea07f..1b9e41a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java @@ -33,15 +33,21 @@ public class TargetController { @ApiOperation("装机容量统计:区分填报/接入站点") @PostMapping("/installed-capacity") @ApiOperationSupport(order = 1) - public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.installedCapacity(stationName,type)); + public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.installedCapacity(stationName,type,current,size)); } @ApiOperation("发电量统计:区分填报/接入站点") @PostMapping("/electric-generation") @ApiOperationSupport(order = 2) - public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.electricGeneration(stationName,type)); + public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.electricGeneration(stationName,type,current,size)); } @@ -49,8 +55,11 @@ public class TargetController { @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @PostMapping("/complete-generation") @ApiOperationSupport(order = 3) - public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeGeneration(stationName,type)); + public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeGeneration(stationName,type,current,size)); } @@ -58,8 +67,11 @@ public class TargetController { @ApiOperation("两票统计:区分填报/平台业务数据") @PostMapping("/complete-ticket") @ApiOperationSupport(order = 4) - public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeTicket(areaName,type)); + public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeTicket(areaName,type,current,size)); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java index 6009791..0ad73ef 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java @@ -19,16 +19,16 @@ import java.util.List; public interface TargetService { // 获取站点装机容量 - List installedCapacity(String stationName,Integer type); + List installedCapacity(String stationName,Integer type,Integer current,Integer size); // 发电量统计 - List electricGeneration(String stationName,Integer type); + List electricGeneration(String stationName,Integer type,Integer current,Integer size); // 计划发电量/实际发电量统计 - List completeGeneration(String stationName,Integer type); + List completeGeneration(String stationName,Integer type,Integer current,Integer size); // 两票统计 - List completeTicket(String areaName,Integer type); + List completeTicket(String areaName,Integer type,Integer current,Integer size); // 缺陷率统计 List defect(String areaName, Integer type); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index fd77958..12f67a2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -118,7 +118,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List installedCapacity(String stationName,Integer type) { + public List installedCapacity(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -148,7 +148,7 @@ public class TargetServiceImpl implements TargetService { List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList()); + }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -156,7 +156,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List electricGeneration(String stationName,Integer type) { + public List electricGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -191,7 +191,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); if(CollectionUtil.isEmpty(targets)){ @@ -213,7 +213,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } // 查询填报数据 @@ -234,7 +234,7 @@ public class TargetServiceImpl implements TargetService { } item.setDetail("站点为填报数据,暂无设备装机发电量信息!"); return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -242,7 +242,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeGeneration(String stationName,Integer type) { + public List completeGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -292,7 +292,8 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0) + .skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ // 计划发电量 String mon = DateUtil.format(new Date(),"yyyy"); @@ -335,7 +336,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } String mon = DateUtil.format(new Date(),"yyyy"); List powers = powerService.list(Wrappers.lambdaQuery() @@ -357,7 +358,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -365,10 +366,10 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeTicket(String areaName,Integer type) { + public List completeTicket(String areaName,Integer type,Integer current,Integer size) { // 光伏/风电双票填报数据 if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){ - return this.getcompleteFillTicket(areaName,type); + return this.getcompleteFillTicket(areaName,type,current,size); } // 平台业务数据 List types; @@ -390,22 +391,42 @@ public class TargetServiceImpl implements TargetService { CountDownLatch countDownLatch = new CountDownLatch(areas.size()); List completeTickets = new ArrayList<>(); exe.execute(()-> { - for (Dept dept: areas) { - // 双票 - DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); - CompleteTicketVo completeTicketVo = new CompleteTicketVo(); - if (ObjectUtil.isEmpty(doublePass)) { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount("0"); - completeTicketVo.setCompleteCount("0"); - completeTicketVo.setCompleteRate("0.0"); - } else { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); - completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); - completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + if(StringUtil.isEmpty(areaName)){ + for (Dept dept: areas.stream().filter(area->area.getDeptName().equals(areaName)).collect(Collectors.toList())) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); + } + }else{ + for (Dept dept: areas) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); } - completeTickets.add(completeTicketVo); countDownLatch.countDown(); } }); @@ -417,7 +438,7 @@ public class TargetServiceImpl implements TargetService { Thread.currentThread().interrupt(); } exe.shutdown(); - return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).collect(Collectors.toList()); + return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -451,7 +472,7 @@ public class TargetServiceImpl implements TargetService { * @param type * @return */ - private List getcompleteFillTicket(String stationName, Integer type) { + private List getcompleteFillTicket(String stationName, Integer type,Integer current,Integer size) { List stations = stationService.list(Wrappers.lambdaQuery() .eq(StationEntity::getType, type) .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) @@ -478,7 +499,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** From 223eb21b48a7130d67ff743537d0e2ae65f760a9 Mon Sep 17 00:00:00 2001 From: tanghaihao <850814414@qq.com> Date: Mon, 7 Aug 2023 10:49:13 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9C=BA=E7=BB=84=E6=9C=80=E5=A4=A7=E5=80=BC?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=88=A0=E9=99=A4=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml | 2 +- .../java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml index db7e24d..d7be978 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml @@ -117,7 +117,7 @@