Browse Source

fix: 解决卫生表导出内容异常的问题

zhongwei
liwen 5 months ago
parent
commit
09de77d57e
  1. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  2. 19
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

@ -194,8 +194,8 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
hygieneRecordDetailVO.setCheckList(res);
Map<String, Object> params = BaseUtil.obj2Map(hygieneRecordDetailVO);
String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = savePath + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX;
String wordPath = "D:/" + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = "D:/" + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX;
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, "",response);
}

19
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -144,10 +144,10 @@ public class BaseUtil {
}
}
// 表格处理
if (templatePath.equals("template/卫生自查表.docx")) {
if ("template/卫生自查表.docx".equals(templatePath)) {
formatHygieneRecordTable(xwpfDocument);
}
if (templatePath.equals("template/车辆检查表.docx")) {
if ("template/车辆检查表.docx".equals(templatePath)) {
formatCarCheckRecordTable(xwpfDocument);
}
} catch (Exception e) {
@ -225,13 +225,18 @@ public class BaseUtil {
List<XWPFTableRow> rows = table.getRows();
// 第三行到倒数第二行为需合并区域
for (int row = 3; row < rows.size() - 1;) {
XWPFTableCell startCell = rows.get(row).getCell(0);
String startText = startCell.getText();
// 判断责任区和责任人是否完全一致,一致则合并
XWPFTableCell startFirstCell = rows.get(row).getCell(0);
String startFirstText = startFirstCell.getText();
XWPFTableCell startSecondCell = rows.get(row).getCell(1);
String startSecondText = startSecondCell.getText();
int index = row + 1;
for (; index < rows.size(); index++) {
XWPFTableCell endCell = rows.get(index).getCell(0);
String endText = endCell.getText();
if (!startText.equals(endText)) {
XWPFTableCell endFirstCell = rows.get(index).getCell(0);
String endFirstText = endFirstCell.getText();
XWPFTableCell endSecondCell = rows.get(index).getCell(1);
String endSecondText = endSecondCell.getText();
if (!startFirstText.equals(endFirstText) || !startSecondText.equals(endSecondText)) {
break;
}
}

Loading…
Cancel
Save