| | |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @author 赵士淞 |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-26 |
| | | **/ |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria){ |
| | | // 国际时间转中国时间 |
| | | String targetYearMonth = DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()); |
| | | // 获取某年某月最后一天 |
| | | String lastDayOfTargetYearMonth = DateUtil.getLastDayOfMonth(targetYearMonth); |
| | | // // 根据用户ID、指定年月查询 |
| | | // SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findTargetYearMonth(criteria.getUserId(), lastDayOfTargetYearMonth); |
| | | |
| | | // 根据用户ID、指定年月查询(新) |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findYearMonth(criteria.getUserId(), lastDayOfTargetYearMonth); |
| | | |
| | | // 判断查询结果 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.YEAR, 1); |
| | | calendar.set(Calendar.MONTH, Calendar.JANUARY); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 明年月初 |
| | | String nextYearMonth = sdf.format(calendar.getTime()); |
| | | // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期 |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7), nextYearMonth); |
| | | if (sysUserLevelOther == null) { |
| | | throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | | } |
| | | // 返回 |
| | | |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther); |
| | | } |
| | | |
| | |
| | | if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) { |
| | | throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!"); |
| | | } |
| | | // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | } |
| | | // 保存 |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources)); |
| | |
| | | |
| | | /** |
| | | * 查询旧用户级别其他 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |