Commit 9ce96e13e9c809ac991a8b8a6475fdc8a79bdb9b

Authored by 戈灵虎
1 parent 6a9f62b5

fix(tree-inspection): 统一树种类型字段使用字典值

2026年6月 危险树巡查新增需求.docx 0 → 100644
No preview for this file type
api_document_tree_inspection.md
@@ -135,7 +135,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 @@ -135,7 +135,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1
135 "trunk": { "woodDamage": 0, "tilt": 0, "barkDamage": 0 }, 135 "trunk": { "woodDamage": 0, "tilt": 0, "barkDamage": 0 },
136 "crown": { "looseBranch": 0, "collarAbnormal": 0, "ventilationBalance": 0 }, 136 "crown": { "looseBranch": 0, "collarAbnormal": 0, "ventilationBalance": 0 },
137 "weight": { 137 "weight": {
138 - "treeSpeciesType": "深根性树种", 138 + "treeSpeciesType": "1",
139 "plantingDate": "2015-06", 139 "plantingDate": "2015-06",
140 "isWindCorridor": false, 140 "isWindCorridor": false,
141 "treePoolType": "联通树池", 141 "treePoolType": "联通树池",
@@ -158,7 +158,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 @@ -158,7 +158,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1
158 158
159 | 字段 | 类型 | 必填 | 说明 | 159 | 字段 | 类型 | 必填 | 说明 |
160 |------|------|------|------| 160 |------|------|------|------|
161 -| `treeSpeciesType` | String | **是** | 树种类型文本:`"深根性树种"` 或 `"浅根性树种"` | 161 +| `treeSpeciesType` | String | **是** | 树种类型字典值:`"1"` (深根性树种) 或 `"2"` (浅根性树种) |
162 | `plantingDate` | String | 否 | 栽植年月,格式 `yyyy-MM`。**填写后系统自动计算年限和权重** | 162 | `plantingDate` | String | 否 | 栽植年月,格式 `yyyy-MM`。**填写后系统自动计算年限和权重** |
163 | `plantingYears` | String | 否 | **已废弃**,无需传入。后端根据 `plantingDate` 自动计算 | 163 | `plantingYears` | String | 否 | **已废弃**,无需传入。后端根据 `plantingDate` 自动计算 |
164 | `isWindCorridor` | Boolean | **是** | 是否处于风口 | 164 | `isWindCorridor` | Boolean | **是** | 是否处于风口 |
@@ -183,7 +183,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 @@ -183,7 +183,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1
183 "treeId": 1024, 183 "treeId": 1024,
184 "inspectionTime": "2026-06-05 14:30:00", 184 "inspectionTime": "2026-06-05 14:30:00",
185 "weight": { 185 "weight": {
186 - "treeSpeciesType": "深根性树种", 186 + "treeSpeciesType": "1",
187 "treeSpeciesWeight": 1.0, 187 "treeSpeciesWeight": 1.0,
188 "plantingYears": "栽植 10-30 年", 188 "plantingYears": "栽植 10-30 年",
189 "plantingYearsWeight": 1.1, 189 "plantingYearsWeight": 1.1,
@@ -234,7 +234,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 @@ -234,7 +234,7 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1
234 "trunk": { "woodDamage": 0, "tilt": 0, "barkDamage": 0 }, 234 "trunk": { "woodDamage": 0, "tilt": 0, "barkDamage": 0 },
235 "crown": { "looseBranch": 0, "collarAbnormal": 0, "ventilationBalance": 0 }, 235 "crown": { "looseBranch": 0, "collarAbnormal": 0, "ventilationBalance": 0 },
236 "weight": { 236 "weight": {
237 - "treeSpeciesType": "深根性树种", 237 + "treeSpeciesType": "1",
238 "treeSpeciesWeight": 1.0, 238 "treeSpeciesWeight": 1.0,
239 "plantingYears": "栽植 10-30 年", 239 "plantingYears": "栽植 10-30 年",
240 "plantingYearsWeight": 1.1, 240 "plantingYearsWeight": 1.1,
@@ -313,6 +313,6 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 @@ -313,6 +313,6 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1
313 ## 五、注意事项 313 ## 五、注意事项
314 314
315 1. `estimationtreeage` 和 `plantingYears` 字段虽然废弃但**后端仍保留兼容**,前端可以分阶段迁移 315 1. `estimationtreeage` 和 `plantingYears` 字段虽然废弃但**后端仍保留兼容**,前端可以分阶段迁移
316 -2. 巡检提交接口中 `weight.treeSpeciesType` 传的是**文本**("深根性树种"/"浅根性树种"),不是字典值;而一树一档案中 `treeSpeciesType` 存的也是相同文本 316 +2. 巡检提交接口、一树一档案以及历史变更记录中的 `treeSpeciesType` 均已统一使用**字典值**(`"1"`=深根性,`"2"`=浅根性),读取接口也同样输出该字典值。
317 3. `plantingDate` 格式必须严格为 `yyyy-MM`(如 `"2015-06"`),否则后端解析会失败并降级处理 317 3. `plantingDate` 格式必须严格为 `yyyy-MM`(如 `"2015-06"`),否则后端解析会失败并降级处理
318 4. `/latest` 接口返回 `data` 为 `null` 时表示无历史巡检记录,前端应展示空表单 318 4. `/latest` 接口返回 `data` 为 `null` 时表示无历史巡检记录,前端应展示空表单
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/treeinspection/vo/TreeInspectionRespVO.java
@@ -111,7 +111,7 @@ public class TreeInspectionRespVO { @@ -111,7 +111,7 @@ public class TreeInspectionRespVO {
111 @Data 111 @Data
112 @Schema(description = "权重因子评估详情") 112 @Schema(description = "权重因子评估详情")
113 public static class WeightRespDTO { 113 public static class WeightRespDTO {
114 - @Schema(description = "树种类型:深根性树种, 浅根性树种", example = "深根性树种") 114 + @Schema(description = "树种类型(字典值:1=深根性树种, 2=浅根性树种)", example = "1")
115 private String treeSpeciesType; 115 private String treeSpeciesType;
116 116
117 @Schema(description = "树种类型权重常数", example = "1.0") 117 @Schema(description = "树种类型权重常数", example = "1.0")
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/treeinspection/vo/TreeInspectionSaveReqVO.java
@@ -129,7 +129,7 @@ public class TreeInspectionSaveReqVO { @@ -129,7 +129,7 @@ public class TreeInspectionSaveReqVO {
129 @Data 129 @Data
130 @Schema(description = "权重因子评估 DTO") 130 @Schema(description = "权重因子评估 DTO")
131 public static class WeightDTO { 131 public static class WeightDTO {
132 - @Schema(description = "树种类型:深根性树种, 浅根性树种", requiredMode = Schema.RequiredMode.REQUIRED, example = "深根性树种") 132 + @Schema(description = "树种类型(字典值:1=深根性树种, 2=浅根性树种)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
133 @NotBlank(message = "树种类型不能为空") 133 @NotBlank(message = "树种类型不能为空")
134 private String treeSpeciesType; 134 private String treeSpeciesType;
135 135
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/treeinspection/TreeInspectionServiceImpl.java
@@ -71,7 +71,7 @@ public class TreeInspectionServiceImpl implements TreeInspectionService { @@ -71,7 +71,7 @@ public class TreeInspectionServiceImpl implements TreeInspectionService {
71 } 71 }
72 72
73 // 4. 补齐各因子的权重指标(即使由前端打分,后端依然补齐数据库里各个细节因子权重以支持底层的统计与分析) 73 // 4. 补齐各因子的权重指标(即使由前端打分,后端依然补齐数据库里各个细节因子权重以支持底层的统计与分析)
74 - double treeSpeciesWeight = "浅根性树种".equals(entity.getTreeSpeciesType()) ? 1.1 : 1.0; 74 + double treeSpeciesWeight = "2".equals(entity.getTreeSpeciesType()) || "浅根性树种".equals(entity.getTreeSpeciesType()) ? 1.1 : 1.0;
75 entity.setTreeSpeciesWeight(treeSpeciesWeight); 75 entity.setTreeSpeciesWeight(treeSpeciesWeight);
76 76
77 // 4.1 如果传入了 plantingDate(栽植年月),自动计算 plantingYears 文本和权重 77 // 4.1 如果传入了 plantingDate(栽植年月),自动计算 plantingYears 文本和权重
urbanops-module-garden/src/test/java/com/zteits/urbanops/module/garden/service/treeinspection/TreeInspectionServiceImplTest.java
@@ -71,7 +71,7 @@ public class TreeInspectionServiceImplTest extends BaseMockitoUnitTest { @@ -71,7 +71,7 @@ public class TreeInspectionServiceImplTest extends BaseMockitoUnitTest {
71 71
72 // 权重 72 // 权重
73 TreeInspectionSaveReqVO.WeightDTO weight = new TreeInspectionSaveReqVO.WeightDTO(); 73 TreeInspectionSaveReqVO.WeightDTO weight = new TreeInspectionSaveReqVO.WeightDTO();
74 - weight.setTreeSpeciesType("深根性树种"); // 1.0 74 + weight.setTreeSpeciesType("1"); // 1.0
75 weight.setPlantingYears("栽植 10-30 年"); // 1.1 75 weight.setPlantingYears("栽植 10-30 年"); // 1.1
76 weight.setIsWindCorridor(false); // 1.0 76 weight.setIsWindCorridor(false); // 1.0
77 weight.setTreePoolType("联通树池"); // 1.0 77 weight.setTreePoolType("联通树池"); // 1.0
@@ -200,7 +200,7 @@ public class TreeInspectionServiceImplTest extends BaseMockitoUnitTest { @@ -200,7 +200,7 @@ public class TreeInspectionServiceImplTest extends BaseMockitoUnitTest {
200 entity.setCrownLooseBranch(0); 200 entity.setCrownLooseBranch(0);
201 entity.setCrownCollarAbnormal(0); 201 entity.setCrownCollarAbnormal(0);
202 entity.setCrownVentilationBalance(1); 202 entity.setCrownVentilationBalance(1);
203 - entity.setTreeSpeciesType("深根性树种"); 203 + entity.setTreeSpeciesType("1");
204 entity.setTreeSpeciesWeight(1.0); 204 entity.setTreeSpeciesWeight(1.0);
205 entity.setPlantingYears("栽植 10-30 年"); 205 entity.setPlantingYears("栽植 10-30 年");
206 entity.setPlantingYearsWeight(1.1); 206 entity.setPlantingYearsWeight(1.1);