Commit a029929bb402cf5af5c31caba40023010d232474

Authored by 王彪总
1 parent 85e34fb6

feat(garden): 添加GIS道路管理和坐标转换功能

- 新增GIS道路管理相关控制器、服务和数据对象
- 实现WGS84到GCJ02坐标转换算法和工具类
- 添加GIS道路关联和取消关联功能
- 实现GIS道路坐标批量转换功能
- 添加GIS道路数据导入导出功能
- 新增问题类型级联查询接口优化前端展示
- 配置本地调试Mock认证支持
- 更新部署脚本和数据库表结构变更SQL
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/problemtype/GardenProblemTypeMapper.java
... ... @@ -6,6 +6,8 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
6 6 import com.zteits.urbanops.module.garden.controller.admin.problemtype.vo.ProblemTypePageReqVO;
7 7 import com.zteits.urbanops.module.garden.dal.dataobject.problemtype.GardenProblemTypeDO;
8 8 import org.apache.ibatis.annotations.Mapper;
  9 +import org.apache.ibatis.annotations.Param;
  10 +import org.apache.ibatis.annotations.Select;
9 11  
10 12 import java.util.ArrayList;
11 13 import java.util.List;
... ... @@ -75,9 +77,15 @@ public interface GardenProblemTypeMapper extends BaseMapperX<GardenProblemTypeDO
75 77 }
76 78  
77 79 /**
  80 + * 绕过逻辑删除,直接查 typeCode 是否物理存在(用于编码生成时避免唯一键冲突)
  81 + */
  82 + @Select("SELECT COUNT(1) FROM garden_problem_type WHERE type_code = #{code}")
  83 + int countByTypeCodeRaw(@Param("code") String code);
  84 +
  85 + /**
78 86 * 生成下一个编码:父级编码 + 5位递增序号
79 87 * 如 parentCode=BIZ_GARDEN → BIZ_GARDEN00001, BIZ_GARDEN00002
80   - * 注意:加 LENGTH 条件避免匹配到子级编码(如 yl0000100001 干扰 yl 下的二级编码)
  88 + * 注意:加 LENGTH 条件避免匹配到子级编码;绕过逻辑删除检查确保唯一键可用
81 89 */
82 90 default String generateNextCode(String parentCode) {
83 91 int expectedLength = parentCode.length() + 5;
... ... @@ -86,17 +94,26 @@ public interface GardenProblemTypeMapper extends BaseMapperX<GardenProblemTypeDO
86 94 .apply("LENGTH(type_code) = {0}", expectedLength)
87 95 .orderByDesc(GardenProblemTypeDO::getTypeCode)
88 96 .last("LIMIT 1"));
  97 + int seq;
89 98 if (list == null || list.isEmpty()) {
90   - return parentCode + "00001";
91   - }
92   - String maxCode = list.get(0).getTypeCode();
93   - String seqStr = maxCode.substring(parentCode.length());
94   - try {
95   - int seq = Integer.parseInt(seqStr) + 1;
96   - return parentCode + String.format("%05d", seq);
97   - } catch (NumberFormatException e) {
98   - return parentCode + "00001";
  99 + seq = 1;
  100 + } else {
  101 + String maxCode = list.get(0).getTypeCode();
  102 + String seqStr = maxCode.substring(parentCode.length());
  103 + try {
  104 + seq = Integer.parseInt(seqStr) + 1;
  105 + } catch (NumberFormatException e) {
  106 + seq = 1;
  107 + }
99 108 }
  109 + // 跳过被逻辑删除记录占用的编码
  110 + int maxAttempts = 100;
  111 + String nextCode;
  112 + do {
  113 + nextCode = parentCode + String.format("%05d", seq);
  114 + seq++;
  115 + } while (countByTypeCodeRaw(nextCode) > 0 && --maxAttempts > 0);
  116 + return nextCode;
100 117 }
101 118  
102 119 }
... ...