yubo
2026-03-31 09c6b3b6fc4ee6b1bc9fa1a6d3da3044729fc95a
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
@@ -666,6 +666,8 @@
            if (null != dicItem) {
                empBaseInfo.setArchivesStatus(dicItem.getDicItemCode());
            }
            // 身份证有效期
            empBaseInfo.setCertificateValidity(DateUtil.parse(list.get(33).toString()));
            empBaseInfo.setEmpStatus("0");
            boolean saveResult = this.save(empBaseInfo);
            // 新入职员工需要增加一条入职记录
@@ -1076,7 +1078,7 @@
        if (count != null) {
            stringObjectMap.put("insuranceCount", count);
        }
        //QueryRequest request
        // QueryRequest request
        return stringObjectMap;
    }
@@ -1485,7 +1487,7 @@
    @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)
@@ -1496,7 +1498,7 @@
    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)
@@ -1508,7 +1510,7 @@
    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>()
@@ -1525,7 +1527,7 @@
        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());
@@ -1569,8 +1571,9 @@
    @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-甲方购买
@@ -1582,7 +1585,6 @@
    private List<EmpBaseInfo> findInsuranceAlertList(EmpBaseInfo empBaseInfo, QueryRequest request) {
        // 1. 计算时间范围
        LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange());
        LocalDate startDate = dateRange[0];
        LocalDate endDate = dateRange[1];
        // 2. 获取提醒年龄配置
@@ -1621,12 +1623,14 @@
                    }
                    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());
    }
@@ -1639,14 +1643,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 -> {
@@ -1656,7 +1660,7 @@
                    .map(DicItem::getDicItemName)
                    .orElse("未知"));
        });
        // 构建分页结果
        Page<EmpBaseInfo> resultPage = new Page<>(page.getCurrent(), page.getSize(), total);
        resultPage.setRecords(pageList);
@@ -1717,26 +1721,31 @@
    /**
     * 根据设置的参数计算员工的年假
     *
     * @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) {
@@ -1868,6 +1877,7 @@
    /**
     * 根据时间范围类型计算开始和结束日期
     *
     * @param timeRange 0-当天 1-本周 2-本月 3-今年
     * @return 包含开始日期和结束日期的数组 [startDate, endDate)
     */