| | |
| | | import me.zhengjie.modules.system.service.mapstruct.UserMapper; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.service.TaskDaliyService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria; |
| | | import me.zhengjie.utils.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.cache.annotation.CacheConfig; |
| | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final SysUserCompanyRepository sysUserCompanyRepository; |
| | | private final SysCompanyRepository sysCompanyRepository; |
| | | private final TaskDaliyService taskDaliyService; |
| | | |
| | | @Override |
| | | public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { |
| | |
| | | * @throws ParseException |
| | | */ |
| | | @Override |
| | | public Map getUserBaseInfo() throws ParseException { |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | public Map getUserBaseInfo(Date yearMonth) throws ParseException { |
| | | // 返回集合 |
| | | Map returnData = new HashMap(); |
| | | LocalDate startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate endDate = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()); |
| | | List<Attendance> attendanceRecordList = attendanceRepository.findAllByUserAndDate(userId, startDate.toString(), endDate.toString()); |
| | | // 当前登录用户 |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | // 目标年月字符串 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String sdfDate = sdf.format(yearMonth); |
| | | // 目标年月初字符串 |
| | | String sdfFirstDate = DateUtil.getFirstDayOfMonthFull(sdfDate); |
| | | // 目标年月末字符串 |
| | | String sdfLastDate = DateUtil.getLastDayOfMonthFull(sdfDate); |
| | | // 出勤天数 |
| | | 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)){ |
| | | numDay++; |
| | | } |
| | | } |
| | | // 出勤天数 |
| | | returnData.put("onDutyDays", numDay); |
| | | // 剩余年假 |
| | | Double yearTimes = attendanceLeaveService.getYearTimeLength(userId); |
| | | returnData.put("annualLeave", yearTimes); |
| | | // 剩余补卡 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 获取当前年 |
| | | int year = calendar.get(Calendar.YEAR); |
| | | // 获取当前月 |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String mouths = ""; |
| | | if(month < 10){ |
| | | mouths = "0" + month; |
| | | } |
| | | String baseDate = year + "-" + mouths; |
| | | // 查询当月的补卡记录的条数 |
| | | Integer count = attendanceCardreplacementRepository.count(userId, baseDate); |
| | | Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0,7)); |
| | | // 查询配置表的每月补卡次数 |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("每月可补卡次数"); |
| | | if(count >= sysConfigProportion.getProportion()){ |
| | |
| | | returnData.put("cardLeft", (sysConfigProportion.getProportion() - count)); |
| | | } |
| | | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 法定节假日 |
| | | List<String> holiday = new ArrayList<>(); |
| | | // 天数 |
| | |
| | | List<SysConfigHoliday> holidayConfigurationList = sysConfigHolidayRepository.findAll(); |
| | | for (SysConfigHoliday holidayConfiguration : holidayConfigurationList) { |
| | | if (holidayConfiguration.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) { |
| | | holiday.add(df.format(holidayConfiguration.getHolidayDate())); |
| | | holiday.add(sdf.format(holidayConfiguration.getHolidayDate())); |
| | | } |
| | | } |
| | | // 获取当月所有日期 |
| | | List<String> dateList = DateTimeUtil.getDayByMonth(); |
| | | List<String> dateList = DateTimeUtil.getDayByMonth(sdfDate.substring(0,4), sdfDate.substring(5,7)); |
| | | Date date1 = new Date(); |
| | | String todayDay = df.format(date1); |
| | | String todayDay = sdf.format(date1); |
| | | if (!todayDay.substring(0,7).equals(sdfDate.substring(0,7))) { |
| | | todayDay = sdfLastDate; |
| | | } |
| | | // 工作日的天数 |
| | | for(String date : dateList){ |
| | | Date isWeekEnd = df.parse(date); |
| | | Date isWeekEnd = sdf.parse(date); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(isWeekEnd); |
| | | if(isWeekEnd.compareTo(df.parse(todayDay)) <= 0){ |
| | | 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; |
| | | } |
| | |
| | | } |
| | | } |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | String startTime = startDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime()); |
| | | String endTime = df.format(new Date()) + " " + 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; |
| | | // 查询外出表 |
| | |
| | | // 出差时长 |
| | | Double bussTimes = 0.0; |
| | | // 查询出差表 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId,Timestamp.valueOf(startDate + " " + "00:00:00").toLocalDateTime(),Timestamp.valueOf(df.format(new Date()) + " " + "00:00:00").toLocalDateTime()); |
| | | 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)); |
| | | |
| | | // 任务日报查询类 |
| | | TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria(); |
| | | taskDaliyQueryCriteria.setUserId(userId); |
| | | taskDaliyQueryCriteria.setTargetYearMonth(sdfDate.substring(0,7)); |
| | | // 查询某月已完成工时 |
| | | Double completedWork = taskDaliyService.queryCompletedWork(taskDaliyQueryCriteria, true); |
| | | // 月初到今天绩效时长 |
| | | returnData.put("achievementsTime", completedWork); |
| | | |
| | | return returnData; |
| | | } |
| | | |
| | |
| | | for (UserDto userDTO : queryAll) { |
| | | List<String> roles = userDTO.getRoles().stream().map(RoleSmallDto::getName).collect(Collectors.toList()); |
| | | String levelName = userDTO.getLevelId() != null ? sysLevelRepository.findById(userDTO.getLevelId()).orElseGet(SysLevel::new).getName() : ""; |
| | | SysUserCompany sysUserCompany = sysUserCompanyRepository.findById(userDTO.getCompanyId()).orElseGet(SysUserCompany::new); |
| | | SysCompany sysCompany = sysCompanyRepository.findById(userDTO.getCompanyId()).orElseGet(SysCompany::new); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户名", userDTO.getUsername()); |
| | | map.put("角色", roles); |
| | |
| | | map.put("钉钉号", userDTO.getDingding()); |
| | | map.put("排班", userDTO.getSysRostering().getName()); |
| | | map.put("级别", levelName); |
| | | map.put("所属公司", sysUserCompany == null ? "" : sysUserCompany.getLabel()); |
| | | map.put("所属公司", sysCompany == null ? "" : sysCompany.getLabel()); |
| | | map.put("状态", userDTO.getEnabled() ? "启用" : "禁用"); |
| | | map.put("手机号码", userDTO.getPhone()); |
| | | map.put("修改密码的时间", userDTO.getPwdResetTime()); |
| | |
| | | // 保存 |
| | | sysUserLevelOtherRepository.save(sysUserLevelOther); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<UserDto> findByRoleLevel(Integer level) { |
| | | // 根据角色等级查询用户 |
| | | return userMapper.toDto(userRepository.findByRoleLevel(level)); |
| | | } |
| | | } |