Browse Source

1、bi大屏接口

develop
bobol 9 months ago
parent
commit
c60339a9e5
  1. 6
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java
  2. 13
      lzbi-module/src/main/java/com/lzbi/bi/domain/FinishingRate.java
  3. 17
      lzbi-module/src/main/java/com/lzbi/bi/domain/FinishingRateLabel.java
  4. 83
      lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java
  5. 5
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java

6
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java

@ -1,13 +1,15 @@
package com.lzbi.bi.controller;
import com.lzbi.bi.domain.DcBusDataScreenNewReq;
import com.lzbi.bi.service.DcBusiDataScreenNewService;
import com.lzbi.common.core.controller.BaseController;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 大屏控制器

13
lzbi-module/src/main/java/com/lzbi/bi/domain/FinishingRate.java

@ -1,8 +1,6 @@
package com.lzbi.bi.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
@ -13,17 +11,8 @@ import java.util.List;
@Data
public class FinishingRate {
private List<Label> labelArr;
private List<FinishingRateLabel> labelArr;
private List<BigDecimal> valueArr;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class Label {
private String name;
private BigDecimal max;
}
}

17
lzbi-module/src/main/java/com/lzbi/bi/domain/FinishingRateLabel.java

@ -0,0 +1,17 @@
package com.lzbi.bi.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FinishingRateLabel {
private String name;
private BigDecimal max;
}

83
lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenNewService.java

@ -5,17 +5,20 @@ import com.lzbi.bi.domain.*;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.core.domain.entity.SysDept;
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.TargetDraftDaynewResVo;
import com.lzbi.draft.domain.vo.TargetDraftMonthAggregateResVo;
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper;
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService;
import com.lzbi.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -27,9 +30,11 @@ import static java.util.stream.Collectors.groupingBy;
/**
* 大屏业务
*
* @author : lienbo
* @date : 2023-12-14
*/
@Slf4j
@Service
public class DcBusiDataScreenNewService {
@ -51,8 +56,8 @@ public class DcBusiDataScreenNewService {
return list;
}
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())
.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;
@ -74,7 +79,7 @@ public class DcBusiDataScreenNewService {
List<String> xArr = new ArrayList<>();
List<BigDecimal> yArr1 = new ArrayList<>();
List<BigDecimal> yArr2 = new ArrayList<>();
targetDraftDaynewResVos.stream().collect(groupingBy(TargetDraftDaynewResVo::getOrganizeName)).entrySet().forEach(entry->{
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());
@ -109,7 +114,7 @@ public class DcBusiDataScreenNewService {
SysDept deptParams = new SysDept();
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId());
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE);
List<SysDept> childrenDept = iSysDeptService.selectDeptList(deptParams);
List<SysDept> childrenDept = iSysDeptService.selecttList(deptParams);
if (CollectionUtils.isEmpty(childrenDept)) {
throw new RuntimeException("该公司无热源");
}
@ -155,7 +160,7 @@ public class DcBusiDataScreenNewService {
SysDept deptParams = new SysDept();
deptParams.setParentId(targetDraftDaynewReqVo.getOrgId());
deptParams.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE);
List<SysDept> childrenDept = iSysDeptService.selectDeptList(deptParams);
List<SysDept> childrenDept = iSysDeptService.selecttList(deptParams);
if (CollectionUtils.isEmpty(childrenDept)) {
throw new RuntimeException("该公司无热源");
}
@ -194,47 +199,6 @@ public class DcBusiDataScreenNewService {
public FinishingRate getFinishingRate(TargetDraftDaynewReqVo targetDraftDaynewReqVo) {
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<>();
names.add(ReportNameEnum.FIRST_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<>();
orgIds.add(targetDraftDaynewReqVo.getOrgId());
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);
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;
}

5
lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java

@ -2,6 +2,7 @@ package com.lzbi.draft.service;
import java.util.List;
import com.lzbi.common.utils.DateUtils;
import com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo;
import org.springframework.stereotype.Service;
@ -94,4 +95,8 @@ public class DcBusiTargetDraftDaynewService extends ServiceImpl<DcBusiTargetDraf
public List<TargetDraftDaynewResVo> selectTargetDraftDaynewList(TargetDraftDaynewReqVo vo){
return baseMapper.selectTargetDraftDaynewList(vo);
}
public List<TargetDraftDaynewAggregateResVo> selectTargetDraftDaynewAggregateList(TargetDraftDaynewReqVo vo){
return baseMapper.selectTargetDraftDaynewAggregateList(vo);
}
}

Loading…
Cancel
Save