Browse Source

Merge remote-tracking branch 'origin/dev_screen_data_2.0' into dev_screen_data_2.0

dev_shibei_match
yinzuomei 5 years ago
parent
commit
d86c822278
  1. 9
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  2. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
  3. 35
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java
  4. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java
  5. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java
  7. 85
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  8. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  9. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
  10. 13
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java
  11. 33
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java
  12. 33
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ScreenExtractDailyTask.java

9
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java

@ -220,4 +220,13 @@ public interface DataStatisticalOpenFeignClient {
*/
@PostMapping("/data/stats/eidim/init-all")
Result initAllEIDims();
/**
* @Description 抽取数据到大屏
* @param extractFormDTO
* @author zxc
* @date 2020/9/24 10:15 上午
*/
@PostMapping(value = "/data/stats/screenextract/extractdailyall")
Result extractDailyAll(@RequestBody(required = false) ExtractFormDTO extractFormDTO);
}

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java

@ -212,4 +212,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp
public Result initAllEIDims() {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "initAllEIDims");
}
@Override
public Result extractDailyAll(ExtractFormDTO extractFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "extractDailyAll",extractFormDTO);
}
}

35
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java

@ -0,0 +1,35 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.extract.form.ExtractFormDTO;
import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author zxc
* @DateTime 2020/9/24 9:42 上午
*/
@RestController
@RequestMapping("screenextract")
public class ScreenExtractDailyController {
@Autowired
private ScreenExtractService screenExtractService;
/**
* @Description 抽取数据到大屏
* @param extractFormDTO
* @author zxc
* @date 2020/9/24 10:15 上午
*/
@PostMapping("extractdailyall")
public Result screenExtractDaily(@RequestBody ExtractFormDTO extractFormDTO){
screenExtractService.extractDailyAll(extractFormDTO);
return new Result();
}
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java

@ -0,0 +1,19 @@
package com.epmet.service.evaluationindex.extract.toscreen;
import com.epmet.dto.extract.form.ExtractFormDTO;
/**
* @Author zxc
* @DateTime 2020/9/24 9:57 上午
*/
public interface ScreenExtractService {
/**
* @Description 抽取数据到大屏
* @param extractFormDTO
* @author zxc
* @date 2020/9/24 10:15 上午
*/
void extractDailyAll(ExtractFormDTO extractFormDTO);
}

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

@ -63,24 +63,30 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
public Boolean statsPartyMemberBaseInfoToScreen(String customerId, String dateId) {
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);
}
if (groupByLevel.containsKey(ScreenConstant.STREET)){
// 街道级别
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET);
disPose(customerGridInfoList,false,customerId,dateId);
}
if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){
// 区级
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT);
disPose(customerGridInfoList,false,customerId,dateId);
}
if (groupByLevel.containsKey(ScreenConstant.CITY)){
// 市级
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY);
disPose(customerGridInfoList,false,customerId,dateId);
}
if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){
// 省级
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE);
disPose(customerGridInfoList,false,customerId,dateId);
}
@ -96,13 +102,16 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
*/
public void disPose(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String dateId){
if (!CollectionUtils.isEmpty(agencyIdList)){
// 网格ID或机关Id
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
List<PartyBaseInfoFormDTO> result = new ArrayList<>();
if (isGrid == true){
// 是 community 级别,子级为gridId
List<UserCountResultDTO> userCountList = userGridDailyService.selectUserCount(customerId, dateId);
agencyIdList.forEach(agency -> {
// 1. 处理社区下的所有网格中的党员信息
String agencyId = agency.getAgencyId();
// 获取下级所有agencyId【根据agencyMap中的level判断下级orgId是否是gridId】(此处直接作为gridId)
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId);
List<String> gridIds = (List<String>) agencyMap.get(agencyId);
orgIds.addAll(gridIds);
@ -140,7 +149,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
});
}
});
// 2. 处理社区级别的党员信息
// 2. 处理社区级别的党员信息(因为网格级别的已算出,社区级别直接累加)
Map<String, List<PartyBaseInfoFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(PartyBaseInfoFormDTO::getParentId));
groupByAgency.forEach((commAgencyId,party) -> {
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO();
@ -163,8 +172,10 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
});
delAndInsert(result,customerId,dateId,orgIds);
}else {
// 级别为 street,district,city,province
agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId();
// 查询下级机关的党员信息,直接累加
List<PartyInfoResultDTO> partyInfoList = cpcBaseDataService.selectPartyInfo(customerId, dateId, agencyId);
if (!CollectionUtils.isEmpty(partyInfoList)){
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO();
@ -207,6 +218,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
int birthDayMonth = birth.getMonthValue();
int birthDayOfMonth = birth.getDayOfMonth();
int age = nowYear - birthDayYear;
// 当前月小于出生年的月份 或者 当前月等于出生年的月 并且 当前日小于出生年的日,就是不满一岁
if (nowMonth < birthDayMonth || (nowMonth == birthDayMonth && nowDayOfMonth < birthDayOfMonth)) {
age--;
}
@ -223,6 +235,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
*/
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();
}
@ -241,8 +254,10 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
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();
@ -260,10 +275,13 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService {
*/
@Transactional(rollbackFor = Exception.class)
public void delAndInsert(List<PartyBaseInfoFormDTO> result, String customerId, String dateId, List<String> orgIds){
// 查询客户下所有的agency
List<PartyBaseInfoFormDTO> partyBaseInfoList = agencyService.selectAllAgencyIdToParty(customerId,dateId);
// 查询客户下所有的grid
List<PartyBaseInfoFormDTO> resultList = gridService.selectAllGridIdToParty(customerId, dateId);
resultList.addAll(partyBaseInfoList);
List<PartyBaseInfoFormDTO> finalResult = new ArrayList<>();
// 因为是根据级别来删除,插入,所以把需要操作的orgIds单独出来
resultList.forEach(rl -> {
orgIds.forEach(orgId -> {
if (rl.getOrgId().equals(orgId)){

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

@ -11,6 +11,7 @@ import com.epmet.service.evaluationindex.extract.toscreen.PioneerDataExtractServ
import com.epmet.service.evaluationindex.screen.ScreenPioneerDataService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
@ -23,6 +24,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/9/22 11:25
*/
@Service
public class PioneerDataExtractServiceImpl implements PioneerDataExtractService {
@Autowired

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

@ -0,0 +1,85 @@
package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.extract.form.ExtractFormDTO;
import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService;
import com.epmet.service.evaluationindex.extract.toscreen.PioneerDataExtractService;
import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService;
import com.epmet.service.stats.DimCustomerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/9/24 9:57 上午
*/
@Service
@Slf4j
public class ScreenExtractServiceImpl implements ScreenExtractService {
@Autowired
private DimCustomerService dimCustomerService;
@Autowired
private PartyBaseInfoService partyBaseInfoService;
@Autowired
private PioneerDataExtractService pioneerDataExtractService;
/**
* @Description 抽取数据到大屏
* @param extractFormDTO
* @author zxc
* @date 2020/9/24 10:15 上午
*/
@Override
public void extractDailyAll(ExtractFormDTO extractFormDTO) {
List<String> customerIds = new ArrayList<>();
if (StringUtils.isNotBlank(extractFormDTO.getCustomerId())){
customerIds.add(extractFormDTO.getCustomerId());
}else {
int pageNo = NumConstant.ONE;
int pageSize = NumConstant.ONE_HUNDRED;
customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize);
}
if (!CollectionUtils.isEmpty(customerIds)){
customerIds.forEach(customerId -> {
if (StringUtils.isNotBlank(extractFormDTO.getStartDate()) && StringUtils.isNotBlank(extractFormDTO.getEndDate())){
List<String> daysBetween = DateUtils.getDaysBetween(extractFormDTO.getStartDate(), extractFormDTO.getEndDate());
daysBetween.forEach(dateId -> {
extractDaily(customerId,dateId);
});
}else if (StringUtils.isNotBlank(extractFormDTO.getDateId())){
extractDaily(customerId,extractFormDTO.getDateId());
}else {
String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", "");
extractDaily(customerId,dateId);
}
});
}
}
/**
* @Description 按天计算
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/24 10:16 上午
*/
public void extractDaily(String customerId,String dateId){
partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId,dateId);
pioneerDataExtractService.extractGridPioneerData(customerId,dateId);
pioneerDataExtractService.extractCommunityPioneerData(customerId,dateId);
pioneerDataExtractService.extractStreetPioneerData(customerId,dateId);
pioneerDataExtractService.extractDistrictPioneerData(customerId,dateId);
pioneerDataExtractService.extractCityPioneerData(customerId,dateId);
pioneerDataExtractService.extractProvincePioneerData(customerId,dateId);
}
}

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

@ -186,7 +186,10 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom
*/
@Override
public List<PartyMemberInfoResultDTO> selectPartyMemberInfo(String customerId, List<String> gridIds) {
return baseDao.selectPartyMemberInfo(customerId, gridIds);
if (!CollectionUtils.isEmpty(gridIds)){
return baseDao.selectPartyMemberInfo(customerId, gridIds);
}
return new ArrayList<>();
}
/**

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml

@ -189,7 +189,7 @@ thread:
queueCapacity: @thread.pool.queue-capacity@
keepAlive: @thread.pool.keep-alive@
#dingTalk:
# robot:
# webHook: @dingTalk.robot.webHook@
# secret: @dingTalk.robot.secret@
dingTalk:
robot:
webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@

13
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java

@ -0,0 +1,13 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
/**
* @Author zxc
* @DateTime 2020/9/24 10:21 上午
*/
public interface ScreenExtractTaskService {
Result screenExtractDaily(String params);
}

33
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java

@ -0,0 +1,33 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.extract.form.ExtractFormDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.service.ScreenExtractTaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Author zxc
* @DateTime 2020/9/24 10:22 上午
*/
@Service
@Slf4j
public class ScreenExtractTaskServiceImpl implements ScreenExtractTaskService {
@Autowired
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient;
@Override
public Result screenExtractDaily(String params) {
ExtractFormDTO extractFormDTO = new ExtractFormDTO();
if (StringUtils.isNotBlank(params)) {
extractFormDTO = JSON.parseObject(params, ExtractFormDTO.class);
}
return dataStatisticalOpenFeignClient.extractDailyAll(extractFormDTO);
}
}

33
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ScreenExtractDailyTask.java

@ -0,0 +1,33 @@
package com.epmet.task;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.ScreenExtractTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Author zxc
* @DateTime 2020/9/24 10:26 上午
*/
@Component("screenExtractDailyTask")
public class ScreenExtractDailyTask implements ITask{
@Autowired
private ScreenExtractTaskService screenExtractTaskService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void run(String params) {
logger.info("ScreenExtractDailyTask定时任务正在执行,参数为:{}", params);
Result result = screenExtractTaskService.screenExtractDaily(params);
if (result.success()){
logger.info("ScreenExtractDailyTask定时任务执行成功");
}else {
logger.error("ScreenExtractDailyTask定时任务执行失败:" + result.getMsg());
}
}
}
Loading…
Cancel
Save