Commit 41a9cc67 by lijingjing

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

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