Browse Source

基层治理-热心市民、党员排行

dev_shibei_match
wangchao 5 years ago
parent
commit
71234ea71b
  1. 27
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CpcScoreResultDTO.java
  2. 10
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/GridInfoDTO.java
  3. 26
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/point/UserPointDTO.java
  4. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java
  5. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPartyUserRankDataDao.java
  6. 27
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/point/PointDao.java
  7. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java
  8. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java
  9. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
  10. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPartyUserRankDataEntity.java
  11. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java
  12. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java
  13. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenGrassrootsGovernDataAbsorptionService.java
  14. 119
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java
  15. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/CpcIndexCalculateService.java
  16. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java
  17. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPartyUserRankDataService.java
  18. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPartyUserRankDataServiceImpl.java
  19. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserTotalDataServiceImpl.java
  20. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/UserPointService.java
  21. 46
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/impl/UserPointServiceImpl.java
  22. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java
  23. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
  24. 50
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
  25. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml
  26. 59
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml
  27. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
  28. 19
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/point/UserPointDao.xml
  29. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml
  30. 37
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml
  31. 43
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml
  32. 24
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

27
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CpcScoreResultDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Description 党员指标得分查询DTO
* @ClassName CpcScoreResultDTO
* @Auth wangc
* @Date 2020-09-25 16:52
*/
@Data
public class CpcScoreResultDTO implements Serializable {
private static final long serialVersionUID = -7129757727997430029L;
/**
* 用户Id
* */
private String userId;
/**
* 党员指标得分
* */
private BigDecimal score;
}

10
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/GridInfoDTO.java

@ -38,4 +38,14 @@ public class GridInfoDTO implements Serializable {
* agencyId的pids
*/
private String pids;
/**
* 网格名称
* */
private String gridName;
/**
* 机关名称
* */
private String orgName;
}

26
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/point/UserPointDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.point;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 用户积分DTO
* @ClassName UserPointDTO
* @Auth wangc
* @Date 2020-09-25 15:42
*/
@Data
public class UserPointDTO implements Serializable {
private static final long serialVersionUID = 6976982699085437418L;
/**
* 用户Id
* */
private String userId;
/**
* 用户累计积分
* */
private Integer pointTotal;
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CpcScoreResultDTO;
import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -83,4 +84,13 @@ public interface CpcScoreDao extends BaseDao<CpcScoreEntity> {
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentCode") String allParentCode, @Param("offset") int offset, @Param("pageSize") int pageSize);
int insertBatch(@Param("list") Collection<CpcScoreEntity> values);
/**
* @Description 查询客户下的党员指标得分
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 17:13
**/
List<CpcScoreResultDTO> selectCpcScore(@Param("customerId") String customerId,@Param("monthId") String monthId);
}

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPartyUserRankDataDao.java

@ -45,6 +45,15 @@ public interface ScreenPartyUserRankDataDao extends BaseDao<ScreenPartyUserRankD
**/
Integer deletePartyUserRankData(@Param("customerId") String customerId);
/**
* @Description 按照客户月份删除
* @param
* @return java.lang.Integer
* @author wangc
* @date 2020.09.27 11:19
*/
Integer deleteBatchByCustomerIdAndDateId(@Param("customerId") String customerId,@Param("dateId") String dateId);
/**
* 9党建引领|基层治理-居民党员积分排行榜
* 2) 在批量新增
@ -55,4 +64,13 @@ public interface ScreenPartyUserRankDataDao extends BaseDao<ScreenPartyUserRankD
* @Date 10:52 2020-08-18
**/
void batchInsertPartyUserRankData(@Param("list") List<PartyUserRankDataFormDTO> list,@Param("customerId")String customerId);
/**
* @Description 批量插入
* @param list
* @return void
* @author wangc
* @date 2020.09.27 10:06
*/
void insertBatch(List<ScreenPartyUserRankDataEntity> list);
}

27
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/point/PointDao.java

@ -0,0 +1,27 @@
package com.epmet.dao.point;
import com.epmet.dto.point.UserPointDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 积分查询DAO
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Mapper
public interface PointDao {
/**
* @Description 查询客户下的用户积分
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 15:51
**/
List<UserPointDTO> selectUserPointByCustomerId(@Param("customerId") String customerId);
}

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

@ -48,13 +48,4 @@ public interface FactParticipationUserGridDailyDao extends BaseDao<FactParticipa
* @date 2020/9/23 9:57 上午
*/
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);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java

@ -19,6 +19,7 @@ package com.epmet.dao.stats.user;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.stats.user.FactRegUserGridDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.entity.stats.user.FactRegUserGridDailyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -38,4 +39,12 @@ public interface FactRegUserGridDailyDao extends BaseDao<FactRegUserGridDailyEnt
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @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);
}

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

@ -3,6 +3,7 @@ package com.epmet.dao.user;
import com.epmet.dto.extract.form.GridHeartedFormDTO;
import com.epmet.dto.extract.result.UserPartyResultDTO;
import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -121,4 +122,13 @@ public interface UserDao {
* @Date 2020/9/21 13:46
**/
List<String> selectGridRegUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId);
/**
* @Description 获取客户下的网格注册居民
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 13:54
**/
List<ScreenPartyUserRankDataEntity> selectRegisteredUserByCustomerId(@Param("customerId") String customerId);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPartyUserRankDataEntity.java

@ -22,6 +22,8 @@ import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 党建引领基层治理-市民党员积分排行榜
*
@ -90,6 +92,10 @@ public class ScreenPartyUserRankDataEntity extends BaseEpmetEntity {
*/
private Integer pointTotal;
/**
* 党员指标得分
* */
private BigDecimal indexScore;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java

@ -1,5 +1,7 @@
package com.epmet.service.evaluationindex.extract.dataToIndex;
import java.util.Map;
/**
* 党员相关
*

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.extract.dataToIndex.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.indexcal.CpcScoreResultDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import com.epmet.service.evaluationindex.extract.dataToIndex.CalCpcIndexService;
import com.epmet.service.evaluationindex.extract.todata.*;
@ -126,7 +127,6 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId,monthId,indexPartyAblityCpcList);
}
/**
* @param customerId
* @param partyMemberList
@ -400,4 +400,6 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
}

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

@ -0,0 +1,29 @@
package com.epmet.service.evaluationindex.extract.toscreen;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
/**
* 基层治理
* 热心市民积分 党员能力值
* 难点赌点
* */
public interface ScreenGrassrootsGovernDataAbsorptionService {
/**
* @Description 用户积分党员分值数据中转站
* @param param
* @return
* @author wangc
* @date 2020.09.25 09:53
**/
void userScoreDataHub(ScreenCentralZoneDataFormDTO param);
/**
* @Description 难点赌点数据中转站
* @param param
* @return
* @author wangc
* @date 2020.09.25 10:00
**/
void difficultyDataHub(ScreenCentralZoneDataFormDTO param);
}

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

@ -0,0 +1,119 @@
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.org.GridInfoDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovernDataAbsorptionService;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.screen.ScreenPartyUserRankDataService;
import com.epmet.service.org.CustomerGridService;
import com.epmet.service.point.UserPointService;
import com.epmet.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description 基层治理数据
* @ClassName ScreenGrassrootsGovernDataAbsorptionServiceImpl
* @Auth wangc
* @Date 2020-09-25 09:48
*/
@Service
@Slf4j
public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGrassrootsGovernDataAbsorptionService {
@Autowired
private UserService userService;
@Autowired
private CustomerGridService customerGridService;
@Autowired
private UserPointService userPointService;
@Autowired
private CpcIndexCalculateService cpcIndexCalculateService;
@Autowired
private ScreenPartyUserRankDataService screenPartyUserRankDataService;
/**
* @Description 用户积分党员分值数据中转站
* @param param
* @return
* @author wangc
* @date 2020.09.25 09:53
**/
@Override
public void userScoreDataHub(ScreenCentralZoneDataFormDTO param) {
//1.查询出客户下的网格注册用户
List<ScreenPartyUserRankDataEntity> registeredUsers = userService.getRegisteredUserList(param.getCustomerId());
//2.查询出客户下网格的相关信息
List<GridInfoDTO> gridList = customerGridService.queryGridInfoList(param.getCustomerId());
Map<String,GridInfoDTO> gridMap = new HashMap<>();
gridList.forEach(grid -> {gridMap.put(grid.getGridId(),grid);});
//3.查询出客户下用户的累计积分(累计值,没有时间概念,否则需要查询积分明细计算出评价周期末的得分)
Map<String,Integer> pointMap = userPointService.getUserPointMap(param.getCustomerId());
//4.查询出客户下党员的分值
String dateId = param.getDateId();
if(StringUtils.isEmpty(dateId)){
//如果没有传月份,则使用当前时间的上一个月
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
}else{
String dateType = DateUtils.identifyTimeDimension(dateId);
if(StringUtils.isEmpty(dateType) || !org.apache.commons.lang3.StringUtils.equalsAny(dateType,"date","month")){
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
}else if(org.apache.commons.lang3.StringUtils.equals(dateType,"date")){
dateId = dateId.substring(NumConstant.ZERO,dateId.length() - NumConstant.TWO);
}
}
final String finalDateId = dateId;
Map<String, BigDecimal> scoreMap = cpcIndexCalculateService.getCpcScore(param.getCustomerId(),dateId);
//5.整合数据
if(!CollectionUtils.isEmpty(registeredUsers)){
registeredUsers.forEach(user -> {
GridInfoDTO gridInfo = gridMap.get(user.getGridId());
if(null != gridInfo){
user.setGridName(gridInfo.getGridName());
user.setOrgId(gridInfo.getAgencyId());
user.setOrgName(gridInfo.getOrgName());
user.setAllParentIds(gridInfo.getPids());
}
Integer point = pointMap.get(user.getUserId());
BigDecimal score = scoreMap.get(user.getUserId());
user.setPointTotal(null == point ? NumConstant.ZERO : point);
user.setIndexScore(null == score ? new BigDecimal(NumConstant.ZERO) : score);
user.setDataEndTime(finalDateId);
});
}
//6.存入数据库
screenPartyUserRankDataService.dataClean(registeredUsers,param.getCustomerId(),dateId);
}
/**
* @Description 难点赌点数据中转站
* @param param
* @return
* @author wangc
* @date 2020.09.25 10:00
**/
@Override
public void difficultyDataHub(ScreenCentralZoneDataFormDTO param) {
}
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/CpcIndexCalculateService.java

@ -2,6 +2,9 @@ package com.epmet.service.evaluationindex.indexcal;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import java.math.BigDecimal;
import java.util.Map;
/**
* 党员指标计算service
*
@ -15,4 +18,14 @@ public interface CpcIndexCalculateService {
* @return
*/
Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO);
/**
* @Description 获取党员指标得分
* @param customerId
* @param monthId
* @return
* @author wangc
* @date 2020.09.25 16:48
**/
Map<String, BigDecimal> getCpcScore(String customerId, String monthId);
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CpcSubScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CpcScoreResultDTO;
import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.CpcSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
@ -66,6 +67,24 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
return true;
}
/**
* @Description 获取党员指标得分
* @param customerId
* @param monthId
* @return
* @author wangc
* @date 2020.09.25 16:48
**/
@Override
public Map<String, BigDecimal> getCpcScore(String customerId, String monthId) {
List<CpcScoreResultDTO> scores = cpcScoreDao.selectCpcScore(customerId,monthId);
Map<String,BigDecimal> map = new HashMap<>();
if(!CollectionUtils.isEmpty(scores)){
scores.forEach(score -> {map.put(score.getUserId(),score.getScore());});
}
return map;
}
/**
* desc: 计算总分
*

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPartyUserRankDataService.java

@ -20,6 +20,8 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import java.util.List;
/**
* 党建引领基层治理-市民党员积分排行榜
*
@ -28,4 +30,15 @@ import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
*/
public interface ScreenPartyUserRankDataService extends BaseService<ScreenPartyUserRankDataEntity> {
/**
* @Description 用户参与排行数据清洗
* @param dataList
* @param customerId
* @return
* @author wangc
* @date 2020.09.27 09:44
**/
void dataClean(List<ScreenPartyUserRankDataEntity> dataList,String customerId,String dateId);
}

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

@ -19,11 +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.ScreenPartyUserRankDataDao;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.service.evaluationindex.screen.ScreenPartyUserRankDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 党建引领基层治理-市民党员积分排行榜
*
@ -33,5 +37,23 @@ import org.springframework.stereotype.Service;
@Service
public class ScreenPartyUserRankDataServiceImpl extends BaseServiceImpl<ScreenPartyUserRankDataDao, ScreenPartyUserRankDataEntity> implements ScreenPartyUserRankDataService {
@Autowired
ScreenPartyUserRankDataDao screenPartyUserRankDataDao;
/**
* @Description 用户参与排行数据清洗
* @param dataList
* @param customerId
* @return
* @author wangc
* @date 2020.09.27 09:44
**/
@Override
public void dataClean(List<ScreenPartyUserRankDataEntity> dataList, String customerId, String dateId) {
int affectedRows;
do{
affectedRows = baseDao.deleteBatchByCustomerIdAndDateId(customerId,dateId);
}while (affectedRows > NumConstant.ZERO);
baseDao.insertBatch(dataList);
}
}

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

@ -18,13 +18,16 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.DataSourceConstant;
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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
@ -36,6 +39,7 @@ import java.util.List;
* @since v1.0.0 2020-09-22
*/
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl<ScreenUserTotalDataDao, ScreenUserTotalDataEntity> implements ScreenUserTotalDataService {
/**
@ -46,11 +50,12 @@ public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl<ScreenUserTo
* @date 2020.09.24 17:59
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void dataClean(List<ScreenUserTotalDataEntity> list,String customerId) {
int deleteNum;
do {
deleteNum = baseDao.deleteUserTotalData(customerId);
} while (deleteNum <= NumConstant.ZERO);
} while (deleteNum > NumConstant.ZERO);
if(!CollectionUtils.isEmpty(list)){
baseDao.insertBatch(list);

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/UserPointService.java

@ -0,0 +1,18 @@
package com.epmet.service.point;
import java.util.Map;
/**
* 用户积分库
* */
public interface UserPointService {
/**
* @Description 根据客户Id查询用户积分Map
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 16:00
**/
Map<String,Integer> getUserPointMap(String customerId);
}

46
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/impl/UserPointServiceImpl.java

@ -0,0 +1,46 @@
package com.epmet.service.point.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.point.PointDao;
import com.epmet.dto.point.UserPointDTO;
import com.epmet.service.point.UserPointService;
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.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @ClassName UserPointServiceImpl
* @Auth wangc
* @Date 2020-09-25 15:54
*/
@Service
@Slf4j
@DataSource(DataSourceConstant.EPMET_POINT)
public class UserPointServiceImpl implements UserPointService {
@Autowired
private PointDao pointDao;
/**
* @Description 根据客户Id查询用户积分Map
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 16:00
**/
@Override
public Map<String, Integer> getUserPointMap(String customerId) {
List<UserPointDTO> points = pointDao.selectUserPointByCustomerId(customerId);
Map<String,Integer> map = new HashMap<>();
if(!CollectionUtils.isEmpty(points)){
points.forEach(point -> {map.put(point.getUserId(),point.getPointTotal());});
}
return map;
}
}

34
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java

@ -5,12 +5,11 @@ 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.dao.stats.user.FactRegUserGridDailyDao;
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity;
import com.epmet.service.stats.ScreenCentralZoneDataExtractService;
import lombok.extern.slf4j.Slf4j;
@ -35,7 +34,7 @@ import java.util.stream.Collectors;
public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZoneDataExtractService {
@Autowired
private FactParticipationUserGridDailyDao factParticipationUserGridDailyDao;
private FactRegUserGridDailyDao factRegUserGridDailyDao;
@Autowired
private FactGroupGridDailyDao factGroupGridDailyDao;
@Autowired
@ -63,20 +62,22 @@ public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZon
//1.查询用户与党员数据,判断dimId是否为昨天,如果根据这个dimId没有查询出结果,则取前天的数据
//如果还是查不出数据,继续向下执行,这部分数据设置默认值
//注册用户数
List<ScreenUserTotalDataEntity> result =
factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId);
factRegUserGridDailyDao.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));
result = factRegUserGridDailyDao.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);
factRegUserGridDailyDao.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));
gridUserResult = factRegUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO));
}
}
if(!CollectionUtils.isEmpty(gridUserResult)){
@ -145,15 +146,22 @@ public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZon
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)));
Map<String,Integer> projectMap = agencyProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getProjectTotal));
projectMap.putAll(gridProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getProjectTotal)));
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));
Integer count = groupMap.get(orgId);
o.setGroupTotal(null == count ? NumConstant.ZERO : count);
count = topicMap.get(orgId);
o.setTopicTotal(null == count ? NumConstant.ZERO : count);
count = issueMap.get(orgId);
o.setIssueTotal(null == count ? NumConstant.ZERO : count);
count = projectMap.get(orgId);
o.setProjectTotal(null == count ? NumConstant.ZERO : count);
o.setDataEndTime(dimId);
});

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

@ -3,6 +3,7 @@ package com.epmet.service.user;
import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.extract.form.GridHeartedFormDTO;
import com.epmet.dto.stats.user.result.UserStatisticalData;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.util.DimIdGenerator;
import org.apache.ibatis.annotations.Param;
@ -65,4 +66,13 @@ public interface UserService {
* @Date 2020/9/21 16:44
**/
List<String> getGridRegUserIds(String customerId, String gridId);
/**
* @Description 获取客户下的网格注册居民
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 13:54
**/
List<ScreenPartyUserRankDataEntity> getRegisteredUserList(String customerId);
}

50
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java

@ -11,6 +11,7 @@ import com.epmet.dto.extract.result.UserPartyResultDTO;
import com.epmet.dto.stats.user.*;
import com.epmet.dto.stats.user.result.UserStatisticalData;
import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.service.user.UserService;
import com.epmet.util.DimIdGenerator;
import com.epmet.util.ModuleConstant;
@ -23,7 +24,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -357,10 +357,6 @@ public class UserServiceImpl implements UserService {
dataPacket.setPartiAgencyDailyList(list);
}
FactRegUserAgencyMonthlyDTO regAgencyM = new FactRegUserAgencyMonthlyDTO();
regAgencyM.setCustomerId(customerId);
regAgencyM.setAgencyId(agencyId);
@ -695,32 +691,9 @@ public class UserServiceImpl implements UserService {
}
}
public static void main(String[] args) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
//calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
System.out.println(format.format(calendar.getTime()));
calendar.setTime(calendar.getTime());
calendar.add(Calendar.DATE, -1);
System.out.println(calendar.getTime());
System.out.println(format.format(calendar.getTime()));
System.out.println(format2.format(calendar.getTime()));
}
/**
* @return java.util.List<java.lang.String>
* @param customerId
@ -735,4 +708,25 @@ public class UserServiceImpl implements UserService {
return userDao.selectGridRegUserIds(customerId,gridId);
}
/**
* @Description 获取客户下的网格注册居民
* @param customerId
* @return
* @author wangc
* @date 2020.09.25 13:54
**/
@Override
public List<ScreenPartyUserRankDataEntity> getRegisteredUserList(String customerId) {
List<ScreenPartyUserRankDataEntity> userList = userDao.selectRegisteredUserByCustomerId(customerId);
List<String> partyList = userDao.selectPartymembersByCustomerId(customerId);
if(!CollectionUtils.isEmpty(userList)){
userList.forEach(user -> {
if(partyList.contains(user.getUserId())){
user.setPartyFlag(NumConstant.ONE);
}
});
}
return userList;
}
}

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml

@ -148,4 +148,18 @@
)
</foreach>
</insert>
<!-- 查询客户下的党员指标得分 -->
<select id="selectCpcScore" resultType="com.epmet.dto.indexcal.CpcScoreResultDTO">
SELECT
USER_ID,
SCORE
FROM
fact_index_cpc_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND IS_TOTAL = '1'
AND MONTH_ID = #{monthId}
</select>
</mapper>

59
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml

@ -9,6 +9,13 @@
limit 1000;
</delete>
<delete id="deleteBatchByCustomerIdAndDateId">
delete from screen_party_user_rank_data
where CUSTOMER_ID = #{customerId}
AND DATA_END_TIME = #{dateId}
limit 1000;
</delete>
<insert id="batchInsertPartyUserRankData" parameterType="map">
insert into screen_party_user_rank_data
(
@ -59,4 +66,56 @@
</foreach>
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into screen_party_user_rank_data
(
ID,
CUSTOMER_ID,
GRID_ID,
GRID_NAME,
ORG_ID,
ORG_NAME,
PARTY_FLAG,
USER_ID,
SURNAME,
`NAME`,
USER_NAME,
POINT_TOTAL,
INDEX_SCORE,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME,
DATA_END_TIME,
ALL_PARENT_IDS
) values
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{customerId},
#{item.gridId},
#{item.gridName},
#{item.orgId},
#{item.orgName},
#{item.partyFlag},
#{item.userId},
#{item.surname},
#{item.name},
#{item.userName},
#{item.pointTotal},
#{item.indexScore},
'0',
0,
'CRAWLER_ROBOT',
now(),
'CRAWLER_ROBOT',
now(),
#{item.dataEndTime},
#{item.allParentIds}
)
</foreach>
</insert>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -74,8 +74,10 @@
cg.ID as GRID_ID,
cg.PID as AGENCY_ID,
ca.PID AS PID,
CG.CUSTOMER_ID,
cg.PIDS as PIDS
cg.CUSTOMER_ID,
cg.PIDS as PIDS,
cg.GRID_NAME,
ca.ORGANIZATION_NAME as ORG_NAME
FROM
customer_grid cg
LEFT JOIN customer_agency ca ON ( cg.PID = CA.ID )

19
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/point/UserPointDao.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.point.PointDao">
<select id="selectUserPointByCustomerId" resultType="com.epmet.dto.point.UserPointDTO">
SELECT
USER_ID,
TOTAL_POINT
FROM
USER_POINT_TOTAL point
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
</select>
</mapper>

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

@ -80,11 +80,10 @@
<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>
<when test='"grid" == orgLevel'>GRID_ID AS orgId,GROUP_TOTAL AS groupTotal</when>
<otherwise>AGENCY_ID AS orgId,GROUP_TOTAL_COUNT AS groupTotal</otherwise>
</choose>
GROUP_TOTAL_COUNT AS groupTotal
FROM
<choose>
<when test='"grid" == orgLevel'>fact_group_grid_daily</when>

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

@ -121,42 +121,5 @@
AND DATE_ID = #{dateId}
</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>

43
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml

@ -106,4 +106,47 @@
</if>
</delete>
<!-- 根据机构级别查询用户数与党员数 -->
<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_reg_user_grid_daily</when>
<otherwise>fact_reg_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>

24
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

@ -459,6 +459,8 @@
</select>
<!-- 查询当前网格下,首次注册的用户ids -->
<select id="selectGridRegUserIds" parameterType="map" resultType="java.lang.String">
SELECT DISTINCT
USER_ID
@ -470,4 +472,26 @@
and rr.GRID_ID=#{gridId}
AND rr.FIRST_REGISTER = '1'
</select>
<!-- 获取客户下的网格注册居民 -->
<select id="selectRegisteredUserByCustomerId" resultType="com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity">
SELECT
register.CUSTOMER_ID,
register.GRID_ID,
register.USER_ID,
base.SURNAME,
base.NAME,
base.REAl_NAME AS userName,
0 AS partyFlag,
0 AS POINT_TOTAL,
0 AS INDEX_SCORE
FROM
REGISTER_RELATION register
LEFT JOIN USER_BASE_INFO base ON register.USER_ID = base.USER_ID
AND base.DEL_FLAG = '0'
WHERE
register.DEL_FLAG = '0'
AND register.CUSTOMER_ID = #{customerId}
AND register.FIRST_REGISTER = '1'
</select>
</mapper>

Loading…
Cancel
Save