Commit ae1929f4a861912d469adb9434bb8fd23ff967b6

Authored by 姜超
1 parent d049ee40

feature(compensation): 岗位最低收入补偿

岗位最低收入补偿
fw-morax-common/src/main/java/cn/fw/morax/common/config/FlowVal.java
... ... @@ -22,4 +22,9 @@ public class FlowVal {
22 22 */
23 23 private String kpiStarAdjustment;
24 24  
  25 + /**
  26 + * 绩效组修改审批
  27 + */
  28 + private String incomeCompensationConfig;
  29 +
25 30 }
... ...
fw-morax-dao/src/main/java/cn/fw/morax/dao/salary/IncomeCompensationDao.java 0 → 100644
  1 +package cn.fw.morax.dao.salary;
  2 +
  3 +
  4 +import cn.fw.morax.domain.db.salary.IncomeCompensation;
  5 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
  8 +import java.time.LocalDate;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * <p>
  13 + * 收入补偿 Mapper 接口
  14 + * </p>
  15 + *
  16 + * @author jiangchao
  17 + * @since 2022-11-09
  18 + */
  19 +public interface IncomeCompensationDao extends BaseMapper<IncomeCompensation> {
  20 +
  21 + /**
  22 + * 获取重复配置
  23 + *
  24 + * @param postId
  25 + * @param shopIds
  26 + * @return
  27 + */
  28 + List<IncomeCompensation> getRepeatConfigs(@Param("postId") Long postId,
  29 + @Param("shopIds") List<Long> shopIds,
  30 + @Param("approveStatus") Integer approveStatus);
  31 +
  32 +}
... ...
fw-morax-dao/src/main/resources/mapper/salary/IncomeCompensationMapper.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.salary.IncomeCompensationDao">
  4 +
  5 + <!-- 通用查询映射结果 -->
  6 + <resultMap id="BaseResultMap" type="cn.fw.morax.domain.db.salary.IncomeCompensation">
  7 + <result column="id" property="id"/>
  8 + <result column="post_id" property="postId"/>
  9 + <result column="post_name" property="postName"/>
  10 + <result column="shop_ids" property="shopIds"/>
  11 + <result column="shop_names" property="shopNames"/>
  12 + <result column="months" property="months"/>
  13 + <result column="money" property="money"/>
  14 + <result column="max_money" property="maxMoney"/>
  15 + <result column="status" property="status"/>
  16 + <result column="group_id" property="groupId"/>
  17 + <result column="yn" property="yn"/>
  18 + <result column="create_by" property="createBy"/>
  19 + <result column="create_time" property="createTime"/>
  20 + <result column="update_by" property="updateBy"/>
  21 + <result column="update_time" property="updateTime"/>
  22 + </resultMap>
  23 +
  24 + <sql id="all_columns">
  25 + id, post_id, post_name, shop_ids, shop_names, months, money, max_money,
  26 + attachment, status, project_num, group_id, yn,create_time,update_time
  27 + </sql>
  28 +
  29 + <select id="getRepeatConfigs" resultMap="BaseResultMap">
  30 + select
  31 + <include refid="all_columns"/>
  32 + from income_compensation
  33 + where yn = 1
  34 + AND post_id = #{postId}
  35 + AND
  36 + <foreach collection="shopIds" item="shopId" separator=" OR " open="(" close=")">
  37 + FIND_IN_SET(#{shopId}, shop_ids)
  38 + </foreach>
  39 + AND status = #{approveStatus}
  40 + </select>
  41 +
  42 +</mapper>
0 43 \ No newline at end of file
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/salary/IncomeCompensation.java 0 → 100644
  1 +package cn.fw.morax.domain.db.salary;
  2 +
  3 +import cn.fw.common.data.entity.BaseAuditableEntity;
  4 +import cn.fw.common.data.entity.BaseAuditableTimeEntity;
  5 +import cn.fw.common.data.mybatis.handler.LongListTypeHandler;
  6 +import cn.fw.common.data.mybatis.handler.StringListTypeHandler;
  7 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  8 +import com.baomidou.mybatisplus.annotation.TableField;
  9 +import lombok.Data;
  10 +import lombok.EqualsAndHashCode;
  11 +import lombok.experimental.Accessors;
  12 +
  13 +import java.io.Serializable;
  14 +import java.math.BigDecimal;
  15 +import java.time.LocalDateTime;
  16 +import java.util.List;
  17 +
  18 +/**
  19 + * <p>
  20 + * 收入补偿
  21 + * </p>
  22 + *
  23 + * @author jiangchao
  24 + * @since 2022-11-09
  25 + */
  26 +@Data
  27 +@EqualsAndHashCode(callSuper = false)
  28 +@Accessors(chain = true)
  29 +public class IncomeCompensation extends BaseAuditableEntity<IncomeCompensation, Long> {
  30 +
  31 + /**
  32 + * 岗位id
  33 + */
  34 + private Long postId;
  35 +
  36 + /**
  37 + * 岗位名称
  38 + */
  39 + private String postName;
  40 +
  41 + /**
  42 + * 适用门店ids
  43 + */
  44 + @TableField(typeHandler = LongListTypeHandler.class)
  45 + private List<Long> shopIds;
  46 +
  47 + /**
  48 + * 适用门店名称
  49 + */
  50 + @TableField(typeHandler = StringListTypeHandler.class)
  51 + private List<String> shopNames;
  52 +
  53 + /**
  54 + * 多个生效月份
  55 + */
  56 + @TableField(typeHandler = StringListTypeHandler.class)
  57 + private List<String> months;
  58 +
  59 + /**
  60 + * 单人补偿金额
  61 + */
  62 + private BigDecimal money;
  63 +
  64 + /**
  65 + * 单人最高补偿金额
  66 + */
  67 + private BigDecimal maxMoney;
  68 +
  69 + /**
  70 + * 状态;1:审批中 3:生效中 4:已失效
  71 + */
  72 + private SettingStatusEnum status;
  73 +
  74 + /**
  75 + * 集团id
  76 + */
  77 + private Long groupId;
  78 + /**
  79 + * 逻辑删除
  80 + */
  81 + private Boolean yn;
  82 +}
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/dto/IncomeCompensationDTO.java 0 → 100644
  1 +package cn.fw.morax.domain.dto;
  2 +
  3 +import cn.fw.common.data.mybatis.handler.LongListTypeHandler;
  4 +import cn.fw.common.data.mybatis.handler.StringListTypeHandler;
  5 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +import lombok.experimental.Accessors;
  10 +
  11 +import javax.validation.constraints.NotNull;
  12 +import java.math.BigDecimal;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * <p>
  17 + * 收入补偿
  18 + * </p>
  19 + *
  20 + * @author jiangchao
  21 + * @since 2022-11-09
  22 + */
  23 +@Data
  24 +@EqualsAndHashCode(callSuper = false)
  25 +@Accessors(chain = true)
  26 +public class IncomeCompensationDTO {
  27 +
  28 + /**
  29 + * 岗位id
  30 + */
  31 + @NotNull(message = "岗位id不能为空")
  32 + private Long postId;
  33 +
  34 + /**
  35 + * 岗位名称
  36 + */
  37 + private String postName;
  38 +
  39 + /**
  40 + * 适用门店ids
  41 + */
  42 + @TableField(typeHandler = LongListTypeHandler.class)
  43 + private List<Long> shopIds;
  44 +
  45 + /**
  46 + * 适用门店名称
  47 + */
  48 + @TableField(typeHandler = StringListTypeHandler.class)
  49 + private List<String> shopNames;
  50 +
  51 + /**
  52 + * 多个生效月份
  53 + */
  54 + @TableField(typeHandler = StringListTypeHandler.class)
  55 + private List<String> months;
  56 +
  57 + /**
  58 + * 单人补偿金额
  59 + */
  60 + private BigDecimal money;
  61 +
  62 + /**
  63 + * 单人最高补偿金额
  64 + */
  65 + private BigDecimal maxMoney;
  66 +
  67 + /**
  68 + * 状态;1:审批中 3:生效中 4:已失效
  69 + */
  70 + private SettingStatusEnum status;
  71 +
  72 +}
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/dto/query/IncomeCompensationQueryDTO.java 0 → 100644
  1 +package cn.fw.morax.domain.dto.query;
  2 +
  3 +import cn.fw.common.page.BasePageQuery;
  4 +import cn.fw.common.validator.EnumValue;
  5 +import cn.fw.common.web.annotation.LoginContextField;
  6 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  7 +import lombok.Data;
  8 +
  9 +@Data
  10 +public class IncomeCompensationQueryDTO extends BasePageQuery {
  11 +
  12 + /**
  13 + * 状态;1:审批中 2:待生效 3:生效中 4:已失效
  14 + */
  15 + @EnumValue(enumClass = SettingStatusEnum.class, valueMethod = "getValue", message = "薪酬状态枚举值不正确")
  16 + private Integer status;
  17 +
  18 + /**
  19 + * 岗位id
  20 + */
  21 + private Long postId;
  22 +
  23 + /**
  24 + * 集团id
  25 + */
  26 + @LoginContextField(LoginContextField.Name.GROUP_ID)
  27 + private Long groupId;
  28 +
  29 +}
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/enums/ApprovalTypeEnum.java
... ... @@ -13,11 +13,12 @@ import lombok.Getter;
13 13 */
14 14 public enum ApprovalTypeEnum implements IEnum<Integer> {
15 15 /**
16   - * 审批业务类型;1:绩效配置 2:薪酬配置 3:绩效星级申诉
  16 + * 审批业务类型;1:绩效配置 2:薪酬配置 3:绩效星级申诉 4:岗位最低收入补偿
17 17 */
18 18 KPI(1, "绩效配置"),
19 19 SALARY(2, "薪酬配置"),
20 20 COMPLAIN(3, "绩效星级申诉"),
  21 + INCOME_COMPENSATION(4, "岗位最低收入补偿"),
21 22 ;
22 23  
23 24 /**
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/salary/IncomeCompensationVO.java 0 → 100644
  1 +package cn.fw.morax.domain.vo.salary;
  2 +
  3 +import cn.fw.common.data.mybatis.handler.LongListTypeHandler;
  4 +import cn.fw.common.data.mybatis.handler.StringListTypeHandler;
  5 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +import lombok.experimental.Accessors;
  10 +
  11 +import java.math.BigDecimal;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * <p>
  16 + * 收入补偿
  17 + * </p>
  18 + *
  19 + * @author jiangchao
  20 + * @since 2022-11-09
  21 + */
  22 +@Data
  23 +@EqualsAndHashCode(callSuper = false)
  24 +@Accessors(chain = true)
  25 +public class IncomeCompensationVO {
  26 +
  27 + /**
  28 + * 岗位id
  29 + */
  30 + private Long postId;
  31 +
  32 + /**
  33 + * 岗位名称
  34 + */
  35 + private String postName;
  36 +
  37 + /**
  38 + * 适用门店ids
  39 + */
  40 + private List<Long> shopIds;
  41 +
  42 + /**
  43 + * 适用门店名称
  44 + */
  45 + private List<String> shopNames;
  46 +
  47 + /**
  48 + * 多个生效月份
  49 + */
  50 + private List<String> months;
  51 +
  52 + /**
  53 + * 单人补偿金额
  54 + */
  55 + private BigDecimal money;
  56 +
  57 + /**
  58 + * 单人最高补偿金额
  59 + */
  60 + private BigDecimal maxMoney;
  61 +
  62 + /**
  63 + * 状态;1:审批中 3:生效中 4:已失效
  64 + */
  65 + private SettingStatusEnum status;
  66 +
  67 + /**
  68 + * 集团id
  69 + */
  70 + private Long groupId;
  71 + /**
  72 + * 逻辑删除
  73 + */
  74 + private Boolean yn;
  75 +}
... ...
fw-morax-server/src/main/java/cn/fw/morax/server/consumer/FlowConsumer.java
... ... @@ -7,6 +7,7 @@ import cn.fw.morax.domain.db.ApprovalRecord;
7 7 import cn.fw.morax.service.biz.ApprovalBizService;
8 8 import cn.fw.morax.service.biz.kpi.KpiGroupBizService;
9 9 import cn.fw.morax.service.biz.kpi.KpiStarSpecialRuleBizService;
  10 +import cn.fw.morax.service.biz.salary.IncomeCompensationBizService;
10 11 import cn.fw.morax.service.biz.salary.SalaryGroupBizService;
11 12 import com.alibaba.fastjson.JSONObject;
12 13 import lombok.RequiredArgsConstructor;
... ... @@ -29,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
29 30 public class FlowConsumer implements RocketMQListener<ApprovalResult> {
30 31  
31 32 private final KpiStarSpecialRuleBizService kpiStarSpecialRuleBizService;
  33 + private final IncomeCompensationBizService incomeCompensationBizService;
32 34 private final SalaryGroupBizService salaryGroupBizService;
33 35 private final KpiGroupBizService kpiGroupBizService;
34 36 private final ApprovalBizService approvalBizService;
... ... @@ -69,6 +71,10 @@ public class FlowConsumer implements RocketMQListener&lt;ApprovalResult&gt; {
69 71 kpiStarSpecialRuleBizService.approvalKpiStarAdjustment(approvalRecord, result);
70 72 break;
71 73 }
  74 + case INCOME_COMPENSATION: {
  75 + incomeCompensationBizService.approvalCompensationConfig(approvalRecord, result);
  76 + break;
  77 + }
72 78 }
73 79 }
74 80  
... ...
fw-morax-server/src/main/java/cn/fw/morax/server/controller/erp/IncomeCompensationController.java 0 → 100644
  1 +package cn.fw.morax.server.controller.erp;
  2 +
  3 +
  4 +import cn.fw.common.page.AppPage;
  5 +import cn.fw.common.web.annotation.ControllerMethod;
  6 +import cn.fw.common.web.auth.LoginAuthBean;
  7 +import cn.fw.common.web.auth.annotation.CurrentUser;
  8 +import cn.fw.data.base.domain.common.Message;
  9 +import cn.fw.morax.domain.dto.IncomeCompensationDTO;
  10 +import cn.fw.morax.domain.dto.query.IncomeCompensationQueryDTO;
  11 +import cn.fw.morax.domain.dto.query.KpiGroupQueryDTO;
  12 +import cn.fw.morax.domain.vo.kpi.KpiGroupIndicatorVO;
  13 +import cn.fw.morax.domain.vo.kpi.KpiGroupVO;
  14 +import cn.fw.morax.domain.vo.salary.IncomeCompensationVO;
  15 +import cn.fw.morax.service.biz.kpi.KpiGroupIndicatorBizService;
  16 +import cn.fw.morax.service.biz.salary.IncomeCompensationBizService;
  17 +import cn.fw.morax.service.data.salary.IncomeCompensationService;
  18 +import cn.fw.security.auth.client.annotation.Authorization;
  19 +import cn.fw.security.auth.client.annotation.IgnoreAuth;
  20 +import cn.fw.security.auth.client.enums.AuthType;
  21 +import lombok.RequiredArgsConstructor;
  22 +import lombok.extern.slf4j.Slf4j;
  23 +import org.springframework.validation.annotation.Validated;
  24 +import org.springframework.web.bind.annotation.*;
  25 +
  26 +import javax.validation.constraints.NotNull;
  27 +
  28 +import static cn.fw.common.web.util.ResultBuilder.success;
  29 +
  30 +/**
  31 + * <p>
  32 + * 收入补偿 前端控制器
  33 + * </p>
  34 + *
  35 + * @author jiangchao
  36 + * @since 2022-11-09
  37 + */
  38 +@Slf4j
  39 +@RequiredArgsConstructor
  40 +@Authorization(AuthType.ERP)
  41 +@Validated
  42 +@IgnoreAuth
  43 +@RestController
  44 +@RequestMapping("/erp/salary")
  45 +public class IncomeCompensationController {
  46 +
  47 + private final IncomeCompensationBizService incomeCompensationBizService;
  48 + private final IncomeCompensationService incomeCompensationService;
  49 +
  50 + /**
  51 + * 岗位最低收入补偿
  52 + *
  53 + * @param dto
  54 + * @return
  55 + */
  56 + @GetMapping("/income-compensation/page")
  57 + @ControllerMethod("岗位最低收入补偿列表")
  58 + public Message<AppPage<IncomeCompensationVO>> incomeCompensationPage(@Validated IncomeCompensationQueryDTO dto) {
  59 + return success(incomeCompensationBizService.incomeCompensationPage(dto));
  60 + }
  61 +
  62 +
  63 + /**
  64 + * 岗位最低收入补偿详情
  65 + *
  66 + * @return
  67 + */
  68 + @GetMapping("/income-compensation")
  69 + @ControllerMethod("绩效组详情")
  70 + public Message<IncomeCompensationVO> incomeCompensationDetail(@NotNull(message = "岗位最低收入补偿id不能为空") Long id) {
  71 + return success(incomeCompensationBizService.incomeCompensationDetail(id));
  72 + }
  73 +
  74 + /**
  75 + * 保存岗位最低收入补偿
  76 + *
  77 + * @param dto 岗位最低收入补偿
  78 + * @return
  79 + */
  80 + @PostMapping("/income-compensation")
  81 + @ControllerMethod("绩效组详情")
  82 + public Message<IncomeCompensationVO> saveIncomeCompensation(@Validated @RequestBody IncomeCompensationDTO dto,
  83 + @CurrentUser LoginAuthBean user) {
  84 + return success(incomeCompensationBizService.saveIncomeCompensation(dto, user));
  85 + }
  86 +
  87 +
  88 +}
... ...
fw-morax-server/src/main/resources/application-dev.yml
... ... @@ -27,4 +27,5 @@ p6spy-db:
27 27 flow:
28 28 kpiGroupConfig: "P8U7YTGC95" #绩效组修改审批
29 29 salaryGroupConfig: "W7KM0T97UT" #薪酬组修改审批
30   - kpiStarAdjustment: "Y31C4OZ960" #绩效星级特殊调整
31 30 \ No newline at end of file
  31 + kpiStarAdjustment: "Y31C4OZ960" #绩效星级特殊调整
  32 + incomeCompensationConfig: "Y31C4OZ960" #岗位最低收入补贴
32 33 \ No newline at end of file
... ...
fw-morax-server/src/main/resources/application-gray.yml
... ... @@ -46,6 +46,7 @@ flow:
46 46 kpiGroupConfig: "46T0P7JX58" #绩效组修改审批
47 47 salaryGroupConfig: "06ZTQ93Y4V" #薪酬组修改审批
48 48 kpiStarAdjustment: "9DNS246M0G" #绩效星级特殊调整
  49 + incomeCompensationConfig: "Y31C4OZ960" #岗位最低收入补贴
49 50  
50 51 todo:
51 52 person-confirm: 'W2DRPm21AQ'
... ...
fw-morax-server/src/main/resources/application-prd.yml
... ... @@ -46,6 +46,7 @@ flow:
46 46 kpiGroupConfig: "46T0P7JX58" #绩效组修改审批
47 47 salaryGroupConfig: "06ZTQ93Y4V" #薪酬组修改审批
48 48 kpiStarAdjustment: "9DNS246M0G" #绩效星级特殊调整
  49 + incomeCompensationConfig: "Y31C4OZ960" #岗位最低收入补贴
49 50  
50 51 todo:
51 52 person-confirm: 'W2DRPm21AQ'
... ...
fw-morax-server/src/main/resources/application-test.yml
... ... @@ -56,6 +56,7 @@ flow:
56 56 kpiGroupConfig: "P8U7YTGC95" #绩效组修改审批
57 57 salaryGroupConfig: "W7KM0T97UT" #薪酬组修改审批
58 58 kpiStarAdjustment: "Y31C4OZ960" #绩效星级特殊调整
  59 + incomeCompensationConfig: "Y31C4OZ960" #岗位最低收入补贴
59 60  
60 61 todo:
61 62 person-confirm: 'wqDmVvAQ6b'
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/salary/IncomeCompensationBizService.java 0 → 100644
  1 +package cn.fw.morax.service.biz.salary;
  2 +
  3 +import cn.fw.approval.sdk.param.InitiateApprovalParam;
  4 +import cn.fw.common.data.mybatis.pagination.PageData;
  5 +import cn.fw.common.exception.BusinessException;
  6 +import cn.fw.common.page.AppPage;
  7 +import cn.fw.common.web.auth.LoginAuthBean;
  8 +import cn.fw.morax.common.config.FlowVal;
  9 +import cn.fw.morax.common.pojo.event.ApprovalResultEvent;
  10 +import cn.fw.morax.common.utils.PublicUtil;
  11 +import cn.fw.morax.domain.db.ApprovalRecord;
  12 +import cn.fw.morax.domain.db.salary.IncomeCompensation;
  13 +import cn.fw.morax.domain.dto.IncomeCompensationDTO;
  14 +import cn.fw.morax.domain.dto.query.IncomeCompensationQueryDTO;
  15 +import cn.fw.morax.domain.enums.ApprovalStatusEnum;
  16 +import cn.fw.morax.domain.enums.ApprovalTypeEnum;
  17 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  18 +import cn.fw.morax.domain.vo.salary.IncomeCompensationVO;
  19 +import cn.fw.morax.rpc.approval.FlowApproveRpc;
  20 +import cn.fw.morax.rpc.approval.dto.FlowDto;
  21 +import cn.fw.morax.service.biz.kpi.KpiGroupUserBizService;
  22 +import cn.fw.morax.service.data.ApprovalRecordService;
  23 +import cn.fw.morax.service.data.salary.IncomeCompensationService;
  24 +import com.alibaba.fastjson.JSON;
  25 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  26 +import com.google.common.collect.Lists;
  27 +import lombok.RequiredArgsConstructor;
  28 +import lombok.extern.slf4j.Slf4j;
  29 +import org.springframework.stereotype.Service;
  30 +import org.springframework.transaction.annotation.Transactional;
  31 +
  32 +import java.time.LocalDate;
  33 +import java.time.LocalDateTime;
  34 +import java.time.format.DateTimeFormatter;
  35 +import java.util.*;
  36 +import java.util.stream.Collectors;
  37 +
  38 +@Service
  39 +@Slf4j
  40 +@RequiredArgsConstructor
  41 +public class IncomeCompensationBizService {
  42 +
  43 + private final IncomeCompensationService incomeCompensationService;
  44 + private final ApprovalRecordService approvalRecordService;
  45 + private final KpiGroupUserBizService kpiGroupUserBizService;
  46 + private final FlowApproveRpc flowApproveRpc;
  47 + private final FlowVal flowVal;
  48 +
  49 + /**
  50 + * 分页查询
  51 + * @param dto
  52 + * @return
  53 + */
  54 + public AppPage<IncomeCompensationVO> incomeCompensationPage(IncomeCompensationQueryDTO dto) {
  55 + PageData<IncomeCompensation> pageData = incomeCompensationService.page(new PageData<>(dto.getCurrent(), dto.getPageSize()),
  56 + Wrappers.<IncomeCompensation>lambdaQuery()
  57 + .eq(IncomeCompensation::getGroupId, dto.getGroupId())
  58 + .eq(PublicUtil.isNotEmpty(dto.getPostId()), IncomeCompensation::getPostId, dto.getPostId())
  59 + .eq(PublicUtil.isNotEmpty(dto.getStatus()), IncomeCompensation::getStatus, dto.getStatus())
  60 + .eq(IncomeCompensation::getYn, Boolean.TRUE)
  61 + .last("ORDER BY FIELD(`status`,3,1,2,4)")
  62 + );
  63 + return PublicUtil.toPage(pageData, incomeCompensation -> {
  64 + IncomeCompensationVO incomeCompensationVO = PublicUtil.copy(incomeCompensation, IncomeCompensationVO.class);
  65 + return incomeCompensationVO;
  66 + });
  67 + }
  68 +
  69 + /**
  70 + * 岗位最低收入补偿详情
  71 + *
  72 + * @param id
  73 + * @return
  74 + */
  75 + public IncomeCompensationVO incomeCompensationDetail(Long id) {
  76 + IncomeCompensation incomeCompensation = incomeCompensationService.getById(id);
  77 + return PublicUtil.copy(incomeCompensation, IncomeCompensationVO.class);
  78 + }
  79 +
  80 + /**
  81 + * 保存
  82 + *
  83 + * @param dto
  84 + * @param user
  85 + * @return
  86 + */
  87 + @Transactional(rollbackFor = Exception.class)
  88 + public IncomeCompensationVO saveIncomeCompensation(IncomeCompensationDTO dto, LoginAuthBean user) {
  89 + checkIncomeCompensation(dto);
  90 + IncomeCompensation incomeCompensation = convertDB(dto, user);
  91 + incomeCompensationService.save(incomeCompensation);
  92 +
  93 + applyApproveCompensation(incomeCompensation, user);
  94 + return PublicUtil.copy(incomeCompensation, IncomeCompensationVO.class);
  95 + }
  96 +
  97 + /**
  98 + * 提交审批
  99 + *
  100 + * @param compensation
  101 + * @param user
  102 + */
  103 + @Transactional(rollbackFor = Exception.class)
  104 + public void applyApproveCompensation(IncomeCompensation compensation, LoginAuthBean user){
  105 + Date expTime = PublicUtil.getExpTimeOfMonth(LocalDate.now());
  106 + Integer staffNum = kpiGroupUserBizService.queryShopPostCurStaffNum(compensation.getPostId(), compensation.getShopIds());
  107 + //提交审批
  108 + List<InitiateApprovalParam.Condition> conditions = Lists.newArrayList();
  109 + InitiateApprovalParam.Condition postCondition = new InitiateApprovalParam.Condition();
  110 + postCondition.setParamName("postId");
  111 + postCondition.setValue(compensation.getPostId().toString());
  112 + InitiateApprovalParam.Condition shopCondition = new InitiateApprovalParam.Condition();
  113 + shopCondition.setParamName("shopId");
  114 + List<String> shopIdsStr = compensation.getShopIds().stream().map(s -> s.toString()).collect(Collectors.toList());
  115 + shopCondition.setValue(String.join(",", shopIdsStr));
  116 + conditions.add(postCondition);
  117 + conditions.add(shopCondition);
  118 + Map extDataMap = new HashMap<String, Object>() {{
  119 + put("id", compensation.getId().toString());
  120 + }};
  121 + FlowDto flowDto = FlowDto.builder()
  122 + .groupId(compensation.getGroupId())
  123 + .approvalNo(flowVal.getKpiGroupConfig())
  124 + .briefContent(Lists.newArrayList(
  125 + "申请人:" + user.getUserName(),
  126 + "岗位:" + compensation.getPostName(),
  127 + "适用门店:" + compensation.getShopIds().size() + "个",
  128 + "适用人员:" + staffNum + "人",
  129 + "补偿月份:" + String.join(",", compensation.getMonths()),
  130 + "补偿金额:" + compensation.getMoney() + "元",
  131 + "申请时间:" + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format(LocalDateTime.now())
  132 + ))
  133 + .initiatorId(user.getUserId())
  134 + .expTime(expTime)
  135 + .shopIds(compensation.getShopIds())
  136 + .conditions(conditions)
  137 + .extData(extDataMap)
  138 + .build();
  139 + String approvalNo = flowApproveRpc.initiate(flowDto);
  140 + ApprovalRecord approvalRecord = ApprovalRecord.builder()
  141 + .approvalNo(approvalNo)
  142 + .approvalStatus(ApprovalStatusEnum.IN_APPROVAL)
  143 + .approvalType(ApprovalTypeEnum.INCOME_COMPENSATION)
  144 + .dataId(compensation.getId())
  145 + .groupId(compensation.getGroupId())
  146 + .build();
  147 + approvalRecordService.save(approvalRecord);
  148 + }
  149 +
  150 +
  151 + /**
  152 + * 检查绩效组配置状态
  153 + *
  154 + * @param dto
  155 + */
  156 + public void checkIncomeCompensation(IncomeCompensationDTO dto) {
  157 + Long postId = dto.getPostId();
  158 + List<Long> shopIds = dto.getShopIds();
  159 + List<IncomeCompensation> approves = incomeCompensationService.getRepeatConfigs(postId, shopIds, SettingStatusEnum.APPROVING);
  160 + if (PublicUtil.isNotEmpty(approves)) {
  161 + IncomeCompensation incomeCompensation = approves.get(0);
  162 + List<String> shopNames = new ArrayList<>(incomeCompensation.getShopNames());
  163 + shopNames.retainAll(dto.getShopNames());
  164 + throw new BusinessException("绩效组门店【" + String.join(",", shopNames) + "】存在" +
  165 + incomeCompensation.getStatus().getName() + "配置");
  166 + }
  167 +
  168 + }
  169 +
  170 + /**
  171 + * 转换对象
  172 + *
  173 + * @param dto
  174 + * @param user
  175 + * @return
  176 + */
  177 + public IncomeCompensation convertDB(IncomeCompensationDTO dto, LoginAuthBean user) {
  178 + IncomeCompensation incomeCompensation = new IncomeCompensation();
  179 + incomeCompensation.setPostId(dto.getPostId());
  180 + incomeCompensation.setPostName(dto.getPostName());
  181 + incomeCompensation.setShopIds(dto.getShopIds());
  182 + incomeCompensation.setShopNames(dto.getShopNames());
  183 + incomeCompensation.setMonths(dto.getMonths());
  184 + incomeCompensation.setMoney(dto.getMoney());
  185 + incomeCompensation.setMaxMoney(dto.getMaxMoney());
  186 + incomeCompensation.setStatus(dto.getStatus());
  187 + incomeCompensation.setGroupId(user.getGroupId());
  188 + incomeCompensation.setYn(Boolean.TRUE);
  189 + return incomeCompensation;
  190 + }
  191 +
  192 + /**
  193 + * 岗位最低收入补偿
  194 + *
  195 + * @param approvalRecord
  196 + * @param resultEvent
  197 + */
  198 + public void approvalCompensationConfig(ApprovalRecord approvalRecord, ApprovalResultEvent resultEvent) {
  199 + log.info("收到岗位最低收入补偿审批信息:{}", JSON.toJSONString(resultEvent));
  200 + Boolean agree = resultEvent.getAgree();
  201 + Long compensationId = approvalRecord.getDataId();
  202 + incomeCompensationService.update(Wrappers.<IncomeCompensation>lambdaUpdate()
  203 + .set(IncomeCompensation::getStatus, (agree) ? SettingStatusEnum.EFFECTIVE : SettingStatusEnum.INEFFECTIVE)
  204 + .eq(IncomeCompensation::getId, compensationId)
  205 + );
  206 + if (!resultEvent.getAgree()) {
  207 + return;
  208 + }
  209 + IncomeCompensation compensation = incomeCompensationService.getById(approvalRecord.getDataId());
  210 + List<IncomeCompensation> effects = incomeCompensationService.getRepeatConfigs(compensation.getPostId(),
  211 + compensation.getShopIds(), SettingStatusEnum.EFFECTIVE);
  212 + List<Long> inEffectIds = effects.stream().filter(effect -> (! compensationId.equals(effect.getId())))
  213 + .map(IncomeCompensation::getId).collect(Collectors.toList());
  214 + if (PublicUtil.isEmpty(inEffectIds)) {
  215 + return;
  216 + }
  217 + incomeCompensationService.update(Wrappers.<IncomeCompensation>lambdaUpdate()
  218 + .set(IncomeCompensation::getStatus, SettingStatusEnum.INEFFECTIVE)
  219 + .set(IncomeCompensation::getUpdateTime, new Date())
  220 + .in(IncomeCompensation::getId, inEffectIds)
  221 + );
  222 + }
  223 +}
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/salary/IncomeCompensationService.java 0 → 100644
  1 +package cn.fw.morax.service.data.salary;
  2 +
  3 +
  4 +import cn.fw.morax.domain.db.salary.IncomeCompensation;
  5 +import cn.fw.morax.domain.dto.query.IncomeCompensationQueryDTO;
  6 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  7 +import com.baomidou.mybatisplus.extension.service.IService;
  8 +
  9 +import java.time.LocalDate;
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * <p>
  14 + * 收入补偿 服务类
  15 + * </p>
  16 + *
  17 + * @author jiangchao
  18 + * @since 2022-11-09
  19 + */
  20 +public interface IncomeCompensationService extends IService<IncomeCompensation> {
  21 +
  22 + /**
  23 + * 获取重复配置
  24 + *
  25 + * @param postId
  26 + * @param shopIds
  27 + * @return
  28 + */
  29 + List<IncomeCompensation> getRepeatConfigs(Long postId, List<Long> shopIds, SettingStatusEnum approveStatus);
  30 +
  31 +
  32 +}
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/salary/impl/IncomeCompensationServiceImpl.java 0 → 100644
  1 +package cn.fw.morax.service.data.salary.impl;
  2 +
  3 +import cn.fw.morax.dao.salary.IncomeCompensationDao;
  4 +import cn.fw.morax.domain.db.salary.IncomeCompensation;
  5 +import cn.fw.morax.domain.enums.SettingStatusEnum;
  6 +import cn.fw.morax.service.data.salary.IncomeCompensationService;
  7 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * <p>
  14 + * 收入补偿 服务实现类
  15 + * </p>
  16 + *
  17 + * @author jiangchao
  18 + * @since 2022-11-09
  19 + */
  20 +@Service
  21 +public class IncomeCompensationServiceImpl extends ServiceImpl<IncomeCompensationDao, IncomeCompensation> implements IncomeCompensationService {
  22 +
  23 + @Override
  24 + public List<IncomeCompensation> getRepeatConfigs(Long postId, List<Long> shopIds, SettingStatusEnum approveStatus) {
  25 + return this.getBaseMapper().getRepeatConfigs(postId, shopIds, approveStatus.getValue());
  26 + }
  27 +}
... ...