Browse Source

党员大屏数据抽取

dev_shibei_match
zxc 5 years ago
parent
commit
3426d3bf6d
  1. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  2. 12
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/ScreenConstant.java
  3. 132
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/PartyBaseInfoFormDTO.java
  4. 35
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/CustomerAgencyInfoResultDTO.java
  5. 51
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyMemberInfoResultDTO.java
  6. 35
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/UserCountResultDTO.java
  7. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCpcBaseDataDao.java
  8. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  9. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java
  10. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java
  11. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java
  12. 211
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java
  13. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCpcBaseDataService.java
  14. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  15. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCpcBaseDataServiceImpl.java
  16. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  17. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java
  18. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  19. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/FactParticipationUserAgencyDailyService.java
  20. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/FactParticipationUserGridDailyService.java
  21. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/FactParticipationUserAgencyDailyServiceImpl.java
  22. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/FactParticipationUserGridDailyServiceImpl.java
  23. 68
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCpcBaseDataDao.xml
  24. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  25. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml
  26. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml
  27. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java

@ -31,8 +31,11 @@ public interface NumConstant {
int FOURTEEN=14;
int TWENTY = 20;
int THIRTY = 30;
int THIRTY_ONE = 31;
int FORTY = 40;
int FORTY_ONE = 41;
int FIFTY = 50;
int FIFTY_ONE = 51;
int SIXTY = 60;
int ONE_HUNDRED = 100;
int ONE_THOUSAND = 1000;

12
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/ScreenConstant.java

@ -8,10 +8,22 @@ public interface ScreenConstant {
String COMMUNITY = "community";
String STREET = "street";
String DISTRICT = "district";
String CITY = "city";
String PROVINCE = "province";
String LEVEL = "level";
String STR_NULL = "";
String ENGLISH_COMMA = ",";
String GRID = "grid";
String AGENCY = "agency";
}

132
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/PartyBaseInfoFormDTO.java

@ -0,0 +1,132 @@
package com.epmet.dto.extract.form;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/9/22 3:19 下午
*/
@Data
public class PartyBaseInfoFormDTO implements Serializable {
private static final long serialVersionUID = 1685776533893300943L;
/**
* ID 主键
*/
private String id;
/**
* 客户Id
*/
private String customerId;
/**
* 组织类别 agency组织部门department网格grid
*/
private String orgType;
/**
* 组织Id 可以为网格机关id
*/
private String orgId;
/**
* 上级组织Id
*/
private String parentId;
/**
* 组织名称
*/
private String orgName;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* 注册用户数
*/
private Integer registerUserCount;
/**
* 群众用户数
*/
private Integer resiTotal;
/**
* 注册党员数
*/
private Integer partyMemberCount;
/**
* 小于20岁的党员总人数
*/
private Integer ageLevel1;
/**
* 20-30岁的党员总人数
*/
private Integer ageLevel2;
/**
* 31-40岁的党员总人数
*/
private Integer ageLevel3;
/**
* 41-50岁的党员总人数
*/
private Integer ageLevel4;
/**
* 51-60岁的党员总人数
*/
private Integer ageLevel5;
/**
* 60+岁的党员总人数
*/
private Integer ageLevel6;
/**
* 删除标识 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
public PartyBaseInfoFormDTO() {
this.registerUserCount = NumConstant.ZERO;
this.resiTotal = NumConstant.ZERO;
this.partyMemberCount = NumConstant.ZERO;
this.ageLevel1 = NumConstant.ZERO;
this.ageLevel2 = NumConstant.ZERO;
this.ageLevel3 = NumConstant.ZERO;
this.ageLevel4 = NumConstant.ZERO;
this.ageLevel5 = NumConstant.ZERO;
this.ageLevel6 = NumConstant.ZERO;
this.delFlag = NumConstant.ZERO_STR;
this.revision = NumConstant.ZERO;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

35
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/CustomerAgencyInfoResultDTO.java

@ -0,0 +1,35 @@
package com.epmet.dto.extract.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/9/22 4:21 下午
*/
@Data
public class CustomerAgencyInfoResultDTO implements Serializable {
private static final long serialVersionUID = -584952326059903779L;
/**
* 机关ID
*/
private String agencyId;
/**
* 机关名称
*/
private String agencyName;
/**
* 机关父级ID
*/
private String pid;
/**
* 机关级别
*/
private String level;
}

51
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyMemberInfoResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.extract.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author zxc
* @DateTime 2020/9/22 5:23 下午
*/
@Data
public class PartyMemberInfoResultDTO implements Serializable {
private static final long serialVersionUID = 6591845785373556485L;
/**
* 网格ID
*/
private String gridId;
/**
* 机关ID
*/
private String agencyId;
/**
* 父级ID
*/
private String parentId;
/**
* 生日
*/
private Date birthday;
/**
* 年龄
*/
private Integer age;
/**
* 网格名称
*/
private String gridName;
/**
* 机关名称
*/
private String agencyName;
}

35
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/UserCountResultDTO.java

@ -0,0 +1,35 @@
package com.epmet.dto.extract.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/9/23 9:54 上午
*/
@Data
public class UserCountResultDTO implements Serializable {
private static final long serialVersionUID = -6349371693110337172L;
/**
* 群众用户数
*/
private Integer resiTotal;
/**
* 注册用户数
*/
private Integer registerUserCount;
/**
* 注册党员数
*/
private Integer partyMemberCount;
/**
* 网格ID / 机关ID
*/
private String orgId;
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCpcBaseDataDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.form.PartyBaseInfoFormDTO;
import com.epmet.dto.screencoll.form.CpcBaseDataFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCpcBaseDataEntity;
import org.apache.ibatis.annotations.Mapper;
@ -55,4 +56,22 @@ public interface ScreenCpcBaseDataDao extends BaseDao<ScreenCpcBaseDataEntity> {
* @Date 10:52 2020-08-18
**/
void batchInsertCpcBaseData(@Param("list") List<CpcBaseDataFormDTO> list, @Param("customerId")String customerId);
/**
* @Description 插入党员基本信息
* @param baseInfos
* @author zxc
* @date 2020/9/22 3:28 下午
*/
void insertPartyBaseInfo(@Param("baseInfos") List<PartyBaseInfoFormDTO> baseInfos);
/**
* @Description 删除旧的党员基本信息
* @param customerId
* @param dateId
* @param orgIds
* @author zxc
* @date 2020/9/22 3:28 下午
*/
Integer deleteOldPartyBaseInfo(@Param("customerId") String customerId,@Param("dateId") String dateId,@Param("orgIds")List<String> orgIds);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -120,6 +121,14 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/
List<TreeResultDTO> selectSubAgencyList(@Param("pids") String pids);
/**
* @Description 查询客户下所有机关ID
* @param customerId
* @author zxc
* @date 2020/9/22 4:06 下午
*/
List<CustomerAgencyInfoResultDTO> selectAllAgencyId(@Param("customerId") String customerId);
ScreenCustomerAgencyEntity getLastAddedAgency();
ScreenCustomerAgencyEntity getLastUpdatedAgency();

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.stats;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.PartyMemberInfoResultDTO;
import com.epmet.dto.stats.form.DimCustomerPartyMemberFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import com.epmet.entity.stats.DimCustomerPartymemberEntity;
@ -60,4 +61,13 @@ public interface DimCustomerPartymemberDao extends BaseDao<DimCustomerPartymembe
* @Date 2020/9/18 9:00
**/
List<FactIndexPartyAblityCpcMonthlyEntity> selectPartyMemberList(String customerId);
/**
* @Description 查询党员信息
* @param customerId
* @param gridIds
* @author zxc
* @date 2020/9/22 5:26 下午
*/
List<PartyMemberInfoResultDTO> selectPartyMemberInfo(@Param("customerId")String customerId,@Param("gridIds") List<String> gridIds);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.stats.user;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserAgencyDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserAgencyDailyEntity;
import org.apache.ibatis.annotations.Mapper;
@ -38,4 +39,13 @@ public interface FactParticipationUserAgencyDailyDao extends BaseDao<FactPartici
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @Description 查询机关下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
List<UserCountResultDTO> selectUserCount(String customerId, String dateId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.stats.user;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserGridDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity;
import org.apache.ibatis.annotations.Mapper;
@ -38,4 +39,13 @@ public interface FactParticipationUserGridDailyDao extends BaseDao<FactParticipa
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @Description 查询网格下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
List<UserCountResultDTO> selectUserCount(String customerId, String dateId);
}

211
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java

@ -1,12 +1,29 @@
package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.dto.extract.form.PartyBaseInfoFormDTO;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.extract.result.PartyMemberInfoResultDTO;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService;
import com.epmet.service.evaluationindex.screen.ScreenCpcBaseDataService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.epmet.service.stats.user.FactParticipationUserAgencyDailyService;
import com.epmet.service.stats.user.FactParticipationUserGridDailyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import com.epmet.constant.ScreenConstant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Desciption 党员基本情况
@ -19,6 +36,14 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
@Autowired
private ScreenCustomerAgencyService agencyService;
@Autowired
private DimCustomerPartymemberService partyMemberService;
@Autowired
private FactParticipationUserGridDailyService userGridDailyService;
@Autowired
private FactParticipationUserAgencyDailyService userAgencyDailyService;
@Autowired
private ScreenCpcBaseDataService cpcBaseDataService;
/**
* @Description 统计基层党建-党员基本情况
@ -29,9 +54,187 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
*/
@Override
public Boolean statsPartyMemberBaseInfoToScreen(String customerId, String dateId) {
String agencyId = "cyagstrbee8711eaa1fac03fd56f7847";
Map<String, Object> stringObjectMap = agencyService.selectAllSubAgencyId(agencyId, customerId);
System.out.println(stringObjectMap);
return null;
List<CustomerAgencyInfoResultDTO> agencyIdList = agencyService.selectAllAgencyId(customerId);
if (!CollectionUtils.isEmpty(agencyIdList)){
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel));
if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY);
disPose(customerGridInfoList,true,customerId,dateId);
}else if (groupByLevel.containsKey(ScreenConstant.STREET)){
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET);
disPose(customerGridInfoList,false,customerId,dateId);
}else if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT);
disPose(customerGridInfoList,false,customerId,dateId);
}else if (groupByLevel.containsKey(ScreenConstant.CITY)){
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY);
disPose(customerGridInfoList,false,customerId,dateId);
}else if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE);
disPose(customerGridInfoList,false,customerId,dateId);
}else {
// TODO 干啥
}
}
return true;
}
/**
* @Description
* @param isGrid true:level = community
* @author zxc
* @date 2020/9/22 4:48 下午
*/
public void disPose(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String dateId){
if (!CollectionUtils.isEmpty(agencyIdList)){
List<PartyBaseInfoFormDTO> result = new ArrayList<>();
if (isGrid == true){
List<UserCountResultDTO> userCountList = userGridDailyService.selectUserCount(customerId, dateId);
agencyIdList.forEach(agency -> {
// 1. 处理社区下的所有网格中的党员信息
String agencyId = agency.getAgencyId();
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId);
List<String> gridIds = (List<String>) agencyMap.get(agencyId);
List<PartyMemberInfoResultDTO> partyMemberInfoList = partyMemberService.selectPartyMemberInfo(customerId, gridIds);
if (!CollectionUtils.isEmpty(partyMemberInfoList)){
partyMemberInfoList.forEach(party -> {
party.setAge(getAge(party.getBirthday()));
});
Map<String, List<PartyMemberInfoResultDTO>> groupByGridId = partyMemberInfoList.stream().collect(Collectors.groupingBy(PartyMemberInfoResultDTO::getGridId));
groupByGridId.forEach((gridId,partyInfos) -> {
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO();
form.setOrgType(ScreenConstant.GRID);
form.setOrgId(gridId);
form.setOrgName(partyInfos.get(NumConstant.ZERO).getGridName());
form.setAgeLevel1(disposeAge(partyInfos,NumConstant.TWENTY,false));
form.setAgeLevel2(disposeAgeArea(partyInfos,NumConstant.TWENTY,NumConstant.THIRTY));
form.setAgeLevel3(disposeAgeArea(partyInfos,NumConstant.THIRTY_ONE,NumConstant.FORTY));
form.setAgeLevel4(disposeAgeArea(partyInfos,NumConstant.FORTY_ONE,NumConstant.FIFTY));
form.setAgeLevel5(disposeAgeArea(partyInfos,NumConstant.FIFTY_ONE,NumConstant.SIXTY));
form.setAgeLevel6(disposeAge(partyInfos,NumConstant.SIXTY,true));
form.setCustomerId(customerId);
form.setDataEndTime(dateId);
form.setParentId(partyInfos.get(NumConstant.ZERO).getAgencyId());
if (!CollectionUtils.isEmpty(userCountList)){
userCountList.forEach(user -> {
if (gridId.equals(user.getOrgId())){
form.setResiTotal(user.getResiTotal());
form.setRegisterUserCount(user.getRegisterUserCount());
form.setPartyMemberCount(user.getPartyMemberCount());
}
});
}
result.add(form);
});
}
});
// 2. 处理社区级别的党员信息
Map<String, List<PartyBaseInfoFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(PartyBaseInfoFormDTO::getParentId));
groupByAgency.forEach((commAgencyId,party) -> {
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO();
form.setOrgName(party.get(NumConstant.ZERO).getOrgName());
form.setOrgId(commAgencyId);
form.setOrgType(ScreenConstant.AGENCY);
form.setParentId(party.get(NumConstant.ZERO).getParentId());
form.setAgeLevel1(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel1)));
form.setAgeLevel2(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel2)));
form.setAgeLevel3(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel3)));
form.setAgeLevel4(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel4)));
form.setAgeLevel5(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel5)));
form.setAgeLevel6(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel6)));
form.setPartyMemberCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getPartyMemberCount)));
form.setResiTotal(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getResiTotal)));
form.setRegisterUserCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getRegisterUserCount)));
result.add(form);
});
delAndInsert(result,customerId,dateId);
}else {
List<UserCountResultDTO> userCountRList = userAgencyDailyService.selectUserCount(customerId, dateId);
agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId();
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId);
List<String> agencyIds = (List<String>) agencyMap.get(agencyId);
// todo
});
}
}
}
/**
* @Description 根据生日计算年龄
* @param birthday
* @author zxc
* @date 2020/9/22 5:34 下午
*/
public Integer getAge(Date birthday){
LocalDate now = LocalDate.now();
int nowYear = now.getYear();
int nowMonth = now.getMonthValue();
int nowDayOfMonth = now.getDayOfMonth();
LocalDate birth = birthday.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
int birthDayYear = birth.getYear();
int birthDayMonth = birth.getMonthValue();
int birthDayOfMonth = birth.getDayOfMonth();
int age = nowYear - birthDayYear;
if (nowMonth < birthDayMonth || (nowMonth == birthDayMonth && nowDayOfMonth < birthDayOfMonth)) {
age--;
}
return age;
}
/**
* @Description 处理年龄段之间的人数
* @param partyMemberInfoList
* @param startAge
* @param endAge
* @author zxc
* @date 2020/9/22 5:45 下午
*/
public Integer disposeAgeArea(List<PartyMemberInfoResultDTO> partyMemberInfoList, Integer startAge,Integer endAge ){
if (!CollectionUtils.isEmpty(partyMemberInfoList)){
List<PartyMemberInfoResultDTO> collect = partyMemberInfoList.stream().filter(p -> p.getAge() >= startAge).filter(p -> p.getAge() <= endAge).collect(Collectors.toList());
return collect.size();
}
return NumConstant.ZERO;
}
/**
* @Description 计算 大于/小于 年龄的人数
* @param partyMemberInfoList
* @param age
* @param isGreater 是否是 大于
* @author zxc
* @date 2020/9/22 5:49 下午
*/
public Integer disposeAge(List<PartyMemberInfoResultDTO> partyMemberInfoList, Integer age , Boolean isGreater){
if (!CollectionUtils.isEmpty(partyMemberInfoList)){
List<PartyMemberInfoResultDTO> collect = new ArrayList<>();
if (isGreater == true){
collect = partyMemberInfoList.stream().filter(p -> p.getAge() > age).collect(Collectors.toList());
}else {
collect = partyMemberInfoList.stream().filter(p -> p.getAge() < age).collect(Collectors.toList());
}
return collect.size();
}
return NumConstant.ZERO;
}
/**
* @Description
* @param result
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 10:13 上午
*/
public void delAndInsert(List<PartyBaseInfoFormDTO> result, String customerId, String dateId){
if (!CollectionUtils.isEmpty(result)){
List<String> orgIds = result.stream().map(m -> m.getOrgId()).collect(Collectors.toList());
Integer delNum;
do {
delNum = cpcBaseDataService.deleteOldPartyBaseInfo(customerId, dateId, orgIds);
}while (delNum > NumConstant.ZERO);
cpcBaseDataService.insertPartyBaseInfo(result);
}
}
}

21
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCpcBaseDataService.java

@ -18,8 +18,11 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.extract.form.PartyBaseInfoFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCpcBaseDataEntity;
import java.util.List;
/**
* 基层党建-党员基本情况
*
@ -28,4 +31,22 @@ import com.epmet.entity.evaluationindex.screen.ScreenCpcBaseDataEntity;
*/
public interface ScreenCpcBaseDataService extends BaseService<ScreenCpcBaseDataEntity> {
/**
* @Description 插入党员基本信息
* @param baseInfoFormDTOS
* @author zxc
* @date 2020/9/22 3:28 下午
*/
void insertPartyBaseInfo(List<PartyBaseInfoFormDTO> baseInfoFormDTOS);
/**
* @Description 删除旧的党员基本信息
* @param customerId
* @param dateId
* @param orgIds
* @author zxc
* @date 2020/9/22 3:28 下午
*/
Integer deleteOldPartyBaseInfo(String customerId, String dateId, List<String> orgIds);
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java

@ -17,6 +17,9 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import java.util.List;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
@ -42,6 +45,14 @@ public interface ScreenCustomerAgencyService{
*/
Map<String,Object> selectAllSubAgencyId(String agencyId, String customerId);
/**
* @Description 查询客户下所有机关ID
* @param customerId
* @author zxc
* @date 2020/9/22 4:06 下午
*/
List<CustomerAgencyInfoResultDTO> selectAllAgencyId(String customerId);
ScreenCustomerAgencyEntity getLastAddedAgency();
ScreenCustomerAgencyEntity getLastUpdatedAgency();

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCpcBaseDataServiceImpl.java

@ -19,10 +19,13 @@ package com.epmet.service.evaluationindex.screen.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.evaluationindex.screen.ScreenCpcBaseDataDao;
import com.epmet.dto.extract.form.PartyBaseInfoFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCpcBaseDataEntity;
import com.epmet.service.evaluationindex.screen.ScreenCpcBaseDataService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 基层党建-党员基本情况
@ -34,4 +37,21 @@ import org.springframework.stereotype.Service;
public class ScreenCpcBaseDataServiceImpl extends BaseServiceImpl<ScreenCpcBaseDataDao, ScreenCpcBaseDataEntity> implements ScreenCpcBaseDataService {
@Override
public void insertPartyBaseInfo(List<PartyBaseInfoFormDTO> baseInfoFormDTOS) {
baseDao.insertPartyBaseInfo(baseInfoFormDTOS);
}
/**
* @Description 删除旧的党员基本信息
* @param customerId
* @param dateId
* @param orgIds
* @author zxc
* @date 2020/9/22 3:28 下午
*/
@Override
public Integer deleteOldPartyBaseInfo(String customerId, String dateId, List<String> orgIds) {
return baseDao.deleteOldPartyBaseInfo(customerId, dateId,orgIds);
}
}

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.constant.ScreenConstant;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -77,18 +78,18 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
resultMap.put(agencyId,gridIdList);
}else {
resultMap.put(ScreenConstant.LEVEL,rootAgency.getLevel());
resultMap.put(agencyId,getDepartmentList((ScreenConstant.STR_NULL.equals(rootAgency.getPids())||rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getAgencyId() : rootAgency.getPids().concat(ScreenConstant.ENGLISH_COMMA).concat(rootAgency.getAgencyId())));
resultMap.put(agencyId,getSubList((ScreenConstant.STR_NULL.equals(rootAgency.getPids())||rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getAgencyId() : rootAgency.getPids().concat(ScreenConstant.ENGLISH_COMMA).concat(rootAgency.getAgencyId())));
}
return resultMap;
}
private List<String> getDepartmentList(String subAgencyPids) {
private List<String> getSubList(String subAgencyPids) {
List<String> result = new ArrayList<>();
List<TreeResultDTO> subAgencyList = screenCustomerAgencyDao.selectSubAgencyList(subAgencyPids);
if (!CollectionUtils.isEmpty(subAgencyList)) {
result.addAll(subAgencyList.stream().map(sub -> sub.getAgencyId()).collect(Collectors.toList()));
subAgencyList.forEach(sub -> {
List<String> subAgency = getDepartmentList(sub.getPids() + "," + sub.getAgencyId());
List<String> subAgency = getSubList(sub.getPids() + "," + sub.getAgencyId());
result.addAll(subAgency);
});
}
@ -157,4 +158,15 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
cae.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenCustomerAgencyDao.insert(cae);
}
/**
* @Description 查询客户下所有机关ID
* @param customerId
* @author zxc
* @date 2020/9/22 4:06 下午
*/
@Override
public List<CustomerAgencyInfoResultDTO> selectAllAgencyId(String customerId) {
return screenCustomerAgencyDao.selectAllAgencyId(customerId);
}
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java

@ -19,6 +19,7 @@ package com.epmet.service.stats;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.extract.result.PartyMemberInfoResultDTO;
import com.epmet.dto.stats.DimCustomerPartymemberDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
@ -111,4 +112,13 @@ public interface DimCustomerPartymemberService extends BaseService<DimCustomerPa
* @Date 2020/9/18 9:03
**/
List<FactIndexPartyAblityCpcMonthlyEntity> selectPartyMemberList(String customerId);
/**
* @Description 查询党员信息
* @param customerId
* @param gridIds
* @author zxc
* @date 2020/9/22 5:26 下午
*/
List<PartyMemberInfoResultDTO> selectPartyMemberInfo(String customerId,List<String> gridIds);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java

@ -30,6 +30,7 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.StatsConstant;
import com.epmet.dao.stats.DimCustomerPartymemberDao;
import com.epmet.dto.extract.result.PartyMemberInfoResultDTO;
import com.epmet.dto.stats.DimCustomerPartymemberDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.dto.stats.form.DimCustomerPartyMemberFormDTO;
@ -174,6 +175,18 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom
return baseDao.selectPartyMemberList(customerId);
}
/**
* @Description 查询党员信息
* @param customerId
* @param gridIds
* @author zxc
* @date 2020/9/22 5:26 下午
*/
@Override
public List<PartyMemberInfoResultDTO> selectPartyMemberInfo(String customerId, List<String> gridIds) {
return baseDao.selectPartyMemberInfo(customerId, gridIds);
}
/**
* @Description 删除旧纪录插入新纪录
* @param partyMemberList

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/FactParticipationUserAgencyDailyService.java

@ -19,6 +19,7 @@ package com.epmet.service.stats.user;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserAgencyDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserAgencyDailyEntity;
@ -93,4 +94,13 @@ public interface FactParticipationUserAgencyDailyService extends BaseService<Fac
* @date 2020-06-17
*/
void delete(String[] ids);
/**
* @Description 查询机关下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
List<UserCountResultDTO> selectUserCount(String customerId, String dateId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/FactParticipationUserGridDailyService.java

@ -19,6 +19,7 @@ package com.epmet.service.stats.user;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserGridDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity;
@ -93,4 +94,13 @@ public interface FactParticipationUserGridDailyService extends BaseService<FactP
* @date 2020-06-17
*/
void delete(String[] ids);
/**
* @Description 查询网格下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
List<UserCountResultDTO> selectUserCount(String customerId,String dateId);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/FactParticipationUserAgencyDailyServiceImpl.java

@ -24,6 +24,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.stats.user.FactParticipationUserAgencyDailyDao;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserAgencyDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserAgencyDailyEntity;
import com.epmet.service.stats.user.FactParticipationUserAgencyDailyService;
@ -98,4 +99,16 @@ public class FactParticipationUserAgencyDailyServiceImpl extends BaseServiceImpl
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @Description 查询机关下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
@Override
public List<UserCountResultDTO> selectUserCount(String customerId, String dateId) {
return baseDao.selectUserCount(customerId, dateId);
}
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/FactParticipationUserGridDailyServiceImpl.java

@ -24,6 +24,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.stats.user.FactParticipationUserGridDailyDao;
import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserGridDailyDTO;
import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity;
import com.epmet.service.stats.user.FactParticipationUserGridDailyService;
@ -99,4 +100,16 @@ public class FactParticipationUserGridDailyServiceImpl extends BaseServiceImpl<F
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @Description 查询网格下用户信息
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/23 9:57 上午
*/
@Override
public List<UserCountResultDTO> selectUserCount(String customerId, String dateId) {
return baseDao.selectUserCount(customerId, dateId);
}
}

68
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCpcBaseDataDao.xml

@ -64,5 +64,73 @@
</foreach>
</insert>
<!-- 插入党员基本信息 -->
<insert id="insertPartyBaseInfo">
insert into screen_cpc_base_data
(
ID,
CUSTOMER_ID,
ORG_TYPE,
ORG_ID,
PARENT_ID,
ORG_NAME,
DATA_END_TIME,
REGISTER_USER_COUNT,
RESI_TOTAL,
PARTY_MEMBER_COUNT,
AGE_LEVEL_1,
AGE_LEVEL_2,
AGE_LEVEL_3,
AGE_LEVEL_4,
AGE_LEVEL_5,
AGE_LEVEL_6,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
) values
<foreach collection="list" item="item" separator=",">
(
REPLACE(UUID(), '-', ''),
#{customerId},
#{item.orgType},
#{item.orgId},
#{item.parentId},
#{item.orgName},
#{item.dataEndTime},
#{item.registerUserCount},
#{item.resiTotal},
#{item.partyMemberCount},
#{item.ageLevel1},
#{item.ageLevel2},
#{item.ageLevel3},
#{item.ageLevel4},
#{item.ageLevel5},
#{item.ageLevel6},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
now(),
#{item.updatedBy},
now()
)
</foreach>
</insert>
<!-- 删除旧的党员基本信息 -->
<delete id="deleteOldPartyBaseInfo">
delete from screen_cpc_base_data
where CUSTOMER_ID = #{customerId}
and DATA_END_TIME = #{dateId}
and
(
<foreach collection="ordIds" item="orgId" separator=" OR ">
org_id = #{orgId}
</foreach>
)
</delete>
</mapper>

15
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -243,4 +243,19 @@
from screen_customer_agency sca
where sca.AGENCY_ID = #{agencyId}
</select>
<!-- 查询客户下所有机关ID -->
<select id="selectAllAgencyId" resultType="com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO">
SELECT
agency_id,
pid,
level,
agency_name
FROM
screen_customer_agency
WHERE
del_flag = '0'
AND CUSTOMER_ID = #{customerId}
ORDER BY created_time DESC
</select>
</mapper>

25
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml

@ -87,4 +87,29 @@
dcp.DEL_FLAG = '0'
AND dcp.CUSTOMER_ID =#{customerId}
</select>
<!-- 查询党员信息 -->
<select id="selectPartyMemberInfo" resultType="com.epmet.dto.extract.result.PartyMemberInfoResultDTO">
SELECT
dcp.GRID_ID,
dcp.AGENCY_ID,
dcp.PARENT_ID,
dcp.BIRTHDAY,
scg.GRID_NAME,
sca.AGENCY_NAME
FROM dim_customer_partymember dcp
LEFT JOIN screen_customer_grid scg ON scg.GRID_ID = dcp.GRID_ID
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = dcp.AGENCY_ID
WHERE
dcp.DEL_FLAG = '0'
AND scg.DEL_FLAG = 0
AND sca.DEL_FLAG = 0
AND dcp.CUSTOMER_ID = #{customerId}
AND
(
<foreach collection="gridIds" item="gridId" separator=" OR ">
dcp.GRID_ID = #{gridId}
</foreach>
)
</select>
</mapper>

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml

@ -102,5 +102,19 @@
</if>
</delete>
<!-- 查询机关下用户信息 -->
<select id="selectUserCount" resultType="com.epmet.dto.extract.result.UserCountResultDTO">
SELECT
REG_TOTAL AS resiTotal,
RESI_TOTAL AS registerUserCount,
PARTYMEMBER_TOTAL AS partyMemberCount,
AGENCY_ID AS orgId
FROM
fact_participation_user_agency_daily
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper>

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml

@ -107,5 +107,19 @@
</if>
</delete>
<!-- 查询网格下用户信息 -->
<select id="selectUserCount" resultType="com.epmet.dto.extract.result.UserCountResultDTO">
SELECT
REG_TOTAL AS resiTotal,
RESI_TOTAL AS registerUserCount,
PARTYMEMBER_TOTAL AS partyMemberCount,
GRID_ID AS orgId
FROM
fact_participation_user_grid_daily
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper>
Loading…
Cancel
Save