# Project List Reanalyze Backend Implementation Plan

> **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** 确认并验证项目管理列表“重新分析”复用现有项目级重打标链路即可满足“重新打标并重新计算人数”的后端要求，不新增额外接口或并行逻辑。

**Architecture:** 后端实现保持不改代码的最短路径，继续复用 `CcdiBankTagController -> ProjectBankTagRebuildCoordinator -> CcdiBankTagServiceImpl -> CcdiProjectOverviewServiceImpl` 这条现有链路。实施工作集中在边界核验、接口契约回归、关键测试运行和实施记录沉淀，确保前端接入后不会因为后端口径不清而额外返工。

**Tech Stack:** Java 21, Spring Boot 3, JUnit 5, Mockito, Maven

## 后端验收清单

- `POST /ccdi/project/tags/rebuild` 支持只传 `projectId`
- 手动提交后项目状态会切换为 `3-打标中`
- 打标成功后会调用 `refreshOverviewEmployeeResults(projectId, operator)`
- `refreshOverviewEmployeeResults(projectId, operator)` 会同步刷新高/中/低风险人数

## 最小化实现结论

- 本次后端不新增接口
- 本次后端不新增服务分支
- 本次后端不新增人数重算调用

---

### Task 1: 核验现有后端链路已覆盖需求

**Files:**
- Modify: `docs/plans/backend/2026-03-24-project-list-reanalyze-backend-implementation.md`
- Reference: `ccdi-project/src/main/java/com/ruoyi/ccdi/project/controller/CcdiBankTagController.java`
- Reference: `ccdi-project/src/main/java/com/ruoyi/ccdi/project/service/impl/ProjectBankTagRebuildCoordinator.java`
- Reference: `ccdi-project/src/main/java/com/ruoyi/ccdi/project/service/impl/CcdiBankTagServiceImpl.java`
- Reference: `ccdi-project/src/main/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectOverviewServiceImpl.java`

- [ ] **Step 1: Write the acceptance checklist**

先在计划中明确本次后端必须被验证的四个事实：

- `POST /ccdi/project/tags/rebuild` 支持只传 `projectId`
- 手动提交后项目状态会切换为 `3-打标中`
- 打标成功后会调用 `refreshOverviewEmployeeResults(projectId, operator)`
- `refreshOverviewEmployeeResults(...)` 会同步刷新高/中/低风险人数

- [ ] **Step 2: Run repository grep to verify the call chain**

Run:

```bash
rg -n "refreshOverviewEmployeeResults|submitManual|/rebuild|updateProjectStatus\\(projectId, CcdiProjectStatusConstants.TAGGING" ccdi-project/src/main/java -S
```

Expected:

- 能同时看到控制器入口、协调器提交流程、`TAGGING` 状态切换和人数重算调用

- [ ] **Step 3: Keep implementation minimal**

如果上述四个事实都成立，则明确记录：

- 本次后端不新增接口
- 本次后端不新增服务分支
- 本次后端不新增人数重算调用

- [ ] **Step 4: Commit**

```bash
git add docs/plans/backend/2026-03-24-project-list-reanalyze-backend-implementation.md
git commit -m "补充项目列表重新分析后端实施计划"
```

### Task 2: 运行关键后端测试锁定现有契约

**Files:**
- Test: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/controller/CcdiBankTagControllerTest.java`
- Test: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/ProjectBankTagRebuildCoordinatorTest.java`
- Test: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiBankTagServiceRiskCountRefreshTest.java`

- [ ] **Step 1: Run controller and coordinator contract tests**

Run:

```bash
mvn -pl ccdi-project -Dtest=CcdiBankTagControllerTest,ProjectBankTagRebuildCoordinatorTest test
```

Expected:

- `PASS`
- 能证明手动重打标入口、运行中防重提交流程和归档保护逻辑都已存在

- [ ] **Step 2: Run risk count refresh test**

Run:

```bash
mvn -pl ccdi-project -Dtest=CcdiBankTagServiceRiskCountRefreshTest test
```

Expected:

- `PASS`
- 能证明重打标成功后会刷新员工结果并同步更新项目风险人数

- [ ] **Step 3: If any test fails, inspect before changing code**

若失败，先检查是否为环境或依赖问题，再决定是否需要补充代码；本次默认目标是不产生新的后端代码改动。

- [ ] **Step 4: Commit**

```bash
git status --short
```

Expected:

- 若仅运行测试无文件变化，则本任务无需代码提交

### Task 3: 补充后端验证记录与边界说明

**Files:**
- Create: `docs/tests/records/2026-03-24-project-list-reanalyze-backend-verification.md`
- Create: `docs/reports/implementation/2026-03-24-project-list-reanalyze-backend-record.md`

- [ ] **Step 1: Write verification skeleton**

创建后端验证记录，至少包含：

```markdown
# 项目管理列表重新分析后端验证记录

## 验证范围
- 手动重打标接口可直接复用于列表页
- 重打标开始后项目进入打标中
- 重打标成功后自动重算项目风险人数
- 运行中任务和归档项目保留既有后端保护
```

- [ ] **Step 2: Record exact commands and results**

把实际执行的测试命令和结果写入验证记录：

```bash
mvn -pl ccdi-project -Dtest=CcdiBankTagControllerTest,ProjectBankTagRebuildCoordinatorTest,CcdiBankTagServiceRiskCountRefreshTest test
```

Expected:

- 记录通过或失败原因

- [ ] **Step 3: Write the implementation record**

在 `docs/reports/implementation/2026-03-24-project-list-reanalyze-backend-record.md` 中写明：

- 为什么本次后端不需要改代码
- 现有复用链路覆盖了哪些需求
- 已验证的保护场景有哪些
- 后续仅由前端接线即可进入实现阶段

- [ ] **Step 4: Commit**

```bash
git add docs/tests/records/2026-03-24-project-list-reanalyze-backend-verification.md docs/reports/implementation/2026-03-24-project-list-reanalyze-backend-record.md
git commit -m "补充项目列表重新分析后端验证记录"
```
