|
@ -5,17 +5,20 @@ import com.lzbi.bi.domain.*; |
|
|
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.ReportNameEnum; |
|
|
import com.lzbi.common.enums.ReportNameEnum; |
|
|
|
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftMonthAggregateResVo; |
|
|
import com.lzbi.draft.domain.vo.TargetDraftMonthAggregateResVo; |
|
|
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; |
|
|
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; |
|
|
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 lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
@ -27,9 +30,11 @@ import static java.util.stream.Collectors.groupingBy; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 大屏业务 |
|
|
* 大屏业务 |
|
|
|
|
|
* |
|
|
* @author : lienbo |
|
|
* @author : lienbo |
|
|
* @date : 2023-12-14 |
|
|
* @date : 2023-12-14 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
public class DcBusiDataScreenNewService { |
|
|
public class DcBusiDataScreenNewService { |
|
|
|
|
|
|
|
@ -109,7 +114,7 @@ public class DcBusiDataScreenNewService { |
|
|
SysDept deptParams = new SysDept(); |
|
|
SysDept deptParams = new SysDept(); |
|
|
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId()); |
|
|
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId()); |
|
|
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
List<SysDept> childrenDept = iSysDeptService.selectDeptList(deptParams); |
|
|
List<SysDept> childrenDept = iSysDeptService.selecttList(deptParams); |
|
|
if (CollectionUtils.isEmpty(childrenDept)) { |
|
|
if (CollectionUtils.isEmpty(childrenDept)) { |
|
|
throw new RuntimeException("该公司无热源"); |
|
|
throw new RuntimeException("该公司无热源"); |
|
|
} |
|
|
} |
|
@ -155,7 +160,7 @@ public class DcBusiDataScreenNewService { |
|
|
SysDept deptParams = new SysDept(); |
|
|
SysDept deptParams = new SysDept(); |
|
|
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId()); |
|
|
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId()); |
|
|
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE); |
|
|
List<SysDept> childrenDept = iSysDeptService.selectDeptList(deptParams); |
|
|
List<SysDept> childrenDept = iSysDeptService.selecttList(deptParams); |
|
|
if (CollectionUtils.isEmpty(childrenDept)) { |
|
|
if (CollectionUtils.isEmpty(childrenDept)) { |
|
|
throw new RuntimeException("该公司无热源"); |
|
|
throw new RuntimeException("该公司无热源"); |
|
|
} |
|
|
} |
|
@ -194,47 +199,6 @@ public class DcBusiDataScreenNewService { |
|
|
|
|
|
|
|
|
public FinishingRate getFinishingRate(TargetDraftDaynewReqVo targetDraftDaynewReqVo) { |
|
|
public FinishingRate getFinishingRate(TargetDraftDaynewReqVo targetDraftDaynewReqVo) { |
|
|
FinishingRate finishingRate = new FinishingRate(); |
|
|
FinishingRate finishingRate = new FinishingRate(); |
|
|
// 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.getHeatSupplied());
|
|
|
|
|
|
// 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));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// List<FinishingRate.Label> labelArray = new ArrayList<>();
|
|
|
|
|
|
// List<BigDecimal> valueArr = new ArrayList<>();
|
|
|
|
|
|
// final BigDecimal[] max = {new BigDecimal(0)};
|
|
|
|
|
|
// map.forEach((key, value) -> {
|
|
|
|
|
|
// FinishingRate.Label label = new FinishingRate.Label();
|
|
|
|
|
|
// if (ObjectUtils.isEmpty(dcBusDataScreenNewReq.getOrgId())) {
|
|
|
|
|
|
// label.setName(value.get(0).getOrgName());
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// label.setName(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).getValAccumulative());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// valueArr.add(sum);
|
|
|
|
|
|
// if (max[0].compareTo(sum) < 0) {
|
|
|
|
|
|
// max[0] = sum;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// labelArray.add(label);
|
|
|
|
|
|
// });
|
|
|
|
|
|
// labelArray.stream().forEach(label -> label.setMax(max[0]));
|
|
|
|
|
|
// finishingRate.setLabelArr(labelArray);
|
|
|
|
|
|
// finishingRate.setValueArr(valueArr);
|
|
|
|
|
|
// }
|
|
|
|
|
|
List<String> names = new ArrayList<>(); |
|
|
List<String> names = new ArrayList<>(); |
|
|
names.add(ReportNameEnum.FIRST_NETWORK_WATER_CONSUMPTION_RATE.getName()); |
|
|
names.add(ReportNameEnum.FIRST_NETWORK_WATER_CONSUMPTION_RATE.getName()); |
|
|
names.add(ReportNameEnum.SECOND_NETWORK_WATER_CONSUMPTION_RATE.getName()); |
|
|
names.add(ReportNameEnum.SECOND_NETWORK_WATER_CONSUMPTION_RATE.getName()); |
|
@ -247,9 +211,32 @@ public class DcBusiDataScreenNewService { |
|
|
List<Long> orgIds = new ArrayList<>(); |
|
|
List<Long> orgIds = new ArrayList<>(); |
|
|
orgIds.add(targetDraftDaynewReqVo.getOrgId()); |
|
|
orgIds.add(targetDraftDaynewReqVo.getOrgId()); |
|
|
targetDraftDaynewReqVo.setOrgIds(orgIds); |
|
|
targetDraftDaynewReqVo.setOrgIds(orgIds); |
|
|
List<TargetDraftDaynewResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewList(targetDraftDaynewReqVo); |
|
|
List<TargetDraftDaynewAggregateResVo> targetDraftDaynewResVos = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewAggregateList(targetDraftDaynewReqVo); |
|
|
|
|
|
if (CollectionUtils.isEmpty(targetDraftDaynewResVos)) { |
|
|
|
|
|
log.error("日底稿无数据"); |
|
|
|
|
|
throw new RuntimeException("无数据"); |
|
|
|
|
|
} |
|
|
List<TargetDraftMonthAggregateResVo> targetDraftMonthAggregateResVos = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMontAggregateList(targetDraftDaynewReqVo); |
|
|
List<TargetDraftMonthAggregateResVo> targetDraftMonthAggregateResVos = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMontAggregateList(targetDraftDaynewReqVo); |
|
|
|
|
|
if (CollectionUtils.isEmpty(targetDraftMonthAggregateResVos)) { |
|
|
|
|
|
log.error("月底稿无数据"); |
|
|
|
|
|
throw new RuntimeException("无数据"); |
|
|
|
|
|
} |
|
|
|
|
|
Map<String, BigDecimal> targetDraftDaynewMap = targetDraftDaynewResVos.stream().collect(Collectors.toMap(TargetDraftDaynewAggregateResVo::getReportName, TargetDraftDaynewAggregateResVo::getValueResult)); |
|
|
|
|
|
Map<String, BigDecimal> targetDraftMonthMap = targetDraftMonthAggregateResVos.stream().collect(Collectors.toMap(TargetDraftMonthAggregateResVo::getReportName, TargetDraftMonthAggregateResVo::getValPlan)); |
|
|
|
|
|
List<FinishingRateLabel> labelArray = new ArrayList<>(); |
|
|
|
|
|
List<BigDecimal> valueArr = new ArrayList<>(); |
|
|
|
|
|
targetDraftMonthMap.forEach((reportName, plan) -> { |
|
|
|
|
|
FinishingRateLabel label = new FinishingRateLabel(reportName, new BigDecimal(100)); |
|
|
|
|
|
labelArray.add(label); |
|
|
|
|
|
BigDecimal valueResul = targetDraftDaynewMap.get(reportName); |
|
|
|
|
|
if (null != plan && plan.compareTo(BigDecimal.ZERO) > 0 && null != valueResul) { |
|
|
|
|
|
valueArr.add(valueResul.divide(plan, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); |
|
|
|
|
|
} else { |
|
|
|
|
|
valueArr.add(BigDecimal.ZERO); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
finishingRate.setLabelArr(labelArray); |
|
|
|
|
|
finishingRate.setValueArr(valueArr); |
|
|
return finishingRate; |
|
|
return finishingRate; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|