xuhy
2026-03-11 ef32f6913325bb593d537b4ff433545f73ecb79a
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
@@ -226,23 +226,35 @@
    @Override
    public PageInfo<ClockInStatisticsDto> getClockInStatistics(ClockInStatisticsVo query) {
        PageInfo<ClockInStatisticsDto> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<Long> appUserIds = new ArrayList<>();
        List<Long> appUserIds1 = new ArrayList<>();
        List<Long> appUserIds2 = new ArrayList<>();
        List<Long> appUserIds3 = new ArrayList<>();
        //处理查询条件
        if(StringUtils.isNotEmpty(query.getName())){
            R<List<XpOperationsUser>> listR = xpOperationUserClient.listByName(query.getName());
            if(listR.getCode() == Constants.SUCCESS){
                List<Long> collect = listR.getData().stream().map(XpOperationsUser::getId).collect(Collectors.toList());
                appUserIds.addAll(collect);
                appUserIds1.addAll(collect);
            }
            appUserIds.add(0L);
            appUserIds1.add(0L);
        }
        if(null != query.getRoleId()){
            R<List<XpOperationsRole>> roleByRoleId = xpOperationUserClient.getXpOperationsRoleByRoleId(query.getRoleId());
            if(roleByRoleId.getCode() == Constants.SUCCESS){
                List<Long> collect = roleByRoleId.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList());
                appUserIds.addAll(collect);
                appUserIds2.addAll(collect);
            }
            appUserIds.add(0L);
            appUserIds2.add(0L);
        }
        if(StringUtils.isNotEmpty(query.getName()) && null != query.getRoleId()){
            for (Long l : appUserIds1) {
                if(appUserIds2.contains(l)){
                    appUserIds3.add(l);
                }
            }
        }else{
            appUserIds3.addAll(appUserIds1);
            appUserIds3.addAll(appUserIds2);
        }
        String startTime = "";
@@ -253,7 +265,7 @@
            endTime = statisticDate.split(" - ")[1].split(" ")[0];
        }
        //查询数据
        List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds, startTime, endTime);
        List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds3, startTime, endTime);
        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();
@@ -272,7 +284,8 @@
            }
            Integer shouldClockInDays = clockInStatistic.getShouldClockInDays();
            Integer clockInDays = clockInStatistic.getClockInDays();
            clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays);
            Integer lateEarly = clockInStatistic.getLateEarly();
            clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays - lateEarly);
        }
        pageInfo.setRecords(clockInStatistics);
        return pageInfo;
@@ -287,23 +300,35 @@
    @Override
    public void exportClockInStatistics(ClockInStatisticsVo query, HttpServletResponse response) {
        PageInfo<ClockInStatisticsDto> pageInfo = new PageInfo<>(0, 10000);
        List<Long> appUserIds = new ArrayList<>();
        List<Long> appUserIds1 = new ArrayList<>();
        List<Long> appUserIds2 = new ArrayList<>();
        List<Long> appUserIds3 = new ArrayList<>();
        //处理查询条件
        if(StringUtils.isNotEmpty(query.getName())){
            R<List<XpOperationsUser>> listR = xpOperationUserClient.listByName(query.getName());
            if(listR.getCode() == Constants.SUCCESS){
                List<Long> collect = listR.getData().stream().map(XpOperationsUser::getId).collect(Collectors.toList());
                appUserIds.addAll(collect);
                appUserIds1.addAll(collect);
            }
            appUserIds.add(0L);
            appUserIds1.add(0L);
        }
        if(null != query.getRoleId()){
            R<List<XpOperationsRole>> roleByRoleId = xpOperationUserClient.getXpOperationsRoleByRoleId(query.getRoleId());
            if(roleByRoleId.getCode() == Constants.SUCCESS){
                List<Long> collect = roleByRoleId.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList());
                appUserIds.addAll(collect);
                appUserIds2.addAll(collect);
            }
            appUserIds.add(0L);
            appUserIds2.add(0L);
        }
        if(StringUtils.isNotEmpty(query.getName()) && null != query.getRoleId()){
            for (Long l : appUserIds1) {
                if(appUserIds2.contains(l)){
                    appUserIds3.add(l);
                }
            }
        }else{
            appUserIds3.addAll(appUserIds1);
            appUserIds3.addAll(appUserIds2);
        }
        String startTime = "";
        String endTime = "";
@@ -313,7 +338,7 @@
            endTime = statisticDate.split(" - ")[1].split(" ")[0];
        }
        //查询数据
        List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds, startTime, endTime);
        List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds3, startTime, endTime);
        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();
@@ -331,7 +356,8 @@
            }
            Integer shouldClockInDays = clockInStatistic.getShouldClockInDays();
            Integer clockInDays = clockInStatistic.getClockInDays();
            clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays);
            Integer lateEarly = clockInStatistic.getLateEarly();
            clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays - lateEarly);
        }
        ExcelUtil<ClockInStatisticsDto> excel = new ExcelUtil<ClockInStatisticsDto>(ClockInStatisticsDto.class);