Commit 027cc9ddffc974a4dfbabec2939d06769311e080
1 parent
96cde8ad
feat(garden): 新增行道树栽种年月和树种类型字段支持
Showing
8 changed files
with
70 additions
and
3 deletions
api_document_tree_inspection.md
| ... | ... | @@ -103,6 +103,19 @@ GET /garden/tree/page?pageNo=1&pageSize=20&treeSpeciesType=1 |
| 103 | 103 | |
| 104 | 104 | > 列表中在"胸径"后面新增"树种类别"展示列,值通过字典翻译。 |
| 105 | 105 | |
| 106 | +### 2.4 一树一档案修改记录 | |
| 107 | + | |
| 108 | +**接口**:`GET /garden/tree-change-log/page?treeid={treeid}` | |
| 109 | + | |
| 110 | +返回数据或请求参数已支持新字段: | |
| 111 | + | |
| 112 | +- 请求参数新增:`plantingDate` (栽种年月), `treeSpeciesType` (树种类型字典值) 用于过滤检索。 | |
| 113 | +- 响应对象(`TreeChangeLogRespVO`)已补齐: | |
| 114 | + - `plantingDate`: 栽种年月,格式 `yyyy-MM` | |
| 115 | + - `treeSpeciesType`: 树种类型字典值 | |
| 116 | + | |
| 117 | +> 💡 **业务说明**:当行道树通过“新增/编辑”以及“巡检记录自动回写”时,系统均会自动向修改记录表中插入一条变更快照。 | |
| 118 | + | |
| 106 | 119 | --- |
| 107 | 120 | |
| 108 | 121 | ## 三、巡检记录相关接口变更 | ... | ... |
sql/tree_inspection_planting_date.sql
| ... | ... | @@ -6,14 +6,18 @@ |
| 6 | 6 | ALTER TABLE garden_tree ADD COLUMN planting_date VARCHAR(10) COMMENT '栽种年月(格式yyyy-MM)'; |
| 7 | 7 | ALTER TABLE garden_tree ADD COLUMN tree_species_type VARCHAR(20) COMMENT '树种类型(字典类型:tree_species_type)'; |
| 8 | 8 | |
| 9 | --- 2. garden_tree_inspection 表新增字段 | |
| 9 | +-- 2. garden_tree_change_log 表新增字段(修改记录表与主表保持一致) | |
| 10 | +ALTER TABLE garden_tree_change_log ADD COLUMN planting_date VARCHAR(10) COMMENT '栽种年月(格式yyyy-MM)'; | |
| 11 | +ALTER TABLE garden_tree_change_log ADD COLUMN tree_species_type VARCHAR(20) COMMENT '树种类型(字典类型:tree_species_type)'; | |
| 12 | + | |
| 13 | +-- 3. garden_tree_inspection 表新增字段 | |
| 10 | 14 | ALTER TABLE garden_tree_inspection ADD COLUMN planting_date VARCHAR(10) COMMENT '栽植年月(格式yyyy-MM)'; |
| 11 | 15 | |
| 12 | --- 3. 插入字典类型 | |
| 16 | +-- 4. 插入字典类型 | |
| 13 | 17 | INSERT INTO system_dict_type (name, type, status, remark, creator, create_time, updater, update_time, deleted, deleted_time) |
| 14 | 18 | VALUES ('树种类型', 'tree_species_type', 0, '行道树树种类型(深根性/浅根性)', '1', NOW(), '1', NOW(), 0, NULL); |
| 15 | 19 | |
| 16 | --- 4. 插入字典数据(注意:dict_type 对应上面的 type 值) | |
| 20 | +-- 5. 插入字典数据(注意:dict_type 对应上面的 type 值) | |
| 17 | 21 | INSERT INTO system_dict_data (sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted, deleted_time) |
| 18 | 22 | VALUES (1, '深根性树种', '1', 'tree_species_type', 0, 'default', '', '深根性树种', '1', NOW(), '1', NOW(), 0, NULL); |
| 19 | 23 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/treechangelog/vo/TreeChangeLogPageReqVO.java
| ... | ... | @@ -70,6 +70,12 @@ public class TreeChangeLogPageReqVO extends PageParam { |
| 70 | 70 | @Schema(description = "估测树龄") |
| 71 | 71 | private String estimationtreeage; |
| 72 | 72 | |
| 73 | + @Schema(description = "栽种年月(格式yyyy-MM)") | |
| 74 | + private String plantingDate; | |
| 75 | + | |
| 76 | + @Schema(description = "树种类型(字典类型:tree_species_type)") | |
| 77 | + private String treeSpeciesType; | |
| 78 | + | |
| 73 | 79 | @Schema(description = "冠幅东西") |
| 74 | 80 | private String canopyeastwest; |
| 75 | 81 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/treechangelog/vo/TreeChangeLogRespVO.java
| ... | ... | @@ -106,6 +106,14 @@ public class TreeChangeLogRespVO implements VO { |
| 106 | 106 | @ExcelProperty("估测树龄") |
| 107 | 107 | private String estimationtreeage; |
| 108 | 108 | |
| 109 | + @Schema(description = "栽种年月(格式yyyy-MM)", example = "2015-06") | |
| 110 | + @ExcelProperty("栽种年月") | |
| 111 | + private String plantingDate; | |
| 112 | + | |
| 113 | + @Schema(description = "树种类型(字典类型:tree_species_type)", example = "1") | |
| 114 | + @ExcelProperty("树种类别") | |
| 115 | + private String treeSpeciesType; | |
| 116 | + | |
| 109 | 117 | @Schema(description = "冠幅东西") |
| 110 | 118 | @ExcelProperty("冠幅东西") |
| 111 | 119 | private String canopyeastwest; | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/treechangelog/vo/TreeChangeLogSaveReqVO.java
| ... | ... | @@ -72,6 +72,12 @@ public class TreeChangeLogSaveReqVO { |
| 72 | 72 | @Schema(description = "估测树龄") |
| 73 | 73 | private String estimationtreeage; |
| 74 | 74 | |
| 75 | + @Schema(description = "栽种年月(格式yyyy-MM)", example = "2015-06") | |
| 76 | + private String plantingDate; | |
| 77 | + | |
| 78 | + @Schema(description = "树种类型(字典类型:tree_species_type)", example = "1") | |
| 79 | + private String treeSpeciesType; | |
| 80 | + | |
| 75 | 81 | @Schema(description = "冠幅东西") |
| 76 | 82 | private String canopyeastwest; |
| 77 | 83 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/treechangelog/TreeChangeLogDO.java
| ... | ... | @@ -108,6 +108,14 @@ public class TreeChangeLogDO { |
| 108 | 108 | */ |
| 109 | 109 | private String estimationtreeage; |
| 110 | 110 | /** |
| 111 | + * 栽种年月(格式 yyyy-MM) | |
| 112 | + */ | |
| 113 | + private String plantingDate; | |
| 114 | + /** | |
| 115 | + * 树种类型(字典类型:tree_species_type) | |
| 116 | + */ | |
| 117 | + private String treeSpeciesType; | |
| 118 | + /** | |
| 111 | 119 | * 冠幅东西 |
| 112 | 120 | */ |
| 113 | 121 | private String canopyeastwest; | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/treeinspection/TreeInspectionServiceImpl.java
| ... | ... | @@ -17,12 +17,16 @@ import com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil; |
| 17 | 17 | import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; |
| 18 | 18 | import com.zteits.urbanops.module.garden.dal.dataobject.treeinspection.TreeInspectionDO; |
| 19 | 19 | import com.zteits.urbanops.module.garden.dal.dataobject.tree.TreeDO; |
| 20 | +import com.zteits.urbanops.module.garden.dal.dataobject.treechangelog.TreeChangeLogDO; | |
| 20 | 21 | import com.zteits.urbanops.module.garden.dal.mysql.treeinspection.TreeInspectionMapper; |
| 21 | 22 | import com.zteits.urbanops.module.garden.dal.mysql.tree.TreeMapper; |
| 23 | +import com.zteits.urbanops.module.garden.dal.mysql.treechangelog.TreeChangeLogMapper; | |
| 22 | 24 | import com.zteits.urbanops.module.garden.enums.ErrorCodeConstants; |
| 23 | 25 | import com.zteits.urbanops.module.garden.controller.app.treeinspection.vo.*; |
| 24 | 26 | import com.zteits.urbanops.module.garden.convert.treeinspection.TreeInspectionConvert; |
| 25 | 27 | |
| 28 | +import java.time.LocalDateTime; | |
| 29 | + | |
| 26 | 30 | /** |
| 27 | 31 | * 行道树巡检与安全风险评估业务 Service 实现类 |
| 28 | 32 | * |
| ... | ... | @@ -39,6 +43,9 @@ public class TreeInspectionServiceImpl implements TreeInspectionService { |
| 39 | 43 | @Resource |
| 40 | 44 | private TreeMapper treeMapper; |
| 41 | 45 | |
| 46 | + @Resource | |
| 47 | + private TreeChangeLogMapper treeChangeLogMapper; | |
| 48 | + | |
| 42 | 49 | @Override |
| 43 | 50 | @Transactional(rollbackFor = Exception.class) |
| 44 | 51 | public Long createTreeInspection(TreeInspectionSaveReqVO createReqVO) { |
| ... | ... | @@ -162,6 +169,17 @@ public class TreeInspectionServiceImpl implements TreeInspectionService { |
| 162 | 169 | } |
| 163 | 170 | if (needUpdateTree) { |
| 164 | 171 | treeMapper.updateById(tree); |
| 172 | + | |
| 173 | + // 8.1 插入一树一档案修改记录(巡检回写引起的变更) | |
| 174 | + TreeChangeLogDO changeLog = new TreeChangeLogDO(); | |
| 175 | + org.springframework.beans.BeanUtils.copyProperties(tree, changeLog); | |
| 176 | + changeLog.setId(null); | |
| 177 | + changeLog.setTreeid(tree.getId()); | |
| 178 | + changeLog.setCreateby(loginUserId != null ? String.valueOf(loginUserId) : null); | |
| 179 | + changeLog.setCreatetime(LocalDateTime.now()); | |
| 180 | + changeLog.setUpdateby(loginUserId != null ? String.valueOf(loginUserId) : null); | |
| 181 | + changeLog.setUpdatetime(LocalDateTime.now()); | |
| 182 | + treeChangeLogMapper.insert(changeLog); | |
| 165 | 183 | } |
| 166 | 184 | |
| 167 | 185 | return entity.getId(); | ... | ... |
urbanops-module-garden/src/test/java/com/zteits/urbanops/module/garden/service/treeinspection/TreeInspectionServiceImplTest.java
| ... | ... | @@ -12,6 +12,7 @@ import com.zteits.urbanops.module.garden.dal.dataobject.treeinspection.TreeInspe |
| 12 | 12 | import com.zteits.urbanops.module.garden.dal.dataobject.tree.TreeDO; |
| 13 | 13 | import com.zteits.urbanops.module.garden.dal.mysql.treeinspection.TreeInspectionMapper; |
| 14 | 14 | import com.zteits.urbanops.module.garden.dal.mysql.tree.TreeMapper; |
| 15 | +import com.zteits.urbanops.module.garden.dal.mysql.treechangelog.TreeChangeLogMapper; | |
| 15 | 16 | import com.zteits.urbanops.module.garden.controller.app.treeinspection.vo.*; |
| 16 | 17 | import com.zteits.urbanops.module.garden.enums.ErrorCodeConstants; |
| 17 | 18 | |
| ... | ... | @@ -32,6 +33,9 @@ public class TreeInspectionServiceImplTest extends BaseMockitoUnitTest { |
| 32 | 33 | @Mock |
| 33 | 34 | private TreeMapper treeMapper; |
| 34 | 35 | |
| 36 | + @Mock | |
| 37 | + private TreeChangeLogMapper treeChangeLogMapper; | |
| 38 | + | |
| 35 | 39 | private TreeInspectionSaveReqVO createReqVOBase() { |
| 36 | 40 | TreeInspectionSaveReqVO req = new TreeInspectionSaveReqVO(); |
| 37 | 41 | req.setTreeId(1024L); | ... | ... |