| | |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.service.TaskDaliyService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria; |
| | | import me.zhengjie.modules.treatment.domain.*; |
| | | import me.zhengjie.modules.treatment.repository.*; |
| | | import me.zhengjie.utils.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.cache.annotation.CacheConfig; |
| | |
| | | private final SysCompanyRepository sysCompanyRepository; |
| | | private final TaskDaliyService taskDaliyService; |
| | | private final DeptRepository deptRepository; |
| | | private final MeritLevelRepository meritLevelRepository; |
| | | private final CmnLevelRepository cmnLevelRepository; |
| | | private final MeritWageRepository meritWageRepository; |
| | | private final CmnLevelRankRepository cmnLevelRankRepository; |
| | | |
| | | private final MongoTemplate mongoTemplate; |
| | | private final UserLevelWageRepository userLevelWageRepository; |
| | | private final UserInsuranceRepository userInsuranceRepository; |
| | | |
| | | @Override |
| | | public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { |
| | |
| | | |
| | | @Override |
| | | @Cacheable(key = "'total'") |
| | | // @CacheEvict(value = "total", allEntries = true) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<UserDto> queryAll(UserQueryCriteria criteria) { |
| | | criteria.setEnabled(true); |
| | |
| | | userRepository.save(resources); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(resources.getId(), null, resources.getLevelId()); |
| | | // 判断用户级别变更(新) |
| | | checkUserLevelNew(resources.getId(), null, resources.getLevelId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | userRepository.save(user); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(user.getId(), tempOldLevelId, tempNewLevelId); |
| | | // 判断用户级别变更(新) |
| | | checkUserLevelNew(user.getId(), tempOldLevelId, tempNewLevelId); |
| | | // 清除缓存 |
| | | delCaches(user.getId(), user.getUsername()); |
| | | } |
| | |
| | | private void checkUserLevel(Long userId, Long oldLevelId, Long newLevelId) { |
| | | // 判断新旧用户级别ID是否相等 |
| | | if (oldLevelId == null) { |
| | | // 创建用户级别工资 |
| | | // 创建用户级别工资(旧) |
| | | createSysUserLevelWage(userId, newLevelId); |
| | | // 创建用户级别保险 |
| | | // 创建用户级别保险(旧) |
| | | createSysUserLevelInsurance(userId, newLevelId); |
| | | // 创建用户级别其他 |
| | | createSysUserLevelOther(userId, newLevelId); |
| | | |
| | | } else if (oldLevelId != newLevelId) { |
| | | // 旧用户级别工资 |
| | | SysUserLevelWage oldSysUserLevelWage = sysUserLevelWageRepository.findLastByUserId(userId); |
| | |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(oldSysUserLevelWage); |
| | | } |
| | | // 创建用户级别工资 |
| | | // 创建用户级别工资(旧) |
| | | createSysUserLevelWage(userId, newLevelId); |
| | | // 旧用户级别保险 |
| | | SysUserLevelInsurance oldSysUserLevelInsurance = sysUserLevelInsuranceRepository.findLastByUserId(userId); |
| | |
| | | // 保存 |
| | | sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance); |
| | | } |
| | | // 创建用户级别保险 |
| | | // 创建用户级别保险(旧) |
| | | createSysUserLevelInsurance(userId, newLevelId); |
| | | // 旧用户级别其他 |
| | | SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 判断用户级别变更 |
| | | * @param userId |
| | | * @param oldLevelId |
| | | * @param newLevelId |
| | | */ |
| | | private void checkUserLevelNew(Long userId, Long oldLevelId, Long newLevelId) { |
| | | |
| | | // 创建用户级别工资(新) |
| | | createNewSysUserLevelWage(userId, newLevelId); |
| | | // 创建用户级别保险 (新) |
| | | createNewSysUserLevelInsurance(userId, newLevelId); |
| | | |
| | | // 判断新旧用户级别ID是否相等 |
| | | if (oldLevelId == null) { |
| | | // 创建用户级别其他 |
| | | createSysUserLevelOther(userId, newLevelId); |
| | | } else if (oldLevelId != newLevelId) { |
| | | // // 旧用户级别其他 |
| | | // SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId); |
| | | // // 判断旧用户级别其他是否为空 |
| | | // if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) { |
| | | // // 旧日期字符串 |
| | | // String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0, 10); |
| | | // // 获取当前日期 |
| | | // Date nowDate = new Date(); |
| | | // // 创建Calendar实例 |
| | | // Calendar nowCalendar = Calendar.getInstance(); |
| | | // // 设置当前时间 |
| | | // nowCalendar.setTime(nowDate); |
| | | // // 新日期字符串 |
| | | // String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 10); |
| | | // // 判断新、旧日期字符串 |
| | | // if (oldDateString.equals(nowDateString)) { |
| | | // throw new BadRequestException("每天只能调整一次级别,请明日再试!"); |
| | | // } |
| | | // // 设置前一天时间 |
| | | // nowCalendar.add(Calendar.DATE, -1); |
| | | // // 旧用户级别保险 |
| | | // oldSysUserLevelOther.setEndDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | // } |
| | | // // 创建用户级别其他 |
| | | // createSysUserLevelOther(userId, newLevelId); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建用户级别工资 |
| | | * |
| | | * @param userId |
| | |
| | | sysUserLevelWageRepository.save(sysUserLevelWage); |
| | | } |
| | | |
| | | /** |
| | | * 创建用户界别工资(新) |
| | | * @param userId |
| | | * @param levelId |
| | | */ |
| | | private void createNewSysUserLevelWage(Long userId, Long levelId) { |
| | | // 级别 |
| | | SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new); |
| | | // 用户级别工资 |
| | | UserLevelWage userLevelWage = new UserLevelWage(); |
| | | userLevelWage.setUserId(userId); |
| | | userLevelWage.setLevel(levelId); |
| | | Date date = new Date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | userLevelWage.setYearMonth(sdf.format(date).substring(0,7)); |
| | | // 查询最小的等级 |
| | | MeritLevel meritLevel = meritLevelRepository.findMinMeritStandardByLevelId(levelId).get(0); |
| | | userLevelWage.setRank(meritLevel.getId()); |
| | | // 查询级别基本工资 |
| | | CmnLevel cmnLevel = cmnLevelRepository.findByJobId(sysLevel.getJobId()).get(0); |
| | | userLevelWage.setBasicWage(cmnLevel.getBasicWage()); |
| | | userLevelWage.setRankWage(cmnLevel.getRankWage()); |
| | | userLevelWage.setPerformanceWage(cmnLevel.getPerformanceWage()); |
| | | // 查询绩效系数 |
| | | CmnLevelRank cmnLevelRank = cmnLevelRankRepository.findbylevelSm(levelId).get(0); |
| | | userLevelWage.setPerformanceCoefficient(new BigDecimal(cmnLevelRank.getPerformanceCoefficient())); |
| | | // 保存 |
| | | userLevelWageRepository.save(userLevelWage); |
| | | } |
| | | |
| | | /** |
| | | * 创建用户级别保险 (新) |
| | | * @param userId |
| | | * @param levelId |
| | | */ |
| | | public void createNewSysUserLevelInsurance(Long userId, Long levelId) { |
| | | // 级别 |
| | | SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new); |
| | | // 用户级别工资 |
| | | UserInsurance userInsurance = new UserInsurance(); |
| | | userInsurance.setUserId(userId); |
| | | Date date = new Date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | userInsurance.setYearMonth(sdf.format(date).substring(0,7)); |
| | | userInsurance.setAccumulationFund(sysLevel.getAccumulationRadix()); |
| | | userInsurance.setAccumulationFundPersonal(sysLevel.getAccumulationPersonalProportion()); |
| | | userInsurance.setAccumulationFundCompany(sysLevel.getAccumulationCompanyProportion()); |
| | | userInsurance.setRetirementInsurance(sysLevel.getPensionRadix()); |
| | | userInsurance.setRetirementInsurancePersonal(sysLevel.getPensionPersonalProportion()); |
| | | userInsurance.setRetirementInsuranceCompany(sysLevel.getPensionCompanyProportion()); |
| | | userInsurance.setMedicalInsurance(sysLevel.getMedicalRadix()); |
| | | userInsurance.setMedicalInsurancePersonal(sysLevel.getMedicalPersonalProportion()); |
| | | userInsurance.setMedicalInsuranceCompany(sysLevel.getMedicalCompanyProportion()); |
| | | userInsurance.setUnemploymentInsurance(sysLevel.getUnemploymentRadix()); |
| | | userInsurance.setUnemploymentInsurancePersonal(sysLevel.getUnemploymentPersonalProportion()); |
| | | userInsurance.setUnemploymentInsuranceCompany(sysLevel.getUnemploymentCompanyProportion()); |
| | | userInsurance.setBirthInsurance(sysLevel.getMaternityRadix()); |
| | | userInsurance.setBirthInsurancePersonal(sysLevel.getMaternityPersonalProportion()); |
| | | userInsurance.setBirthInsuranceCompany(sysLevel.getMaternityCompanyProportion()); |
| | | userInsurance.setEmploymentInsurance(sysLevel.getIndustrialInjuryRadix()); |
| | | userInsurance.setEmploymentInsurancePersonal(sysLevel.getIndustrialInjuryPersonalProportion()); |
| | | userInsurance.setEmploymentInsuranceCompany(sysLevel.getIndustrialInjuryCompanyProportion()); |
| | | // 保存 |
| | | userInsuranceRepository.save(userInsurance); |
| | | } |
| | | |
| | | // 创建用户级别保险 |
| | | private void createSysUserLevelInsurance(Long userId, Long levelId) { |
| | | // 级别 |