Commit 41a9cc67 by lijingjing

报告生成复制报告未形成单元格问题处理;

parent 406c9f7b
......@@ -16,7 +16,7 @@ import com.patzn.cloud.commons.exception.PatznException;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.commons.toolkit.DateUtils;
import com.patzn.cloud.commons.toolkit.FileUtils;
import com.patzn.cloud.commons.toolkit.JacksonUtils;
import com.patzn.cloud.commons.toolkit.IoUtils;
import com.patzn.cloud.commons.toolkit.MapMergeUtils;
import com.patzn.cloud.oss.starter.OssClient;
import com.patzn.cloud.service.hmhj.dto.*;
......@@ -994,15 +994,13 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
os.flush();
entrustReportService.uploadReportGenerateDocx(entrust, ids, account, StringHandleUtils.join(sampleNameSet), "报告生成", file);
} catch (Exception e) {
e.printStackTrace();
logger.error("==== EntrustSampleServiceImpl ==== makeReport ====> 生成上传报告时异常:", e);
} finally {
try {
os.close();
baseDoc.close();
io.close();
IoUtils.close(os, baseDoc, io);
FileUtils.deleteFiles(file);
} catch (Exception e) {
e.printStackTrace();
logger.error("==== EntrustSampleServiceImpl ==== makeReport ====> 关闭IO时异常:", e);
}
}
......@@ -1071,13 +1069,13 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
continue;
}
if (StringUtils.isBlank(config.getDataAttribute())) {
continue;
}
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
String value = StringHandleUtils.getFieldValue(config.getDataAttribute(), vo);
cell.setCellValue(value);
}
......@@ -1105,13 +1103,16 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
XSSFRow xssfRow = sheetOneIndex.getRow(beginRow);
for (EntrustReportTemplateConfig config : configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
continue;
}
if (StringUtils.isBlank(config.getDataAttribute())) {
continue;
}
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
String value = StringHandleUtils.getFieldValue(config.getDataAttribute(), vo);
cell.setCellValue(value);
}
......@@ -1153,7 +1154,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
cell.setCellValue(sn);
} else {
......@@ -1223,6 +1224,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
return true;
}
private static XSSFCell getOrCreateCell(XSSFRow xssfRow, int column) {
XSSFCell cell = xssfRow.getCell(column);
if (null == cell) {
cell = xssfRow.createCell(column);
}
return cell;
}
@Override
public boolean makeSingleReport(Long sampleId, Long[] itemIds, Long templateId, Account account) {
......@@ -1458,7 +1467,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
cell.setCellValue(sn);
} else {
......@@ -2187,13 +2196,13 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
continue;
}
if (org.apache.commons.lang3.StringUtils.isBlank(config.getDataAttribute())) {
continue;
}
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
String value = StringHandleUtils.getFieldValue(config.getDataAttribute(), vo);
cell.setCellValue(value);
}
......@@ -2267,7 +2276,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell = getOrCreateCell(xssfRow, config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
cell.setCellValue(sn);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment