From 1b978faa6df37feb92ea84f08fc63dbf0d120efb Mon Sep 17 00:00:00 2001
From: churf <123456>
Date: Thu, 07 Sep 2023 01:27:46 +0000
Subject: [PATCH] 首页日报查看进度逻辑修改

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java |  394 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 298 insertions(+), 96 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 5d2acc3..373e335 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
@@ -40,6 +40,8 @@
 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.TaskDaliyMongo;
+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;
@@ -49,9 +51,13 @@
 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;
@@ -100,6 +106,8 @@
     private final TaskDaliyService taskDaliyService;
     private final DeptRepository deptRepository;
 
+    private final MongoTemplate mongoTemplate;
+
     @Override
     public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
         Page<User> page = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
@@ -108,29 +116,193 @@
 
     @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;
+        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 = "'AllUser'")
+    public List<DeptAndUser> getUserDept() {
+        List<Dept> all = deptRepository.findAll();
+        List<DeptAndUser> result = new ArrayList<>();
+        // 根节点
+        for (Dept dept : all) {
+            if (dept.getPid() == null) {
+                //没有上级部门,他们就是最顶级的菜单
+                DeptAndUser deptAndUser = new DeptAndUser();
+                deptAndUser.setValue(dept.getId());
+                deptAndUser.setLabel(dept.getName());
+                result.add(deptAndUser);
+            }
+        }
+        List<DeptAndUser> list = new ArrayList<>();
+
+        for (Dept dept : all) {
+            // 一级节点
+            if (dept.getPid() != null) {
+                if (dept.getPid().equals(result.get(0).getValue())) {
+                    DeptAndUser deptAndUser = new DeptAndUser();
+                    deptAndUser.setLabel(dept.getName());
+                    deptAndUser.setValue(dept.getId());
+                    list.add(deptAndUser);
+                }
+            }
+        }
+        result.get(0).setChildren(list);
+
+        for (int i = 0; i < list.size(); i++) {
+            // 二级节点
+            List<DeptAndUser> list_two = new ArrayList<>();
+            for (Dept dept : all) {
+                if (dept.getPid() != null) {
+                    if (dept.getPid().equals(result.get(0).getChildren().get(i).getValue())) {
+                        DeptAndUser deptAndUser = new DeptAndUser();
+                        deptAndUser.setLabel(dept.getName());
+                        deptAndUser.setValue(dept.getId());
+                        list_two.add(deptAndUser);
+                    }
+                }
+            }
+            result.get(0).getChildren().get(i).setChildren(list_two);
+        }
+
+        for (int i = 0; i < result.get(0).getChildren().size(); i++) {
+            for (int j = 0; j < result.get(0).getChildren().get(i).getChildren().size(); j++) {
+                ArrayList<DeptAndUser> list_three = new ArrayList<>();
+                for (Dept dept : all) {
+                    if (dept.getPid() != null) {
+                        if (dept.getPid().equals(result.get(0).getChildren().get(i).getChildren().get(j).getValue())) {
+                            DeptAndUser deptAndUser = new DeptAndUser();
+                            deptAndUser.setLabel(dept.getName());
+                            deptAndUser.setValue(dept.getId());
+                            list_three.add(deptAndUser);
+                        }
+                    }
+                }
+                result.get(0).getChildren().get(i).getChildren().get(j).setChildren(list_three);
+            }
+        }
+
+        for (int i = 0; i < result.get(0).getChildren().size(); i++) {
+            for (int j = 0; j < result.get(0).getChildren().get(i).getChildren().size(); j++) {
+                for (int r = 0; r < result.get(0).getChildren().get(i).getChildren().get(j).getChildren().size(); r++) {
+                    ArrayList<DeptAndUser> list_four = new ArrayList<>();
+                    if (!(deptRepository.findById(result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getValue()).get().getSubCount() == 0)) {
+                        // 当前节点不是叶子节点
+                        for (Dept dept : all) {
+                            if (dept.getPid() != null) {
+                                if (dept.getPid().equals(result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getValue())) {
+                                    DeptAndUser deptAndUser = new DeptAndUser();
+                                    deptAndUser.setValue(dept.getId());
+                                    deptAndUser.setLabel(dept.getName());
+                                    list_four.add(deptAndUser);
+                                }
+                            }
+                        }
+                        result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).setChildren(list_four);
+                    }
+                }
+            }
+        }
+
+        //return result;
+        recursionGetData(result);
+        return result;
+    }
+
+
+    public void recursionGetData(List<DeptAndUser> list) {
+        for (DeptAndUser deptAndUser : list) {
+            if (deptAndUser.getChildren() == null) {
+                deptAndUser.setChildren(new ArrayList<DeptAndUser>());
+            }
+            if (deptAndUser.getChildren().size() > 0) {
+                recursionGetData(deptAndUser.getChildren());
+            }
+            List<User> users = userRepository.findByDeptIdInAndEnabledWithSingle(deptAndUser.getValue(), true);
+            for (User user : users) {
+                DeptAndUser result_deptAndUser = new DeptAndUser();
+                result_deptAndUser.setValue(user.getId());
+                result_deptAndUser.setLabel(user.getNickName());
+                deptAndUser.getChildren().add(result_deptAndUser);
+            }
+        }
+    }
+
+    @Override
+    public Long[] getUserPidDept(Long id) {
+        ArrayList<Long> list = new ArrayList<>();
+        Long deptId_leaf = userRepository.findDeptIdByUserId(id);
+        list.add(id);
+        list.add(0, deptId_leaf);
+        list = getPidNode(list, deptId_leaf);
+        return list.toArray(new Long[list.size()]);
+    }
+
+    private ArrayList<Long> getPidNode(ArrayList<Long> list, Long deptId_leaf) {
+        Long pidId = deptRepository.findPidIdByDeptId(deptId_leaf);
+        if (pidId != null) {
+            list.add(0, pidId);
+            getPidNode(list, pidId);
+        }
+        return list;
+    }
+
 
     @Override
     @Cacheable(key = "'total'")
@@ -146,7 +318,7 @@
         List<User> users = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
         List<UserDto> usersDto = userMapper.toDto(users);
         // 循环用户
-        for (int i= 0; i < usersDto.size(); i ++) {
+        for (int i = 0; i < usersDto.size(); i++) {
             // 根据用户ID、指定年月查询用户级别工资
             SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findTargetYearMonth(usersDto.get(i).getId(), calendarStr);
             // 判断用户级别工资是否为空
@@ -214,15 +386,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());
@@ -265,6 +438,7 @@
 
     /**
      * 获取日历信息
+     *
      * @param month
      * @return
      * @throws Exception
@@ -281,8 +455,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"));
@@ -303,50 +477,71 @@
         Long duration = (Duration.between(user.getSysRostering().getWorkStartTime(), user.getSysRostering().getWorkEndTime())).toHours();
 
         //查询日志表
-        List<TaskDaliy> taskDaliyList = taskDaliyRepository.findAllByUserAndDate(userId,startDate,endDate);
-        for (TaskDaliy taskDaliy : taskDaliyList) {
-            CalendarVo daily = new CalendarVo();
-            daily.setDate(taskDaliy.getFillDate().toString());
-            if (dateList.contains(taskDaliy.getFillDate().toString())) {
-                dateList.remove(taskDaliy.getFillDate().toString());
+        List<TaskDaliyMongo> taskDaliyList = mongoTemplate.find(Query.query(new Criteria("userId").is(userId).and("fillDate").gte(startDate).lte(endDate)), TaskDaliyMongo.class);
+        Map<String,Double> map = new HashMap<>();
+        for (TaskDaliyMongo taskDaliy : taskDaliyList) {
+            if (map.get(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0").format(taskDaliy.getFillDate())) != null) {
+                // 如果已经有了
+                Double todayHours = map.get(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0").format(taskDaliy.getFillDate()));
+                todayHours += taskDaliy.getConsumedHours();
+                map.put(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0").format(taskDaliy.getFillDate()),todayHours);
+            } else {
+                map.put(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0").format(taskDaliy.getFillDate()),taskDaliy.getConsumedHours());
             }
-            daily.setIsOk(taskDaliy.getConsumedHours().compareTo(new Double(duration - 1)) >= 0 ? true : false);
-            daily.setTitle(taskDaliy.getConsumedHours().compareTo(new Double(duration - 1)) >= 0 ? "工时: " + taskDaliy.getConsumedHours().toString() : "已填工时:" + taskDaliy.getConsumedHours().toString() + " 不满8小时,请补充日报");
-            daily.setType(2);
-            calendarInfo.add(daily);
+        }
+        for (Map.Entry<String, Double> entry : map.entrySet()) {
+            CalendarVo calendarVo = new CalendarVo();
+            if (entry.getValue() >= 8) {
+                calendarVo.setDate(entry.getKey());
+                calendarVo.setIsOk(true);
+                calendarVo.setTitle("工时:"+entry.getValue());
+                calendarVo.setType(2);
+            } else {
+                calendarVo.setDate(entry.getKey());
+                calendarVo.setIsOk(false);
+                calendarVo.setTitle("已填工时:"+entry.getValue()+" 不足8小时,请补充日报");
+                calendarVo.setType(2);
+            }
+            calendarInfo.add(calendarVo);
         }
 
-        for (String date : dateList) {
-            String type1 = "";
-            String type2 = "";
-            CalendarVo dailyVo = new CalendarVo();
-            dailyVo.setDate(date);
-            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)){
-                    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)){
-                    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)){
-                    dailyVo.setTitle("休息");
-                    dailyVo.setIsOk(true);
-                }else if(date.equals(df.format(attendanceRecord.getAttendanceDate()))){
-                    dailyVo.setTitle("日报未填写,请补充日报");
-                    dailyVo.setIsOk(false);
+            for (String date : dateList) {
+                String type1 = "";
+                String type2 = "";
+                System.out.println(date);
+                CalendarVo dailyVo = new CalendarVo();
+                if (map.get(date) != null) {
+                    // 如果在map中找到了它的值,说明用户填写过日报
+                    continue;
                 }
+                dailyVo.setDate(date);
+                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)) {
+                        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)) {
+                        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)) {
+                        dailyVo.setTitle("休息");
+                        dailyVo.setIsOk(true);
+                    } else if (date.equals(df.format(attendanceRecord.getAttendanceDate()))) {
+                        dailyVo.setTitle("日报未填写,请补充日报");
+                        dailyVo.setIsOk(false);
+                    }
+                }
+                dailyVo.setType(2);
+                calendarInfo.add(dailyVo);
             }
-            dailyVo.setType(2);
-            calendarInfo.add(dailyVo);
-        }
         return calendarInfo;
     }
 
     /**
      * 判断状态
+     *
      * @param result
      * @return
      */
@@ -397,7 +592,8 @@
     }
 
     /**
-     *获取用户基础信息
+     * 获取用户基础信息
+     *
      * @return
      * @throws ParseException
      */
@@ -417,8 +613,8 @@
         // 出勤天数
         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++;
             }
         }
@@ -427,12 +623,12 @@
         Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
         returnData.put("annualLeave", yearTimes);
         // 查询当月的补卡记录的条数
-        Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0,7));
+        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));
         }
 
@@ -447,19 +643,19 @@
             }
         }
         // 获取当月所有日期
-        List<String> dateList = DateTimeUtil.getDayByMonth(sdfDate.substring(0,4), sdfDate.substring(5,7));
+        List<String> dateList = DateTimeUtil.getDayByMonth(sdfDate.substring(0, 4), sdfDate.substring(5, 7));
         Date date1 = new Date();
         String todayDay = sdf.format(date1);
-        if (!todayDay.substring(0,7).equals(sdfDate.substring(0,7))) {
+        if (!todayDay.substring(0, 7).equals(sdfDate.substring(0, 7))) {
             todayDay = sdfLastDate;
         }
         // 工作日的天数
-        for(String date : dateList){
+        for (String date : dateList) {
             Date isWeekEnd = sdf.parse(date);
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(isWeekEnd);
-            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){
+            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;
                 }
             }
@@ -474,12 +670,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();
@@ -488,33 +684,33 @@
                 }
             }
             // 下班打卡时间不为空并且打卡状态不为出差外出的考勤记录
-            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 = sdfFirstDate.substring(0,10) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime());
-        String endTime = todayDay.substring(0,10) + " " + 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(sdfFirstDate).toLocalDateTime(),Timestamp.valueOf(todayDay.substring(0,10) + " " + "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));
@@ -522,7 +718,8 @@
         // 任务日报查询类
         TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria();
         taskDaliyQueryCriteria.setUserId(userId);
-        taskDaliyQueryCriteria.setTargetYearMonth(sdfDate.substring(0,7));
+        taskDaliyQueryCriteria.setTargetYearMonth(sdfDate.substring(0, 7));
+        taskDaliyQueryCriteria.setTargetYearMonth(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(yearMonth));
         // 查询某月已完成工时
         Double completedWork = taskDaliyService.queryCompletedWork(taskDaliyQueryCriteria, true);
         // 月初到今天绩效时长
@@ -578,8 +775,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();
@@ -652,6 +849,7 @@
 
     /**
      * 判断用户级别变更
+     *
      * @param userId
      * @param oldLevelId
      * @param newLevelId
@@ -671,7 +869,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实例
@@ -679,7 +877,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("每天只能调整一次级别,请明日再试!");
@@ -698,7 +896,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实例
@@ -706,7 +904,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("每天只能调整一次级别,请明日再试!");
@@ -725,7 +923,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实例
@@ -733,7 +931,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("每天只能调整一次级别,请明日再试!");
@@ -754,6 +952,7 @@
 
     /**
      * 创建用户级别工资
+     *
      * @param userId
      * @param levelId
      */
@@ -807,6 +1006,7 @@
 
     /**
      * 创建用户级别其他
+     *
      * @param userId
      * @param levelId
      */
@@ -823,4 +1023,6 @@
         // 保存
         sysUserLevelOtherRepository.save(sysUserLevelOther);
     }
+
+
 }

--
Gitblit v1.9.3