| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.model.account.SysRole; |
| | | import com.xiaopeng.api.model.account.XpOperationsRole;import com.xiaopeng.api.model.account.XpOperationsUser;import com.xiaopeng.api.model.maintenance.XpCheckLocation; |
| | | import com.xiaopeng.api.model.maintenance.XpClockIn; |
| | | import com.xiaopeng.api.model.maintenance.XpShift; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | List<String> appUserIdList = clockInStatistics.stream().map(ClockInStatisticsDto::getAppUserId).collect(Collectors.toList()); |
| | | List<Long> ids = appUserIdList.stream().map(Long::parseLong).collect(Collectors.toList()); |
| | | List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(ids).getData(); |
| | | Map<Long, XpOperationsUserWithRoleVO> userMap = data.stream().collect(Collectors.toMap(XpOperationsUserWithRoleVO::getId, Function.identity())); |
| | | //将查询结果组装成map对象,用于循环中提取数据 |
| | | for (ClockInStatisticsDto clockInStatistic : clockInStatistics) { |
| | | String appUserId = clockInStatistic.getAppUserId(); |
| | | //运维账号可以拥有多个角色 |
| | | List<XpOperationsUserWithRoleVO> collect = data.stream().filter(x->x.getId().equals(Long.parseLong(appUserId))).collect(Collectors.toList()); |
| | | if(!collect.isEmpty()){ |
| | | XpOperationsUserWithRoleVO xpOperationsUserWithRoleVO = collect.get(0); |
| | | clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName()); |
| | | if(CollUtil.isNotEmpty(userMap)){ |
| | | XpOperationsUserWithRoleVO vo = userMap.get(Long.parseLong(appUserId)); |
| | | if (Objects.nonNull(vo)) { |
| | | clockInStatistic.setName(vo.getNickName()); |
| | | String roleName = vo.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";")); |
| | | clockInStatistic.setRoleName(roleName); |
| | | } |
| | | } |
| | | String roleName = collect.stream().map(XpOperationsUserWithRoleVO::getRoleName).collect(Collectors.joining(";")); |
| | | clockInStatistic.setRoleName(roleName); |
| | | Integer shouldClockInDays = clockInStatistic.getShouldClockInDays(); |
| | | Integer clockInDays = clockInStatistic.getClockInDays(); |
| | | clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays); |
| | |
| | | List<String> appUserIdList = clockInStatistics.stream().map(ClockInStatisticsDto::getAppUserId).collect(Collectors.toList()); |
| | | List<Long> ids = appUserIdList.stream().map(Long::parseLong).collect(Collectors.toList()); |
| | | List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(ids).getData(); |
| | | Map<Long, XpOperationsUserWithRoleVO> userMap = data.stream().collect(Collectors.toMap(XpOperationsUserWithRoleVO::getId, Function.identity())); |
| | | for (ClockInStatisticsDto clockInStatistic : clockInStatistics) { |
| | | String appUserId = clockInStatistic.getAppUserId(); |
| | | //运维账号可以拥有多个角色 |
| | | List<XpOperationsUserWithRoleVO> collect = data.stream().filter(x->x.getId().equals(Long.parseLong(appUserId))).collect(Collectors.toList()); |
| | | if(!collect.isEmpty()){ |
| | | XpOperationsUserWithRoleVO xpOperationsUserWithRoleVO = collect.get(0); |
| | | clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName()); |
| | | if(CollUtil.isNotEmpty(userMap)){ |
| | | XpOperationsUserWithRoleVO vo = userMap.get(Long.parseLong(appUserId)); |
| | | if (Objects.nonNull(vo)) { |
| | | clockInStatistic.setName(vo.getNickName()); |
| | | String roleName = vo.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";")); |
| | | clockInStatistic.setRoleName(roleName); |
| | | } |
| | | } |
| | | String roleName = collect.stream().map(XpOperationsUserWithRoleVO::getRoleName).collect(Collectors.joining(";")); |
| | | clockInStatistic.setRoleName(roleName); |
| | | Integer shouldClockInDays = clockInStatistic.getShouldClockInDays(); |
| | | Integer clockInDays = clockInStatistic.getClockInDays(); |
| | | clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays); |
| | |
| | | //将查询结果组装成map对象,用于循环中提取数据 |
| | | for (ClockInStatisticsDetailsDto clockInStatistic : clockInStatisticsDetails) { |
| | | clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName()); |
| | | clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoleName()); |
| | | clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";"))); |
| | | } |
| | | pageInfo.setRecords(clockInStatisticsDetails); |
| | | return pageInfo; |
| | |
| | | //将查询结果组装成map对象,用于循环中提取数据 |
| | | for (ClockInStatisticsDetailsDto clockInStatistic : clockInStatisticsDetails) { |
| | | clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName()); |
| | | clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoleName()); |
| | | clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";"))); |
| | | } |
| | | |
| | | ExcelUtil<ClockInStatisticsDetailsDto> excel = new ExcelUtil<ClockInStatisticsDetailsDto>(ClockInStatisticsDetailsDto.class); |