churf
2023-09-06 988982dbaf75aa9d728522f1331a250e612fb506
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -40,6 +40,7 @@
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;
@@ -476,23 +477,43 @@
        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 = "";
                System.out.println(date);
            CalendarVo dailyVo = new CalendarVo();
                if (map.get(date) != null) {
                    // 如果在map中找到了它的值,说明用户填写过日报
                    break;
                }
            dailyVo.setDate(date);
            for (Attendance attendanceRecord : attendanceList) {
                type1 = attendanceRecord.getStartClockResults();
@@ -698,6 +719,7 @@
        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);
        // 月初到今天绩效时长