# Risk People Overview Risk Count 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:** 保持风险等级、TOP10 和项目风险人数回写口径继续基于去重规则数，不做范围外调整。仅在 `ccdi-project` 结果总览员工聚合 SQL 中增加单独的打标数量字段，并在风险人员总览服务映射时使用该字段作为 `riskCount`。

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

---

### Task 1: 锁定疑似违规数新口径

**Files:**
- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectOverviewServiceImplTest.java`
- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/mapper/CcdiProjectOverviewMapperSqlTest.java`

- [ ] **Step 1: Write the failing test**

调整服务测试，断言 `riskCount` 读取独立的打标数量字段，而不是 `ruleCount`。调整 SQL 结构测试，锁定员工聚合查询包含 `hit_count` 聚合。

- [ ] **Step 2: Run test to verify it fails**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectOverviewServiceImplTest,CcdiProjectOverviewMapperSqlTest
```

Expected:

- `FAIL`
- 原因是聚合 VO 与 SQL 尚未提供打标数量字段

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

为员工聚合 VO 新增 `hitCount` 字段；Mapper XML 增加 `count(1) as hit_count` 聚合，并映射到结果集；Service 构建风险人员总览项时改为优先使用 `hitCount` 作为 `riskCount`。

- [ ] **Step 4: Run test to verify it passes**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectOverviewServiceImplTest,CcdiProjectOverviewMapperSqlTest
```

Expected:

- `PASS`

- [ ] **Step 5: Commit**

```bash
git add ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectOverviewServiceImplTest.java ccdi-project/src/test/java/com/ruoyi/ccdi/project/mapper/CcdiProjectOverviewMapperSqlTest.java ccdi-project/src/main/java/com/ruoyi/ccdi/project/domain/vo/CcdiProjectEmployeeRiskAggregateVO.java ccdi-project/src/main/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectOverviewServiceImpl.java ccdi-project/src/main/resources/mapper/ccdi/project/CcdiProjectOverviewMapper.xml
git commit -m "调整风险人员总览疑似违规数口径"
```
