zxl
2025-10-17 9e11e94f8a92a62695657bb2b3b59a1cf47058a5
大屏显示问题以及报备导出
5个文件已修改
449 ■■■■■ 已修改文件
ycl-common/src/main/java/annotation/Excel.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java 319 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/annotation/Excel.java
@@ -142,7 +142,7 @@
    /**
     * 自定义数据处理器
     */
    public Class<?> handler() default ExcelHandlerAdapter.class;
    public Class<? extends ExcelHandlerAdapter> handler() default DefaultExcelHandler.class;
    /**
     * 自定义数据处理器参数
ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
@@ -8,12 +8,14 @@
import com.ycl.system.Result;
import com.ycl.system.domain.group.Add;
import com.ycl.system.domain.group.Update;
import com.ycl.utils.StringUtils;
import com.ycl.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,7 @@
 * @author xp
 * @since 2024-03-19
 */
@Slf4j
@Validated
@RequiredArgsConstructor
@Api(value = "报备", tags = "报备管理")
@@ -124,6 +127,11 @@
    public void export(HttpServletResponse response, ReportQuery query)
    {
        List<ReportVO> list = reportService.export(query);
        for (ReportVO reportVO : list){
            if(StringUtils.isBlank(reportVO.getReportContent()) ||"null".equals(reportVO.getReportContent()) ){
                reportVO.setReportContent("暂无");
            }
        }
        ExcelUtil<ReportVO> util = new ExcelUtil<>(ReportVO.class);
        util.exportExcel(response, list, "运维单位");
    }
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -179,8 +179,7 @@
                checkScores = scoreMapper.selectCheckScoreMap(checkScore);
            }
        }
        //分数保留一位小数
        checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(3, RoundingMode.HALF_UP)));
        checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(4, RoundingMode.HALF_UP)));
        Map<Long, List<CheckScore>> map = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
        for (Map.Entry<Long, List<CheckScore>> entry : map.entrySet()) {
            List<CheckScore> tempList = getCheckScores(entry);
@@ -206,13 +205,13 @@
        if (!hasCar){
            CheckScore car = new CheckScore();
            car.setExamineCategory((short) 2);
            car.setScore(new BigDecimal("0.00"));
            car.setScore(new BigDecimal("0.000"));
            tempList.add(car);
        }
        if (!hasFace){
            CheckScore face = new CheckScore();
            face.setExamineCategory((short) 3);
            face.setScore(new BigDecimal("0.00"));
            face.setScore(new BigDecimal("0.000"));
            tempList.add(face);
        }
@@ -566,7 +565,23 @@
    //大屏展示考核得分
    @Override
    public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) {
        Date now = new Date();
//        Date now = new Date();
        Calendar cal = Calendar.getInstance();
// 2. 设置为今年10月12号 00:00:00(清除时分秒,避免当前时间干扰)
        cal.set(Calendar.MONTH, Calendar.OCTOBER);  // 10月(用常量更直观,避免记0基)
// cal.set(Calendar.MONTH, 9);  // 也可以用数字9(不推荐,可读性差)
        cal.set(Calendar.DAY_OF_MONTH, 12);         // 日期设为12号
        cal.set(Calendar.HOUR_OF_DAY, 12);           // 小时设为0(24小时制)
        cal.set(Calendar.MINUTE, 0);                // 分钟设为0
        cal.set(Calendar.SECOND, 0);                // 秒设为0
        cal.set(Calendar.MILLISECOND, 0);           // 毫秒设为0
// 3. 转成Date对象
        Date now = cal.getTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dashboardQuery.setStartTime(format.format(DateUtils.getDayStart(now)));
        dashboardQuery.setEndTime(format.format(DateUtils.getDayEnd(now)));
@@ -588,7 +603,7 @@
            Map<String, Object> map = resultMap.get(checkScore.getDeptName());
            BigDecimal score = checkScore.getScore();
            // 核心逻辑:原始score ×10 → 保留两位小数 → 拼接百分号
            BigDecimal scoreMultiplied = score.multiply(new BigDecimal("10")); // 4.6160 ×10 = 46.160
            BigDecimal scoreMultiplied = score.multiply(new BigDecimal("100"));
            BigDecimal scoreWithTwoDecimals = scoreMultiplied.setScale(2, RoundingMode.HALF_UP); // 保留两位小数:46.16
            String formattedScore = scoreWithTwoDecimals + "%"; // 拼接百分号:46.16%
ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
@@ -1,5 +1,6 @@
package com.ycl.platform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
@@ -322,43 +323,79 @@
    @Override
    public List<ReportVO> export(ReportQuery query) {
        // 1. 分页查询主数据(不变)
        IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class);
        page.setSize(-1);
        query.setUnitId(SecurityUtils.getUnitId());
        baseMapper.page(page, query);
        List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
        Map<String, String> dictMap = errorTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
        page.getRecords().forEach(item -> {
            if (StringUtils.hasText(item.getErrorType())) {
                item.setErrorTypeList(List.of(item.getErrorType().split(",")));
                StringBuilder sb = new StringBuilder();
                item.getErrorTypeList().stream().forEach(err -> {
                    String s = dictMap.get(err);
                    if (org.springframework.util.StringUtils.hasText(s)) {
                        sb.append(s).append("、");
                    }
                });
                item.setErrorType(sb.substring(0, sb.length() - 1));
            }
            // 审核结果
            List<ReportAuditingRecord> records = new LambdaQueryChainWrapper<>(reportAuditingRecordService.getBaseMapper())
                    .eq(ReportAuditingRecord::getReportId, item.getId())
                    .orderByDesc(ReportAuditingRecord::getCreateTime)
                    .last("limit 1")
                    .list();
            if (! CollectionUtils.isEmpty(records)) {
                item.setResultStr(records.get(0).getResult() ? "通过" : "未通过");
                item.setResultRemark(records.get(0).getResultRemark());
                item.setAuditingTime(records.get(0).getCreateTime());
        List<ReportVO> records = page.getRecords();
        if (CollectionUtils.isEmpty(records)) {
            return Collections.emptyList();
        }
        // 2. 批量查询字典数据(不变,建议加缓存)
        List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
        Map<String, String> errorDictMap = errorTypeList.stream()
                .collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel, (k1, k2) -> k2));
        // 3. 批量查询审核记录(核心修改:用子查询替代窗口函数,兼容低版本MySQL)
        List<Integer> reportIds = records.stream().map(ReportVO::getId).collect(Collectors.toList());
        // 子查询:获取每个reportId的最新创建时间
        LambdaQueryWrapper<ReportAuditingRecord> maxTimeQuery = new LambdaQueryWrapper<ReportAuditingRecord>()
                .in(ReportAuditingRecord::getReportId, reportIds)
                .groupBy(ReportAuditingRecord::getReportId)
                .select(ReportAuditingRecord::getReportId, ReportAuditingRecord::getCreateTime); // 分组查reportId和最大时间
        // 主查询:关联子查询,拿到每个reportId最新的审核记录
        List<ReportAuditingRecord> allAuditRecords = reportAuditingRecordService.getBaseMapper().selectList(
                new LambdaQueryWrapper<ReportAuditingRecord>()
                        .in(ReportAuditingRecord::getReportId, reportIds)
                        // 关联子查询,匹配reportId和最新创建时间
                        .inSql(ReportAuditingRecord::getCreateTime,
                                "SELECT MAX(create_time) FROM t_report_auditing_record WHERE report_id IN (" +
                                        reportIds.stream().map(String::valueOf).collect(Collectors.joining(",")) +
                                        ") GROUP BY report_id")
        );
        // 构建reportId -> 最新审核记录的Map(不变)
        Map<Integer, ReportAuditingRecord> auditRecordMap = allAuditRecords.stream()
                .collect(Collectors.toMap(ReportAuditingRecord::getReportId, record -> record, (k1, k2) -> {
                    // 极端情况:同一reportId有相同创建时间的记录,取任意一个(按创建时间倒序取第一个)
                    return k1.getCreateTime().after(k2.getCreateTime()) ? k1 : k2;
                }));
        // 4. 循环处理数据(不变,保留之前的字符串优化和空值处理)
        records.forEach(item -> {
            // 处理故障类型(不变)
            String errorType = item.getErrorType();
            if (StringUtils.hasText(errorType)) {
                String[] errorTypeArr = StringUtils.split(errorType, ",");
                StringJoiner sj = new StringJoiner("、");
                for (String err : errorTypeArr) {
                    String dictLabel = errorDictMap.get(err);
                    if (StringUtils.hasText(dictLabel)) {
                        sj.add(dictLabel);
                    }
                }
                item.setErrorTypeList(Arrays.asList(errorTypeArr));
                item.setErrorType(sj.toString());
            }
            // 处理审核结果(不变,从Map获取)
            ReportAuditingRecord auditRecord = auditRecordMap.get(item.getId());
            if (auditRecord != null) {
                item.setResultStr(auditRecord.getResult() ? "通过" : "未通过");
                item.setResultRemark(auditRecord.getResultRemark());
                item.setAuditingTime(auditRecord.getCreateTime());
            } else {
                item.setResultStr("审核中");
            }
            item.setReportContent(EscapeUtil.clean(item.getReportContent()));
        });
        return page.getRecords();
    }
            item.setReportContent(EscapeUtil.clean(StringUtils.defaultString(item.getReportContent())));
        });
        return records;
    }
    @Override
    public Result auditingRecord(Integer id) {
ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
@@ -563,25 +563,26 @@
     */
    @Override
    public void exportVideoOnline(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException {
        log.error("开始导出数据");
        log.error("传入的月份:{}",exportForm.getMonth());
        //默认查所有部门
        log.info("开始导出数据");
        log.info("传入的月份:{}", exportForm.getMonth());
        // 默认查所有部门
        if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
            List<Integer> deptIds = new ArrayList<>();
            List<Integer> deptIds = new ArrayList<>(AreaDeptEnum.values().length);
            for (AreaDeptEnum value : AreaDeptEnum.values()) {
                deptIds.add(value.getDeptId());
            }
            exportForm.setDeptIds(deptIds);
        }
        List<ExcelExp> sheet = new ArrayList<>();
        //通过Collections静态方法,把list转为线程安全的list
        List mysheet = Collections.synchronizedList(sheet);
        // 使用线程安全的List,预先指定容量
        List<ExcelExp> mysheet = Collections.synchronizedList(new ArrayList<>());
        VideoExportForm.convertTags(exportForm);
        Query query = getQuery(exportForm);
        //月份每日在线数据
        // 月份每日在线数据
        List<TMonitorResult> onlineResult = mongoTemplate.find(query, TMonitorResult.class);
        log.error("月份在线数据:{}条数",onlineResult.size());
        // 使用 Collectors.toMap 去重,保留每个 No 的第一个遇到的元素
        log.info("月份在线数据:{}条数", onlineResult.size());
        // 使用Collectors.toMap去重,保留每个No的第一个遇到的元素
        Map<String, TMonitorResult> uniqueResultsMap = onlineResult.stream()
                .collect(Collectors.toMap(
                        TMonitorResult::getNo, // keyMapper,这里假设 getNo() 返回 No 字段
@@ -590,192 +591,206 @@
                ));
        // 将 Map 转换为 List
        List<TMonitorResult> tMonitorResults = new ArrayList<>(uniqueResultsMap.values());
        log.error("去重后大小:{}",tMonitorResults.size());
        //获取动态列数据
        List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
        List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
        //补充动态列数据
        if (!CollectionUtils.isEmpty(dynamics)) {
            Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
            for (TMonitorResult tMonitorResult : tMonitorResults) {
                Integer pointId = tMonitorResult.getPointId();
                tMonitorResult.setDynamicColumnList(map.get(pointId));
        log.info("去重后大小:{}", tMonitorResults.size());
        // 获取动态列数据并构建缓存Map
        Map<Integer, List<DynamicColumnVO>> dynamicColumnMap = new HashMap<>();
        if (!tMonitorResults.isEmpty()) {
            //获取点位集合
            List<Integer> pointIds = tMonitorResults.stream()
                    .map(TMonitorResult::getPointId)
                    .distinct() // 去重,减少数据库查询
                    .collect(Collectors.toList());
            //获取集合点位的补充列信息
            List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
            if (!CollectionUtils.isEmpty(dynamics)) {
                dynamicColumnMap = dynamics.stream()
                        .collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
            }
            // 补充动态列数据
            for (TMonitorResult result : tMonitorResults) {
                result.setDynamicColumnList(dynamicColumnMap.getOrDefault(result.getPointId(), Collections.emptyList()));
            }
        }
        //存放区域 与 设备列表 map key为 区域
        Map<Integer, List<VideoDailyExp>> map = new HashMap<>();
        List<CompletableFuture<List<VideoDailyExp>>> futures = new ArrayList<>();
        // 按部门分组,减少后续循环中的过滤操作
        Map<Integer, List<TMonitorResult>> deptMonitorMap = tMonitorResults.stream()
                .collect(Collectors.groupingBy(TMonitorResult::getDeptId));
        // 按设备编号分组onlineResult,加速后续查找
        Map<String, List<TMonitorResult>> noToOnlineMap = onlineResult.stream()
                .collect(Collectors.groupingBy(TMonitorResult::getNo));
        // 并行处理各部门数据
        List<CompletableFuture<ExcelExp>> futures = new ArrayList<>(exportForm.getDeptIds().size());
        Map<Integer, List<VideoDailyExp>> deptExpMap = new ConcurrentHashMap<>();
        for (Integer deptId : exportForm.getDeptIds()) {
            CompletableFuture<List<VideoDailyExp>> future = CompletableFuture.supplyAsync(() -> {
                List<VideoDailyExp> videoDailyExps = new ArrayList<>();
                //筛选部门数据
                List<TMonitorResult> monitors = tMonitorResults.stream()
                        .filter(tMonitorResult -> deptId.equals(tMonitorResult.getDeptId()))
                        .collect(Collectors.toList());
                if (CollectionUtils.isEmpty(monitors)) return videoDailyExps;
            // 使用部门ID的最终变量
            final Integer currentDeptId = deptId;
            CompletableFuture<ExcelExp> future = CompletableFuture.supplyAsync(() -> {
                // 直接从预分组的Map中获取,避免每次过滤
                List<TMonitorResult> monitors = deptMonitorMap.getOrDefault(currentDeptId, Collections.emptyList());
                if (monitors.isEmpty()) {
                    return null;
                }
                List<String> ids = monitors.stream()
                        .map(BaseResult::getNo)
                        .collect(Collectors.toList());
                //筛选mongo区县数据
                List<TMonitorResult> onlines = onlineResult.stream()
                        .filter(result -> ids.contains(result.getNo()))
                        .collect(Collectors.toList());
                List<VideoDailyExp> videoDailyExps = new ArrayList<>(monitors.size());
                AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(currentDeptId);
                String areaName = areaDeptEnum == null ? "未知" : areaDeptEnum.getName();
                AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
                for (TMonitorResult result : monitors) {
                    VideoDailyExp videoDailyExp = new VideoDailyExp();
                    videoDailyExp.setSerialNumber(result.getNo());
                    videoDailyExp.setDeviceName(result.getName());
                    videoDailyExp.setType(result.getMonitorType());
                    videoDailyExp.setArea(areaName);
                    videoDailyExp.setArea(areaDeptEnum == null ? "未知" : areaDeptEnum.getName());
                    // 构建标签字符串
                    StringBuilder tag = new StringBuilder();
                    if (result.getProvinceTag()) tag.append("省厅、");
                    if (result.getImportantTag()) tag.append("重点点位、");
                    if (result.getImportantCommandImageTag()) tag.append("重点指挥图像、");
                    if (result.getDeptTag()) tag.append("部级、");
                    StringBuilder tag = new StringBuilder("" +
                            (result.getProvinceTag() ? "省厅、" : "") +
                            (result.getImportantTag() ? "重点点位、" : "") +
                            (result.getImportantCommandImageTag() ? "重点指挥图像、" : "") +
                            (result.getDeptTag() ? "部级、" : ""));
                    //动态列处理加在标签里
                    if (!CollectionUtils.isEmpty(result.getDynamicColumnList())) {
                        for (DynamicColumnVO dynamicColumnVO : result.getDynamicColumnList()) {
                    // 处理动态列
                    List<DynamicColumnVO> dynamicColumns = result.getDynamicColumnList();
                    if (!dynamicColumns.isEmpty()) {
                        for (DynamicColumnVO dynamicColumnVO : dynamicColumns) {
                            tag.append(dynamicColumnVO.getColumnValue()).append("、");
                        }
                    }
                    // 删除字符串末尾的"、"
                    if (tag.toString().endsWith("、")) {
                        tag = new StringBuilder(tag.substring(0, tag.length() - 1));
                    // 移除末尾的"、"
                    if (tag.length() > 0) {
                        tag.setLength(tag.length() - 1);
                    }
                    videoDailyExp.setTag(tag.toString());
                    // 设置在线数据
                    try {
                        // 从预构建的Map中获取,避免每次过滤
                        List<TMonitorResult> onlines = noToOnlineMap.getOrDefault(result.getNo(), Collections.emptyList());
                        setOnlineDaily(videoDailyExp, result, onlines);
                    } catch (Exception e) {
                        log.error(e.getMessage());
                        log.error("设置在线数据异常", e);
                    }
                    videoDailyExps.add(videoDailyExp);
                }
                ExcelExp excelExp = new ExcelExp(
                        areaDeptEnum == null ? "未知" : areaDeptEnum.getName(),
                        videoDailyExps,
                        VideoDailyExp.class
                );
                mysheet.add(excelExp);
                // 存储结果到线程安全的Map
                deptExpMap.put(currentDeptId, videoDailyExps);
                return videoDailyExps;
                return new ExcelExp(areaName, videoDailyExps, VideoDailyExp.class);
            }, threadPoolTaskExecutor);
            futures.add(future);
            map.put(deptId,future.join());
        }
        // 获取全量数据
        List<VideoDailyExp> totalExps = futures.stream()
                .map(CompletableFuture::join)
        // 等待所有并行任务完成
        CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
        // 收集所有部门的ExcelExp结果
        for (CompletableFuture<ExcelExp> future : futures) {
            ExcelExp excelExp = future.join();
            if (excelExp != null) {
                mysheet.add(excelExp);
            }
        }
        // 获取全量数据并添加"全量"sheet
        List<VideoDailyExp> totalExps = deptExpMap.values().stream()
                .flatMap(List::stream)
                .collect(Collectors.toList());
        ExcelExp excelExp = new ExcelExp("全量", totalExps, VideoDailyExp.class);
        mysheet.add(excelExp);
        long face = totalExps.stream().filter(item -> item.getType().contains("1")).count();
        long car = totalExps.stream().filter(item -> item.getType().contains("2")).count();
        long video = totalExps.stream().filter(item -> item.getType().contains("3")).count();
        log.error("人脸数:{}",face);
        log.error("car数:{}",car);
        log.error("video数:{}",video);
        //添加新的sheet 离线数统计表
        List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>();
        mysheet.add(new ExcelExp("全量", totalExps, VideoDailyExp.class));
        //在线率统计表
        List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>();
        for (Integer deptId : map.keySet()){
            List<VideoDailyExp>  list = map.get(deptId);
            AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
            // 添加离线表记录
            //设备类型 1人脸 2车辆 3视频
            //人脸
            log.error("传入部门集合大小:{} + 部门id:{}" ,list.size(),deptId);
            VideoTypeOffOnlineExp faceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum);
            //卡口
            VideoTypeOffOnlineExp carVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum);
            //视频
            VideoTypeOffOnlineExp videoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum);
            VideoOnlineRateExp faceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum);
            //卡口
            VideoOnlineRateExp carVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum);
            //视频
            VideoOnlineRateExp VideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum);
            //将该区域类三种设备类型的 信息 放入 excel对象内
            //放入当前区域的人脸设备相关详细
            videoTypeOffOnlineExps.add(faceVideoTypeOffOnlineExp);
            //放入当前区域的车辆设备相关详细
            videoTypeOffOnlineExps.add(carVideoTypeOffOnlineExp);
            //放入当前区域的视频设备相关详细
            videoTypeOffOnlineExps.add(videoTypeOffOnlineExp);
            videoOnlineRateExps.add(faceVideoOnlineRateExp);
            videoOnlineRateExps.add(carVideoOnlineRateExp);
            videoOnlineRateExps.add(VideoOnlineRateExp);
        // 统计各类型设备数量
        long face = 0, car = 0, video = 0;
        for (VideoDailyExp exp : totalExps) {
            String type = exp.getType();
            if (type.contains("1")) face++;
            if (type.contains("2")) car++;
            if (type.contains("3")) video++;
        }
        //计算自贡市合计
        //插入excel时确保数据出现在最后
        List<VideoTypeOffOnlineExp> allVideoTypeOffOnlineExps = new ArrayList<>();
        //插入excel时确保数据出现在最后
        List<VideoOnlineRateExp> allVideoOnlineRateExps =  new ArrayList<>();
        log.info("人脸数:{}", face);
        log.info("car数:{}", car);
        log.info("video数:{}", video);
        //所有离线数据中,各区设备为人脸的对象  合计装配对象
        VideoTypeOffOnlineExp allFaceVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allFaceVideosOffline,"人脸");
        // 处理离线数统计和在线率统计
        List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>();
        List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>();
        VideoTypeOffOnlineExp allCarVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allCarVideosOffline,"卡口");
        for (Map.Entry<Integer, List<VideoDailyExp>> entry : deptExpMap.entrySet()) {
            Integer deptId = entry.getKey();
            List<VideoDailyExp> list = entry.getValue();
            AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
        VideoTypeOffOnlineExp allVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allVideosOffline,"视频");
            // 批量处理三种设备类型
            addDeviceStats(list, areaDeptEnum, "1", "人脸", videoTypeOffOnlineExps, videoOnlineRateExps);
            addDeviceStats(list, areaDeptEnum, "2", "卡口", videoTypeOffOnlineExps, videoOnlineRateExps);
            addDeviceStats(list, areaDeptEnum, "3", "视频", videoTypeOffOnlineExps, videoOnlineRateExps);
        }
        allVideoTypeOffOnlineExps.add(allFaceVideosOffline);
        allVideoTypeOffOnlineExps.add(allCarVideosOffline);
        allVideoTypeOffOnlineExps.add(allVideosOffline);
        // 计算合计数据
        addTotalStats(videoTypeOffOnlineExps, videoOnlineRateExps, face, car, video);
        //所有在线数据 合计装配对象
        VideoOnlineRateExp allFaceVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(face,videoOnlineRateExps,allFaceVideosOnline,"人脸");
        // 添加统计sheet
        mysheet.add(new ExcelExp("离线数统计", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class));
        mysheet.add(new ExcelExp("在线率统计", videoOnlineRateExps, VideoOnlineRateExp.class));
        VideoOnlineRateExp allCarVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(car,videoOnlineRateExps,allCarVideosOnline,"卡口");
        VideoOnlineRateExp allVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(video,videoOnlineRateExps,allVideosOnline,"视频");
        allVideoOnlineRateExps.add(allFaceVideosOnline);
        allVideoOnlineRateExps.add(allCarVideosOnline);
        allVideoOnlineRateExps.add(allVideosOnline);
        videoTypeOffOnlineExps.addAll(allVideoTypeOffOnlineExps);
        videoOnlineRateExps.addAll(allVideoOnlineRateExps);
        log.error("打印计算离线的信息:{}" ,videoTypeOffOnlineExps );
        log.error("打印在线的信息:{}" ,videoOnlineRateExps );
        //添加合计数据
        ExcelExp excelTypeOffLineExp = new ExcelExp("离线数统计", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class);
        mysheet.add(excelTypeOffLineExp);
        //添加在线率表
        ExcelExp excelOnlineRateExp = new ExcelExp("在线率统计",videoOnlineRateExps, VideoOnlineRateExp.class);
        mysheet.add(excelOnlineRateExp);
        // 导出Excel
        ExcelUtilManySheet<List<ExcelExp>> util = new ExcelUtilManySheet<>(mysheet);
        util.exportExcelManySheet(response, mysheet);
        log.error("导出结束");
        log.info("导出结束");
    }
    // 新增辅助方法:批量添加设备统计信息
    private void addDeviceStats(List<VideoDailyExp> list, AreaDeptEnum areaDeptEnum,
                                String typeCode, String typeName,
                                List<VideoTypeOffOnlineExp> offLineList,
                                List<VideoOnlineRateExp> onlineList) {
        offLineList.add(getListOfflineCountInfo(list, typeCode, areaDeptEnum));
        onlineList.add(getListOnLineCountInfo(list, typeCode, areaDeptEnum));
    }
    // 新增辅助方法:添加合计统计
    private void addTotalStats(List<VideoTypeOffOnlineExp> offLineList,
                               List<VideoOnlineRateExp> onlineList,
                               long face, long car, long video) throws NoSuchFieldException, IllegalAccessException {
        // 离线统计合计
        VideoTypeOffOnlineExp allFaceVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(offLineList, allFaceVideosOffline, "人脸");
        VideoTypeOffOnlineExp allCarVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(offLineList, allCarVideosOffline, "卡口");
        VideoTypeOffOnlineExp allVideosOffline = new VideoTypeOffOnlineExp();
        setAllVideoTypeOffOnlineExpCount(offLineList, allVideosOffline, "视频");
        offLineList.add(allFaceVideosOffline);
        offLineList.add(allCarVideosOffline);
        offLineList.add(allVideosOffline);
        // 在线统计合计
        VideoOnlineRateExp allFaceVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(face, onlineList, allFaceVideosOnline, "人脸");
        VideoOnlineRateExp allCarVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(car, onlineList, allCarVideosOnline, "卡口");
        VideoOnlineRateExp allVideosOnline = new VideoOnlineRateExp();
        setAllVideoTypeOnlineExpCount(video, onlineList, allVideosOnline, "视频");
        onlineList.add(allFaceVideosOnline);
        onlineList.add(allCarVideosOnline);
        onlineList.add(allVideosOnline);
    }
    //离线设备数据,合计对象,信息装配
    public void setAllVideoTypeOffOnlineExpCount(List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps,
                                                                  VideoTypeOffOnlineExp videoTypeOffOnlineExp,