| | |
| | | } |
| | | |
| | | |
| | | |
| | | empBaseInfo.setDelFlag(2); |
| | | // 入职类型 |
| | | dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "lztype") && StrUtil.equals(j.getDicItemName(), list.get(31).toString())).findFirst().orElse(null); |
| | |
| | | if (null != dicItem) { |
| | | empBaseInfo.setArchivesStatus(dicItem.getDicItemCode()); |
| | | } |
| | | //身份证有效期 |
| | | // 身份证有效期 |
| | | empBaseInfo.setCertificateValidity(DateUtil.parse(list.get(33).toString())); |
| | | empBaseInfo.setEmpStatus("0"); |
| | | boolean saveResult = this.save(empBaseInfo); |
| | |
| | | if (count != null) { |
| | | stringObjectMap.put("insuranceCount", count); |
| | | } |
| | | //QueryRequest request |
| | | // QueryRequest request |
| | | return stringObjectMap; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void updateAnnualLeave(String userId) { |
| | | EmpBaseInfo empBaseInfo = this.getById(userId); |
| | | int holiday = calculateHoliday(empBaseInfo.getEntryDate()); |
| | | int holiday = calculateHoliday(empBaseInfo.getEntryDate(), empBaseInfo.getEmpStatus()); |
| | | empBaseInfo.setAnnualLeave(holiday); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | | .set(EmpBaseInfo::getAnnualLeave, holiday) |
| | |
| | | public void updateAnnualLeave() { |
| | | List<EmpBaseInfo> list = this.list(); |
| | | list.parallelStream().forEach(p -> { |
| | | int holiday = calculateHoliday(p.getEntryDate()); |
| | | int holiday = calculateHoliday(p.getEntryDate(), p.getEmpStatus()); |
| | | p.setAnnualLeave(holiday); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | | .set(EmpBaseInfo::getAnnualLeave, holiday) |
| | |
| | | public void updateEmpBaseKeyInfo() { |
| | | List<EmpBaseInfo> list = this.list(); |
| | | list.parallelStream().forEach(p -> { |
| | | int holiday = calculateHoliday(p.getEntryDate()); |
| | | int holiday = calculateHoliday(p.getEntryDate(), p.getEmpStatus()); |
| | | int age = calculateAge(p.getBirthdate()); |
| | | |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | |
| | | SortUtil.handlePageSort(request, page, "insuranceType", FebsConstant.ORDER_DESC, true); |
| | | |
| | | // 使用优化后的方法查询社保档位提醒员工 |
| | | List<EmpBaseInfo> alertList = findInsuranceAlertList(empBaseInfo,request); |
| | | List<EmpBaseInfo> alertList = findInsuranceAlertList(empBaseInfo, request); |
| | | // 手动分页 |
| | | int total = alertList.size(); |
| | | int start = (int) ((page.getCurrent() - 1) * page.getSize()); |
| | |
| | | |
| | | @Override |
| | | public Long countInsuranceAlert(EmpBaseInfo empBaseInfo, QueryRequest request) { |
| | | return (long) findInsuranceAlertList(empBaseInfo,request).size(); |
| | | return (long) findInsuranceAlertList(empBaseInfo, request).size(); |
| | | } |
| | | |
| | | /** |
| | | * 查询社保档位提醒员工列表 |
| | | * 保险类型:6-(非深户) 四险二档 7-(非深户) 四险一档 10-外参 13-临时工意外险 14-甲方购买 |
| | |
| | | |
| | | // 使用正向计算获取退休提醒列表 |
| | | List<EmpBaseInfo> alertList = findRetirementAlertList(empBaseInfo); |
| | | |
| | | |
| | | // 手动分页 |
| | | int total = alertList.size(); |
| | | int start = (int) ((page.getCurrent() - 1) * page.getSize()); |
| | | int end = Math.min(start + (int) page.getSize(), total); |
| | | |
| | | |
| | | List<EmpBaseInfo> pageList = start < total ? alertList.subList(start, end) : new ArrayList<>(); |
| | | |
| | | |
| | | // 设置字典名称 |
| | | List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class); |
| | | pageList.forEach(item -> { |
| | |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("未知")); |
| | | }); |
| | | |
| | | |
| | | // 构建分页结果 |
| | | Page<EmpBaseInfo> resultPage = new Page<>(page.getCurrent(), page.getSize(), total); |
| | | resultPage.setRecords(pageList); |
| | |
| | | /** |
| | | * 根据设置的参数计算员工的年假 |
| | | * |
| | | * @param date 入职日期 |
| | | * @param date 入职日期 |
| | | * @param empStatus 人员状态(0-正常 1-离职 2-退休)只计算在职的 |
| | | * @return 年假天数 |
| | | */ |
| | | private int calculateHoliday(Date date) { |
| | | int holiday = 0; |
| | | int joinYear = DateUtil.ageOfNow(date); |
| | | String configValue = redisService.get("annual_leave").toString(); |
| | | String[] values = StrUtil.split(configValue, "|"); |
| | | String[] condition = StrUtil.split(values[0], ","); |
| | | String[] days = StrUtil.split(values[1], ","); |
| | | if (condition.length == 2) { |
| | | int one = Integer.parseInt(condition[0]); |
| | | int two = Integer.parseInt(condition[1]); |
| | | if (joinYear >= one && joinYear < two) { |
| | | holiday = Integer.parseInt(days[0]); |
| | | } else if (joinYear >= two) { |
| | | holiday = Integer.parseInt(days[1]); |
| | | private int calculateHoliday(Date date, String empStatus) { |
| | | if (!empStatus.equals("0")) { |
| | | int holiday = 0; |
| | | int joinYear = DateUtil.ageOfNow(date); |
| | | String configValue = redisService.get("annual_leave").toString(); |
| | | String[] values = StrUtil.split(configValue, "|"); |
| | | String[] condition = StrUtil.split(values[0], ","); |
| | | String[] days = StrUtil.split(values[1], ","); |
| | | if (condition.length == 2) { |
| | | int one = Integer.parseInt(condition[0]); |
| | | int two = Integer.parseInt(condition[1]); |
| | | if (joinYear >= one && joinYear < two) { |
| | | holiday = Integer.parseInt(days[0]); |
| | | } else if (joinYear >= two) { |
| | | holiday = Integer.parseInt(days[1]); |
| | | } |
| | | } |
| | | return holiday; |
| | | } else { |
| | | return 0; |
| | | } |
| | | return holiday; |
| | | } |
| | | |
| | | private int calculateAge(Date date) { |
| | | return DateUtil.ageOfNow(date); |
| | | } |
| | | |
| | | private QueryWrapper<EmpBaseInfo> createInsuranceAlertQueryWrapper(EmpBaseInfo empBaseInfo) { |
| | | String[] alertInsuranceTypes = {"6", "7", "10", "13", "14"}; |
| | | |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("a.DelFlag", "0"); |
| | | queryWrapper.eq("a.empStatus", "0"); |
| | | queryWrapper.in("a.insuranceType", (Object[]) alertInsuranceTypes); |
| | | |
| | | int alertWomanAge = getRedisConfigWithDefault("insurance_alert_woman", 39); |
| | | int alertManAge = getRedisConfigWithDefault("insurance_alert_man", 48); |
| | | |
| | | queryWrapper.and(wrapper -> |
| | | wrapper.and(inner -> inner.eq("a.sex", "1").ge("a.age", alertManAge)) |
| | | .or(inner -> inner.eq("a.sex", "2").ge("a.age", alertWomanAge)) |
| | | ); |
| | | |
| | | |
| | | return queryWrapper; |
| | | } |
| | | |
| | | private void buildAgeCondition(QueryWrapper<EmpBaseInfo> wrapper, int manAge, int womanAge) { |
| | | wrapper.nested(inner -> inner |
| | | .gt("a.age", manAge).eq("a.sex", "1") |
| | | ).or().nested(inner -> inner |
| | | .gt("a.age", womanAge).eq("a.sex", "2") |
| | | ); |
| | | } |
| | | |
| | | private int getRedisConfigWithDefault(String key, int defaultValue) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 统计退休提醒数量(正向计算) |
| | | */ |
| | | public Long countRetirementAlert(EmpBaseInfo empBaseInfo) { |
| | | return (long) findRetirementAlertList(empBaseInfo).size(); |
| | | } |
| | | |
| | | /** |
| | | * 计算员工的实际退休时间(正向计算) |
| | | * 方案A:法定退休时间早于2025-01时,按法定年龄退休,不延迟 |
| | | */ |
| | |
| | | |
| | | // 法定退休时间晚于等于2025-01,计算延迟 |
| | | long monthsBetween = ChronoUnit.MONTHS.between(delayStart, legalRetirement); |
| | | long delayMonths = monthsBetween / delayDivisor; |
| | | long delayMonths = (monthsBetween / delayDivisor) + 1; |
| | | |
| | | return legalRetirement.plusMonths(delayMonths); |
| | | } |
| | | |
| | | /** |
| | | * 根据时间范围类型计算开始和结束日期 |
| | | * |
| | | * @param timeRange 0-当天 1-本周 2-本月 3-今年 |
| | | * @return 包含开始日期和结束日期的数组 [startDate, endDate) |
| | | */ |