| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(key = "'AllUser'") |
| | | public List<DeptAndUser> getUserDept() { |
| | | List<Dept> all = deptRepository.findAll(); |
| | | List<DeptAndUser> result = new ArrayList<>(); |
| | |
| | | if (dept.getPid() == null) { |
| | | //没有上级部门,他们就是最顶级的菜单 |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setId(dept.getId()); |
| | | deptAndUser.setValue(dept.getId()); |
| | | deptAndUser.setLabel(dept.getName()); |
| | | result.add(deptAndUser); |
| | | } |
| | |
| | | for (Dept dept : all) { |
| | | // 一级节点 |
| | | if (dept.getPid() != null) { |
| | | if (dept.getPid().equals(result.get(0).getId())) { |
| | | if (dept.getPid().equals(result.get(0).getValue())) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setLabel(dept.getName()); |
| | | deptAndUser.setId(dept.getId()); |
| | | deptAndUser.setValue(dept.getId()); |
| | | list.add(deptAndUser); |
| | | } |
| | | } |
| | |
| | | List<DeptAndUser> list_two = new ArrayList<>(); |
| | | for (Dept dept : all) { |
| | | if (dept.getPid() != null) { |
| | | if (dept.getPid().equals(result.get(0).getChildren().get(i).getId())) { |
| | | if (dept.getPid().equals(result.get(0).getChildren().get(i).getValue())) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setLabel(dept.getName()); |
| | | deptAndUser.setId(dept.getId()); |
| | | deptAndUser.setValue(dept.getId()); |
| | | list_two.add(deptAndUser); |
| | | } |
| | | } |
| | |
| | | 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).getId())) { |
| | | if (dept.getPid().equals(result.get(0).getChildren().get(i).getChildren().get(j).getValue())) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setLabel(dept.getName()); |
| | | deptAndUser.setId(dept.getId()); |
| | | deptAndUser.setValue(dept.getId()); |
| | | list_three.add(deptAndUser); |
| | | } |
| | | } |
| | |
| | | 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).getId()).get().getSubCount() == 0)) { |
| | | 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).getId())) { |
| | | if (dept.getPid().equals(result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getValue())) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setId(dept.getId()); |
| | | deptAndUser.setValue(dept.getId()); |
| | | deptAndUser.setLabel(dept.getName()); |
| | | list_four.add(deptAndUser); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < result.get(0).getChildren().size(); i++) { |
| | | if (result.get(0).getChildren().get(i).getChildren() != null) { |
| | | for (int j = 0; j < result.get(0).getChildren().get(i).getChildren().size(); j++) { |
| | | if (result.get(0).getChildren().get(i).getChildren().get(j).getChildren() != null) { |
| | | for (int r = 0; r < result.get(0).getChildren().get(i).getChildren().get(j).getChildren().size(); r++) { |
| | | if (result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getChildren() != null) { |
| | | for (int s = 0; s < result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getChildren().size(); s++) { |
| | | if (result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getChildren().get(s).getChildren() == null) { |
| | | List<User> byDeptIdInAndEnabledWithSingle = userRepository.findByDeptIdInAndEnabledWithSingle(result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getChildren().get(s).getId(), true); |
| | | List<DeptAndUser> newList = new ArrayList<>(); |
| | | for (User user : byDeptIdInAndEnabledWithSingle) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setLabel(user.getNickName()); |
| | | deptAndUser.setId(user.getId()); |
| | | newList.add(deptAndUser); |
| | | } |
| | | result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getChildren().get(s).setChildren(newList); |
| | | } |
| | | } |
| | | } else { |
| | | List<User> byDeptIdInAndEnabledWithSingle = userRepository.findByDeptIdInAndEnabledWithSingle(result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).getId(), true); |
| | | List<DeptAndUser> newList = new ArrayList<>(); |
| | | for (User user : byDeptIdInAndEnabledWithSingle) { |
| | | DeptAndUser deptAndUser = new DeptAndUser(); |
| | | deptAndUser.setLabel(user.getNickName()); |
| | | deptAndUser.setId(user.getId()); |
| | | newList.add(deptAndUser); |
| | | } |
| | | result.get(0).getChildren().get(i).getChildren().get(j).getChildren().get(r).setChildren(newList); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | @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; |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria(); |
| | | taskDaliyQueryCriteria.setUserId(userId); |
| | | taskDaliyQueryCriteria.setTargetYearMonth(sdfDate.substring(0, 7)); |
| | | taskDaliyQueryCriteria.setTargetYearMonth(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(yearMonth)); |
| | | // 查询某月已完成工时 |
| | | Double completedWork = taskDaliyService.queryCompletedWork(taskDaliyQueryCriteria, true); |
| | | // 月初到今天绩效时长 |