| | |
| | | package com.ruoyi.staff.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | IPage<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftPage(page, time, userName, sysDeptId); |
| | | //查询所有班次(打卡规则) |
| | | List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null); |
| | | mapIPage.getRecords().forEach(i -> { |
| | | String[] shiftTimes = i.getShiftTime().split(";"); |
| | | for (PerformanceShiftMapDto i : mapIPage.getRecords()) { |
| | | List<String> shiftTimes = StrUtil.split(i.getShiftTime(), ";"); |
| | | if(CollUtil.isEmpty(shiftTimes)){ |
| | | continue; |
| | | } |
| | | double totalAttendance = 0;//总出勤天数 |
| | | List<Map<String, Object>> map = new ArrayList<>(); |
| | | // 分割日期 |
| | | for (String shiftTime : shiftTimes) { |
| | | i.setShiftTime(null); |
| | | Map<String, Object> hashMap = new HashMap<>(); |
| | | String[] shiftTimeAndShift = shiftTime.split(":"); |
| | | List<String> shiftTimeAndShift = StrUtil.split(shiftTime, ":"); |
| | | if(CollUtil.isEmpty(shiftTimeAndShift) || shiftTimeAndShift.size() != 3){ |
| | | continue; |
| | | } |
| | | //排班详细数据 |
| | | hashMap.put("id", shiftTimeAndShift[2]); |
| | | hashMap.put("shift", shiftTimeAndShift[1]); |
| | | hashMap.put("time", shiftTimeAndShift[0]); |
| | | hashMap.put("id", shiftTimeAndShift.get(2)); |
| | | hashMap.put("shift", shiftTimeAndShift.get(1)); |
| | | hashMap.put("time", shiftTimeAndShift.get(0)); |
| | | map.add(hashMap); |
| | | i.setList(map); |
| | | //汇总的各班次统计数据 |
| | |
| | | if (!i.getMonthlyAttendance().containsKey(personalAttendanceLocationConfig.getShift())){ |
| | | i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), 0); |
| | | } |
| | | if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift[1])) { |
| | | if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift.get(1))) { |
| | | BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(personalAttendanceLocationConfig.getShift()).toString()); |
| | | i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), bigDecimal.add(new BigDecimal("1"))); |
| | | } |
| | | } |
| | | //统计总出勤天数(早/中/晚/夜)都算出勤,其余都是休息 |
| | | if (shiftTimeAndShift[1].contains("早") || |
| | | shiftTimeAndShift[1].contains("中") || |
| | | shiftTimeAndShift[1].contains("晚") || |
| | | shiftTimeAndShift[1].contains("夜")) { |
| | | if (shiftTimeAndShift.get(1).contains("早") || |
| | | shiftTimeAndShift.get(1).contains("中") || |
| | | shiftTimeAndShift.get(1).contains("晚") || |
| | | shiftTimeAndShift.get(1).contains("夜")) { |
| | | i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | // 获取header时间 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |