Commit f731acde authored by tianbo's avatar tianbo

消防监督报告bug修改

parent 1afe21cd
......@@ -16,6 +16,9 @@ public class CheckReportDangerDto implements Serializable {
String companyName;
@ApiModelProperty(value = "隐患id")
String id;
@ApiModelProperty(value = "隐患id")
String dangerId;
@ApiModelProperty(value = "存在问题")
......
......@@ -95,7 +95,7 @@ public class CheckReportController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取检查报告文档", notes = "获取检查报告文档")
@GetMapping(value = "/docx/{id}")
public ResponseModel getCheckReportDocx(HttpServletResponse response, @PathVariable(name = "id") String reportId) throws Exception {
return ResponseHelper.buildResponse(iCheckReportService.getCheckReportDocx(response, reportId));
public void getCheckReportDocx(HttpServletResponse response, @PathVariable(name = "id") String reportId) throws Exception {
iCheckReportService.getCheckReportDocx(response, reportId);
}
}
......@@ -231,8 +231,8 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
// 复查已整改隐患
List<CheckReportDangerDto> reviewReformedList = result.get("reviewReformedList");
Set<String> reviewDangerIdSet = Sets.newHashSet();
reviewDangerIdSet.addAll(Lists.transform(reviewDangerList, CheckReportDangerDto::getDangerId));
reviewDangerIdSet.addAll(Lists.transform(reviewReformedList, CheckReportDangerDto::getDangerId));
reviewDangerIdSet.addAll(Lists.transform(reviewDangerList, CheckReportDangerDto::getId));
reviewDangerIdSet.addAll(Lists.transform(reviewReformedList, CheckReportDangerDto::getId));
// 保存本次复查隐患id
checkReport.setReviewDangerIds(Joiner.on(",").join(reviewDangerIdSet));
// List<CheckReportDangerDto> reviewReformingList = result.get("reviewReformingList");
......@@ -290,7 +290,8 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
}
@Override
public Object getCheckReportDocx(HttpServletResponse response, String reportId) throws ParseException, UnsupportedEncodingException {
public void getCheckReportDocx(HttpServletResponse response, String reportId) throws ParseException,
UnsupportedEncodingException {
CheckReportDto report = this.getDetailById(reportId);
report.setReportDate(getCheckReportDateStr(report));
report.setNowDate(DateUtils.dateFormat(new Date(), DateUtils.CHN_DATE_PATTERN));
......@@ -305,7 +306,7 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
configureBuilder.setElMode(ELMode.SPEL_MODE).bind("checkDangerList", checkDangerTablePolicy).bind("reviewDangerList", reviewDangerTablePolicy).build();
XWPFTemplate template = XWPFTemplate.compile(checkReportTemplatePath, configureBuilder.build()).render(report);
response.setContentType("application/msword");
response.setHeader("Content-disposition",
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
OutputStream out = null;
BufferedOutputStream bos = null;
......@@ -328,7 +329,6 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
}
}
}
return null;
}
private String getCheckReportDateStr(CheckReportDto checkReportDto) throws ParseException {
......@@ -394,23 +394,24 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
report.getCompanyName(), report.getDangerName(), report.getDangerStateName(), report.getCompanyId());
checkDangerList.add(rowRenderData);
}));
generateTableData(table, checkDangerList);
// companyId字段在RowRenderData中下标(0开始,companyName:1,dangerName:2,dangerStateName:3,companyId:4)
generateTableData(table, checkDangerList, 4);
}
}
public static void generateTableData(XWPFTable table, List<RowRenderData> dangerList) {
public static void generateTableData(XWPFTable table, List<RowRenderData> dangerList, int bizIndex) {
if (!ValidationUtil.isEmpty(dangerList)) {
// 表格渲染和列表数据下标相反,需要翻转一下列表
List<RowRenderData> reverseList = Lists.reverse(dangerList);
table.removeRow(dangerListDataStartRow);
int lastRow = dangerListDataStartRow;
String sameCompanyId =
dangerList.get(0).getCellDatas().get(4).getRenderData().getText();
dangerList.get(0).getCellDatas().get(bizIndex).getRenderData().getText();
List<Map<String, Integer>> mergeRowMapList = Lists.newArrayList();
// 循环插入行
int listLength = dangerList.size();
for (int i = 0; i < listLength; i++) {
String companyId = dangerList.get(i).getCellDatas().get(4).getRenderData().getText();
String companyId = dangerList.get(i).getCellDatas().get(bizIndex).getRenderData().getText();
reverseList.get(i).getCellDatas().get(0).getRenderData().setText(String.valueOf(listLength - i));
reverseList.get(i).getCellDatas().forEach(cellRenderData -> {
Style style = new Style();
......@@ -419,10 +420,12 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
cellRenderData.getRenderData().setStyle(style);
});
XWPFTableRow insertNewTableRow = table.insertNewTableRow(dangerListDataStartRow);
IntStream.range(0, 4).forEach(j -> insertNewTableRow.createCell());
// 生成表格字段个数 (不包含companyId字段)
int cellLength = reverseList.get(i).getCellDatas().size() - 1;
IntStream.range(0, cellLength).forEach(j -> insertNewTableRow.createCell());
if (!sameCompanyId.equals(companyId)) {
sameCompanyId = dangerList.get(i).getCellDatas().get(4).getRenderData().getText();
sameCompanyId = dangerList.get(i).getCellDatas().get(bizIndex).getRenderData().getText();
Map<String, Integer> mergeRowMap = Maps.newHashMap();
mergeRowMap.put("fromRow", lastRow);
mergeRowMap.put("toRow", i + dangerListDataStartRow - 1);
......@@ -464,7 +467,8 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
report.getRemark(), report.getCompanyId());
reviewDangerList.add(rowRenderData);
}));
generateTableData(table, reviewDangerList);
// companyId字段在RowRenderData中下标(0开始,companyName:1,dangerName:2,dangerStateName:3,remark:4,companyId:5)
generateTableData(table, reviewDangerList, 5);
}
}
......
......@@ -38,5 +38,5 @@ public interface ICheckReportService {
* @param reportId
* @return
*/
Object getCheckReportDocx(HttpServletResponse response, String reportId) throws Exception;
void getCheckReportDocx(HttpServletResponse response, String reportId) throws Exception;
}
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