Browse Source

方法模板

master
sunyuchao 4 years ago
parent
commit
b9a5c2d171
  1. 4
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java
  2. 37
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
  3. 31
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java
  4. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java
  5. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java
  6. 104
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  7. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java
  8. 41
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java

4
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java

@ -47,9 +47,9 @@ public class CustomerDataManageFormDTO implements Serializable {
@NotBlank(message = "结束时间不能为空",groups = CustomerDataManageForm.class)
private String endTime;
private Integer pageNo;
private Integer pageNo = 1;
private Integer pageSize;
private Integer pageSize = 20;
/**
* 是否分页true分 false不分

37
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java

@ -0,0 +1,37 @@
package com.epmet.dataaggre.dto.datastats.result;
import lombok.Data;
/**
* @Description 运营情况数据导出-接口返参
* @Auth sun
*/
@Data
public class CustomerDataManageResultDTO {
//组织
private String orgName;
//用户数
private Integer userCount;
//居民数
private Integer residentCount;
//党员数
private Integer partyMemberCount;
//小组数
private Integer groupCount;
//话题数
private Integer topicCount;
//议题数
private Integer issueCount;
//项目数
private Integer projectCount;
//结案项目数
private Integer closedProjectCount;
//巡查人数
private Integer patrolPeopleCount;
//巡查次数
private Integer patrolCount;
//巡查时长
private String patrolDuration;
}

31
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java

@ -0,0 +1,31 @@
package com.epmet.dataaggre.dto.evaluationindex;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author sun
* @Description 根据组织Id判断查询直属下级组织/网格列表组织存在子客户的查询包含子客户组织数据
*/
@Data
public class ScreenAgencyOrGridListDTO implements Serializable {
private static final long serialVersionUID = 6328123559936824470L;
//组织级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city,省级:province)
private String level;
//直属下级组织或网格集合
private List<AgencyGrid> agencyGridList;
@Data
public class AgencyGrid {
//组织id
private String agencyId;
//组织名称
private String agencyName;
//网格Id
private String gridId;
//网格name
private String gridName;
}
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java

@ -230,5 +230,15 @@ public class DataStatsController {
dataStatsService.CustomerDataManage(formDTO,response);
}
/**
* @Param formDTO
* @Description 运营情况数据查询
* @author sun
*/
@PostMapping("governratio")
public Result<List<CustomerDataManageResultDTO>> operateexport(@RequestBody CustomerDataManageFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class);
return new Result<List<CustomerDataManageResultDTO>>().ok(dataStatsService.operateExport(formDTO));
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java

@ -10,6 +10,7 @@ import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;
/**
@ -239,4 +240,11 @@ public interface DataStatsService {
* @date 2021/9/10 3:52 下午
*/
void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception;
/**
* @Description 运营情况数据查询
* @author sun
*/
List<CustomerDataManageResultDTO> operateExport(CustomerDataManageFormDTO formDTO) throws ParseException;
}

104
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -2,50 +2,53 @@
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.constant.OrgConstant;
import com.epmet.dataaggre.dao.datastats.DataStatsDao;
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.constant.OrgConstant;
import com.epmet.dataaggre.dao.datastats.DataStatsDao;
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
import com.epmet.dataaggre.excel.CustomerDataManageExcel;
import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @Author sun
@ -1899,4 +1902,41 @@ public class DataStatsServiceImpl implements DataStatsService {
return s.toString();
}
/**
* @Param formDTO
* @Description 运营情况数据查询
* @author sun
*/
@Override
public List<CustomerDataManageResultDTO> operateExport(CustomerDataManageFormDTO formDTO) throws ParseException {
//1.必要参数校验及处理
if (!"Interval".equals(formDTO.getType()) && StringUtils.isEmpty(formDTO.getStartTime())) {
throw new RenException("请选择开始时间或查询累计值");
}
//入参有开始时间的则需要减去一天
if (StringUtils.isNotBlank(formDTO.getStartTime())) {
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD);
Date date = format.parse(formDTO.getStartTime());
Date yesterday = DateUtils.addDateDays(date, -1);
formDTO.setStartTime(format.format(yesterday));
}
//2.查询组织现在,判断查询下级组织还是网格数据
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId());
if (null == agencyGrid) {
return new ArrayList<>();
}
List<String> idList;
if (!"community".equals(agencyGrid.getLevel())) {
//组织层级用户、群组、话题、议题、项目、巡查数据查询
idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getAgencyId).collect(Collectors.toList());
} else {
//网格层级用户、群组、话题、议题、项目、巡查数据查询
idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getGridId).collect(Collectors.toList());
}
//3.封装数据并返回
return null;
}
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java

@ -2,6 +2,7 @@ package com.epmet.dataaggre.service.evaluationindex;
import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO;
import com.epmet.dataaggre.dto.datastats.result.GovrnRatioResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
@ -79,4 +80,10 @@ public interface EvaluationIndexService {
*/
String selectAgencyNameByAgencyId(String agencyId);
/**
* @Description 根据组织Id判断查询直属下级组织/网格列表组织存在子客户的查询包含子客户组织数据
* @author sun
*/
ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId);
}

41
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java

@ -2,10 +2,12 @@ package com.epmet.dataaggre.service.evaluationindex.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.evaluationindex.EvaluationIndexDao;
import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO;
import com.epmet.dataaggre.dto.datastats.result.GovrnRatioResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
@ -154,4 +156,43 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
return evaluationIndexDao.selectAgencyNameByAgencyId(agencyId);
}
/**
* @Description 根据组织Id判断查询直属下级组织/网格列表组织存在子客户的查询包含子客户组织数据
* @author sun
*/
@Override
public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId) {
ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO();
List<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList = new ArrayList<>();
//1.查询组织信息
ScreenCustomerAgencyDTO dto = evaluationIndexDao.getByAgencyId(agencyId);
if (dto == null) {
log.error(String.format("组织信息不存在,组织Id->%s"), agencyId);
return new ScreenAgencyOrGridListDTO();
}
//2.根据组织级别判断查询直属组织或网格列表
List<ScreenCustomerAgencyDTO> agencyList = new ArrayList<>();
List<ScreenCustomerGridDTO> gridList = new ArrayList<>();
if (!"community".equals(dto.getLevel())) {
//2-1.直属下级组织列表
//2.判断客户是否存在子客户
List<String> list = customerRelation.haveSubCustomer(dto.getCustomerId());
if (!CollectionUtils.isNotEmpty(list)) {
agencyList = evaluationIndexDao.getSubAgencyListByAgency(agencyId, null, null);
} else {
list.add(dto.getCustomerId());
agencyList = evaluationIndexDao.getSubAgencyListByAgency(null, dto.getAreaCode(), list);
}
agencyGridList = ConvertUtils.sourceToTarget(agencyList, ScreenAgencyOrGridListDTO.AgencyGrid.class);
} else {
//2-2.直属下级网格列表
gridList = evaluationIndexDao.getSubGridList(agencyId);
agencyGridList = ConvertUtils.sourceToTarget(gridList, ScreenAgencyOrGridListDTO.AgencyGrid.class);
}
resultDTO.setLevel(dto.getLevel());
resultDTO.setAgencyGridList(agencyGridList);
return resultDTO;
}
}

Loading…
Cancel
Save