| | |
| | | } |
| | | |
| | | |
| | | |
| | | 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-甲方购买 |
| | |
| | | private List<EmpBaseInfo> findInsuranceAlertList(EmpBaseInfo empBaseInfo, QueryRequest request) { |
| | | // 1. 计算时间范围 |
| | | LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange()); |
| | | LocalDate startDate = dateRange[0]; |
| | | LocalDate endDate = dateRange[1]; |
| | | |
| | | // 2. 获取提醒年龄配置 |
| | |
| | | } |
| | | |
| | | int alertAge = "1".equals(emp.getSex()) ? alertManAge : alertWomanAge; |
| | | int maxAge = "1".equals(emp.getSex()) ? 50 : 40; |
| | | LocalDate birthDate = emp.getBirthdate().toInstant() |
| | | .atZone(ZoneId.systemDefault()) |
| | | .toLocalDate(); |
| | | LocalDate alertDate = birthDate.plusYears(alertAge); |
| | | LocalDate maxDate = birthDate.plusYears(maxAge); |
| | | |
| | | return !alertDate.isAfter(endDate); |
| | | return !alertDate.isAfter(endDate) && endDate.isBefore(maxDate); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | |
| | | |
| | | // 使用正向计算获取退休提醒列表 |
| | | 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) { |
| | |
| | | |
| | | /** |
| | | * 根据时间范围类型计算开始和结束日期 |
| | | * |
| | | * @param timeRange 0-当天 1-本周 2-本月 3-今年 |
| | | * @return 包含开始日期和结束日期的数组 [startDate, endDate) |
| | | */ |