|
@ -1,12 +1,20 @@ |
|
|
package com.lzbi.bi.service; |
|
|
package com.lzbi.bi.service; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import com.lzbi.bi.domain.*; |
|
|
import com.lzbi.bi.domain.*; |
|
|
import com.lzbi.common.config.TargetModelConfig; |
|
|
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.common.utils.bean.BeanUtils; |
|
|
import com.lzbi.draft.domain.DcBusiTargetDraftDay; |
|
|
import com.lzbi.draft.domain.DcBusiTargetDraftDay; |
|
|
import com.lzbi.draft.domain.DcBusiTargetDraftMonth; |
|
|
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.DcBusiTargetDraftDayMapper; |
|
|
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; |
|
|
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.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -15,10 +23,14 @@ import org.springframework.stereotype.Service; |
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
import java.util.stream.Collectors; |
|
|
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 |
|
|
@Resource |
|
|
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper; |
|
|
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper; |
|
|
|
|
|
|
|
|
public List<UserIOverViewVO> getUserOverview(DcBusDataScreenNewReq dcBusDataScreenNewReq) { |
|
|
@Resource |
|
|
|
|
|
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private ISysDeptService iSysDeptService; |
|
|
|
|
|
|
|
|
|
|
|
public List<UserIOverViewVO> getUserOverview(TargetDraftDaynewReqVo vo) { |
|
|
List<UserIOverViewVO> list = new ArrayList<>(); |
|
|
List<UserIOverViewVO> list = new ArrayList<>(); |
|
|
DcBusiTargetDraftDay params = new DcBusiTargetDraftDay(); |
|
|
List<String> reportNames = Stream.of(ReportNameEnum.OPENING_AREA.getName(), ReportNameEnum.HEATING_AREA.getName()).collect(Collectors.toList()); |
|
|
BeanUtils.copyBeanProp(params, dcBusDataScreenNewReq); |
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(Stream.of(vo.getOrgId()).collect(Collectors.toList())); |
|
|
String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
String[] yearMonthDayArr = yearMonthDay.split("-"); |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
if (yearMonthDayArr.length > 1) { |
|
|
return list; |
|
|
params.setCountYear(yearMonthDayArr[0]); |
|
|
|
|
|
params.setCountMonth(yearMonthDayArr[1]); |
|
|
|
|
|
} |
|
|
|
|
|
params.setTargetModelCode(targetModelConfig.getUser()); |
|
|
|
|
|
List<DcBusiTargetDraftDay> dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper.selectDcBusiTargetDraftDayList(params); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(dcBusiTargetDraftDayList)) { |
|
|
|
|
|
Map<Object, List<DcBusiTargetDraftDay>> 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.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; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ProvideAnswerWaterAverageTemperatureVO getProvideAnswerWaterAverageTemperature(DcBusDataScreenNewReq dcBusDataScreenNewReq) { |
|
|
public ProvideAnswerWaterAverageTemperatureVO getProvideAnswerWaterAverageTemperature(TargetDraftDaynewReqVo vo) { |
|
|
ProvideAnswerWaterAverageTemperatureVO provideAnswerWaterAverageTemperatureVO = new ProvideAnswerWaterAverageTemperatureVO(); |
|
|
ProvideAnswerWaterAverageTemperatureVO resVO = new ProvideAnswerWaterAverageTemperatureVO(); |
|
|
ProvideAnswerWaterAverageTemperatureReq params = new ProvideAnswerWaterAverageTemperatureReq(); |
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.HEAT_SOURCE).build()); |
|
|
params.setCompanyId(dcBusDataScreenNewReq.getCompanyId()); |
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); |
|
|
return resVO; |
|
|
String[] yearMonthDayArr = yearMonthDay.split("-"); |
|
|
|
|
|
if (yearMonthDayArr.length > 1) { |
|
|
|
|
|
params.setYear(yearMonthDayArr[0]); |
|
|
|
|
|
params.setMonth(yearMonthDayArr[1]); |
|
|
|
|
|
} |
|
|
} |
|
|
params.setProvideWaterAverageTemperature(targetModelConfig.getProvideWaterAverageTemperature()); |
|
|
List<String> reportNames = Stream.of(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName(), ReportNameEnum.RETURN_WATER_TEMPERATURE.getName()).collect(Collectors.toList()); |
|
|
params.setAnswerWaterAverageTemperature(targetModelConfig.getAnswerWaterAverageTemperature()); |
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
List<ProvideAnswerWaterAverageTemperatureDTO> provideAnswerWaterAverageTemperatureDTOS = dcBusiTargetDraftDayMapper.selectProvideAnswerWaterAverageTemperatureList(params); |
|
|
vo.setAssetType("0").setAssetLevel("20").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
if (CollectionUtils.isNotEmpty(provideAnswerWaterAverageTemperatureDTOS)) { |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
List<String> xArr = new ArrayList<>(); |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
List<BigDecimal> yArr1 = new ArrayList<>(); |
|
|
return resVO; |
|
|
List<BigDecimal> 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); |
|
|
|
|
|
} |
|
|
} |
|
|
return provideAnswerWaterAverageTemperatureVO; |
|
|
List<String> xArr = new ArrayList<>(); |
|
|
|
|
|
List<BigDecimal> yArr1 = new ArrayList<>(); |
|
|
|
|
|
List<BigDecimal> 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<BoilerStatisticsVO> getBoilerStatistics(DcBusDataScreenNewReq dcBusDataScreenNewReq) { |
|
|
public List<BoilerStatisticsVO> getBoilerStatistics(TargetDraftDaynewReqVo vo) { |
|
|
List<BoilerStatisticsVO> list = new ArrayList<>(); |
|
|
List<BoilerStatisticsVO> list = new ArrayList<>(); |
|
|
DcBusiTargetDraftMonth params = new DcBusiTargetDraftMonth(); |
|
|
List<String> reportNames = Stream.of(ReportNameEnum.WATER_SUPPLY_TEMPERATURE.getName(), ReportNameEnum.RETURN_WATER_TEMPERATURE.getName()).collect(Collectors.toList()); |
|
|
BeanUtils.copyBeanProp(params, dcBusDataScreenNewReq); |
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(Stream.of(vo.getOrgId()).collect(Collectors.toList())); |
|
|
String yearMonthDay = dcBusDataScreenNewReq.getYearMonthDay(); |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
String[] yearMonthDayArr = yearMonthDay.split("-"); |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
if (yearMonthDayArr.length > 1) { |
|
|
return list; |
|
|
params.setCountYear(yearMonthDayArr[0]); |
|
|
|
|
|
params.setCountMonth(yearMonthDayArr[1]); |
|
|
|
|
|
} |
|
|
|
|
|
params.setTargetModelCode(targetModelConfig.getBoiler()); |
|
|
|
|
|
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonths = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(params); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(dcBusiTargetDraftMonths)) { |
|
|
|
|
|
Map<Object, List<DcBusiTargetDraftMonth>> 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.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; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|