32 changed files with 651 additions and 94 deletions
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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); |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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) { |
|||
|
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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> |
|||
|
Loading…
Reference in new issue