diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index b618bd54d1..a7a768b095 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -19,8 +19,11 @@ import org.joda.time.format.DateTimeFormatter; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.DateTimeException; import java.time.ZoneId; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 日期处理工具类 @@ -640,4 +643,42 @@ public class DateUtils { } return minusMonthId; } + + /** + * @Description 根据传入的时间维度判断格式,日、周、月、季、年 + * @param dimension + * @return + * @author wangc + * @date 2020.09.24 10:11 + **/ + public static String identifyTimeDimension(String dimension){ + //yyyyMMdd DATE_PATTERN_YYYYMMDD + //yyyyMM DATE_PATTERN_YYYYMM + //yyyy DATE_PATTERN_YYYY + //yyyyWcc + //yyyyQc + if(dimension.length() == NumConstant.EIGHT){ + + SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYYMMDD); + try{ df.parse(dimension); }catch (ParseException e){ return null; } + return "date"; + + }else if(dimension.length() == NumConstant.FOUR){ + SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYY); + try{df.parse(dimension);}catch (ParseException e){return null;} + return "year"; + }else if(dimension.length() == NumConstant.SEVEN){ + if(dimension.contains("W")){ + return "week"; + }else return null; + }else if(dimension.length() == NumConstant.SIX){ + if(dimension.contains("Q")){ + return "quarter"; + }else{ + SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYYMM); + try{df.parse(dimension);}catch (ParseException e){return null;} + return "month"; + } + }else return null; + } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java new file mode 100644 index 0000000000..6eb609fc5d --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.screen.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 大屏中央区数据写入传参DTO + * @ClassName ScreenCentralZoneDataFormDTO + * @Auth wangc + * @Date 2020-09-24 10:02 + */ +@Data +public class ScreenCentralZoneDataFormDTO implements Serializable { + private static final long serialVersionUID = -6621150245370746092L; + + /** + * 客户Id + * */ + private String customerId; + + /** + * 时间维度 不一定是dateId 需要根据其格式进行判断维度的类型 + * */ + private String dateId; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index ce10359a47..4f136ffc56 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -18,6 +18,7 @@ import com.epmet.dao.stats.DimMonthDao; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.extract.form.ExtractFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity; @@ -35,11 +36,13 @@ import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollStreetServ import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService; import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService; import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService; +import com.epmet.service.evaluationindex.extract.toscreen.ScreenCentralZoneDataAbsorptionService; import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimCustomerPartymemberService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -99,6 +102,8 @@ public class DemoController { private IndexCollCommunityService indexCollCommunityService; @Autowired private IndexCollStreetService indexCollStreetService; + @Autowired + private ScreenCentralZoneDataAbsorptionService screenCentralZoneDataAbsorptionService; @GetMapping("testAlarm") public void testAlarm() { @@ -642,4 +647,9 @@ public class DemoController { return new Result(); } + @PostMapping("centralzonedatacleaning") + public Result centralZoneDataCleaning(@RequestBody ScreenCentralZoneDataFormDTO param){ + screenCentralZoneDataAbsorptionService.centralZoneDataHub(param); + return new Result(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserTotalDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserTotalDataDao.java index f09189dce0..2456d0d93a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserTotalDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserTotalDataDao.java @@ -55,4 +55,6 @@ public interface ScreenUserTotalDataDao extends BaseDao list, @Param("customerId")String customerId); + + void insertBatch(@Param("list") List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactAgencyProjectDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactAgencyProjectDailyDao.java index 2fbabdec6c..87409a6607 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactAgencyProjectDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactAgencyProjectDailyDao.java @@ -19,8 +19,10 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.project.form.MonthProjectListFormDTO; +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.stats.FactAgencyProjectDailyEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -46,4 +48,16 @@ public interface FactAgencyProjectDailyDao extends BaseDao selectProjectCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId ); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java index c97f5c8120..5dfd4bc79d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java @@ -19,11 +19,13 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.group.result.GroupGridDailyResultDTO; +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.stats.FactGroupGridDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 组-网格日统计数据 @@ -47,5 +49,15 @@ public interface FactGroupGridDailyDao extends BaseDao * @author zxc */ void deleteInsertDateId(@Param("dateId")String dateId,@Param("customerId")String customerId); - + + /** + * @Description 根据机关级别查询小组数据 + * @param orgLevel + * @param customerId + * @param dateId + * @return + * @author wangc + * @date 2020.09.24 16:19 + **/ + List selectGroupCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridDailyDao.java index 595131257d..c26edcd375 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridDailyDao.java @@ -18,10 +18,13 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.stats.FactIssueGridDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 网格议题数量(按日) * @@ -39,5 +42,16 @@ public interface FactIssueGridDailyDao extends BaseDao * @return void */ void deleteByCustomerId(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * @Description 根据机关类型查询议题数据 + * @param orgLevel + * @param customerId + * @param dateId + * @return + * @author wangc + * @date 2020.09.24 17:19 + **/ + List selectIssueCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId ); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/topic/FactTopicTotalGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/topic/FactTopicTotalGridDailyDao.java index 7276945b90..7a0e6439df 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/topic/FactTopicTotalGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/topic/FactTopicTotalGridDailyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.stats.topic; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.stats.topic.FactTopicTotalGridDailyDTO; +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.stats.topic.FactTopicTotalGridDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,4 +37,15 @@ public interface FactTopicTotalGridDailyDao extends BaseDao list); void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); + + /** + * @Description 根据机关类型查询话题数据 + * @param orgLevel + * @param customerId + * @param dateId + * @return + * @author wangc + * @date 2020.09.24 17:19 + **/ + List selectTopicCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId ); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java index 248efe22a6..cd84b6d3b0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java @@ -20,6 +20,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.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -48,4 +49,12 @@ public interface FactParticipationUserGridDailyDao extends BaseDao selectUserCount(String customerId, String dateId); + /** + * @Description 根据机构级别查询用户数与党员数 + * @param orgLevel + * @return + * @author wangc + * @date 2020.09.24 14:59 + **/ + List selectUserAndPartymemberByOrgLevel(@Param("orgLevel") String orgLevel,@Param("customerId") String customerId, @Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenCentralZoneDataAbsorptionService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenCentralZoneDataAbsorptionService.java new file mode 100644 index 0000000000..7c11d3acb3 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenCentralZoneDataAbsorptionService.java @@ -0,0 +1,19 @@ +package com.epmet.service.evaluationindex.extract.toscreen; + +import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; + +/** + * 大屏中央区数据写入 + * */ + +public interface ScreenCentralZoneDataAbsorptionService { + + /** + * @Description 中央区数据写入 + * @param param + * @return + * @author wangc + * @date 2020.09.24 10:41 + **/ + void centralZoneDataHub(ScreenCentralZoneDataFormDTO param); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenCentralZoneDataAbsorptionServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenCentralZoneDataAbsorptionServiceImpl.java new file mode 100644 index 0000000000..40d47d4f91 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenCentralZoneDataAbsorptionServiceImpl.java @@ -0,0 +1,50 @@ +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.screen.form.ScreenCentralZoneDataFormDTO; +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; +import com.epmet.service.evaluationindex.extract.toscreen.ScreenCentralZoneDataAbsorptionService; +import com.epmet.service.evaluationindex.screen.ScreenUserTotalDataService; +import com.epmet.service.stats.ScreenCentralZoneDataExtractService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + + +/** + * @Description + * @ClassName ScreenCentralZoneDataAbsorptionServiceImpl + * @Auth wangc + * @Date 2020-09-24 10:42 + */ +@Service +@Slf4j +public class ScreenCentralZoneDataAbsorptionServiceImpl implements ScreenCentralZoneDataAbsorptionService { + + @Autowired + private ScreenCentralZoneDataExtractService screenCentralZoneDataExtractService; + @Autowired + private ScreenUserTotalDataService screenUserTotalDataService; + + /** + * @Description 中央区数据写入 + * @param param + * @return + * @author wangc + * @date 2020.09.24 10:41 + **/ + @Override + public void centralZoneDataHub(ScreenCentralZoneDataFormDTO param) { + if(StringUtils.isBlank(param.getDateId())){ + //默认前一天 + param.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); + } + List dataList = screenCentralZoneDataExtractService.extractCentralZoneData(param.getCustomerId(),param.getDateId()); + + screenUserTotalDataService.dataClean(dataList,param.getCustomerId()); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserTotalDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserTotalDataService.java index fd8e5f94e8..3f38a3a683 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserTotalDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserTotalDataService.java @@ -21,6 +21,8 @@ package com.epmet.service.evaluationindex.screen; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; +import java.util.List; + /** * 中央区-各类(用户|党员|党群|话题|议题|项目)总数 * @@ -28,5 +30,14 @@ import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; * @since v1.0.0 2020-09-22 */ public interface ScreenUserTotalDataService extends BaseService { - + + + /** + * @Description 大屏中央区数据清洗 + * @param list + * @return + * @author wangc + * @date 2020.09.24 17:59 + **/ + void dataClean(List list,String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java index 308ba90d08..a1b21beced 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java @@ -19,10 +19,15 @@ package com.epmet.service.evaluationindex.screen.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.dao.evaluationindex.screen.ScreenUserTotalDataDao; import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.service.evaluationindex.screen.ScreenUserTotalDataService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; /** * 中央区-各类(用户|党员|党群|话题|议题|项目)总数 @@ -33,4 +38,22 @@ import org.springframework.stereotype.Service; @Service public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl implements ScreenUserTotalDataService { + /** + * @Description 大屏中央区数据清洗 + * @param list + * @return + * @author wangc + * @date 2020.09.24 17:59 + **/ + @Override + public void dataClean(List list,String customerId) { + int deleteNum; + do { + deleteNum = baseDao.deleteUserTotalData(customerId); + } while (deleteNum <= NumConstant.ZERO); + + if(!CollectionUtils.isEmpty(list)){ + baseDao.insertBatch(list); + } + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/ScreenCentralZoneDataExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/ScreenCentralZoneDataExtractService.java new file mode 100644 index 0000000000..0406c9f42a --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/ScreenCentralZoneDataExtractService.java @@ -0,0 +1,22 @@ +package com.epmet.service.stats; + +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; + +import java.util.List; + +/** + * 大屏中央区数据抽取(form : date-statistical) + * */ +public interface ScreenCentralZoneDataExtractService { + + /** + * @Description 抽取中央区数据 + * @param customerId + * @param dimId + * @return + * @author wangc + * @date 2020.09.24 11:13 + **/ + List extractCentralZoneData(String customerId,String dimId); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java new file mode 100644 index 0000000000..a36695b6b0 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java @@ -0,0 +1,164 @@ +package com.epmet.service.stats.impl; + +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.stats.*; +import com.epmet.dao.stats.topic.FactTopicTotalAgencyDailyDao; +import com.epmet.dao.stats.topic.FactTopicTotalGridDailyDao; + + +import com.epmet.dao.stats.user.FactParticipationUserGridDailyDao; + +import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; +import com.epmet.service.stats.ScreenCentralZoneDataExtractService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Description 大屏中央区数据抽取(form : date-statistical) + * @ClassName ScreenCentralZoneDataExtractServiceImpl + * @Auth wangc + * @Date 2020-09-24 11:15 + */ +@Slf4j +@Service +@DataSource(DataSourceConstant.STATS) +public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZoneDataExtractService { + + @Autowired + private FactParticipationUserGridDailyDao factParticipationUserGridDailyDao; + @Autowired + private FactGroupGridDailyDao factGroupGridDailyDao; + @Autowired + private FactTopicTotalGridDailyDao factTopicTotalGridDailyDao; + @Autowired + private FactIssueGridDailyDao factIssueGridDailyDao; + @Autowired + private FactAgencyProjectDailyDao factAgencyProjectDailyDao; + + + private final String ORG_LEVEL_AGENCY = "agency"; + private final String ORG_LEVEL_GRID = "grid"; + + + /** + * @Description 抽取中央区数据 + * @param customerId + * @param dimId + * @return + * @author wangc + * @date 2020.09.24 11:13 + **/ + @Override + public List extractCentralZoneData(String customerId, String dimId) { + + //1.查询用户与党员数据,判断dimId是否为昨天,如果根据这个dimId没有查询出结果,则取前天的数据 + //如果还是查不出数据,继续向下执行,这部分数据设置默认值 + List result = + factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); + if(CollectionUtils.isEmpty(result)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + result = factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + if(null == result) result = new LinkedList<>(); + } + List gridUserResult = + factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); + + if(CollectionUtils.isEmpty(gridUserResult)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + gridUserResult = factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + if(!CollectionUtils.isEmpty(gridUserResult)){ + result.addAll(gridUserResult); + } + + //2.组 + List agencyGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); + if(CollectionUtils.isEmpty(agencyGroup)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + agencyGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + List gridGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); + if(CollectionUtils.isEmpty(gridGroup)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + gridGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + Map groupMap = agencyGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal)); + groupMap.putAll(gridGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal))); + + + //3.话题 + List agencyTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); + if(CollectionUtils.isEmpty(agencyTopic)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + agencyTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + List gridTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); + if(CollectionUtils.isEmpty(gridTopic)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + gridTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + Map topicMap = agencyTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal)); + topicMap.putAll(gridTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal))); + + //4.议题 + List agencyIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); + if(CollectionUtils.isEmpty(agencyIssue)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + agencyIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + List gridIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); + if(CollectionUtils.isEmpty(gridIssue)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + gridIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + Map issueMap = agencyIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)); + issueMap.putAll(gridIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal))); + + //5.项目 + List agencyProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); + if(CollectionUtils.isEmpty(agencyProject)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + agencyProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + List gridProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); + if(CollectionUtils.isEmpty(gridProject)){ + if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ + gridProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); + } + } + Map projectMap = agencyProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)); + projectMap.putAll(gridProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal))); + + result.forEach(o -> { + String orgId = o.getOrgId(); + o.setGroupTotal(groupMap.get(orgId)); + o.setTopicTotal(topicMap.get(orgId)); + o.setIssueTotal(issueMap.get(orgId)); + o.setProjectTotal(projectMap.get(orgId)); + o.setDataEndTime(dimId); + }); + + + + return result; + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml index ecf0039810..e8c0e8c660 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml @@ -57,4 +57,52 @@ + + insert into screen_user_total_data + ( + ID, + CUSTOMER_ID, + ORG_TYPE, + ORG_ID, + PARENT_ID, + ORG_NAME, + DATA_END_TIME, + USER_TOTAL, + PARTY_TOTAL, + GROUP_TOTAL, + TOPIC_TOTAL, + ISSUE_TOTAL, + PROJECT_TOTAL, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{item.customerId}, + #{item.orgType}, + #{item.orgId}, + #{item.parentId}, + #{item.orgName}, + #{item.dataEndTime}, + #{item.userTotal}, + #{item.partyTotal}, + #{item.groupTotal}, + #{item.topicTotal}, + #{item.issueTotal}, + #{item.projectTotal}, + 0, + 0, + 'CRAWLER_ROBOT', + now(), + 'CRAWLER_ROBOT', + now() + ) + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml index 34327672d6..b2333a5451 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml @@ -25,4 +25,24 @@ AND date_id = #{dateId} + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml index 8c8ab22e50..c8e631ed88 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml @@ -76,4 +76,25 @@ AND customer_id = #{customerId} + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml index 998f24e343..de8596943f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml @@ -50,4 +50,24 @@ + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml index 537a46cebb..097fb515a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml @@ -90,4 +90,22 @@ + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml index 96e16db5be..2837f9c4a1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml @@ -121,5 +121,42 @@ AND DATE_ID = #{dateId} + + \ No newline at end of file