| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.config.FileProperties; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.exception.EntityExistException; |
| | | import me.zhengjie.exception.EntityNotFoundException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.impl.AttendanceLeaveServiceImpl; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.project.repository.ProjectRepository; |
| | | import me.zhengjie.modules.quartz.utils.DateTimeUtil; |
| | | import me.zhengjie.modules.security.service.OnlineUserService; |
| | | import me.zhengjie.modules.security.service.UserCacheManager; |
| | | import me.zhengjie.modules.system.domain.*; |
| | | import me.zhengjie.exception.EntityExistException; |
| | | import me.zhengjie.exception.EntityNotFoundException; |
| | | import me.zhengjie.modules.system.domain.vo.CalendarVo; |
| | | import me.zhengjie.modules.system.repository.*; |
| | | import me.zhengjie.modules.system.service.UserService; |
| | | import me.zhengjie.modules.system.service.dto.*; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserMapper; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserSmallMapper; |
| | | 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; |
| | | import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria; |
| | | import me.zhengjie.modules.task.service.dto.TaskDaliyMongoDto; |
| | | import me.zhengjie.modules.treatment.domain.*; |
| | | import me.zhengjie.modules.treatment.repository.*; |
| | | import me.zhengjie.modules.treatment.rest.CmnInsuranceController; |
| | | import me.zhengjie.utils.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.CacheManager; |
| | | import org.springframework.cache.annotation.CacheConfig; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | |
| | | public class UserServiceImpl implements UserService { |
| | | |
| | | private final UserRepository userRepository; |
| | | private final ProjectRepository projectRepository; |
| | | private final UserMapper userMapper; |
| | | private final UserSmallMapper userSmallMapper; |
| | | private final FileProperties properties; |
| | | private final RedisUtils redisUtils; |
| | | private final UserCacheManager userCacheManager; |
| | |
| | | private final SysUserLevelInsuranceRepository sysUserLevelInsuranceRepository; |
| | | private final SysUserLevelOtherRepository sysUserLevelOtherRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final TaskDaliyRepository taskDaliyRepository; |
| | | private final AttendanceLeaveServiceImpl attendanceLeaveService; |
| | | private final AttendanceCardreplacementRepository attendanceCardreplacementRepository; |
| | | private final SysConfigProportionRepository sysConfigProportionRepository; |
| | |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final SysCompanyRepository sysCompanyRepository; |
| | | private final TaskDaliyService taskDaliyService; |
| | | private final DeptRepository deptRepository; |
| | | private final MeritLevelRepository meritLevelRepository; |
| | | private final CmnLevelRepository cmnLevelRepository; |
| | | private final MeritWageRepository meritWageRepository; |
| | | private final CmnLevelRankRepository cmnLevelRankRepository; |
| | | private final CmnInsuranceRepository cmnInsuranceRepository; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getPerformanceDetail(Long nextMonth) throws ParseException { |
| | | public List<TaskDaliyMongo> getPerformanceDetail(Long nextMonth) throws ParseException { |
| | | 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)); |
| | | String nextMonth_ = df.format(new Date(nextMonth)).substring(0,7) + "-01"; |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(df.parse(nextMonth_)); |
| | | cal.add(Calendar.MONTH, 1); |
| | |
| | | String nextMonthFirstDay = df.format(cal.getTime()); |
| | | 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); |
| | | daliyMongoList = mongoTemplate.find(Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()).and("fillDate").gte(new SimpleDateFormat("yyyy-MM-dd").parse(nextMonth_)).lt(new SimpleDateFormat("yyyy-MM-dd").parse(nextMonthFirstDay))), TaskDaliyMongo.class); |
| | | daliyMongoList = mongoTemplate.find( |
| | | Query.query( |
| | | new Criteria("userId").is(SecurityUtils.getCurrentUserId()) |
| | | .and("fillDate") |
| | | .gte(new SimpleDateFormat("yyyy-MM-dd").parse(nextMonth_)) |
| | | .lt(new SimpleDateFormat("yyyy-MM-dd").parse(nextMonthFirstDay))) |
| | | .with(Sort.by(Sort.Order.desc("fillDate"))) |
| | | , TaskDaliyMongo.class); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | List<Map> resultList = new ArrayList<>(); |
| | | for (TaskDaliyMongo taskDaliyMongo : daliyMongoList) { |
| | | String taskName = taskDaliyMongo.getTaskUserMongo().getTask().getName(); |
| | | if (resultList.isEmpty()) { |
| | | Map map = new HashMap(); |
| | | map.put("name", taskName); |
| | | if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) { |
| | | map.put("value", taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | } else { |
| | | map.put("value", taskDaliyMongo.getConsumedHours()); |
| | | } |
| | | map.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | findList(resultList, taskDaliyMongo); |
| | | } |
| | | |
| | | for (Map map : resultList) { |
| | | ArrayList<Map> list = new ArrayList<>(); |
| | | for (Object key : map.keySet()) { |
| | | if (!key.equals("name") && !key.equals("value")) { |
| | | Map innerMap = new HashMap(); |
| | | innerMap.put(key, map.get(key)); |
| | | list.add(innerMap); |
| | | Collection<TaskDaliyMongo> daliyMongoValues = daliyMongoList.stream().collect( |
| | | Collectors.groupingBy( |
| | | (TaskDaliyMongo taskDaliyMongo) -> taskDaliyMongo.getTaskUserMongo().getTask().getName(), |
| | | Collectors.reducing( |
| | | null, |
| | | (TaskDaliyMongo prev, TaskDaliyMongo cur) -> { |
| | | if (prev == null) { |
| | | cur.getTaskProgress(); |
| | | cur.getTaskUserMongo().getPerformanceHours(); |
| | | cur.getTaskUserMongo().getPerformanceType(); |
| | | if ("1".equals(cur.getTaskUserMongo().getPerformanceType())) { |
| | | cur.setConsumedHours(BigDecimal.valueOf(cur.getTaskUserMongo().getPerformanceHours()) |
| | | .multiply(BigDecimal.valueOf(cur.getTaskProgress())) |
| | | .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | return cur; |
| | | } |
| | | map.put("list", list); |
| | | if ("0".equals(cur.getTaskUserMongo().getPerformanceType())) { |
| | | prev.setConsumedHours(prev.getConsumedHours() + cur.getConsumedHours()); |
| | | } |
| | | return resultList; |
| | | return prev; |
| | | } |
| | | ) |
| | | ) |
| | | ).values(); |
| | | return new ArrayList<>(daliyMongoValues); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return userList; |
| | | } |
| | | |
| | | /* |
| | | 方法作用: |
| | | 遍历resultList 集合将集合中的元素逐个遍历,如果有元素与当前任务的任务名称相等 |
| | | 如果任务名称相等,取出当前元素并且将当前任务的消耗工时添加进元素中 |
| | | */ |
| | | private static void findList(List<Map> resultList, TaskDaliyMongo taskDaliyMongo) { |
| | | boolean flag = false; |
| | | for (Map map : resultList) { |
| | | if (map.get("name").equals(taskDaliyMongo.getTaskUserMongo().getTask().getName())) { |
| | | // 有 |
| | | Double value = (Double) map.get("value"); |
| | | value += taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours(); |
| | | map.put("value", value); |
| | | map.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | flag = true; |
| | | } |
| | | } |
| | | // 无 |
| | | if (!flag) { |
| | | Map newMap = new HashMap(); |
| | | if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) { |
| | | newMap.put("name", taskDaliyMongo.getTaskUserMongo().getTask().getName()); |
| | | newMap.put("value", taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | newMap.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | } else { |
| | | newMap.put("name", taskDaliyMongo.getTaskUserMongo().getTask().getName()); |
| | | newMap.put("value", taskDaliyMongo.getConsumedHours()); |
| | | newMap.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours()); |
| | | } |
| | | resultList.add(newMap); |
| | | } |
| | | @Override |
| | | public void findByUserIdInAndCompanyId(List<Long> userIds, Long companyId) { |
| | | userRepository.findByUserIdInAndCompanyId(userIds, companyId); |
| | | } |
| | | |
| | | private ArrayList<Long> getPidNode(ArrayList<Long> list, Long deptId_leaf) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Cacheable(key = "'total'") |
| | | // @Cacheable(key = "'total'") |
| | | // @CacheEvict(value = "total", allEntries = true) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<UserDto> queryAll(UserQueryCriteria criteria) { |
| | | criteria.setEnabled(true); |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | public List<UserSmallDto> querySmallAll(UserQueryCriteria criteria) { |
| | | // 日历类 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 日期格式化 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 日历字符串 |
| | | String calendarStr = sdf.format(calendar.getTime()); |
| | | // 只查询有效数据 |
| | | criteria.setEnabled(true); |
| | | // 查询用户数据 |
| | | List<User> users = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)); |
| | | List<UserSmallDto> usersDto = userSmallMapper.toDto(users); |
| | | // 循环用户 |
| | | for (int i = 0; i < usersDto.size(); i++) { |
| | | // 根据用户ID、指定年月查询用户级别工资 |
| | | SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findTargetYearMonth(usersDto.get(i).getId(), calendarStr); |
| | | // 判断用户级别工资是否为空 |
| | | if (sysUserLevelWage != null) { |
| | | // 根据ID查询用户级别 |
| | | SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelWage.getLevelId()).orElseGet(SysLevel::new); |
| | | // 用户 |
| | | usersDto.get(i).setLevelName(sysLevel.getName()); |
| | | } else { |
| | | // 用户 |
| | | usersDto.get(i).setLevelName(null); |
| | | } |
| | | } |
| | | return usersDto; |
| | | } |
| | | |
| | | @Override |
| | | // @Cacheable(key = "'total'") |
| | | // @CacheEvict(value = "total", allEntries = true) |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | public List<UserDto> queryAll(UserQueryCriteria criteria) { |
| | | // 日历类 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 日期格式化 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 日历字符串 |
| | | String calendarStr = sdf.format(calendar.getTime()); |
| | | // 只查询有效数据 |
| | | criteria.setEnabled(true); |
| | | // 查询用户数据 |
| | | List<User> users = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)); |
| | | List<UserDto> usersDto = userMapper.toDto(users); |
| | |
| | | redisUtils.del("user::AllUser"); |
| | | userRepository.save(resources); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(resources.getId(), null, resources.getLevelId()); |
| | | // checkUserLevel(resources.getId(), null, resources.getLevelId()); |
| | | // 判断用户级别变更(新) |
| | | checkUserLevelNew(resources); |
| | | } |
| | |
| | | } |
| | | |
| | | //获取应工作时长 |
| | | User user = userRepository.getById(userId); |
| | | Long duration = (Duration.between(user.getSysRostering().getWorkStartTime(), user.getSysRostering().getWorkEndTime())).toHours(); |
| | | // User user = userRepository.getById(userId); |
| | | // Long duration = (Duration.between(user.getSysRostering().getWorkStartTime(), user.getSysRostering().getWorkEndTime())).toHours(); |
| | | |
| | | //查询日志表 |
| | | List<TaskDaliyMongo> taskDaliyList = mongoTemplate.find(Query.query(new Criteria("userId").is(userId).and("fillDate").gte(startDate).lte(endDate)), TaskDaliyMongo.class); |
| | |
| | | for (String date : dateList) { |
| | | String type1 = ""; |
| | | String type2 = ""; |
| | | System.out.println(date); |
| | | CalendarVo dailyVo = new CalendarVo(); |
| | | if (map.get(date) != null) { |
| | | // 如果在map中找到了它的值,说明用户填写过日报 |
| | |
| | | } |
| | | returnData.put("Times", attCheckOnDuration + attCheckOffDuration + goOutTimes + (bussTimes * 8)); |
| | | |
| | | // 任务日报查询类 |
| | | 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 = 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.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours()) { |
| | | // // 如果当前的绩效任务中,用户填写的日报超出了绩效时长就以绩效任务中绩效时长为准 |
| | | // completedWork += taskDaliyMongo.getTaskUserMongo().getPerformanceHours(); |
| | | // } else { |
| | | // completedWork += taskDaliyMongo.getConsumedHours(); |
| | | // } |
| | | // //判断集合中填写的日报是否一个任务填写次数超过1次 |
| | | // |
| | | // } else { |
| | | // // 非绩效任务 |
| | | // completedWork += taskDaliyMongo.getConsumedHours(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | DecimalFormat decimalFormat = new DecimalFormat("#"); |
| | | DecimalFormat decimalFormat = new DecimalFormat("0.##"); |
| | | decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
| | | |
| | | 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); |
| | | 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))) |
| | | .with(Sort.by(Sort.Order.desc("fillDate"))) |
| | | , TaskDaliyMongo.class); |
| | | |
| | | //根据日报中项目分配字段的id去重,并保留日报进度最高的 |
| | | Map<Object, TaskDaliyMongo> uniqueMap = daliyMongoList.stream() |
| | | .collect(Collectors.toMap( |
| | | taskDaliyMongo -> taskDaliyMongo.getTaskUserMongo().getId(), |
| | | taskDaliyMongo -> taskDaliyMongo, |
| | | (existing, replacement) -> existing.getTaskProgress() > replacement.getTaskProgress() ? existing : replacement)); |
| | | |
| | | List<TaskDaliyMongo> taskDaliyMongoList = new ArrayList<>(uniqueMap.values()); |
| | | for (TaskDaliyMongo taskDaliyMongo : taskDaliyMongoList) { |
| | | //绩效 |
| | | if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) { |
| | | List<TaskDaliyMongoDto> resultList = daliyMongoList.stream().collect( |
| | | Collectors.groupingBy( |
| | | (TaskDaliyMongo taskDaliyMongo) -> taskDaliyMongo.getTaskUserMongo().getId(), |
| | | Collectors.reducing( |
| | | null, |
| | | (TaskDaliyMongo prev, TaskDaliyMongo cur) -> { |
| | | if (prev == null) { |
| | | if ("1".equals(cur.getTaskUserMongo().getPerformanceType())) { |
| | | cur.setConsumedHours(BigDecimal.valueOf(cur.getTaskUserMongo().getPerformanceHours()) |
| | | .multiply(BigDecimal.valueOf(cur.getTaskProgress())) |
| | | .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | return cur; |
| | | } |
| | | if ("0".equals(cur.getTaskUserMongo().getPerformanceType())) { |
| | | prev.setConsumedHours(prev.getConsumedHours() + cur.getConsumedHours()); |
| | | } |
| | | return prev; |
| | | } |
| | | ) |
| | | ) |
| | | ).values().stream().map(taskDaliyMongo -> { |
| | | if ("1".equals(taskDaliyMongo.getTaskUserMongo().getPerformanceType())) { |
| | | // 查询日报表是否存在小于当前月填写的当前任务的日报 |
| | | List<TaskDaliyMongo> taskDaliyMongoSm = mongoTemplate.find(Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()).and("old_task_id").is(taskDaliyMongo.getOld_task_id()).and("fillDate").lte(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime))).with(Sort.by(Sort.Direction.DESC, "fillDate")), TaskDaliyMongo.class); |
| | | List<TaskDaliyMongo> taskDaliyMongoSm = null; |
| | | try { |
| | | taskDaliyMongoSm = mongoTemplate.find( |
| | | Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()) |
| | | .and("taskUserMongo").is(taskDaliyMongo.getTaskUserMongo()) |
| | | .and("fillDate").lt(new SimpleDateFormat("yyyy-MM-dd").parse(startTime))) |
| | | .with(Sort.by(Sort.Direction.DESC, "fillDate")), TaskDaliyMongo.class); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //跨月 |
| | | if (taskDaliyMongoSm.size() > 0) { |
| | | Double horseValue1 = Double.valueOf(decimalFormat.format((taskDaliyMongoSm.get(0).getTaskProgress() / 100) * taskDaliyMongo.getTaskUserMongo().getPerformanceHours())); |
| | | horseValue1 = taskDaliyMongo.getTaskUserMongo().getPerformanceHours() - horseValue1; |
| | | completedWork += horseValue1; |
| | | } else { |
| | | completedWork += taskDaliyMongo.getTaskUserMongo().getPerformanceHours(); |
| | | BigDecimal lastValue = BigDecimal.valueOf(taskDaliyMongoSm.get(0).getTaskProgress()) |
| | | .multiply(BigDecimal.valueOf(taskDaliyMongoSm.get(0).getTaskUserMongo().getPerformanceHours())) |
| | | .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); |
| | | taskDaliyMongo.setConsumedHours(BigDecimal.valueOf(taskDaliyMongo.getConsumedHours()).subtract(lastValue).doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 非绩效 |
| | | for (TaskDaliyMongo taskDaliyMongo : daliyMongoList) { |
| | | //非绩效 |
| | | if (!taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) { |
| | | completedWork += taskDaliyMongo.getConsumedHours(); |
| | | } |
| | | } |
| | | return taskDaliyMongo; |
| | | }) |
| | | // .collect( |
| | | // Collectors.groupingBy( |
| | | // (TaskDaliyMongo taskDaliyMongo) -> taskDaliyMongo.getTaskUserMongo().getTask().getId(), |
| | | // Collectors.reducing( |
| | | // null, |
| | | // (TaskDaliyMongo prev, TaskDaliyMongo cur) -> { |
| | | // if (prev == null) { |
| | | // return cur; |
| | | // } |
| | | // prev.setConsumedHours(prev.getConsumedHours() + cur.getConsumedHours()); |
| | | // return prev; |
| | | // } |
| | | // ) |
| | | // ) |
| | | // ).values().stream() |
| | | .map(taskDaliyMongo -> { |
| | | TaskDaliyMongoDto dto = new TaskDaliyMongoDto(); |
| | | dto.setId(taskDaliyMongo.getId()); |
| | | dto.setFillDate(taskDaliyMongo.getFillDate()); |
| | | dto.setUserNickName(userRepository.findById(SecurityUtils.getCurrentUserId()).get().getNickName()); |
| | | dto.setProjectId(taskDaliyMongo.getTaskUserMongo().getTask().getProjectId()); |
| | | dto.setProjectName(projectRepository.findById(taskDaliyMongo.getTaskUserMongo().getTask().getProjectId()).get().getName()); |
| | | dto.setTaskName(taskDaliyMongo.getTaskUserMongo().getTask().getName()); |
| | | dto.setTaskId(taskDaliyMongo.getTaskUserMongo().getTask().getId()); |
| | | dto.setConsumedHours(BigDecimal.valueOf(taskDaliyMongo.getConsumedHours()).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | dto.setTaskProgress(taskDaliyMongo.getTaskProgress()); |
| | | dto.setSettlementStatus(taskDaliyMongo.getSettlementStatus()); |
| | | dto.setRemarks(taskDaliyMongo.getRemarks()); |
| | | dto.setTaskUserMongo(taskDaliyMongo.getTaskUserMongo()); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | // 月初到今天绩效时长 |
| | | returnData.put("achievementsTime", completedWork); |
| | | returnData.put("achievementsTime", resultList.stream().mapToDouble(TaskDaliyMongoDto::getConsumedHours).sum()); |
| | | // 绩效详细 |
| | | returnData.put("achievementsList", resultList); |
| | | |
| | | return returnData; |
| | | } |
| | |
| | | @Override |
| | | public void download(List<UserDto> queryAll, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | 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() : ""; |
| | | SysCompany sysCompany = sysCompanyRepository.findById(userDTO.getCompany().getId()).orElseGet(SysCompany::new); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户名", userDTO.getUsername()); |
| | | map.put("角色", roles); |
| | | map.put("部门", userDTO.getDept().getName()); |
| | | map.put("岗位", userDTO.getJobs().stream().map(JobSmallDto::getName).collect(Collectors.toList())); |
| | | map.put("邮箱", userDTO.getEmail()); |
| | | map.put("钉钉号", userDTO.getDingding()); |
| | | map.put("排班", userDTO.getSysRostering().getName()); |
| | | map.put("级别", levelName); |
| | | map.put("所属公司", sysCompany == null ? "" : sysCompany.getLabel()); |
| | | map.put("状态", userDTO.getEnabled() ? "启用" : "禁用"); |
| | | map.put("手机号码", userDTO.getPhone()); |
| | | map.put("修改密码的时间", userDTO.getPwdResetTime()); |
| | | map.put("创建日期", userDTO.getCreateTime()); |
| | | list.add(map); |
| | | } |
| | | // for (UserSmallDto 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() : ""; |
| | | // SysCompany sysCompany = sysCompanyRepository.findById(userDTO.getCompany().getId()).orElseGet(SysCompany::new); |
| | | // Map<String, Object> map = new LinkedHashMap<>(); |
| | | // map.put("用户名", userDTO.getUsername()); |
| | | // map.put("角色", roles); |
| | | // map.put("部门", userDTO.getDept().getName()); |
| | | // map.put("岗位", userDTO.getJobs().stream().map(JobSmallDto::getName).collect(Collectors.toList())); |
| | | // map.put("邮箱", userDTO.getEmail()); |
| | | // map.put("钉钉号", userDTO.getDingding()); |
| | | // map.put("排班", userDTO.getSysRostering().getName()); |
| | | // map.put("级别", levelName); |
| | | // map.put("所属公司", sysCompany == null ? "" : sysCompany.getLabel()); |
| | | // map.put("状态", userDTO.getEnabled() ? "启用" : "禁用"); |
| | | // map.put("手机号码", userDTO.getPhone()); |
| | | // map.put("修改密码的时间", userDTO.getPwdResetTime()); |
| | | // map.put("创建日期", userDTO.getCreateTime()); |
| | | // list.add(map); |
| | | // } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | |
| | | sysUserLevelOther.setUserId(resources.getId()); |
| | | sysUserLevelOther.setLevelId(cmnLevel.getId()); |
| | | sysUserLevelOther.setPersonalPerformanceProportion(Double.valueOf(0)); |
| | | sysUserLevelOther.setStartDate(Timestamp.valueOf(LocalDate.now().atStartOfDay())); |
| | | // 计算剩余年假 |
| | | Double annualLeave = getAnnualLeave(calendar); |
| | | sysUserLevelOther.setAnnualLeaveDays(annualLeave); |
| | |
| | | } |
| | | // 日期设置为 明年/后年 年初 |
| | | sysUserLevelOther1.setYearMonth(sdf.format(calendar1.getTime())); |
| | | sysUserLevelOther1.setStartDate(new Timestamp(calendar1.getTimeInMillis())); |
| | | sysUserLevelOtherRepository.save(sysUserLevelOther1); |
| | | } |
| | | } |