| | |
| | | return list.toArray(new Long[list.size()]); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getPerformanceDetail(Long nextMonth) { |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 |
| | | //本月第一天 |
| | | Calendar c = Calendar.getInstance(); |
| | | c.add(Calendar.MONTH, 0); |
| | | c.set(Calendar.DAY_OF_MONTH, 1); |
| | | String todayMonth = df.format(c.getTime()); |
| | | String nextMonth_ = df.format(new Date(nextMonth)); |
| | | List<TaskDaliyMongo> daliyMongoList; |
| | | try { |
| | | daliyMongoList = mongoTemplate.find(Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()).and("fillDate").gte(new SimpleDateFormat("yyyy-MM-dd").parse(todayMonth)).lte(new SimpleDateFormat("yyyy-MM-dd").parse(nextMonth_))), TaskDaliyMongo.class); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | List<Map> resultList = new ArrayList<>(); |
| | | for (TaskDaliyMongo taskDaliyMongo : daliyMongoList) { |
| | | String taskName = taskDaliyMongo.getTaskUserMongo().getTask().getName(); |
| | | Double taskConsumeHours = taskDaliyMongo.getConsumedHours(); |
| | | if (resultList.isEmpty()) { |
| | | Map map = new HashMap(); |
| | | map.put("name", taskName); |
| | | map.put("value", taskConsumeHours); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | findList(resultList, taskName, taskConsumeHours); |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | /* |
| | | 方法作用: |
| | | 遍历resultList 集合将集合中的元素逐个遍历,如果有元素与当前任务的任务名称相等 |
| | | 如果任务名称相等,取出当前元素并且将当前任务的消耗工时添加进元素中 |
| | | */ |
| | | private static void findList(List<Map> resultList, String taskName, Double taskConsumeHours) { |
| | | boolean flag = false; |
| | | for (Map map : resultList) { |
| | | if (map.get("name").equals(taskName)) { |
| | | // 有 |
| | | Double value = (Double) map.get("value"); |
| | | value += taskConsumeHours; |
| | | map.put("value", value); |
| | | flag = true; |
| | | } |
| | | } |
| | | // 无 |
| | | if (!flag) { |
| | | Map newMap = new HashMap(); |
| | | newMap.put("name", taskName); |
| | | newMap.put("value", taskConsumeHours); |
| | | resultList.add(newMap); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<Long> getPidNode(ArrayList<Long> list, Long deptId_leaf) { |
| | | Long pidId = deptRepository.findPidIdByDeptId(deptId_leaf); |
| | | if (pidId != null) { |
| | |
| | | |
| | | //查询日志表 |
| | | 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<>(); |
| | | 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); |
| | | 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()); |
| | | map.put(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0").format(taskDaliy.getFillDate()), taskDaliy.getConsumedHours()); |
| | | } |
| | | } |
| | | for (Map.Entry<String, Double> entry : map.entrySet()) { |
| | |
| | | if (entry.getValue() >= 8) { |
| | | calendarVo.setDate(entry.getKey()); |
| | | calendarVo.setIsOk(true); |
| | | calendarVo.setTitle("工时:"+entry.getValue()); |
| | | calendarVo.setTitle("工时:" + entry.getValue()); |
| | | calendarVo.setType(2); |
| | | } else { |
| | | calendarVo.setDate(entry.getKey()); |
| | | calendarVo.setIsOk(false); |
| | | calendarVo.setTitle("已填工时:"+entry.getValue()+" 不足8小时,请补充日报"); |
| | | calendarVo.setTitle("已填工时:" + entry.getValue() + " 不足8小时,请补充日报"); |
| | | calendarVo.setType(2); |
| | | } |
| | | calendarInfo.add(calendarVo); |
| | | } |
| | | |
| | | 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); |
| | | 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); |
| | | } |
| | | return calendarInfo; |
| | | } |
| | | |
| | |
| | | Double completedWork = 0D; |
| | | List<TaskDaliyMongo> daliyMongoList = mongoTemplate.find(Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()).and("fillDate").gte(new SimpleDateFormat("yyyy-MM-dd").parse(startTime)).lte(new SimpleDateFormat("yyyy-MM-dd").parse(endTime))), TaskDaliyMongo.class); |
| | | for (TaskDaliyMongo taskDaliyMongo : daliyMongoList) { |
| | | if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")){ |
| | | if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) { |
| | | // 绩效任务 |
| | | if (taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours()) { |
| | | // 如果当前的绩效任务中,用户填写的日报超出了绩效时长就以绩效任务中绩效时长为准 |