diff --git a/src/main/java/com/gis/xian/dto/DisasterRiskData.java b/src/main/java/com/gis/xian/dto/DisasterRiskData.java index bd46e08..9c408f5 100644 --- a/src/main/java/com/gis/xian/dto/DisasterRiskData.java +++ b/src/main/java/com/gis/xian/dto/DisasterRiskData.java @@ -48,6 +48,8 @@ public class DisasterRiskData { private int index; /** 位置 */ private String position; + /** 灾害点名称 */ + private String disasterName; /** 乡镇/街道 */ private String village; /** 发生概率(小数 0-1) */ diff --git a/src/main/java/com/gis/xian/service/impl/IReportOutputServiceImpl.java b/src/main/java/com/gis/xian/service/impl/IReportOutputServiceImpl.java index ecc0ee5..31bc11b 100644 --- a/src/main/java/com/gis/xian/service/impl/IReportOutputServiceImpl.java +++ b/src/main/java/com/gis/xian/service/impl/IReportOutputServiceImpl.java @@ -130,7 +130,7 @@ public class IReportOutputServiceImpl implements ReportOutputService { inferenceResultFileMapper.upsert(id, relativePath, baseName); log.info("文件记录已写入: inference_id={}, file_name={}, file_path={}", id, baseName, relativePath); - return fileServerPath.replaceAll("/+$", "") + "/" + relativePath; + return relativePath; } /** @@ -223,6 +223,7 @@ public class IReportOutputServiceImpl implements ReportOutputService { String level = prob >= 70 ? "高" : "中"; return new DisasterRiskData.SpotRisk() .setPosition(spot.getPosition()) + .setDisasterName(spot.getDisasterName()) .setVillage(spot.getVillage()) .setProbability(prob) .setRiskLevel(level); diff --git a/src/main/java/com/gis/xian/utils/ReportTableBuilder.java b/src/main/java/com/gis/xian/utils/ReportTableBuilder.java index 60dca4b..a2ec7ba 100644 --- a/src/main/java/com/gis/xian/utils/ReportTableBuilder.java +++ b/src/main/java/com/gis/xian/utils/ReportTableBuilder.java @@ -34,22 +34,27 @@ public class ReportTableBuilder { * 构建灾害风险表(四列:序号、位置、发生概率、灾害等级) */ public static TableRenderData buildRiskTable(String disasterType, List spots) { + // 山洪第二列用灾害点名称,其他用位置 + boolean useDisasterName = "山洪".equals(disasterType); + String col2Header = useDisasterName ? "灾害名称" : "位置"; + RowRenderData header = Rows.of( "序号", - "位置", + col2Header, disasterType + "发生概率", "灾害等级" - ).textFontFamily("黑体").textFontSize(XIAO_SI_FONT).textBold().center().create(); + ).textFontFamily("黑体").textFontSize(XIAO_SI_FONT).textBold().center().verticalCenter().create(); Tables.TableBuilder builder = Tables.of(header); AtomicInteger idx = new AtomicInteger(1); for (DisasterRiskData.SpotRisk spot : spots) { + String col2 = useDisasterName ? spot.getDisasterName() : spot.getPosition(); builder.addRow(Rows.of( String.valueOf(idx.getAndIncrement()), - spot.getPosition(), + col2, PCT_FMT.format(spot.getProbability()) + "%", spot.getRiskLevel() - ).textFontFamily("仿宋_GB2312").textFontSize(XIAO_SI_FONT).center().create()); + ).textFontFamily("仿宋_GB2312").textFontSize(XIAO_SI_FONT).center().verticalCenter().create()); } TableRenderData table = builder.create(); diff --git a/src/main/resources/template/rainfall/rainfall-template.docx b/src/main/resources/template/rainfall/rainfall-template.docx index 17d3649..d02fcfc 100644 Binary files a/src/main/resources/template/rainfall/rainfall-template.docx and b/src/main/resources/template/rainfall/rainfall-template.docx differ