From 908298c5ee4c87ca8575d7088050e7170a124724 Mon Sep 17 00:00:00 2001
From: yaozc2021 <yaozc@yhzhg.cn>
Date: Thu, 13 Mar 2025 09:59:58 +0000
Subject: [PATCH] BUG修正

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java         |    4 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java          |   11 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java   |  565 +++++++++++++-------------
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java |    3 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java                |    2 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java    |   25 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java |  143 +++++-
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java            |  103 +++-
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java          |  274 ++++++------
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java      |  107 ++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java               |    1 
 11 files changed, 744 insertions(+), 494 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java
index c5589d9..c3c3e27 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java
@@ -89,6 +89,10 @@
     @ApiModelProperty(value = "出差类别")
     private String category;
 
+    @Column(name = "`project_id`")
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+
     @Column(name = "`approval_status`",nullable = false)
     @NotBlank
     @ApiModelProperty(value = "审批状态")
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java
index 17af2f7..c844c7c 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java
@@ -1,137 +1,139 @@
-/*
-*  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.AgreeUpdateRequest;
-import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
-import me.zhengjie.modules.attendance.domain.AttendanceLeave;
-import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
-import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
-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 java.text.ParseException;
-import javax.servlet.http.HttpServletResponse;
-
-/**
-* @website https://eladmin.vip
-* @author wcd
-* @date 2022-12-16
-**/
-@RestController
-@RequiredArgsConstructor
-@Api(tags = "请假管理")
-@RequestMapping("/api/attendanceLeave")
-public class AttendanceLeaveController {
-
-    private final AttendanceLeaveService attendanceLeaveService;
-
-    @Log("导出数据")
-    @ApiOperation("导出数据")
-    @GetMapping(value = "/download")
-    @PreAuthorize("@el.check('attendanceLeave:download')")
-    public void exportAttendanceLeave(HttpServletResponse response, AttendanceLeaveQueryCriteria criteria) throws IOException {
-        attendanceLeaveService.download(attendanceLeaveService.queryAll(criteria), response);
-    }
-
-    @GetMapping
-    @Log("查询请假")
-    @ApiOperation("查询请假")
-    @PreAuthorize("@el.check('attendanceLeave:list')")
-    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
-        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria,pageable),HttpStatus.OK);
-    }
-
-    @GetMapping(value = "/all")
-    @Log("查询请假")
-    @ApiOperation("查询请假")
-    @PreAuthorize("@el.check('attendanceLeave:list')")
-    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria){
-        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria),HttpStatus.OK);
-    }
-
-    @PostMapping
-    @Log("新增请假")
-    @ApiOperation("新增请假")
-    @PreAuthorize("@el.check('attendanceLeave:add')")
-    public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeave resources) throws Exception {
-        return new ResponseEntity<>(attendanceLeaveService.create(resources),HttpStatus.CREATED);
-    }
-
-    @PutMapping
-    @Log("修改请假")
-    @ApiOperation("修改请假")
-    @PreAuthorize("@el.check('attendanceLeave:edit')")
-    public ResponseEntity<Object> updateAttendanceLeave(@Validated @RequestBody AttendanceLeave resources){
-        attendanceLeaveService.update(resources);
-        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
-    }
-
-    @PostMapping(value = "/calcTimeLength")
-    @Log("计算请假时长")
-    @ApiOperation("计算请假时长")
-    public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceLeave resources) throws Exception {
-        return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK);
-    }
-
-    @PostMapping(value = "/getYearTimeLength")
-    @Log("获取年假时长")
-    @ApiOperation("获取年假时长")
-    public ResponseEntity<Object> getYearTimeLength(@RequestBody Long userId) throws ParseException {
-        return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId), HttpStatus.OK);
-    }
-
-    @PostMapping(value = "/getOverTimeLength")
-    @Log("获取调休假时长")
-    @ApiOperation("获取调休假时长")
-    public ResponseEntity<Object> getOverTimeLength(@RequestBody Long userId) throws ParseException {
-        return new ResponseEntity<>(attendanceLeaveService.getOverTimeLength(userId), HttpStatus.OK);
-    }
-
-    @PutMapping(value = "/approve")
-    @Log("审核功能")
-    @ApiOperation("审核功能")
-    @PreAuthorize("@el.check('attendanceLeave:approve')")
-    public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources) throws Exception {
-        attendanceLeaveService.updateApprove(resources);
-        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
-    }
-
-    @DeleteMapping
-    @Log("删除请假")
-    @ApiOperation("删除请假")
-    @PreAuthorize("@el.check('attendanceLeave:del')")
-    public ResponseEntity<Object> deleteAttendanceLeave(@RequestBody Long[] ids) {
-        attendanceLeaveService.deleteAll(ids);
-        return new ResponseEntity<>(HttpStatus.OK);
-    }
-
-    @PutMapping(value = "/updateAgree")
-    @Log("批量审核")
-    @ApiOperation("批量审核")
-    @PreAuthorize("@el.check('attendanceLeave:updateAgree')")
-    public ResponseEntity<Object> editIsAgree(@Validated @RequestBody AgreeUpdateRequest request) throws Exception {
-        attendanceLeaveService.updateAgree(request);
-        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
-    }
+/*
+*  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.AgreeUpdateRequest;
+import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
+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 java.text.ParseException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2022-12-16
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "请假管理")
+@RequestMapping("/api/attendanceLeave")
+public class AttendanceLeaveController {
+
+    private final AttendanceLeaveService attendanceLeaveService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('attendanceLeave:download')")
+    public void exportAttendanceLeave(HttpServletResponse response, AttendanceLeaveQueryCriteria criteria) throws IOException {
+        attendanceLeaveService.download(attendanceLeaveService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询请假")
+    @ApiOperation("查询请假")
+    @PreAuthorize("@el.check('attendanceLeave:list')")
+    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @GetMapping(value = "/all")
+    @Log("查询请假")
+    @ApiOperation("查询请假")
+    @PreAuthorize("@el.check('attendanceLeave:list')")
+    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria){
+        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增请假")
+    @ApiOperation("新增请假")
+    @PreAuthorize("@el.check('attendanceLeave:add')")
+    public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeave resources) throws Exception {
+        return new ResponseEntity<>(attendanceLeaveService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改请假")
+    @ApiOperation("修改请假")
+    @PreAuthorize("@el.check('attendanceLeave:edit')")
+    public ResponseEntity<Object> updateAttendanceLeave(@Validated @RequestBody AttendanceLeave resources){
+        attendanceLeaveService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @PostMapping(value = "/calcTimeLength")
+    @Log("计算请假时长")
+    @ApiOperation("计算请假时长")
+    public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceLeave resources) throws Exception {
+        return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK);
+    }
+
+    @PostMapping(value = "/getYearTimeLength/{userId}")
+    @Log("获取年假时长")
+    @ApiOperation("获取年假时长")
+    public ResponseEntity<Object> getYearTimeLength(@PathVariable Long userId, @RequestBody String year) throws ParseException {
+        return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId, year), HttpStatus.OK);
+    }
+
+    @PostMapping(value = "/getOverTimeLength/{userId}")
+    @Log("获取调休假时长")
+    @ApiOperation("获取调休假时长")
+    public ResponseEntity<Object> getOverTimeLength(@PathVariable Long userId, @RequestBody String yearMonth) throws ParseException {
+        Double overTimeLength = attendanceLeaveService.getOverTimeLength(userId, yearMonth);
+        Double overTimeCloseLength = attendanceLeaveService.getOverTimeCloseLength(userId, yearMonth);
+        return new ResponseEntity<>(overTimeLength + overTimeCloseLength, HttpStatus.OK);
+    }
+
+    @PutMapping(value = "/approve")
+    @Log("审核功能")
+    @ApiOperation("审核功能")
+    @PreAuthorize("@el.check('attendanceLeave:approve')")
+    public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources) throws Exception {
+        attendanceLeaveService.updateApprove(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @DeleteMapping
+    @Log("删除请假")
+    @ApiOperation("删除请假")
+    @PreAuthorize("@el.check('attendanceLeave:del')")
+    public ResponseEntity<Object> deleteAttendanceLeave(@RequestBody Long[] ids) {
+        attendanceLeaveService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+
+    @PutMapping(value = "/updateAgree")
+    @Log("批量审核")
+    @ApiOperation("批量审核")
+    @PreAuthorize("@el.check('attendanceLeave:updateAgree')")
+    public ResponseEntity<Object> editIsAgree(@Validated @RequestBody AgreeUpdateRequest request) throws Exception {
+        attendanceLeaveService.updateAgree(request);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
 }
\ 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 89c9122..62d1037 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
@@ -86,14 +86,25 @@
     Double getYearTimeLength(Long userId) throws ParseException;
 
     /**
+     *获取剩余年假
+     * @return
+     * @throws ParseException
+     */
+    Double getYearTimeLength(Long userId, String year) throws ParseException;
+
+    /**
      *获取剩余调休假
      * @return
      * @throws ParseException
      */
     Double getOverTimeLength(Long userId) throws ParseException;
 
+    Double getOverTimeLength(Long userId, String yearMonth) throws ParseException;
+
     Double getOverTimeCloseLength(Long userId);
 
+    Double getOverTimeCloseLength(Long userId, String yearMonth);
+
     /**
      * 审核功能
      * @param resources /
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
index e47c706..9559a1b 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
@@ -125,4 +125,5 @@
      */
     void addAttendanceInfo(Attendance attendance) throws Exception;
 
+    void generateAttendance(Long id, String startDate, String endDate);
 }
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java
index fdd8a85..86f2f50 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java
@@ -63,6 +63,9 @@
     /** 出差类别 */
     private String category;
 
+    /** 项目ID */
+    private Long projectId;
+
     /** 审批状态 */
     private String approvalStatus;
 
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 83db201..3a2b164 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
@@ -336,7 +336,7 @@
     public void repeatValidation(String startTime, String endTime, Long userId){
         // 查询外出表
         List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(startTime, endTime, userId);
-        if(attendanceGoOutList.size() > 0){
+        if(attendanceGoOutList.size() > 0) {
             AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0);
             SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
             throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime())
@@ -370,7 +370,7 @@
 
             //用Calendar 进行日期比较判断
             Calendar calendar = Calendar.getInstance();
-            while (startDate.getTime()<=endDate.getTime()){
+            while (startDate.getTime()<=endDate.getTime()) {
                 // 把日期添加到集合
                 list.add(sdf.format(startDate));
                 // 设置日期
@@ -451,26 +451,86 @@
     }
 
     /**
+     * 获取用户年假剩余时长
+     */
+    @Override
+    public Double getYearTimeLength(Long userId, String year) {
+        //获取年假剩余(新)
+        Double surplusYearTime = new Double(0.00);
+        // 根据用户查询
+        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);
+                }
+            }
+        }
+        return surplusYearTime;
+    }
+
+    /**
      * 获取用户调休假剩余时长
      */
     @Override
     public Double getOverTimeLength(Long userId) {
-        //获取调休假剩余时长
-        Double surplusYearTime = new Double(0.00);
-
-        LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(3);
-        LocalDate localDateEnd = LocalDate.now().plusDays(1);
-
-        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay());
-        if (!attendanceOvertimeList.isEmpty()) {
-            surplusYearTime = attendanceOvertimeList.stream()
-                    .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
-                    .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
-            Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
-            if (usedTime > 0) {
-                surplusYearTime = surplusYearTime - usedTime;
-            }
+        LocalDate localDateStart = LocalDate.of(2024, 1, 1);
+        LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
+        Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
+        if (overTimeLast == null) {
+            overTimeLast = 0.0;
         }
+        LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
+
+        Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
+        if (surplusYearTime == null) {
+            surplusYearTime = 0.0;
+        }
+        Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+        if (usedTime == null) {
+            usedTime = 0.0;
+        }
+        if (overTimeLast > usedTime) {
+            return surplusYearTime;
+        }
+        surplusYearTime = surplusYearTime + overTimeLast - usedTime;
+
+        if (surplusYearTime <= 0.0) {
+            return 0.0;
+        }
+        return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    @Override
+    public Double getOverTimeLength(Long userId, String yearMonth) {
+        LocalDate localDateStart = LocalDate.of(2024, 1, 1);
+        LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
+        Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
+        if (overTimeLast == null) {
+            overTimeLast = 0.0;
+        }
+        LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
+
+        Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
+        if (surplusYearTime == null) {
+            surplusYearTime = 0.0;
+        }
+        Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+        if (usedTime == null) {
+            usedTime = 0.0;
+        }
+        if (overTimeLast > usedTime) {
+            return surplusYearTime;
+        }
+        surplusYearTime = surplusYearTime + overTimeLast - usedTime;
+
         if (surplusYearTime <= 0.0) {
             return 0.0;
         }
@@ -482,26 +542,41 @@
      */
     @Override
     public Double getOverTimeCloseLength(Long userId) {
-        //获取年假剩余(新)
-        Double surplusYearTime = new Double(0.00);
-
-        LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(4);
-        LocalDate localDateEnd = LocalDate.now().plusDays(1);
-
-
-        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateStart.plusMonths(1).withDayOfMonth(1).atStartOfDay());
-        if (!attendanceOvertimeList.isEmpty()) {
-            surplusYearTime = attendanceOvertimeList.stream()
-                    .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
-                    .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
-            Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
-            if (usedTime > 0) {
-                surplusYearTime = surplusYearTime - usedTime;
-            }
+        LocalDate localDateStart = LocalDate.of(2024, 1, 1);
+        LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
+        Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
+        if (surplusYearTime == null) {
+            surplusYearTime = 0.0;
         }
-        if (surplusYearTime <= 0.0) {
+        LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
+        Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+        if (usedTime == null) {
+            usedTime = 0.0;
+        }
+        if (surplusYearTime <= usedTime) {
             return 0.0;
         }
+        surplusYearTime = surplusYearTime - usedTime;
+        return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    @Override
+    public Double getOverTimeCloseLength(Long userId, String yearMonth) {
+        LocalDate localDateStart = LocalDate.of(2024, 1, 1);
+        LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
+        Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
+        if (surplusYearTime == null) {
+            surplusYearTime = 0.0;
+        }
+        LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
+        Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+        if (usedTime == null) {
+            usedTime = 0.0;
+        }
+        if (surplusYearTime <= usedTime) {
+            return 0.0;
+        }
+        surplusYearTime = surplusYearTime - usedTime;
         return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
     }
 
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
index 6fa81c1..aaf45a9 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -30,10 +30,12 @@
 import me.zhengjie.modules.system.domain.User;
 import me.zhengjie.modules.system.repository.DictDetailRepository;
 import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
+import me.zhengjie.modules.system.repository.SysRosteringRepository;
 import me.zhengjie.modules.system.repository.UserRepository;
 import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria;
 import me.zhengjie.utils.*;
 import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -287,6 +289,74 @@
         dingTalkService.getDingTalkAttendanceList(attendance.getAttendanceDate(), userList);
         // 选择日期和员工更新员工的考勤信息,未选择员工则更新所有人
         dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate ,userList);
+    }
+
+    @Autowired
+    private SysRosteringRepository sysRosteringRepository;
+
+    @Override
+    public void generateAttendance(Long id, String startDate, String endDate) {
+        Stream.iterate(LocalDate.parse(startDate), date -> date.plusDays(1))
+            .limit(ChronoUnit.DAYS.between(LocalDate.parse(startDate), LocalDate.parse(endDate)) + 1).forEach(date -> {
+                    User user = userRepository.findById(id).get();
+                    // 用户排班
+                    SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId());
+                    // 考勤记录
+                    Attendance attendance = new Attendance();
+
+                    SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+
+                    // 时间格式化
+                    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+                    // 考勤记录
+                    attendance.setUserId(user.getId());
+                    attendance.setAttendanceDate(Timestamp.valueOf(date.atStartOfDay()));
+                    // 考勤日期类是否是周末、节假日、工作日
+                    if (sysConfigHoliday == null && (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)) {
+                        attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
+                        attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
+                        // 考勤记录:日期类型-双休
+                        attendance.setDateType(Constant.DATE_TYPE_WEEKEND);
+                    } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
+                        attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
+                        attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
+                        // 考勤记录:日期类型-节假日
+                        attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS);
+                    } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
+                        attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
+                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
+                        attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
+                        // 考勤记录:日期类型-法定节假日
+                        attendance.setDateType(Constant.DATE_TYPE_HOLIDAYS);
+                    } else {
+                        attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL);
+                        attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL);
+                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
+                        attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
+
+                        attendance.setActualWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
+                        attendance.setActualWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
+
+                        // 考勤记录:日期类型-工作日
+                        attendance.setDateType(Constant.DATE_TYPE_WEEKDAY);
+                    }
+
+                    // 考勤记
+                    attendance.setRosteringWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
+                    attendance.setRosteringWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
+                    attendance.setRosteringLunchStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime())));
+                    attendance.setRosteringLunchEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime())));
+
+                    // 保存
+                    attendanceRepository.save(attendance);
+        });
+
     }
 
     @Override
@@ -613,6 +683,38 @@
             List<Calculate> breakParts = new ArrayList<>();
             breakParts.add(new Calculate(rosteringLunchStartTime, rosteringLunchEndTime));
 
+            // 请假信息
+            List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
+            breakParts.addAll(
+                    attendanceLeaveList.stream().map(attendanceLeave -> {
+                        LocalDateTime attendanceLeaveStart = attendanceLeave.getLeaveStartTime().toLocalDateTime();
+                        LocalDateTime attendanceLeaveEnd = attendanceLeave.getLeaveEndTime().toLocalDateTime();
+                        if (attendanceLeaveStart.isBefore(rosteringWorkStartTime)) {
+                            attendanceLeaveStart = rosteringWorkStartTime;
+                        }
+                        if (attendanceLeaveEnd.isAfter(rosteringWorkEndTime)) {
+                            attendanceLeaveEnd = rosteringWorkEndTime;
+                        }
+                        return new Calculate(attendanceLeaveStart, attendanceLeaveEnd);
+                    }
+                    ).filter(calculate -> calculate.getStart().isBefore(calculate.getEnd())).collect(Collectors.toList())
+            );
+            // 合并请假时间
+            List<Calculate> finalBreakParts = breakParts.stream().sorted().reduce(new Stack<>(), (result, current) -> {
+                // 删除重复时间,合并相连的时间段
+                if (result.empty()) {
+                    result.push(current);
+                    return result;
+                }
+                Calculate last = result.peek();
+                if (last.getEnd().isBefore(current.getStart())) {
+                    result.push(current);
+                } else if (last.getEnd().isBefore(current.getEnd())) {
+                    last.setEnd(current.getEnd());
+                }
+                return result;
+            }, (o1, o2) -> null);
+
             // 外出信息
             List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
             attendanceParts.addAll(
@@ -646,7 +748,7 @@
                 return result;
             }, (o1, o2) -> null).forEach(calculate -> {
                 // 去除休息时间:午休等
-                for (Calculate breakPart : breakParts) {
+                for (Calculate breakPart : finalBreakParts) {
                     if ((calculate.getStart().isBefore(breakPart.getStart()) && calculate.getEnd().isAfter(breakPart.getStart()))
                             || (calculate.getStart().isBefore(breakPart.getEnd()) && calculate.getEnd().isAfter(breakPart.getEnd()))) {
                         Calculate calculate1 = new Calculate(calculate.getStart(), breakPart.getStart());
@@ -670,9 +772,6 @@
                             (total, current) -> total.add(BigDecimal.valueOf(current)),
                             (o1, o2) -> null).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP
                     );
-
-            // 请假信息
-            List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
             // 年假不扣工时
             BigDecimal annualLeaveHours = attendanceLeaveList.stream()
                     .filter(attendanceLeave -> Constant.LEAVE_TYPE_ANNUAL_LEAVE.equals(attendanceLeave.getLeaveType())
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java
index 2b4442d..d0a27e7 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java
@@ -193,13 +193,13 @@
                     // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下)
                     if (ObjectUtils.isNotEmpty(attendance) && (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS))) {
                         // 开始打卡结果
-                        if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
+                        if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
                             attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
                             attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
                             attendance.setActualWorkStartTime(null);
                         }
                         // 结束打卡结果
-                        if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
+                        if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
                             attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
                             attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
                             attendance.setActualWorkEndTime(null);
@@ -247,7 +247,8 @@
                     }
                     // 修改考勤打卡状态
                     if (ObjectUtils.isNotEmpty(attendance)) {
-                        attendance = updateRecord(user, attendance, true, attendDate);
+                        getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), true);
+//                        attendance = updateRecord(user, attendance, true, attendDate);
                         attendanceRepository.save(attendance);
                     }
                 }
@@ -360,7 +361,8 @@
                     }
                     // 修改考勤打卡状态
                     if (ObjectUtils.isNotEmpty(attendance)) {
-                        attendance = updateRecord(user, attendance, false, attendDate);
+                        getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), false);
+//                        attendance = updateRecord(user, attendance, false, attendDate);
                         attendanceRepository.save(attendance);
                     }
                 }
@@ -442,20 +444,35 @@
                 Double outDuration = new Double(0.00);
                 Double outStartDuration = new Double(0.00);// 考勤按钮的时长
                 Double outEndDuration = new Double(0.00);// 考勤按钮的时长
-                for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
-                    // attendDate不等于null 说明是考勤信息按钮
-                    if(ObjectUtils.isNotEmpty(attendDate)){
+                if(ObjectUtils.isNotEmpty(attendDate)){
+                    for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
                         // 上午时长、下午时长
-                        outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
-                        outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
-                        //调用方法修改考勤打卡状态
-                        updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
-                    }else{
-                        // 上午or下午总时长
-                        outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
-                        updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
+                        outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
+                        outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
                     }
+                    //调用方法修改考勤打卡状态
+                    updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
+                }else{
+                    for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
+                        // 上午or下午总时长
+                        outDuration += getDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance, day);
+                    }
+                    updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
                 }
+//                for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
+//                    // attendDate不等于null 说明是考勤信息按钮
+//                    if(ObjectUtils.isNotEmpty(attendDate)){
+//                        // 上午时长、下午时长
+//                        outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
+//                        outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
+//                        //调用方法修改考勤打卡状态
+//                        updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
+//                    }else{
+//                        // 上午or下午总时长
+//                        outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
+//                        updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
+//                    }
+//                }
             }else{
                 if(ObjectUtils.isNotEmpty(attendanceBusinessTravel)){
                     // attendDate不等于null 说明是考勤信息按钮
@@ -475,32 +492,58 @@
         }else{
             // 查询考勤外出表
             List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime());
-            for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
-                // attendDate不等于null 说明是考勤信息按钮
-                if(ObjectUtils.isNotEmpty(attendDate)){
+            // attendDate不等于null 说明是考勤信息按钮
+            if(ObjectUtils.isNotEmpty(attendDate)){
+                for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
                     // 上午时长、下午时长
                     leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
                     leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
-                }else{
-                    // 上午or下午总时长
-                    leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
                 }
-            }
-            for(AttendanceLeave attendanceLeave : attendanceLeaveList){
-                // attendDate不等于null 说明是考勤信息按钮
-                if(ObjectUtils.isNotEmpty(attendDate)){
+                for(AttendanceLeave attendanceLeave : attendanceLeaveList){
                     // 上午总时长、下午总时长
                     leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
                     leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
-                    //调用方法修改考勤打卡状态
-                    updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
-                }else{
+                }
+                //调用方法修改考勤打卡状态
+                updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
+            } else {
+                for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
+                    // 上午or下午总时长
+                    leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
+                }
+                for(AttendanceLeave attendanceLeave : attendanceLeaveList){
                     // 上午or下午总时长
                     leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
-                    //调用方法修改考勤打卡状态
-                    updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
                 }
+                //调用方法修改考勤打卡状态
+                updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
             }
+//            for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
+//                // attendDate不等于null 说明是考勤信息按钮
+//                if(ObjectUtils.isNotEmpty(attendDate)){
+//                    // 上午时长、下午时长
+//                    leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
+//                    leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
+//                }else{
+//                    // 上午or下午总时长
+//                    leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
+//                }
+//            }
+//            for(AttendanceLeave attendanceLeave : attendanceLeaveList){
+//                // attendDate不等于null 说明是考勤信息按钮
+//                if(ObjectUtils.isNotEmpty(attendDate)){
+//                    // 上午总时长、下午总时长
+//                    leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
+//                    leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
+//                    //调用方法修改考勤打卡状态
+//                    updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
+//                }else{
+//                    // 上午or下午总时长
+//                    leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
+//                    //调用方法修改考勤打卡状态
+//                    updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
+//                }
+//            }
         }
     }
 
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java
index babbb61..2789d32 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java
@@ -1,283 +1,284 @@
-/*
- *  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.system.service.impl;
-
-import me.zhengjie.exception.BadRequestException;
-import me.zhengjie.modules.system.domain.SysLevel;
-import me.zhengjie.modules.system.domain.SysUserLevelOther;
-import me.zhengjie.modules.system.domain.User;
-import me.zhengjie.modules.system.repository.SysLevelRepository;
-import me.zhengjie.modules.system.repository.UserRepository;
-import me.zhengjie.modules.treatment.domain.CmnLevel;
-import me.zhengjie.modules.treatment.repository.CmnLevelRepository;
-import me.zhengjie.utils.*;
-import lombok.RequiredArgsConstructor;
-import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository;
-import me.zhengjie.modules.system.service.SysUserLevelOtherService;
-import me.zhengjie.modules.system.service.dto.SysUserLevelOtherDto;
-import me.zhengjie.modules.system.service.dto.SysUserLevelOtherQueryCriteria;
-import me.zhengjie.modules.system.service.mapstruct.SysUserLevelOtherMapper;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.IOException;
-import javax.servlet.http.HttpServletResponse;
-import java.util.function.Function;
-
-/**
- * @author 赵士淞
- * @website https://eladmin.vip
- * @description 服务实现
- * @date 2022-12-26
- **/
-@Service
-@RequiredArgsConstructor
-public class SysUserLevelOtherServiceImpl implements SysUserLevelOtherService {
-
-    private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
-    private final SysUserLevelOtherMapper sysUserLevelOtherMapper;
-    private final UserRepository userRepository;
-    private final SysLevelRepository sysLevelRepository;
-    private final CmnLevelRepository cmnLevelRepository;
-
-    @Override
-    public Map<String, Object> queryAll(SysUserLevelOtherQueryCriteria criteria, Pageable pageable) {
-        Page<SysUserLevelOther> page = sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
-        // 将实体类转换为DTO(重写)
-        Function<SysUserLevelOther, SysUserLevelOtherDto> func = new Function<SysUserLevelOther, SysUserLevelOtherDto>() {
-            @Override
-            public SysUserLevelOtherDto apply(SysUserLevelOther t) {
-                // 将实体类转换成DTO
-                SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherMapper.toDto(t);
-                // 根据用户ID查询用户信息
-                User user = userRepository.findById(sysUserLevelOtherDto.getUserId()).orElseGet(User::new);
-                ValidationUtil.isNull(user.getId(), "User", "id", sysUserLevelOtherDto.getUserId());
-                // 用户昵称
-                sysUserLevelOtherDto.setUserNickName(user.getNickName());
-                // 根据级别ID查询级别信息
-                CmnLevel sysLevel = cmnLevelRepository.findById(sysUserLevelOtherDto.getLevelId()).orElseGet(CmnLevel::new);
-                ValidationUtil.isNull(sysLevel.getId(), "SysLevel", "id", sysUserLevelOtherDto.getLevelId());
-                // 级别名称
-                sysUserLevelOtherDto.setLevelName(sysLevel.getName());
-                // 返回处理好的DTO
-                return sysUserLevelOtherDto;
-            }
-        };
-        return PageUtil.toPage(page.map(func));
-    }
-
-    @Override
-    public List<SysUserLevelOtherDto> queryAll(SysUserLevelOtherQueryCriteria criteria) {
-        return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
-    }
-
-    @Override
-    public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria) {
-
-        // 明年月初
-        // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期
-        SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7) );
-        if (sysUserLevelOther == null) {
-            throw new BadRequestException("没有获取到当前员工的级别信息!");
-        }
-
-        return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
-    }
-
-    @Override
-    @Transactional
-    public SysUserLevelOtherDto findById(Long id) {
-        SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findById(id).orElseGet(SysUserLevelOther::new);
-        ValidationUtil.isNull(sysUserLevelOther.getId(), "SysUserLevelOther", "id", id);
-        return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public SysUserLevelOtherDto create(SysUserLevelOther resources) throws Exception {
-//        // 查询旧用户级别其他
-//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
-//        // 判断旧用户级别其他是否为空
-//        if (oldSysUserLevelOther != null) {
-//            // 旧日期字符串
-//            String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10);
-//            // 新日期字符串
-//            String newDateString = resources.getStartDate().toString().substring(0,10);
-//            // 判断新、旧日期字符串
-//            if (oldDateString.equals(newDateString)) {
-//                throw new BadRequestException("每天只能调整一次用户级别其他,请更换日期再试!");
-//            }
-//            if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) {
-//                throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
-//            }
-//            // 创建Calendar实例
-//            Calendar previousCalendar = Calendar.getInstance();
-//            // 设置新日期时间
-//            previousCalendar.setTime(resources.getStartDate());
-//            // 设置前一天时间
-//            previousCalendar.add(Calendar.DATE, -1);
-//            // 旧用户级别其他
-//            oldSysUserLevelOther.setEndDate(new Timestamp(previousCalendar.getTime().getTime()));
-//            // 保存
-//            sysUserLevelOtherRepository.save(oldSysUserLevelOther);
-//        }
-
-//        // 查询旧用户级别其他(新)
-//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
-//        // 判断旧用户级别其他是否为空
-//        if (oldSysUserLevelOther != null) {
-//            // 旧日期字符串
-//            String oldDateString = oldSysUserLevelOther.getYearMonth();
-//            // 新日期字符串
-//            String newDateString = resources.getYearMonth();
-//            if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) {
-//                throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
-//            }
-//        }
-        // 保存
-        return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources));
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void update(SysUserLevelOther resources) throws Exception {
-//        // 查询旧用户级别其他
-//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
-//        // 判断旧用户级别其他是否为空
-//        if (oldSysUserLevelOther != null) {
-//            // 判断修改的是否是最新履历
-//            if (oldSysUserLevelOther.getId() != resources.getId()) {
-//                throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
-//            }
-//            // 旧日期字符串
-//            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 (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) {
-//                // 复制
-//                oldSysUserLevelOther.copy(resources);
-//                // 保存
-//                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
-//            } else {
-//                // 新用户级别其他
-//                resources.setId(null);
-//                resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime()));
-//                // 保存
-//                sysUserLevelOtherRepository.save(resources);
-//                // 设置前一天时间
-//                nowCalendar.add(Calendar.DATE, -1);
-//                // 旧用户级别其他
-//                oldSysUserLevelOther.setEndDate(new Timestamp(nowCalendar.getTime().getTime()));
-//                // 保存
-//                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
-//            }
-//        } else {
-//            throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
-//        }
-
-        // 查询旧用户级别其他(新)
-        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
-        // 判断旧用户级别其他是否为空
-        if (oldSysUserLevelOther != null) {
-            // 判断修改的是否是最新履历
-            if (oldSysUserLevelOther.getId() != resources.getId()) {
-                throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
-            }
-            // 旧日期字符串
-            String oldDateString = oldSysUserLevelOther.getYearMonth();
-            // 获取当前日期
-            Date nowDate = new Date();
-            // 创建Calendar实例
-            Calendar nowCalendar = Calendar.getInstance();
-            // 设置当前时间
-            nowCalendar.setTime(nowDate);
-            // 新日期字符串
-            String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 7);
-            // 判断新、旧日期字符串
-//            if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(nowDateString).getTime()) {
-                // 复制
-                oldSysUserLevelOther.copy(resources);
-                // 保存
-                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
-//            }
-        } else {
-            throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
-        }
-    }
-
-    @Override
-    public void deleteAll(Long[] ids) {
-        for (Long id : ids) {
-            sysUserLevelOtherRepository.deleteById(id);
-        }
-    }
-
-    @Override
-    public void download(List<SysUserLevelOtherDto> all, HttpServletResponse response) throws IOException {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (SysUserLevelOtherDto sysUserLevelOther : all) {
-            String nickName = sysUserLevelOther.getUserId() != null ? userRepository.findById(sysUserLevelOther.getUserId()).orElseGet(User::new).getNickName() : "";
-            String levelName = sysUserLevelOther.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelOther.getLevelId()).orElseGet(SysLevel::new).getName() : "";
-            Map<String, Object> map = new LinkedHashMap<>();
-            map.put("用户昵称", nickName);
-            map.put("级别名称", levelName);
-            map.put("开始日期", sysUserLevelOther.getStartDate());
-            map.put("结束日期", sysUserLevelOther.getEndDate());
-            map.put("个人业绩比例", sysUserLevelOther.getPersonalPerformanceProportion());
-            map.put("年假天数", sysUserLevelOther.getAnnualLeaveDays());
-            map.put("备注", sysUserLevelOther.getRemarks());
-            map.put("创建者", sysUserLevelOther.getCreateBy());
-            map.put("创建时间", sysUserLevelOther.getCreateTime());
-            map.put("更新者", sysUserLevelOther.getUpdateBy());
-            map.put("更新时间", sysUserLevelOther.getUpdateTime());
-            list.add(map);
-        }
-        FileUtil.downloadExcel(list, response);
-    }
-
-    /**
-     * 查询旧用户级别其他
-     *
-     * @param userId
-     * @return
-     */
-    private SysUserLevelOther selectOldUserLevelOther(Long userId) {
-//        // 旧用户级别其他
-//        SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId);
-
-        // 旧用户级别其他(新)
-        SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findByNewUserId(userId);
-
-        // 判断旧用户级别其他是否为空
-        if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) {
-            return oldSysUserLevelOther;
-        } else {
-            return null;
-        }
-    }
+/*
+ *  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.system.service.impl;
+
+import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.system.domain.SysLevel;
+import me.zhengjie.modules.system.domain.SysUserLevelOther;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.repository.SysLevelRepository;
+import me.zhengjie.modules.system.repository.UserRepository;
+import me.zhengjie.modules.treatment.domain.CmnLevel;
+import me.zhengjie.modules.treatment.repository.CmnLevelRepository;
+import me.zhengjie.utils.*;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository;
+import me.zhengjie.modules.system.service.SysUserLevelOtherService;
+import me.zhengjie.modules.system.service.dto.SysUserLevelOtherDto;
+import me.zhengjie.modules.system.service.dto.SysUserLevelOtherQueryCriteria;
+import me.zhengjie.modules.system.service.mapstruct.SysUserLevelOtherMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.function.Function;
+
+/**
+ * @author 赵士淞
+ * @website https://eladmin.vip
+ * @description 服务实现
+ * @date 2022-12-26
+ **/
+@Service
+@RequiredArgsConstructor
+public class SysUserLevelOtherServiceImpl implements SysUserLevelOtherService {
+
+    private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
+    private final SysUserLevelOtherMapper sysUserLevelOtherMapper;
+    private final UserRepository userRepository;
+    private final SysLevelRepository sysLevelRepository;
+    private final CmnLevelRepository cmnLevelRepository;
+
+    @Override
+    public Map<String, Object> queryAll(SysUserLevelOtherQueryCriteria criteria, Pageable pageable) {
+        Page<SysUserLevelOther> page = sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
+        // 将实体类转换为DTO(重写)
+        Function<SysUserLevelOther, SysUserLevelOtherDto> func = new Function<SysUserLevelOther, SysUserLevelOtherDto>() {
+            @Override
+            public SysUserLevelOtherDto apply(SysUserLevelOther t) {
+                // 将实体类转换成DTO
+                SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherMapper.toDto(t);
+                // 根据用户ID查询用户信息
+                User user = userRepository.findById(sysUserLevelOtherDto.getUserId()).orElseGet(User::new);
+                ValidationUtil.isNull(user.getId(), "User", "id", sysUserLevelOtherDto.getUserId());
+                // 用户昵称
+                sysUserLevelOtherDto.setUserNickName(user.getNickName());
+                // 根据级别ID查询级别信息
+                CmnLevel sysLevel = cmnLevelRepository.findById(sysUserLevelOtherDto.getLevelId()).orElseGet(CmnLevel::new);
+                ValidationUtil.isNull(sysLevel.getId(), "SysLevel", "id", sysUserLevelOtherDto.getLevelId());
+                // 级别名称
+                sysUserLevelOtherDto.setLevelName(sysLevel.getName());
+                // 返回处理好的DTO
+                return sysUserLevelOtherDto;
+            }
+        };
+        return PageUtil.toPage(page.map(func));
+    }
+
+    @Override
+    public List<SysUserLevelOtherDto> queryAll(SysUserLevelOtherQueryCriteria criteria) {
+        return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
+    }
+
+    @Override
+    public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria) {
+
+        // 明年月初
+        // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期
+        SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7) );
+        if (sysUserLevelOther == null) {
+            throw new BadRequestException("没有获取到当前员工的级别信息!");
+        }
+
+        return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
+    }
+
+    @Override
+    @Transactional
+    public SysUserLevelOtherDto findById(Long id) {
+        SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findById(id).orElseGet(SysUserLevelOther::new);
+        ValidationUtil.isNull(sysUserLevelOther.getId(), "SysUserLevelOther", "id", id);
+        return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public SysUserLevelOtherDto create(SysUserLevelOther resources) throws Exception {
+//        // 查询旧用户级别其他
+//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
+//        // 判断旧用户级别其他是否为空
+//        if (oldSysUserLevelOther != null) {
+//            // 旧日期字符串
+//            String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10);
+//            // 新日期字符串
+//            String newDateString = resources.getStartDate().toString().substring(0,10);
+//            // 判断新、旧日期字符串
+//            if (oldDateString.equals(newDateString)) {
+//                throw new BadRequestException("每天只能调整一次用户级别其他,请更换日期再试!");
+//            }
+//            if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) {
+//                throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
+//            }
+//            // 创建Calendar实例
+//            Calendar previousCalendar = Calendar.getInstance();
+//            // 设置新日期时间
+//            previousCalendar.setTime(resources.getStartDate());
+//            // 设置前一天时间
+//            previousCalendar.add(Calendar.DATE, -1);
+//            // 旧用户级别其他
+//            oldSysUserLevelOther.setEndDate(new Timestamp(previousCalendar.getTime().getTime()));
+//            // 保存
+//            sysUserLevelOtherRepository.save(oldSysUserLevelOther);
+//        }
+
+//        // 查询旧用户级别其他(新)
+//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
+//        // 判断旧用户级别其他是否为空
+//        if (oldSysUserLevelOther != null) {
+//            // 旧日期字符串
+//            String oldDateString = oldSysUserLevelOther.getYearMonth();
+//            // 新日期字符串
+//            String newDateString = resources.getYearMonth();
+//            if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) {
+//                throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
+//            }
+//        }
+        // 保存
+        resources.setStartDate(new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse(resources.getYearMonth() + "-01").getTime()));
+        return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(SysUserLevelOther resources) throws Exception {
+//        // 查询旧用户级别其他
+//        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
+//        // 判断旧用户级别其他是否为空
+//        if (oldSysUserLevelOther != null) {
+//            // 判断修改的是否是最新履历
+//            if (oldSysUserLevelOther.getId() != resources.getId()) {
+//                throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
+//            }
+//            // 旧日期字符串
+//            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 (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) {
+//                // 复制
+//                oldSysUserLevelOther.copy(resources);
+//                // 保存
+//                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
+//            } else {
+//                // 新用户级别其他
+//                resources.setId(null);
+//                resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime()));
+//                // 保存
+//                sysUserLevelOtherRepository.save(resources);
+//                // 设置前一天时间
+//                nowCalendar.add(Calendar.DATE, -1);
+//                // 旧用户级别其他
+//                oldSysUserLevelOther.setEndDate(new Timestamp(nowCalendar.getTime().getTime()));
+//                // 保存
+//                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
+//            }
+//        } else {
+//            throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
+//        }
+
+        // 查询旧用户级别其他(新)
+        SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
+        // 判断旧用户级别其他是否为空
+        if (oldSysUserLevelOther != null) {
+            // 判断修改的是否是最新履历
+            if (oldSysUserLevelOther.getId() != resources.getId()) {
+                throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
+            }
+            // 旧日期字符串
+            String oldDateString = oldSysUserLevelOther.getYearMonth();
+            // 获取当前日期
+            Date nowDate = new Date();
+            // 创建Calendar实例
+            Calendar nowCalendar = Calendar.getInstance();
+            // 设置当前时间
+            nowCalendar.setTime(nowDate);
+            // 新日期字符串
+            String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 7);
+            // 判断新、旧日期字符串
+//            if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(nowDateString).getTime()) {
+                // 复制
+                oldSysUserLevelOther.copy(resources);
+                // 保存
+                sysUserLevelOtherRepository.save(oldSysUserLevelOther);
+//            }
+        } else {
+            throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
+        }
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long id : ids) {
+            sysUserLevelOtherRepository.deleteById(id);
+        }
+    }
+
+    @Override
+    public void download(List<SysUserLevelOtherDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (SysUserLevelOtherDto sysUserLevelOther : all) {
+            String nickName = sysUserLevelOther.getUserId() != null ? userRepository.findById(sysUserLevelOther.getUserId()).orElseGet(User::new).getNickName() : "";
+            String levelName = sysUserLevelOther.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelOther.getLevelId()).orElseGet(SysLevel::new).getName() : "";
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("用户昵称", nickName);
+            map.put("级别名称", levelName);
+            map.put("开始日期", sysUserLevelOther.getStartDate());
+            map.put("结束日期", sysUserLevelOther.getEndDate());
+            map.put("个人业绩比例", sysUserLevelOther.getPersonalPerformanceProportion());
+            map.put("年假天数", sysUserLevelOther.getAnnualLeaveDays());
+            map.put("备注", sysUserLevelOther.getRemarks());
+            map.put("创建者", sysUserLevelOther.getCreateBy());
+            map.put("创建时间", sysUserLevelOther.getCreateTime());
+            map.put("更新者", sysUserLevelOther.getUpdateBy());
+            map.put("更新时间", sysUserLevelOther.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+
+    /**
+     * 查询旧用户级别其他
+     *
+     * @param userId
+     * @return
+     */
+    private SysUserLevelOther selectOldUserLevelOther(Long userId) {
+//        // 旧用户级别其他
+//        SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId);
+
+        // 旧用户级别其他(新)
+        SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findByNewUserId(userId);
+
+        // 判断旧用户级别其他是否为空
+        if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) {
+            return oldSysUserLevelOther;
+        } else {
+            return null;
+        }
+    }
 }
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
index b0e49ce..592860c 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -809,7 +809,7 @@
         }
         returnData.put("onDutyDays", numDay);
         // 剩余年假
-        Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
+        Double yearTimes = attendanceLeaveService.getYearTimeLength(userId, sdfDate.substring(0, 4));
         returnData.put("annualLeave", yearTimes);
         // 查询当月的补卡记录的条数
         Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0, 7));
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
index 752102b..731e09d 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
@@ -176,18 +176,29 @@
         Map<String, Double> attendanceBusinessTravelMap = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(AttendanceBusinessTravel::getCategory, Collectors.summingDouble(AttendanceBusinessTravel::getTravelDuration)));
 
         BigDecimal travelSubsidy = new BigDecimal(0.0);
-        // 出差补助金
-        attendanceBusinessTravelMap.forEach((key, value) -> {
-            if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
+        for (Map.Entry<String, Double> entry : attendanceBusinessTravelMap.entrySet()) {
+            if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
                 // 出差补助金
                 SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
-                travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
-            } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
+                travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * sysConfigProportion.getProportion()));
+            } else if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
                 // 客户现场补助金
 //                SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
-                travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
+                travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * 30)); // 按30元/天计算 TODO 待调整
             }
-        });
+        }
+//        // 出差补助金
+//        attendanceBusinessTravelMap.forEach((key, value) -> {
+//            if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
+//                // 出差补助金
+//                SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
+//                travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
+//            } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
+//                // 客户现场补助金
+////                SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
+//                travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
+//            }
+//        });
         return travelSubsidy.doubleValue();
     }
 

--
Gitblit v1.9.3