Browse Source

toScreen 中央区数据

master
wangchao 5 years ago
parent
commit
9fe924b210
  1. 41
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  2. 26
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserTotalDataDao.java
  5. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactAgencyProjectDailyDao.java
  6. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java
  7. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridDailyDao.java
  8. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/topic/FactTopicTotalGridDailyDao.java
  9. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java
  10. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenCentralZoneDataAbsorptionService.java
  11. 50
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenCentralZoneDataAbsorptionServiceImpl.java
  12. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserTotalDataService.java
  13. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java
  14. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/ScreenCentralZoneDataExtractService.java
  15. 164
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java
  16. 48
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml
  17. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml
  18. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml
  19. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml
  20. 18
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml
  21. 37
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml

41
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.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.DateTimeException;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* 日期处理工具类 * 日期处理工具类
@ -640,4 +643,42 @@ public class DateUtils {
} }
return minusMonthId; 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;
}
} }

26
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;
}

10
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.AgencySubTreeDto;
import com.epmet.dto.extract.form.ExtractFormDTO; import com.epmet.dto.extract.form.ExtractFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity; 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.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService; import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService;
import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService; 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.evaluationindex.indexcal.*;
import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimAgencyService;
import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerPartymemberService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -99,6 +102,8 @@ public class DemoController {
private IndexCollCommunityService indexCollCommunityService; private IndexCollCommunityService indexCollCommunityService;
@Autowired @Autowired
private IndexCollStreetService indexCollStreetService; private IndexCollStreetService indexCollStreetService;
@Autowired
private ScreenCentralZoneDataAbsorptionService screenCentralZoneDataAbsorptionService;
@GetMapping("testAlarm") @GetMapping("testAlarm")
public void testAlarm() { public void testAlarm() {
@ -642,4 +647,9 @@ public class DemoController {
return new Result(); return new Result();
} }
@PostMapping("centralzonedatacleaning")
public Result centralZoneDataCleaning(@RequestBody ScreenCentralZoneDataFormDTO param){
screenCentralZoneDataAbsorptionService.centralZoneDataHub(param);
return new Result();
}
} }

2
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<ScreenUserTotalDataEntit
* @Date 10:52 2020-08-18 * @Date 10:52 2020-08-18
**/ **/
void batchInsertUserTotalData(@Param("list") List<UserTotalDataFormDTO> list, @Param("customerId")String customerId); void batchInsertUserTotalData(@Param("list") List<UserTotalDataFormDTO> list, @Param("customerId")String customerId);
void insertBatch(@Param("list") List<ScreenUserTotalDataEntity> list);
} }

14
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.commons.mybatis.dao.BaseDao;
import com.epmet.dto.project.form.MonthProjectListFormDTO; import com.epmet.dto.project.form.MonthProjectListFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.FactAgencyProjectDailyEntity; import com.epmet.entity.stats.FactAgencyProjectDailyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -46,4 +48,16 @@ public interface FactAgencyProjectDailyDao extends BaseDao<FactAgencyProjectDail
* @Description 根据客户Id日维度Id批量物理删除一下可能存在的历史数据 * @Description 根据客户Id日维度Id批量物理删除一下可能存在的历史数据
**/ **/
void delDateProject(FactAgencyProjectDailyEntity delEntity); void delDateProject(FactAgencyProjectDailyEntity delEntity);
/**
* @Description 根据机关类型查询项目数据
* @param orgLevel
* @param customerId
* @param dateId
* @return
* @author wangc
* @date 2020.09.24 17:19
**/
List<ScreenUserTotalDataEntity> selectProjectCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId );
} }

14
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.commons.mybatis.dao.BaseDao;
import com.epmet.dto.group.result.GroupGridDailyResultDTO; import com.epmet.dto.group.result.GroupGridDailyResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.FactGroupGridDailyEntity; import com.epmet.entity.stats.FactGroupGridDailyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* -网格日统计数据 * -网格日统计数据
@ -47,5 +49,15 @@ public interface FactGroupGridDailyDao extends BaseDao<FactGroupGridDailyEntity>
* @author zxc * @author zxc
*/ */
void deleteInsertDateId(@Param("dateId")String dateId,@Param("customerId")String customerId); 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<ScreenUserTotalDataEntity> selectGroupCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId);
} }

14
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; package com.epmet.dao.stats;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.FactIssueGridDailyEntity; import com.epmet.entity.stats.FactIssueGridDailyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 网格议题数量(按日) * 网格议题数量(按日)
* *
@ -39,5 +42,16 @@ public interface FactIssueGridDailyDao extends BaseDao<FactIssueGridDailyEntity>
* @return void * @return void
*/ */
void deleteByCustomerId(@Param("customerId") String customerId, @Param("dateId") String dateId); 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<ScreenUserTotalDataEntity> selectIssueCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId );
} }

12
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.commons.mybatis.dao.BaseDao;
import com.epmet.dto.stats.topic.FactTopicTotalGridDailyDTO; import com.epmet.dto.stats.topic.FactTopicTotalGridDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.topic.FactTopicTotalGridDailyEntity; import com.epmet.entity.stats.topic.FactTopicTotalGridDailyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -36,4 +37,15 @@ public interface FactTopicTotalGridDailyDao extends BaseDao<FactTopicTotalGridDa
void insertBatch(@Param("list") List<FactTopicTotalGridDailyDTO> list); void insertBatch(@Param("list") List<FactTopicTotalGridDailyDTO> list);
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); 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<ScreenUserTotalDataEntity> selectTopicCountByOrgLevel(@Param("orgLevel") String orgLevel, @Param("customerId") String customerId, @Param("dateId")String dateId );
} }

9
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.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.UserCountResultDTO; import com.epmet.dto.extract.result.UserCountResultDTO;
import com.epmet.dto.stats.user.FactParticipationUserGridDailyDTO; import com.epmet.dto.stats.user.FactParticipationUserGridDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity; import com.epmet.entity.stats.user.FactParticipationUserGridDailyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -48,4 +49,12 @@ public interface FactParticipationUserGridDailyDao extends BaseDao<FactParticipa
*/ */
List<UserCountResultDTO> selectUserCount(String customerId, String dateId); List<UserCountResultDTO> selectUserCount(String customerId, String dateId);
/**
* @Description 根据机构级别查询用户数与党员数
* @param orgLevel
* @return
* @author wangc
* @date 2020.09.24 14:59
**/
List<ScreenUserTotalDataEntity> selectUserAndPartymemberByOrgLevel(@Param("orgLevel") String orgLevel,@Param("customerId") String customerId, @Param("dateId")String dateId);
} }

19
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);
}

50
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<ScreenUserTotalDataEntity> dataList = screenCentralZoneDataExtractService.extractCentralZoneData(param.getCustomerId(),param.getDateId());
screenUserTotalDataService.dataClean(dataList,param.getCustomerId());
}
}

13
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.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; 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 * @since v1.0.0 2020-09-22
*/ */
public interface ScreenUserTotalDataService extends BaseService<ScreenUserTotalDataEntity> { public interface ScreenUserTotalDataService extends BaseService<ScreenUserTotalDataEntity> {
/**
* @Description 大屏中央区数据清洗
* @param list
* @return
* @author wangc
* @date 2020.09.24 17:59
**/
void dataClean(List<ScreenUserTotalDataEntity> list,String customerId);
} }

23
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.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.dao.evaluationindex.screen.ScreenUserTotalDataDao; import com.epmet.dao.evaluationindex.screen.ScreenUserTotalDataDao;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.service.evaluationindex.screen.ScreenUserTotalDataService; import com.epmet.service.evaluationindex.screen.ScreenUserTotalDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/** /**
* 中央区-各类(用户|党员|党群|话题|议题|项目)总数 * 中央区-各类(用户|党员|党群|话题|议题|项目)总数
@ -33,4 +38,22 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl<ScreenUserTotalDataDao, ScreenUserTotalDataEntity> implements ScreenUserTotalDataService { public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl<ScreenUserTotalDataDao, ScreenUserTotalDataEntity> implements ScreenUserTotalDataService {
/**
* @Description 大屏中央区数据清洗
* @param list
* @return
* @author wangc
* @date 2020.09.24 17:59
**/
@Override
public void dataClean(List<ScreenUserTotalDataEntity> list,String customerId) {
int deleteNum;
do {
deleteNum = baseDao.deleteUserTotalData(customerId);
} while (deleteNum <= NumConstant.ZERO);
if(!CollectionUtils.isEmpty(list)){
baseDao.insertBatch(list);
}
}
} }

22
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<ScreenUserTotalDataEntity> extractCentralZoneData(String customerId,String dimId);
}

164
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<ScreenUserTotalDataEntity> extractCentralZoneData(String customerId, String dimId) {
//1.查询用户与党员数据,判断dimId是否为昨天,如果根据这个dimId没有查询出结果,则取前天的数据
//如果还是查不出数据,继续向下执行,这部分数据设置默认值
List<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<String,Integer> groupMap = agencyGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal));
groupMap.putAll(gridGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal)));
//3.话题
List<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<String,Integer> topicMap = agencyTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal));
topicMap.putAll(gridTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal)));
//4.议题
List<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<String,Integer> issueMap = agencyIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal));
issueMap.putAll(gridIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)));
//5.项目
List<ScreenUserTotalDataEntity> 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<ScreenUserTotalDataEntity> 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<String,Integer> 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;
}
}

48
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserTotalDataDao.xml

@ -57,4 +57,52 @@
</foreach> </foreach>
</insert> </insert>
<insert id="insertBatch" parameterType="java.util.List">
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
<foreach collection="list" item="item" index="index" separator=",">
(
(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()
)
</foreach>
</insert>
</mapper> </mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactAgencyProjectDailyDao.xml

@ -25,4 +25,24 @@
AND date_id = #{dateId} AND date_id = #{dateId}
</delete> </delete>
<!-- 根据机关类型查询项目数据 -->
<select id="selectProjectCountByOrgLevel" resultType="com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity">
SELECT
<choose>
<when test='"grid" == orgLevel'>GRID_ID as orgId,</when>
<otherwise>AGENCY_ID AS orgId,</otherwise>
</choose>
PROJECT_TOTAL
FROM
<choose>
<when test='"grid" == orgLevel'>fact_grid_project_daily</when>
<otherwise>fact_agency_project_daily</otherwise>
</choose>
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper> </mapper>

21
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml

@ -76,4 +76,25 @@
AND customer_id = #{customerId} AND customer_id = #{customerId}
</delete> </delete>
<!-- 根据机关级别查询小组数据 -->
<select id="selectGroupCountByOrgLevel" resultType="com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity">
SELECT
<choose>
<when test='"grid" == orgLevel'>GRID_ID AS orgId,</when>
<otherwise>AGENCY_ID AS orgId,</otherwise>
</choose>
GROUP_TOTAL_COUNT AS groupTotal
FROM
<choose>
<when test='"grid" == orgLevel'>fact_group_grid_daily</when>
<otherwise>fact_group_agency_daily</otherwise>
</choose>
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper> </mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridDailyDao.xml

@ -50,4 +50,24 @@
</delete> </delete>
<!-- 根据机关类型查询议题数据 -->
<select id="selectIssueCountByOrgLevel" resultType="com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity">
SELECT
<choose>
<when test='"grid" == orgLevel'>GRID_ID as orgId,</when>
<otherwise>AGENCY_ID AS orgId,</otherwise>
</choose>
ISSUE_TOTAL
FROM
<choose>
<when test='"grid" == orgLevel'>fact_issue_grid_daily</when>
<otherwise>fact_issue_agency_daily</otherwise>
</choose>
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper> </mapper>

18
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicTotalGridDailyDao.xml

@ -90,4 +90,22 @@
</if> </if>
</delete> </delete>
<!-- 根据机关类型查询话题数据 -->
<select id="selectTopicCountByOrgLevel" resultType="com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity">
SELECT
<choose>
<when test='"grid" == orgLevel'>GRID_ID as orgId,</when>
<otherwise>AGENCY_ID AS orgId,</otherwise>
</choose>
TOPIC_TOTAL
FROM
<choose>
<when test='"grid" == orgLevel'>fact_topic_total_grid_daily</when>
<otherwise>fact_topic_total_agency_daily</otherwise>
</choose>
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</select>
</mapper> </mapper>

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

@ -121,5 +121,42 @@
AND DATE_ID = #{dateId} AND DATE_ID = #{dateId}
</select> </select>
<!-- 根据机构级别查询用户数与党员数 -->
<select id="selectUserAndPartymemberByOrgLevel" resultType="com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity">
SELECT
fact.CUSTOMER_ID,
<choose>
<when test='"grid" == orgLevel'>
fact.GRID_ID as orgId,
'grid' as orgType,
dim.GRID_NAME as orgName,
dim.AGENCY_ID as parentId,
</when>
<otherwise>
fact.AGENCY_ID AS orgId,
'agency' AS orgType,dim.AGENCY_NAME AS orgName,
dim.PID AS parentId,
</otherwise>
</choose>
fact.REG_TOTAL as userTotal,
fact.PARTYMEMBER_TOTAL as partyTotal
FROM
<choose>
<when test='"grid" == orgLevel'>fact_participation_user_grid_daily</when>
<otherwise>fact_participation_user_agency_daily</otherwise>
</choose>
fact
LEFT JOIN
<choose>
<when test='"grid" == orgLevel'>dim_grid dim ON fact.GRID_ID = dim.ID </when>
<otherwise>dim_agency dim ON fact.AGENCY_ID = dim.ID </otherwise>
</choose>
AND dim.DEL_FLAG = '0'
AND dim.CUSTOMER_ID = #{customerId}
WHERE
fact.DEL_FLAG = '0'
AND fact.CUSTOMER_ID = #{customerId}
AND fact.DATE_ID = #{dateId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save