From ebc35b881089c3ec706304e75f394eea3e98742a Mon Sep 17 00:00:00 2001 From: eric777 Date: Wed, 31 Jan 2024 17:20:17 +0800 Subject: [PATCH] =?UTF-8?q?jiahan.wu[CR]=20bi=E5=A4=A7=E5=B1=8F=E5=85=AC?= =?UTF-8?q?=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lzbi/common/enums/ReportNameEnum.java | 6 +- .../DcBusiDataScreenNewController.java | 26 ++- .../lzbi/bi/domain/BoilerStatisticsVO.java | 4 + .../service/DcBusiDataScreenNewService.java | 158 ++++++++---------- 4 files changed, 86 insertions(+), 108 deletions(-) diff --git a/lzbi-common/src/main/java/com/lzbi/common/enums/ReportNameEnum.java b/lzbi-common/src/main/java/com/lzbi/common/enums/ReportNameEnum.java index 713f967..ac30e23 100644 --- a/lzbi-common/src/main/java/com/lzbi/common/enums/ReportNameEnum.java +++ b/lzbi-common/src/main/java/com/lzbi/common/enums/ReportNameEnum.java @@ -20,7 +20,11 @@ public enum ReportNameEnum SECOND_NETWORK_WATER_CONSUMPTION_RATE("二次网耗水率"), PRIMARY_NET_RECHARGE_WATER("一次网补水量"), DATANG_PRIMARY_NET_RECHARGE_WATER("从大唐补一次网水量"), - POWER_CONSUMPTION_RATE_OF_HEAT_SOURCE_PLANT("热源厂电耗率"); + POWER_CONSUMPTION_RATE_OF_HEAT_SOURCE_PLANT("热源厂电耗率"), + WATER_SUPPLY_TEMPERATURE("供水温度"), + RETURN_WATER_TEMPERATURE("回水温度"), + NUMBER_OF_STEAM_FURNACES_IN_OPERATION("汽炉运行台数"), + NUMBER_OF_WATER_FURNACES_IN_OPERATION("水炉运行台数"); private final String name; diff --git a/lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java b/lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java index 73d947e..fed0158 100644 --- a/lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java +++ b/lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java @@ -4,11 +4,10 @@ import com.lzbi.bi.domain.DcBusDataScreenNewReq; import com.lzbi.bi.service.DcBusiDataScreenNewService; import com.lzbi.common.core.controller.BaseController; import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * 大屏控制器 @@ -24,33 +23,30 @@ public class DcBusiDataScreenNewController extends BaseController { /** * 用户总览 - * @param dcBusDataScreenNewReq * @return */ - @GetMapping("/userOverview") - public AjaxResult userOverview (@Validated DcBusDataScreenNewReq dcBusDataScreenNewReq) { - return success(dcBusiDataScreenNewService.getUserOverview(dcBusDataScreenNewReq)); + @PostMapping("/userOverview") + public AjaxResult userOverview (@RequestBody TargetDraftDaynewReqVo vo) { + return success(dcBusiDataScreenNewService.getUserOverview(vo)); } /** * 供/回水均温 - * @param dcBusDataScreenNewReq * @return */ - @GetMapping("/provideAnswerWaterAverageTemperature") - public AjaxResult provideAnswerWaterAverageTemperature(@Validated DcBusDataScreenNewReq dcBusDataScreenNewReq) { - return success(dcBusiDataScreenNewService.getProvideAnswerWaterAverageTemperature(dcBusDataScreenNewReq)); + @PostMapping("/provideAnswerWaterAverageTemperature") + public AjaxResult provideAnswerWaterAverageTemperature(@RequestBody TargetDraftDaynewReqVo vo) { + return success(dcBusiDataScreenNewService.getProvideAnswerWaterAverageTemperature(vo)); } /** * 锅炉统计 - * @param dcBusDataScreenNewReq * @return */ - @GetMapping("/boilerStatistics") - public AjaxResult boilerStatistics(@Validated DcBusDataScreenNewReq dcBusDataScreenNewReq) { - return success(dcBusiDataScreenNewService.getBoilerStatistics(dcBusDataScreenNewReq)); + @PostMapping("/boilerStatistics") + public AjaxResult boilerStatistics(@RequestBody TargetDraftDaynewReqVo vo) { + return success(dcBusiDataScreenNewService.getBoilerStatistics(vo)); } /** diff --git a/lzbi-module/src/main/java/com/lzbi/bi/domain/BoilerStatisticsVO.java b/lzbi-module/src/main/java/com/lzbi/bi/domain/BoilerStatisticsVO.java index 761fb78..fd2b88e 100644 --- a/lzbi-module/src/main/java/com/lzbi/bi/domain/BoilerStatisticsVO.java +++ b/lzbi-module/src/main/java/com/lzbi/bi/domain/BoilerStatisticsVO.java @@ -1,8 +1,10 @@ package com.lzbi.bi.domain; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; import java.math.BigDecimal; @@ -10,8 +12,10 @@ import java.math.BigDecimal; * 锅炉统计结果 */ @Data +@Builder @NoArgsConstructor @AllArgsConstructor +@Accessors(chain = true) public class BoilerStatisticsVO { private String label; diff --git a/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java b/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java index 76659ea..5ef2304 100644 --- a/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java +++ b/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java @@ -1,12 +1,20 @@ package com.lzbi.bi.service; +import cn.hutool.core.collection.CollUtil; import com.lzbi.bi.domain.*; import com.lzbi.common.config.TargetModelConfig; +import com.lzbi.common.constant.BizConstants; +import com.lzbi.common.core.domain.entity.SysDept; +import com.lzbi.common.enums.ReportNameEnum; import com.lzbi.common.utils.bean.BeanUtils; import com.lzbi.draft.domain.DcBusiTargetDraftDay; import com.lzbi.draft.domain.DcBusiTargetDraftMonth; +import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; +import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; import com.lzbi.draft.mapper.DcBusiTargetDraftDayMapper; import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; +import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; +import com.lzbi.system.service.ISysDeptService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -15,10 +23,14 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.groupingBy; /** * 大屏业务 @@ -37,109 +49,71 @@ public class DcBusiDataScreenNewService { @Resource private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper; - public List getUserOverview(DcBusDataScreenNewReq dcBusDataScreenNewReq) { + @Resource + private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; + + @Resource + private ISysDeptService iSysDeptService; + + public List getUserOverview(TargetDraftDaynewReqVo vo) { List list = new ArrayList<>(); - DcBusiTargetDraftDay params = new DcBusiTargetDraftDay(); - BeanUtils.copyBeanProp(params, dcBusDataScreenNewReq); - String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); - String[] yearMonthDayArr = yearMonthDay.split("-"); - if (yearMonthDayArr.length > 1) { - params.setCountYear(yearMonthDayArr[0]); - params.setCountMonth(yearMonthDayArr[1]); - } - params.setTargetModelCode(targetModelConfig.getUser()); - List dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper.selectDcBusiTargetDraftDayList(params); - if (CollectionUtils.isNotEmpty(dcBusiTargetDraftDayList)) { - Map> map; - if (ObjectUtils.isEmpty(dcBusDataScreenNewReq.getOrgId())) { - map = dcBusiTargetDraftDayList.stream().collect(Collectors.groupingBy(DcBusiTargetDraftDay::getOrgId)); - } else { - map = dcBusiTargetDraftDayList.stream().collect(Collectors.groupingBy(DcBusiTargetDraftDay::getAssetCode)); - } - map.forEach((key, value) -> { - UserIOverViewVO userIOverViewVO = new UserIOverViewVO(); - if (ObjectUtils.isEmpty(dcBusDataScreenNewReq.getOrgId())) { - userIOverViewVO.setTitle(value.get(0).getOrgName()); - } else { - userIOverViewVO.setTitle(value.get(0).getAssetName()); - } - BigDecimal plan = new BigDecimal(0); - BigDecimal sum = new BigDecimal(0); - for (int i = 0, len = value.size(); i < len; i++) { - plan = plan.add(value.get(i).getValPlan()); - sum = sum.add(value.get(i).getValSum()); - } - userIOverViewVO.setTotal(plan); - userIOverViewVO.setReal(sum); - list.add(userIOverViewVO); - }); + List reportNames = Stream.of(ReportNameEnum.OPENING_AREA.getName(), ReportNameEnum.HEATING_AREA.getName()).collect(Collectors.toList()); + vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(Stream.of(vo.getOrgId()).collect(Collectors.toList())); + List targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); + if (CollUtil.isEmpty(targetDraftDaynewResVos)) { + return list; } + list.add(UserIOverViewVO.builder() + .real(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.OPENING_AREA.getName().equals(t.getReportName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()) + .total(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.HEATING_AREA.getName().equals(t.getReportName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()) + .title("供暖面积") + .build()); return list; } - public ProvideAnswerWaterAverageTemperatureVO getProvideAnswerWaterAverageTemperature(DcBusDataScreenNewReq dcBusDataScreenNewReq) { - ProvideAnswerWaterAverageTemperatureVO provideAnswerWaterAverageTemperatureVO = new ProvideAnswerWaterAverageTemperatureVO(); - ProvideAnswerWaterAverageTemperatureReq params = new ProvideAnswerWaterAverageTemperatureReq(); - params.setCompanyId(dcBusDataScreenNewReq.getCompanyId()); - String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); - String[] yearMonthDayArr = yearMonthDay.split("-"); - if (yearMonthDayArr.length > 1) { - params.setYear(yearMonthDayArr[0]); - params.setMonth(yearMonthDayArr[1]); + public ProvideAnswerWaterAverageTemperatureVO getProvideAnswerWaterAverageTemperature(TargetDraftDaynewReqVo vo) { + ProvideAnswerWaterAverageTemperatureVO resVO = new ProvideAnswerWaterAverageTemperatureVO(); + List sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.HEAT_SOURCE).build()); + if (CollUtil.isEmpty(sysDepts)) { + return resVO; } - params.setProvideWaterAverageTemperature(targetModelConfig.getProvideWaterAverageTemperature()); - params.setAnswerWaterAverageTemperature(targetModelConfig.getAnswerWaterAverageTemperature()); - List provideAnswerWaterAverageTemperatureDTOS = dcBusiTargetDraftDayMapper.selectProvideAnswerWaterAverageTemperatureList(params); - if (CollectionUtils.isNotEmpty(provideAnswerWaterAverageTemperatureDTOS)) { - List xArr = new ArrayList<>(); - List yArr1 = new ArrayList<>(); - List yArr2 = new ArrayList<>(); - provideAnswerWaterAverageTemperatureDTOS.forEach(value -> { - xArr.add(value.getTitle()); - yArr1.add(value.getProvideWaterAverageTemperature()); - yArr2.add(value.getAnswerWaterAverageTemperature()); - }); - provideAnswerWaterAverageTemperatureVO.setXArr(xArr); - provideAnswerWaterAverageTemperatureVO.setYArr1(yArr1); - provideAnswerWaterAverageTemperatureVO.setYArr2(yArr2); + List reportNames = Stream.of(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName(), ReportNameEnum.RETURN_WATER_TEMPERATURE.getName()).collect(Collectors.toList()); + List orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); + vo.setAssetType("0").setAssetLevel("20").setReportNames(reportNames).setOrgIds(orgIds); + List targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); + if (CollUtil.isEmpty(targetDraftDaynewResVos)) { + return resVO; } - return provideAnswerWaterAverageTemperatureVO; + List xArr = new ArrayList<>(); + List yArr1 = new ArrayList<>(); + List yArr2 = new ArrayList<>(); + targetDraftDaynewResVos.stream().collect(groupingBy(TargetDraftDaynewResVo::getOrganizeName)).entrySet().forEach(entry->{ + xArr.add(entry.getKey()); + yArr1.add(entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); + yArr2.add(entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.RETURN_WATER_TEMPERATURE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); + }); + resVO.setXArr(xArr); + resVO.setYArr1(yArr1); + resVO.setYArr2(yArr2); + return resVO; } - public List getBoilerStatistics(DcBusDataScreenNewReq dcBusDataScreenNewReq) { + public List getBoilerStatistics(TargetDraftDaynewReqVo vo) { List list = new ArrayList<>(); - DcBusiTargetDraftMonth params = new DcBusiTargetDraftMonth(); - BeanUtils.copyBeanProp(params, dcBusDataScreenNewReq); - String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); - String[] yearMonthDayArr = yearMonthDay.split("-"); - if (yearMonthDayArr.length > 1) { - params.setCountYear(yearMonthDayArr[0]); - params.setCountMonth(yearMonthDayArr[1]); - } - params.setTargetModelCode(targetModelConfig.getBoiler()); - List dcBusiTargetDraftMonths = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(params); - if (CollectionUtils.isNotEmpty(dcBusiTargetDraftMonths)) { - Map> map; - if (ObjectUtils.isEmpty(dcBusDataScreenNewReq.getOrgId())) { - map = dcBusiTargetDraftMonths.stream().collect(Collectors.groupingBy(DcBusiTargetDraftMonth::getOrgId)); - } else { - map = dcBusiTargetDraftMonths.stream().collect(Collectors.groupingBy(DcBusiTargetDraftMonth::getAssetCode)); - } - map.forEach((key, value) -> { - BoilerStatisticsVO boilerStatisticsVO = new BoilerStatisticsVO(); - if (ObjectUtils.isEmpty(dcBusDataScreenNewReq.getOrgId())) { - boilerStatisticsVO.setLabel(value.get(0).getOrgName()); - } else { - boilerStatisticsVO.setLabel(value.get(0).getAssetName()); - } - BigDecimal sum = new BigDecimal(0); - for (int i = 0, len = value.size(); i < len; i++) { - sum = sum.add(value.get(i).getValResult()); - } - boilerStatisticsVO.setValue(sum); - list.add(boilerStatisticsVO); - }); + List reportNames = Stream.of(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName(), ReportNameEnum.RETURN_WATER_TEMPERATURE.getName()).collect(Collectors.toList()); + vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(Stream.of(vo.getOrgId()).collect(Collectors.toList())); + List targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); + if (CollUtil.isEmpty(targetDraftDaynewResVos)) { + return list; } + list.add(BoilerStatisticsVO.builder() + .label(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName()) + .value(targetDraftDaynewResVos.stream().filter(x -> x.getReportName().equals(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()) + .build()); + list.add(BoilerStatisticsVO.builder() + .label(ReportNameEnum.RETURN_WATER_TEMPERATURE.getName()) + .value(targetDraftDaynewResVos.stream().filter(x -> x.getReportName().equals(ReportNameEnum.RETURN_WATER_TEMPERATURE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()) + .build()); return list; }