Browse Source

bi大屏

develop
bobol 6 months ago
parent
commit
d31e5bb4c7
  1. 18
      lzbi-module/src/main/java/com/lzbi/bi/domain/dto/MultiOrgSomedaySomeParamSummarizingDataDTO.java
  2. 14
      lzbi-module/src/main/java/com/lzbi/bi/domain/dto/SomeOrgSomedaySomeParamSummarizingDataDTO.java
  3. 23
      lzbi-module/src/main/java/com/lzbi/bi/domain/req/ParamSummarizingDataReq.java
  4. 101
      lzbi-module/src/main/java/com/lzbi/bi/mapper/DcBusiDataScreenMainMapper.java
  5. 119
      lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java
  6. 95
      lzbi-module/src/main/resources/mapper/DcBusiDataScreenMainMapper.xml

18
lzbi-module/src/main/java/com/lzbi/bi/domain/dto/MultiOrgSomedaySomeParamSummarizingDataDTO.java

@ -0,0 +1,18 @@
package com.lzbi.bi.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* 多个组织某天参数数据
*/
@Data
public class MultiOrgSomedaySomeParamSummarizingDataDTO {
private Long orgId;
private String orgName;
private BigDecimal value;
}

14
lzbi-module/src/main/java/com/lzbi/bi/domain/dto/SomeOrgSomedaySomeParamSummarizingDataDTO.java

@ -0,0 +1,14 @@
package com.lzbi.bi.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* 某组织某天参数数据
*/
@Data
public class SomeOrgSomedaySomeParamSummarizingDataDTO {
private BigDecimal value;
}

23
lzbi-module/src/main/java/com/lzbi/bi/domain/req/ParamSummarizingDataReq.java

@ -0,0 +1,23 @@
package com.lzbi.bi.domain.req;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class ParamSummarizingDataReq {
@NotNull
private String dateYear;
@NotNull
private String dateMonth;
@NotNull
private String dateDay;
@NotNull
private Long orgId;
private String targetModelCode;
}

101
lzbi-module/src/main/java/com/lzbi/bi/mapper/DcBusiDataScreenMainMapper.java

@ -3,56 +3,89 @@ package com.lzbi.bi.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.bi.domain.DcBusiDataScreenDto;
import com.lzbi.bi.domain.dto.MultiOrgSomedaySomeParamSummarizingDataDTO;
import com.lzbi.bi.domain.dto.SomeOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.dto.SomeOrgSomedaySomeParamSummarizingDataDTO;
import com.lzbi.bi.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.req.ReportDataReq;
import com.lzbi.bi.domain.req.ParamSummarizingDataReq;
import com.lzbi.bi.domain.vo.ChildrenOrgSomedaySomeReportDataVO;
import com.lzbi.bi.domain.vo.MapOrgVO;
import com.lzbi.bi.domain.vo.SomeOrgSomeReportYearlyDataVO;
import com.lzbi.bi.domain.vo.SomeOrgSomedaySomeReportDataVO;
import java.math.BigDecimal;
import java.util.List;
/**
* 资产指标调整单;(dc_busi_target_adjust)表数据库访问层
*
* @author : zhousq
* @date : 2023-11-16
*/
@InterceptorIgnore(tenantLine = "true")
public interface DcBusiDataScreenMainMapper extends BaseMapper<DcBusiDataScreenDto> {
/**
* 查询某个组织某天的某个图表数据
* @param reportDataReq
* @return
*/
SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq);
/**
* 查询下级组织某天的某个图表数据列表
* @param reportDataReq
* @return
*/
List<ChildrenOrgSomedaySomeReportDataVO> selectChildrenOrgSomedaySomeReportDataList(ReportDataReq reportDataReq);
/**
* 查询某组织某天多图表数据列表
* @param reportDataReq
* @return
*/
List<SomeOrgSomedayMultiReportDataDTO> selectSomeOrgSomedayMultiReportDataList(ReportDataReq reportDataReq);
/**
* 查询某类型的下级组织某天的多图表数据列表
* @param reportDataReq
* @return
*/
List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> selectSomeTypeChildrenOrgSomedayMultiReportDataList(ReportDataReq reportDataReq);
/**
* 查询某组织某个图表年度数据列表
* @param reportDataReq
* @return
*/
List<SomeOrgSomeReportYearlyDataVO> selectSomeOrgSomeReportYearlyDataList(ReportDataReq reportDataReq);
/**
* 查询某个组织某天的某个图表数据
*
* @param reportDataReq
* @return
*/
SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq);
/**
* 查询下级组织某天的某个图表数据列表
*
* @param reportDataReq
* @return
*/
List<ChildrenOrgSomedaySomeReportDataVO> selectChildrenOrgSomedaySomeReportDataList(ReportDataReq reportDataReq);
/**
* 查询某组织某天多图表数据列表
*
* @param reportDataReq
* @return
*/
List<SomeOrgSomedayMultiReportDataDTO> selectSomeOrgSomedayMultiReportDataList(ReportDataReq reportDataReq);
/**
* 查询某类型的下级组织某天的多图表数据列表
*
* @param reportDataReq
* @return
*/
List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> selectSomeTypeChildrenOrgSomedayMultiReportDataList(ReportDataReq reportDataReq);
/**
* 查询某组织某个图表年度数据列表
*
* @param reportDataReq
* @return
*/
List<SomeOrgSomeReportYearlyDataVO> selectSomeOrgSomeReportYearlyDataList(ReportDataReq reportDataReq);
/**
* 查询地图上的组织数据列表
*
* @param reportDataReq
* @return
*/
List<MapOrgVO> selectMapOrgList(ReportDataReq reportDataReq);
/**
* 查询某组织某天某参数的汇总数据
* @param paramSummarizingDataReq
* @return
*/
BigDecimal selectSomeOrgSomedaySomeParamSummarizingData(ParamSummarizingDataReq paramSummarizingDataReq);
/**
* 查询多个级组织某天某参数的汇总数据列表
* @param paramSummarizingDataReq
* @return
*/
MultiOrgSomedaySomeParamSummarizingDataDTO selectMultiOrgSomedaySomeParamSummarizingData(ParamSummarizingDataReq paramSummarizingDataReq);
}

119
lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java

@ -8,15 +8,19 @@ 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.SomeOrgSomedaySomeParamSummarizingDataDTO;
import com.lzbi.bi.domain.req.ParamSummarizingDataReq;
import com.lzbi.bi.domain.vo.*;
import com.lzbi.bi.mapper.DcBusiDataScreenMainMapper;
import com.lzbi.bi.mapper.ScreenMockDataMapper;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.constant.ParamsModelCodeConstants;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.enums.ReportNameEnum;
import com.lzbi.bi.domain.dto.SomeOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.req.ReportDataReq;
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;
@ -25,6 +29,9 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -45,8 +52,45 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
private ISysDeptService iSysDeptService;
@Resource
private DcBusiTargetDraftDaynewService dcBusiTargetDraftDaynewService;
@Resource
private ScreenMockDataMapper baseMapper;
// @Resource
// private ScreenMockDataMapper baseMapper;
/**
* 供暖起始日期--月日
*/
private static final String HEATING_START_DATE = "11-01";
/**
* 供暖结束日期--月日
*/
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_END_DATE = "10-31";
private static final String GRMJ = "供热面积";
private static final String LWMJ = "联网面积";
private static final String AQGR = "安全供热";
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 {
SPECIAL_REPORT_LIST = new ArrayList<>();
SPECIAL_REPORT_LIST.add(GRMJ);
SPECIAL_REPORT_LIST.add(LWMJ);
SPECIAL_REPORT_LIST.add(AQGR);
SPECIAL_REPORT_LIST.add(RY);
SPECIAL_REPORT_LIST.add(HRZ);
SPECIAL_REPORT_LIST.add(ZMJ);
SPECIAL_REPORT_LIST.add(ZYH);
}
/**
* 查询某个组织某天的某个图表数据
@ -55,7 +99,61 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
*/
public SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq) {
this.buildReportDataReq(reportDataReq);
return baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq);
if (SPECIAL_REPORT_LIST.contains(reportDataReq.getReportName())) {
return this.selectSpecialReportData(reportDataReq);
} else {
return baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq);
}
}
public SomeOrgSomedaySomeReportDataVO selectSpecialReportData(ReportDataReq reportDataReq) {
ParamSummarizingDataReq paramSummarizingDataReq = new ParamSummarizingDataReq();
BeanUtils.copyBeanProp(paramSummarizingDataReq, reportDataReq);
BigDecimal value = null;
switch (reportDataReq.getReportName()) {
case GRMJ:
paramSummarizingDataReq.setTargetModelCode(ParamsModelCodeConstants.供暖面积);
value = baseMapper.selectSomeOrgSomedaySomeParamSummarizingData(paramSummarizingDataReq);
break;
case LWMJ:
paramSummarizingDataReq.setTargetModelCode(ParamsModelCodeConstants.开栓已执行);
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();
String noHeatingStartDateStr = year + NO_HEATING_START_DATE;
String noHeatingEndDateStr = year + NO_HEATING_END_DATE;
LocalDate noHeatingStartDate = LocalDate.parse(noHeatingStartDateStr, dateTimeFormatter);
LocalDate noHeatingEndDate = LocalDate.parse(noHeatingEndDateStr, dateTimeFormatter);
String heatingStartDateStr = (year - 1) + HEATING_START_DATE;
String heatingEndDateStr = year + HEATING_END_DATE;
LocalDate heatingStartDate = LocalDate.parse(heatingStartDateStr, dateTimeFormatter);
LocalDate heatingEndDate = LocalDate.parse(heatingEndDateStr, dateTimeFormatter);
// 如果在非供暖期,就是获取最大值
if (date.isBefore(noHeatingEndDate) && date.isAfter(noHeatingStartDate)) {
long daysDiff = ChronoUnit.DAYS.between(heatingEndDate, heatingStartDate);
value = BigDecimal.valueOf(daysDiff);
} else {
long daysDiff = ChronoUnit.DAYS.between(date, heatingStartDate);
value = BigDecimal.valueOf(daysDiff);
}
break;
case RY:
// iSysDeptService.selectCompany()
break;
case HRZ:
break;
case ZMJ:
break;
case ZYH:
break;
default:
break;
}
return new SomeOrgSomedaySomeReportDataVO(value, null);
}
/**
@ -139,12 +237,7 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
Map<String, BigDecimal> reportNameValueMap = orgDataList.stream().collect(Collectors.toMap(SomeTypeChildrenOrgSomedayMultiReportDataDTO::getReportName, SomeTypeChildrenOrgSomedayMultiReportDataDTO::getValueResult, (v1, v2) -> v2));
head.add(orgDataList.get(0).getOrgName());
for (int i = 1; i < result.size(); i++) {
int finalI = i;
reportNameValueMap.forEach((reportName, valueResult) -> {
if (result.get(finalI).get(0).equals(reportName)) {
result.get(finalI).add(valueResult);
}
});
result.get(i).add(reportNameValueMap.get(String.valueOf(result.get(i).get(0))));
}
});
}
@ -172,12 +265,7 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
Map<String, BigDecimal> reportNameMaxValueResultMap = dateYearDataList.stream().collect(Collectors.toMap(SomeOrgSomeReportYearlyDataVO::getReportName, SomeOrgSomeReportYearlyDataVO::getMaxValueResult, (v1, v2) -> v2));
head.add(dateYear);
for (int i = 1; i < result.size(); i++) {
int finalI = i;
reportNameMaxValueResultMap.forEach((reportName, maxValueResult) -> {
if (result.get(finalI).get(0).equals(reportName)) {
result.get(finalI).add(maxValueResult);
}
});
result.get(i).add(reportNameMaxValueResultMap.get(String.valueOf(result.get(i).get(0))));
}
}
});
@ -186,6 +274,7 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
}
public List<MapOrgVO> selectMapOrgList(ReportDataReq reportDataReq) {
this.buildChildrenOrgReportDataReq(reportDataReq);
return baseMapper.selectMapOrgList(reportDataReq);
}

95
lzbi-module/src/main/resources/mapper/DcBusiDataScreenMainMapper.xml

@ -444,4 +444,99 @@
t3.report_name,
t1.date_year
</select>
<select id="selectMapOrgList"
parameterType="com.lzbi.bi.domain.req.ReportDataReq"
resultType="com.lzbi.bi.domain.vo.MapOrgVO">
SELECT
t.dept_id AS "orgId",
t.dept_name AS "orgName",
tt.number
FROM
sys_dept t
LEFT JOIN (
SELECT
t5.dept_id,
SUM( t1.val_last ) as "number"
FROM
dc_busi_param_draft_day t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
AND t2.column_type = "P"
AND t2.target_model_code = "P00001"
INNER JOIN dc_base_asset_info t3 ON t2.asset_code = t3.asset_code
INNER JOIN sys_dept t4 ON t3.org_id = t4.dept_id
AND t3.asset_level = "30"
AND t3.asset_type = "1"
INNER JOIN sys_dept t5 ON FIND_IN_SET( t5.dept_id, concat( t4.ancestors, ",", t4.dept_id ) )
WHERE
t5.parent_id = #{orgId}
AND t1.count_date = CONCAT( #{dateYear}, '-', #{dateMonth}, '-', #{dateDay} )
GROUP BY
t5.dept_id
) tt ON t.dept_id = tt.dept_id
WHERE
t.parent_id = #{orgId}
AND t.org_type = #{orgType}
</select>
<select id="selectSomeOrgSomedaySomeParamSummarizingData"
parameterType="com.lzbi.bi.domain.req.ParamSummarizingDataReq"
resultType="java.math.BigDecimal">
SELECT
SUM( t1.val_last ) AS "value"
FROM
dc_busi_param_draft_day t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
AND t2.column_type = "P"
AND t2.target_model_code = #{targetModelCode}
INNER JOIN dc_base_asset_info t3 ON t2.asset_code = t3.asset_code
INNER JOIN sys_dept t4 ON t3.org_id = t4.dept_id
AND t3.asset_level = '30'
AND t3.asset_type = '1'
INNER JOIN sys_dept t5 ON FIND_IN_SET( t5.dept_id, t4.ancestors)
WHERE
t5.dept_id = #{orgId}
AND t1.count_date = CONCAT( #{dateYear}, '-', #{dateMonth}, '-', #{dateDay} )
GROUP BY
t5.dept_id
</select>
<select id="selectMultiOrgSomedaySomeParamSummarizingData"
parameterType="com.lzbi.bi.domain.req.ParamSummarizingDataReq"
resultType="com.lzbi.bi.domain.dto.MultiOrgSomedaySomeParamSummarizingDataDTO">
SELECT
t.dept_id AS "orgId",
t.dept_name AS "orgName",
tt.number
FROM
sys_dept t
LEFT JOIN (
SELECT
t5.dept_id,
SUM( t1.val_last ) AS "number"
FROM
dc_busi_param_draft_day t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
AND t2.column_type = "P"
AND t2.target_model_code = "P00001"
INNER JOIN dc_base_asset_info t3 ON t2.asset_code = t3.asset_code
INNER JOIN sys_dept t4 ON t3.org_id = t4.dept_id
AND t3.asset_level = '30'
AND t3.asset_type = '1'
INNER JOIN sys_dept t5 ON FIND_IN_SET( t5.dept_id, t4.ancestors )
WHERE
t5.dept_id IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
AND t1.count_date = CONCAT( #{dateYear}, '-', #{dateMonth}, '-', #{dateDay} )
GROUP BY
t5.dept_id
) tt ON t.dept_id = tt.dept_id
WHERE
t.dept_id IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save