Commit 304c04738baf3ccb802071afa682687f63b83205

Authored by 姜超
1 parent c285665c

feature(*): 考评阶段指标上报

考评阶段指标上报
doc/2023_update.sql
... ... @@ -557,4 +557,5 @@ ALTER TABLE `fw_morax`.`eval_group_user`
557 557 -- salary_closure
558 558 -- eval_group_rank
559 559 -- eval_group
560   --- kpi_stage_mq_log
561 560 \ No newline at end of file
  561 +-- kpi_stage_mq_log
  562 +-- indicator_user_stage_value
562 563 \ No newline at end of file
... ...
fw-morax-dao/src/main/java/cn/fw/morax/dao/kpi/IndicatorUserStageValueDao.java 0 → 100644
  1 +package cn.fw.morax.dao.kpi;
  2 +
  3 +import cn.fw.morax.domain.db.kpi.IndicatorUserStageValue;
  4 +import cn.fw.morax.domain.db.kpi.IndicatorUserValue;
  5 +import cn.fw.morax.domain.vo.kpi.IndicatorUserStageValueVO;
  6 +import cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO;
  7 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  8 +import org.apache.ibatis.annotations.Param;
  9 +import org.springframework.stereotype.Repository;
  10 +
  11 +import java.time.YearMonth;
  12 +import java.util.List;
  13 +import java.util.Set;
  14 +
  15 +/**
  16 + * 用户指标上报数据
  17 + *
  18 + * @author : kurisu
  19 + * @version : 2.0
  20 + * @className : IndicatorUserValueDao
  21 + * @description : 用户指标上报数据
  22 + * @date : 2022-12-15 11:22
  23 + */
  24 +@Repository
  25 +public interface IndicatorUserStageValueDao extends BaseMapper<IndicatorUserStageValue> {
  26 +
  27 + /**
  28 + * 获取指标原始上报记录
  29 + *
  30 + * @param indicatorCode
  31 + * @param monthly
  32 + * @param userIds
  33 + * @return
  34 + */
  35 + List<IndicatorUserStageValueVO> getReportData(@Param("indicatorCode") String indicatorCode,
  36 + @Param("monthly") YearMonth monthly,
  37 + @Param("userIds") Set<Long> userIds,
  38 + @Param("shopIds") Set<Long> shopIds);
  39 +
  40 +}
... ...
fw-morax-dao/src/main/resources/mapper/kpi/IndicatorUserStageValueMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.fw.morax.dao.kpi.IndicatorUserStageValueDao">
  4 +
  5 + <select id="getReportData" resultType="cn.fw.morax.domain.vo.kpi.IndicatorUserStageValueVO">
  6 + SELECT
  7 + t1.id,
  8 + t1.user_id,
  9 + t1.indicator_code,
  10 + t1.indicator_name,
  11 + t1.indicator_value,
  12 + t1.value_type,
  13 + t1.data_date,
  14 + t1.group_id
  15 + FROM
  16 + indicator_user_value t1,
  17 + (
  18 + SELECT CONVERT
  19 + ( SUBSTRING_INDEX( group_concat( id ORDER BY `data_date` DESC ), ',', 1 ), SIGNED ) pk
  20 + FROM
  21 + indicator_user_value
  22 + WHERE
  23 + DATE_FORMAT( data_date, '%Y-%m' ) = #{monthly}
  24 + <if test="userIds != null and userIds.size > 0 ">
  25 + AND user_id IN
  26 + <foreach collection="userIds" item="userId" separator=" , " open="(" close=")">
  27 + #{userId}
  28 + </foreach>
  29 + </if>
  30 + <if test="shopIds != null and shopIds.size > 0 ">
  31 + AND shop_id IN
  32 + <foreach collection="shopIds" item="shopId" separator=" , " open="(" close=")">
  33 + #{shopId}
  34 + </foreach>
  35 + </if>
  36 + AND indicator_code = #{indicatorCode}
  37 + AND yn = 1
  38 + GROUP BY
  39 + user_id
  40 + ) t2
  41 + WHERE
  42 + t1.id = t2.pk
  43 + </select>
  44 +
  45 +
  46 +
  47 +
  48 +</mapper>
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/bo/kpi/UserIndicatorStageBO.java 0 → 100644
  1 +package cn.fw.morax.domain.bo.kpi;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.math.BigDecimal;
  6 +import java.util.Date;
  7 +import java.util.Map;
  8 +
  9 +/**
  10 + * @author : kurisu
  11 + * @version : 2.0
  12 + * @className : UserIndicatorBO
  13 + * @description : 人员绩效值
  14 + * @date : 2022-04-13 17:21
  15 + */
  16 +@Data
  17 +public class UserIndicatorStageBO {
  18 + /**
  19 + * 指标编码
  20 + */
  21 + private String indicatorCode;
  22 + /**
  23 + * 人员id
  24 + */
  25 + private Long userId;
  26 + /**
  27 + * 指标值类型
  28 + */
  29 + private Integer valueType;
  30 + /**
  31 + * 指标对应值
  32 + */
  33 + private Map<String, BigDecimal> value;
  34 + /**
  35 + * 数据开始日期
  36 + */
  37 + private Date beginDate;
  38 + /**
  39 + * 数据结束日期
  40 + */
  41 + private Date endDate;
  42 + /**
  43 + * 集团id
  44 + */
  45 + private Long groupId;
  46 +}
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/kpi/IndicatorUserStageValue.java 0 → 100644
  1 +package cn.fw.morax.domain.db.kpi;
  2 +
  3 +import cn.fw.common.data.entity.BaseAuditableTimeEntity;
  4 +import cn.fw.morax.domain.enums.DimensionTypeEnum;
  5 +import cn.fw.morax.domain.enums.IndicatorValueTypeEnum;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +
  10 +import java.time.LocalDate;
  11 +
  12 +/**
  13 + * 用户绩效指标上报数据类
  14 + *
  15 + * @author : kurisu
  16 + * @version : 2.0
  17 + * @className : IndicatorUserValue
  18 + * @description : 用户绩效指标上报数据类
  19 + * @date : 2022-12-15 11:19
  20 + */
  21 +@Data
  22 +@EqualsAndHashCode(callSuper = true)
  23 +@TableName(autoResultMap = true)
  24 +public class IndicatorUserStageValue extends BaseAuditableTimeEntity<IndicatorUserStageValue, Long> {
  25 + /**
  26 + * 人员id
  27 + */
  28 + private Long userId;
  29 + /**
  30 + * 门店id
  31 + */
  32 + private Long shopId;
  33 + /**
  34 + * 指标编码
  35 + */
  36 + private String indicatorCode;
  37 + /**
  38 + * 指标名称
  39 + */
  40 + private String indicatorName;
  41 + /**
  42 + * 维度类型 1:人员 2:门店
  43 + */
  44 + private DimensionTypeEnum dimensionType;
  45 + /**
  46 + * 类型;1: 百分比 2:数量 3:条件值 4:金额 5:工龄
  47 + */
  48 + private IndicatorValueTypeEnum valueType;
  49 + /**
  50 + * 指标业务值
  51 + * 指标值;jons字符串 map类型
  52 + */
  53 + private String indicatorValue;
  54 + /**
  55 + * 数据开始日期
  56 + */
  57 + private LocalDate beginDate;
  58 + /**
  59 + * 数据结束日期
  60 + */
  61 + private LocalDate endDate;
  62 + /**
  63 + * 集团id
  64 + */
  65 + private Long groupId;
  66 + /**
  67 + * 逻辑删除
  68 + */
  69 + private Boolean yn;
  70 +}
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/kpi/IndicatorUserStageValueVO.java 0 → 100644
  1 +package cn.fw.morax.domain.vo.kpi;
  2 +
  3 +import cn.fw.morax.domain.enums.DimensionTypeEnum;
  4 +import cn.fw.morax.domain.enums.IndicatorValueTypeEnum;
  5 +import lombok.Data;
  6 +
  7 +import java.time.LocalDate;
  8 +
  9 +/**
  10 + * 用户绩效指标上报数据类
  11 + *
  12 + * @author : kurisu
  13 + * @version : 2.0
  14 + * @className : IndicatorUserValue
  15 + * @description : 用户绩效指标上报数据类
  16 + * @date : 2022-12-15 11:19
  17 + */
  18 +@Data
  19 +public class IndicatorUserStageValueVO {
  20 + /**
  21 + * id
  22 + */
  23 + private Long id;
  24 + /**
  25 + * 人员id
  26 + */
  27 + private Long userId;
  28 + /**
  29 + * 指标编码
  30 + */
  31 + private String indicatorCode;
  32 + /**
  33 + * 指标名称
  34 + */
  35 + private String indicatorName;
  36 +
  37 + /**
  38 + * 维度类型 1:人员 2:门店
  39 + */
  40 + private DimensionTypeEnum dimensionType;
  41 + /**
  42 + * 类型;1: 百分比 2:数量 3:条件值 4:金额 5:工龄
  43 + */
  44 + private IndicatorValueTypeEnum valueType;
  45 + /**
  46 + * 指标业务值
  47 + * 指标值;jons字符串 map类型
  48 + */
  49 + private String indicatorValue;
  50 + /**
  51 + * 数据日期
  52 + */
  53 + private LocalDate dataDate;
  54 + /**
  55 + * 集团id
  56 + */
  57 + private Long groupId;
  58 + /**
  59 + * 逻辑删除
  60 + */
  61 + private Boolean yn;
  62 +}
... ...
fw-morax-sdk/src/main/java/cn/fw/morax/sdk/api/IndicatorReportService.java
... ... @@ -3,6 +3,7 @@ package cn.fw.morax.sdk.api;
3 3 import cn.fw.data.base.domain.common.Message;
4 4 import cn.fw.morax.sdk.dto.CustomList;
5 5 import cn.fw.morax.sdk.dto.common.IndicatorShopValueReq;
  6 +import cn.fw.morax.sdk.dto.common.IndicatorStageValueReq;
6 7 import cn.fw.morax.sdk.dto.common.IndicatorValueReq;
7 8 import org.springframework.cloud.openfeign.FeignClient;
8 9 import org.springframework.web.bind.annotation.PostMapping;
... ... @@ -38,4 +39,13 @@ public interface IndicatorReportService {
38 39 */
39 40 @PostMapping("/report-shop/up")
40 41 Message<Void> indicatorShopReport(@Valid @RequestBody CustomList<IndicatorShopValueReq> shopIndicatorList);
  42 +
  43 + /**
  44 + * 上报人员阶段指标数据
  45 + *
  46 + * @param userIndicatorList 人员指标数据
  47 + * @return void
  48 + */
  49 + @PostMapping("/report-stage/up")
  50 + Message<Void> indicatorStageReport(@Valid @RequestBody CustomList<IndicatorStageValueReq> userIndicatorList);
41 51 }
... ...
fw-morax-sdk/src/main/java/cn/fw/morax/sdk/dto/common/IndicatorStageValueReq.java 0 → 100644
  1 +package cn.fw.morax.sdk.dto.common;
  2 +
  3 +import cn.fw.common.validator.EnumValue;
  4 +import lombok.Data;
  5 +import org.hibernate.validator.constraints.ScriptAssert;
  6 +
  7 +import javax.validation.Valid;
  8 +import javax.validation.constraints.NotBlank;
  9 +import javax.validation.constraints.NotEmpty;
  10 +import javax.validation.constraints.NotNull;
  11 +import javax.validation.constraints.Past;
  12 +import java.util.Date;
  13 +import java.util.List;
  14 +import java.util.regex.Pattern;
  15 +
  16 +/**
  17 + * @author : kurisu
  18 + * @version : 2.0
  19 + * @className : IndicatorValueReq
  20 + * @description : 人员绩效指标值
  21 + * @date : 2022-12-22 09:45
  22 + */
  23 +@Data
  24 +@ScriptAssert.List({
  25 + @ScriptAssert(lang = "javascript", script = "_this.checkConditionValue()", message = "指标项key不正确"),
  26 +})
  27 +public class IndicatorStageValueReq {
  28 + private static final String regNo = "^[-\\+]?[\\d]*$";
  29 + /**
  30 + * 人员id
  31 + */
  32 + @NotNull(message = "人员id不能为空")
  33 + private Long userId;
  34 + /**
  35 + * 指标编码
  36 + */
  37 + @NotBlank(message = "指标编码不能为空")
  38 + private String indicatorCode;
  39 + /**
  40 + * 指标值类型
  41 + *
  42 + * @see IndicatorValueEnum
  43 + */
  44 + @NotNull(message = "指标值类型不能为空")
  45 + @EnumValue(enumClass = IndicatorValueEnum.class, message = "指标值枚举值不正确")
  46 + private Integer valueType;
  47 + /**
  48 + * 指标项
  49 + */
  50 + @NotEmpty(message = "指标项不能为空")
  51 + @Valid
  52 + private List<IndicatorValueDTO> indicatorValue;
  53 + /**
  54 + * 数据开始日期
  55 + */
  56 + @NotNull(message = "数据开始日期不能为空")
  57 + @Past(message = "数据开始日期必须为过去的时间")
  58 + private Date beginDate;
  59 + /**
  60 + * 数据结束日期
  61 + */
  62 + @NotNull(message = "数据结束日期不能为空")
  63 + @Past(message = "数据结束日期必须为过去的时间")
  64 + private Date endDate;
  65 + /**
  66 + * 集团id
  67 + */
  68 + @NotNull(message = "集团id不能为空")
  69 + private Long groupId;
  70 +
  71 + public boolean checkConditionValue() {
  72 + if (IndicatorValueEnum.CONDITION.getValue().equals(valueType)) {
  73 + return indicatorValue.stream().allMatch(r -> isNumber(r.getKey()));
  74 + }
  75 + return true;
  76 + }
  77 +
  78 + private boolean isNumber(String str) {
  79 + if (str == null) {
  80 + return false;
  81 + }
  82 + Pattern compile = Pattern.compile(regNo);
  83 + return compile.matcher(str).matches();
  84 + }
  85 +}
  86 +
... ...
fw-morax-server/src/main/java/cn/fw/morax/server/controller/api/IndicatorReportServiceImpl.java
... ... @@ -5,6 +5,7 @@ import cn.fw.data.base.domain.common.Message;
5 5 import cn.fw.morax.sdk.api.IndicatorReportService;
6 6 import cn.fw.morax.sdk.dto.CustomList;
7 7 import cn.fw.morax.sdk.dto.common.IndicatorShopValueReq;
  8 +import cn.fw.morax.sdk.dto.common.IndicatorStageValueReq;
8 9 import cn.fw.morax.sdk.dto.common.IndicatorValueReq;
9 10 import cn.fw.morax.service.biz.kpi.IndicatorBizService;
10 11 import lombok.RequiredArgsConstructor;
... ... @@ -53,4 +54,13 @@ public class IndicatorReportServiceImpl implements IndicatorReportService {
53 54 indicatorBizService.reportShopData(userIndicatorList);
54 55 return Message.success();
55 56 }
  57 +
  58 + @PostMapping("/report-stage/up")
  59 + @ControllerMethod("上报人员阶段指标数据")
  60 + @Override
  61 + public Message<Void> indicatorStageReport(@Valid @RequestBody CustomList<IndicatorStageValueReq> userIndicatorList) {
  62 + BV.isTrue(userIndicatorList.size() <= MAX_SIZE, () -> MessageFormatTransfer("最多支持一次性处理{0}条任务", MAX_SIZE));
  63 + indicatorBizService.reportStageData(userIndicatorList);
  64 + return Message.success();
  65 + }
56 66 }
... ...
fw-morax-server/src/main/java/cn/fw/morax/server/task/KpiCalcTask.java
... ... @@ -51,6 +51,7 @@ public class KpiCalcTask {
51 51 public void persistence() {
52 52 indicatorBizService.persistenceUserData();
53 53 indicatorBizService.persistenceShopData();
  54 + indicatorBizService.persistenceUserStageData();
54 55 }
55 56  
56 57 /**
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/kpi/IndicatorBizService.java
... ... @@ -11,6 +11,7 @@ import cn.fw.morax.common.utils.PublicUtil;
11 11 import cn.fw.morax.common.utils.ThreadPoolUtil;
12 12 import cn.fw.morax.domain.bo.kpi.ShopIndicatorBO;
13 13 import cn.fw.morax.domain.bo.kpi.UserIndicatorBO;
  14 +import cn.fw.morax.domain.bo.kpi.UserIndicatorStageBO;
14 15 import cn.fw.morax.domain.db.eval.EvalGroup;
15 16 import cn.fw.morax.domain.db.eval.EvalGroupIndicatorParam;
16 17 import cn.fw.morax.domain.db.eval.EvalGroupIndicatorPrecondition;
... ... @@ -25,6 +26,7 @@ import cn.fw.morax.domain.dto.query.IndicatorPostQueryDTO;
25 26 import cn.fw.morax.domain.dto.query.IndicatorQueryDTO;
26 27 import cn.fw.morax.domain.dto.query.QueryConditionIndicatorsListDTO;
27 28 import cn.fw.morax.domain.enums.*;
  29 +import cn.fw.morax.domain.vo.kpi.IndicatorUserStageValueVO;
28 30 import cn.fw.morax.domain.vo.kpi.IndicatorsVO;
29 31 import cn.fw.morax.domain.vo.kpi.QueryConditionIndicatorsListVO;
30 32 import cn.fw.morax.rpc.ehr.EhrRpcService;
... ... @@ -32,12 +34,14 @@ import cn.fw.morax.rpc.ehr.dto.PostInfoDTO;
32 34 import cn.fw.morax.rpc.ehr.dto.PostRoleDTO;
33 35 import cn.fw.morax.sdk.dto.CustomList;
34 36 import cn.fw.morax.sdk.dto.common.IndicatorShopValueReq;
  37 +import cn.fw.morax.sdk.dto.common.IndicatorStageValueReq;
35 38 import cn.fw.morax.sdk.dto.common.IndicatorValueDTO;
36 39 import cn.fw.morax.sdk.dto.common.IndicatorValueReq;
37 40 import cn.fw.morax.service.data.CombineIndicatorParamService;
38 41 import cn.fw.morax.service.data.eval.EvalGroupIndicatorParamService;
39 42 import cn.fw.morax.service.data.eval.EvalGroupIndicatorPreconditionService;
40 43 import cn.fw.morax.service.data.eval.EvalGroupService;
  44 +import cn.fw.morax.service.data.kpi.IndicatorUserStageValueService;
41 45 import cn.fw.morax.service.data.kpi.IndicatorUserValueService;
42 46 import cn.fw.morax.service.data.kpi.IndicatorsService;
43 47 import cn.fw.morax.service.data.salary.SalaryGroupProjectParamService;
... ... @@ -83,6 +87,7 @@ public class IndicatorBizService {
83 87 private final EhrRpcService ehrRpcService;
84 88 private final StringRedisTemplate stringRedisTemplate;
85 89 private final IndicatorUserValueService indicatorUserValueService;
  90 + private final IndicatorUserStageValueService indicatorUserStageValueService;
86 91  
87 92 /**
88 93 * 指标数据上报redis-key
... ... @@ -99,6 +104,9 @@ public class IndicatorBizService {
99 104 @Value("${spring.cache.custom.global-prefix}:indicator:enable:")
100 105 @Getter
101 106 private String enablePrefix;
  107 + @Value("${spring.cache.custom.global-prefix}:indicator-stage-value")
  108 + @Getter
  109 + private String indicatorStageKeyPref;
102 110  
103 111 /**
104 112 * 分页查询
... ... @@ -258,6 +266,21 @@ public class IndicatorBizService {
258 266 }
259 267  
260 268 /**
  269 + * 收集业务系统上报的数据
  270 + * 先直接放到redis增加系统吞吐量
  271 + *
  272 + * @param userIndicatorList
  273 + */
  274 + public void reportStageData(CustomList<IndicatorStageValueReq> userIndicatorList) {
  275 + String[] jsonArr = userIndicatorList.stream().map(r -> {
  276 + UserIndicatorStageBO bo = transferStageBo(r);
  277 + return JSONObject.toJSONString(bo);
  278 + }).toArray(String[]::new);
  279 + BoundListOperations<String, String> opsList = stringRedisTemplate.boundListOps(getIndicatorStageKeyPref());
  280 + opsList.rightPushAll(jsonArr);
  281 + }
  282 +
  283 + /**
261 284 * 从缓存取池上报的数据并进行持久化
262 285 */
263 286 public void persistenceUserData() {
... ... @@ -291,6 +314,39 @@ public class IndicatorBizService {
291 314 }
292 315  
293 316 /**
  317 + * 从缓存取池上报的数据并进行持久化
  318 + */
  319 + public void persistenceUserStageData() {
  320 + ThreadPoolExecutor threadPool = ThreadPoolUtil.getInstance().getThreadPool();
  321 + ListOperations<String, String> opsForList = stringRedisTemplate.opsForList();
  322 + List<String> overflowsOrFailList = new ArrayList<>();
  323 + String jsonStr;
  324 + while ((jsonStr = opsForList.leftPop(getIndicatorStageKeyPref())) != null) {
  325 + final UserIndicatorStageBO bo = JSONObject.parseObject(jsonStr, UserIndicatorStageBO.class);
  326 + if (Objects.isNull(bo)) {
  327 + continue;
  328 + }
  329 + try {
  330 + //保存业务系统绩效指标值
  331 + final String finalJsonStr = jsonStr;
  332 + threadPool.execute(() -> {
  333 + try {
  334 + saveUserStageIndicator(bo);
  335 + } catch (Exception e) {
  336 + log.error("保存业务系统绩效阶段指标值失败:{}", bo, e);
  337 + overflowsOrFailList.add(finalJsonStr);
  338 + }
  339 + });
  340 + } catch (RejectedExecutionException re) {
  341 + overflowsOrFailList.add(jsonStr);
  342 + }
  343 + }
  344 + if (!CollectionUtils.isEmpty(overflowsOrFailList)) {
  345 + opsForList.rightPushAll(getIndicatorKeyPref(), overflowsOrFailList);
  346 + }
  347 + }
  348 +
  349 + /**
294 350 * 持久化业务系统上报的指标数据
295 351 *
296 352 * @param bo
... ... @@ -325,6 +381,43 @@ public class IndicatorBizService {
325 381 }
326 382  
327 383 /**
  384 + * 持久化业务系统上报的指标数据
  385 + *
  386 + * @param bo
  387 + */
  388 + @Transactional(rollbackFor = Exception.class)
  389 + public void saveUserStageIndicator(UserIndicatorStageBO bo) {
  390 + final LocalDate beginDate = DateUtil.date2LocalDate(bo.getBeginDate());
  391 + final LocalDate endDate = DateUtil.date2LocalDate(bo.getEndDate());
  392 + Indicators indicator = indicatorsService.queryByCode(bo.getIndicatorCode(), Boolean.FALSE);
  393 + if (Objects.isNull(indicator)) {
  394 + return;
  395 + }
  396 + IndicatorUserStageValue value = new IndicatorUserStageValue();
  397 + value.setUserId(bo.getUserId());
  398 + value.setShopId(-1L);
  399 + value.setDimensionType(DimensionTypeEnum.STAFF);
  400 + value.setIndicatorCode(indicator.getIndicatorCode());
  401 + value.setIndicatorName(indicator.getIndicatorName());
  402 + IndicatorValueTypeEnum valueTypeEnum = IndicatorValueTypeEnum.ofValue(bo.getValueType());
  403 + value.setValueType(valueTypeEnum);
  404 + Map<String, BigDecimal> valueMap = bo.getValue();
  405 + value.setIndicatorValue(JSONObject.toJSONString(valueMap));
  406 + value.setBeginDate(beginDate);
  407 + value.setEndDate(endDate);
  408 + value.setGroupId(bo.getGroupId());
  409 + value.setYn(Boolean.TRUE);
  410 + indicatorUserStageValueService.remove(Wrappers.<IndicatorUserStageValue>lambdaQuery()
  411 + .eq(IndicatorUserStageValue::getUserId, value.getUserId())
  412 + .eq(IndicatorUserStageValue::getIndicatorCode, value.getIndicatorCode())
  413 + .eq(IndicatorUserStageValue::getBeginDate, beginDate)
  414 + .eq(IndicatorUserStageValue::getEndDate, beginDate)
  415 + .eq(IndicatorUserStageValue::getGroupId, value.getGroupId())
  416 + );
  417 + indicatorUserStageValueService.save(value);
  418 + }
  419 +
  420 + /**
328 421 * 收集业务系统上报的数据
329 422 * 先直接放到redis增加系统吞吐量
330 423 *
... ... @@ -616,6 +709,34 @@ public class IndicatorBizService {
616 709 * @param req
617 710 * @return
618 711 */
  712 + private UserIndicatorStageBO transferStageBo(IndicatorStageValueReq req) {
  713 + UserIndicatorStageBO bo = new UserIndicatorStageBO();
  714 + bo.setIndicatorCode(req.getIndicatorCode());
  715 + bo.setUserId(req.getUserId());
  716 + bo.setBeginDate(req.getBeginDate());
  717 + bo.setEndDate(req.getEndDate());
  718 + bo.setGroupId(req.getGroupId());
  719 + IndicatorValueTypeEnum typeEnum = IndicatorValueTypeEnum.ofValue(req.getValueType());
  720 + bo.setValueType(req.getValueType());
  721 + List<IndicatorValueDTO> valueList = req.getIndicatorValue();
  722 + Map<String, BigDecimal> map = new HashMap<>(valueList.size());
  723 + for (IndicatorValueDTO valueDTO : valueList) {
  724 + String key = req.getIndicatorCode();
  725 + if (IndicatorValueTypeEnum.CONDITION.equals(typeEnum)) {
  726 + key = valueDTO.getKey();
  727 + }
  728 + map.put(key, valueDTO.getValue());
  729 + }
  730 + bo.setValue(map);
  731 + return bo;
  732 + }
  733 +
  734 + /**
  735 + * 转换数据
  736 + *
  737 + * @param req
  738 + * @return
  739 + */
619 740 private ShopIndicatorBO transferShopBo(IndicatorShopValueReq req) {
620 741 ShopIndicatorBO bo = new ShopIndicatorBO();
621 742 bo.setIndicatorCode(req.getIndicatorCode());
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/kpi/IndicatorUserStageValueService.java 0 → 100644
  1 +package cn.fw.morax.service.data.kpi;
  2 +
  3 +import cn.fw.morax.domain.db.kpi.IndicatorUserStageValue;
  4 +import cn.fw.morax.domain.db.kpi.IndicatorUserValue;
  5 +import cn.fw.morax.domain.vo.kpi.IndicatorUserStageValueVO;
  6 +import cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO;
  7 +import com.baomidou.mybatisplus.extension.service.IService;
  8 +
  9 +import java.time.YearMonth;
  10 +import java.util.List;
  11 +import java.util.Set;
  12 +
  13 +/**
  14 + * 用户上报的绩效数据
  15 + *
  16 + * @author : kurisu
  17 + * @version : 2.0
  18 + * @className : IndicatorUserValueService
  19 + * @description : 用户上报的绩效数据
  20 + * @date : 2022-12-15 11:24
  21 + */
  22 +public interface IndicatorUserStageValueService extends IService<IndicatorUserStageValue> {
  23 +
  24 + /**
  25 + * 获取指标原始上报记录
  26 + *
  27 + * @param indicatorCode
  28 + * @param monthly
  29 + * @param userIds
  30 + * @return
  31 + */
  32 + List<IndicatorUserStageValueVO> getStaffReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds);
  33 +
  34 +}
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/kpi/impl/IndicatorUserStageValueServiceImpl.java 0 → 100644
  1 +package cn.fw.morax.service.data.kpi.impl;
  2 +
  3 +import cn.fw.morax.dao.kpi.IndicatorUserStageValueDao;
  4 +import cn.fw.morax.dao.kpi.IndicatorUserValueDao;
  5 +import cn.fw.morax.domain.db.kpi.IndicatorUserStageValue;
  6 +import cn.fw.morax.domain.db.kpi.IndicatorUserValue;
  7 +import cn.fw.morax.domain.vo.kpi.IndicatorUserStageValueVO;
  8 +import cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO;
  9 +import cn.fw.morax.service.data.kpi.IndicatorUserStageValueService;
  10 +import cn.fw.morax.service.data.kpi.IndicatorUserValueService;
  11 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  12 +import lombok.extern.slf4j.Slf4j;
  13 +import org.springframework.stereotype.Service;
  14 +
  15 +import java.time.YearMonth;
  16 +import java.util.List;
  17 +import java.util.Set;
  18 +
  19 +/**
  20 + * 绩效上报的数据
  21 + *
  22 + * @author : kurisu
  23 + * @version : 2.0
  24 + * @className : IndicatorUserValueServiceImpl
  25 + * @description : 绩效上报的数据
  26 + * @date : 2022-12-15 11:25
  27 + */
  28 +@Service
  29 +@Slf4j
  30 +public class IndicatorUserStageValueServiceImpl extends ServiceImpl<IndicatorUserStageValueDao, IndicatorUserStageValue>
  31 + implements IndicatorUserStageValueService {
  32 +
  33 + @Override
  34 + public List<IndicatorUserStageValueVO> getStaffReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds) {
  35 + return this.baseMapper.getReportData(indicatorCode, monthly, userIds, null);
  36 + }
  37 +
  38 +}
... ...