Browse Source

Merge branch 'dev_data_fusion' into develop

master
sunyuchao 4 years ago
parent
commit
a47dcfe4c5
  1. 8
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/AgenctBasicDataFormDTO.java
  2. 4
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java
  3. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java
  4. 108
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  5. 22
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java
  6. 48
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java
  7. 29
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml

8
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{}
}

4
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

15
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<com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO>
*/
ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List<String> 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);
}

108
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<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
//1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
List<ScreenCustomerAgencyDTO> 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<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
//1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
List<ScreenCustomerAgencyDTO> 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<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
//1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
List<ScreenCustomerAgencyDTO> 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<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
//1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
List<ScreenCustomerAgencyDTO> 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<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
//1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
List<ScreenCustomerAgencyDTO> 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<String> subAgencyIds = indexService.getAgencyByAreaCodeAgencyId(formDTO.getAgencyId(), formDTO.getAreaCode());
if (CollectionUtils.isEmpty(subAgencyIds)) {
subAgencyIds = new ArrayList<>();
}
subAgencyIds.add(formDTO.getAgencyId());
List<FactAgencyGovernDailyEntity> 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<String> subAgencyIds = indexService.getAgencyByAreaCodeAgencyId(formDTO.getAgencyId(), agencyDTO.getAreaCode());
if (CollectionUtils.isEmpty(subAgencyIds)) {
subAgencyIds = new ArrayList<>();
}
subAgencyIds.add(formDTO.getAgencyId());
List<FactAgencyGovernDailyEntity> 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<String> agencyIds = subAgencyList.stream().map(DimAgencyEntity::getId).collect(Collectors.toList());
if (StringUtils.isNotBlank(formDTO.getAreaCode())) {
List<ScreenCustomerAgencyDTO> subAgencies = indexService.getSubAgencyList(formDTO.getAgencyId(), formDTO.getAreaCode());
ScreenCustomerAgencyDTO agencyDTO = indexService.getAgencyInfo(formDTO.getAgencyId());
if (customerRelation.haveSubCustomer(agencyDTO.getCustomerId())) {
List<ScreenCustomerAgencyDTO> 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()));

22
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<com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO>
*/
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<String> getAgencyIdsByAgencyId(String agencyId);
/**
* @Description 查询直属下级组织列表有子客户的按areaCode查没有的按agencyId查
* @author sun
*/
List<ScreenCustomerAgencyDTO> getSubAgencyListByAgency(String agencyId);
}

48
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<String> 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<ScreenCustomerAgencyDTO> 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());
}
}
}

29
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}
</select>
<select id="getAgencyInfo" resultType="com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO">
SELECT
customer_id,
agency_id ,
agency_name,
level,
area_code,
parent_area_code
FROM
SCREEN_CUSTOMER_AGENCY
WHERE
del_flag = '0'
and AGENCY_ID = #{agencyId}
</select>
<select id="getByAgencyId" resultType="com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO">
SELECT
customer_id AS customerId,
agency_id AS agencyId,
agency_name AS agencyName,
level AS level,
area_code AS areaCode,
parent_area_code AS parentAreaCode
FROM
screen_customer_agency
WHERE
del_flag = '0'
AND agency_id = #{agencyId}
</select>
</mapper>
Loading…
Cancel
Save