Commit a77b5913d76405080881fc7f03642d4d9fe03459

Authored by 张志伟
2 parents f72163d1 1d01b24e

Merge branch 'main-modify' into 'main'

薪酬返回开始、结束时间

薪酬返回开始、结束时间

See merge request !70
fw-morax-dao/src/main/java/cn/fw/morax/dao/salary/SalaryGroupUserDao.java
... ... @@ -40,4 +40,15 @@ public interface SalaryGroupUserDao extends BaseMapper<SalaryGroupUser> {
40 40 SalaryGroupUser getMonthLastData(@Param("sgc") String sgc,
41 41 @Param("userId") Long userId,
42 42 @Param("monthly") YearMonth monthly);
  43 +
  44 + /**
  45 + * 获取某月最近的绩效组人员数据
  46 + *
  47 + * @param sgc
  48 + * @param monthly
  49 + * @return
  50 + */
  51 + SalaryGroupUser getMonthFirstData(@Param("sgc") String sgc,
  52 + @Param("userId") Long userId,
  53 + @Param("monthly") YearMonth monthly);
43 54 }
... ...
fw-morax-dao/src/main/resources/mapper/salary/SalaryGroupUserMapper.xml
... ... @@ -35,4 +35,19 @@
35 35 LIMIT 1
36 36 </select>
37 37  
  38 + <select id="getMonthFirstData" resultType="cn.fw.morax.domain.db.salary.SalaryGroupUser">
  39 + SELECT
  40 + *
  41 + FROM
  42 + salary_group_user
  43 + WHERE
  44 + sgc = #{sgc}
  45 + AND user_id = #{userId}
  46 + AND DATE_FORMAT(data_date, '%Y-%m') = #{monthly}
  47 + AND yn = 1
  48 + ORDER BY
  49 + data_date ASC
  50 + LIMIT 1
  51 + </select>
  52 +
38 53 </mapper>
... ...
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/salary/StaffSalaryVO.java
... ... @@ -4,6 +4,8 @@ import cn.fw.morax.domain.enums.StarLevelEnum;
4 4 import lombok.Data;
5 5  
6 6 import java.math.BigDecimal;
  7 +import java.time.LocalDate;
  8 +import java.time.LocalDateTime;
7 9 import java.time.YearMonth;
8 10 import java.util.List;
9 11  
... ... @@ -53,6 +55,14 @@ public class StaffSalaryVO {
53 55 */
54 56 private String shopName;
55 57 /**
  58 + * 开始时间
  59 + */
  60 + private LocalDateTime startTime;
  61 + /**
  62 + * 开始时间
  63 + */
  64 + private LocalDateTime endTime;
  65 + /**
56 66 * 本月薪资(剩余应发)
57 67 */
58 68 private BigDecimal wages;
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/biz/salary/SalaryPoolBizService.java
... ... @@ -184,10 +184,11 @@ public class SalaryPoolBizService {
184 184 * @return 详情
185 185 */
186 186 private StaffSalaryVO getPoolDetail(SalaryPool pool) {
187   - LocalDate localDate = getPoolLastData(pool);
188   - List<SalaryPoolDetailVO> salaryDetailList = salaryPoolDetailService.queryByPoolId(pool.getId(), pool.getSalaryGroupId(), localDate);
189   - BV.isNotEmpty(salaryDetailList, () -> "该人员薪酬数据不存在");
190 187 StaffSalaryVO vo = this.convertToSalaryVO(pool);
  188 + buildPoolData(pool, vo);
  189 + LocalDate dataDate = LocalDate.from(vo.getEndTime());
  190 + List<SalaryPoolDetailVO> salaryDetailList = salaryPoolDetailService.queryByPoolId(pool.getId(), pool.getSalaryGroupId(), dataDate);
  191 + BV.isNotEmpty(salaryDetailList, () -> "该人员薪酬数据不存在");
191 192 Map<SalaryTypeEnum, List<SalaryPoolDetailVO>> salaryTypeMap = salaryDetailList.stream().collect(Collectors.groupingBy(SalaryPoolDetailVO::getType));
192 193 for (Map.Entry<SalaryTypeEnum, List<SalaryPoolDetailVO>> salaryDetail : salaryTypeMap.entrySet()) {
193 194 detailClassification(vo, salaryDetail.getKey(), salaryDetail.getValue());
... ... @@ -198,7 +199,28 @@ public class SalaryPoolBizService {
198 199 }
199 200  
200 201 /**
201   - * 获取绩效池详情最近日期
  202 + * 查询薪酬开始日期,结束日期
  203 + *
  204 + * @param salaryPool
  205 + * @return
  206 + */
  207 + public void buildPoolData(SalaryPool salaryPool, StaffSalaryVO vo) {
  208 + SalaryGroupUser salaryGroupUser = salaryGroupUserService.getMonthLastData(salaryPool.getSgc(),
  209 + salaryPool.getUserId(), salaryPool.getMonthly());
  210 + if (PublicUtil.isEmpty(salaryGroupUser)) {
  211 + log.error("员工薪酬池:{},不存在绩效组人员数据", JSON.toJSONString(salaryPool));
  212 + vo.setEndTime(PublicUtil.getYesterdayOrEndOfMonthDay(salaryPool.getMonthly()).atTime(23, 59, 59));
  213 + vo.setStartTime(salaryPool.getMonthly().atDay(1).atTime(00, 00, 00));
  214 + return;
  215 + }
  216 + vo.setEndTime(salaryGroupUser.getDataDate().atTime(23, 59, 59));
  217 + SalaryGroupUser firstSalaryGroupUser = salaryGroupUserService.getMonthFirstData(salaryPool.getSgc(),
  218 + salaryPool.getUserId(), salaryPool.getMonthly());
  219 + vo.setStartTime(firstSalaryGroupUser.getDataDate().atTime(00, 00, 00));
  220 + }
  221 +
  222 + /**
  223 + * 查询薪酬结束日期
202 224 *
203 225 * @param salaryPool
204 226 * @return
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/salary/SalaryGroupUserService.java
... ... @@ -32,4 +32,13 @@ public interface SalaryGroupUserService extends IService&lt;SalaryGroupUser&gt; {
32 32 * @return
33 33 */
34 34 SalaryGroupUser getMonthLastData(String sgc, Long userId, YearMonth monthly);
  35 +
  36 + /**
  37 + * 获取某月最早的薪酬组人员数据
  38 + *
  39 + * @param sgc
  40 + * @param monthly
  41 + * @return
  42 + */
  43 + SalaryGroupUser getMonthFirstData(String sgc, Long userId, YearMonth monthly);
35 44 }
... ...
fw-morax-service/src/main/java/cn/fw/morax/service/data/salary/impl/SalaryGroupUserServiceImpl.java
... ... @@ -28,4 +28,8 @@ public class SalaryGroupUserServiceImpl extends ServiceImpl&lt;SalaryGroupUserDao,
28 28 public SalaryGroupUser getMonthLastData(String sgc, Long userId, YearMonth monthly) {
29 29 return this.getBaseMapper().getMonthLastData(sgc, userId, monthly);
30 30 }
  31 + @Override
  32 + public SalaryGroupUser getMonthFirstData(String sgc, Long userId, YearMonth monthly) {
  33 + return this.getBaseMapper().getMonthFirstData(sgc, userId, monthly);
  34 + }
31 35 }
... ...