diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/AgenctBasicDataFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/AgenctBasicDataFormDTO.java index df3e286b57..9f8c5fd1b1 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/AgenctBasicDataFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/AgenctBasicDataFormDTO.java @@ -24,14 +24,6 @@ public class AgenctBasicDataFormDTO implements Serializable { * 日维度Id */ private String dateId; - /** - * 机关级别(社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province) - */ - private String level; - /** - * 行政地区编码 - */ - private String areaCode; public interface Agency extends CustomerClientShowGroup{} } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java index be7ef9bb75..4789d534dd 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java @@ -23,10 +23,6 @@ public class SubAgencyFormDTO implements Serializable { * 日维度Id */ private String dateId; - /** - * 行政地区编码 - */ - private String areaCode; /** * 排序类型字段 * 用户【用户:user 党员:party 居民:resi】 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java index 392ec5991a..878e376bce 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java @@ -67,4 +67,19 @@ public interface EvaluationIndexDao { * @return java.util.List */ ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List agencyIds, @Param("dateId") String dateId); + + /** + * 获取组织信息 + * @author zhaoqifeng + * @date 2021/6/29 13:58 + * @param agencyId + * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO + */ + ScreenCustomerAgencyDTO getAgencyInfo(@Param("agencyId") String agencyId); + + /** + * @Description 查询agencyId对应组织信息 + * @author sun + */ + ScreenCustomerAgencyDTO getByAgencyId(@Param("agencyId") String agencyId); } \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 48bd39d76f..04676609bc 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -19,6 +19,7 @@ import com.epmet.dataaggre.entity.datastats.DimGridEntity; import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; +import com.epmet.dataaggre.service.opercrm.CustomerRelation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -46,6 +47,8 @@ public class DataStatsServiceImpl implements DataStatsService { private DataStatsDao dataStatsDao; @Autowired private EvaluationIndexService indexService; + @Autowired + private CustomerRelation customerRelation; /** @@ -68,10 +71,9 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setDateId(format.format(yesterday)); } - //0.判断level是否有值,有值判断areaCode是否有值,没值直接用agencyId查数据,有值查询不是当前agencyId对应客户的areaCode的下级组织列表 - if(StringUtils.isNotBlank(formDTO.getLevel())&&!"community".equals(formDTO.getLevel())&&StringUtils.isNotBlank(formDTO.getAreaCode())){ - agencyList = indexService.getAgencyByAreaCodeAgencyId(formDTO.getAgencyId(), formDTO.getAreaCode()); - } + //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); + agencyList.add(formDTO.getAgencyId()); agencyList.add(formDTO.getAgencyId()); //1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】 @@ -287,8 +289,8 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setType("user"); } - //1.查询直属下级组织列表,有areaCode的按areaCode查,没有的按agencyId查 - List subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + //1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return resultList; } @@ -425,8 +427,8 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setType("group"); } - //1.查询直属下级组织列表,有areaCode的按areaCode查,没有的按agencyId查 - List subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + //1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return resultList; } @@ -560,8 +562,8 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setType("topic"); } - //1.查询直属下级组织列表,有areaCode的按areaCode查,没有的按agencyId查 - List subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + //1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return resultList; } @@ -749,8 +751,8 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setType("issue"); } - //1.查询直属下级组织列表,有areaCode的按areaCode查,没有的按agencyId查 - List subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + //1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return resultList; } @@ -891,8 +893,8 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setType("project"); } - //1.查询直属下级组织列表,有areaCode的按areaCode查,没有的按agencyId查 - List subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + //1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return resultList; } @@ -1127,40 +1129,39 @@ public class DataStatsServiceImpl implements DataStatsService { SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); formDTO.setDateId(format.format(yesterday)); } - if (OrgConstant.PROVINCE.equals(formDTO.getLevel()) || OrgConstant.CITY.equals(formDTO.getLevel()) || OrgConstant.DISTRICT.equals(formDTO.getLevel())) { - if (StringUtils.isNotBlank(formDTO.getAreaCode())) { + ScreenCustomerAgencyDTO agencyDTO = indexService.getAgencyInfo(formDTO.getAgencyId()); + if (customerRelation.haveSubCustomer(agencyDTO.getCustomerId())) { - List subAgencyIds = indexService.getAgencyByAreaCodeAgencyId(formDTO.getAgencyId(), formDTO.getAreaCode()); - if (CollectionUtils.isEmpty(subAgencyIds)) { - subAgencyIds = new ArrayList<>(); - } - subAgencyIds.add(formDTO.getAgencyId()); - List list = dataStatsDao.getAgencyGovernDaily(subAgencyIds, formDTO.getDateId()); - if (CollectionUtils.isNotEmpty(list)) { - //问题解决总数 - Integer problemResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getProblemResolvedCount).sum(); - //未出小组即未转议题的:话题关闭已解决数 - Integer inGroupTopicResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getInGroupTopicResolvedCount).sum(); - //未出小组即未转议题的:话题关闭无需解决数 - Integer inGroupTopicUnResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getInGroupTopicUnResolvedCount).sum(); - //未出当前网格的,结案项目数 - Integer gridSelfGovernProjectTotal = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getGridSelfGovernProjectTotal).sum(); - //由社区结案的项目总数 - Integer communityClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getCommunityClosedCount).sum(); - //由街道结案的项目总数 - Integer streetClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getStreetClosedCount).sum(); - //由区直部门结案的项目总数 - Integer districtDeptClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getDistrictDeptClosedCount).sum(); - - resultDTO.setProblemResolvedCount(problemResolvedCount); - resultDTO.setGroupSelfGovernRatio(getPercentage(inGroupTopicResolvedCount + inGroupTopicUnResolvedCount, problemResolvedCount)); - resultDTO.setGridSelfGovernRatio(getPercentage(gridSelfGovernProjectTotal, problemResolvedCount)); - resultDTO.setCommunityResolvedRatio(getPercentage(communityClosedCount, problemResolvedCount)); - resultDTO.setStreetResolvedRatio(getPercentage(streetClosedCount, problemResolvedCount)); - resultDTO.setDistrictDeptResolvedRatio(getPercentage(districtDeptClosedCount, problemResolvedCount)); - - return resultDTO; - } + List subAgencyIds = indexService.getAgencyByAreaCodeAgencyId(formDTO.getAgencyId(), agencyDTO.getAreaCode()); + if (CollectionUtils.isEmpty(subAgencyIds)) { + subAgencyIds = new ArrayList<>(); + } + subAgencyIds.add(formDTO.getAgencyId()); + List list = dataStatsDao.getAgencyGovernDaily(subAgencyIds, formDTO.getDateId()); + if (CollectionUtils.isNotEmpty(list)) { + //问题解决总数 + Integer problemResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getProblemResolvedCount).sum(); + //未出小组即未转议题的:话题关闭已解决数 + Integer inGroupTopicResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getInGroupTopicResolvedCount).sum(); + //未出小组即未转议题的:话题关闭无需解决数 + Integer inGroupTopicUnResolvedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getInGroupTopicUnResolvedCount).sum(); + //未出当前网格的,结案项目数 + Integer gridSelfGovernProjectTotal = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getGridSelfGovernProjectTotal).sum(); + //由社区结案的项目总数 + Integer communityClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getCommunityClosedCount).sum(); + //由街道结案的项目总数 + Integer streetClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getStreetClosedCount).sum(); + //由区直部门结案的项目总数 + Integer districtDeptClosedCount = list.stream().mapToInt(FactAgencyGovernDailyEntity ::getDistrictDeptClosedCount).sum(); + + resultDTO.setProblemResolvedCount(problemResolvedCount); + resultDTO.setGroupSelfGovernRatio(getPercentage(inGroupTopicResolvedCount + inGroupTopicUnResolvedCount, problemResolvedCount)); + resultDTO.setGridSelfGovernRatio(getPercentage(gridSelfGovernProjectTotal, problemResolvedCount)); + resultDTO.setCommunityResolvedRatio(getPercentage(communityClosedCount, problemResolvedCount)); + resultDTO.setStreetResolvedRatio(getPercentage(streetClosedCount, problemResolvedCount)); + resultDTO.setDistrictDeptResolvedRatio(getPercentage(districtDeptClosedCount, problemResolvedCount)); + + return resultDTO; } } //1.按日期查询当前组织事件治理指数 @@ -1201,8 +1202,9 @@ public class DataStatsServiceImpl implements DataStatsService { return resultList; } List agencyIds = subAgencyList.stream().map(DimAgencyEntity::getId).collect(Collectors.toList()); - if (StringUtils.isNotBlank(formDTO.getAreaCode())) { - List subAgencies = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode()); + ScreenCustomerAgencyDTO agencyDTO = indexService.getAgencyInfo(formDTO.getAgencyId()); + if (customerRelation.haveSubCustomer(agencyDTO.getCustomerId())) { + List subAgencies = indexService.getSubAgencyList(formDTO.getAgencyId(), agencyDTO.getAreaCode()); agencyIds = subAgencies.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); subAgencyList = subAgencies.stream().map(item -> { DimAgencyEntity entity = new DimAgencyEntity(); @@ -1377,10 +1379,10 @@ public class DataStatsServiceImpl implements DataStatsService { SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); formDTO.setDateId(format.format(yesterday)); } - - if (OrgConstant.PROVINCE.equals(formDTO.getLevel()) || OrgConstant.CITY.equals(formDTO.getLevel()) || OrgConstant.DISTRICT.equals(formDTO.getLevel())) { - if (StringUtils.isNotBlank(formDTO.getAreaCode())) { - ScreenGovernRankDataDailyDTO governData = indexService.getGovernRank(formDTO.getOrgId(), formDTO.getAreaCode(), formDTO.getDateId()); + if (OrgConstant.AGENCY.equals(formDTO.getOrgType())) { + ScreenCustomerAgencyDTO agencyDTO = indexService.getAgencyInfo(formDTO.getOrgId()); + if (customerRelation.haveSubCustomer(agencyDTO.getCustomerId())) { + ScreenGovernRankDataDailyDTO governData = indexService.getGovernRank(formDTO.getOrgId(), agencyDTO.getAreaCode(), formDTO.getDateId()); resultDTO.setGovernRatio(getPercentage(governData.getGovernCount(), governData.getClosedCount())); resultDTO.setResolvedRatio(getPercentage(governData.getResolvedCount(), governData.getClosedCount())); resultDTO.setResponseRatio(getPercentage(governData.getResponseCount(), governData.getTransferCount())); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java index fe6fef6bfc..43be38a84f 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java @@ -49,4 +49,26 @@ public interface EvaluationIndexService { * @return java.util.List */ ScreenGovernRankDataDailyDTO getGovernRank(String agencyId, String areaCode, String dateId); + + /** + * 获取组织信息 + * @author zhaoqifeng + * @date 2021/6/29 13:57 + * @param agencyId + * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO + */ + ScreenCustomerAgencyDTO getAgencyInfo(String agencyId); + + /** + * @Description 根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + * @author sun + */ + List getAgencyIdsByAgencyId(String agencyId); + + /** + * @Description 查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + * @author sun + */ + List getSubAgencyListByAgency(String agencyId); + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java index 96c86d7d53..c9fa3bf7d2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java @@ -11,6 +11,7 @@ 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.service.evaluationindex.EvaluationIndexService; +import com.epmet.dataaggre.service.opercrm.CustomerRelation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -32,6 +33,8 @@ import java.util.List; public class EvaluationIndexServiceImpl implements EvaluationIndexService { @Autowired private EvaluationIndexDao evaluationIndexDao; + @Autowired + private CustomerRelation customerRelation; /** * @Param formDTO @@ -90,4 +93,49 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { return evaluationIndexDao.getGovernRankList(agencyIdList, dateId); } + /** + * 获取组织信息 + * + * @param agencyId + * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO + * @author zhaoqifeng + * @date 2021/6/29 13:57 + */ + @Override + public ScreenCustomerAgencyDTO getAgencyInfo(String agencyId) { + return evaluationIndexDao.getAgencyInfo(agencyId); + } + + /** + * @Description 根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + * @author sun + */ + @Override + public List getAgencyIdsByAgencyId(String agencyId) { + //1.查询agencyId对应组织信息 + ScreenCustomerAgencyDTO dto = evaluationIndexDao.getByAgencyId(agencyId); + //2.判断客户是否存在子客户 + if (!customerRelation.haveSubCustomer(dto.getCustomerId())) { + return new ArrayList<>(); + } + //3.存在子客户的,查询当前组织的areaCode对应的直属下级且不是agencyId对应的客户id的客户组织列表 + return evaluationIndexDao.getAgencyByAreaCodeAgencyId(agencyId, dto.getAreaCode()); + } + + /** + * @Description 查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查 + * @author sun + */ + @Override + public List getSubAgencyListByAgency(String agencyId) { + //1.查询agencyId对应组织信息 + ScreenCustomerAgencyDTO dto = evaluationIndexDao.getByAgencyId(agencyId); + //2.判断客户是否存在子客户 + if (!customerRelation.haveSubCustomer(dto.getCustomerId())) { + return evaluationIndexDao.getSubAgencyList(agencyId, null); + } else { + return evaluationIndexDao.getSubAgencyList(null, dto.getAreaCode()); + } + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml index af8d39f643..b76960a3d2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml @@ -96,5 +96,34 @@ AND ORG_TYPE = 'agency' AND DATE_ID = #{dateId} + + + \ No newline at end of file