新增动态生成excel内容方法
This commit is contained in:
parent
b7c0553239
commit
2f1f658d33
|
@ -4,6 +4,11 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
|
@ -183,4 +188,44 @@ public class ExportUtil {
|
|||
Map<String,Object> dataMap){
|
||||
exportXls(response,template,target,dataSet,dataMap,"file.xls");
|
||||
}
|
||||
|
||||
public static Workbook createWorkBook(List<String> stationNameList, List<String> columnNameList, List<Map<String, Object>> dataList) {
|
||||
//创建工作簿
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
//遍历台站数量
|
||||
for (int i=0; i<stationNameList.size(); i++) {
|
||||
String stationName = stationNameList.get(i);
|
||||
//创建工作页
|
||||
Sheet sheet = workbook.createSheet(stationName);
|
||||
//声明行下标
|
||||
int rowIndex = 0;
|
||||
//创建第一行
|
||||
Row row = sheet.createRow(rowIndex);
|
||||
for (int j=0; j<columnNameList.size(); j++) {
|
||||
String columnName = columnNameList.get(j);
|
||||
//创建当前行的单元格
|
||||
Cell cell = row.createCell(j);
|
||||
cell.setCellValue(columnName);
|
||||
}
|
||||
rowIndex+=1;
|
||||
//遍历数据根据字段名称取值赋值
|
||||
for (int j=0; j<dataList.size(); j++) {
|
||||
//创建存储数据的行
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
//数据数组中读取下标对应的数据
|
||||
Map<String, Object> data = dataList.get(j);
|
||||
for (int k=0; k<columnNameList.size(); k++) {
|
||||
Cell cell = dataRow.createCell(k);
|
||||
//从列名数组中读取列名
|
||||
String columnName = columnNameList.get(k);
|
||||
//根据列名读取对应数据的信息
|
||||
Object value = data.get(StringUtils.upperCase(columnName));
|
||||
cell.setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -436,8 +436,11 @@ public class GammaController {
|
|||
}
|
||||
|
||||
@GetMapping("exportRadionuclideActivity")
|
||||
public void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletRequest request, HttpServletResponse response){
|
||||
gammaService.exportRadionuclideActivity(sampleId, fileName, request, response);
|
||||
public void exportRadionuclideActivity(Integer sampleId, String fileName,
|
||||
String arTime, String crTime,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
gammaService.exportRadionuclideActivity(sampleId, fileName, arTime, crTime, request, response);
|
||||
}
|
||||
|
||||
@GetMapping("Spectrum")
|
||||
|
|
|
@ -153,7 +153,7 @@ public interface IGammaService{
|
|||
|
||||
Result<?> radionuclideActivity(Integer sampleId, String fileName, HttpServletRequest request);
|
||||
|
||||
void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletRequest request, HttpServletResponse response);
|
||||
void exportRadionuclideActivity(Integer sampleId, String fileName, String arTime, String crTime,HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
Result Spectrum(Integer sampleId, String fileName, HttpServletRequest request);
|
||||
|
||||
|
|
|
@ -214,8 +214,23 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
}
|
||||
//读取redis缓存的计算mdc信息
|
||||
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
//如果是数据库加载 判断如果mdc计算结果是空的 就加入新的 否则使用数据库加载的mdc数据
|
||||
if (CollectionUtils.isEmpty(phd.getMdcInfoMap())) {
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
Map<String, CalMDCInfo> infoMap = phd.getMdcInfoMap();
|
||||
for (Map.Entry<String, CalMDCInfo> entry:infoMap.entrySet()) {
|
||||
String nuclName = entry.getKey();
|
||||
CalMDCInfo info = mdcInfoMap.get(nuclName);
|
||||
if (Objects.nonNull(info)) {
|
||||
CalMDCInfo mdcInfo = entry.getValue();
|
||||
mdcInfo.setHalflife(info.getHalflife());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gammaFileUtil.Qcstate(phd);
|
||||
key = fileName + StringPool.DASH + userName;
|
||||
|
|
Loading…
Reference in New Issue
Block a user