|
|
@ -8,6 +8,7 @@ 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.SysDeptLocation; |
|
|
|
import com.lzbi.bi.domain.dto.MultiOrgSomeReportEverydayData; |
|
|
|
import com.lzbi.bi.domain.dto.SomeOrgSomedaySomeParamSummarizingDataDTO; |
|
|
|
import com.lzbi.bi.domain.req.ParamSummarizingDataReq; |
|
|
|
import com.lzbi.bi.domain.vo.*; |
|
|
@ -24,6 +25,7 @@ import com.lzbi.common.utils.bean.BeanUtils; |
|
|
|
import com.lzbi.draft.domain.vo.*; |
|
|
|
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; |
|
|
|
import com.lzbi.system.service.ISysDeptService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
@ -54,23 +56,23 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService; |
|
|
|
// @Resource
|
|
|
|
// private ScreenMockDataMapper baseMapper;
|
|
|
|
|
|
|
|
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
/** |
|
|
|
* 供暖起始日期--月日 |
|
|
|
*/ |
|
|
|
private static final String HEATING_START_DATE = "11-01"; |
|
|
|
private static final String HEATING_START_DATE = "-11-01"; |
|
|
|
/** |
|
|
|
* 供暖结束日期--月日 |
|
|
|
*/ |
|
|
|
private static final String HEATING_END_DATE = "03-31"; |
|
|
|
private static final String HEATING_END_DATE = "-03-31"; |
|
|
|
/** |
|
|
|
* 非供暖起始日期--月日 |
|
|
|
*/ |
|
|
|
private static final String NO_HEATING_START_DATE = "04-01"; |
|
|
|
private static final String NO_HEATING_START_DATE = "-04-01"; |
|
|
|
/** |
|
|
|
* 非供暖结束日期--月日 |
|
|
|
*/ |
|
|
|
private static final String NO_HEATING_END_DATE = "10-31"; |
|
|
|
private static final String NO_HEATING_END_DATE = "-10-31"; |
|
|
|
|
|
|
|
private static final String GRMJ = "供热面积"; |
|
|
|
private static final String LWMJ = "联网面积"; |
|
|
@ -78,7 +80,6 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
private static final String RY = "热源"; |
|
|
|
private static final String HRZ = "换热站"; |
|
|
|
private static final String ZMJ = "总面积"; |
|
|
|
private static final String ZYH = "总用户"; |
|
|
|
private static final List<String> SPECIAL_REPORT_LIST; |
|
|
|
|
|
|
|
static { |
|
|
@ -89,7 +90,6 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
SPECIAL_REPORT_LIST.add(RY); |
|
|
|
SPECIAL_REPORT_LIST.add(HRZ); |
|
|
|
SPECIAL_REPORT_LIST.add(ZMJ); |
|
|
|
SPECIAL_REPORT_LIST.add(ZYH); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -120,7 +120,6 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
value = baseMapper.selectSomeOrgSomedaySomeParamSummarizingData(paramSummarizingDataReq); |
|
|
|
break; |
|
|
|
case AQGR: |
|
|
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
String dateStr = reportDataReq.getDateYear() + "-" + reportDataReq.getDateMonth() + "-" + reportDataReq.getDateDay(); |
|
|
|
LocalDate date = LocalDate.parse(dateStr, dateTimeFormatter); |
|
|
|
int year = date.getYear(); |
|
|
@ -134,21 +133,28 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
LocalDate heatingEndDate = LocalDate.parse(heatingEndDateStr, dateTimeFormatter); |
|
|
|
// 如果在非供暖期,就是获取最大值
|
|
|
|
if (date.isBefore(noHeatingEndDate) && date.isAfter(noHeatingStartDate)) { |
|
|
|
long daysDiff = ChronoUnit.DAYS.between(heatingEndDate, heatingStartDate); |
|
|
|
value = BigDecimal.valueOf(daysDiff); |
|
|
|
long daysDiff = ChronoUnit.DAYS.between(heatingStartDate, heatingEndDate); |
|
|
|
value = BigDecimal.valueOf(daysDiff + 1); |
|
|
|
} else { |
|
|
|
long daysDiff = ChronoUnit.DAYS.between(date, heatingStartDate); |
|
|
|
value = BigDecimal.valueOf(daysDiff); |
|
|
|
if (date.isAfter(noHeatingEndDate)) { |
|
|
|
heatingStartDateStr = year + HEATING_START_DATE; |
|
|
|
heatingStartDate = LocalDate.parse(heatingStartDateStr, dateTimeFormatter); |
|
|
|
} |
|
|
|
long daysDiff = ChronoUnit.DAYS.between(heatingStartDate, date); |
|
|
|
value = BigDecimal.valueOf(daysDiff + 1); |
|
|
|
} |
|
|
|
break; |
|
|
|
case RY: |
|
|
|
// iSysDeptService.selectCompany()
|
|
|
|
int ryCount = iSysDeptService.selectSomeTypeChildrenDeptCount(reportDataReq.getOrgId(), BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
|
value = BigDecimal.valueOf(ryCount); |
|
|
|
break; |
|
|
|
case HRZ: |
|
|
|
int hrzCount = baseMapper.selectSomeOrgHeatExchangeStationCount(reportDataReq.getOrgId()); |
|
|
|
value = BigDecimal.valueOf(hrzCount); |
|
|
|
break; |
|
|
|
case ZMJ: |
|
|
|
break; |
|
|
|
case ZYH: |
|
|
|
paramSummarizingDataReq.setTargetModelCode(ParamsModelCodeConstants.开栓已执行); |
|
|
|
value = baseMapper.selectSomeOrgSomedaySomeParamSummarizingData(paramSummarizingDataReq); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
@ -184,6 +190,28 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartHaveOrgId(ReportDataReq reportDataReq) { |
|
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
|
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
JSONArray head = new JSONArray(); |
|
|
|
head.add("name"); |
|
|
|
JSONArray body = new JSONArray(); |
|
|
|
body.add(reportDataReq.getReportName()); |
|
|
|
JSONArray idJsonArr = new JSONArray(); |
|
|
|
idJsonArr.add("orgId"); |
|
|
|
data.forEach(item -> { |
|
|
|
head.add(item.getOrgName()); |
|
|
|
body.add(item.getValueResult()); |
|
|
|
idJsonArr.add(item.getOrgId()); |
|
|
|
}); |
|
|
|
result.add(head); |
|
|
|
result.add(body); |
|
|
|
result.add(idJsonArr); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartStacking(ReportDataReq reportDataReq) { |
|
|
|
List<JSONArray> result = new ArrayList<>(); |
|
|
|
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq); |
|
|
@ -278,6 +306,75 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai |
|
|
|
return baseMapper.selectMapOrgList(reportDataReq); |
|
|
|
} |
|
|
|
|
|
|
|
public List<SomeReportDataRankingVO> selectSomeReportDataRankingList(ReportDataReq reportDataReq) { |
|
|
|
List<SomeReportDataRankingVO> result = new ArrayList<>(); |
|
|
|
this.buildChildrenOrgReportDataReq(reportDataReq); |
|
|
|
this.buildHeatingDate(reportDataReq); |
|
|
|
List<MultiOrgSomeReportEverydayData> multiOrgSomeReportEverydayDataList = baseMapper.selectChildOrgSomeReportEverydayDataList(reportDataReq); |
|
|
|
if (!CollectionUtils.isEmpty(multiOrgSomeReportEverydayDataList)) { |
|
|
|
// 排序后的日期列表
|
|
|
|
List<String> dateSoredList = multiOrgSomeReportEverydayDataList.stream().map(MultiOrgSomeReportEverydayData::getDate).collect(Collectors.toSet()).stream().sorted().collect(Collectors.toList()); |
|
|
|
// 排序后的组织id列表
|
|
|
|
List<Long> orgIdSoredList = multiOrgSomeReportEverydayDataList.stream().map(MultiOrgSomeReportEverydayData::getOrgId).collect(Collectors.toSet()).stream().sorted().collect(Collectors.toList()); |
|
|
|
// 组织map
|
|
|
|
Map<Long, String> orgMap = multiOrgSomeReportEverydayDataList.stream().collect(Collectors.toMap(MultiOrgSomeReportEverydayData::getOrgId, MultiOrgSomeReportEverydayData::getOrgName, (v1, v2) -> v2)); |
|
|
|
// 按日期分组的map
|
|
|
|
Map<String, List<MultiOrgSomeReportEverydayData>> groupDateMap = multiOrgSomeReportEverydayDataList.stream().collect(groupingBy(MultiOrgSomeReportEverydayData::getDate)); |
|
|
|
dateSoredList.forEach(date -> { |
|
|
|
SomeReportDataRankingVO someReportDataRankingVO = new SomeReportDataRankingVO(); |
|
|
|
someReportDataRankingVO.setCdate(date); |
|
|
|
List<MultiOrgSomeReportEverydayData> data = groupDateMap.get(date); |
|
|
|
Map<Long, MultiOrgSomeReportEverydayData> orgIdMap = data.stream().collect(Collectors.toMap(MultiOrgSomeReportEverydayData::getOrgId, item -> item, (v1, v2) -> v1)); |
|
|
|
List<String> orgNameList = new ArrayList<>(); |
|
|
|
List<BigDecimal> valueList = new ArrayList<>(); |
|
|
|
orgIdSoredList.forEach(orgId -> { |
|
|
|
orgNameList.add(orgMap.get(orgId)); |
|
|
|
if (orgIdMap.containsKey(orgId)) { |
|
|
|
valueList.add(orgIdMap.get(orgId).getValue()); |
|
|
|
} else { |
|
|
|
valueList.add(null); |
|
|
|
} |
|
|
|
}); |
|
|
|
someReportDataRankingVO.setCname(StringUtils.join(orgNameList, ",")); |
|
|
|
someReportDataRankingVO.setCut(StringUtils.join(valueList, ",")); |
|
|
|
result.add(someReportDataRankingVO); |
|
|
|
}); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构建供暖期 |
|
|
|
* @param reportDataReq |
|
|
|
*/ |
|
|
|
private void buildHeatingDate(ReportDataReq reportDataReq) { |
|
|
|
String dateStr = reportDataReq.getDateYear() + "-" + reportDataReq.getDateMonth() + "-" + reportDataReq.getDateDay(); |
|
|
|
LocalDate date = LocalDate.parse(dateStr, dateTimeFormatter); |
|
|
|
int year = date.getYear(); |
|
|
|
String noHeatingEndDateStr = year + NO_HEATING_END_DATE; |
|
|
|
LocalDate noHeatingEndDate = LocalDate.parse(noHeatingEndDateStr, dateTimeFormatter); |
|
|
|
String heatingStartDateStr; |
|
|
|
String heatingEndDateStr; |
|
|
|
if (date.isAfter(noHeatingEndDate)) { |
|
|
|
heatingStartDateStr = year + HEATING_START_DATE; |
|
|
|
heatingEndDateStr = dateStr; |
|
|
|
reportDataReq.setHeatingStartDate(heatingStartDateStr); |
|
|
|
reportDataReq.setHeatingEndDate(heatingEndDateStr); |
|
|
|
} else { |
|
|
|
heatingStartDateStr = (year - 1) + HEATING_START_DATE; |
|
|
|
String noHeatingStartDateStr = year + NO_HEATING_START_DATE; |
|
|
|
LocalDate noHeatingStartDate = LocalDate.parse(noHeatingStartDateStr, dateTimeFormatter); |
|
|
|
if (date.isAfter(noHeatingStartDate)) { |
|
|
|
heatingEndDateStr = year + HEATING_END_DATE; |
|
|
|
} else { |
|
|
|
heatingEndDateStr = dateStr; |
|
|
|
} |
|
|
|
} |
|
|
|
reportDataReq.setHeatingStartDate(heatingStartDateStr); |
|
|
|
|
|
|
|
reportDataReq.setHeatingEndDate(heatingEndDateStr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询某组织某天多图表数据DTO列表 |
|
|
|
* @param reportDataReq |
|
|
|