Commit 1297ad463a665dfb36b8fc4734b33c68bd82d758

Authored by 姜超
1 parent 916a0611

feature(*): 移除考评报表文件

移除考评报表文件
fw-morax-dao/src/main/java/cn/fw/morax/dao/eval/EvalShopReportDao.java deleted
1   -package cn.fw.morax.dao.eval;
2   -
3   -import cn.fw.morax.domain.db.eval.EvalShopReport;
4   -import cn.fw.morax.domain.db.eval.EvalUserReport;
5   -import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6   -import org.springframework.stereotype.Repository;
7   -
8   -/**
9   - * @author : kurisu
10   - * @className : KpiPoolDao
11   - * @description : 绩效池
12   - * @date: 2022-04-06 14:35
13   - */
14   -@Repository
15   -public interface EvalShopReportDao extends BaseMapper<EvalShopReport> {
16   -
17   -}
fw-morax-dao/src/main/java/cn/fw/morax/dao/eval/EvalUserReportDao.java deleted
1   -package cn.fw.morax.dao.eval;
2   -
3   -import cn.fw.morax.domain.db.eval.EvalUserReport;
4   -import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5   -import org.springframework.stereotype.Repository;
6   -
7   -/**
8   - * @author : kurisu
9   - * @className : KpiPoolDao
10   - * @description : 绩效池
11   - * @date: 2022-04-06 14:35
12   - */
13   -@Repository
14   -public interface EvalUserReportDao extends BaseMapper<EvalUserReport> {
15   -
16   -}
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalShopReport.java deleted
1   -package cn.fw.morax.domain.db.eval;
2   -
3   -import cn.fw.common.data.entity.BaseEntity;
4   -import cn.fw.morax.domain.enums.ReportDimensionEnum;
5   -import com.baomidou.mybatisplus.annotation.TableName;
6   -import lombok.Data;
7   -import lombok.EqualsAndHashCode;
8   -import lombok.experimental.Accessors;
9   -
10   -import java.math.BigDecimal;
11   -import java.time.LocalDate;
12   -
13   -/**
14   - * <p>
15   - * 绩效得分率(报表)
16   - * </p>
17   - *
18   - * @author jiangchao
19   - * @since 2022-11-29
20   - */
21   -@Data
22   -@EqualsAndHashCode(callSuper = false)
23   -@Accessors(chain = true)
24   -@TableName(autoResultMap = true)
25   -public class EvalShopReport extends BaseEntity<EvalShopReport, Long> {
26   -
27   - private static final long serialVersionUID = 1L;
28   -
29   - /**
30   - * 日期
31   - */
32   - private LocalDate date;
33   -
34   - /**
35   - * 维度
36   - */
37   - private ReportDimensionEnum dimension;
38   -
39   - /**
40   - * 集团id
41   - */
42   - private Long groupId;
43   -
44   - /**
45   - * 门店名称
46   - */
47   - private String s1;
48   -
49   - /**
50   - * 考评组名称
51   - */
52   - private String s2;
53   -
54   - /**
55   - * 门店id
56   - */
57   - private Long l1;
58   -
59   - /**
60   - * 考评组id
61   - */
62   - private Long l2;
63   -
64   - /**
65   - * 考评池id
66   - */
67   - private Long l3;
68   -
69   - /**
70   - * 考评得分率
71   - */
72   - private BigDecimal b1;
73   -
74   - /**
75   - * 考评奖惩
76   - */
77   - private BigDecimal b2;
78   -
79   - private Boolean yn;
80   -
81   - public EvalShopReport() {
82   - }
83   -
84   - public EvalShopReport(ReportDimensionEnum dimension, Long groupId) {
85   - this.dimension = dimension;
86   - this.groupId = groupId;
87   - }
88   -}
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalUserReport.java deleted
1   -package cn.fw.morax.domain.db.eval;
2   -
3   -import cn.fw.common.data.entity.BaseEntity;
4   -import cn.fw.morax.domain.enums.ReportDimensionEnum;
5   -import com.baomidou.mybatisplus.annotation.TableName;
6   -import lombok.Data;
7   -import lombok.EqualsAndHashCode;
8   -import lombok.experimental.Accessors;
9   -
10   -import java.math.BigDecimal;
11   -import java.time.LocalDate;
12   -
13   -/**
14   - * <p>
15   - * 绩效得分率(报表)
16   - * </p>
17   - *
18   - * @author jiangchao
19   - * @since 2022-11-29
20   - */
21   -@Data
22   -@EqualsAndHashCode(callSuper = false)
23   -@Accessors(chain = true)
24   -@TableName(autoResultMap = true)
25   -public class EvalUserReport extends BaseEntity<EvalUserReport, Long> {
26   -
27   - private static final long serialVersionUID = 1L;
28   -
29   - /**
30   - * 日期
31   - */
32   - private LocalDate date;
33   -
34   - /**
35   - * 维度
36   - */
37   - private ReportDimensionEnum dimension;
38   -
39   - /**
40   - * 集团id
41   - */
42   - private Long groupId;
43   -
44   - /**
45   - * 人员名称
46   - */
47   - private String s1;
48   -
49   - /**
50   - * 门店名称
51   - */
52   - private String s2;
53   -
54   - /**
55   - * 岗位名称
56   - */
57   - private String s3;
58   -
59   - /**
60   - * 考评组名称
61   - */
62   - private String s4;
63   -
64   - /**
65   - * 人员id
66   - */
67   - private Long l1;
68   -
69   - /**
70   - * 门店id
71   - */
72   - private Long l2;
73   -
74   - /**
75   - * 岗位id
76   - */
77   - private Long l3;
78   -
79   - /**
80   - * 绩效组id
81   - */
82   - private Long l4;
83   -
84   - /**
85   - * 考评池id
86   - */
87   - private Long l5;
88   -
89   - /**
90   - * 考评得分率
91   - */
92   - private BigDecimal b1;
93   -
94   - /**
95   - * 考评奖惩
96   - */
97   - private BigDecimal b2;
98   -
99   - /**
100   - * 是否纳入考评考核
101   - */
102   - private Boolean b3;
103   -
104   - private Boolean yn;
105   -
106   - public EvalUserReport() {
107   - }
108   -
109   - public EvalUserReport(ReportDimensionEnum dimension, Long groupId) {
110   - this.dimension = dimension;
111   - this.groupId = groupId;
112   - }
113   -}
fw-morax-server/src/main/java/cn/fw/morax/server/task/EvalShopReportTask.java deleted
1   -package cn.fw.morax.server.task;
2   -
3   -import cn.fw.common.cache.locker.DistributedLocker;
4   -import cn.fw.morax.common.constant.TimeTaskConstant;
5   -import cn.fw.morax.common.utils.PublicUtil;
6   -import cn.fw.morax.domain.db.eval.*;
7   -import cn.fw.morax.domain.dto.GroupCalEvalReportDTO;
8   -import cn.fw.morax.domain.enums.EvalScopeEnum;
9   -import cn.fw.morax.domain.enums.ReportDimensionEnum;
10   -import cn.fw.morax.rpc.oop.OopRpcService;
11   -import cn.fw.morax.rpc.oop.dto.ShopDTO;
12   -import cn.fw.morax.service.data.eval.EvalGroupService;
13   -import cn.fw.morax.service.data.eval.EvalShopReportService;
14   -import cn.fw.morax.service.data.eval.EvalUserPoolService;
15   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
16   -import com.google.common.collect.Lists;
17   -import lombok.Getter;
18   -import lombok.RequiredArgsConstructor;
19   -import lombok.extern.slf4j.Slf4j;
20   -import org.redisson.api.RLock;
21   -import org.springframework.beans.factory.annotation.Value;
22   -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23   -import org.springframework.scheduling.annotation.Scheduled;
24   -import org.springframework.stereotype.Component;
25   -import org.springframework.transaction.annotation.Transactional;
26   -import org.springframework.util.CollectionUtils;
27   -
28   -import java.math.BigDecimal;
29   -import java.math.RoundingMode;
30   -import java.time.LocalDate;
31   -import java.time.YearMonth;
32   -import java.util.*;
33   -import java.util.concurrent.locks.Lock;
34   -import java.util.function.Predicate;
35   -import java.util.stream.Collectors;
36   -
37   -/**
38   - * @author : jiangchao
39   - * @className : KpiReportRatioTask
40   - * @description : 绩效报表定时器
41   - * @date : 2022-04-07 15:29
42   - */
43   -@Component
44   -@Slf4j
45   -@RequiredArgsConstructor
46   -@ConditionalOnProperty(prefix = "task", name = "switch", havingValue = "on")
47   -public class EvalShopReportTask {
48   -
49   - private final EvalShopReportService evalShopReportService;
50   - private final EvalUserPoolService evalUserPoolService;
51   - private final EvalGroupService evalGroupService;
52   - private final DistributedLocker distributedLocker;
53   - private final OopRpcService oopRpcService;
54   -
55   - @Value("${spring.cache.custom.global-prefix}:eval:shop:report")
56   - @Getter
57   - private String evalShopReportDistKey;
58   -
59   - /**
60   - * 绩效报表定时任务
61   - *
62   - */
63   - @Scheduled(cron = TimeTaskConstant.EVAL_REPORT)
64   - @Transactional(rollbackFor = Exception.class)
65   - public void evalShopReportTask() {
66   - this.evalShopReport(LocalDate.now().minusDays(1));
67   - }
68   -
69   - /**
70   - * 绩效报表定时任务
71   - *
72   - * @param date
73   - */
74   - @Transactional(rollbackFor = Exception.class)
75   - public void evalShopReport(LocalDate date) {
76   - Lock lock = distributedLocker.lock(getEvalShopReportDistKey());
77   - if (! ((RLock) lock).isLocked()) {
78   - return;
79   - }
80   - try {
81   - log.info("定时任务【考评人员报表数据抽取】开始执行");
82   -
83   - evalShopReportService.update(Wrappers.<EvalShopReport>lambdaUpdate()
84   - .set(EvalShopReport::getYn, Boolean.FALSE)
85   - .eq(EvalShopReport::getDate, date)
86   - );
87   -
88   - List<EvalGroup> allEvalGroups = evalGroupService.getAllEffectGroups(date);
89   - Map<Long, List<EvalGroup>> groupKpiGroupMap = allEvalGroups.stream()
90   - .filter(evalGroup -> EvalScopeEnum.SHOP.equals(evalGroup.getScopeType()))
91   - .collect(Collectors.groupingBy(EvalGroup::getGroupId));
92   -
93   - List<EvalShopReport> shopReports = Lists.newArrayListWithCapacity(500);
94   -
95   - //遍历集团
96   - oopRpcService.allGroups().stream().forEach(group -> {
97   - //构建查询参数
98   - final Long groupId = group.getId();
99   - List<EvalGroup> evalGroups = groupKpiGroupMap.getOrDefault(groupId, new ArrayList<>());
100   - GroupCalEvalReportDTO calDTO = buildParam(evalGroups, groupId, date);
101   - if (PublicUtil.isEmpty(calDTO.getShopIds())) {
102   - return;
103   - }
104   -
105   - //查询所有门店
106   - List<ShopDTO> shopDTOs = oopRpcService.queryShops(new ArrayList<>(calDTO.getShopIds()));
107   - //计算考评组 门店
108   - calEvalGroupShopData(calDTO, shopReports, shopDTOs);
109   -// //计算考评组门店
110   - calShopData(calDTO, shopReports, shopDTOs);
111   - });
112   - if (PublicUtil.isNotEmpty(shopReports)) {
113   - shopReports.stream().forEach(userReport -> {
114   - userReport.setDate(date);
115   - userReport.setYn(Boolean.TRUE);
116   - });
117   - evalShopReportService.saveBatch(shopReports);
118   - }
119   - } catch (Exception e){
120   - log.error(e.getMessage(), e);
121   - } finally {
122   - lock.unlock();
123   - }
124   - }
125   -
126   - public GroupCalEvalReportDTO buildParam(List<EvalGroup> evalGroups, Long groupId, LocalDate date) {
127   - GroupCalEvalReportDTO calDTO = new GroupCalEvalReportDTO(evalGroups, groupId);
128   - if (PublicUtil.isEmpty(evalGroups)) {
129   - return calDTO;
130   - }
131   - List<EvalUserPool> pools = evalUserPoolService.list(Wrappers.<EvalUserPool>lambdaQuery()
132   - .in(EvalUserPool::getEvalGroupId, evalGroups.stream().map(EvalGroup::getId).collect(Collectors.toList()))
133   - .eq(EvalUserPool::getMonthly, YearMonth.from(date))
134   - .eq(EvalUserPool::getYn, Boolean.TRUE)
135   - );
136   - calDTO.setUserPools(pools);
137   - Set<Long> shopIds = evalGroups.stream().map(evalGroup -> {
138   - return evalGroup.getShopIds().stream().map(Long::new).collect(Collectors.toList());
139   - }).collect(HashSet::new, Set::addAll, Set::addAll);
140   - calDTO.setShopIds(shopIds);
141   - return calDTO;
142   - }
143   -
144   - /**
145   - * 计算绩效组门店维度数据
146   - *
147   - * @param calDto
148   - */
149   - public void calEvalGroupShopData(GroupCalEvalReportDTO calDto,
150   - List<EvalShopReport> shopReports,
151   - List<ShopDTO> shopDTOs
152   - ) {
153   - List<EvalShopPool> shopPools = calDto.getShopPools();
154   - List<EvalGroup> userEvalGroups = calDto.getEvalGroups();
155   -
156   - for (EvalGroup evalGroup : userEvalGroups) {
157   - final Long evalGroupId = evalGroup.getId();
158   - final String evalGroupName = evalGroup.getName();
159   - final Set<Long> shopIds = new HashSet<>(evalGroup.getShopIds());
160   -
161   - shopDTOs.stream().filter(shopDTO -> shopIds.contains(shopDTO.getId())).forEach(shop -> {
162   - Long shopId = shop.getId();
163   - EvalShopReport evalGroupShopReport = new EvalShopReport(ReportDimensionEnum.EVAL_GROUP_SHOP, calDto.getGroupId());
164   - Predicate<EvalShopPool> evalGroupShopPredicate = pool -> {
165   - return shopId.equals(pool.getShopId()) && evalGroupId.equals(pool.getEvalGroupId());
166   - };
167   - evalGroupShopReport.setL1(shopId);
168   - evalGroupShopReport.setS1(shop.getShopName());
169   - evalGroupShopReport.setS2(evalGroupName);
170   - evalGroupShopReport.setL2(evalGroupId);
171   - evalGroupShopReport.setB1(averageRatio(shopPools, evalGroupShopPredicate));
172   - evalGroupShopReport.setB2(totalSalary(shopPools, evalGroupShopPredicate));
173   - shopReports.add(evalGroupShopReport);
174   - });
175   -
176   - }
177   - }
178   -
179   - /**
180   - * 计算绩效组门店维度数据
181   - *
182   - * @param calDto
183   - */
184   - public void calShopData(GroupCalEvalReportDTO calDto,
185   - List<EvalShopReport> shopReports,
186   - List<ShopDTO> shopDTOs
187   - ) {
188   - List<EvalShopPool> shopPools = calDto.getShopPools();
189   - List<EvalGroup> evalGroups = calDto.getEvalGroups();
190   -
191   - shopDTOs.stream().forEach(shop -> {
192   - final Long shopId = shop.getId();
193   - EvalShopReport shopReport = new EvalShopReport(ReportDimensionEnum.SHOP, calDto.getGroupId());
194   - Predicate<EvalShopPool> predicate = pool -> {
195   - return shopId.equals(pool.getShopId());
196   - };
197   - shopReport.setL2(shopId);
198   - shopReport.setS2(shop.getShopName());
199   - shopReport.setB1(averageRatio(shopPools, predicate));
200   - shopReport.setB2(totalSalary(shopPools, predicate));
201   - shopReports.add(shopReport);
202   -
203   - for (EvalGroup evalGroup : evalGroups) {
204   - final String evalGroupName = evalGroup.getName();
205   - final Long evalGroupId = evalGroup.getId();
206   - final List<Long> shopIds = evalGroup.getShopIds();
207   - if (! shopIds.contains(shopId)) {
208   - continue;
209   - }
210   -
211   - EvalShopReport shopEvalGroup = new EvalShopReport(ReportDimensionEnum.SHOP_EVAL_GROUP, calDto.getGroupId());
212   - Predicate<EvalShopPool> predicateEvalGroup = pool -> {
213   - return shopId.equals(pool.getShopId()) && evalGroupId.equals(pool.getEvalGroupId()) ;
214   - };
215   - shopEvalGroup.setL1(shopId);
216   - shopEvalGroup.setS1(shop.getShopName());
217   - shopEvalGroup.setS2(evalGroupName);
218   - shopEvalGroup.setL2(evalGroupId);
219   - shopEvalGroup.setB1(averageRatio(shopPools, predicateEvalGroup));
220   - shopEvalGroup.setB2(totalSalary(shopPools, predicateEvalGroup));
221   - shopReports.add(shopEvalGroup);
222   - }
223   - });
224   - }
225   -
226   -
227   - /**
228   - * 绩效池平均绩效得分率
229   - *
230   - * @param pools
231   - * @return
232   - */
233   - public BigDecimal averageRatio(Collection<EvalShopPool> pools, Predicate<EvalShopPool> predicate) {
234   - if (CollectionUtils.isEmpty(pools)) {
235   - return BigDecimal.ZERO;
236   - }
237   - Double averageRatioDouble = pools.stream()
238   - .filter(predicate)
239   - .mapToDouble(r -> Optional.ofNullable(r.getScoreRatio()).orElse(BigDecimal.ZERO).doubleValue())
240   - .average()
241   - .orElse(0);
242   - BigDecimal averageRatio = new BigDecimal(averageRatioDouble.toString());
243   - return averageRatio.multiply(new BigDecimal("100")).setScale(2, RoundingMode.DOWN);
244   - }
245   -
246   - /**
247   - * 总薪酬
248   - *
249   - * @param pools
250   - * @return
251   - */
252   - public BigDecimal totalSalary(Collection<EvalShopPool> pools, Predicate<EvalShopPool> predicate) {
253   - if (CollectionUtils.isEmpty(pools)) {
254   - return BigDecimal.ZERO;
255   - }
256   - BigDecimal totalSalary = pools.stream()
257   - .filter(predicate)
258   - .map(r -> Optional.ofNullable(r.getReward()).orElse(BigDecimal.ZERO))
259   - .reduce(BigDecimal.ZERO, BigDecimal::add);
260   - return totalSalary.setScale(2, RoundingMode.DOWN);
261   - }
262   -}
fw-morax-server/src/main/java/cn/fw/morax/server/task/EvalUserReportTask.java deleted
1   -package cn.fw.morax.server.task;
2   -
3   -import cn.fw.common.cache.locker.DistributedLocker;
4   -import cn.fw.morax.common.constant.Constant;
5   -import cn.fw.morax.common.constant.TimeTaskConstant;
6   -import cn.fw.morax.common.utils.PublicUtil;
7   -import cn.fw.morax.domain.db.eval.EvalGroup;
8   -import cn.fw.morax.domain.db.eval.EvalUserPool;
9   -import cn.fw.morax.domain.db.eval.EvalUserReport;
10   -import cn.fw.morax.domain.dto.GroupCalEvalReportDTO;
11   -import cn.fw.morax.domain.enums.EvalScopeEnum;
12   -import cn.fw.morax.domain.enums.ReportDimensionEnum;
13   -import cn.fw.morax.rpc.oop.OopRpcService;
14   -import cn.fw.morax.rpc.oop.dto.ShopDTO;
15   -import cn.fw.morax.service.data.eval.EvalGroupService;
16   -import cn.fw.morax.service.data.eval.EvalUserPoolService;
17   -import cn.fw.morax.service.data.eval.EvalUserReportService;
18   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
19   -import com.google.common.collect.Lists;
20   -import lombok.Getter;
21   -import lombok.RequiredArgsConstructor;
22   -import lombok.extern.slf4j.Slf4j;
23   -import org.redisson.api.RLock;
24   -import org.springframework.beans.factory.annotation.Value;
25   -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
26   -import org.springframework.scheduling.annotation.Scheduled;
27   -import org.springframework.stereotype.Component;
28   -import org.springframework.transaction.annotation.Transactional;
29   -import org.springframework.util.CollectionUtils;
30   -
31   -import java.math.BigDecimal;
32   -import java.math.RoundingMode;
33   -import java.time.LocalDate;
34   -import java.time.YearMonth;
35   -import java.util.*;
36   -import java.util.concurrent.locks.Lock;
37   -import java.util.function.Predicate;
38   -import java.util.stream.Collectors;
39   -
40   -/**
41   - * @author : jiangchao
42   - * @className : KpiReportRatioTask
43   - * @description : 绩效报表定时器
44   - * @date : 2022-04-07 15:29
45   - */
46   -@Component
47   -@Slf4j
48   -@RequiredArgsConstructor
49   -@ConditionalOnProperty(prefix = "task", name = "switch", havingValue = "on")
50   -public class EvalUserReportTask {
51   -
52   - private final EvalUserReportService evalUserReportService;
53   - private final EvalUserPoolService evalUserPoolService;
54   - private final EvalGroupService evalGroupService;
55   - private final DistributedLocker distributedLocker;
56   - private final OopRpcService oopRpcService;
57   -
58   - @Value("${spring.cache.custom.global-prefix}:eval:user:report")
59   - @Getter
60   - private String evalUserReportDistKey;
61   -
62   - /**
63   - * 绩效报表定时任务
64   - *
65   - */
66   - @Scheduled(cron = TimeTaskConstant.EVAL_REPORT)
67   - @Transactional(rollbackFor = Exception.class)
68   - public void evalUserReportTask() {
69   - this.evalUserReport(LocalDate.now().minusDays(1));
70   - }
71   -
72   - /**
73   - * 绩效报表定时任务
74   - *
75   - * @param date
76   - */
77   - @Transactional(rollbackFor = Exception.class)
78   - public void evalUserReport(LocalDate date) {
79   - Lock lock = distributedLocker.lock(getEvalUserReportDistKey());
80   - if (! ((RLock) lock).isLocked()) {
81   - return;
82   - }
83   - try {
84   - log.info("定时任务【考评人员报表数据抽取】开始执行");
85   -
86   - evalUserReportService.update(Wrappers.<EvalUserReport>lambdaUpdate()
87   - .set(EvalUserReport::getYn, Boolean.FALSE)
88   - .eq(EvalUserReport::getDate, date)
89   - );
90   -
91   - List<EvalGroup> allEvalGroups = evalGroupService.getAllEffectGroups(date);
92   - Map<Long, List<EvalGroup>> groupKpiGroupMap = allEvalGroups.stream()
93   - .filter(evalGroup -> EvalScopeEnum.STAFF.equals(evalGroup.getScopeType()))
94   - .collect(Collectors.groupingBy(EvalGroup::getGroupId));
95   -
96   - List<EvalUserReport> userReports = Lists.newArrayListWithCapacity(500);
97   -
98   - //遍历集团
99   - oopRpcService.allGroups().stream().forEach(group -> {
100   - //构建查询参数
101   - final Long groupId = group.getId();
102   - List<EvalGroup> evalGroups = groupKpiGroupMap.getOrDefault(groupId, new ArrayList<>());
103   -
104   - GroupCalEvalReportDTO calDTO = buildParam(evalGroups, groupId, date);
105   - if (PublicUtil.isEmpty(calDTO.getShopIds())) {
106   - return;
107   - }
108   -
109   - //查询所有门店
110   - List<ShopDTO> shopDTOs = oopRpcService.queryShops(new ArrayList<>(calDTO.getShopIds()));
111   -
112   - //计算考评名组 门店
113   - calEvalGroupData(calDTO, userReports, shopDTOs);
114   -// //计算员工
115   - calStaffData(calDTO, userReports);
116   -// //计算绩效组门店
117   - calShopData(calDTO, userReports, shopDTOs);
118   - });
119   - if (PublicUtil.isNotEmpty(userReports)) {
120   - userReports.stream().forEach(userReport -> {
121   - userReport.setDate(date);
122   - userReport.setYn(Boolean.TRUE);
123   - });
124   - evalUserReportService.saveBatch(userReports);
125   - }
126   - } catch (Exception e){
127   - log.error(e.getMessage(), e);
128   - } finally {
129   - lock.unlock();
130   - }
131   - }
132   -
133   - public GroupCalEvalReportDTO buildParam(List<EvalGroup> evalGroups, Long groupId, LocalDate date) {
134   - GroupCalEvalReportDTO calDTO = new GroupCalEvalReportDTO(evalGroups, groupId);
135   - if (PublicUtil.isEmpty(evalGroups)) {
136   - return calDTO;
137   - }
138   - List<EvalUserPool> pools = evalUserPoolService.list(Wrappers.<EvalUserPool>lambdaQuery()
139   - .in(EvalUserPool::getEvalGroupId, evalGroups.stream().map(EvalGroup::getId).collect(Collectors.toList()))
140   - .eq(EvalUserPool::getMonthly, YearMonth.from(date))
141   - .eq(EvalUserPool::getYn, Boolean.TRUE)
142   - );
143   - calDTO.setUserPools(pools);
144   - Set<Long> shopIds = evalGroups.stream().map(evalGroup -> {
145   - return evalGroup.getShopIds().stream().map(Long::new).collect(Collectors.toList());
146   - }).collect(HashSet::new, Set::addAll, Set::addAll);
147   - calDTO.setShopIds(shopIds);
148   - return calDTO;
149   - }
150   -
151   - /**
152   - * 计算员工维度数据
153   - *
154   - * @param calDto
155   - */
156   - public void calStaffData(GroupCalEvalReportDTO calDto,
157   - List<EvalUserReport> userReports
158   - ) {
159   - List<EvalUserPool> userPools = calDto.getUserPools();
160   - List<EvalGroup> evalGroups = calDto.getEvalGroups();
161   -
162   - Map<Long, String> evalGroupNameMap = evalGroups.stream().collect(Collectors.toMap(EvalGroup::getId, EvalGroup::getName, (v1, v2) -> v1));
163   -
164   - for (EvalUserPool pool : userPools) {
165   - EvalUserReport userReport = new EvalUserReport(ReportDimensionEnum.STAFF, calDto.getGroupId());;
166   -
167   - userReport.setS1(pool.getUserName());
168   - userReport.setS2(pool.getShopName());
169   - userReport.setS3(pool.getPostName());
170   - userReport.setB3(pool.getInclusion());
171   - userReport.setB1(pool.getScoreRatio().multiply(Constant.ONE_HUNDRED));
172   - userReport.setB2(pool.getReward());
173   - userReport.setL1(pool.getUserId());
174   - userReport.setL2(pool.getShopId());
175   - userReport.setL3(pool.getEvalGroupId());
176   - userReport.setL5(pool.getPostId());
177   -
178   - userReport.setL4(pool.getEvalGroupId());
179   - userReport.setS4(evalGroupNameMap.getOrDefault(pool.getEvalGroupId(), ""));
180   - userReports.add(userReport);
181   - }
182   - }
183   -
184   - /**
185   - * 计算绩效组门店维度数据
186   - *
187   - * @param calDto
188   - */
189   - public void calEvalGroupData(GroupCalEvalReportDTO calDto,
190   - List<EvalUserReport> userReports,
191   - List<ShopDTO> shopDTOs
192   - ) {
193   - List<EvalUserPool> userPools = calDto.getUserPools();
194   - List<EvalGroup> userEvalGroups = calDto.getEvalGroups();
195   -
196   - for (EvalGroup evalGroup : userEvalGroups) {
197   - final Long evalGroupId = evalGroup.getId();
198   - final String evalGroupName = evalGroup.getName();
199   - final Set<Long> shopIds = new HashSet<>(evalGroup.getShopIds());
200   -
201   - shopDTOs.stream().filter(shopDTO -> shopIds.contains(shopDTO.getId())).forEach(shop -> {
202   - Long shopId = shop.getId();
203   - EvalUserReport evalGroupShopReport = new EvalUserReport(ReportDimensionEnum.EVAL_GROUP_SHOP, calDto.getGroupId());
204   - Predicate<EvalUserPool> evalGroupShopPredicate = pool -> {
205   - return shopId.equals(pool.getShopId()) && evalGroupId.equals(pool.getEvalGroupId()) && Boolean.TRUE.equals(pool.getInclusion());
206   - };
207   - evalGroupShopReport.setL2(shopId);
208   - evalGroupShopReport.setS2(shop.getShopName());
209   - evalGroupShopReport.setS4(evalGroupName);
210   - evalGroupShopReport.setL4(evalGroupId);
211   - evalGroupShopReport.setB1(averageRatio(userPools, evalGroupShopPredicate));
212   - evalGroupShopReport.setB2(totalSalary(userPools, evalGroupShopPredicate));
213   - userReports.add(evalGroupShopReport);
214   - });
215   -
216   - }
217   - }
218   -
219   - /**
220   - * 计算绩效组门店维度数据
221   - *
222   - * @param calDto
223   - */
224   - public void calShopData(GroupCalEvalReportDTO calDto,
225   - List<EvalUserReport> userReports,
226   - List<ShopDTO> shopDTOs
227   - ) {
228   - List<EvalUserPool> userPools = calDto.getUserPools();
229   - List<EvalGroup> userEvalGroups = calDto.getEvalGroups();
230   -
231   - shopDTOs.stream().forEach(shop -> {
232   - final Long shopId = shop.getId();
233   - EvalUserReport userReport = new EvalUserReport(ReportDimensionEnum.SHOP, calDto.getGroupId());
234   - Predicate<EvalUserPool> predicate = pool -> {
235   - return shopId.equals(pool.getShopId()) && Boolean.TRUE.equals(pool.getInclusion());
236   - };
237   - userReport.setL2(shopId);
238   - userReport.setS2(shop.getShopName());
239   - userReport.setB1(averageRatio(userPools, predicate));
240   - userReport.setB2(totalSalary(userPools, predicate));
241   - userReports.add(userReport);
242   -
243   - for (EvalGroup evalGroup : userEvalGroups) {
244   - final String evalGroupName = evalGroup.getName();
245   - final Long evalGroupId = evalGroup.getId();
246   - final List<Long> shopIds = evalGroup.getShopIds();
247   - if (! shopIds.contains(shopId)) {
248   - continue;
249   - }
250   -
251   - EvalUserReport shopEvalGroup = new EvalUserReport(ReportDimensionEnum.SHOP_EVAL_GROUP, calDto.getGroupId());
252   - Predicate<EvalUserPool> predicateEvalGroup = pool -> {
253   - return shopId.equals(pool.getShopId()) && evalGroupId.equals(pool.getEvalGroupId()) && Boolean.TRUE.equals(pool.getInclusion());
254   - };
255   - shopEvalGroup.setL2(shopId);
256   - shopEvalGroup.setS2(shop.getShopName());
257   - shopEvalGroup.setS4(evalGroupName);
258   - shopEvalGroup.setL4(evalGroupId);
259   - shopEvalGroup.setB1(averageRatio(userPools, predicateEvalGroup));
260   - shopEvalGroup.setB2(totalSalary(userPools, predicateEvalGroup));
261   - userReports.add(shopEvalGroup);
262   - }
263   - });
264   - }
265   -
266   -
267   - /**
268   - * 绩效池平均绩效得分率
269   - *
270   - * @param pools
271   - * @return
272   - */
273   - public BigDecimal averageRatio(Collection<EvalUserPool> pools, Predicate<EvalUserPool> predicate) {
274   - if (CollectionUtils.isEmpty(pools)) {
275   - return BigDecimal.ZERO;
276   - }
277   - Double averageRatioDouble = pools.stream()
278   - .filter(predicate)
279   - .mapToDouble(r -> Optional.ofNullable(r.getScoreRatio()).orElse(BigDecimal.ZERO).doubleValue())
280   - .average()
281   - .orElse(0);
282   - BigDecimal averageRatio = new BigDecimal(averageRatioDouble.toString());
283   - return averageRatio.multiply(new BigDecimal("100")).setScale(2, RoundingMode.DOWN);
284   - }
285   -
286   - /**
287   - * 总薪酬
288   - *
289   - * @param pools
290   - * @return
291   - */
292   - public BigDecimal totalSalary(Collection<EvalUserPool> pools, Predicate<EvalUserPool> predicate) {
293   - if (CollectionUtils.isEmpty(pools)) {
294   - return BigDecimal.ZERO;
295   - }
296   - BigDecimal totalSalary = pools.stream()
297   - .filter(predicate)
298   - .map(r -> Optional.ofNullable(r.getReward()).orElse(BigDecimal.ZERO))
299   - .reduce(BigDecimal.ZERO, BigDecimal::add);
300   - return totalSalary.setScale(2, RoundingMode.DOWN);
301   - }
302   -}
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/EvalShopReportService.java deleted
1   -package cn.fw.morax.service.data.eval;
2   -
3   -
4   -import cn.fw.morax.domain.db.eval.EvalShopReport;
5   -import cn.fw.morax.domain.db.eval.EvalUserReport;
6   -import com.baomidou.mybatisplus.extension.service.IService;
7   -
8   -/**
9   - * <p>
10   - * 考评组 服务类
11   - * </p>
12   - *
13   - * @author jiangchao
14   - * @since 2022-12-09
15   - */
16   -public interface EvalShopReportService extends IService<EvalShopReport> {
17   -
18   -}
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/EvalUserReportService.java deleted
1   -package cn.fw.morax.service.data.eval;
2   -
3   -
4   -import cn.fw.morax.domain.db.eval.Eval;
5   -import cn.fw.morax.domain.db.eval.EvalUserReport;
6   -import com.baomidou.mybatisplus.extension.service.IService;
7   -
8   -/**
9   - * <p>
10   - * 考评组 服务类
11   - * </p>
12   - *
13   - * @author jiangchao
14   - * @since 2022-12-09
15   - */
16   -public interface EvalUserReportService extends IService<EvalUserReport> {
17   -
18   -}
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/impl/EvalShopReportServiceImpl.java deleted
1   -package cn.fw.morax.service.data.eval.impl;
2   -
3   -
4   -import cn.fw.morax.dao.eval.EvalShopReportDao;
5   -import cn.fw.morax.dao.eval.EvalUserReportDao;
6   -import cn.fw.morax.domain.db.eval.EvalShopReport;
7   -import cn.fw.morax.domain.db.eval.EvalUserReport;
8   -import cn.fw.morax.service.data.eval.EvalShopReportService;
9   -import cn.fw.morax.service.data.eval.EvalUserReportService;
10   -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11   -import org.springframework.stereotype.Service;
12   -
13   -/**
14   - * <p>
15   - * 考评组 服务实现类
16   - * </p>
17   - *
18   - * @author jiangchao
19   - * @since 2022-12-09
20   - */
21   -@Service
22   -public class EvalShopReportServiceImpl extends ServiceImpl<EvalShopReportDao, EvalShopReport> implements EvalShopReportService {
23   -
24   -}
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/impl/EvalUserReportServiceImpl.java deleted
1   -package cn.fw.morax.service.data.eval.impl;
2   -
3   -
4   -import cn.fw.morax.dao.eval.EvalUserReportDao;
5   -import cn.fw.morax.domain.db.eval.EvalUserReport;
6   -import cn.fw.morax.service.data.eval.EvalUserReportService;
7   -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8   -import org.springframework.stereotype.Service;
9   -
10   -/**
11   - * <p>
12   - * 考评组 服务实现类
13   - * </p>
14   - *
15   - * @author jiangchao
16   - * @since 2022-12-09
17   - */
18   -@Service
19   -public class EvalUserReportServiceImpl extends ServiceImpl<EvalUserReportDao, EvalUserReport> implements EvalUserReportService {
20   -
21   -}