From a021aefa0327ad260fb377cbb87eed45a5140e00 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Sat, 11 Dec 2021 11:09:25 +0800 Subject: [PATCH] test --- .../dto/result/demand/CategoryDetailDTO.java | 11 +++ .../com/epmet/dao/IcUserDemandRecDao.java | 13 ++- .../impl/IcUserDemandRecServiceImpl.java | 52 ++++++++---- .../resources/mapper/IcUserDemandRecDao.xml | 81 ++++++++++++++++++- 4 files changed, 134 insertions(+), 23 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java new file mode 100644 index 0000000000..9e2802362a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java @@ -0,0 +1,11 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CategoryDetailDTO extends CategoryAnalysisDetail implements Serializable { + private static final long serialVersionUID = 4459219163308113201L; + private String categoryCode; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java index 299576cfcf..1dfaf2cb85 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java @@ -21,10 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.demand.IcResiUserDemandFromDTO; import com.epmet.dto.form.demand.PageListAnalysisFormDTO; import com.epmet.dto.form.demand.UserDemandPageFormDTO; -import com.epmet.dto.result.demand.CategoryAnalysisDTO; -import com.epmet.dto.result.demand.DemandRecResultDTO; -import com.epmet.dto.result.demand.IcResiUserReportDemandRes; -import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.demand.*; import com.epmet.entity.IcUserDemandRecEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -69,6 +66,14 @@ public interface IcUserDemandRecDao extends BaseDao { List pageListAnalysis(PageListAnalysisFormDTO formDTO); + List selectDetail(@Param("categoryCode") String categoryCode, + @Param("orgType") String orgType, + @Param("orgId") String orgId, + @Param("gridPids") String gridPids, + @Param("customerId") String customerId, + @Param("startDateId") String startDateId, + @Param("endDateId") String endDateId); + List selectListCategoryAnalysisDTO(@Param("firstCategoryList") List firstCategoryList, @Param("customerId") String customerId, @Param("orgId") String orgId, diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 8a8e9280af..89d464e3fe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -54,6 +55,7 @@ import com.epmet.service.IcResiDemandDictService; import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -71,6 +73,7 @@ import java.util.stream.Collectors; * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-19 */ +@Slf4j @Service public class IcUserDemandRecServiceImpl extends BaseServiceImpl implements IcUserDemandRecService { @Autowired @@ -722,6 +725,8 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl list=new ArrayList<>(); + // firstCategoryList是所有的一级分类字典 + firstCategoryList.forEach(firstCategory->{ + CategoryAnalysisDTO categoryAnalysisDTO=new CategoryAnalysisDTO(firstCategory.getValue(),firstCategory.getLabel(),NumConstant.ZERO,Collections.EMPTY_LIST); + categoryAnalysisDTO.setDetail(constructDefaultDetail(legend)); + list.add(categoryAnalysisDTO); + }); + + log.info("阶段性胜利2:"+ JSON.toJSONString(list)); + + // 5、查询出有数据的一级分类,sql计算出detail List haveDemandList=baseDao.selectListCategoryAnalysisDTO(firstCategoryList, formDTO.getCusotmerId(), formDTO.getOrgId(), @@ -747,25 +762,32 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl detail= + log.info("阶段性胜利3:"+ JSON.toJSONString(haveDemandList)); + Map map = haveDemandList.stream().filter(temp -> CollectionUtils.isNotEmpty(temp.getDetail())).collect(Collectors.toMap(CategoryAnalysisDTO::getCategoryCode, dto -> dto)); + if(MapUtils.isNotEmpty(map)){ + for(CategoryAnalysisDTO result:list){ + if (map.containsKey(result.getCategoryCode()) && null != map.get(result.getCategoryCode())) { + result.setDetail(map.get(result.getCategoryCode()).getDetail()); + } + } } } - - //构造最后的反参 - List list=new ArrayList<>(); - // firstCategoryList是所有的一级分类字典 - firstCategoryList.forEach(firstCategory->{ - CategoryAnalysisDTO categoryAnalysisDTO=new CategoryAnalysisDTO(firstCategory.getValue(),firstCategory.getLabel(),NumConstant.ZERO,Collections.EMPTY_LIST); - list.add(categoryAnalysisDTO); - }); - + //返回结果,也不知道对不对 CategoryAnalysisResDTO result=new CategoryAnalysisResDTO(); result.setLegend(legend); result.setCategoryList(list); - return null; + return result; + } + + private List constructDefaultDetail(List legend) { + List l = new ArrayList<>(); + legend.forEach(legendDTO -> { + CategoryAnalysisDetail d = ConvertUtils.sourceToTarget(legendDTO, CategoryAnalysisDetail.class); + d.setServiceDemandTotal(NumConstant.ZERO); + d.setTotalService(NumConstant.ZERO); + }); + return l; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml index ffc3aa454f..eff843c279 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml @@ -263,12 +263,29 @@ - select - #{category.value} as categoryCode, - #{category.label} as categoryName, - count(m.id) as total + #{category.value} as category_code, + #{category.label} as category_name, + count(m.id) as TOTAL, + #{orgType} as org_type, + #{orgId} as org_id, + #{gridPids} as grid_pids, + #{customerId} as customer_id, + #{startDateId} as start_date_id, + #{endDateId} as end_date_id from ic_user_demand_rec m where m.DEL_FLAG='0' and m.CUSTOMER_ID=#{customerId} @@ -281,6 +298,62 @@ and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') >= #{startDateId} and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') <= #{endDateId} and m.CATEGORY_CODE like concat(#{category.value},'%') + and m.status !='canceled' + + \ No newline at end of file