完善导出原始数据接口

This commit is contained in:
caozehui
2025-01-21 15:06:16 +08:00
parent 413f668179
commit 1ad3fe48b4
2 changed files with 26 additions and 22 deletions

View File

@@ -45,11 +45,6 @@ public class ResultParam {
*/ */
private Integer index; private Integer index;
/**
* 当前选中的检测项
*/
private String currentCheckItem;
@Data @Data
public static class QueryParam { public static class QueryParam {

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.result.service.impl; package com.njcn.gather.result.service.impl;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; 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.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.device.service.IPqDevService; 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.pojo.po.AdPlan;
import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.result.pojo.enums.ResultResponseEnum; 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.ResultVO;
import com.njcn.gather.result.pojo.vo.TreeDataVO; import com.njcn.gather.result.pojo.vo.TreeDataVO;
import com.njcn.gather.result.service.IResultService; 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.param.StorageParam;
import com.njcn.gather.storage.pojo.po.AdBaseResult; import com.njcn.gather.storage.pojo.po.AdBaseResult;
import com.njcn.gather.storage.pojo.vo.RawDataVO; import com.njcn.gather.storage.pojo.vo.RawDataVO;
@@ -816,20 +817,28 @@ public class ResultServiceImpl implements IResultService {
storage.setHarmNum(harmNum); storage.setHarmNum(harmNum);
rawDataMap = adHarmonicService.listHarmData(storage); rawDataMap = adHarmonicService.listHarmData(storage);
} }
if (ObjectUtil.isNotNull(rawDataMap)) {
List<RawDataVO> rawDataVOList = rawDataMap.get(param.getCurrentCheckItem());
if (CollUtil.isNotEmpty(rawDataVOList)) { if (ObjectUtil.isNotEmpty(rawDataMap)) {
if (isTPhase(rawDataVOList)) { List<Map<String, Object>> sheetsList = new ArrayList<>();
List<RawDataExcel.TRawDataExcel> rawDataExcelList = BeanUtil.copyToList(rawDataVOList, RawDataExcel.TRawDataExcel.class); rawDataMap.forEach((k, v) -> {
ExcelUtil.exportExcel("原始数据.xlsx", "sheet1", param.getCurrentCheckItem(), RawDataExcel.TRawDataExcel.class, ObjectUtil.isEmpty(rawDataExcelList) ? new ArrayList<>() : rawDataExcelList); HashMap sheet = new HashMap<>();
ExportParams exportParams = new ExportParams();
exportParams.setSheetName(k);
sheet.put("title", exportParams);
if (isTPhase(v)) {
List<RawDataExcel.TRawDataExcel> rawDataExcelList = BeanUtil.copyToList(v, RawDataExcel.TRawDataExcel.class);
sheet.put("data", rawDataExcelList);
sheet.put("entity", RawDataExcel.TRawDataExcel.class);
} else { } else {
List<RawDataExcel.NotTRawDataExcel> rawDataExcelList = BeanUtil.copyToList(rawDataVOList, RawDataExcel.NotTRawDataExcel.class); List<RawDataExcel.NotTRawDataExcel> rawDataExcelList = BeanUtil.copyToList(v, RawDataExcel.NotTRawDataExcel.class);
ExcelUtil.exportExcel("原始数据.xlsx", "sheet1", param.getCurrentCheckItem(), RawDataExcel.NotTRawDataExcel.class, ObjectUtil.isEmpty(rawDataExcelList) ? new ArrayList<>() : rawDataExcelList); sheet.put("data", rawDataExcelList);
sheet.put("entity", RawDataExcel.NotTRawDataExcel.class);
} }
} else { sheetsList.add(sheet);
throw new BusinessException(ResultResponseEnum.RAW_DATA_NOT_EXIST); });
} ExcelUtil.exportExcel("原始数据.xlsx", sheetsList);
} else {
throw new BusinessException(ResultResponseEnum.RAW_DATA_NOT_EXIST);
} }
} }