From 86b0362eaf4c320dc6a54fc12ce80b0bf7890a85 Mon Sep 17 00:00:00 2001
From: yaozc <yaozc@yhzhg.cn>
Date: Thu, 30 May 2024 02:06:17 +0000
Subject: [PATCH] 11111

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java |  120 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 89 insertions(+), 31 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
index 13b9b08..5ee1085 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceMonthServiceImpl.java
@@ -118,7 +118,7 @@
                         attTypeInfo.put("leaveType", attendanceMonthLeaves.get(i).getLeaveType());
                         attTypeInfo.put("leaveCount", attendanceMonthLeaves.get(i).getLeaveCount());
                         attTypeInfo.put("leaveTime", attendanceMonthLeaves.get(i).getLeaveTime());
-                        if(attendanceMonthLeaves.get(i).getLeaveType().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE)){
+                        if(attendanceMonthLeaves.get(i).getLeaveType().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || attendanceMonthLeaves.get(i).getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)){
                             attTypeInfo.put("leaveYearTime", attendanceMonthLeaves.get(i).getSurplusDuration() == null ? 0 : attendanceMonthLeaves.get(i).getSurplusDuration());
                         }
                         leaveTypeList.add(attTypeInfo);
@@ -136,8 +136,51 @@
     }
 
     @Override
-    public List<AttendanceMonthDto> queryAll(AttendanceMonthQueryCriteria criteria){
-        return attendanceMonthMapper.toDto(attendanceMonthRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    @SneakyThrows
+    public List<AttendanceMonthDto> queryAll(AttendanceMonthQueryCriteria criteria) {
+        // 判断工资查询类年月是否为空
+        if (criteria.getAttendanceDate() != null && !"".equals(criteria.getAttendanceDate())) {
+            // 年月:国际时间转中国时间
+            criteria.setAttendanceDate(DateUtil.internationalTimeToChinaTime(criteria.getAttendanceDate()));
+        }
+        List<AttendanceMonthDto> attendanceMonthDtoList = attendanceMonthMapper.toDto(attendanceMonthRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
+        for (AttendanceMonthDto attendanceMonthDto : attendanceMonthDtoList) {
+            // 根据用户ID查询用户信息
+            User user = userRepository.findById(attendanceMonthDto.getUserId()).orElseGet(User::new);
+            // 用户昵称
+            attendanceMonthDto.setNickName(user.getNickName());
+            // 查询公司
+            SysCompany sysCompany = sysCompanyRepository.findById(attendanceMonthDto.getCompanyId()).orElseGet(SysCompany::new);
+            attendanceMonthDto.setCompanyName(sysCompany.getLabel());
+            // 查询部门
+            Dept dept = deptRepository.findById(attendanceMonthDto.getDeptId()).orElseGet(Dept::new);
+            attendanceMonthDto.setDeptName(dept.getName());
+            // 查询岗位
+            if(ObjectUtils.isNotEmpty(attendanceMonthDto.getJobId())){
+                Job job = jobRepository.findById(attendanceMonthDto.getJobId()).orElseGet(Job::new);
+                attendanceMonthDto.setJobName(job.getName());
+            }
+//            List<Map> leaveTypeList = new ArrayList<>();
+//            // 查询请假类型表
+//            List<AttendanceMonthLeave> attendanceMonthLeaves = attendanceMonthLeaveRepository.findByAttendanceMonthId(attendanceMonthDto.getId());
+//            if(attendanceMonthLeaves.size() != 0){
+//                for(int i = 0; i < attendanceMonthLeaves.size(); i++){
+//                    Map attTypeInfo = new HashMap();
+//                    attTypeInfo.put("leaveType", attendanceMonthLeaves.get(i).getLeaveType());
+//                    attTypeInfo.put("leaveCount", attendanceMonthLeaves.get(i).getLeaveCount());
+//                    attTypeInfo.put("leaveTime", attendanceMonthLeaves.get(i).getLeaveTime());
+//                    if(attendanceMonthLeaves.get(i).getLeaveType().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || attendanceMonthLeaves.get(i).getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)){
+//                        attTypeInfo.put("leaveYearTime", attendanceMonthLeaves.get(i).getSurplusDuration() == null ? 0 : attendanceMonthLeaves.get(i).getSurplusDuration());
+//                    }
+//                    leaveTypeList.add(attTypeInfo);
+//                }
+//            }else{
+//                Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonthDto.getUserId());
+//                attendanceMonthDto.setYearTime(yearTime);
+//            }
+//            attendanceMonthDto.setLeaveTypeList(leaveTypeList);
+        }
+        return attendanceMonthDtoList;
     }
 
     @Override
@@ -218,64 +261,79 @@
     public void download(List<AttendanceMonthDto> all, HttpServletResponse response) throws IOException {
         List<Map<String, Object>> list = new ArrayList<>();
         for (AttendanceMonthDto attendanceMonth : all) {
-            // 根据用户ID查询用户信息
-            User user = userRepository.findById(attendanceMonth.getUserId()).orElseGet(User::new);
-            // 查询公司
-            SysCompany sysCompany = sysCompanyRepository.findById(attendanceMonth.getCompanyId()).orElseGet(SysCompany::new);
-            // 查询部门
-            Dept dept = deptRepository.findById(attendanceMonth.getDeptId()).orElseGet(Dept::new);
-            Job job = new Job();
-            // 查询岗位
-            if(attendanceMonth.getJobId() != null){
-                job = jobRepository.findById(attendanceMonth.getJobId()).orElseGet(Job::new);
-            }
+//            // 根据用户ID查询用户信息
+//            User user = userRepository.findById(attendanceMonth.getUserId()).orElseGet(User::new);
+//            // 查询公司
+//            SysCompany sysCompany = sysCompanyRepository.findById(attendanceMonth.getCompanyId()).orElseGet(SysCompany::new);
+//            // 查询部门
+//            Dept dept = deptRepository.findById(attendanceMonth.getDeptId()).orElseGet(Dept::new);
+//            Job job = new Job();
+//            // 查询岗位
+//            if(attendanceMonth.getJobId() != null){
+//                job = jobRepository.findById(attendanceMonth.getJobId()).orElseGet(Job::new);
+//            }
             String isAdmit = attendanceMonth.getIsAdmit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVE_STATUS_ACKNOWLEDGED, attendanceMonth.getIsAdmit()).getLabel() : "";
             String isP = attendanceMonth.getIsPublicity() != null ? dictDetailRepository.findByDictNameAndValue(Constant.PUBLICITY_STATUS_YES, attendanceMonth.getIsPublicity()).getLabel() : "";
 
             Double annualLeave = 0.0D;
+            Double locationLeave = 0.0D;
             Double compassionateLeave = 0.0D;
             List<AttendanceMonthLeave> attendanceMonthLeaves = attendanceMonthLeaveRepository.findByAttendanceMonthId(attendanceMonth.getId());
             if(attendanceMonthLeaves.size() != 0){
                 for(AttendanceMonthLeave attendanceMonthLeave : attendanceMonthLeaves){
                 	if(attendanceMonthLeave.getLeaveType().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE) || attendanceMonthLeave.getLeaveType().equals(Constant.LEAVE_TYPE_SICK_LEAVE)){
                 		compassionateLeave += attendanceMonthLeave.getLeaveTime();
-                    } else {
+                    } else if (attendanceMonthLeave.getLeaveType().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE)) {
                     	annualLeave += attendanceMonthLeave.getLeaveTime();
+                    } else if (attendanceMonthLeave.getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)) {
+                        locationLeave += attendanceMonthLeave.getLeaveTime();
                     }
                 }
             }
 
             Map<String,Object> map = new LinkedHashMap<>();
             map.put("统计年月", attendanceMonth.getAttendanceDate());
-            map.put("用户", user.getNickName());
-            map.put("公司", sysCompany.getLabel());
-            map.put("部门", dept.getName());
-            map.put("岗位", job == null ? null : job.getName());
+            map.put("用户", attendanceMonth.getNickName());
+            map.put("公司", attendanceMonth.getCompanyName());
+            map.put("部门", attendanceMonth.getDeptName());
+            map.put("岗位", attendanceMonth.getJobName());
             map.put("应出勤天数", attendanceMonth.getRequiredAttendanceDays());
-            map.put("应出勤时长", attendanceMonth.getRequiredAttendanceTime());
             map.put("实际出勤天数", attendanceMonth.getActualAttendanceDays());
+            map.put("应出勤时长", attendanceMonth.getRequiredAttendanceTime());
+//            map.put("外出时长", attendanceMonth.getGoOutTime());
+//            map.put("出差时长", attendanceMonth.getBussTime());
             map.put("实际出勤时长", attendanceMonth.getActualAttendanceTime());
             map.put("迟到次数", attendanceMonth.getCountOfBeingLate());
             map.put("迟到时长", attendanceMonth.getTimeOfBeingLate());
             map.put("早退次数", attendanceMonth.getCountOfBeingEarly());
             map.put("早退时长", attendanceMonth.getTimeOfBeingEarly());
-            map.put("外出次数", attendanceMonth.getGoOutNumber());
-            map.put("外出时长", attendanceMonth.getGoOutTime());
-            map.put("出差次数", attendanceMonth.getBussNumber());
-            map.put("出差时长", attendanceMonth.getBussTime());
-            map.put("年假", annualLeave);
-            map.put("事假", compassionateLeave);
+//            map.put("外出次数", attendanceMonth.getGoOutNumber());
+//            map.put("出差次数", attendanceMonth.getBussNumber());
+//            map.put("出差时长", attendanceMonth.getBussTime());
+
+            map.put("当月使用年假", annualLeave);
+            map.put("当月使用调休假", locationLeave);
+            map.put("当月使用事假", compassionateLeave);
+
+            Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonth.getUserId());
+            map.put("剩余年假", yearTime);
+
+            Double overTime = attendanceLeaveService.getOverTimeLength(attendanceMonth.getUserId());
+            map.put("剩余调休假", overTime);
+
             map.put("上班缺卡次数", attendanceMonth.getOnCardNumber());
             map.put("下班缺卡次数", attendanceMonth.getOffCardNumber());
             map.put("公示状态", attendanceMonth.getIsPublicity());
             map.put("承认状态", isAdmit);
-            map.put("备注", attendanceMonth.getRemarks());
-            map.put("创建者", attendanceMonth.getCreateBy());
-            map.put("创建时间", attendanceMonth.getCreateTime());
-            map.put("更新者", attendanceMonth.getUpdateBy());
-            map.put("更新时间", attendanceMonth.getUpdateTime());
+//            map.put("备注", attendanceMonth.getRemarks());
+//            map.put("创建者", attendanceMonth.getCreateBy());
+//            map.put("创建时间", attendanceMonth.getCreateTime());
+//            map.put("更新者", attendanceMonth.getUpdateBy());
+//            map.put("更新时间", attendanceMonth.getUpdateTime());
             list.add(map);
         }
+//        list = list.subList(0, 1);
+//        list.forEach(System.out::println);
         FileUtil.downloadExcel(list, response);
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3