From 9bc31fa514df22c5af8c2e8717037c91cb7d26e3 Mon Sep 17 00:00:00 2001
From: 赵士淞 <zhaoss@yhzhg.cn>
Date: Wed, 18 Jan 2023 02:52:31 +0000
Subject: [PATCH] Merge branch 'weicd' of http://192.168.1.110:5678/r/pms-upgrade into master

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)

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 599d6d4..818666b 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
@@ -24,6 +24,7 @@
 import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
 import me.zhengjie.modules.constant.Constant;
 import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl;
 import me.zhengjie.modules.system.domain.*;
 import me.zhengjie.modules.system.repository.DictDetailRepository;
 import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
@@ -74,6 +75,7 @@
     private final AttendanceRepository attendanceRepository;
     private final AttendanceGoOutRepository attendanceGoOutRepository;
     private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
+    private final DingTalkServiceImpl dingTalkService;
 
     @Override
     public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
@@ -455,25 +457,20 @@
      * @param resources /
      */
     @Override
-    public void updateApprove(AttendanceLeave resources) {
+    public void updateApprove(AttendanceLeave resources) throws Exception {
         AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
         ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
         attendanceLeave.copy(resources);
-        //审批通过直接改考勤记录的状态
-        if(resources.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED)){
-            // 查询考勤记录是否存在
-            Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getLeaveStartTime().toLocalDateTime().toString().substring(0,10));
-            if(ObjectUtils.isNotEmpty(attendance)){
-                if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) && resources.getLeaveStartTime().toLocalDateTime().compareTo(attendance.getRosteringWorkStartTime().toLocalDateTime()) <= 0) {
-                    attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LEAVE);
-                }
-                if (!attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) &&resources.getLeaveEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) >= 0) {
-                    attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LEAVE);
-                }
-                attendanceRepository.save(attendance);
-            }
-        }
         attendanceLeaveRepository.save(attendanceLeave);
+        // 调用定时任务修改考勤记录
+        List<User> userList = new ArrayList<>();
+        if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
+            User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
+            userList.add(user);
+        }
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
+        dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList);
     }
 
     @Override
@@ -505,15 +502,17 @@
     public void download(List<AttendanceLeaveDto> all, HttpServletResponse response) throws IOException {
         List<Map<String, Object>> list = new ArrayList<>();
         for (AttendanceLeaveDto attendanceLeave : all) {
+            String leavrType = attendanceLeave.getLeaveType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TYPE, attendanceLeave.getLeaveType()).getLabel() : "";
+            String leaveStatus = attendanceLeave.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVAL_STATUS, attendanceLeave.getApprovalStatus()).getLabel() : "";
             Map<String,Object> map = new LinkedHashMap<>();
             map.put("用户ID", attendanceLeave.getUserId());
             map.put("审批用户ID", attendanceLeave.getApprovalUserId());
-            map.put("请假类型", attendanceLeave.getLeaveType());
+            map.put("请假类型", leavrType);
             map.put("请假开始时间", attendanceLeave.getLeaveStartTime());
             map.put("请假结束时间", attendanceLeave.getLeaveEndTime());
             map.put("请假时长", attendanceLeave.getLeaveDuration());
             map.put("请假原因", attendanceLeave.getLeaveReason());
-            map.put("审批状态", attendanceLeave.getApprovalStatus());
+            map.put("审批状态", leaveStatus);
             map.put("审批说明", attendanceLeave.getApprovalDescription());
             map.put("备注", attendanceLeave.getRemarks());
             map.put("创建者", attendanceLeave.getCreateBy());

--
Gitblit v1.9.3