From bdbce4e615d15f4f8423cc8ac5ee7fc66bb311ef Mon Sep 17 00:00:00 2001
From: churf <123456>
Date: Mon, 21 Aug 2023 09:38:16 +0000
Subject: [PATCH] 前端显示优化

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java |  254 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 185 insertions(+), 69 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
index 9085a82..cd0f2c6 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -37,20 +37,26 @@
 import me.zhengjie.modules.system.repository.*;
 import me.zhengjie.modules.system.service.UserService;
 import me.zhengjie.modules.system.service.dto.*;
-import me.zhengjie.modules.system.service.mapstruct.SysUserLevelWageMapper;
 import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper;
 import me.zhengjie.modules.system.service.mapstruct.UserMapper;
 import me.zhengjie.modules.task.domain.TaskDaliy;
+import me.zhengjie.modules.task.domain.TaskMongo;
 import me.zhengjie.modules.task.repository.TaskDaliyRepository;
+import me.zhengjie.modules.task.service.TaskDaliyService;
+import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria;
 import me.zhengjie.utils.*;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
+
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.NotBlank;
 import java.io.File;
@@ -95,7 +101,11 @@
     private final SysConfigHolidayRepository sysConfigHolidayRepository;
     private final AttendanceGoOutRepository attendanceGoOutRepository;
     private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
-    private final SystemSettingRepository systemSettingRepository;
+    private final SysCompanyRepository sysCompanyRepository;
+    private final TaskDaliyService taskDaliyService;
+    private final DeptRepository deptRepository;
+
+    private final MongoTemplate mongoTemplate;
 
     @Override
     public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@@ -104,9 +114,95 @@
     }
 
     @Override
+    public List<DeptUserNodeDto> queryDeptUserByDeptId(Long deptId) {
+        List<DeptUserNodeDto> result = new ArrayList<DeptUserNodeDto>();
+        Optional<Dept> deptOpt = deptRepository.findById(deptId);
+        if (deptOpt.isPresent()) {
+            Dept dept = deptOpt.get();
+            List<Dept> subDeptList = deptRepository.findByPid(deptId);
+            subDeptList.forEach(subDept -> {
+                DeptUserNodeDto deptUserNodeDto = new DeptUserNodeDto();
+                deptUserNodeDto.setId(subDept.getId());
+                deptUserNodeDto.setLabel(subDept.getName());
+                deptUserNodeDto.setLeaf(false);
+                result.add(deptUserNodeDto);
+            });
+            List<User> userList = userRepository.findByDeptAndEnabled(dept, true);
+            userList.forEach(user -> {
+                DeptUserNodeDto deptUserNodeDto = new DeptUserNodeDto();
+                deptUserNodeDto.setId(user.getId());
+                deptUserNodeDto.setLabel(user.getNickName());
+                deptUserNodeDto.setLeaf(true);
+                result.add(deptUserNodeDto);
+            });
+        }
+        return result;
+    }
+
+    @Override
+    public List<UserDto> getUserByTaskId(String taskId) {
+        // 日历类
+        Calendar calendar = Calendar.getInstance();
+        // 日期格式化
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        // 日历字符串
+        String calendarStr = sdf.format(calendar.getTime());
+
+        TaskMongo taskMongo = mongoTemplate.findById(taskId, TaskMongo.class);
+        List<Long> containUserList = taskMongo.getContainUserList();
+        List<User> userList = new ArrayList<>();
+        if(containUserList.size() != 0){
+            for (Long userId : containUserList) {
+                userList.add(userRepository.findById(userId).get());
+            }
+        }
+        List<UserDto> userDto = userMapper.toDto(userList);
+        for (int i = 0; i < userDto.size(); i++) {
+            // 根据用户ID、指定年月查询用户级别工资
+            SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findTargetYearMonth(userDto.get(i).getId(), calendarStr);
+            // 判断用户级别工资是否为空
+            if (sysUserLevelWage != null) {
+                // 根据ID查询用户级别
+                SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelWage.getLevelId()).orElseGet(SysLevel::new);
+                // 用户
+                userDto.get(i).setLevelName(sysLevel.getName());
+            } else {
+                // 用户
+                userDto.get(i).setLevelName(null);
+            }
+        }
+        return userDto;
+    }
+
+    @Override
+    @Cacheable(key = "'total'")
+    @Transactional(rollbackFor = Exception.class)
     public List<UserDto> queryAll(UserQueryCriteria criteria) {
+        // 日历类
+        Calendar calendar = Calendar.getInstance();
+        // 日期格式化
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        // 日历字符串
+        String calendarStr = sdf.format(calendar.getTime());
+        // 查询用户数据
         List<User> users = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
-        return userMapper.toDto(users);
+        List<UserDto> usersDto = userMapper.toDto(users);
+        // 循环用户
+        for (int i = 0; i < usersDto.size(); i++) {
+            // 根据用户ID、指定年月查询用户级别工资
+            SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findTargetYearMonth(usersDto.get(i).getId(), calendarStr);
+            // 判断用户级别工资是否为空
+            if (sysUserLevelWage != null) {
+                // 根据ID查询用户级别
+                SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelWage.getLevelId()).orElseGet(SysLevel::new);
+                // 用户
+                usersDto.get(i).setLevelName(sysLevel.getName());
+            } else {
+                // 用户
+                usersDto.get(i).setLevelName(null);
+            }
+        }
+        return usersDto;
     }
 
     @Override
@@ -130,6 +226,7 @@
         if (userRepository.findByPhone(resources.getPhone()) != null) {
             throw new EntityExistException(User.class, "phone", resources.getPhone());
         }
+        redisUtils.del(CacheKey.TOTAL_USER);
         userRepository.save(resources);
         // 判断用户级别变更
         checkUserLevel(resources.getId(), null, resources.getLevelId());
@@ -159,15 +256,16 @@
             redisUtils.del(CacheKey.ROLE_AUTH + resources.getId());
         }
         // 修改部门会影响 数据权限
-        if (!Objects.equals(resources.getDept(),user.getDept())) {
+        if (!Objects.equals(resources.getDept(), user.getDept())) {
             redisUtils.del(CacheKey.DATA_USER + resources.getId());
         }
         // 如果用户被禁用,则清除用户登录信息
-        if(!resources.getEnabled()){
+        if (!resources.getEnabled()) {
             onlineUserService.kickOutForUsername(resources.getUsername());
         }
         // 临时旧用户级别ID
-        Long tempOldLevelId = user.getLevelId();;
+        Long tempOldLevelId = user.getLevelId();
+        ;
         user.setUsername(resources.getUsername());
         user.setEmail(resources.getEmail());
         user.setEnabled(resources.getEnabled());
@@ -210,6 +308,7 @@
 
     /**
      * 获取日历信息
+     *
      * @param month
      * @return
      * @throws Exception
@@ -226,8 +325,8 @@
         //当前登录人
         Long userId = SecurityUtils.getCurrentUserId();
         //查询这个范围的考勤记录
-        List<Attendance> attendanceList = attendanceRepository.findAllByUserAndDate(userId,startDate.toString(),endDate.toString());
-        for(Attendance attendance : attendanceList){
+        List<Attendance> attendanceList = attendanceRepository.findAllByUserAndDate(userId, startDate.toString(), endDate.toString());
+        for (Attendance attendance : attendanceList) {
             CalendarVo onDuty = new CalendarVo();
             onDuty.setDate(df.format(attendance.getAttendanceDate()));
             onDuty.setTitle(Constant.ATTENDANCE_STATE_NORMAL.equals(formateResult(attendance.getStartClockResults()).get("msg")) ? "上班打卡时间:" + attendance.getActualWorkStartTime().toString() : "上班:" + formateResult(attendance.getStartClockResults()).get("msg"));
@@ -248,7 +347,7 @@
         Long duration = (Duration.between(user.getSysRostering().getWorkStartTime(), user.getSysRostering().getWorkEndTime())).toHours();
 
         //查询日志表
-        List<TaskDaliy> taskDaliyList = taskDaliyRepository.findAllByUserAndDate(userId,startDate,endDate);
+        List<TaskDaliy> taskDaliyList = taskDaliyRepository.findAllByUserAndDate(userId, startDate, endDate);
         for (TaskDaliy taskDaliy : taskDaliyList) {
             CalendarVo daily = new CalendarVo();
             daily.setDate(taskDaliy.getFillDate().toString());
@@ -269,17 +368,17 @@
             for (Attendance attendanceRecord : attendanceList) {
                 type1 = attendanceRecord.getStartClockResults();
                 type2 = attendanceRecord.getEndClockResults();
-                date = date.substring(0,10);
-                if(date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_LEAVE) && type2.equals(Constant.ATTENDANCE_STATE_LEAVE)){
+                date = date.substring(0, 10);
+                if (date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_LEAVE) && type2.equals(Constant.ATTENDANCE_STATE_LEAVE)) {
                     dailyVo.setTitle("请假");
                     dailyVo.setIsOk(true);
-                }else if(date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_BUSINESS) && type2.equals(Constant.ATTENDANCE_STATE_BUSINESS)){
+                } else if (date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_BUSINESS) && type2.equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                     dailyVo.setTitle("出差");
                     dailyVo.setIsOk(true);
-                }else if(date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_REST) && type2.equals(Constant.ATTENDANCE_STATE_REST)){
+                } else if (date.equals(df.format(attendanceRecord.getAttendanceDate())) && type1.equals(Constant.ATTENDANCE_STATE_REST) && type2.equals(Constant.ATTENDANCE_STATE_REST)) {
                     dailyVo.setTitle("休息");
                     dailyVo.setIsOk(true);
-                }else if(date.equals(df.format(attendanceRecord.getAttendanceDate()))){
+                } else if (date.equals(df.format(attendanceRecord.getAttendanceDate()))) {
                     dailyVo.setTitle("日报未填写,请补充日报");
                     dailyVo.setIsOk(false);
                 }
@@ -292,6 +391,7 @@
 
     /**
      * 判断状态
+     *
      * @param result
      * @return
      */
@@ -342,50 +442,46 @@
     }
 
     /**
-     *获取用户基础信息
+     * 获取用户基础信息
+     *
      * @return
      * @throws ParseException
      */
     @Override
-    public Map getUserBaseInfo() throws ParseException {
-        Long userId = SecurityUtils.getCurrentUserId();
+    public Map getUserBaseInfo(Date yearMonth) throws ParseException {
+        // 返回集合
         Map returnData = new HashMap();
-        LocalDate startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth());
-        LocalDate endDate = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth());
-        List<Attendance> attendanceRecordList = attendanceRepository.findAllByUserAndDate(userId, startDate.toString(), endDate.toString());
+        // 当前登录用户
+        Long userId = SecurityUtils.getCurrentUserId();
+        // 目标年月字符串
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String sdfDate = sdf.format(yearMonth);
+        // 目标年月初字符串
+        String sdfFirstDate = DateUtil.getFirstDayOfMonthFull(sdfDate);
+        // 目标年月末字符串
+        String sdfLastDate = DateUtil.getLastDayOfMonthFull(sdfDate);
+        // 出勤天数
+        List<Attendance> attendanceRecordList = attendanceRepository.findAllByUserAndDate(userId, sdfFirstDate, sdfLastDate);
         int numDay = 0;
-        for(Attendance attendance : attendanceRecordList){
-            if(!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_REST)){
+        for (Attendance attendance : attendanceRecordList) {
+            if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_REST)) {
                 numDay++;
             }
         }
-        // 出勤天数
         returnData.put("onDutyDays", numDay);
         // 剩余年假
         Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
         returnData.put("annualLeave", yearTimes);
-        // 剩余补卡
-        Calendar calendar = Calendar.getInstance();
-        // 获取当前年
-        int year = calendar.get(Calendar.YEAR);
-        // 获取当前月
-        int month = calendar.get(Calendar.MONTH) + 1;
-        String mouths = "";
-        if(month < 10){
-            mouths = "0" + month;
-        }
-        String baseDate = year + "-" + mouths;
         // 查询当月的补卡记录的条数
-        Integer count = attendanceCardreplacementRepository.count(userId, baseDate);
+        Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0, 7));
         // 查询配置表的每月补卡次数
         SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("每月可补卡次数");
-        if(count >= sysConfigProportion.getProportion()){
+        if (count >= sysConfigProportion.getProportion()) {
             returnData.put("cardLeft", 0);
-        }else{
+        } else {
             returnData.put("cardLeft", (sysConfigProportion.getProportion() - count));
         }
 
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
         // 法定节假日
         List<String> holiday = new ArrayList<>();
         // 天数
@@ -393,19 +489,23 @@
         List<SysConfigHoliday> holidayConfigurationList = sysConfigHolidayRepository.findAll();
         for (SysConfigHoliday holidayConfiguration : holidayConfigurationList) {
             if (holidayConfiguration.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
-                holiday.add(df.format(holidayConfiguration.getHolidayDate()));
+                holiday.add(sdf.format(holidayConfiguration.getHolidayDate()));
             }
         }
         // 获取当月所有日期
-        List<String> dateList = DateTimeUtil.getDayByMonth();
+        List<String> dateList = DateTimeUtil.getDayByMonth(sdfDate.substring(0, 4), sdfDate.substring(5, 7));
         Date date1 = new Date();
-        String todayDay = df.format(date1);
+        String todayDay = sdf.format(date1);
+        if (!todayDay.substring(0, 7).equals(sdfDate.substring(0, 7))) {
+            todayDay = sdfLastDate;
+        }
         // 工作日的天数
-        for(String date : dateList){
-            Date isWeekEnd = df.parse(date);
+        for (String date : dateList) {
+            Date isWeekEnd = sdf.parse(date);
+            Calendar calendar = Calendar.getInstance();
             calendar.setTime(isWeekEnd);
-            if(isWeekEnd.compareTo(df.parse(todayDay)) <= 0){
-                if(!holiday.contains(date) && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY){
+            if (isWeekEnd.compareTo(sdf.parse(todayDay)) <= 0) {
+                if (!holiday.contains(date) && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                     shouldWordDays += 1;
                 }
             }
@@ -420,12 +520,12 @@
         Double attCheckOnDuration = 0.0;
         // 考勤下午时间
         Double attCheckOffDuration = 0.0;
-        for(Attendance attendance : attendanceRecordList){
+        for (Attendance attendance : attendanceRecordList) {
             // 上班打卡时间不为空并且打卡状态不为出差外出的考勤记录
-            if(ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)){
+            if (ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                 LocalDateTime attCheckOnTime = attendance.getActualWorkStartTime().toLocalDateTime();
-                LocalDateTime scheduleStartTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0,10) +" " + user.getSysRostering().getLunchStartTime().toString() + ":00",formatter2);
-                if(attCheckOnTime.compareTo(scheduleStartTime) <= 0){
+                LocalDateTime scheduleStartTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchStartTime().toString() + ":00", formatter2);
+                if (attCheckOnTime.compareTo(scheduleStartTime) <= 0) {
                     // 获得两个时间之间的相差值
                     Duration duration = Duration.between(attCheckOnTime, scheduleStartTime);
                     Long minutes = duration.toMinutes();
@@ -434,36 +534,46 @@
                 }
             }
             // 下班打卡时间不为空并且打卡状态不为出差外出的考勤记录
-            if(ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)){
+            if (ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
                 LocalDateTime attCheckOffTime = attendance.getActualWorkEndTime().toLocalDateTime();
-                LocalDateTime scheduleEndTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0,10) +" " + user.getSysRostering().getLunchEndTime().toString() + ":00",formatter2);
-                if(attCheckOffTime.compareTo(scheduleEndTime) > 0){
+                LocalDateTime scheduleEndTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchEndTime().toString() + ":00", formatter2);
+                if (attCheckOffTime.compareTo(scheduleEndTime) > 0) {
                     // 获得两个时间之间的相差值
                     Duration duration = Duration.between(scheduleEndTime, attCheckOffTime);
                     Long minutes = duration.toMinutes();
-                    Double hour = Double.valueOf(String.valueOf(new BigDecimal(Double.valueOf(minutes) / 60 ).setScale(2, BigDecimal.ROUND_HALF_UP)));
+                    Double hour = Double.valueOf(String.valueOf(new BigDecimal(Double.valueOf(minutes) / 60).setScale(2, BigDecimal.ROUND_HALF_UP)));
                     attCheckOffDuration = attCheckOffDuration + hour;
                 }
             }
         }
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
-        String startTime = startDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime());
-        String endTime = df.format(new Date()) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkEndTime());
+        String startTime = sdfFirstDate.substring(0, 10) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime());
+        String endTime = todayDay.substring(0, 10) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkEndTime());
         // 外出时长
         Double goOutTimes = 0.0;
         // 查询外出表
-        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId,Timestamp.valueOf(startTime).toLocalDateTime(),Timestamp.valueOf(endTime).toLocalDateTime());
-        for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
+        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, Timestamp.valueOf(startTime).toLocalDateTime(), Timestamp.valueOf(endTime).toLocalDateTime());
+        for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
             goOutTimes = goOutTimes + attendanceGoOut.getOutDuration();
         }
         // 出差时长
         Double bussTimes = 0.0;
         // 查询出差表
-        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId,Timestamp.valueOf(startDate + " " + "00:00:00").toLocalDateTime(),Timestamp.valueOf(df.format(new Date()) + " " + "00:00:00").toLocalDateTime());
-        for(AttendanceBusinessTravel attendanceBusinessTravel : attendanceBusinessTravelList){
+        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId, Timestamp.valueOf(sdfFirstDate).toLocalDateTime(), Timestamp.valueOf(todayDay.substring(0, 10) + " " + "00:00:00").toLocalDateTime());
+        for (AttendanceBusinessTravel attendanceBusinessTravel : attendanceBusinessTravelList) {
             bussTimes = bussTimes + attendanceBusinessTravel.getTravelDuration();
         }
         returnData.put("Times", attCheckOnDuration + attCheckOffDuration + goOutTimes + (bussTimes * 8));
+
+        // 任务日报查询类
+        TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria();
+        taskDaliyQueryCriteria.setUserId(userId);
+        taskDaliyQueryCriteria.setTargetYearMonth(sdfDate.substring(0, 7));
+        // 查询某月已完成工时
+        Double completedWork = taskDaliyService.queryCompletedWork(taskDaliyQueryCriteria, true);
+        // 月初到今天绩效时长
+        returnData.put("achievementsTime", completedWork);
+
         return returnData;
     }
 
@@ -475,6 +585,7 @@
             UserDto user = findById(id);
             delCaches(user.getId(), user.getUsername());
         }
+        redisUtils.del(CacheKey.TOTAL_USER);
         userRepository.deleteAllByIdIn(ids);
     }
 
@@ -513,8 +624,8 @@
         // 验证文件上传的格式
         String image = "gif jpg png jpeg";
         String fileType = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
-        if(fileType != null && !image.contains(fileType)){
-            throw new BadRequestException("文件格式错误!, 仅支持 " + image +" 格式");
+        if (fileType != null && !image.contains(fileType)) {
+            throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式");
         }
         User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername());
         String oldPath = user.getAvatarPath();
@@ -546,7 +657,7 @@
         for (UserDto userDTO : queryAll) {
             List<String> roles = userDTO.getRoles().stream().map(RoleSmallDto::getName).collect(Collectors.toList());
             String levelName = userDTO.getLevelId() != null ? sysLevelRepository.findById(userDTO.getLevelId()).orElseGet(SysLevel::new).getName() : "";
-            SystemSetting systemSetting = systemSettingRepository.findByValue(userDTO.getCompany());
+            SysCompany sysCompany = sysCompanyRepository.findById(userDTO.getCompany().getId()).orElseGet(SysCompany::new);
             Map<String, Object> map = new LinkedHashMap<>();
             map.put("用户名", userDTO.getUsername());
             map.put("角色", roles);
@@ -556,7 +667,7 @@
             map.put("钉钉号", userDTO.getDingding());
             map.put("排班", userDTO.getSysRostering().getName());
             map.put("级别", levelName);
-            map.put("所属公司", systemSetting == null ? "" : systemSetting.getLabel());
+            map.put("所属公司", sysCompany == null ? "" : sysCompany.getLabel());
             map.put("状态", userDTO.getEnabled() ? "启用" : "禁用");
             map.put("手机号码", userDTO.getPhone());
             map.put("修改密码的时间", userDTO.getPwdResetTime());
@@ -587,6 +698,7 @@
 
     /**
      * 判断用户级别变更
+     *
      * @param userId
      * @param oldLevelId
      * @param newLevelId
@@ -606,7 +718,7 @@
             // 判断旧用户级别工资是否为空
             if (oldSysUserLevelWage != null && oldSysUserLevelWage.getId() != null) {
                 // 旧日期字符串
-                String oldDateString = oldSysUserLevelWage.getStartDate().toString().substring(0,10);
+                String oldDateString = oldSysUserLevelWage.getStartDate().toString().substring(0, 10);
                 // 获取当前日期
                 Date nowDate = new Date();
                 // 创建Calendar实例
@@ -614,7 +726,7 @@
                 // 设置当前时间
                 nowCalendar.setTime(nowDate);
                 // 新日期字符串
-                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
+                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 10);
                 // 判断新、旧日期字符串
                 if (oldDateString.equals(nowDateString)) {
                     throw new BadRequestException("每天只能调整一次级别,请明日再试!");
@@ -633,7 +745,7 @@
             // 判断旧用户级别保险是否为空
             if (oldSysUserLevelInsurance != null && oldSysUserLevelInsurance.getId() != null) {
                 // 旧日期字符串
-                String oldDateString = oldSysUserLevelInsurance.getStartDate().toString().substring(0,10);
+                String oldDateString = oldSysUserLevelInsurance.getStartDate().toString().substring(0, 10);
                 // 获取当前日期
                 Date nowDate = new Date();
                 // 创建Calendar实例
@@ -641,7 +753,7 @@
                 // 设置当前时间
                 nowCalendar.setTime(nowDate);
                 // 新日期字符串
-                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
+                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 10);
                 // 判断新、旧日期字符串
                 if (oldDateString.equals(nowDateString)) {
                     throw new BadRequestException("每天只能调整一次级别,请明日再试!");
@@ -660,7 +772,7 @@
             // 判断旧用户级别其他是否为空
             if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) {
                 // 旧日期字符串
-                String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10);
+                String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0, 10);
                 // 获取当前日期
                 Date nowDate = new Date();
                 // 创建Calendar实例
@@ -668,7 +780,7 @@
                 // 设置当前时间
                 nowCalendar.setTime(nowDate);
                 // 新日期字符串
-                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
+                String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 10);
                 // 判断新、旧日期字符串
                 if (oldDateString.equals(nowDateString)) {
                     throw new BadRequestException("每天只能调整一次级别,请明日再试!");
@@ -689,6 +801,7 @@
 
     /**
      * 创建用户级别工资
+     *
      * @param userId
      * @param levelId
      */
@@ -742,6 +855,7 @@
 
     /**
      * 创建用户级别其他
+     *
      * @param userId
      * @param levelId
      */
@@ -758,4 +872,6 @@
         // 保存
         sysUserLevelOtherRepository.save(sysUserLevelOther);
     }
+
+
 }

--
Gitblit v1.9.3