Commit c1b3c16f1b082918a80ebfef31dbe81f89d4d39c

Authored by 姜超
1 parent f692be3a

feature(*): 门店考评池查询

门店考评池查询
fw-morax-dao/src/main/java/cn/fw/morax/dao/eval/EvalShopPoolDao.java
... ... @@ -3,6 +3,9 @@ package cn.fw.morax.dao.eval;
3 3  
4 4 import cn.fw.morax.domain.db.eval.EvalShopPool;
5 5 import cn.fw.morax.domain.db.eval.EvalUserPool;
  6 +import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO;
  7 +import cn.fw.morax.domain.vo.eval.EvalShopPoolVO;
  8 +import cn.fw.morax.domain.vo.eval.EvalUserPoolVO;
6 9 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
7 10 import org.apache.ibatis.annotations.Param;
8 11  
... ... @@ -21,4 +24,19 @@ public interface EvalShopPoolDao extends BaseMapper<EvalShopPool> {
21 24  
22 25 List<EvalShopPool> getLastPool(@Param("monthly") YearMonth monthly, @Param("groupId") Long groupId);
23 26  
  27 + /**
  28 + * 考评池分页查询
  29 + *
  30 + * @param dto
  31 + * @return
  32 + */
  33 + List<EvalShopPoolVO> queryPagePool(@Param("condition") EvalPoolQueryDTO dto, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
  34 +
  35 + /**
  36 + * 查询考评池数据总署
  37 + *
  38 + * @param dto
  39 + * @return
  40 + */
  41 + long queryPagePoolTotal(@Param("condition") EvalPoolQueryDTO dto);
24 42 }
... ...
fw-morax-dao/src/main/java/cn/fw/morax/dao/eval/EvalUserPoolDao.java
... ... @@ -40,5 +40,5 @@ public interface EvalUserPoolDao extends BaseMapper&lt;EvalUserPool&gt; {
40 40 * @param dto
41 41 * @return
42 42 */
43   - long queryPagePoolTotal(EvalPoolQueryDTO dto);
  43 + long queryPagePoolTotal(@Param("condition") EvalPoolQueryDTO dto);
44 44 }
... ...
fw-morax-dao/src/main/resources/mapper/eval/EvalShopPoolDao.xml
... ... @@ -7,40 +7,25 @@
7 7 <result column="id" property="id"/>
8 8 <result column="egc" property="egc"/>
9 9 <result column="eval_group_id" property="evalGroupId"/>
10   - <result column="user_id" property="userId"/>
11   - <result column="user_name" property="userName"/>
12   - <result column="post_id" property="postId"/>
13   - <result column="post_name" property="postName"/>
14 10 <result column="shop_id" property="shopId"/>
15 11 <result column="shop_name" property="shopName"/>
16   - <result column="fund_shop_id" property="fundShopId"/>
17   - <result column="fund_shop_name" property="fundShopName"/>
18 12 <result column="reward" property="reward"/>
19 13 <result column="score" property="score"/>
20 14 <result column="score_ratio" property="scoreRatio"/>
21 15 <result column="monthly" property="monthly"/>
22   - <result column="regular" property="regular"/>
23 16 <result column="group_id" property="groupId"/>
24 17 <result column="yn" property="yn"/>
25 18 <result column="create_time" property="createTime"/>
26 19 <result column="update_time" property="updateTime"/>
27 20 </resultMap>
28 21  
  22 + <sql id="all_columns">
  23 + id,eval_id,egc,eval_group_id,shop_id,shop_name,reward,status,score,score_ratio,monthly,group_id,
  24 + </sql>
  25 +
29 26 <select id="getLastPool" resultType="cn.fw.morax.domain.db.eval.EvalShopPool">
30 27 SELECT
31   - t1.id,
32   - t1.egc,
33   - t1.eval_group_id,
34   - t1.shop_id,
35   - t1.shop_name,
36   - t1.reward,
37   - t1.status,
38   - t1.score,
39   - t1.monthly,
40   - t1.group_id,
41   - t1.yn,
42   - t1.create_time,
43   - t1.update_time,
  28 + <include refid="all_columns"/>
44 29 FROM
45 30 eval_shop_pool t1,
46 31 (
... ... @@ -59,5 +44,56 @@
59 44 t1.id = t2.pk
60 45 </select>
61 46  
  47 + <select id="queryPagePool" resultType="cn.fw.morax.domain.vo.eval.EvalShopPoolVO">
  48 + SELECT
  49 + t1.id,
  50 + t1.eval_id,
  51 + t1.egc,
  52 + t1.eval_group_id,
  53 + t1.shop_id,
  54 + t1.shop_name,
  55 + t1.reward,
  56 + t1.status,
  57 + t1.score,
  58 + t1.score_ratio,
  59 + t1.monthly,
  60 + t1.group_id,
  61 + t2.name as evalGroupName
  62 + from eval_shop_pool t1
  63 + left join eval_group t2 on t1.eval_group_id = t2.id
  64 + where t1.yn = 1
  65 + and t1.group_id = #{condition.groupId}
  66 + <if test="condition.monthly !=null">
  67 + and t1.monthly = #{condition.monthly}
  68 + </if>
  69 + <if test="condition.managerShopIds !=null and condition.managerShopIds.size() > 0">
  70 + and t1.shop_id in
  71 + <foreach collection="condition.managerShopIds" item="id" index="index" open="(" close=")" separator=",">
  72 + #{id}
  73 + </foreach>
  74 + </if>
  75 + <if test="condition.orderString != null and condition.orderString !='' ">
  76 + ${condition.orderString}
  77 + </if>
  78 + limit #{startIndex},#{pageSize};
  79 + </select>
  80 +
  81 +
  82 + <select id="queryPagePoolTotal" resultType="java.lang.Long">
  83 + SELECT
  84 + IFNULL(count(1),0)
  85 + from eval_user_pool
  86 + where yn = 1
  87 + and group_id = #{condition.groupId}
  88 + <if test="condition.monthly !=null">
  89 + and monthly = #{condition.monthly}
  90 + </if>
  91 + <if test="condition.managerShopIds !=null and condition.managerShopIds.size() > 0">
  92 + and shop_id in
  93 + <foreach collection="condition.managerShopIds" item="id" index="index" open="(" close=")" separator=",">
  94 + #{id}
  95 + </foreach>
  96 + </if>
  97 + </select>
62 98  
63 99 </mapper>
64 100 \ No newline at end of file
... ...
fw-morax-dao/src/main/resources/mapper/eval/EvalUserPoolDao.xml
... ... @@ -59,34 +59,46 @@
59 59 t1.id = t2.pk
60 60 </select>
61 61  
62   - <select id="getPools" resultType="cn.fw.morax.domain.vo.eval.EvalUserPoolVO">
  62 + <select id="queryPagePool" resultType="cn.fw.morax.domain.vo.eval.EvalUserPoolVO">
63 63 SELECT
64   - t1.id,
65   - t1.egc,
66   - t1.eval_id,
67   - t1.eval_group_id,
68   - t1.user_id,
69   - t1.user_name,
70   - t1.post_id,
71   - t1.post_name,
72   - t1.shop_id,
73   - t1.shop_name,
74   - t1.fund_shop_id,
75   - t1.fund_shop_name,
76   - t1.reward,
77   - t1.score,
78   - t1.monthly,
79   - t1.group_id,
80   - t2.name as evalGroupName,
81   - t3.name as evalName
82   - FROM
83   - eval_user_pool t1
84   - left join eval_group t2 on t1.eval_group_id = t2.id
85   - left join eval t3 on t1.eval_id = t3.id
86   - WHERE
87   - t1.monthly = #{monthly}
88   - AND t1.user_id = #{userId}
89   - order by t1.create_time desc
  64 + *
  65 + from eval_user_pool
  66 + where yn = 1
  67 + and group_id = #{condition.groupId}
  68 + <if test="condition.userId !=null">
  69 + and user_id = #{condition.userId}
  70 + </if>
  71 + <if test="condition.userName !=null and condition.userName != ''">
  72 + and user_name like concat('%', #{condition.userName}, '%')
  73 + </if>
  74 + <if test="condition.startLevel !=null">
  75 + and star_level = #{condition.startLevel}
  76 + </if>
  77 + <if test="condition.monthly !=null">
  78 + and monthly = #{condition.monthly}
  79 + </if>
  80 + <if test="condition.postId !=null">
  81 + and post_id = #{condition.postId}
  82 + </if>
  83 + <if test="condition.postName !=null and condition.postName != ''">
  84 + and post_name like concat('%', #{condition.postName}, '%')
  85 + </if>
  86 + <if test="condition.shopId !=null">
  87 + and shop_id = #{condition.shopId}
  88 + </if>
  89 + <if test="condition.shopName !=null and condition.shopName != ''">
  90 + and shop_name like concat('%', #{condition.shopName}, '%')
  91 + </if>
  92 + <if test="condition.managerStaffIds !=null and condition.managerStaffIds.size() > 0">
  93 + and user_id in
  94 + <foreach collection="condition.managerStaffIds" item="id" index="index" open="(" close=")" separator=",">
  95 + #{id}
  96 + </foreach>
  97 + </if>
  98 + <if test="condition.orderString != null and condition.orderString !='' ">
  99 + ${condition.orderString}
  100 + </if>
  101 + limit #{startIndex},#{pageSize};
90 102 </select>
91 103  
92 104  
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalShopPool.java
... ... @@ -8,6 +8,7 @@ import lombok.Data;
8 8 import lombok.EqualsAndHashCode;
9 9  
10 10 import java.math.BigDecimal;
  11 +import java.time.LocalDate;
11 12  
12 13 /**
13 14 * <p>
... ... @@ -88,10 +89,10 @@ public class EvalShopPool extends BaseAuditableTimeEntity&lt;EvalShopPool, Long&gt; {
88 89 */
89 90 private BigDecimal score;
90 91  
91   -// /**
92   -// * 考评得分率
93   -// */
94   -// private BigDecimal scoreRatio;
  92 + /**
  93 + * 考评得分率
  94 + */
  95 + private BigDecimal scoreRatio;
95 96  
96 97 /**
97 98 * 月度
... ... @@ -99,6 +100,11 @@ public class EvalShopPool extends BaseAuditableTimeEntity&lt;EvalShopPool, Long&gt; {
99 100 private String monthly;
100 101  
101 102 /**
  103 + * 数据日期
  104 + */
  105 + private LocalDate dataDate;
  106 +
  107 + /**
102 108 * 固定的
103 109 */
104 110 private EvalShopPoolStatusEnum status;
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalUserPool.java
... ... @@ -7,6 +7,7 @@ import lombok.Data;
7 7 import lombok.EqualsAndHashCode;
8 8  
9 9 import java.math.BigDecimal;
  10 +import java.time.LocalDate;
10 11 import java.time.YearMonth;
11 12  
12 13 /**
... ... @@ -88,10 +89,15 @@ public class EvalUserPool extends BaseAuditableTimeEntity&lt;EvalUserPool, Long&gt; {
88 89 */
89 90 private BigDecimal score;
90 91  
91   -// /**
92   -// * 考评得分率
93   -// */
94   -// private BigDecimal scoreRatio;
  92 + /**
  93 + * 考评得分率
  94 + */
  95 + private BigDecimal scoreRatio;
  96 +
  97 + /**
  98 + * 数据日期
  99 + */
  100 + private LocalDate dataDate;
95 101  
96 102 /**
97 103 * 月度
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/dto/query/EvalPoolQueryDTO.java
... ... @@ -84,7 +84,15 @@ public class EvalPoolQueryDTO extends BasePageQuery {
84 84 *
85 85 * @ignore
86 86 */
87   - private List<Long> managerStaffList;
  87 + private List<Long> managerStaffIds;
  88 +
  89 + /**
  90 + * 管理门店列表
  91 + *
  92 + * @ignore
  93 + */
  94 + private List<Long> managerShopIds;
  95 +
88 96 /**
89 97 * 排序字符串
90 98 *
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/eval/EvalShopPoolVO.java
... ... @@ -2,12 +2,15 @@ package cn.fw.morax.domain.vo.eval;
2 2  
3 3 import cn.fw.common.data.entity.BaseAuditableTimeEntity;
4 4 import cn.fw.morax.domain.enums.EvalShopPoolStatusEnum;
  5 +import cn.fw.morax.domain.enums.EvalTypeEnum;
5 6 import com.baomidou.mybatisplus.annotation.TableLogic;
6 7 import com.baomidou.mybatisplus.annotation.TableName;
7 8 import lombok.Data;
8 9 import lombok.EqualsAndHashCode;
9 10  
10 11 import java.math.BigDecimal;
  12 +import java.time.LocalDate;
  13 +import java.util.List;
11 14  
12 15 /**
13 16 * <p>
... ... @@ -24,11 +27,21 @@ public class EvalShopPoolVO {
24 27 private static final long serialVersionUID = 1L;
25 28  
26 29 /**
  30 + * 考评池id
  31 + */
  32 + private Long id;
  33 +
  34 + /**
27 35 * 考评组编码
28 36 */
29 37 private String egc;
30 38  
31 39 /**
  40 + * 考评组
  41 + */
  42 + private String evalGroupName;
  43 +
  44 + /**
32 45 * 考评id
33 46 */
34 47 private Long evalId;
... ... @@ -37,6 +50,12 @@ public class EvalShopPoolVO {
37 50 */
38 51 private Long evalGroupId;
39 52  
  53 +
  54 + /**
  55 + * 考评类型; 1:活动考评 2:其他考评
  56 + */
  57 + private EvalTypeEnum evalType;
  58 +
40 59 // /**
41 60 // * 用户id
42 61 // */
... ... @@ -87,16 +106,32 @@ public class EvalShopPoolVO {
87 106 */
88 107 private BigDecimal score;
89 108  
90   -// /**
91   -// * 考评得分率
92   -// */
93   -// private BigDecimal scoreRatio;
  109 + /**
  110 + * 考评得分率
  111 + */
  112 + private BigDecimal scoreRatio;
  113 +
  114 + /**
  115 + * 绩效总分
  116 + */
  117 + private BigDecimal totalScore;
  118 +
  119 + /**
  120 + * 考评得分率(格式化)
  121 + */
  122 + private String scoreRatioFormat;
94 123  
95 124 /**
96 125 * 月度
97 126 */
98 127 private String monthly;
99 128  
  129 +
  130 + /**
  131 + * 数据日期
  132 + */
  133 + private LocalDate dataDate;
  134 +
100 135 /**
101 136 * 固定的
102 137 */
... ... @@ -108,9 +143,13 @@ public class EvalShopPoolVO {
108 143 private Long groupId;
109 144  
110 145 /**
111   - * 逻辑删除
  146 + * 指标
  147 + */
  148 + private List<EvalPoolIndicatorDetailVO> indicators;
  149 +
  150 + /**
  151 + * 奖励
112 152 */
113   - @TableLogic
114   - private Boolean yn;
  153 + private List<EvalPoolRewardDetailVO> rewards;
115 154  
116 155 }
... ...
fw-morax-rpc/src/main/java/cn/fw/morax/rpc/ehr/EhrRpcService.java
... ... @@ -25,6 +25,7 @@ import java.util.ArrayList;
25 25 import java.util.Date;
26 26 import java.util.List;
27 27 import java.util.Objects;
  28 +import java.util.stream.Collectors;
28 29  
29 30 import static cn.fw.common.businessvalidator.Validator.BV;
30 31  
... ... @@ -167,6 +168,29 @@ public class EhrRpcService {
167 168 }
168 169  
169 170 /**
  171 + * 查询管理范围下的员工
  172 + *
  173 + * @param userId
  174 + * @return
  175 + */
  176 + @Nullable
  177 + public List<Long> queryManageShops(final Long userId) {
  178 + if (PublicUtil.isEmpty(userId)) {
  179 + return new ArrayList<>();
  180 + }
  181 + try {
  182 + final Message<ManagerVo> msg = managerApi.getRealTimeManagerScope(null, userId, false);
  183 + log.info("ManagerApi.getRealTimeManagerScope: msg.code={}, msg.result={}, msg.data={}", msg.getCode(), msg.getResult(), msg.getData());
  184 + if (msg.isSuccess() && !Objects.isNull(msg.getData())) {
  185 + return this.convertShopIds(msg.getData().getScopeList());
  186 + }
  187 + } catch (Exception e) {
  188 + e.printStackTrace();
  189 + }
  190 + return null;
  191 + }
  192 +
  193 + /**
170 194 * 查询门店实时管理者
171 195 *
172 196 * @param shopIds
... ... @@ -435,6 +459,22 @@ public class EhrRpcService {
435 459 return staffBaseInfoVos;
436 460 }
437 461  
  462 + /**
  463 + * 转换为dto
  464 + * @param scopes
  465 + * @return
  466 + */
  467 + public List<Long> convertShopIds(List<ManagerStaffVo> scopes) {
  468 + if (PublicUtil.isEmpty(scopes)) {
  469 + return new ArrayList<>();
  470 + }
  471 + List<Long> shopIds = scopes.stream().flatMap(managerStaffVo -> managerStaffVo.getShopList().stream())
  472 + .map(ManagerStaffShopVo::getShopId).distinct()
  473 + .collect(Collectors.toList());
  474 +
  475 + return shopIds;
  476 + }
  477 +
438 478  
439 479 /**
440 480 * 根据身份证批量查询员工基础信息
... ...
fw-morax-server/src/main/java/cn/fw/morax/server/controller/app/EvalController.java
... ... @@ -183,6 +183,19 @@ public class EvalController {
183 183 }
184 184  
185 185 /**
  186 + * 门店考评详情查询
  187 + *
  188 + * @param evalPoolId 用户id
  189 + * @return 绩效池详情
  190 + * @ignoreParams userId
  191 + */
  192 + @GetMapping("/shop-pool")
  193 + @ControllerMethod("门店考评详情查询")
  194 + public Message<EvalShopPoolVO> queryShopPoolDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId) {
  195 + return success(evalGroupPoolService.queryShopPoolDetail(evalPoolId));
  196 + }
  197 +
  198 + /**
186 199 * 人员考评指标排名
187 200 *
188 201 * @param dto
... ... @@ -226,7 +239,7 @@ public class EvalController {
226 239 * @return
227 240 * @ignoreParams currentUser
228 241 */
229   - @GetMapping("/shop-pool")
  242 + @GetMapping("/shop-pools")
230 243 @ControllerMethod("门店考评池列表")
231 244 public Message<AppPage<EvalShopPoolVO>> queryShopPool(@Validated EvalPoolQueryDTO dto) {
232 245 if (PublicUtil.isEmpty(dto.getMonthly())) {
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalCalculateService.java
... ... @@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
25 25 import org.springframework.transaction.annotation.Transactional;
26 26  
27 27 import java.math.BigDecimal;
  28 +import java.math.RoundingMode;
28 29 import java.time.LocalDate;
29 30 import java.time.YearMonth;
30 31 import java.util.*;
... ... @@ -125,7 +126,7 @@ public class EvalCalculateService {
125 126 try {
126 127 calculateEvalGroup(bo);
127 128 } catch (Exception ex) {
128   - log.error("计算绩效数据失败:{}", bo, ex);
  129 + log.error("计算考评数据失败:{}", bo, ex);
129 130 setOps.add(finalStr);
130 131 }
131 132 });
... ... @@ -150,7 +151,6 @@ public class EvalCalculateService {
150 151 log.error("考评组[{}]不存在,终止计算!", evalGroupId);
151 152 return;
152 153 }
153   -
154 154 List<EvalGroupUserShop> userShops = this.buildEvalGroupObj(evalGroup, localDate, Boolean.TRUE);
155 155 if (CollectionUtils.isEmpty(userShops)) {
156 156 log.error("考评组[{}]人员为空,终止计算!", evalGroupId);
... ... @@ -199,22 +199,28 @@ public class EvalCalculateService {
199 199 }
200 200 if (EvalScopeEnum.STAFF.equals(evalScope)) {
201 201 for (EvalGroupUserShop userShop : userShops) {
  202 + BigDecimal scoreRatio = userShop.getScore().divide(userShop.getIndicatorTotalScore(), 2, RoundingMode.DOWN);
202 203 evalUserPoolService.update(Wrappers.<EvalUserPool>lambdaUpdate()
203 204 .eq(EvalUserPool::getId, userShop.getPoolId())
204 205 .eq(EvalUserPool::getYn, Boolean.TRUE)
205 206 .set(EvalUserPool::getReward, userShop.getReward())
206 207 .set(EvalUserPool::getScore, userShop.getScore())
  208 + .set(EvalUserPool::getScoreRatio, scoreRatio)
207 209 .set(EvalUserPool::getMonthly, YearMonth.from(localDate))
  210 + .set(EvalUserPool::getDataDate, localDate)
208 211 );
209 212 }
210 213 } else {
211 214 for (EvalGroupUserShop userShop : userShops) {
  215 + BigDecimal scoreRatio = userShop.getScore().divide(userShop.getIndicatorTotalScore(), 2, RoundingMode.DOWN);
212 216 evalShopPoolService.update(Wrappers.<EvalShopPool>lambdaUpdate()
213 217 .eq(EvalShopPool::getId, userShop.getPoolId())
214 218 .eq(EvalShopPool::getYn, Boolean.TRUE)
215 219 .set(EvalShopPool::getReward, userShop.getReward())
216 220 .set(EvalShopPool::getScore, userShop.getScore())
  221 + .set(EvalShopPool::getScoreRatio, scoreRatio)
217 222 .set(EvalShopPool::getMonthly, YearMonth.from(localDate))
  223 + .set(EvalShopPool::getDataDate, localDate)
218 224 );
219 225 }
220 226 }
... ... @@ -356,6 +362,8 @@ public class EvalCalculateService {
356 362 detail.setEvalGroupRewardId(evalGroupReward.getId());
357 363 detail.setAmount(salaryMoney);
358 364 rewardDetails.add(detail);
  365 +
  366 + userShop.setReward(userShop.getReward().add(salaryMoney));
359 367 }
360 368 }
361 369 }
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalGroupPoolService.java
... ... @@ -70,6 +70,7 @@ public class EvalGroupPoolService {
70 70 private final KpiGroupUserBizService kpiGroupUserBizService;
71 71 private final EvalGroupUserService evalGroupUserService;
72 72 private final EvalUserPoolService evalUserPoolService;
  73 + private final EvalShopPoolService evalShopPoolService;
73 74 private final SettingDraftService settingDraftService;
74 75 private final ApprovalBizService approvalBizService;
75 76 private final EvalGroupService evalGroupService;
... ... @@ -83,6 +84,35 @@ public class EvalGroupPoolService {
83 84 *
84 85 * @return
85 86 */
  87 + public EvalShopPoolVO queryShopPoolDetail(final Long poolId) {
  88 + EvalShopPool evalShopPool = evalShopPoolService.getById(poolId);
  89 + if (PublicUtil.isEmpty(evalShopPool)) {
  90 + throw new BusinessException("人员考评数据不存在");
  91 + }
  92 + return shopPoolDetail(evalShopPool);
  93 + }
  94 +
  95 + public EvalShopPoolVO shopPoolDetail(EvalShopPool pool) {
  96 + EvalShopPoolVO evalShopPoolVO = PublicUtil.copy(pool, EvalShopPoolVO.class);
  97 +
  98 + LocalDate dataDate = evalShopPoolVO.getDataDate();
  99 +
  100 + this.setShopIndicatorDetails(evalShopPoolVO, dataDate);
  101 + this.setShopRewardDetails(evalShopPoolVO, dataDate);
  102 + evalShopPoolVO.setDataDate(dataDate);
  103 +
  104 + Eval eval = evalService.getById(pool.getEvalId());
  105 + BV.notNull(pool, "考评池不存在");
  106 + evalShopPoolVO.setEvalType(eval.getType());
  107 +
  108 + return evalShopPoolVO;
  109 + }
  110 +
  111 + /**
  112 + * 查询考评详情
  113 + *
  114 + * @return
  115 + */
86 116 public EvalUserPoolVO queryPoolDetail(final Long poolId) {
87 117 EvalUserPool evalUserPool = evalUserPoolService.getById(poolId);
88 118 if (PublicUtil.isEmpty(evalUserPool)) {
... ... @@ -165,6 +195,33 @@ public class EvalGroupPoolService {
165 195 pool.setTotalScore(totalScore);
166 196 }
167 197  
  198 + public void setShopIndicatorDetails(EvalShopPoolVO pool, LocalDate localDate) {
  199 + Long evalGroupId = pool.getEvalGroupId();
  200 + Long poolId = pool.getId();
  201 + DecimalFormat decimalFormat = new DecimalFormat("##########.##");
  202 +
  203 + List<EvalPoolIndicatorDetailVO> indicatorDetails = evalPoolIndicatorDetailService.getStaffIndicatorValues(poolId, evalGroupId, localDate);
  204 +
  205 + BigDecimal totalScore = BigDecimal.ZERO;
  206 + BigDecimal staffScore = BigDecimal.ZERO;
  207 + BigDecimal baseScore;
  208 + for (EvalPoolIndicatorDetailVO indicatorValueVO : indicatorDetails) {
  209 + baseScore = new BigDecimal(indicatorValueVO.getBaseScore());
  210 + totalScore = totalScore.add(baseScore);
  211 + staffScore = staffScore.add(indicatorValueVO.getScore());
  212 +
  213 + indicatorValueVO.setScoreFormat(decimalFormat.format(indicatorValueVO.getScore()));
  214 + BigDecimal indicatorScoreRatio = indicatorValueVO.getScore().divide(baseScore, 2, RoundingMode.DOWN).multiply(Constant.ONE_HUNDRED);
  215 + indicatorValueVO.setScoreRatioFormat(decimalFormat.format(indicatorScoreRatio));
  216 + }
  217 + BigDecimal staffScoreRatio = (BigDecimal.ZERO.compareTo(totalScore) == 0) ? BigDecimal.ZERO :
  218 + staffScore.divide(totalScore, 2, RoundingMode.DOWN).multiply(Constant.ONE_HUNDRED);
  219 + pool.setScoreRatioFormat(decimalFormat.format(staffScoreRatio));
  220 + pool.setIndicators(indicatorDetails);
  221 + pool.setScoreRatio(staffScoreRatio);
  222 + pool.setTotalScore(totalScore);
  223 + }
  224 +
168 225 public void setRewardDetails(EvalUserPoolVO pool, LocalDate localDate) {
169 226 Long evalGroupId = pool.getEvalGroupId();
170 227 Long poolId = pool.getId();
... ... @@ -181,6 +238,22 @@ public class EvalGroupPoolService {
181 238 pool.setRewards(rewardValues);
182 239 }
183 240  
  241 + public void setShopRewardDetails(EvalShopPoolVO pool, LocalDate localDate) {
  242 + Long evalGroupId = pool.getEvalGroupId();
  243 + Long poolId = pool.getId();
  244 + DecimalFormat decimalFormat = new DecimalFormat("##########.##");
  245 +
  246 + List<EvalPoolRewardDetailVO> rewardValues = evalPoolRewardDetailService.getStaffRewardValues(poolId, evalGroupId, localDate);
  247 +
  248 + BigDecimal totalReward = BigDecimal.ZERO;
  249 + for (EvalPoolRewardDetailVO rewardValue : rewardValues) {
  250 + totalReward = totalReward.add(rewardValue.getAmount());
  251 + }
  252 +
  253 + pool.setReward(totalReward);
  254 + pool.setRewards(rewardValues);
  255 + }
  256 +
184 257  
185 258 /**
186 259 * 查询用户绩效池
... ... @@ -236,6 +309,7 @@ public class EvalGroupPoolService {
236 309 return users.stream().findFirst().get().getDataDate();
237 310 }
238 311  
  312 +
239 313 /**
240 314 * 员工考评得分详情
241 315 *
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalPoolCommonService.java
... ... @@ -107,6 +107,7 @@ public class EvalPoolCommonService {
107 107 evalShopPool.setShopId(shopId);
108 108 evalShopPool.setShopName(shopDTO.getShortName());
109 109 evalShopPool.setScore(BigDecimal.ZERO);
  110 + evalShopPool.setScoreRatio(BigDecimal.ZERO);
110 111 evalShopPool.setReward(BigDecimal.ZERO);
111 112 evalShopPool.setGroupId(evalGroup.getGroupId());
112 113 evalShopPool.setYn(Boolean.TRUE);
... ... @@ -194,6 +195,7 @@ public class EvalPoolCommonService {
194 195 evalUserPool.setShopId(user.getShopId());
195 196 evalUserPool.setShopName(user.getShopName());
196 197 evalUserPool.setScore(BigDecimal.ZERO);
  198 + evalUserPool.setScoreRatio(BigDecimal.ZERO);
197 199 evalUserPool.setInclusion(Boolean.FALSE.equals(user.getIgnored()));
198 200 // evalUserPool.setScoreRatio(BigDecimal.ZERO);
199 201 evalUserPool.setReward(BigDecimal.ZERO);
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalPoolService.java
... ... @@ -5,12 +5,12 @@ import cn.fw.morax.common.constant.Constant;
5 5 import cn.fw.morax.common.utils.PublicUtil;
6 6 import cn.fw.morax.common.utils.StringUtils;
7 7 import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO;
8   -import cn.fw.morax.domain.dto.query.KpiPoolQueryDTO;
9 8 import cn.fw.morax.domain.vo.eval.EvalShopPoolVO;
10 9 import cn.fw.morax.domain.vo.eval.EvalUserPoolVO;
11   -import cn.fw.morax.domain.vo.kpi.KpiPoolVO;
  10 +import cn.fw.morax.rpc.ehr.EhrRpcService;
12 11 import cn.fw.morax.service.biz.CommonService;
13 12 import cn.fw.morax.service.data.eval.EvalGroupUserService;
  13 +import cn.fw.morax.service.data.eval.EvalShopPoolService;
14 14 import cn.fw.morax.service.data.eval.EvalUserPoolService;
15 15 import com.alibaba.fastjson.JSON;
16 16 import lombok.RequiredArgsConstructor;
... ... @@ -37,7 +37,9 @@ public class EvalPoolService {
37 37  
38 38 private final EvalGroupUserService evalGroupUserService;
39 39 private final EvalUserPoolService evalUserPoolService;
  40 + private final EvalShopPoolService evalShopPoolService;
40 41 private final CommonService commonService;
  42 + private final EhrRpcService ehrRpcService;
41 43  
42 44  
43 45 /**
... ... @@ -48,11 +50,11 @@ public class EvalPoolService {
48 50 */
49 51 public AppPage<EvalUserPoolVO> queryUserPool(EvalPoolQueryDTO dto) {
50 52 if (PublicUtil.isNotEmpty(dto.getManagerUserId())) {
51   - dto.setManagerStaffList(commonService.queryManageStaffIds(dto.getManagerUserId(), dto.getMonthly()));
  53 + dto.setManagerStaffIds(commonService.queryManageStaffIds(dto.getManagerUserId(), dto.getMonthly()));
52 54 } else {
53   - dto.setManagerStaffList(commonService.queryManageStaffIds(dto.getCurrentUserId(), dto.getMonthly()));
  55 + dto.setManagerStaffIds(commonService.queryManageStaffIds(dto.getCurrentUserId(), dto.getMonthly()));
54 56 }
55   - if (PublicUtil.isEmpty(dto.getManagerStaffList())) {
  57 + if (PublicUtil.isEmpty(dto.getManagerStaffIds())) {
56 58 return AppPage.empty(dto);
57 59 }
58 60  
... ... @@ -81,29 +83,23 @@ public class EvalPoolService {
81 83 */
82 84 public AppPage<EvalShopPoolVO> queryShopPool(EvalPoolQueryDTO dto) {
83 85 if (PublicUtil.isNotEmpty(dto.getManagerUserId())) {
84   - dto.setManagerStaffList(commonService.queryManageStaffIds(dto.getManagerUserId(), dto.getMonthly()));
  86 + dto.setManagerShopIds(ehrRpcService.queryManageShops(dto.getManagerUserId()));
85 87 } else {
86   - dto.setManagerStaffList(commonService.queryManageStaffIds(dto.getCurrentUserId(), dto.getMonthly()));
  88 + dto.setManagerShopIds(ehrRpcService.queryManageShops(dto.getCurrentUserId()));
87 89 }
88   - if (PublicUtil.isEmpty(dto.getManagerStaffList())) {
  90 + if (PublicUtil.isEmpty(dto.getManagerShopIds())) {
89 91 return AppPage.empty(dto);
90 92 }
91 93  
92 94 prepareParams(dto);
93   - AppPage<EvalUserPoolVO> page = AppPage.empty(dto);
94   - log.info("绩效池查询参数:{}", JSON.toJSONString(dto));
95   - long total = evalUserPoolService.queryPagePoolTotal(dto);
  95 + AppPage<EvalShopPoolVO> page = AppPage.empty(dto);
  96 + log.info("考评池查询参数:{}", JSON.toJSONString(dto));
  97 + long total = evalShopPoolService.queryPagePoolTotal(dto);
96 98 if (total > 0) {
97 99 page.setTotal(total);
98   - List<EvalUserPoolVO> userPoolVOS = evalUserPoolService.queryPagePool(dto);
99   - for (EvalUserPoolVO poolVO : userPoolVOS) {
100   - BigDecimal staffScoreRatio = (BigDecimal.ZERO.compareTo(poolVO.getTotalScore()) == 0) ? BigDecimal.ZERO :
101   - poolVO.getScore().divide(poolVO.getTotalScore(), 2, RoundingMode.DOWN).multiply(Constant.ONE_HUNDRED);
102   - poolVO.setScoreRatio(staffScoreRatio);
103   - }
104   - page.setData(userPoolVOS);
  100 + page.setData(evalShopPoolService.queryPagePool(dto));
105 101 }
106   - return null;
  102 + return page;
107 103 }
108 104  
109 105 /**
... ... @@ -127,7 +123,7 @@ public class EvalPoolService {
127 123 }
128 124 if (PublicUtil.isNotEmpty(queryVO.getQueryStaffs())) {
129 125 List<Long> queryStaffIds = Arrays.stream(queryVO.getQueryStaffs().split(",")).map(Long::parseLong).collect(Collectors.toList());
130   - queryVO.getManagerStaffList().retainAll(queryStaffIds);
  126 + queryVO.getManagerStaffIds().retainAll(queryStaffIds);
131 127 }
132 128 }
133 129  
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/EvalShopPoolService.java
... ... @@ -2,6 +2,9 @@ package cn.fw.morax.service.data.eval;
2 2  
3 3  
4 4 import cn.fw.morax.domain.db.eval.EvalShopPool;
  5 +import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO;
  6 +import cn.fw.morax.domain.vo.eval.EvalShopPoolVO;
  7 +import cn.fw.morax.domain.vo.eval.EvalUserPoolVO;
5 8 import com.baomidou.mybatisplus.extension.service.IService;
6 9 import org.apache.ibatis.annotations.Param;
7 10  
... ... @@ -20,4 +23,13 @@ public interface EvalShopPoolService extends IService&lt;EvalShopPool&gt; {
20 23  
21 24 List<EvalShopPool> getLastPool(YearMonth monthly, Long groupId);
22 25  
  26 + long queryPagePoolTotal(EvalPoolQueryDTO dto);
  27 +
  28 + /**
  29 + * 考评池分页查询
  30 + *
  31 + * @param dto
  32 + * @return
  33 + */
  34 + List<EvalShopPoolVO> queryPagePool(EvalPoolQueryDTO dto);
23 35 }
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/EvalUserPoolService.java
... ... @@ -8,6 +8,7 @@ import cn.fw.morax.domain.dto.query.KpiPoolQueryDTO;
8 8 import cn.fw.morax.domain.vo.eval.EvalUserPoolVO;
9 9 import cn.fw.morax.domain.vo.kpi.KpiPoolVO;
10 10 import com.baomidou.mybatisplus.extension.service.IService;
  11 +import org.apache.ibatis.annotations.Param;
11 12  
12 13 import java.time.YearMonth;
13 14 import java.util.List;
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/impl/EvalShopPoolServiceImpl.java
... ... @@ -3,6 +3,9 @@ package cn.fw.morax.service.data.eval.impl;
3 3  
4 4 import cn.fw.morax.dao.eval.EvalShopPoolDao;
5 5 import cn.fw.morax.domain.db.eval.EvalShopPool;
  6 +import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO;
  7 +import cn.fw.morax.domain.vo.eval.EvalShopPoolVO;
  8 +import cn.fw.morax.domain.vo.eval.EvalUserPoolVO;
6 9 import cn.fw.morax.service.data.eval.EvalShopPoolService;
7 10 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 11 import org.springframework.stereotype.Service;
... ... @@ -23,6 +26,20 @@ public class EvalShopPoolServiceImpl extends ServiceImpl&lt;EvalShopPoolDao, EvalSh
23 26  
24 27 @Override
25 28 public List<EvalShopPool> getLastPool(YearMonth monthly, Long groupId) {
26   - return this.getLastPool(monthly, groupId);
  29 + return this.baseMapper.getLastPool(monthly, groupId);
  30 + }
  31 +
  32 +
  33 + @Override
  34 + public long queryPagePoolTotal(EvalPoolQueryDTO dto) {
  35 + return this.baseMapper.queryPagePoolTotal(dto);
  36 + }
  37 +
  38 + @Override
  39 + public List<EvalShopPoolVO> queryPagePool(EvalPoolQueryDTO dto) {
  40 + Integer pageSize = dto.getPageSize();
  41 + Integer current = dto.getCurrent();
  42 + int startIndex = (current.equals(0) ? 0 : (current - 1) * pageSize);
  43 + return this.getBaseMapper().queryPagePool(dto, startIndex, pageSize);
27 44 }
28 45 }
... ...