feat:Export Excel

This commit is contained in:
nieziyan 2023-09-07 19:04:39 +08:00
parent 5cc898bf83
commit 72b017a650
14 changed files with 233 additions and 99 deletions

13
derby.log Normal file
View File

@ -0,0 +1,13 @@
----------------------------------------------------------------
Thu Sep 07 18:35:29 CST 2023:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.14.2.0 - (1828579): instance a816c00e-018a-6f36-0bb6-000026acaf78
on database directory memory:E:\Code\RadionuclideAnalysis\AnalysisSystemForRadionuclide\dd4468e9-cdd6-4c7a-91ec-3c8744a24ea3 with class loader sun.misc.Launcher$AppClassLoader@18b4aac2
Loaded from file:/E:/maven/.m2/repository/org/apache/derby/derby/10.14.2.0/derby-10.14.2.0.jar
java.vendor=Oracle Corporation
java.runtime.version=1.8.0_351-b10
user.dir=E:\Code\RadionuclideAnalysis\AnalysisSystemForRadionuclide
os.name=Windows 10
os.arch=amd64
os.version=10.0
derby.system.home=null
Database Class Loader started - derby.database.classpath=''

View File

@ -258,25 +258,5 @@
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<!--<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-poi</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-jexcel</artifactId>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-reader</artifactId>
<version>2.0.5</version>
</dependency>-->
</dependencies>
</project>

View File

@ -121,4 +121,6 @@ public class SymbolConstant {
*/
public static final String BARRE = "-";
public static final String SPACE = " ";
}

View File

@ -2,7 +2,6 @@ package org.jeecg.common.util;
import cn.hutool.core.util.ObjectUtil;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.modules.base.dto.QCResultDto;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
@ -44,9 +43,8 @@ public class ExportUtil {
}
public static <T> void exportXls(HttpServletResponse response, Class<T> target,
List<T> data, String sheetName, String fileName){
List<T> data, String fileName){
ExportParams params = new ExportParams();
params.setSheetName(sheetName);
Workbook workbook = null;
OutputStream outputStream = null;
try {
@ -70,23 +68,24 @@ public class ExportUtil {
}
public static <T> void exportXls(HttpServletResponse response, Class<T> target, List<T> data){
exportXls(response, target, data, "sheet1", "file");
exportXls(response, target, data, "file.xls");
}
public static TemplateExportParams excelTemplate(String name){
//return new TemplateExportParams("C:/Users/a/Desktop/"+ name +".xlsx");
return new TemplateExportParams("E:\\Code\\IDEA\\AnalysisSystemForRadionuclide\\jeecg-boot-base-core\\src\\main\\resources\\excelTemplate\\"+ name +".xlsx");
String templatePath = "D:\\excelTemplate\\";
templatePath += name;
return new TemplateExportParams(templatePath);
}
public static void exportXls(HttpServletResponse response, String template,
Map<String,Object> data, String fileName){
Map<String,Object> dataMap, String fileName){
TemplateExportParams params = excelTemplate(template);
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,fileName);
workbook = ExcelExportUtil.exportExcel(params, data);
workbook = ExcelExportUtil.exportExcel(params, dataMap);
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
@ -101,4 +100,39 @@ public class ExportUtil {
}
}
}
public static void exportXls(HttpServletResponse response, String template,
Map<String,Object> dataMap){
exportXls(response,template,dataMap,"file.xls");
}
public static <T> void exportXls(HttpServletResponse response, String template,
Class<T> target, List<T> dataSet,
Map<String,Object> dataMap, String fileName){
TemplateExportParams params = excelTemplate(template);
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,fileName);
workbook = ExcelExportUtil.exportExcel(params, target,dataSet,dataMap);
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (ObjectUtil.isNotNull(outputStream))
outputStream.close();
if (ObjectUtil.isNotNull(workbook))
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static <T> void exportXls(HttpServletResponse response, String template,
Class<T> target, List<T> dataSet,
Map<String,Object> dataMap){
exportXls(response,template,target,dataSet,dataMap,"file.xls");
}
}

View File

@ -1,14 +0,0 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
@Data
public class QCResultDto {
@Excel(name = "Name",orderNum = "1",width = 30)
private String fieldName;
@Excel(name = "Value",orderNum = "2",width = 10)
private Object fieldValue;
}

View File

@ -0,0 +1,22 @@
package org.jeecg.modules.base.enums;
import lombok.Getter;
import org.springframework.web.bind.annotation.GetMapping;
/*
* Excel文件导出模板模板名枚举
* */
@Getter
public enum ExportTemplate {
SampleInfo_G("SampleInformation-G.xls"),
RadionuclideActivity_G("RadionuclideActivity-G.xls"),
SampleInfo_B("SampleInformation-B.xls"),
QcResult_B("QcResult-B.xls");
ExportTemplate(String name) {
this.name = name;
}
private String name;
}

View File

@ -1,28 +1,41 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
@Data
public class TablePeak implements Serializable {
@Excel(name = "Index",orderNum = "1",width = 10)
private Integer no;
@Excel(name = "Energy(keV)",orderNum = "2",width = 20)
private String energy;
@Excel(name = "Centroid",orderNum = "3",width = 20)
private String centroid;
@Excel(name = "Multiplet",orderNum = "4",width = 20)
private String multiplet;
@Excel(name = "Fwhm(keV)",orderNum = "5",width = 20)
private String fwhm;
@Excel(name = "NetArea",orderNum = "6",width = 20)
private String netArea;
@Excel(name = "AreaErr(%)",orderNum = "7",width = 20)
private String areaErr;
@Excel(name = "Significant",orderNum = "8",width = 20)
private String significant;
@Excel(name = "Sensitivity",orderNum = "9",width = 20)
private String sensitivity;
@Excel(name = "Nuclides",orderNum = "10",width = 20)
private String indentify;
}

View File

@ -22,7 +22,6 @@ public class GammaController {
private IGammaService gammaService;
@GetMapping("gammaByDB")
@ApiOperation(value = "gamma页面loadFromDB加载数据", notes = "gamma页面loadFromDB加载数据")
public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName){
return gammaService.gammaByDB(dbName, sampleId);
}
@ -237,10 +236,16 @@ public class GammaController {
@GetMapping("peakInformation")
@ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据")
public Result peakInformation(@RequestParam Integer sampleId, String fileName) {
public Result<?> peakInformation(@RequestParam Integer sampleId, String fileName){
return gammaService.peakInformation(sampleId, fileName);
}
@GetMapping("exportPeakInformation")
public void exportPeakInformation(@RequestParam Integer sampleId, String fileName,
HttpServletResponse response){
gammaService.exportPeakInformation(sampleId, fileName, response);
}
@GetMapping("viewARR")
@ApiOperation(value = "查看ARR页面数据", notes = "查看ARR页面数据")
public void viewARR(Integer sampleId, HttpServletResponse response) {
@ -259,6 +264,12 @@ public class GammaController {
return gammaService.radionuclideActivity(sampleId, fileName);
}
@GetMapping("exportRadionuclideActivity")
public void exportRadionuclideActivity(Integer sampleId, String fileName,
HttpServletResponse response){
gammaService.exportRadionuclideActivity(sampleId, fileName, response);
}
@GetMapping("Spectrum")
@ApiOperation(value = "查看Spectrum页面数据", notes = "查看Spectrum页面数据")
public Result Spectrum(Integer sampleId, String fileName) {
@ -267,7 +278,7 @@ public class GammaController {
@GetMapping("sampleInformation")
@ApiOperation(value = "查看Sample Information页面数据", notes = "查看Sample Information页面数据")
public Result sampleInformation(Integer sampleId, String fileName) {
public Result<?> sampleInformation(Integer sampleId, String fileName){
return gammaService.sampleInformation(sampleId, fileName);
}
@ -278,16 +289,13 @@ public class GammaController {
@GetMapping("viewQCResult")
@ApiOperation(value = "查看QC Result页面数据", notes = "查看QC Result页面数据")
public Result<List<TableQCResult>> viewQCResult(Integer sampleId, String fileName) {
public Result<?> viewQCResult(Integer sampleId, String fileName){
return gammaService.viewQCResult(sampleId, fileName);
}
@GetMapping("exportQCResult")
public void exportQCResult(Integer sampleId, String fileName, HttpServletResponse response){
Result<List<TableQCResult>> result = gammaService.viewQCResult(sampleId, fileName);
List<TableQCResult> tableQCResults = result.getResult();
if (CollUtil.isEmpty(tableQCResults))return;
gammaService.exportQCResult(tableQCResults,response);
public void exportQCResult(Integer sampleId, String fileName,HttpServletResponse response){
gammaService.exportQCResult(sampleId,fileName,response);
}
@GetMapping("viewRLR")

View File

@ -1,11 +1,14 @@
package org.jeecg.modules.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.service.ISpectrumAnalysisService;
@ -16,6 +19,10 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("spectrumAnalysis")
@ -93,24 +100,26 @@ public class SpectrumAnalysesController {
@GetMapping("viewSampleInformation")
@ApiOperation(value = "查看SampleInformation数据", notes = "查看SampleInformation数据")
public Result viewSampleInformation(Integer sampleId) {
public Result<?> viewSampleInformation(Integer sampleId){
return spectrumAnalysisService.viewSampleInformation(sampleId);
}
@GetMapping("exportSampleInformation")
@ApiOperation(value = "导出SampleInformation数据", notes = "导出SampleInformation数据")
public void exportSampleInformation(Integer sampleId, HttpServletResponse response){
spectrumAnalysisService.exportSampleInformation(sampleId,response);
}
@GetMapping("viewQCResult")
@ApiOperation(value = "查看QC Result数据", notes = "查看QC Result数据")
public Result viewQCResult(Integer sampleId) {
public Result<?> viewQCResult(Integer sampleId){
return spectrumAnalysisService.viewQCResult(sampleId);
}
@GetMapping("exportQCResult")
@ApiOperation(value = "导出QC Result数据", notes = "导出QC Result数据")
public void exportQCResult(Integer sampleId,HttpServletResponse response){
Result<QCResult> result = spectrumAnalysisService.viewQCResult(sampleId);
QCResult qcResult = result.getResult();
if (ObjectUtil.isNull(qcResult))return;
spectrumAnalysisService.exportQCResult(qcResult,response);
spectrumAnalysisService.exportQCResult(sampleId,response);
}
@GetMapping("viewRLR")

View File

@ -82,24 +82,28 @@ public interface IGammaService{
Result viewComment(Integer sampleId, String fileName);
Result peakInformation(Integer sampleId, String fileName);
Result<?> peakInformation(Integer sampleId, String fileName);
void exportPeakInformation(Integer sampleId, String fileName, HttpServletResponse response);
void viewARR(Integer sampleId, HttpServletResponse response);
Result viewRRR(Integer sampleId, String fileName);
Result radionuclideActivity(Integer sampleId, String fileName);
Result<?> radionuclideActivity(Integer sampleId, String fileName);
void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletResponse response);
Result Spectrum(Integer sampleId, String fileName);
Result<Map<String, String>> sampleInformation(Integer sampleId, String fileName);
Result<?> sampleInformation(Integer sampleId, String fileName);
void exportSampleInformation(Integer sampleId, String fileName,
HttpServletResponse response);
Result<List<TableQCResult>> viewQCResult(Integer sampleId, String fileName);
Result<?> viewQCResult(Integer sampleId, String fileName);
void exportQCResult(List<TableQCResult> data,HttpServletResponse response);
void exportQCResult(Integer sampleId, String fileName,HttpServletResponse response);
Result viewRLR(Integer sampleId, String fileName);

View File

@ -35,11 +35,13 @@ public interface ISpectrumAnalysisService {
Result viewSpectrum(Integer sampleId);
Result viewSampleInformation(Integer sampleId);
Result<?> viewSampleInformation(Integer sampleId);
Result<QCResult> viewQCResult(Integer sampleId);
void exportSampleInformation(Integer sampleId, HttpServletResponse response);
void exportQCResult(QCResult qcResult,HttpServletResponse response);
Result<?> viewQCResult(Integer sampleId);
void exportQCResult(Integer sampleId, HttpServletResponse response);
Result viewRLR(Integer sampleId);

View File

@ -1,5 +1,7 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
@ -12,10 +14,12 @@ import org.apache.commons.net.ftp.FTPFile;
import org.jeecg.common.Excel.ExportExcel;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
import org.jeecg.modules.base.enums.ExportTemplate;
import org.jeecg.modules.base.enums.RoleType;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.entity.*;
@ -43,6 +47,8 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_G;
@Service(value = "gammaService")
@DS("ora")
public class GammaServiceImpl implements IGammaService {
@ -1568,8 +1574,8 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
public Result peakInformation(Integer sampleId, String fileName){
Result result = new Result();
public Result<List<TablePeak>> peakInformation(Integer sampleId, String fileName){
Result<List<TablePeak>> result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
@ -1606,6 +1612,18 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public void exportPeakInformation(Integer sampleId, String fileName, HttpServletResponse response) {
Result<List<TablePeak>> result = peakInformation(sampleId, fileName);
List<TablePeak> peaks = result.getResult();
if (CollUtil.isEmpty(peaks)) return;
String export = "PeakInformation-Gamma.xls";
for (int i = 0; i < peaks.size(); i++) {
peaks.get(i).setNo(i + 1);
}
ExportUtil.exportXls(response,TablePeak.class,peaks,export);
}
@Override
public void viewARR(Integer sampleId, HttpServletResponse response) {
if(Objects.isNull(sampleId)) {
@ -1685,8 +1703,8 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result radionuclideActivity(Integer sampleId, String fileName) {
Result result = new Result();
public Result<Map<String, Object>> radionuclideActivity(Integer sampleId, String fileName) {
Result<Map<String, Object>> result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
@ -1699,6 +1717,26 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletResponse response) {
Result<Map<String, Object>> result = radionuclideActivity(sampleId, fileName);
Map<String, Object> dataMap = result.getResult();
if (MapUtil.isEmpty(dataMap)) return;
Date actRef = (Date) dataMap.get("dateTime_act_ref");
Date conRef = (Date) dataMap.get("dateTime_con_ref");
if (ObjectUtil.isNotNull(actRef)){
String actTime = DateUtil.format(actRef, DateConstant.DATE_TIME);
dataMap.put("dateTime_act_ref",actTime);
}
if (ObjectUtil.isNotNull(conRef)){
String conTime = DateUtil.format(conRef, DateConstant.DATE_TIME);
dataMap.put("dateTime_con_ref",conTime);
}
String export = "RadionuclideActivity-Gamma.xls";
String template = ExportTemplate.RadionuclideActivity_G.getName();
ExportUtil.exportXls(response,template,dataMap,export);
}
@Override
public Result Spectrum(Integer sampleId, String fileName) {
Result result = new Result();
@ -1763,16 +1801,13 @@ public class GammaServiceImpl implements IGammaService {
@Override
public void exportSampleInformation(Integer sampleId, String fileName,
HttpServletResponse response) {
/*Result<Map<String, String>> result = sampleInformation(sampleId, fileName);
Result<Map<String, String>> result = sampleInformation(sampleId, fileName);
Map<String, String> sampleInfo = result.getResult();
if (MapUtil.isEmpty(sampleInfo)) return;*/
/*Map<String, Object> data = sampleInfo.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));*/
/*String exportFileName = "SampleInfo-Gamma.xls";
ExportUtil.exportXls(response,"SampleInfo-G",data,exportFileName);*/
Map<String, Object> data = new HashMap<>();
data.put("name","123");
data.put("sex",1);
if (MapUtil.isEmpty(sampleInfo)) return;
Map<String, Object> dataMap = sampleInfo.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
String export = "SampleInfo-Gamma.xls";
ExportUtil.exportXls(response, SampleInfo_G.getName(),dataMap,export);
}
@Override
@ -1845,10 +1880,12 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public void exportQCResult(List<TableQCResult> data, HttpServletResponse response) {
String sheetName = "QCResult-Gamma";
String fileName = "QCResult-Gamma.xls";
ExportUtil.exportXls(response,TableQCResult.class,data,sheetName,fileName);
public void exportQCResult(Integer sampleId, String fileName, HttpServletResponse response) {
Result<List<TableQCResult>> result = viewQCResult(sampleId, fileName);
List<TableQCResult> qcResults = result.getResult();
if (CollUtil.isEmpty(qcResults))return;
String export = "QCResult-Gamma.xls";
ExportUtil.exportXls(response,TableQCResult.class,qcResults,export);
}
@Override

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
@ -16,10 +17,10 @@ import org.apache.commons.net.ftp.FTPFile;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.dto.QCResultDto;
import org.jeecg.modules.base.entity.original.*;
import org.jeecg.modules.base.enums.*;
import org.jeecg.modules.entity.*;
@ -44,6 +45,9 @@ import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.jeecg.modules.base.enums.ExportTemplate.QcResult_B;
import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_B;
@Service("spectrumAnalysisService")
@DS("ora")
public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
@ -984,8 +988,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
@Override
public Result viewSampleInformation(Integer sampleId) {
Result result = new Result();
public Result<StringBuffer> viewSampleInformation(Integer sampleId) {
Result<StringBuffer> result = new Result();
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
if (StringUtils.isNotBlank(sampleFilePath)){
String pathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
@ -1066,7 +1070,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
inputStream.close();
}
result.setSuccess(true);
result.setResult(strBuffer.toString());
result.setResult(strBuffer);
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -1088,6 +1092,30 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
return result;
}
@Override
public void exportSampleInformation(Integer sampleId, HttpServletResponse response) {
Result<StringBuffer> result = viewSampleInformation(sampleId);
StringBuffer buffer = result.getResult();
if (ObjectUtil.isNull(buffer)) return;
String sampleInfo = buffer.toString();
String colon = SymbolConstant.COLON;
String space = SymbolConstant.SPACE;
List<String> sampleInfos = ListUtil.toList(sampleInfo.split("\n")).stream()
.filter(StrUtil::isNotBlank)
.filter(item -> StrUtil.contains(item,colon))
.collect(Collectors.toList());
Map<String,Object> dataMap = new HashMap<>();
for (String s : sampleInfos) {
String[] split = s.split(colon,2);// 只分割为两部分
String key = StrUtil.removeAll(split[0],space);
String value = split[1].trim();
dataMap.put(key,value);
}
String export = "SampleInformation-Beta.xls";
String template = SampleInfo_B.getName();
ExportUtil.exportXls(response,template,dataMap,export);
}
@Override
public Result<QCResult> viewQCResult(Integer sampleId) {
Result<QCResult> result = new Result();
@ -1317,18 +1345,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
@Override
public void exportQCResult(QCResult qcResult, HttpServletResponse response) {
Map<String, Object> qcMap = BeanUtil.beanToMap(qcResult);
List<QCResultDto> qcResultDtos = new ArrayList<>();
for (Map.Entry<String, Object> entry : qcMap.entrySet()) {
QCResultDto qcResultDto = new QCResultDto();
qcResultDto.setFieldName(entry.getKey());
qcResultDto.setFieldValue(entry.getValue());
qcResultDtos.add(qcResultDto);
}
String sheetName = "QCResult-Beta";
String fileName = "QCResult-Beta.xls";
ExportUtil.exportXls(response,QCResultDto.class,qcResultDtos,sheetName,fileName);
public void exportQCResult(Integer sampleId, HttpServletResponse response) {
Result<QCResult> result = viewQCResult(sampleId);
QCResult qcResult = result.getResult();
if (ObjectUtil.isNull(qcResult)) return;
Map<String, Object> dataMap = BeanUtil.beanToMap(qcResult);
String export = "QCResult-Beta.xls";
String template = QcResult_B.getName();
ExportUtil.exportXls(response,template,dataMap,export);
}
@Override