diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index 72de92dd19..520b6bee09 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/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); } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index d33250bbab..8c5e2eafff 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/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); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java new file mode 100644 index 0000000000..2f81eeadc2 --- /dev/null +++ b/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(); + } + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java new file mode 100644 index 0000000000..70ff60bff3 --- /dev/null +++ b/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); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java index 050b8df4ce..f3c758df72 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java +++ b/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 agencyIdList = agencyService.selectAllAgencyId(customerId); if (!CollectionUtils.isEmpty(agencyIdList)){ + // 根据组织级别分组 Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){ + // 社区级别 List customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY); disPose(customerGridInfoList,true,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.STREET)){ + // 街道级别 List customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ + // 区级 List customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.CITY)){ + // 市级 List customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ + // 省级 List customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); disPose(customerGridInfoList,false,customerId,dateId); } @@ -96,13 +102,16 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { */ public void disPose(List agencyIdList, Boolean isGrid, String customerId, String dateId){ if (!CollectionUtils.isEmpty(agencyIdList)){ + // 网格ID或机关Id List orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); List result = new ArrayList<>(); if (isGrid == true){ + // 是 community 级别,子级为gridId List userCountList = userGridDailyService.selectUserCount(customerId, dateId); agencyIdList.forEach(agency -> { // 1. 处理社区下的所有网格中的党员信息 String agencyId = agency.getAgencyId(); + // 获取下级所有agencyId【根据agencyMap中的level判断下级orgId是否是gridId】(此处直接作为gridId) Map agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); List gridIds = (List) agencyMap.get(agencyId); orgIds.addAll(gridIds); @@ -140,7 +149,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { }); } }); - // 2. 处理社区级别的党员信息 + // 2. 处理社区级别的党员信息(因为网格级别的已算出,社区级别直接累加) Map> 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 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 partyMemberInfoList, Integer startAge,Integer endAge ){ if (!CollectionUtils.isEmpty(partyMemberInfoList)){ + // 计算大于多少岁并小于多少岁的人 List 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 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 result, String customerId, String dateId, List orgIds){ + // 查询客户下所有的agency List partyBaseInfoList = agencyService.selectAllAgencyIdToParty(customerId,dateId); + // 查询客户下所有的grid List resultList = gridService.selectAllGridIdToParty(customerId, dateId); resultList.addAll(partyBaseInfoList); List finalResult = new ArrayList<>(); + // 因为是根据级别来删除,插入,所以把需要操作的orgIds单独出来 resultList.forEach(rl -> { orgIds.forEach(orgId -> { if (rl.getOrgId().equals(orgId)){ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java index 1cd53ed9a2..0971f22372 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java +++ b/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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java new file mode 100644 index 0000000000..a46d3d0d58 --- /dev/null +++ b/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 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 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); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java index 26480757da..65b04efc11 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java +++ b/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 selectPartyMemberInfo(String customerId, List gridIds) { - return baseDao.selectPartyMemberInfo(customerId, gridIds); + if (!CollectionUtils.isEmpty(gridIds)){ + return baseDao.selectPartyMemberInfo(customerId, gridIds); + } + return new ArrayList<>(); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index 0772838230..ccb02b714f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/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@ diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java new file mode 100644 index 0000000000..5e144642ed --- /dev/null +++ b/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); + +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java new file mode 100644 index 0000000000..0566277dc5 --- /dev/null +++ b/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); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ScreenExtractDailyTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ScreenExtractDailyTask.java new file mode 100644 index 0000000000..3e5c130e1a --- /dev/null +++ b/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()); + } + } +}