|
|
@ -1,32 +1,26 @@ |
|
|
|
package com.lzbi.bi.service; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.ObjUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.service.IService; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.lzbi.bi.domain.DcBusiDataScreenDto; |
|
|
|
import com.lzbi.bi.domain.DcBusiDataScreenVo; |
|
|
|
import com.lzbi.bi.domain.SysDeptLocation; |
|
|
|
import com.lzbi.bi.mapper.DcBusiDataScreenMainMapper; |
|
|
|
import com.lzbi.common.constant.BizConstants; |
|
|
|
import com.lzbi.common.core.domain.entity.SysDept; |
|
|
|
import com.lzbi.common.enums.HeatingPeriodEnum; |
|
|
|
import com.lzbi.common.enums.ReportNameEnum; |
|
|
|
import com.lzbi.common.utils.StringUtils; |
|
|
|
import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo; |
|
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; |
|
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; |
|
|
|
import com.lzbi.draft.domain.dto.SomeOrgSomedayMultiReportDataDTO; |
|
|
|
import com.lzbi.draft.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO; |
|
|
|
import com.lzbi.draft.domain.req.ReportDataReq; |
|
|
|
import com.lzbi.draft.domain.vo.*; |
|
|
|
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; |
|
|
|
import com.lzbi.system.service.ISysDeptService; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -51,222 +45,194 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
@Resource |
|
|
|
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; |
|
|
|
|
|
|
|
public List<DcBusiDataScreenVo> selectCoalLostByDate(String qdate){ |
|
|
|
return baseMapper.selectCoalLostByDate(qdate); |
|
|
|
/** |
|
|
|
* 查询某个组织某天的某个图表数据 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq) { |
|
|
|
this.buildReportDataReq(reportDataReq); |
|
|
|
return baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectDatainTaget(String qdate){ |
|
|
|
return baseMapper.selectDataPowerLost(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectDataPowerLost(String qdate){ |
|
|
|
return baseMapper.selectDataPowerLost(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectDataWaterLostFirst(String qdate){ |
|
|
|
return baseMapper.selectDataWaterLostFirst(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectDataWaterLostSecond(String qdate){ |
|
|
|
return baseMapper.selectDataWaterLostSecond(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectDataWaterLostStationAll(String qdate){ |
|
|
|
return baseMapper.selectDataWaterLostStationAll(qdate); |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询下级组织某天的某个图表数据列表 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<ChildrenOrgSomedaySomeReportDataVO> selectChildrenOrgSomedaySomeReportDataList(ReportDataReq reportDataReq) { |
|
|
|
this.buildChildrenOrgReportDataReq(reportDataReq); |
|
|
|
return baseMapper.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
|
} |
|
|
|
public JSONObject selectPowerAll(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.TOTAL_GENERATING_CAPACITY.getName(), ReportNameEnum.TOTAL_ELECTRICITY_CONSUMPTION.getName()).collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("0").setReportNames(reportNames).setOrgIds(Stream.of(vo.getOrgId()).collect(Collectors.toList())); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
|
|
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchart(ReportDataReq reportDataReq) { |
|
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
|
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
JSONArray head = new JSONArray(); |
|
|
|
JSONArray body = new JSONArray(); |
|
|
|
data.forEach(item -> { |
|
|
|
head.add(item.getOrgName()); |
|
|
|
body.add(item.getValueResult()); |
|
|
|
}); |
|
|
|
result.add(head); |
|
|
|
result.add(body); |
|
|
|
} |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
targetDraftDaynewResVos.forEach(item->{ |
|
|
|
JSONObject jsb=new JSONObject(); |
|
|
|
jsb.put("name",item.getReportName()); |
|
|
|
jsb.put("value", item.getValueResult().toString()); |
|
|
|
jsb.put("unit",item.getTargetUnit()); |
|
|
|
list.add(jsb); |
|
|
|
}); |
|
|
|
ret.put("source",list); |
|
|
|
return ret; |
|
|
|
return result; |
|
|
|
} |
|
|
|
public JSONObject getSquareInfoCompany(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.OPENING_AREA.getName(), ReportNameEnum.HEATING_AREA.getName()).collect(Collectors.toList()); |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
JSONArray product=new JSONArray(); |
|
|
|
JSONArray realcost=new JSONArray(); |
|
|
|
JSONArray realcost_2=new JSONArray(); |
|
|
|
product.add("real_name"); |
|
|
|
realcost.add(ReportNameEnum.OPENING_AREA.getName()); |
|
|
|
realcost_2.add(ReportNameEnum.HEATING_AREA.getName()); |
|
|
|
targetDraftDaynewResVos.stream().collect(Collectors.toList()).sort(Comparator.comparing(TargetDraftDaynewResVo::getOrganizeName)); |
|
|
|
product.addAll(targetDraftDaynewResVos.stream().map(TargetDraftDaynewResVo::getOrganizeName).distinct().collect(Collectors.toList())); |
|
|
|
for (int i = 1; i < product.size(); i++) { |
|
|
|
int finalI = i; |
|
|
|
realcost.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.OPENING_AREA.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
realcost_2.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.HEATING_AREA.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
|
|
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartStacking(ReportDataReq reportDataReq) { |
|
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
|
JSONArray head = new JSONArray(); |
|
|
|
head.add("product"); |
|
|
|
head.add("实际"); |
|
|
|
head.add("指标"); |
|
|
|
result.add(head); |
|
|
|
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
data.forEach(item -> { |
|
|
|
JSONArray body = new JSONArray(); |
|
|
|
body.add(item.getOrgName()); |
|
|
|
body.add(item.getValueResult()); |
|
|
|
body.add(item.getValuePlan()); |
|
|
|
result.add(body); |
|
|
|
}); |
|
|
|
} |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
list.add(product); |
|
|
|
list.add(realcost); |
|
|
|
list.add(realcost_2); |
|
|
|
ret.put("source",list); |
|
|
|
ret.put("unit",targetDraftDaynewResVos.get(0).getTargetUnit()); |
|
|
|
ret.put("concatSquare",targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.OPENING_AREA.getName().equals(x.getReportName())).map(TargetDraftDaynewResVo::getValueResult).reduce(BigDecimal.ZERO,BigDecimal::add)); |
|
|
|
ret.put("realSquare",targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.HEATING_AREA.getName().equals(x.getReportName())).map(TargetDraftDaynewResVo::getValueResult).reduce(BigDecimal.ZERO,BigDecimal::add)); |
|
|
|
return ret; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getSquareInfoGroup(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return ret; |
|
|
|
/** |
|
|
|
* 查询某组织某天多图表数据列表 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<SomeOrgSomedayMultiReportDataVO> selectSomeOrgSomedayMultiReportDataList(ReportDataReq reportDataReq) { |
|
|
|
List<SomeOrgSomedayMultiReportDataDTO> someOrgSomedayMultiReportDataDTOS = this.selectSomeOrgSomedayMultiReportDataDTOList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(someOrgSomedayMultiReportDataDTOS)) { |
|
|
|
return JSONArray.parseArray(JSONArray.toJSONString(someOrgSomedayMultiReportDataDTOS), SomeOrgSomedayMultiReportDataVO.class); |
|
|
|
} |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.OPENING_AREA.getName(), ReportNameEnum.HEATING_AREA.getName()).collect(Collectors.toList()); |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
JSONArray inCircle=new JSONArray(); |
|
|
|
JSONArray outCircle=new JSONArray(); |
|
|
|
targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.OPENING_AREA.getName().equals(x.getReportName())).forEach(x->{ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("name", x.getOrganizeName()); |
|
|
|
jo.put("unit", x.getTargetUnit()); |
|
|
|
jo.put("value", x.getValueResult()); |
|
|
|
inCircle.add(jo); |
|
|
|
}); |
|
|
|
targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.HEATING_AREA.getName().equals(x.getReportName())).forEach(x->{ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("name", x.getOrganizeName()); |
|
|
|
jo.put("unit", x.getTargetUnit()); |
|
|
|
jo.put("value", x.getValueResult()); |
|
|
|
outCircle.add(jo); |
|
|
|
});; |
|
|
|
ret.put("inCircle",inCircle); |
|
|
|
ret.put("outCircle",outCircle); |
|
|
|
JSONObject allJo=new JSONObject(); |
|
|
|
allJo.put("unit",targetDraftDaynewResVos.get(0).getTargetUnit()); |
|
|
|
allJo.put("concatSquare",targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.OPENING_AREA.getName().equals(x.getReportName())).map(TargetDraftDaynewResVo::getValueResult).reduce(BigDecimal.ZERO,BigDecimal::add)); |
|
|
|
allJo.put("realSquare",targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.HEATING_AREA.getName().equals(x.getReportName())).map(TargetDraftDaynewResVo::getValueResult).reduce(BigDecimal.ZERO,BigDecimal::add)); |
|
|
|
ret.put("all", allJo); |
|
|
|
return ret; |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getCoalLostRate(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.COAL_CONSUMPTION.getName(), ReportNameEnum.COAL_CONSUMPTION_PER_UNIT.getName()).collect(Collectors.toList()); |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
JSONArray product=new JSONArray(); |
|
|
|
JSONArray realcost=new JSONArray(); |
|
|
|
JSONArray realcost_2=new JSONArray(); |
|
|
|
product.add("name"); |
|
|
|
realcost.add(ReportNameEnum.COAL_CONSUMPTION.getName()); |
|
|
|
realcost_2.add(ReportNameEnum.COAL_CONSUMPTION_PER_UNIT.getName()); |
|
|
|
targetDraftDaynewResVos.stream().collect(Collectors.toList()).sort(Comparator.comparing(TargetDraftDaynewResVo::getOrganizeName)); |
|
|
|
product.addAll(targetDraftDaynewResVos.stream().map(TargetDraftDaynewResVo::getOrganizeName).distinct().collect(Collectors.toList())); |
|
|
|
for (int i = 1; i < product.size(); i++) { |
|
|
|
int finalI = i; |
|
|
|
realcost.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.COAL_CONSUMPTION.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
realcost_2.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.COAL_CONSUMPTION_PER_UNIT.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
public List<JSONArray> selectChildrenOrgSomedayMultiReportDataBar(ReportDataReq reportDataReq) { |
|
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
|
List<String> reportNames = reportDataReq.getReportNames(); |
|
|
|
JSONArray head = new JSONArray(); |
|
|
|
head.add("product"); |
|
|
|
head.addAll(reportNames); |
|
|
|
result.add(head); |
|
|
|
this.buildChildrenOrgReportDataReq(reportDataReq); |
|
|
|
List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> data = this.selectSomeTypeChildrenOrgSomedayMultiReportDataDTOList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
Map<Long, List<SomeTypeChildrenOrgSomedayMultiReportDataDTO>> orgIdGroupMap = data.stream().collect(groupingBy(SomeTypeChildrenOrgSomedayMultiReportDataDTO::getOrgId)); |
|
|
|
orgIdGroupMap.forEach((orgId, orgDataList) -> { |
|
|
|
JSONArray body = new JSONArray(); |
|
|
|
body.add(orgDataList.get(0).getOrgName()); |
|
|
|
Map<String, BigDecimal> reportValueMap = orgDataList.stream().collect(Collectors.toMap(SomeTypeChildrenOrgSomedayMultiReportDataDTO::getReportName, SomeTypeChildrenOrgSomedayMultiReportDataDTO::getValueResult, (v1, v2) -> v2)); |
|
|
|
reportNames.forEach(reportName -> { |
|
|
|
body.add(reportValueMap.get(reportName)); |
|
|
|
}); |
|
|
|
result.add(body); |
|
|
|
}); |
|
|
|
} |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
list.add(product); |
|
|
|
list.add(realcost); |
|
|
|
list.add(realcost_2); |
|
|
|
ret.put("source",list); |
|
|
|
ret.put("unit",targetDraftDaynewResVos.get(0).getTargetUnit()); |
|
|
|
return ret; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getWaterInfo(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return ret; |
|
|
|
/** |
|
|
|
* 查询某组织某天多图表数据DTO列表 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<SomeOrgSomedayMultiReportDataDTO> selectSomeOrgSomedayMultiReportDataDTOList(ReportDataReq reportDataReq) { |
|
|
|
this.buildReportDataReq(reportDataReq); |
|
|
|
return baseMapper.selectSomeOrgSomedayMultiReportDataList(reportDataReq); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询某类型的下级组织某天的多图表数据列表 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> selectSomeTypeChildrenOrgSomedayMultiReportDataDTOList(ReportDataReq reportDataReq) { |
|
|
|
return baseMapper.selectSomeTypeChildrenOrgSomedayMultiReportDataList(reportDataReq); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询某组织某个图表年度数据列表 |
|
|
|
* @param reportDataReq |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<SomeOrgSomeReportYearlyDataVO> selectSomeOrgSomeReportYearlyDataList(ReportDataReq reportDataReq) { |
|
|
|
this.buildReportDataReq(reportDataReq); |
|
|
|
return baseMapper.selectSomeOrgSomeReportYearlyDataList(reportDataReq); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构建统计单元级别和类型 |
|
|
|
* @param reportDataReq |
|
|
|
*/ |
|
|
|
private void buildReportDataReq(ReportDataReq reportDataReq) { |
|
|
|
Long orgId = reportDataReq.getOrgId(); |
|
|
|
if (orgId == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.FIRST_NETWORK_WATER_CONSUMPTION_RATE.getName(), ReportNameEnum.SECOND_NETWORK_WATER_CONSUMPTION_RATE.getName(), |
|
|
|
ReportNameEnum.PRIMARY_NET_RECHARGE_WATER.getName(), ReportNameEnum.DATANG_PRIMARY_NET_RECHARGE_WATER.getName(), ReportNameEnum.WATER_CONSUMPTION_OF_SECONDARY_NETWORK.getName()).collect(Collectors.toList()); |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
SysDept sysDept = iSysDeptService.selectDeptById(orgId); |
|
|
|
if (null != sysDept) { |
|
|
|
String orgType = sysDept.getOrgType(); |
|
|
|
switch (orgType) { |
|
|
|
case BizConstants.DcDeptAttr.BLOC: |
|
|
|
reportDataReq.setAssetLevel("0"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
break; |
|
|
|
case BizConstants.DcDeptAttr.COMANY: |
|
|
|
reportDataReq.setAssetLevel("10"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
break; |
|
|
|
case BizConstants.DcDeptAttr.HEAT_SOURCE: |
|
|
|
reportDataReq.setAssetLevel("20"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
targetDraftDaynewResVos.stream().collect(groupingBy(TargetDraftDaynewResVo::getOrganizeName)).entrySet().forEach(entry->{ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("name", entry.getKey()); |
|
|
|
jo.put("field1", entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.FIRST_NETWORK_WATER_CONSUMPTION_RATE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
jo.put("field2", entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.SECOND_NETWORK_WATER_CONSUMPTION_RATE.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
BigDecimal primary_net_recharge_water_value = entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.PRIMARY_NET_RECHARGE_WATER.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult(); |
|
|
|
BigDecimal datang_primary_net_recharge_water_value = entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.PRIMARY_NET_RECHARGE_WATER.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult(); |
|
|
|
primary_net_recharge_water_value = ObjUtil.isNotEmpty(primary_net_recharge_water_value)?primary_net_recharge_water_value:BigDecimal.ZERO; |
|
|
|
datang_primary_net_recharge_water_value = ObjUtil.isNotEmpty(datang_primary_net_recharge_water_value)?datang_primary_net_recharge_water_value:BigDecimal.ZERO; |
|
|
|
jo.put("field3", primary_net_recharge_water_value.add(datang_primary_net_recharge_water_value)); |
|
|
|
jo.put("field4", entry.getValue().stream().filter(x -> x.getReportName().equals(ReportNameEnum.WATER_CONSUMPTION_OF_SECONDARY_NETWORK.getName())).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
list.add(jo); |
|
|
|
}); |
|
|
|
ret.put("source",list); |
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getPowerLostRate(TargetDraftDaynewReqVo vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
List<String> reportNames = Stream.of(ReportNameEnum.POWER_CONSUMPTION_RATE_OF_HEAT_SOURCE_PLANT.getName(), ReportNameEnum.TOTAL_ELECTRICITY_CONSUMPTION.getName()).collect(Collectors.toList()); |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
return ret; |
|
|
|
/** |
|
|
|
* 构建下级组织的统计单元级别和类型 |
|
|
|
* @param reportDataReq |
|
|
|
*/ |
|
|
|
private void buildChildrenOrgReportDataReq(ReportDataReq reportDataReq) { |
|
|
|
Long orgId = reportDataReq.getOrgId(); |
|
|
|
if (orgId == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray product=new JSONArray(); |
|
|
|
JSONArray realcost=new JSONArray(); |
|
|
|
JSONArray realcost_2=new JSONArray(); |
|
|
|
product.add("name"); |
|
|
|
realcost.add(ReportNameEnum.POWER_CONSUMPTION_RATE_OF_HEAT_SOURCE_PLANT.getName()); |
|
|
|
realcost_2.add(ReportNameEnum.TOTAL_ELECTRICITY_CONSUMPTION.getName()); |
|
|
|
targetDraftDaynewResVos.stream().collect(Collectors.toList()).sort(Comparator.comparing(TargetDraftDaynewResVo::getOrganizeName)); |
|
|
|
product.addAll(targetDraftDaynewResVos.stream().map(TargetDraftDaynewResVo::getOrganizeName).distinct().collect(Collectors.toList())); |
|
|
|
for (int i = 1; i < product.size(); i++) { |
|
|
|
int finalI = i; |
|
|
|
realcost.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.POWER_CONSUMPTION_RATE_OF_HEAT_SOURCE_PLANT.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
realcost_2.add(targetDraftDaynewResVos.stream().filter(t->ReportNameEnum.TOTAL_ELECTRICITY_CONSUMPTION.getName().equals(t.getReportName())&&t.getOrganizeName().equals(product.get(finalI))).findFirst().orElse(new TargetDraftDaynewResVo()).getValueResult()); |
|
|
|
SysDept sysDept = iSysDeptService.selectDeptById(orgId); |
|
|
|
if (null != sysDept) { |
|
|
|
switch (sysDept.getOrgType()) { |
|
|
|
case BizConstants.DcDeptAttr.BLOC: |
|
|
|
reportDataReq.setAssetLevel("10"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
reportDataReq.setOrgType(BizConstants.DcDeptAttr.COMANY); |
|
|
|
break; |
|
|
|
case BizConstants.DcDeptAttr.COMANY: |
|
|
|
reportDataReq.setAssetLevel("20"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
reportDataReq.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
|
break; |
|
|
|
case BizConstants.DcDeptAttr.HEAT_SOURCE: |
|
|
|
reportDataReq.setAssetLevel("30"); |
|
|
|
reportDataReq.setAssetType("0"); |
|
|
|
reportDataReq.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
list.add(product); |
|
|
|
list.add(realcost); |
|
|
|
list.add(realcost_2); |
|
|
|
ret.put("source",list); |
|
|
|
ret.put("unit",targetDraftDaynewResVos.get(0).getTargetUnit()); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getMapInfo(TargetDraftDaynewReqVo vo){ |
|
|
|
public JSONObject getMapInfo(ReportDataReq vo){ |
|
|
|
JSONObject ret=new JSONObject(); |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
@ -305,54 +271,4 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
ret.put("source", jsonArray); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
public List<DcBusiDataScreenVo> selectSquareRealDetail(String qdate) { |
|
|
|
return baseMapper.selectSquareRealDetail(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectSquareSelfDetail(String qdate){ |
|
|
|
return baseMapper.selectSquareSelfDetail(qdate); |
|
|
|
} |
|
|
|
public List<DcBusiDataScreenVo> selectSquareGroup(String qdate){ |
|
|
|
return baseMapper.selectSquareGroup(qdate); |
|
|
|
} |
|
|
|
|
|
|
|
public List<TargetDraftDayRangeResVo> getHeatingPeriodData(TargetDraftDaynewReqVo vo){ |
|
|
|
List<TargetDraftDayRangeResVo> res = Lists.newArrayList(); |
|
|
|
if (!HeatingPeriodEnum.HEATING_ALL_PERIOD.getMonths().contains(Integer.parseInt(vo.getDateMonth()))) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
List<Long> orgIds = sysDepts.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList()); |
|
|
|
vo.setAssetType("0").setAssetLevel("10").setOrgIds(orgIds); |
|
|
|
String dateYear = vo.getDateYear(); |
|
|
|
if (HeatingPeriodEnum.HEATING_NEXT_YREA_PERIOD.getMonths().contains(Integer.parseInt(vo.getDateMonth()))) { |
|
|
|
dateYear = String.valueOf(Integer.parseInt(vo.getDateYear())-1); |
|
|
|
} |
|
|
|
vo.setBeginDate(StringUtils.join(dateYear, "1101")).setAssetType("0").setAssetLevel("10").setOrgIds(orgIds) |
|
|
|
.setEndDate(StringUtils.join(vo.getDateYear(),vo.getDateMonth(),vo.getDateDay())); |
|
|
|
List<TargetDraftDayRangeResVo> list = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewRangeList(vo); |
|
|
|
List<SysDept> depts = sysDepts.stream().filter(x -> list.stream().map(TargetDraftDayRangeResVo::getCname).distinct().collect(Collectors.toList()).contains(x.getDeptName())).collect(Collectors.toList()); |
|
|
|
List<TargetDraftDayRangeResVo> totalList = Lists.newArrayList(); |
|
|
|
list.stream().collect(groupingBy(TargetDraftDayRangeResVo::getCdate)).entrySet().forEach(entry->{ |
|
|
|
depts.forEach(dept->{ |
|
|
|
TargetDraftDayRangeResVo dayVo = entry.getValue().stream().filter(x -> x.getCname().equals(dept.getDeptName())).findFirst().orElse(null); |
|
|
|
if (ObjectUtil.isNull(dayVo)) { |
|
|
|
totalList.add(TargetDraftDayRangeResVo.builder().cdate(entry.getKey()).cname(dept.getDeptName()).valueResult(BigDecimal.ZERO).build()); |
|
|
|
} else { |
|
|
|
totalList.add(dayVo); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
totalList.stream().collect(groupingBy(TargetDraftDayRangeResVo::getCdate)).entrySet().forEach(entry->{ |
|
|
|
res.add(TargetDraftDayRangeResVo.builder().cdate(entry.getKey()) |
|
|
|
.cut(CollectionUtil.join(entry.getValue().stream().map(TargetDraftDayRangeResVo::getValueResult).collect(Collectors.toList()), ",")) |
|
|
|
.cname(CollectionUtil.join(entry.getValue().stream().map(TargetDraftDayRangeResVo::getCname).collect(Collectors.toList()), ",")) |
|
|
|
.build()); |
|
|
|
}); |
|
|
|
res.sort(Comparator.comparing(TargetDraftDayRangeResVo::getCdate)); |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |