From a542a9b8b51476d27cd5f56218068c2762b5b3b6 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Sun, 04 Jan 2026 05:27:26 +0000
Subject: [PATCH] 修改年假结算制度

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java    |    7 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java                   |   72 ++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java             |    8 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java     |   28 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java           |   83 +++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java    |  123 ++++++----
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java  |  108 +++++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java           |   48 ++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java    |    6 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java           |   87 +++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java |   37 +++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java  |   32 ++
 12 files changed, 573 insertions(+), 66 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java
new file mode 100644
index 0000000..8592346
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java
@@ -0,0 +1,72 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import org.hibernate.annotations.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author baolh
+* @date 2025-12-31
+**/
+@Entity
+@Data
+@Table(name="annual_leave_record")
+public class AnnualLeaveRecord implements Serializable {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "`id`")
+    @ApiModelProperty(value = "ID")
+    private Long id;
+
+    @Column(name = "`user_id`")
+    @ApiModelProperty(value = "用户ID")
+    private Long userId;
+
+    @Column(name = "`year`")
+    @ApiModelProperty(value = "年度")
+    private String year;
+
+    @Column(name = "`create_time`")
+    @CreationTimestamp
+    @ApiModelProperty(value = "创建时间")
+    private Timestamp createTime;
+
+    @Column(name = "`update_time`")
+    @UpdateTimestamp
+    @ApiModelProperty(value = "更新时间")
+    private Timestamp updateTime;
+
+    @Column(name = "`surplus_hour`")
+    @ApiModelProperty(value = "年假结余小时数")
+    private Double surplusHour;
+
+    public void copy(AnnualLeaveRecord source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java
new file mode 100644
index 0000000..38bed9d
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java
@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.repository;
+
+import me.zhengjie.modules.attendance.domain.AnnualLeaveRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://eladmin.vip
+* @author baolh
+* @date 2025-12-31
+**/
+public interface AnnualLeaveRecordRepository extends JpaRepository<AnnualLeaveRecord, Long>, JpaSpecificationExecutor<AnnualLeaveRecord> {
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java
new file mode 100644
index 0000000..c6f7da5
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java
@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.attendance.domain.AnnualLeaveRecord;
+import me.zhengjie.modules.attendance.service.AnnualLeaveRecordService;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author baolh
+* @date 2025-12-31
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "年假记录管理")
+@RequestMapping("/api/annualLeaveRecord")
+public class AnnualLeaveRecordController {
+
+    private final AnnualLeaveRecordService annualLeaveRecordService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('annualLeaveRecord:list')")
+    public void exportAnnualLeaveRecord(HttpServletResponse response, AnnualLeaveRecordQueryCriteria criteria) throws IOException {
+        annualLeaveRecordService.download(annualLeaveRecordService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询年假记录")
+    @ApiOperation("查询年假记录")
+    @PreAuthorize("@el.check('annualLeaveRecord:list')")
+    public ResponseEntity<Object> queryAnnualLeaveRecord(AnnualLeaveRecordQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(annualLeaveRecordService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增年假记录")
+    @ApiOperation("新增年假记录")
+    @PreAuthorize("@el.check('annualLeaveRecord:add')")
+    public ResponseEntity<Object> createAnnualLeaveRecord(@Validated @RequestBody AnnualLeaveRecord resources){
+        return new ResponseEntity<>(annualLeaveRecordService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改年假记录")
+    @ApiOperation("修改年假记录")
+    @PreAuthorize("@el.check('annualLeaveRecord:edit')")
+    public ResponseEntity<Object> updateAnnualLeaveRecord(@Validated @RequestBody AnnualLeaveRecord resources){
+        annualLeaveRecordService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @DeleteMapping
+    @Log("删除年假记录")
+    @ApiOperation("删除年假记录")
+    @PreAuthorize("@el.check('annualLeaveRecord:del')")
+    public ResponseEntity<Object> deleteAnnualLeaveRecord(@RequestBody Long[] ids) {
+        annualLeaveRecordService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java
new file mode 100644
index 0000000..d19e4f4
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java
@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service;
+
+import me.zhengjie.modules.attendance.domain.AnnualLeaveRecord;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordDto;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author baolh
+* @date 2025-12-31
+**/
+public interface AnnualLeaveRecordService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(AnnualLeaveRecordQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<AnnualLeaveRecordDto>
+    */
+    List<AnnualLeaveRecordDto> queryAll(AnnualLeaveRecordQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param id ID
+     * @return AnnualLeaveRecordDto
+     */
+    AnnualLeaveRecordDto findById(Long id);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return AnnualLeaveRecordDto
+    */
+    AnnualLeaveRecordDto create(AnnualLeaveRecord resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(AnnualLeaveRecord resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<AnnualLeaveRecordDto> all, HttpServletResponse response) throws IOException;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java
index de08b9e..93e8d42 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java
@@ -16,7 +16,6 @@
 package me.zhengjie.modules.attendance.service;
 
 import me.zhengjie.modules.attendance.domain.AgreeUpdateRequest;
-import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
 import me.zhengjie.modules.attendance.domain.AttendanceLeave;
 import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
 import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
@@ -78,13 +77,6 @@
      * @throws Exception /
      */
     AttendanceLeaveDto calcTimeLength(AttendanceLeave resources) throws Exception;
-
-    /**
-     *获取剩余年假
-     * @return
-     * @throws ParseException
-     */
-    Double getYearTimeLength(Long userId) throws ParseException;
 
     /**
      *获取剩余年假
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java
new file mode 100644
index 0000000..d4fc37f
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java
@@ -0,0 +1,48 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author baolh
+* @date 2025-12-31
+**/
+@Data
+public class AnnualLeaveRecordDto implements Serializable {
+
+    /** ID */
+    private Long id;
+
+    /** 用户ID */
+    private Long userId;
+
+    /** 年度 */
+    private String year;
+
+    /** 创建时间 */
+    private Timestamp createTime;
+
+    /** 更新时间 */
+    private Timestamp updateTime;
+
+    /** 年假结余小时数 */
+    private Double surplusHour;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java
new file mode 100644
index 0000000..69fba85
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java
@@ -0,0 +1,37 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author baolh
+* @date 2025-12-31
+**/
+@Data
+public class AnnualLeaveRecordQueryCriteria{
+
+    /** 精确 */
+    @Query
+    private Long userId;
+
+    /** 精确 */
+    @Query
+    private String year;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java
new file mode 100644
index 0000000..6c03235
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java
@@ -0,0 +1,108 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.impl;
+
+import me.zhengjie.modules.attendance.domain.AnnualLeaveRecord;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.attendance.repository.AnnualLeaveRecordRepository;
+import me.zhengjie.modules.attendance.service.AnnualLeaveRecordService;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordDto;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordQueryCriteria;
+import me.zhengjie.modules.attendance.service.mapstruct.AnnualLeaveRecordMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author baolh
+* @date 2025-12-31
+**/
+@Service
+@RequiredArgsConstructor
+public class AnnualLeaveRecordServiceImpl implements AnnualLeaveRecordService {
+
+    private final AnnualLeaveRecordRepository annualLeaveRecordRepository;
+    private final AnnualLeaveRecordMapper annualLeaveRecordMapper;
+
+    @Override
+    public Map<String,Object> queryAll(AnnualLeaveRecordQueryCriteria criteria, Pageable pageable){
+        Page<AnnualLeaveRecord> page = annualLeaveRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(annualLeaveRecordMapper::toDto));
+    }
+
+    @Override
+    public List<AnnualLeaveRecordDto> queryAll(AnnualLeaveRecordQueryCriteria criteria){
+        return annualLeaveRecordMapper.toDto(annualLeaveRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public AnnualLeaveRecordDto findById(Long id) {
+        AnnualLeaveRecord annualLeaveRecord = annualLeaveRecordRepository.findById(id).orElseGet(AnnualLeaveRecord::new);
+        ValidationUtil.isNull(annualLeaveRecord.getId(),"AnnualLeaveRecord","id",id);
+        return annualLeaveRecordMapper.toDto(annualLeaveRecord);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public AnnualLeaveRecordDto create(AnnualLeaveRecord resources) {
+        return annualLeaveRecordMapper.toDto(annualLeaveRecordRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(AnnualLeaveRecord resources) {
+        AnnualLeaveRecord annualLeaveRecord = annualLeaveRecordRepository.findById(resources.getId()).orElseGet(AnnualLeaveRecord::new);
+        ValidationUtil.isNull( annualLeaveRecord.getId(),"AnnualLeaveRecord","id",resources.getId());
+        annualLeaveRecord.copy(resources);
+        annualLeaveRecordRepository.save(annualLeaveRecord);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long id : ids) {
+            annualLeaveRecordRepository.deleteById(id);
+        }
+    }
+
+    @Override
+    public void download(List<AnnualLeaveRecordDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (AnnualLeaveRecordDto annualLeaveRecord : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("用户ID", annualLeaveRecord.getUserId());
+            map.put("年度", annualLeaveRecord.getYear());
+            map.put("创建时间", annualLeaveRecord.getCreateTime());
+            map.put("更新时间", annualLeaveRecord.getUpdateTime());
+            map.put("年假结余小时数", annualLeaveRecord.getSurplusHour());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
index f71af67..2afc742 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -20,16 +20,12 @@
 import me.zhengjie.modules.approval.domain.ApproveEvent;
 import me.zhengjie.modules.approval.repository.ApproveEventRepository;
 import me.zhengjie.modules.approval.service.TemplateControlFieldService;
-import me.zhengjie.modules.approval.service.TemplateService;
 import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
 import me.zhengjie.modules.attendance.domain.*;
 import me.zhengjie.modules.attendance.repository.*;
 import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
 import me.zhengjie.modules.attendance.service.AttendanceService;
-import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
-import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
-import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria;
-import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordQueryCriteria;
+import me.zhengjie.modules.attendance.service.dto.*;
 import me.zhengjie.modules.attendance.service.mapstruct.AttendanceLeaveMapper;
 import me.zhengjie.modules.constant.Constant;
 import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
@@ -76,15 +72,14 @@
     private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
     private final UserRepository userRepository;
     private final SysConfigHolidayRepository sysConfigHolidayRepository;
-    private final AttendanceRepository attendanceRepository;
     private final AttendanceGoOutRepository attendanceGoOutRepository;
     private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
     private final AttendanceOvertimeRepository attendanceOvertimeRepository;
     private final ApproveEventRepository approveEventRepository;
     private final OvertimeConsumedRecordRepository overtimeConsumedRecordRepository;
+    private final AnnualLeaveRecordRepository annualLeaveRecordRepository;
     private final ApproveEventMapper approveEventMapper;
     private final WeComServiceImpl weComService;
-    private final TemplateService templateService;
     private final TemplateControlFieldService templateControlFieldService;
 
     @Override
@@ -483,54 +478,86 @@
      * 获取用户年假剩余时长
      */
     @Override
-    public Double getYearTimeLength(Long userId) {
-        //获取年假剩余(新)
-        Double surplusYearTime = new Double(0.00);
-        // 根据用户查询
-        List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId);
-        if (sysUserLevelOtherList.size() > 0) {
-            for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
-                // 获取今年
-                int year = Calendar.getInstance().get(Calendar.YEAR);
-                if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
-                    //年假总时长
-                    Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
-
-                    String startTime = year + "-01-01 00:00:00";
-                    String endTime = year + "-12-31 23:59:59";
-                    Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime);
-
-                    surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime);
-                }
-            }
-        }
-        return surplusYearTime;
-    }
-
-    /**
-     * 获取用户年假剩余时长
-     */
-    @Override
     public Double getYearTimeLength(Long userId, String year) {
-        //获取年假剩余(新)
-        Double surplusYearTime = new Double(0.00);
+        // 默认参数
+        LocalDate targetDate;
+        if (StringUtils.isBlank(year)) {
+            // 未指定年度
+            targetDate = LocalDate.now();
+            year = String.valueOf(targetDate.getYear());
+        } else {
+            // 指定年度
+            targetDate = LocalDate.now().withYear(Integer.parseInt(year)).withDayOfYear(1);
+        }
+
+        // 获取年假剩余(新)
+        BigDecimal surplusYearTime = BigDecimal.ZERO;
+
         // 根据用户查询
         List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId);
         if (sysUserLevelOtherList.size() > 0) {
-            for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
-                if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
-                    //年假总时长
-                    Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
-
-                    String startTime = year + "-01-01 00:00:00";
-                    String endTime = year + "-12-31 23:59:59";
-                    Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime);
-
-                    surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime);
+            SysUserLevelOther sysUserLevelOther = sysUserLevelOtherList.stream().filter(sulo -> {
+                if (sulo.getStartDate() != null && sulo.getEndDate() != null) {
+                    return !targetDate.isBefore(sulo.getStartDate().toLocalDateTime().toLocalDate()) && !targetDate.isAfter(sulo.getEndDate().toLocalDateTime().toLocalDate());
+                } else if (sulo.getStartDate() != null) {
+                    return !targetDate.isBefore(sulo.getStartDate().toLocalDateTime().toLocalDate());
                 }
+                return false;
+            }).sorted(Comparator.comparing(SysUserLevelOther::getStartDate).reversed()).findFirst().orElse(null);
+            if (sysUserLevelOther != null) {
+                // 年假总时长
+                BigDecimal yearTime = new BigDecimal(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
+                // 当年使用年假时长
+                String startTime = targetDate.withDayOfYear(1).atTime(4, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                String endTime = targetDate.withDayOfYear(1).plusYears(1).atTime(3, 59, 59, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime);
+
+                // 获取上年度结余年假时长
+                String lastYear = String.valueOf(Integer.parseInt(year) - 1);
+                BigDecimal lastYearTime = BigDecimal.ZERO;
+                // 查询年度年假记录
+                AnnualLeaveRecordQueryCriteria criteria = new AnnualLeaveRecordQueryCriteria();
+                criteria.setUserId(userId);
+                criteria.setYear(lastYear);
+                AnnualLeaveRecord annualLeaveRecord = annualLeaveRecordRepository.findOne((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)).orElse(null);
+                if (annualLeaveRecord != null) {
+                    lastYearTime = new BigDecimal(annualLeaveRecord.getSurplusHour());
+                } else {
+                    // 查询本年度且上年度不存在时创建(2026年1月开始运行上年度结算年假制度)
+                    if (LocalDate.now().getYear() == Integer.parseInt(year)) {
+                        // 去年(剩余年假大于1才可结算至第二年)
+                        LocalDate lastYearDate = targetDate.withDayOfYear(1).minusDays(1);
+                        SysUserLevelOther lastSysUserLevelOther = sysUserLevelOtherList.stream().filter(sulo -> {
+                            if (sulo.getStartDate() != null && sulo.getEndDate() != null) {
+                                return !lastYearDate.isBefore(sulo.getStartDate().toLocalDateTime().toLocalDate()) && !lastYearDate.isAfter(sulo.getEndDate().toLocalDateTime().toLocalDate());
+                            } else if (sulo.getStartDate() != null) {
+                                return !lastYearDate.isBefore(sulo.getStartDate().toLocalDateTime().toLocalDate());
+                            }
+                            return false;
+                        }).sorted(Comparator.comparing(SysUserLevelOther::getStartDate).reversed()).findFirst().orElse(null);
+                        if (lastSysUserLevelOther != null) {
+                            // 上年度使用年假时长
+                            String lastStartTime = targetDate.minusYears(1).withDayOfYear(1).atTime(4, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                            String lastEndTime = targetDate.minusYears(1).withDayOfYear(1).plusYears(1).atTime(3, 59, 59, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                            Double usedLastYearTime = attendanceLeaveRepository.getSurplusYearTime(userId, lastStartTime, lastEndTime);
+                            BigDecimal surplusTime = new BigDecimal(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8).subtract(usedLastYearTime == null ? BigDecimal.ZERO : new BigDecimal(usedLastYearTime));
+                            lastYearTime = surplusTime.compareTo(BigDecimal.ONE) < 0 ? BigDecimal.ZERO : surplusTime;
+                        }
+
+                        AnnualLeaveRecord lastRecord = new AnnualLeaveRecord();
+                        lastRecord.setUserId(userId);
+                        lastRecord.setYear(lastYear);
+                        lastRecord.setSurplusHour(lastYearTime.doubleValue());
+
+                        annualLeaveRecordRepository.save(lastRecord);
+                    }
+                }
+
+                // 计算本年度剩余年假时长
+                surplusYearTime = yearTime.add(lastYearTime).subtract(new BigDecimal(usedYearTime == null ? 0.0 : usedYearTime));
             }
         }
-        return surplusYearTime;
+        return surplusYearTime.doubleValue();
     }
 
     /**
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
index 2fedcb0..bd5e63f 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
@@ -21,8 +21,6 @@
 import me.zhengjie.modules.attendance.domain.AttendanceMonthLeave;
 import me.zhengjie.modules.attendance.repository.AttendanceMonthLeaveRepository;
 import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.salary.domain.Salary;
-import me.zhengjie.modules.salary.service.dto.SalaryDto;
 import me.zhengjie.modules.system.domain.Dept;
 import me.zhengjie.modules.system.domain.Job;
 import me.zhengjie.modules.system.domain.SysCompany;
@@ -125,7 +123,7 @@
                         leaveTypeList.add(attTypeInfo);
                     }
                 }else{
-                    Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonthDto.getUserId());
+                    Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonthDto.getUserId(), null);
                     attendanceMonthDto.setYearTime(yearTime);
                 }
                 attendanceMonthDto.setLeaveTypeList(leaveTypeList);
@@ -316,7 +314,7 @@
             map.put("当月使用调休假", locationLeave);
             map.put("当月使用事假", compassionateLeave);
 
-            Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonth.getUserId());
+            Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonth.getUserId(), null);
             map.put("剩余年假", yearTime);
 
             Double overTime = attendanceLeaveService.getOverTimeLength(attendanceMonth.getUserId(), LocalDateTime.now());
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java
new file mode 100644
index 0000000..ec1e544
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java
@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.attendance.domain.AnnualLeaveRecord;
+import me.zhengjie.modules.attendance.service.dto.AnnualLeaveRecordDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author baolh
+* @date 2025-12-31
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface AnnualLeaveRecordMapper extends BaseMapper<AnnualLeaveRecordDto, AnnualLeaveRecord> {
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java
index 3ec949d..0065363 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java
@@ -1,15 +1,12 @@
 package me.zhengjie.modules.quartz.service.impl;
 
-
 import cn.hutool.core.util.ObjectUtil;
 import lombok.RequiredArgsConstructor;
 import me.zhengjie.modules.attendance.domain.*;
 import me.zhengjie.modules.attendance.repository.*;
 import me.zhengjie.modules.attendance.service.impl.AttendanceLeaveServiceImpl;
-import me.zhengjie.modules.attendance.service.impl.AttendanceServiceImpl;
 import me.zhengjie.modules.constant.Constant;
 import me.zhengjie.modules.system.domain.Job;
-import me.zhengjie.modules.system.domain.Role;
 import me.zhengjie.modules.system.domain.SysConfigHoliday;
 import me.zhengjie.modules.system.domain.User;
 import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
@@ -21,8 +18,6 @@
 import javax.transaction.Transactional;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.time.DayOfWeek;
 import java.time.Duration;
 import java.time.LocalDate;
@@ -226,7 +221,7 @@
                 attendanceMonthLeave.setLeaveTime(getLeaveDuration(leaves,leaveTpeList.get(i2)));
                 //年假剩余时长
                 if(leaveTpeList.get(i2).equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE)){
-                    Double yearTime = attendanceLeaveService.getYearTimeLength(insertData.get(i).getUserId());
+                    Double yearTime = attendanceLeaveService.getYearTimeLength(insertData.get(i).getUserId(), null);
                     attendanceMonthLeave.setSurplusDuration(yearTime);
                 } else if (leaveTpeList.get(i2).equals(Constant.LEAVE_TYPE_LACTATION_LEAVE)) {
                     Double yearTime = attendanceLeaveService.getOverTimeLength(insertData.get(i).getUserId(), LocalDateTime.now());

--
Gitblit v1.9.3