From 758e107251de0e1636df5136cac1f2b51ea1b7e1 Mon Sep 17 00:00:00 2001 From: eric777 Date: Fri, 2 Feb 2024 15:53:10 +0800 Subject: [PATCH] =?UTF-8?q?jiahan.wu[CR]=20=E9=9B=86=E5=9B=A2=E5=A4=A7?= =?UTF-8?q?=E5=B1=8F=E7=83=AD=E5=A5=BD=E7=8E=87=E5=92=8C=E7=85=A4=E8=80=97?= =?UTF-8?q?=E7=8E=87=E6=8E=92=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DcBusiDataScreenMainService.java | 33 ++++-- .../domain/vo/TargetDraftDayRangeResVo.java | 26 +++++ .../mapper/DcBusiTargetDraftDaynewMapper.java | 3 +- .../DcBusiTargetDraftDaynewService.java | 16 +-- .../asset/DcBusiTargetDraftDaynewMapper.xml | 101 +++++++++--------- 5 files changed, 111 insertions(+), 68 deletions(-) create mode 100644 lzbi-module/src/main/java/com/lzbi/draft/domain/vo/TargetDraftDayRangeResVo.java diff --git a/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java b/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java index 0e7c17d..ecd47c7 100644 --- a/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java +++ b/lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java @@ -1,9 +1,11 @@ package com.lzbi.bi.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; 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.ReportNameEnum; 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.TargetDraftDaynewResVo; import com.lzbi.draft.service.DcBusiTargetDraftDaynewService; @@ -27,10 +30,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -315,8 +315,8 @@ public class DcBusiDataScreenMainService extends ServiceImpl getHeatingPeriodData(TargetDraftDaynewReqVo vo){ - List res = Lists.newArrayList(); + public List getHeatingPeriodData(TargetDraftDaynewReqVo vo){ + List res = Lists.newArrayList(); if (!HeatingPeriodEnum.HEATING_ALL_PERIOD.getMonths().contains(Integer.parseInt(vo.getDateMonth()))) { return res; } @@ -332,7 +332,26 @@ public class DcBusiDataScreenMainService extends ServiceImpl list = dcBusiTargetDraftDaynewService.selectTargetDraftDaynewRangeList(vo); + List depts = sysDepts.stream().filter(x -> list.stream().map(TargetDraftDayRangeResVo::getCname).distinct().collect(Collectors.toList()).contains(x.getDeptName())).collect(Collectors.toList()); + List 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; } } \ No newline at end of file diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/TargetDraftDayRangeResVo.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/TargetDraftDayRangeResVo.java new file mode 100644 index 0000000..ca485da --- /dev/null +++ b/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; + +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java index 5fb52e5..595a27d 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java +++ b/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.lzbi.bill.domain.DcBusiTargetInputMaster; 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.TargetDraftDaynewReqVo; import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo; @@ -92,7 +93,7 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper selectTargetDraftDaynewList(TargetDraftDaynewReqVo vo); - List selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo); + List selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo); List selectTargetDraftDaynewAggregateList(TargetDraftDaynewReqVo vo); } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java index 21b1ea5..13ea433 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java @@ -1,17 +1,17 @@ package com.lzbi.draft.service; -import java.util.List; -import java.util.Map; - +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.TargetDraftDaynewReqVo; 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.baomidou.mybatisplus.extension.service.IService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.List; /** * 指标数据底稿日-新结构Service业务层处理 * @@ -98,7 +98,7 @@ public class DcBusiTargetDraftDaynewService extends ServiceImpl selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo){ + public List selectTargetDraftDaynewRangeList(TargetDraftDaynewReqVo vo){ return baseMapper.selectTargetDraftDaynewRangeList(vo); } diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml index 8482bff..f85cd60 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml +++ b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml @@ -322,62 +322,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + 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 - d.organize_name , - c.report_name , - d.value_result , - m.target_unit,CONCAT(d.date_year, '-', d.date_month, '-' , d.date_day) as cdate + max(CONCAT( date_year , date_month , date_day)) max_date, + target_model_code, + organize_id from - dc_busi_target_draft_daynew d, - dc_busi_report_target_config c, - dc_base_target_model m, - ( - select - max(CONCAT( date_year , date_month , date_day)) max_date, - target_model_code, - organize_id - from - dc_busi_target_draft_daynew - where - organize_id in - - #{orgId} - - and CONCAT(date_year , date_month , date_day) >= #{beginDate} - and CONCAT(date_year , date_month , date_day) <= #{endDate} - 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 - - #{orgId} - - and asset_level = #{assetLevel} - and asset_type = #{assetType} - group by org_id - ) a + dc_busi_target_draft_daynew + where + organize_id in + + #{orgId} + + and CONCAT(date_year , date_month , date_day) >= #{beginDate} + and CONCAT(date_year , date_month , date_day) <= #{endDate} + 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 - 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 - - #{reportName} + org_id in + + #{orgId} - order by md.max_date - )t group by cdate + and asset_level = #{assetLevel} + 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 + + #{reportName} + + order by md.max_date