yao-zengchun
2026-01-08 c7ed489cee1127e3b4f96edf74e24b01c065ac2a
Merge branch 'wcd' of http://192.168.1.110:5678/r/pms-upgrade into wcd
8 files added
20 files modified
984 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java 72 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java 23 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceBusinessTravelRepository.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceGoOutRepository.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceOvertimeRepository.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java 87 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java 48 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java 37 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java 108 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java 140 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java 18 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/NewAttendanceServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java 7 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java 70 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/NewSalaryServiceImpl.java 60 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java 26 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/utils/DateUtil.java 56 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/resources/config/application-dev.yml 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/resources/config/application.yml 2 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/dashboard/PanelGroup.vue 24 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AnnualLeaveRecord.java
New file
@@ -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));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
@@ -8,6 +8,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Data
@AllArgsConstructor
@@ -77,4 +78,26 @@
        return result;
    }
    /**
     * 判断与另一个时间区间是否有交集
     */
    public Boolean overlapsWith(Calculate otherCalculate) {
        Objects.requireNonNull(otherCalculate, "另一个时间区间不能为null");
        return !this.end.isBefore(otherCalculate.start) && !otherCalculate.end.isBefore(this.start);
    }
    /**
     * 获取交集区间(没有返回null)
     */
    public Calculate getOverlap(Calculate other) {
        if (!overlapsWith(other)) {
            return null;
        }
        LocalDateTime overlapStart = this.start.isAfter(other.start) ? this.start : other.start;
        LocalDateTime overlapEnd = this.end.isBefore(other.end) ? this.end : other.end;
        return new Calculate(overlapStart, overlapEnd);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AnnualLeaveRecordRepository.java
New file
@@ -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> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceBusinessTravelRepository.java
@@ -52,10 +52,6 @@
    @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time <= ?3 and travel_end_time >= ?2 and approval_status in ('business_approve_status_agree')", nativeQuery = true)
    List<AttendanceBusinessTravel> findByUserAndSEDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
    // 查询出差天数
    @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time >= ?2 and travel_end_time < ?3 and approval_status in ('business_approve_status_agree')", nativeQuery = true)
    List<AttendanceBusinessTravel> findByUserIdAndYearMonth(Long userId, LocalDateTime startDate, LocalDateTime endDate);
    // 查询某天出差总时长
    @Query(value = "SELECT COALESCE(SUM(travel_duration), 0) FROM attendance_business_travel WHERE user_id = ?2 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND id != ?3 AND travel_start_time LIKE CONCAT(?1, '%')", nativeQuery = true)
    BigDecimal countTravelDuration(String date, Long userId, Long id);
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceGoOutRepository.java
@@ -42,6 +42,6 @@
    List<AttendanceGoOut> checkCreateUpdateTime(String startTime, String endTime, Long userId, Set<Long> ids);
    // 查询外出记录
    @Query(value = "SELECT * from attendance_go_out where user_id = ?1 and out_start_time <= ?3 and out_end_time >= ?2 and approval_status in ('go_out_approve_status_agree')", nativeQuery = true)
    @Query(value = "SELECT * FROM attendance_go_out WHERE user_id = ?1 AND out_start_time <= ?3 AND out_end_time >= ?2 AND approval_status IN ('go_out_approve_status_agree')", nativeQuery = true)
    List<AttendanceGoOut> findByUserAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceOvertimeRepository.java
@@ -31,10 +31,10 @@
**/
public interface AttendanceOvertimeRepository extends JpaRepository<AttendanceOvertime, Long>, JpaSpecificationExecutor<AttendanceOvertime> {
    @Query(value = "SELECT SUM(overtime_duration) from attendance_overtime where user_id = ?1 and overtime_start_time >= ?2 and overtime_end_time < ?3 and approval_status in ('overtime_pass')", nativeQuery = true)
    @Query(value = "SELECT SUM(overtime_duration) FROM attendance_overtime WHERE user_id = ?1 AND overtime_start_time <= ?3 AND overtime_end_time >= ?2 AND approval_status IN ('overtime_pass')", nativeQuery = true)
    Double findByUserIdAndYearMonth(Long userId, LocalDateTime startDate, LocalDateTime endDate);
    @Query(value = "SELECT * from attendance_overtime where user_id = ?1 and overtime_start_time >= ?2 and overtime_end_time < ?3 and approval_status in ('overtime_pass')", nativeQuery = true)
    @Query(value = "SELECT * FROM attendance_overtime WHERE user_id = ?1 AND overtime_start_time <= ?3 AND overtime_end_time >= ?2 AND approval_status IN ('overtime_pass')", nativeQuery = true)
    List<AttendanceOvertime> findByUserIdAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
    List<AttendanceOvertime> findByUserId(Long userId);
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AnnualLeaveRecordController.java
New file
@@ -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);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AnnualLeaveRecordService.java
New file
@@ -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;
}
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;
    /**
     *获取剩余年假
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordDto.java
New file
@@ -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;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AnnualLeaveRecordQueryCriteria.java
New file
@@ -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;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AnnualLeaveRecordServiceImpl.java
New file
@@ -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);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -187,7 +187,7 @@
                }
                LocalDateTime goOutStartTime = localDate.atStartOfDay();
                LocalDateTime goOutEndTime = localDate.atTime(LocalTime.MAX);
                LocalDateTime goOutEndTime = localDate.atTime(23, 59, 59);
                if (localDate.equals(endDate)) {
                    goOutEndTime = localDate.atTime(endTime);
                }
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,92 @@
     * 获取用户年假剩余时长
     */
    @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) {
                            // 查询上上年度年假记录
                            AnnualLeaveRecordQueryCriteria beforeLastCriteria = new AnnualLeaveRecordQueryCriteria();
                            beforeLastCriteria.setUserId(userId);
                            beforeLastCriteria.setYear(String.valueOf(Integer.parseInt(lastYear) - 1));
                            AnnualLeaveRecord beforeLastAnnualLeaveRecord = annualLeaveRecordRepository.findOne((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, beforeLastCriteria, criteriaBuilder)).orElseGet(AnnualLeaveRecord::new);
                            // 上年度使用年假时长
                            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 baseLastYearTime = new BigDecimal(lastSysUserLevelOther.getAnnualLeaveDays() == null ? 0 : lastSysUserLevelOther.getAnnualLeaveDays() * 8);
                            BigDecimal surplusTime = baseLastYearTime.add(Optional.ofNullable(beforeLastAnnualLeaveRecord.getSurplusHour()).map(BigDecimal::valueOf).orElse(BigDecimal.ZERO)).subtract(usedLastYearTime == null ? BigDecimal.ZERO : new BigDecimal(usedLastYearTime)).min(baseLastYearTime);
                            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();
    }
    /**
@@ -561,11 +594,14 @@
        LocalDateTime endLocalDateTime = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
        // 因换休3个月后会被结算,只能统计未结算的,仅当前时间3个月内(只参考月份)的可统计。
        LocalDateTime nowLocalDateTime = localDateTime.now().minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
        if (nowLocalDateTime.isBefore(startLocalDateTime) || nowLocalDateTime.isAfter(endLocalDateTime)) {
            return Double.valueOf(0);
        LocalDateTime currentStartLocalDateTime = localDateTime.now().minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
        LocalDateTime currentEndLocalDateTime = localDateTime.now().withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
        Calculate finalCalculate = new Calculate(currentStartLocalDateTime, currentEndLocalDateTime).getOverlap(new Calculate(startLocalDateTime, endLocalDateTime));
        if (finalCalculate != null) {
            startLocalDateTime = finalCalculate.getStart();
            endLocalDateTime = finalCalculate.getEnd();
        } else {
            startLocalDateTime = nowLocalDateTime;
            return Double.valueOf(0);
        }
        // 查询可用调休申请
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());
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -520,14 +520,14 @@
        );
        // 外出信息
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, startOfDate, endOfDate);
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
        attendanceParts.addAll(
                attendanceGoOutList.stream().map(attendanceGoOut ->
                        new Calculate(attendanceGoOut.getOutStartTime().toLocalDateTime(), attendanceGoOut.getOutEndTime().toLocalDateTime())
                ).collect(Collectors.toList())
        );
        // 周末加班
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, startOfDate, endOfDate);
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
        attendanceParts.addAll(
                attendanceOvertimeList.stream().map(attendanceOvertime ->
                        new Calculate(attendanceOvertime.getOvertimeStartTime().toLocalDateTime(), attendanceOvertime.getOvertimeEndTime().toLocalDateTime())
@@ -601,7 +601,7 @@
            return 0.0D;
        }
        // 加班信息
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate));
        return sysConfigHolidayMonthList.stream()
                .filter(sysConfigHoliday -> Constant.DATE_TYPE_LEGAL_HOLIDAYS.equals(sysConfigHoliday.getDateType()))
@@ -627,7 +627,7 @@
        List<SysConfigHoliday> sysConfigHolidayMonthList = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,sysConfigHolidayQueryCriteria,criteriaBuilder));
        // 加班信息
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate));
        Map<LocalDate, String> sysConfigHolidayMap = sysConfigHolidayMonthList.stream().collect(Collectors.toMap(sch -> sch.getHolidayDate().toLocalDateTime().toLocalDate(), SysConfigHoliday::getDateType));
        return attendanceOvertimeList.stream().mapToDouble(ao -> {
@@ -690,15 +690,11 @@
            List<Calculate> breakParts = new ArrayList<>();
            breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30)));
            // 查询调休(因工作日加班过0点加班时间可转调休的规定,部分调休与加班时间重复,需要扣除这部分时间,具体可咨询Lief)
            AttendanceOvertimeQueryCriteria aoCriteria = new AttendanceOvertimeQueryCriteria();
            aoCriteria.setUserId(criteria.getUserId());
            aoCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startOfDate), Timestamp.valueOf(endOfDate)));
            aoCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
            List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, aoCriteria, criteriaBuilder));
            List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            breakParts.addAll(attendanceOvertimeList.stream().map(ao -> new Calculate(ao.getOvertimeStartTime().toLocalDateTime(), ao.getOvertimeEndTime().toLocalDateTime())).collect(Collectors.toList()));
            // 外出信息
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            attendanceParts.addAll(
                    attendanceGoOutList.stream().map(attendanceGoOut -> {
                        LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
@@ -855,7 +851,7 @@
            );
            // 外出信息
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            attendanceParts.addAll(
                    attendanceGoOutList.stream().map(attendanceGoOut -> {
                        LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/NewAttendanceServiceImpl.java
@@ -364,14 +364,14 @@
        );
        // 外出信息
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, startOfDate, endOfDate);
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
        attendanceParts.addAll(
                attendanceGoOutList.stream().map(attendanceGoOut ->
                        new Calculate(attendanceGoOut.getOutStartTime().toLocalDateTime(), attendanceGoOut.getOutEndTime().toLocalDateTime())
                ).collect(Collectors.toList())
        );
        // 周末加班
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, startOfDate, endOfDate);
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
        attendanceParts.addAll(
                attendanceOvertimeList.stream().map(attendanceOvertime ->
                        new Calculate(attendanceOvertime.getOvertimeStartTime().toLocalDateTime(), attendanceOvertime.getOvertimeEndTime().toLocalDateTime())
@@ -444,7 +444,7 @@
            return 0.0D;
        }
        // 加班信息
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate));
        return sysConfigHolidayMonthList.stream()
                .filter(sysConfigHoliday -> Constant.DATE_TYPE_LEGAL_HOLIDAYS.equals(sysConfigHoliday.getDateType()))
@@ -504,7 +504,7 @@
            breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30)));
            // 外出信息
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            attendanceParts.addAll(
                    attendanceGoOutList.stream().map(attendanceGoOut -> {
                        LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
@@ -628,7 +628,7 @@
            );
            // 外出信息
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
            List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            attendanceParts.addAll(
                    attendanceGoOutList.stream().map(attendanceGoOut -> {
                        LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AnnualLeaveRecordMapper.java
New file
@@ -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> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/AttendanceMonthTalkServiceImpl.java
@@ -1,27 +1,23 @@
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;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.DateUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
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;
@@ -138,7 +134,7 @@
        List<AttendanceMonth> insertData = new ArrayList<>();
        for (AttendanceMonth value : info.values()) {
            // 查询当月外出
            List<AttendanceGoOut> goOutList = attendanceGoOutRepository.findByUserAndDate(value.getUserId(), startTime, endTime);
            List<AttendanceGoOut> goOutList = attendanceGoOutRepository.findByUserAndDate(value.getUserId(), DateUtil.parseAttStartTime(startTime), DateUtil.parseAttEndTime(endTime));
            int goOutNumber = goOutList.size();
            // 外出次数
            value.setGoOutNumber(Long.valueOf(goOutNumber));
@@ -225,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());
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/DingTalkServiceImpl.java
@@ -16,6 +16,7 @@
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.SysRosteringRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.DateUtil;
import me.zhengjie.utils.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
@@ -427,7 +428,7 @@
            }
        }
        // 查询外出表o
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime()));
        for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
            // 上午/下午
            if (attendanceGoOut.getOutStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) {
@@ -453,9 +454,9 @@
        // 查询考勤请假表
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), startDate.toLocalDateTime(), endDate.toLocalDateTime());
        // 查询考勤出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(999));
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(0));
        // 查询考勤外出表
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime()));
        // TODO:统计规则请假优先于出差优先于外出
        if (attendanceGoOutList.size() > 0) {
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -40,6 +40,7 @@
import me.zhengjie.modules.treatment.domain.UserLevelWage;
import me.zhengjie.modules.treatment.repository.UserInsuranceRepository;
import me.zhengjie.modules.treatment.repository.UserLevelWageRepository;
import me.zhengjie.utils.DateUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.StringUtils;
import me.zhengjie.modules.weixin.cp.api.WxCpOaWeDocSmartsheetService;
@@ -519,7 +520,7 @@
            }
        }
        // 查询外出表
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime()));
        for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
            // 上午/下午
            if (attendanceGoOut.getOutStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) {
@@ -546,46 +547,77 @@
        // 查询考勤请假表
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), startDate.toLocalDateTime(), endDate.toLocalDateTime());
        // 查询考勤出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(999));
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(0));
        // 查询考勤外出表
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getAttendanceDate().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getAttendanceDate().toLocalDateTime()));
        Double outStartDuration = new Double(0.00); // 上午时长
        Double outEndDuration = new Double(0.00); // 下午时长
        Double bussStartDuration = new Double(0.00); // 上午时长
        Double bussEndDuration = new Double(0.00); // 下午时长
        Double leaveStartDuration = new Double(0.00); // 上午时长
        Double leaveEndDuration = new Double(0.00); // 下午时长
        Map<Timestamp, String> startTimeMap = new HashMap<>();
        Map<Timestamp, String> endTimeMap = new HashMap<>();
        // TODO:统计规则请假优先于出差优先于外出
        if (attendanceGoOutList.size() > 0) {
            // 统计外出
            Double outStartDuration = new Double(0.00); // 上午时长
            Double outEndDuration = new Double(0.00); // 下午时长
            for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
                // 上午时长、下午时长
                outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
                outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
                startTimeMap.put(attendanceGoOut.getOutStartTime(), Constant.ATTENDANCE_STATE_GOOUT);
                endTimeMap.put(attendanceGoOut.getOutEndTime(), Constant.ATTENDANCE_STATE_GOOUT);
            }
            // 调用方法修改考勤打卡状态
            updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_GOOUT, day, outStartDuration, outEndDuration);
        }
        if (attendanceBusinessTravelList.size() > 0) {
            // 统计出差
            Double bussStartDuration = new Double(0.00); // 上午时长
            Double bussEndDuration = new Double(0.00); // 下午时长
            for (AttendanceBusinessTravel attendanceBusinessTravel : attendanceBusinessTravelList) {
                // 上午时长、下午时长
                bussStartDuration += getStartDuration(attendanceBusinessTravel.getTravelStartTime(), attendanceBusinessTravel.getTravelEndTime(), attendance);
                bussEndDuration += getEndDuration(attendanceBusinessTravel.getTravelStartTime(), attendanceBusinessTravel.getTravelEndTime(), attendance);
                startTimeMap.put(attendanceBusinessTravel.getTravelStartTime(), Constant.ATTENDANCE_STATE_BUSINESS);
                endTimeMap.put(attendanceBusinessTravel.getTravelEndTime(), Constant.ATTENDANCE_STATE_BUSINESS);
            }
            // 调用方法修改考勤打卡状态
            updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_BUSINESS, day, bussStartDuration, bussEndDuration);
        }
        if (attendanceLeaveList.size() > 0) {
            // 统计请假
            Double leaveStartDuration = new Double(0.00); // 上午时长
            Double leaveEndDuration = new Double(0.00); // 下午时长
            for (AttendanceLeave attendanceLeave : attendanceLeaveList) {
                // 上午总时长、下午总时长
                leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(), attendanceLeave.getLeaveEndTime(), attendance);
                leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(), attendanceLeave.getLeaveEndTime(), attendance);
                startTimeMap.put(attendanceLeave.getLeaveStartTime(), Constant.ATTENDANCE_STATE_LEAVE);
                endTimeMap.put(attendanceLeave.getLeaveEndTime(), Constant.ATTENDANCE_STATE_LEAVE);
            }
            //调用方法修改考勤打卡状态
            updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_LEAVE, day, leaveStartDuration, leaveEndDuration);
        }
        // 选出最早的开始时间, 更新考勤记录
        if (!startTimeMap.isEmpty()) {
            Timestamp startTime = startTimeMap.keySet().stream().sorted(Comparator.comparing(Timestamp::toLocalDateTime)).findFirst().get();
            if (startTimeMap.get(startTime).equals(Constant.ATTENDANCE_STATE_GOOUT)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_GOOUT, day, outStartDuration + bussStartDuration + leaveStartDuration, 0.00);
            } else if (startTimeMap.get(startTime).equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_BUSINESS, day, outStartDuration + bussStartDuration + leaveStartDuration, 0.00);
            } else if (startTimeMap.get(startTime).equals(Constant.ATTENDANCE_STATE_LEAVE)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_LEAVE, day, outStartDuration + bussStartDuration + leaveStartDuration, 0.00);
            }
        }
        // 选出最晚的结束时间, 更新考勤记录
        if (!endTimeMap.isEmpty()) {
            Timestamp endTime = endTimeMap.keySet().stream().sorted(Comparator.comparing(Timestamp::toLocalDateTime).reversed()).findFirst().get();
            if (endTimeMap.get(endTime).equals(Constant.ATTENDANCE_STATE_GOOUT)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_GOOUT, day, 0.00, outEndDuration + bussEndDuration + leaveEndDuration);
            } else if (endTimeMap.get(endTime).equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_BUSINESS, day, 0.00, outEndDuration + bussEndDuration + leaveEndDuration);
            } else if (endTimeMap.get(endTime).equals(Constant.ATTENDANCE_STATE_LEAVE)) {
                updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_LEAVE, day, 0.00, outEndDuration + bussEndDuration + leaveEndDuration);
            }
        }
        // TODO:20250813修改 增加打卡时间判断,打卡时间需要闭环
@@ -1003,7 +1035,7 @@
    public Integer calculateTimes(LocalDateTime start, LocalDateTime end) {
        Integer time = 0;
        Duration duration = null;
        duration = Duration.between(start, start.toLocalDate().atTime(end.toLocalTime()));
        duration = Duration.between(start, end);
        Long StartSeconds = duration.getSeconds();
        time += StartSeconds.intValue();
        return time;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/NewSalaryServiceImpl.java
@@ -21,10 +21,12 @@
import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository;
import me.zhengjie.modules.attendance.repository.AttendanceOvertimeRepository;
import me.zhengjie.modules.attendance.service.AttendanceService;
import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.project.service.ProjectPerformanceDetailService;
import me.zhengjie.modules.project.service.dto.ProjectPerformanceDetailQueryCriteria;
import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.salary.domain.NewSalary;
import me.zhengjie.modules.salary.repository.NewSalaryRepository;
import me.zhengjie.modules.salary.service.NewSalaryService;
@@ -101,6 +103,7 @@
    // ==================== 以上为定时生成工资记录主要依赖 ====================
    private final MeritWageRepository meritWageRepository;
    private final MeritLevelRepository meritLevelRepository;
    private final WeComServiceImpl weComService;
    @Override
    public Map<String, Object> queryAll(NewSalaryQueryCriteria criteria, Pageable pageable) {
@@ -224,7 +227,10 @@
            map.put("全勤小时数", newSalaryDto.getFullDays());
            map.put("缺勤小时数", newSalaryDto.getAbsenceDays());
            map.put("实际基础工资", newSalaryDto.getActualBasicWage());
            map.put("其他补助", newSalaryDto.getTravelAllowance().add(newSalaryDto.getOvertimeAllowance()).add(newSalaryDto.getComptimeAllowance()));
            map.put("其他补助", newSalaryDto.getTravelAllowance().add(Optional.ofNullable(newSalaryDto.getOvertimeAllowance()).orElse(BigDecimal.ZERO)).add(Optional.ofNullable(newSalaryDto.getComptimeAllowance()).orElse(BigDecimal.ZERO)));
            map.put("出差补助", newSalaryDto.getTravelAllowance());
            map.put("加班补助", newSalaryDto.getOvertimeAllowance());
            map.put("调休结算补助", newSalaryDto.getComptimeAllowance());
//            map.put("绩效工资", newSalaryDto.getAchievementsWage());
//            map.put("应完成绩效工时", newSalaryDto.getNeedCompletedAchievementsHours());
//            map.put("已完成绩效工时", newSalaryDto.getAlreadyCompletedAchievementsHours());
@@ -349,6 +355,15 @@
        }
        // 获取用户列表
        List<UserSmallDto> userDtoList = userService.querySmallAll(userQueryCriteria);
        // 获取用户ID列表
        List<Long> userIds = userDtoList.stream().map(UserSmallDto::getId).collect(Collectors.toList());
        try {
            // 更新打卡状态为等待的考勤信息
            checkAttendanceStatus(userIds, criteria.getTargetYearMonth());
        } catch (Exception e) {
            e.printStackTrace();
            throw new BadRequestException("考勤信息获取失败!");
        }
        // 循环用户列表
        for (int i = 0; i < userDtoList.size(); i++) {
@@ -367,6 +382,32 @@
            String errorMessage = String.join("; ", errors);
            // 抛出一个新的异常
            throw new RuntimeException(errorMessage);
        }
    }
    // 更新打卡状态为等待的用户考勤信息
    public void checkAttendanceStatus(List<Long> userList, String targetYearMonth) throws Exception {
        // 考勤查询类
        AttendanceQueryCriteria attendanceQueryCriteriaStart = new AttendanceQueryCriteria();
        attendanceQueryCriteriaStart.setUserIds(userList);
        attendanceQueryCriteriaStart.setAttendanceDateLike(targetYearMonth.substring(0, 7));
        attendanceQueryCriteriaStart.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR);
        // 获取早打卡状态为等待的考勤记录
        List<AttendanceDto> attendanceListStart = attendanceService.queryAll(attendanceQueryCriteriaStart);
        AttendanceQueryCriteria attendanceQueryCriteriaEnd = new AttendanceQueryCriteria();
        attendanceQueryCriteriaEnd.setUserIds(userList);
        attendanceQueryCriteriaEnd.setAttendanceDateLike(targetYearMonth.substring(0, 7));
        attendanceQueryCriteriaEnd.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR);
        // 获取晚打卡状态为等待的考勤记录
        List<AttendanceDto> attendanceListEnd = attendanceService.queryAll(attendanceQueryCriteriaEnd);
        // 合并考勤记录
        if (!attendanceListEnd.isEmpty() || !attendanceListStart.isEmpty()) {
            attendanceListStart.addAll(attendanceListEnd);
            // 去重
            attendanceListStart = attendanceListStart.stream().distinct().collect(Collectors.toList());
            // 拉取考勤信息
            for (AttendanceDto attendance : attendanceListStart) {
                weComService.getWeComAttendanceListOfNight(String.valueOf(attendance.getAttendanceDate()).substring(0, 10), Collections.singletonList(userRepository.findById(attendance.getUserId()).orElseGet(User::new)));
            }
        }
    }
@@ -439,7 +480,7 @@
        AttendanceQueryCriteria attendanceQueryCriteria = new AttendanceQueryCriteria();
        attendanceQueryCriteria.setUserId(userId);
        attendanceQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询某月平日加班小时数
        // 查询某月平日加班小时数(已去除调休转换的时间)
        Double attendanceHours = attendanceService.queryAttendanceOverTimeHours(attendanceQueryCriteria);
        // 查询某月需结算的(结算三个月前的,如4月时结算1月份的)节假日调休小时数
        Double attendanceHolidayHours = attendanceService.queryAttendanceHolidaysOverTimeHours(attendanceQueryCriteria);
@@ -450,21 +491,6 @@
        criteria.setUserId(userId);
        criteria.setTargetYearMonth(targetYearMonth);
        UserLevelWageDto userLevelWageDto = userLevelWageService.queryTargetYearMonth(criteria);
        // 换休转补助
        LocalDateTime startLocalDateTime = LocalDateTime.parse(targetYearMonth + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        LocalDateTime startLocalDateTime3MonthsPrevious = startLocalDateTime.minusMonths(3).withDayOfMonth(1);
        LocalDateTime endLocalDateTime3MonthsPrevious = startLocalDateTime3MonthsPrevious.plusMonths(1).withDayOfMonth(1);
        LocalDateTime endLocalDateTime = startLocalDateTime.plusMonths(1).withDayOfMonth(1);
        Double approvedTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, startLocalDateTime3MonthsPrevious, endLocalDateTime3MonthsPrevious);
        Double leaveTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(
                        userId, startLocalDateTime3MonthsPrevious, endLocalDateTime, Constant.LEAVE_TYPE_REPLACE).stream()
                .map(AttendanceLeave::getLeaveDuration).mapToDouble(Double::doubleValue).sum();
        if (approvedTime != null && approvedTime.compareTo(leaveTime) > 0) {
            attendanceHours = attendanceHours + approvedTime - leaveTime;
            System.out.println("换休转补助:" + (approvedTime - leaveTime));
        }
        // 平日加班费
        if (userLevelWageDto.getOverTimeWage() != null) {
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -868,22 +868,30 @@
        // 月初到今天应工作时长
        returnData.put("Time", num);
        DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        User user = userRepository.getById(userId);
        BigDecimal resultTime = null;
        List<Calculate> resultParts = new ArrayList<>();
        List<Calculate> calculateList = new ArrayList<>();
        List<Calculate> breakParts = new ArrayList<>();
        for (Attendance attendance : attendanceRecordList) {
            // 上班打卡时间不为空并且打卡状态不为出差外出的考勤记录
            if (ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) &&
                    !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) &&
                    !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS) &&
                    attendance.getActualWorkStartTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0
            ) {
                calculateList.add(new Calculate(attendance.getActualWorkStartTime().toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()));
            }
            // 下班打卡时间不为空并且打卡状态不为出差外出的考勤记录
            if (ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) &&
                    !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) &&
                    !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                calculateList.add(new Calculate(attendance.getActualWorkStartTime().toLocalDateTime(), attendance.getActualWorkEndTime().toLocalDateTime()));
                // 休息时间管理(午休和下班后30分钟)
                breakParts.add(new Calculate(LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchStartTime().toString() + ":00", formatter2), LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchEndTime().toString() + ":00", formatter2)));
                breakParts.add(new Calculate(LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00", formatter2), LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00", formatter2).plusMinutes(30)));
                    !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS) &&
                    attendance.getActualWorkEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) > 0
            ) {
                calculateList.add(new Calculate(attendance.getRosteringLunchEndTime().toLocalDateTime(), attendance.getActualWorkEndTime().toLocalDateTime()));
            }
            // 休息时间管理(午休和下班后30分钟)
            breakParts.add(new Calculate(attendance.getRosteringLunchStartTime().toLocalDateTime(), attendance.getRosteringLunchEndTime().toLocalDateTime()));
            breakParts.add(new Calculate(attendance.getRosteringWorkEndTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime().plusMinutes(30L)));
        }
        calculateList.stream().sorted().reduce(new Stack<Calculate>(), (result, current) -> {
            // 删除重复时间,合并相连的时间段
@@ -925,7 +933,7 @@
            resultParts.addAll(currentParts);
        });
        resultTime = resultParts.stream()
        BigDecimal resultTime = resultParts.stream()
                .map(calculate -> ChronoUnit.SECONDS.between(calculate.getStart(), calculate.getEnd()))
                .reduce(new BigDecimal(0),
                        (total, current) -> total.add(BigDecimal.valueOf(current)),
@@ -939,7 +947,7 @@
        // 外出时长
        Double goOutTimes = 0.0;
        // 查询外出表
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, Timestamp.valueOf(startTime).toLocalDateTime(), Timestamp.valueOf(endTime).toLocalDateTime());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(Timestamp.valueOf(startTime).toLocalDateTime()), DateUtil.parseAttEndTime(Timestamp.valueOf(endTime).toLocalDateTime()));
        for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
            goOutTimes = goOutTimes + attendanceGoOut.getOutDuration();
        }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
@@ -145,12 +145,12 @@
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
        // 获取月初日期
        LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
        LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
        // 获取下月初日期
        LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
        LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
        // 查询指定员工的加班补助金额工资
        Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
        Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), DateUtil.parseAttStartTime(firstDayOfMonth), DateUtil.parseAttEndTime(lastDayOfMonth));
        // 查询配置表
        SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("加班补助金额");
@@ -167,12 +167,12 @@
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
        // 获取月初日期
        LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
        // 获取下月初日期
        LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
        LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
        // 获取月末最后一天日期
        LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
        // 查询出差表的记录
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(criteria.getUserId(), firstDayOfMonth, lastDayOfMonth);
        // TODO:因一天可填多条出差记录,每条最小的时长是0.5天,导致可能会有当天总时长超出1天的情况。(每天出差类型只会有一种,不考虑多种的情况)
        List<AttendanceBusinessTravel> calcAttendanceBusinessTravelList = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(
                (AttendanceBusinessTravel businessTravel) -> businessTravel.getTravelStartTime().toLocalDateTime().toLocalDate().toString(),
eladmin-master/eladmin-system/src/main/java/me/zhengjie/utils/DateUtil.java
@@ -130,7 +130,7 @@
        // 设置秒数
        cal.set(Calendar.SECOND, 59);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 999);
        cal.set(Calendar.MILLISECOND, 0);
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
        return sdf.format(cal.getTime());
@@ -298,7 +298,7 @@
        // 设置秒数
        cal.set(Calendar.SECOND, 59);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 999);
        cal.set(Calendar.MILLISECOND, 0);
        // 日历类
        return cal;
    }
@@ -324,4 +324,56 @@
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        return sdf.format(dayCal.getTime());
    }
    private static final Integer ATT_START_HOUR = 4;
    private static final Integer ATT_START_MINUTE = 0;
    private static final Integer ATT_START_SECOND = 0;
    private static final Integer ATT_START_NANO = 0;
    private static final Integer ATT_END_HOUR = 3;
    private static final Integer ATT_END_MINUTE = 59;
    private static final Integer ATT_END_SECOND = 59;
    private static final Integer ATT_END_NANO = 0;
    private static final Long ATT_END_PLUS_DAY = 1L;
    /**
     * 转为考勤开始时间
     *
     * @param localDateTime / 考勤当天
     * @return /
     */
    public static LocalDateTime parseAttStartTime(LocalDateTime localDateTime) {
        return localDateTime.withHour(ATT_START_HOUR).withMinute(ATT_START_MINUTE).withSecond(ATT_START_SECOND).withNano(ATT_START_NANO);
    }
    /**
     * 转为考勤结束时间
     *
     * @param localDateTime / 考勤当天
     * @return /
     */
    public static LocalDateTime parseAttEndTime(LocalDateTime localDateTime) {
        // 因数据库Nano太大的话会识别为整点,如03:59:59:999识别为04:00:00,所以Nano需要设置为0
        return localDateTime.plusDays(ATT_END_PLUS_DAY).withHour(ATT_END_HOUR).withMinute(ATT_END_MINUTE).withSecond(ATT_END_SECOND).withNano(ATT_END_NANO);
    }
    /**
     * 转为考勤开始时间
     *
     * @param localDate / 考勤当天
     * @return /
     */
    public static LocalDateTime parseAttStartTime(LocalDate localDate) {
        return localDate.atTime(ATT_START_HOUR, ATT_START_MINUTE, ATT_START_SECOND).withNano(ATT_START_NANO);
    }
    /**
     * 转为考勤结束时间
     *
     * @param localDate / 考勤当天
     * @return /
     */
    public static LocalDateTime parseAttEndTime(LocalDate localDate) {
        // 因数据库Nano太大的话会识别为整点,如03:59:59:999识别为04:00:00,所以Nano需要设置为0
        return localDate.atTime(ATT_END_HOUR, ATT_END_MINUTE, ATT_END_SECOND).plusDays(ATT_END_PLUS_DAY).withNano(ATT_END_NANO);
    }
}
eladmin-master/eladmin-system/src/main/resources/config/application-dev.yml
@@ -9,8 +9,9 @@
    druid:
      db-type: com.alibaba.druid.pool.DruidDataSource
      driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
      url: jdbc:log4jdbc:mysql://${DB_HOST:114.116.101.63}:${DB_PORT:31752}/${DB_NAME:pms_upgrade}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
#      url: jdbc:log4jdbc:mysql://${DB_HOST:114.116.101.63}:${DB_PORT:31752}/${DB_NAME:pms_upgrade}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
#      url: jdbc:log4jdbc:mysql://${DB_HOST:114.116.101.63}:${DB_PORT:31404}/${DB_NAME:pms_upgrade}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
      url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:pms_upgrade}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
      username: ${DB_USER:root}
      password: ${DB_PWD:123456}
      # 初始连接数
eladmin-master/eladmin-system/src/main/resources/config/application.yml
@@ -5,7 +5,7 @@
  freemarker:
    check-template-location: false
  profiles:
    active: dev
    active: prod
  jackson:
    time-zone: GMT+8
  data:
eladmin-web-master/src/views/dashboard/PanelGroup.vue
@@ -365,6 +365,9 @@
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    &:hover {
      .card-panel-icon-wrapper {
@@ -402,7 +405,7 @@
    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      margin: 14px 0 35px 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
@@ -410,7 +413,7 @@
    .card-panel-icon {
      float: left;
      font-size: 48px;
      font-size: 30px;
    }
    .card-panel-description {
@@ -422,8 +425,9 @@
      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        font-size: 13px;
        margin-bottom: 12px;
        white-space: normal;
      }
      .card-panel-texts {
@@ -431,12 +435,24 @@
      }
      .card-panel-num {
        font-size: 20px;
        font-size: 15px;
      }
    }
  }
}
@media (max-width: 1230px) {
  .card-panel-description {
    .card-panel-text {
      font-size: 12px !important;
    }
    .card-panel-num {
      font-size: 12px !important;
    }
  }
}
@media (max-width: 550px) {
  .card-panel-description {
    display: none;