From 1ad3fe48b44e403aac4731daf706f2a6652a6adb Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Tue, 21 Jan 2025 15:06:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AF=BC=E5=87=BA=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gather/result/pojo/param/ResultParam.java | 5 --- .../service/impl/ResultServiceImpl.java | 43 +++++++++++-------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/result/pojo/param/ResultParam.java b/detection/src/main/java/com/njcn/gather/result/pojo/param/ResultParam.java index 60e9cb85..83a3897c 100644 --- a/detection/src/main/java/com/njcn/gather/result/pojo/param/ResultParam.java +++ b/detection/src/main/java/com/njcn/gather/result/pojo/param/ResultParam.java @@ -45,11 +45,6 @@ public class ResultParam { */ private Integer index; - /** - * 当前选中的检测项 - */ - private String currentCheckItem; - @Data public static class QueryParam { diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index c1447199..b789aee7 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -1,5 +1,6 @@ package com.njcn.gather.result.service.impl; +import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; @@ -8,12 +9,6 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.device.service.IPqDevService; -import com.njcn.gather.script.mapper.PqScriptMapper; -import com.njcn.gather.script.pojo.po.PqScriptCheckData; -import com.njcn.gather.script.pojo.po.PqScriptDtls; -import com.njcn.gather.script.service.IPqScriptCheckDataService; -import com.njcn.gather.script.service.IPqScriptDtlsService; -import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.result.pojo.enums.ResultResponseEnum; @@ -24,6 +19,12 @@ import com.njcn.gather.result.pojo.vo.RawDataExcel; import com.njcn.gather.result.pojo.vo.ResultVO; import com.njcn.gather.result.pojo.vo.TreeDataVO; import com.njcn.gather.result.service.IResultService; +import com.njcn.gather.script.mapper.PqScriptMapper; +import com.njcn.gather.script.pojo.po.PqScriptCheckData; +import com.njcn.gather.script.pojo.po.PqScriptDtls; +import com.njcn.gather.script.service.IPqScriptCheckDataService; +import com.njcn.gather.script.service.IPqScriptDtlsService; +import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.storage.pojo.param.StorageParam; import com.njcn.gather.storage.pojo.po.AdBaseResult; import com.njcn.gather.storage.pojo.vo.RawDataVO; @@ -816,20 +817,28 @@ public class ResultServiceImpl implements IResultService { storage.setHarmNum(harmNum); rawDataMap = adHarmonicService.listHarmData(storage); } - if (ObjectUtil.isNotNull(rawDataMap)) { - List rawDataVOList = rawDataMap.get(param.getCurrentCheckItem()); - if (CollUtil.isNotEmpty(rawDataVOList)) { - if (isTPhase(rawDataVOList)) { - List rawDataExcelList = BeanUtil.copyToList(rawDataVOList, RawDataExcel.TRawDataExcel.class); - ExcelUtil.exportExcel("原始数据.xlsx", "sheet1", param.getCurrentCheckItem(), RawDataExcel.TRawDataExcel.class, ObjectUtil.isEmpty(rawDataExcelList) ? new ArrayList<>() : rawDataExcelList); + if (ObjectUtil.isNotEmpty(rawDataMap)) { + List> sheetsList = new ArrayList<>(); + rawDataMap.forEach((k, v) -> { + HashMap sheet = new HashMap<>(); + ExportParams exportParams = new ExportParams(); + exportParams.setSheetName(k); + sheet.put("title", exportParams); + if (isTPhase(v)) { + List rawDataExcelList = BeanUtil.copyToList(v, RawDataExcel.TRawDataExcel.class); + sheet.put("data", rawDataExcelList); + sheet.put("entity", RawDataExcel.TRawDataExcel.class); } else { - List rawDataExcelList = BeanUtil.copyToList(rawDataVOList, RawDataExcel.NotTRawDataExcel.class); - ExcelUtil.exportExcel("原始数据.xlsx", "sheet1", param.getCurrentCheckItem(), RawDataExcel.NotTRawDataExcel.class, ObjectUtil.isEmpty(rawDataExcelList) ? new ArrayList<>() : rawDataExcelList); + List rawDataExcelList = BeanUtil.copyToList(v, RawDataExcel.NotTRawDataExcel.class); + sheet.put("data", rawDataExcelList); + sheet.put("entity", RawDataExcel.NotTRawDataExcel.class); } - } else { - throw new BusinessException(ResultResponseEnum.RAW_DATA_NOT_EXIST); - } + sheetsList.add(sheet); + }); + ExcelUtil.exportExcel("原始数据.xlsx", sheetsList); + } else { + throw new BusinessException(ResultResponseEnum.RAW_DATA_NOT_EXIST); } }