diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CpcScoreResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CpcScoreResultDTO.java new file mode 100644 index 0000000000..31b115caab --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/GridInfoDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/GridInfoDTO.java index 06bc4d9cca..993c4ef354 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/GridInfoDTO.java +++ b/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; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/point/UserPointDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/point/UserPointDTO.java new file mode 100644 index 0000000000..067ebbf254 --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java index c03786ecfe..c1b8e5b479 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java +++ b/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 { List 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 values); + + /** + * @Description 查询客户下的党员指标得分 + * @param customerId + * @return + * @author wangc + * @date 2020.09.25 17:13 + **/ + List selectCpcScore(@Param("customerId") String customerId,@Param("monthId") String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPartyUserRankDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPartyUserRankDataDao.java index 518c3fa795..35132261cc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPartyUserRankDataDao.java +++ b/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 list,@Param("customerId")String customerId); + + /** + * @Description 批量插入 + * @param list + * @return void + * @author wangc + * @date 2020.09.27 10:06 + */ + void insertBatch(List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/point/PointDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/point/PointDao.java new file mode 100644 index 0000000000..fe777344aa --- /dev/null +++ b/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 selectUserPointByCustomerId(@Param("customerId") String customerId); + +} 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 cd84b6d3b0..fd0b7d2a86 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 @@ -48,13 +48,4 @@ 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/dao/stats/user/FactRegUserGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java index f06c4c1179..ba2c53eb2c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java +++ b/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 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/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index 28c0a2c389..b9162c30a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/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 selectGridRegUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId); + + /** + * @Description 获取客户下的网格注册居民 + * @param customerId + * @return + * @author wangc + * @date 2020.09.25 13:54 + **/ + List selectRegisteredUserByCustomerId(@Param("customerId") String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPartyUserRankDataEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPartyUserRankDataEntity.java index 4d70bf29ff..93b3a98577 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPartyUserRankDataEntity.java +++ b/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新增) */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java index af4b583eec..cb9552dd4d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java +++ b/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; + /** * 党员相关 * diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java index a837550337..41c21e6b68 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java +++ b/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 { + + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenGrassrootsGovernDataAbsorptionService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenGrassrootsGovernDataAbsorptionService.java new file mode 100644 index 0000000000..56c73b2de5 --- /dev/null +++ b/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); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java new file mode 100644 index 0000000000..563a8c65cc --- /dev/null +++ b/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 registeredUsers = userService.getRegisteredUserList(param.getCustomerId()); + + //2.查询出客户下网格的相关信息 + List gridList = customerGridService.queryGridInfoList(param.getCustomerId()); + Map gridMap = new HashMap<>(); + gridList.forEach(grid -> {gridMap.put(grid.getGridId(),grid);}); + + //3.查询出客户下用户的累计积分(累计值,没有时间概念,否则需要查询积分明细计算出评价周期末的得分) + Map 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 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) { + + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/CpcIndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/CpcIndexCalculateService.java index 3cd66eccf5..29acca93a9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/CpcIndexCalculateService.java +++ b/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 getCpcScore(String customerId, String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java index a4aaf10692..278c4a2236 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java +++ b/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 getCpcScore(String customerId, String monthId) { + List scores = cpcScoreDao.selectCpcScore(customerId,monthId); + Map map = new HashMap<>(); + if(!CollectionUtils.isEmpty(scores)){ + scores.forEach(score -> {map.put(score.getUserId(),score.getScore());}); + } + return map; + } + /** * desc: 计算总分 * diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPartyUserRankDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPartyUserRankDataService.java index 41cda44da2..a454c51734 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPartyUserRankDataService.java +++ b/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 { + + /** + * @Description 用户参与排行数据清洗 + * @param dataList + * @param customerId + * @return + * @author wangc + * @date 2020.09.27 09:44 + **/ + void dataClean(List dataList,String customerId,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/screen/impl/ScreenPartyUserRankDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPartyUserRankDataServiceImpl.java index 6e171bbe80..a543e07fff 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPartyUserRankDataServiceImpl.java +++ b/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 implements ScreenPartyUserRankDataService { + @Autowired + ScreenPartyUserRankDataDao screenPartyUserRankDataDao; + /** + * @Description 用户参与排行数据清洗 + * @param dataList + * @param customerId + * @return + * @author wangc + * @date 2020.09.27 09:44 + **/ + @Override + public void dataClean(List dataList, String customerId, String dateId) { + int affectedRows; + do{ + affectedRows = baseDao.deleteBatchByCustomerIdAndDateId(customerId,dateId); + }while (affectedRows > NumConstant.ZERO); + baseDao.insertBatch(dataList); + } } \ 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 a1b21beced..2ab95df738 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 @@ -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 implements ScreenUserTotalDataService { /** @@ -46,11 +50,12 @@ public class ScreenUserTotalDataServiceImpl extends BaseServiceImpl 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); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/UserPointService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/UserPointService.java new file mode 100644 index 0000000000..ce185cad6a --- /dev/null +++ b/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 getUserPointMap(String customerId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/impl/UserPointServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/point/impl/UserPointServiceImpl.java new file mode 100644 index 0000000000..0402afe418 --- /dev/null +++ b/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 getUserPointMap(String customerId) { + List points = pointDao.selectUserPointByCustomerId(customerId); + Map map = new HashMap<>(); + if(!CollectionUtils.isEmpty(points)){ + points.forEach(point -> {map.put(point.getUserId(),point.getPointTotal());}); + } + return map; + } +} 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 index a36695b6b0..24811db736 100644 --- 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 @@ -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 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 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 projectMap = agencyProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)); - projectMap.putAll(gridProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal))); + Map 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); }); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java index 29521f2f2c..767af842b0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java +++ b/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 getGridRegUserIds(String customerId, String gridId); + + /** + * @Description 获取客户下的网格注册居民 + * @param customerId + * @return + * @author wangc + * @date 2020.09.25 13:54 + **/ + List getRegisteredUserList(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 12616b584c..faf43458cd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/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 * @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 getRegisteredUserList(String customerId) { + List userList = userDao.selectRegisteredUserByCustomerId(customerId); + List partyList = userDao.selectPartymembersByCustomerId(customerId); + if(!CollectionUtils.isEmpty(userList)){ + userList.forEach(user -> { + if(partyList.contains(user.getUserId())){ + user.setPartyFlag(NumConstant.ONE); + } + }); + } + return userList; + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml index 8fbb50a81d..bf0cfd3d51 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml @@ -148,4 +148,18 @@ ) + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml index d4089fcc30..6ca1f5da66 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyUserRankDataDao.xml @@ -9,6 +9,13 @@ limit 1000; + + delete from screen_party_user_rank_data + where CUSTOMER_ID = #{customerId} + AND DATA_END_TIME = #{dateId} + limit 1000; + + insert into screen_party_user_rank_data ( @@ -59,4 +66,56 @@ + + 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 + + ( + (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} + ) + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 41ce69835f..ea0d0fc48b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/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 ) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/point/UserPointDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/point/UserPointDao.xml new file mode 100644 index 0000000000..418d4dd49f --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/point/UserPointDao.xml @@ -0,0 +1,19 @@ + + + + + + + + + + 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 c8e631ed88..7b4c669324 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 @@ -80,11 +80,10 @@ - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml index f8d85b7ab9..855007785a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml @@ -106,4 +106,47 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml index 03f525d12d..55bc599470 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -459,6 +459,8 @@ + + + + +