Browse Source

jiahan.wu[CR] 集团大屏热好率和煤耗率排行

develop
eric777 9 months ago
parent
commit
758e107251
  1. 33
      lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java
  2. 26
      lzbi-module/src/main/java/com/lzbi/draft/domain/vo/TargetDraftDayRangeResVo.java
  3. 3
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java
  4. 16
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java
  5. 101
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml

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

@ -1,9 +1,11 @@
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.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil; 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;
@ -18,6 +20,7 @@ import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.enums.HeatingPeriodEnum; 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.common.utils.StringUtils;
import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo;
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.service.DcBusiTargetDraftDaynewService; import com.lzbi.draft.service.DcBusiTargetDraftDaynewService;
@ -27,10 +30,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -315,8 +315,8 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
return baseMapper.selectSquareGroup(qdate); return baseMapper.selectSquareGroup(qdate);
} }
public List<Map> getHeatingPeriodData(TargetDraftDaynewReqVo vo){ public List<TargetDraftDayRangeResVo> getHeatingPeriodData(TargetDraftDaynewReqVo vo){
List<Map> res = Lists.newArrayList(); List<TargetDraftDayRangeResVo> res = Lists.newArrayList();
if (!HeatingPeriodEnum.HEATING_ALL_PERIOD.getMonths().contains(Integer.parseInt(vo.getDateMonth()))) { if (!HeatingPeriodEnum.HEATING_ALL_PERIOD.getMonths().contains(Integer.parseInt(vo.getDateMonth()))) {
return res; return res;
} }
@ -332,7 +332,26 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
} }
vo.setBeginDate(StringUtils.join(dateYear, "1101")).setAssetType("0").setAssetLevel("10").setOrgIds(orgIds) vo.setBeginDate(StringUtils.join(dateYear, "1101")).setAssetType("0").setAssetLevel("10").setOrgIds(orgIds)
.setEndDate(StringUtils.join(vo.getDateYear(),vo.getDateMonth(),vo.getDateDay())); .setEndDate(StringUtils.join(vo.getDateYear(),vo.getDateMonth(),vo.getDateDay()));
res = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewRangeList(vo); 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; return res;
} }
} }

26
lzbi-module/src/main/java/com/lzbi/draft/domain/vo/TargetDraftDayRangeResVo.java

@ -0,0 +1,26 @@
package com.lzbi.draft.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class TargetDraftDayRangeResVo {
private String cname;
private String cdate;
private BigDecimal valueResult = BigDecimal.ZERO;
private String cut;
}

3
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java

@ -3,6 +3,7 @@ package com.lzbi.draft.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.bill.domain.DcBusiTargetInputMaster; import com.lzbi.bill.domain.DcBusiTargetInputMaster;
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew; import com.lzbi.draft.domain.DcBusiTargetDraftDaynew;
import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo; 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;
@ -92,7 +93,7 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper<DcBusiTargetDr
List<TargetDraftDaynewResVo> selectTargetDraftDaynewList(TargetDraftDaynewReqVo vo); List<TargetDraftDaynewResVo> selectTargetDraftDaynewList(TargetDraftDaynewReqVo vo);
List<Map> selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo); List<TargetDraftDayRangeResVo> selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo);
List<TargetDraftDaynewAggregateResVo> selectTargetDraftDaynewAggregateList(TargetDraftDaynewReqVo vo); List<TargetDraftDaynewAggregateResVo> selectTargetDraftDaynewAggregateList(TargetDraftDaynewReqVo vo);
} }

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

@ -1,17 +1,17 @@
package com.lzbi.draft.service; package com.lzbi.draft.service;
import java.util.List; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.common.utils.DateUtils; import com.lzbi.common.utils.DateUtils;
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew;
import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo; 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 org.springframework.stereotype.Service;
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew;
import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper; import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper;
import com.baomidou.mybatisplus.extension.service.IService; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/** /**
* 指标数据底稿日-新结构Service业务层处理 * 指标数据底稿日-新结构Service业务层处理
* *
@ -98,7 +98,7 @@ public class DcBusiTargetDraftDaynewService extends ServiceImpl<DcBusiTargetDraf
return baseMapper.selectTargetDraftDaynewList(vo); return baseMapper.selectTargetDraftDaynewList(vo);
} }
public List<Map> selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo){ public List<TargetDraftDayRangeResVo> selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo){
return baseMapper.selectTargetDraftDaynewRangeList(vo); return baseMapper.selectTargetDraftDaynewRangeList(vo);
} }

101
lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml

@ -322,62 +322,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectTargetDraftDaynewRangeList" parameterType="com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo" resultType="java.util.HashMap"> <select id="selectTargetDraftDaynewRangeList" parameterType="com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo" resultType="com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo">
select GROUP_CONCAT(organize_name) as cname,GROUP_CONCAT(value_result) as cut, cdate from ( select
d.organize_name as cname,
d.value_result as value_result,
CONCAT(d.date_year, '-', d.date_month, '-' , d.date_day) as cdate
from
dc_busi_target_draft_daynew d,
dc_busi_report_target_config c,
dc_base_target_model m,
(
select select
d.organize_name , max(CONCAT( date_year , date_month , date_day)) max_date,
c.report_name , target_model_code,
d.value_result , organize_id
m.target_unit,CONCAT(d.date_year, '-', d.date_month, '-' , d.date_day) as cdate
from from
dc_busi_target_draft_daynew d, dc_busi_target_draft_daynew
dc_busi_report_target_config c, where
dc_base_target_model m, organize_id in
( <foreach item="orgId" collection="orgIds" open="(" separator="," close=")">
select #{orgId}
max(CONCAT( date_year , date_month , date_day)) max_date, </foreach>
target_model_code, and CONCAT(date_year , date_month , date_day) &gt;= #{beginDate}
organize_id and CONCAT(date_year , date_month , date_day) &lt;= #{endDate}
from group by
dc_busi_target_draft_daynew target_model_code,
where organize_id,date_year , date_month , date_day
organize_id in ) md,
<foreach item="orgId" collection="orgIds" open="(" separator="," close=")"> (
#{orgId} select
</foreach> max(asset_code) asset_code
and CONCAT(date_year , date_month , date_day) &gt;= #{beginDate} from
and CONCAT(date_year , date_month , date_day) &lt;= #{endDate} dc_base_asset_info
group by
target_model_code,
organize_id,date_year , date_month , date_day
) md,
(
select
max(asset_code) asset_code
from
dc_base_asset_info
where
org_id in
<foreach item="orgId" collection="orgIds" open="(" separator="," close=")">
#{orgId}
</foreach>
and asset_level = #{assetLevel}
and asset_type = #{assetType}
group by org_id
) a
where where
d.asset_code = a.asset_code org_id in
and CONCAT(d.date_year , d.date_month , d.date_day) = md.max_date <foreach item="orgId" collection="orgIds" open="(" separator="," close=")">
and d.target_model_code = md.target_model_code #{orgId}
and d.organize_id = md.organize_id
and d.target_model_code = c.target_model_code
and d.target_model_code = m.target_model_code
and c.report_name in
<foreach item="reportName" collection="reportNames" open="(" separator="," close=")">
#{reportName}
</foreach> </foreach>
order by md.max_date and asset_level = #{assetLevel}
)t group by cdate and asset_type = #{assetType}
group by org_id
) a
where
d.asset_code = a.asset_code
and CONCAT(d.date_year , d.date_month , d.date_day) = md.max_date
and d.target_model_code = md.target_model_code
and d.organize_id = md.organize_id
and d.target_model_code = c.target_model_code
and d.target_model_code = m.target_model_code
and c.report_name in
<foreach item="reportName" collection="reportNames" open="(" separator="," close=")">
#{reportName}
</foreach>
order by md.max_date
</select> </select>
<select id="selectTargetDraftDaynewAggregateList" parameterType="com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo" resultType="com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo"> <select id="selectTargetDraftDaynewAggregateList" parameterType="com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo" resultType="com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo">

Loading…
Cancel
Save