|
@ -1,32 +1,26 @@ |
|
|
package com.lzbi.bi.service; |
|
|
package com.lzbi.bi.service; |
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
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.JSONArray; |
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.IService; |
|
|
import com.baomidou.mybatisplus.extension.service.IService; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.lzbi.bi.domain.DcBusiDataScreenDto; |
|
|
import com.lzbi.bi.domain.DcBusiDataScreenDto; |
|
|
import com.lzbi.bi.domain.DcBusiDataScreenVo; |
|
|
|
|
|
import com.lzbi.bi.domain.SysDeptLocation; |
|
|
import com.lzbi.bi.domain.SysDeptLocation; |
|
|
import com.lzbi.bi.mapper.DcBusiDataScreenMainMapper; |
|
|
import com.lzbi.bi.mapper.DcBusiDataScreenMainMapper; |
|
|
import com.lzbi.common.constant.BizConstants; |
|
|
import com.lzbi.common.constant.BizConstants; |
|
|
import com.lzbi.common.core.domain.entity.SysDept; |
|
|
import com.lzbi.common.core.domain.entity.SysDept; |
|
|
import com.lzbi.common.enums.HeatingPeriodEnum; |
|
|
|
|
|
import com.lzbi.common.enums.ReportNameEnum; |
|
|
import com.lzbi.common.enums.ReportNameEnum; |
|
|
import com.lzbi.common.utils.StringUtils; |
|
|
import com.lzbi.draft.domain.dto.SomeOrgSomedayMultiReportDataDTO; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo; |
|
|
import com.lzbi.draft.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; |
|
|
import com.lzbi.draft.domain.req.ReportDataReq; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; |
|
|
import com.lzbi.draft.domain.vo.*; |
|
|
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; |
|
|
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; |
|
|
import com.lzbi.system.service.ISysDeptService; |
|
|
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.stereotype.Service; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
@ -51,222 +45,194 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
@Resource |
|
|
@Resource |
|
|
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; |
|
|
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; |
|
|
|
|
|
|
|
|
public List<DcBusiDataScreenVo> selectCoalLostByDate(String qdate){ |
|
|
/** |
|
|
return baseMapper.selectCoalLostByDate(qdate); |
|
|
* 查询某个组织某天的某个图表数据 |
|
|
} |
|
|
* @param reportDataReq |
|
|
public List<DcBusiDataScreenVo> selectDatainTaget(String qdate){ |
|
|
* @return |
|
|
return baseMapper.selectDataPowerLost(qdate); |
|
|
*/ |
|
|
} |
|
|
public SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq) { |
|
|
public List<DcBusiDataScreenVo> selectDataPowerLost(String qdate){ |
|
|
this.buildReportDataReq(reportDataReq); |
|
|
return baseMapper.selectDataPowerLost(qdate); |
|
|
return baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq); |
|
|
} |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
} |
|
|
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())); |
|
|
* @param reportDataReq |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
* @return |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
*/ |
|
|
return ret; |
|
|
public List<ChildrenOrgSomedaySomeReportDataVO> selectChildrenOrgSomedaySomeReportDataList(ReportDataReq reportDataReq) { |
|
|
|
|
|
this.buildChildrenOrgReportDataReq(reportDataReq); |
|
|
|
|
|
return baseMapper.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
} |
|
|
} |
|
|
JSONArray list=new JSONArray(); |
|
|
|
|
|
targetDraftDaynewResVos.forEach(item->{ |
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchart(ReportDataReq reportDataReq) { |
|
|
JSONObject jsb=new JSONObject(); |
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
jsb.put("name",item.getReportName()); |
|
|
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
jsb.put("value", item.getValueResult().toString()); |
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
jsb.put("unit",item.getTargetUnit()); |
|
|
JSONArray head = new JSONArray(); |
|
|
list.add(jsb); |
|
|
JSONArray body = new JSONArray(); |
|
|
|
|
|
data.forEach(item -> { |
|
|
|
|
|
head.add(item.getOrgName()); |
|
|
|
|
|
body.add(item.getValueResult()); |
|
|
}); |
|
|
}); |
|
|
ret.put("source",list); |
|
|
result.add(head); |
|
|
return ret; |
|
|
result.add(body); |
|
|
} |
|
|
} |
|
|
public JSONObject getSquareInfoCompany(TargetDraftDaynewReqVo vo){ |
|
|
return result; |
|
|
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()); |
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartStacking(ReportDataReq reportDataReq) { |
|
|
vo.setAssetType("0").setAssetLevel("10").setReportNames(reportNames).setOrgIds(orgIds); |
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
JSONArray head = new JSONArray(); |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
head.add("product"); |
|
|
return ret; |
|
|
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 product=new JSONArray(); |
|
|
return result; |
|
|
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()); |
|
|
|
|
|
} |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public JSONObject getSquareInfoGroup(TargetDraftDaynewReqVo vo){ |
|
|
/** |
|
|
JSONObject ret=new JSONObject(); |
|
|
* 查询某组织某天多图表数据列表 |
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
* @param reportDataReq |
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
* @return |
|
|
return ret; |
|
|
*/ |
|
|
|
|
|
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()); |
|
|
return new ArrayList<>(); |
|
|
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(); |
|
|
public List<JSONArray> selectChildrenOrgSomedayMultiReportDataBar(ReportDataReq reportDataReq) { |
|
|
targetDraftDaynewResVos.stream().filter(x->ReportNameEnum.OPENING_AREA.getName().equals(x.getReportName())).forEach(x->{ |
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
JSONObject jo = new JSONObject(); |
|
|
List<String> reportNames = reportDataReq.getReportNames(); |
|
|
jo.put("name", x.getOrganizeName()); |
|
|
JSONArray head = new JSONArray(); |
|
|
jo.put("unit", x.getTargetUnit()); |
|
|
head.add("product"); |
|
|
jo.put("value", x.getValueResult()); |
|
|
head.addAll(reportNames); |
|
|
inCircle.add(jo); |
|
|
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); |
|
|
}); |
|
|
}); |
|
|
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 result; |
|
|
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); |
|
|
* 查询某组织某天多图表数据DTO列表 |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
* @param reportDataReq |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
* @return |
|
|
return ret; |
|
|
*/ |
|
|
} |
|
|
private List<SomeOrgSomedayMultiReportDataDTO> selectSomeOrgSomedayMultiReportDataDTOList(ReportDataReq reportDataReq) { |
|
|
JSONArray product=new JSONArray(); |
|
|
this.buildReportDataReq(reportDataReq); |
|
|
JSONArray realcost=new JSONArray(); |
|
|
return baseMapper.selectSomeOrgSomedayMultiReportDataList(reportDataReq); |
|
|
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()); |
|
|
|
|
|
} |
|
|
} |
|
|
JSONArray list=new JSONArray(); |
|
|
|
|
|
list.add(product); |
|
|
/** |
|
|
list.add(realcost); |
|
|
* 查询某类型的下级组织某天的多图表数据列表 |
|
|
list.add(realcost_2); |
|
|
* @param reportDataReq |
|
|
ret.put("source",list); |
|
|
* @return |
|
|
ret.put("unit",targetDraftDaynewResVos.get(0).getTargetUnit()); |
|
|
*/ |
|
|
return ret; |
|
|
private List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> selectSomeTypeChildrenOrgSomedayMultiReportDataDTOList(ReportDataReq reportDataReq) { |
|
|
|
|
|
return baseMapper.selectSomeTypeChildrenOrgSomedayMultiReportDataList(reportDataReq); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public JSONObject getWaterInfo(TargetDraftDaynewReqVo vo){ |
|
|
/** |
|
|
JSONObject ret=new JSONObject(); |
|
|
* 查询某组织某个图表年度数据列表 |
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
* @param reportDataReq |
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
* @return |
|
|
return ret; |
|
|
*/ |
|
|
|
|
|
public List<SomeOrgSomeReportYearlyDataVO> selectSomeOrgSomeReportYearlyDataList(ReportDataReq reportDataReq) { |
|
|
|
|
|
this.buildReportDataReq(reportDataReq); |
|
|
|
|
|
return baseMapper.selectSomeOrgSomeReportYearlyDataList(reportDataReq); |
|
|
} |
|
|
} |
|
|
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); |
|
|
* @param reportDataReq |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(vo); |
|
|
*/ |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
private void buildReportDataReq(ReportDataReq reportDataReq) { |
|
|
return ret; |
|
|
Long orgId = reportDataReq.getOrgId(); |
|
|
|
|
|
if (orgId == null) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
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); |
|
|
* @param reportDataReq |
|
|
if (CollUtil.isEmpty(targetDraftDaynewResVos)) { |
|
|
*/ |
|
|
return ret; |
|
|
private void buildChildrenOrgReportDataReq(ReportDataReq reportDataReq) { |
|
|
|
|
|
Long orgId = reportDataReq.getOrgId(); |
|
|
|
|
|
if (orgId == null) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
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 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()); |
|
|
|
|
|
} |
|
|
} |
|
|
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(); |
|
|
JSONObject ret=new JSONObject(); |
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
List<SysDept> sysDepts = iSysDeptService.selecttList(SysDept.builder().parentId(vo.getOrgId()).orgType(BizConstants.DcDeptAttr.COMANY).build()); |
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
|
if (CollUtil.isEmpty(sysDepts)) { |
|
@ -305,54 +271,4 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
ret.put("source", jsonArray); |
|
|
ret.put("source", jsonArray); |
|
|
return ret; |
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |