| | |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceOvertime; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceOvertimeRepository; |
| | | import me.zhengjie.modules.system.domain.SysConfigProportion; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysConfigProportionRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.treatment.domain.UserInsurance; |
| | | import me.zhengjie.modules.treatment.domain.UserLevelWage; |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | |
| | |
| | | |
| | | private final UserInsuranceRepository userInsuranceRepository; |
| | | private final CmnInsuranceRepository cmnInsuranceRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final SysConfigProportionRepository sysConfigProportionRepository; |
| | | private final AttendanceOvertimeRepository attendanceOvertimeRepository; |
| | | |
| | | @Override |
| | | public Map<String, Object> queryAll(UserLevelWageQueryCriteria criteria, Pageable pageable) { |
| | |
| | | // 获取某年某月最后一天 |
| | | String yearMonth = targetYearMonth.substring(0,7); |
| | | // 根据用户ID、指定年月查询 |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findByUserIdAndYearMonth(criteria.getUserId(), yearMonth); |
| | | // UserLevelWage userLevelWage = userLevelWageRepository.findByUserIdAndYearMonth(criteria.getUserId(), yearMonth); |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findbyUserIdAndDate(criteria.getUserId(), yearMonth); |
| | | // 判断查询结果 |
| | | if (userLevelWage == null) { |
| | | // throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Double queryOverTimeAllowance(UserLevelWageQueryCriteria criteria) throws ParseException { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter); |
| | | // 获取月初日期 |
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1); |
| | | // 获取下月初日期 |
| | | LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1); |
| | | |
| | | // 查询指定员工的加班补助金额工资 |
| | | Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth); |
| | | |
| | | // 查询配置表 |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("加班补助金额"); |
| | | |
| | | // 出差补助金 |
| | | Double travelSubsidy = (overTimeSalary == null ? 0.0 : overTimeSalary) * sysConfigProportion.getProportion(); |
| | | |
| | | return travelSubsidy; |
| | | } |
| | | |
| | | @Override |
| | | public Double queryTravelAllowance(UserLevelWageQueryCriteria criteria) throws ParseException { |
| | | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter); |
| | | // 获取月初日期 |
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1); |
| | | // 获取下月初日期 |
| | | LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1); |
| | | |
| | | System.out.println("月初日期:" + firstDayOfMonth); |
| | | System.out.println("下月初日期:" + firstDayOfNextMonth); |
| | | |
| | | // 查询出差表的记录 |
| | | Integer bussSameMonthDays = attendanceBusinessTravelRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth); |
| | | // 查询配置表 |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额"); |
| | | |
| | | // 出差补助金 |
| | | Double travelSubsidy = (bussSameMonthDays == null ? 0 : bussSameMonthDays) * sysConfigProportion.getProportion(); |
| | | |
| | | return travelSubsidy; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public UserLevelWageDto findById(Long id) { |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findById(id).orElseGet(UserLevelWage::new); |