# Component-Org Service 编译错误分类 (200 errors, 8 files) **日期**: 2026-05-05 **构建**: `mvn compile -DskipTests -s ../maven-cw-elevator-application/.mvn/settings.xml` **JDK**: 1.8.0_482 | **Spring Boot**: 1.5.22 | **CFR 反编译**: 0.152 --- ## 错误总览 | 类别 | 数量 | 根因 | 自动修复难度 | |------|------|------|-------------| | No-symbol (找不到符号) | 78 | `$$$` ast-grep 残留 + raw stream 调用 + 方法歧义 | ⭐⭐ 中 | | Object→cast | 76 | raw List/Map 失去泛型 | ⭐⭐⭐ 高 | | Type-mismatch | 22 | 类型声明与使用不匹配 | ⭐⭐ 中 | | Ambiguous (方法歧义) | 16 | redisTemplate.execute() 歧义 | ⭐ 低 | | Type-inf (类型推断) | 6 | 空集合初始化泛型推断 | ⭐ 低 | **总计**: 200 errors in 8 files --- ## 1. No-symbol (78 errors) ### 1.1 `$$$` ast-grep 残留 (36 errors) **涉及文件**: CpOrgDevieKitServiceImpl (32), OrganizationUnitTypeServiceImpl (12), AreaTypeServiceImpl (2) **根因**: `ast_grep_replace` 将 `return CloudwalkResult.success(X)` 改为 `return (CloudwalkResult) CloudwalkResult.success($$$)` 时, `$$$` 捕获参数但 rewrite 时 `$$$` 在 `success()` 括号内丢失了 X — X 变量覆盖了 `$$$` 变量名。 **源代码模式**: ```java // 改写前 (ast-grep) return CloudwalkResult.success(updateGroupResult); // 改写后 (异常) return (CloudwalkResult) CloudwalkResult.success($$$); ``` **修复方案**: 逐行恢复原始表达式。 **影响方法**: - CpOrgDevieKitServiceImpl: `onUpdateGroupRequest(L117)`, `onUpdateFeatureRequest(L127/L140/L166)`, `onUpdatePictureRequest(L176/L189/L215)`, `onUpdatePersonRequest(L235/L255/L310)`, `handlePersonValidDate(L522/L530)` - OrganizationUnitTypeServiceImpl: `page(L76)`, `getList(L110)`, `defaultInitOrgType(L121/L145)`, `initParkOrg(L188/L227)` - AreaTypeServiceImpl: `add(L104)` ### 1.2 raw stream `.map()` 调用 Object 方法 (12 errors) **涉及文件**: OrganizationServiceImpl.detail(L814,L815,L824,L843), CpImageStorePersonManager(L110,L357,L365,L386) **根因**: raw List 的 `.stream()` 返回 `Stream`, 对 Object 调用 `.getAreaId()` / `.getImageStoreId()` 找不到方法。 **源代码模式**: ```java // refDTOS 是 raw List, stream() 是 Stream List officeArea = refDTOS.stream() .filter(it -> it.getRefType() == 0) // Object 没有 getRefType() .map(o -> o.getAreaId()) // Object 没有 getAreaId() .collect(Collectors.toList()); ``` **修复方案**: 在 stream 前添加 `(List)` 转换,或定义变量时指定泛型。 ### 1.3 redisTemplate.delete(Object) (2 errors) **涉及文件**: CpOrgDevieKitServiceImpl.unlockSyncLog(L593) **根因**: `redisTemplate.delete(Object)` — RedisTemplate 的 `delete()` 签名是 `delete(K key)` 泛型, 传入 Object 无法匹配。 **修复方案**: 删除 `(Object)` 转型, 直接传 key: `this.redisTemplate.delete(key);` --- ## 2. Object→cast (76 errors) ### 2.1 for-each over raw Collection (30+ errors) **涉及文件**: CpImageStorePersonSynManager, CpImageStorePersonValidateManager, CpOrgDevieKitServiceImpl **根因**: raw List/Map 遍历时 Iterator 返回 Object, 无法赋值给具体类型。 **源代码模式**: ```java // removeMap 是 raw Map for (Map.Entry entry : removeMap.entrySet()) { ... } // 修复: for (Map.Entry> entry : removeMap.entrySet()) { ... } // personInfoDataDatas 是 raw Collection for (DeviceImageUpdateFeautreResult deviceUpdatePersonResult : personInfoDataDatas) { ... } // 修复: 声明 personInfoDataDatas 为 Collection ``` **修复方案**: 找到 raw Collection 的声明位置, 添加泛型类型参数。如果变量有多态使用, 则添加 `(Collection)` 转换。 ### 2.2 redisTemplate.keys() 返回 raw Set (8 errors) **涉及文件**: CpImageStorePersonSynManager.checkHandleSynTaskException(L489,L492,L499,L502) **根因**: `redisTemplate.keys(pattern)` 返回 `Set`, 但声明为 raw `Set`, 后续 `.replaceFirst()` 等方法在 Object 上找不到。 **源代码模式**: ```java Set synQueueHeadDataKeys = this.redisTemplate.keys(...); String imageStoreId = synQueueHeadDataKey.replaceFirst(SYN_QUEUE_HEAD_DATA, ""); ``` **修复方案**: 声明为 `Set`: ```java Set synQueueHeadDataKeys = this.redisTemplate.keys(...); ``` ### 2.3 Map.get() 返回 Object (8 errors) **涉及文件**: CpImageStorePersonManager(L316,L336), OrganizationUnitTypeServiceImpl(L59) **根因**: raw Map 的 `get()` 返回 Object, 无法调用 `.setPersonId()` 或赋值给 Integer。 **修复方案**: 声明 Map 为 `Map` 泛型, 或在 get() 结果上添加强制转型。 ### 2.4 stream().collect() 返回 Object (10 errors) **涉及文件**: OrganizationServiceImpl.saveAreaDetails(L963,L970,L974,L981) **根因**: raw List 的 stream 操作, collect 返回 Object 无法赋值给具体类型。 **修复方案**: 在 stream 前添加 `(List)` 转换: ```java List passableList = ((List)passableArea).stream().map(...).collect(Collectors.toList()); ``` --- ## 3. Type-mismatch (22 errors) ### 3.1 `String` → `Set` 转型 (8 errors) **涉及文件**: CpImageStorePersonSynManager(L489,L492,L499,L502) **根因**: 代码写了 `(java.lang.String)` 转型但实际类型是 `Set`: ```java Set synQueueHeadDataKeys = (java.lang.String) this.redisTemplate.keys(...); ``` **修复方案**: 修改转型为目标类型: ```java Set synQueueHeadDataKeys = this.redisTemplate.keys(...); ``` ### 3.2 三元表达式类型不一致 (4 errors) **涉及文件**: CpImageStorePersonValidateManager(L150, L453) **根因**: ```java List syncPersonDtoList = StringUtils.isNotBlank(dataSet) ? JsonUtils.toObjList(dataSet, SyncPersonLocal.class) : new ArrayList<>(); // inferred as ArrayList ``` `JsonUtils.toObjList()` 返回 `List`, `new ArrayList<>()` 推断为 `ArrayList`, 三元运算符的两个分支类型不一致。 **修复方案**: 指定 ArrayList 的泛型: ```java : new ArrayList() ``` ### 3.3 `ArrayList` vs `List` (2 errors) **涉及文件**: OrganizationServiceImpl.getList(L552) **根因**: `ids` 声明为 `ArrayList` 但 `param.getIds()` 返回 `List`, 不能直接赋值。 **修复方案**: ```java ids = new ArrayList<>(param.getIds()); // 或 ids.clear(); ids.addAll(param.getIds()); ``` ### 3.4 `List` vs `List` (2 errors) **涉及文件**: OrganizationServiceImpl.detail(L826) **根因**: zoneIds 声明为 `List` 但 `result.setZoneIds()` 接受 `List`。 **修复方案**: ```java result.setZoneIds((List)(List) zoneIds); // 双重转型绕过泛型检查 ``` ### 3.5 `List>` vs `List` (2 errors) **涉及文件**: CpImageStorePersonTxHandler.handleImageStorePersonDelete(L201) **根因**: `Lists.partition()` 返回 `List>` 但赋值给 `List`。 **修复方案**: ```java List> partition = Lists.partition(changePersonIds, delBatchSize); ``` --- ## 4. Ambiguous (16 errors) - redisTemplate.execute() 歧义 **涉及文件**: CpImageStorePersonSynManager (12), CpImageStorePersonValidateManager (4) **根因**: `RedisTemplate.execute()` 有两个重载: - `execute(RedisCallback callback)` - `execute(SessionCallback callback)` lambda `connection -> connection.eval(...)` 同时匹配 RedisCallback 和 SessionCallback。 **源代码**: ```java this.redisTemplate.execute(connection -> (Long)connection.eval(lua, keys, args)) ``` **修复方案**: 添加 lambda 参数类型或转型: ```java this.redisTemplate.execute((RedisCallback) connection -> connection.eval(lua, keys, args)) ``` --- ## 5. Type-inf (6 errors) - 类型推断失败 ### 5.1 Sets.newHashSet() 泛型推断 (2 errors) **涉及文件**: CpImageStorePersonTxHandler.deletePersonFromImageStores(L221) **根因**: `Sets.newHashSet((Object[])new String[]{imageId})` — 重建数组丢失类型。 **修复方案**: ```java Sets.newHashSet(imageId) // 或 Sets.newHashSet(new String[]{imageId}) ``` ### 5.2 Map infer from stream (4 errors) **涉及文件**: CpImageStorePersonSynManager.handleImageStoreIncrementSyn(L417,L418) **根因**: `.collect(Collectors.groupingBy(...))` 的结果赋值给 `Map>` 但 stream 是 raw。 **修复方案**: 先转型 source 再 stream。 --- ## 每文件修复优先级 | 文件 | 错误数 | 主要类别 | 修复复杂度 | 预估时间 | |------|-------|---------|-----------|---------| | CpOrgDevieKitServiceImpl | 54 | $$ (32), Obj→cast (20) | ⭐⭐ | 30 min | | CpImageStorePersonSynManager | 38 | Obj→cast (10), Ambiguous (12) | ⭐⭐ | 25 min | | OrganizationServiceImpl | 32 | No-sym (14), Obj→cast (14) | ⭐⭐ | 20 min | | CpImageStorePersonValidateManager | 28 | Obj→cast (12), Type-mis (8) | ⭐⭐ | 20 min | | CpImageStorePersonManager | 16 | No-sym (8), Obj→cast (8) | ⭐⭐ | 15 min | | OrganizationUnitTypeServiceImpl | 14 | $$ (12), Obj→cast (2) | ⭐ | 10 min | | AreaTypeServiceImpl | 10 | $$ (2), Obj→cast (8) | ⭐ | 10 min | | CpImageStorePersonTxHandler | 8 | Type-mis (2), No-sym (2) | ⭐ | 5 min | **总预估**: 约 2 小时逐行修复。