Browse Source

bugfix

dev_shibei_match
yinzuomei 4 years ago
parent
commit
6185d0bb72
  1. 42
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java
  2. 19
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java
  3. 32
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java
  4. 17
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java
  5. 26
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java
  6. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java
  7. 11
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java
  8. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java
  9. 85
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
  10. 22
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml

42
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java

@ -0,0 +1,42 @@
package com.epmet.dto.form.demand;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 服务措施分析-柱状图入参
*/
@Data
public class CategoryAnalysisFormDTO implements Serializable {
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "先选择组织或网格", groups = AddUserShowGroup.class)
private String orgId;
@NotBlank(message = "组织或网格的上级", groups = PageListAnalysisFormDTO.AddUserShowGroup.class)
private String pid;
@NotBlank(message = "组织:agency,网格:grid", groups = AddUserShowGroup.class)
private String orgType;
@NotBlank(message = "起止日期不能为空,格式yyyyMMdd", groups = AddUserShowGroup.class)
private String startDateId;
@NotBlank(message = "截止日期不能为空,格式yyyyMMdd", groups = AddUserShowGroup.class)
private String endDateId;
@NotBlank(message = "先选择组织或网格", groups = AddUserInternalGroup.class)
private String cusotmerId;
/**
* orgType=agency时pid拼接上orgId
*/
private String gridPids;
}

19
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.result.demand;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryAnalysisDTO implements Serializable {
private static final long serialVersionUID = 3007202497989446585L;
private String categoryCode;
private String categoryName;
private Integer total;
private List<CategoryAnalysisDetail> detail;
}

32
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java

@ -0,0 +1,32 @@
package com.epmet.dto.result.demand;
import lombok.Data;
import java.io.Serializable;
@Data
public class CategoryAnalysisDetail implements Serializable {
private static final long serialVersionUID = -4606305611297470078L;
/**
* 区域党建单位party_unit
* 社会组织social_org
* 社区自组织community_org
* 志愿者volunteer
* 未完成unfinished
*/
private String legendCode;
/**
* 服务方类型名称
*/
private String legendName;
/**
* 服务方的个数
*/
private Integer totalService;
/**
* 需求个数
*/
private Integer serviceDemandTotal;
}

17
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java

@ -0,0 +1,17 @@
package com.epmet.dto.result.demand;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryAnalysisResDTO implements Serializable {
private static final long serialVersionUID = -3112952115061180189L;
private List<LegendDTO> legend;
private List<CategoryAnalysisDTO> categoryList;
}

26
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result.demand;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 服务措施分析-柱状图
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LegendDTO implements Serializable {
private static final long serialVersionUID = 7205666632591639499L;
/**
* 区域党建单位party_unit
* 社会组织social_org
* 社区自组织community_org
* 志愿者volunteer
* 未完成unfinished
*/
private String legendCode;
private String legendName;
}

14
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java

@ -257,4 +257,18 @@ public class IcUserDemandRecController {
}
return new Result();
}
/**
* 数据分析-服务措施分析-柱状图
*
* @return
*/
@PostMapping("category-analysis")
public Result<CategoryAnalysisResDTO> categoryAnalysis(@LoginUser TokenDto tokenDto,@RequestBody CategoryAnalysisFormDTO formDTO){
formDTO.setCusotmerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,CategoryAnalysisFormDTO.AddUserShowGroup.class,CategoryAnalysisFormDTO.AddUserInternalGroup.class);
return new Result<CategoryAnalysisResDTO>().ok(icUserDemandRecService.categoryAnalysis(formDTO));
}
}

11
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java

@ -21,8 +21,10 @@ 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.entity.IcUserDemandRecEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -65,4 +67,13 @@ public interface IcUserDemandRecDao extends BaseDao<IcUserDemandRecEntity> {
* @return
*/
List<DemandRecResultDTO> pageListAnalysis(PageListAnalysisFormDTO formDTO);
List<CategoryAnalysisDTO> selectListCategoryAnalysisDTO(@Param("firstCategoryList") List<OptionDTO> firstCategoryList,
@Param("customerId") String customerId,
@Param("orgId") String orgId,
@Param("orgType") String orgType,
@Param("gridPids") String gridPids,
@Param("startDateId") String startDateId,
@Param("endDateId") String endDateId);
}

8
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcUserDemandRecDTO;
import com.epmet.dto.form.demand.*;
import com.epmet.dto.result.demand.CategoryAnalysisResDTO;
import com.epmet.dto.result.demand.DemandRecResultDTO;
import com.epmet.dto.result.demand.DemandResearchAnalysisResultDTO;
import com.epmet.dto.result.demand.IcResiUserReportDemandRes;
@ -161,4 +162,11 @@ public interface IcUserDemandRecService extends BaseService<IcUserDemandRecEntit
* @return
*/
PageData<DemandRecResultDTO> pageListAnalysis(PageListAnalysisFormDTO formDTO);
/**
* 数据分析-服务措施分析-柱状图
*
* @return
*/
CategoryAnalysisResDTO categoryAnalysis(CategoryAnalysisFormDTO formDTO);
}

85
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java

@ -45,9 +45,7 @@ import com.epmet.dto.form.demand.*;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.IcResiUserBriefDTO;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.dto.result.demand.DemandRecResultDTO;
import com.epmet.dto.result.demand.DemandResearchAnalysisResultDTO;
import com.epmet.dto.result.demand.IcResiUserReportDemandRes;
import com.epmet.dto.result.demand.*;
import com.epmet.entity.*;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
@ -239,9 +237,9 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
//3、查询志愿者
// 服务方类型:志愿者:volunteer;社会组织:social_org;社区自组织:community_org;区域党建单位:party_unit;
Map<String,String> userInfoMap=new HashMap<>();
List<String> userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toList());
Set<String> userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toSet());
if(CollectionUtils.isNotEmpty(userIdList)){
Result<List<UserBaseInfoResultDTO>> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList);
Result<List<UserBaseInfoResultDTO>> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList));
if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){
throw new RenException("查询志愿者信息异常");
}
@ -654,9 +652,9 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
//3、查询志愿者
// 服务方类型:志愿者:volunteer;社会组织:social_org;社区自组织:community_org;区域党建单位:party_unit;
Map<String,String> userInfoMap=new HashMap<>();
List<String> userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toList());
Set<String> userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toSet());
if(CollectionUtils.isNotEmpty(userIdList)){
Result<List<UserBaseInfoResultDTO>> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList);
Result<List<UserBaseInfoResultDTO>> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList));
if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){
throw new RenException("查询志愿者信息异常");
}
@ -696,6 +694,79 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
return new PageData<>(list, total);
}
/**
* 数据分析-服务措施分析-柱状图
*
* @param formDTO
* @return
*/
@Override
public CategoryAnalysisResDTO categoryAnalysis(CategoryAnalysisFormDTO formDTO) {
//1、一级分类字典,没有分类直接退出
SubCodeFormDTO subCodeFormDTO=new SubCodeFormDTO();
subCodeFormDTO.setCustomerId(formDTO.getCusotmerId());
subCodeFormDTO.setParentCategoryCode(NumConstant.ZERO_STR);
List<OptionDTO> firstCategoryList=demandDictService.querySubCodeList(subCodeFormDTO);
if(CollectionUtils.isEmpty(firstCategoryList)){
return new CategoryAnalysisResDTO(Collections.EMPTY_LIST,Collections.EMPTY_LIST);
}
//2、没有服务类型直接退出
Result<Map<String, String>> serviceTypeRes=adminOpenFeignClient.dictMap(DictTypeEnum.USER_DEMAND_SERVICE_TYPE.getCode());
if(!serviceTypeRes.success()||MapUtils.isEmpty(serviceTypeRes.getData())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"查询服务方类型异常,请检查是否已经配置字典信息");
}
List<LegendDTO> legend=new ArrayList<>();
serviceTypeRes.getData().forEach((code,name)->{
LegendDTO legendDTO=new LegendDTO(code,name);
legend.add(legendDTO);
});
LegendDTO unfinishLegend = new LegendDTO("unfinished", "未完成");
legend.add(unfinishLegend);
// 3、传进来的是组织id的话,查询出全路径
if("agency".equals(formDTO.getOrgType())){
if(NumConstant.ZERO_STR.equals(formDTO.getPid())){
//当前传入的组织id=客户的根组织
formDTO.setGridPids(formDTO.getOrgId());
}else{
//找到当前组织的所有上级,再拼接上自己
Result<CustomerAgencyDTO> customerAgencyDTOResult=govOrgOpenFeignClient.getAgencyById(formDTO.getOrgId());
if(!customerAgencyDTOResult.success()||null==customerAgencyDTOResult.getData()){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById");
}
formDTO.setGridPids(customerAgencyDTOResult.getData().getPids().concat(StrConstant.COLON).concat(formDTO.getOrgId()));
}
}
// 4、查询出有数据的一级分类
// 4、sql计算出detail
List<CategoryAnalysisDTO> haveDemandList=baseDao.selectListCategoryAnalysisDTO(firstCategoryList,
formDTO.getCusotmerId(),
formDTO.getOrgId(),
formDTO.getOrgType(),
formDTO.getGridPids(),
formDTO.getStartDateId(),
formDTO.getEndDateId());
if(!CollectionUtils.isEmpty(haveDemandList)){
for(CategoryAnalysisDTO analysisRes:haveDemandList){
//todo
//List<CategoryAnalysisDetail> detail=
}
}
//构造最后的反参
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;
}
}

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

@ -261,4 +261,26 @@
</if>
order by r.WANT_SERVICE_TIME desc,r.REPORT_TIME asc
</select>
<select id="selectListCategoryAnalysisDTO" parameterType="map" resultType="com.epmet.dto.result.demand.CategoryAnalysisDTO">
<foreach collection="firstCategoryList" item="category" separator=" UNION ALL ">
select
#{category.value} as categoryCode,
#{category.label} as categoryName,
count(m.id) as total
from ic_user_demand_rec m
where m.DEL_FLAG='0'
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(#{category.value},'%')
</foreach>
</select>
</mapper>
Loading…
Cancel
Save