Browse Source

test

dev_shibei_match
yinzuomei 4 years ago
parent
commit
a021aefa03
  1. 11
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java
  2. 13
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java
  3. 52
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
  4. 81
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml

11
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;
}

13
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<IcUserDemandRecEntity> {
List<DemandRecResultDTO> pageListAnalysis(PageListAnalysisFormDTO formDTO);
List<CategoryAnalysisDetail> 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<CategoryAnalysisDTO> selectListCategoryAnalysisDTO(@Param("firstCategoryList") List<OptionDTO> firstCategoryList,
@Param("customerId") String customerId,
@Param("orgId") String orgId,

52
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<IcUserDemandRecDao, IcUserDemandRecEntity> implements IcUserDemandRecService {
@Autowired
@ -722,6 +725,8 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
});
LegendDTO unfinishLegend = new LegendDTO("unfinished", "未完成");
legend.add(unfinishLegend);
log.info("阶段性胜利1:"+ JSON.toJSONString(legend));
// 3、传进来的是组织id的话,查询出全路径
if("agency".equals(formDTO.getOrgType())){
if(NumConstant.ZERO_STR.equals(formDTO.getPid())){
@ -737,8 +742,18 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
}
}
// 4、查询出有数据的一级分类
// 4、sql计算出detail
//4、构造最后的反参
List<CategoryAnalysisDTO> 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<CategoryAnalysisDTO> haveDemandList=baseDao.selectListCategoryAnalysisDTO(firstCategoryList,
formDTO.getCusotmerId(),
formDTO.getOrgId(),
@ -747,25 +762,32 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
formDTO.getStartDateId(),
formDTO.getEndDateId());
if(!CollectionUtils.isEmpty(haveDemandList)){
for(CategoryAnalysisDTO analysisRes:haveDemandList){
//todo
//List<CategoryAnalysisDetail> detail=
log.info("阶段性胜利3:"+ JSON.toJSONString(haveDemandList));
Map<String, CategoryAnalysisDTO> 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<CategoryAnalysisDTO> 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<CategoryAnalysisDetail> constructDefaultDetail(List<LegendDTO> legend) {
List<CategoryAnalysisDetail> l = new ArrayList<>();
legend.forEach(legendDTO -> {
CategoryAnalysisDetail d = ConvertUtils.sourceToTarget(legendDTO, CategoryAnalysisDetail.class);
d.setServiceDemandTotal(NumConstant.ZERO);
d.setTotalService(NumConstant.ZERO);
});
return l;
}

81
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml

@ -263,12 +263,29 @@
</select>
<select id="selectListCategoryAnalysisDTO" parameterType="map" resultType="com.epmet.dto.result.demand.CategoryAnalysisDTO">
<resultMap id="CategoryAnalysisDTOMap" type="com.epmet.dto.result.demand.CategoryAnalysisDTO">
<result property="categoryCode" column="category_code"/>
<result property="categoryName" column="category_name"/>
<result property="total" column="TOTAL"/>
<collection property="detail" ofType="com.epmet.dto.result.demand.CategoryAnalysisDetail"
column="{categoryCode=category_code, orgType=org_type,orgId=org_id,gridPids=grid_pids,customerId=customer_id,startDateId=start_date_id,endDateId=end_date_id}"
select="com.epmet.dao.IcUserDemandRecDao.selectDetail">
</collection>
</resultMap>
<select id="selectListCategoryAnalysisDTO" parameterType="map" resultMap="CategoryAnalysisDTOMap">
<foreach collection="firstCategoryList" item="category" separator=" UNION ALL ">
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') &gt;= #{startDateId}
and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') &lt;= #{endDateId}
and m.CATEGORY_CODE like concat(#{category.value},'%')
and m.status !='canceled'
</foreach>
</select>
<select id="selectDetail" parameterType="map" resultType="com.epmet.dto.result.demand.CategoryAnalysisDetail">
select
#{categoryCode} as categoryCode,
s.SERVICE_TYPE as legendCode,
(
case when s.SERVICE_TYPE='volunteer' then '志愿者'
when s.SERVICE_TYPE='social_org' then '社会组织'
when s.SERVICE_TYPE='community_org' then '社区自组织'
when s.SERVICE_TYPE='party_unit' then '区域化党建单位'
end
)as legendName,
count(s.DEMAND_REC_ID) as serviceDemandTotal,
count(distinct s.SERVER_ID) as totalService
from ic_user_demand_service s
inner join ic_user_demand_rec m
on(s.DEMAND_REC_ID=m.ID)
where s.DEL_FLAG='0'
and m.DEL_FLAG='0'
and m.`STATUS`='finished'
and m.CUSTOMER_ID=#{customerId}
<if test="null != orgType and orgType == 'grid' ">
and m.GRID_ID=#{orgId}
</if>
<if test="null != orgType and orgType == 'agency' ">
and m.GRID_PIDS like concat(#{gridPids},'%')
</if>
and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') &gt;= #{startDateId}
and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') &lt;= #{endDateId}
and m.CATEGORY_CODE like concat(#{categoryCode},'%')
group by s.SERVICE_TYPE
union all
select
#{categoryCode} as categoryCode,
'unfinished' as legendCode,
'未完成' as legendName,
count(m.id) as serviceDemandTotal,
'0' as totalService
from ic_user_demand_rec m
where m.DEL_FLAG='0'
and m.`STATUS`!='finished'
and m.STATUS !='canceled'
and m.CUSTOMER_ID=#{customerId}
<if test="null != orgType and orgType == 'grid' ">
and m.GRID_ID=#{orgId}
</if>
<if test="null != orgType and orgType == 'agency' ">
and m.GRID_PIDS like concat(#{gridPids},'%')
</if>
and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') &gt;= #{startDateId}
and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') &lt;= #{endDateId}
and m.CATEGORY_CODE like concat(#{categoryCode},'%')
</select>
</mapper>
Loading…
Cancel
Save