# 计分考核模块 - 后端实施文档

> 版本：v1.0
> 创建日期：2026-01-14
> 优先级：P0

---

## 一、概述

### 1.1 文档说明
本文档为计分考核模块的后端实施指南，基于需求文档「需求-03-计分考核.md」编写。

### 1.2 现有模块状态
- **已有**：基础的月度考核汇总表（prison_score）和CRUD接口
- **缺失**：考核规则配置、日常考核记录、自动计算、等级评定、公示功能

### 1.3 新增数据表规划

| 序号 | 表名 | 说明 | 优先级 |
|-----|-----|------|-------|
| 1 | `prison_score_subject` | 考核规则科目表 | P0 |
| 2 | `prison_score_record` | 日常考核记录表 | P0 |
| 3 | `prison_score_level_rule` | 考核等级评定规则表 | P0 |
| 4 | `prison_score_notice` | 考核公示公告表 | P1 |

---

## 二、数据库设计

### 2.1 考核规则科目表 (prison_score_subject)

```sql
CREATE TABLE `prison_score_subject` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '规则ID',
    `code` varchar(50) NOT NULL COMMENT '规则编码（唯一）',
    `name` varchar(100) NOT NULL COMMENT '规则名称',
    `category` tinyint NOT NULL COMMENT '考核类别：1-劳动改造 2-教育改造 3-日常行为 4-卫生纪律 5-加分项 6-扣分项',
    `score` decimal(10,2) NOT NULL COMMENT '分值（正数为加分，负数为扣分）',
    `daily_limit` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '日最高分限制',
    `monthly_limit` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '月最高分限制',
    `description` varchar(500) DEFAULT NULL COMMENT '规则说明',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1-启用 2-禁用',
    `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_code` (`code`),
    KEY `idx_category` (`category`),
    KEY `idx_status` (`status`)
) ENGINE=InnoDB COMMENT='考核规则科目表';
```

**枚举定义**：
```java
/**
 * 考核类别枚举
 */
public enum ScoreSubjectCategoryEnum {
    LABOR(1, "劳动改造"),
    EDUCATION(2, "教育改造"),
    DAILY_BEHAVIOR(3, "日常行为"),
    HYGIENE_DISCIPLINE(4, "卫生纪律"),
    BONUS(5, "加分项"),
    PENALTY(6, "扣分项");

    private final Integer value;
    private final String name;
}

/**
 * 状态枚举
 */
public enum ScoreSubjectStatusEnum {
    ENABLED(1, "启用"),
    DISABLED(2, "禁用");
}
```

### 2.2 日常考核记录表 (prison_score_record)

```sql
CREATE TABLE `prison_score_record` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
    `prisoner_id` bigint NOT NULL COMMENT '罪犯ID',
    `prisoner_no` varchar(50) NOT NULL COMMENT '罪犯编号',
    `record_date` date NOT NULL COMMENT '考核日期',
    `subject_id` bigint NOT NULL COMMENT '考核规则ID',
    `subject_name` varchar(100) NOT NULL COMMENT '规则名称',
    `category` tinyint NOT NULL COMMENT '考核类别',
    `score` decimal(10,2) NOT NULL COMMENT '得分',
    `actual_score` decimal(10,2) NOT NULL COMMENT '实际得分（日限月限校验后）',
    `remark` varchar(500) DEFAULT NULL COMMENT '备注说明',
    `recorder_id` bigint NOT NULL COMMENT '记录人ID',
    `recorder_name` varchar(50) NOT NULL COMMENT '记录人姓名',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_prisoner_date` (`prisoner_no`, `record_date`),
    KEY `idx_record_date` (`record_date`),
    KEY `idx_subject` (`subject_id`)
) ENGINE=InnoDB COMMENT='日常考核记录表';
```

### 2.3 考核等级评定规则表 (prison_score_level_rule)

```sql
CREATE TABLE `prison_score_level_rule` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '规则ID',
    `level` tinyint NOT NULL COMMENT '等级：1-优秀 2-良好 3-合格 4-不合格',
    `level_name` varchar(20) NOT NULL COMMENT '等级名称',
    `min_score` decimal(10,2) NOT NULL COMMENT '最低分（含）',
    `max_score` decimal(10,2) NOT NULL COMMENT '最高分（含）',
    `description` varchar(500) DEFAULT NULL COMMENT '说明',
    `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1-启用 2-禁用',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_level` (`level`),
    KEY `idx_min_score` (`min_score`)
) ENGINE=InnoDB COMMENT='考核等级评定规则表';
```

**默认数据**：
```sql
INSERT INTO `prison_score_level_rule` (`level`, `level_name`, `min_score`, `max_score`, `description`, `sort`, `status`) VALUES
(1, '优秀', 120.00, 9999.99, '表现突出', 1, 1),
(2, '良好', 100.00, 119.99, '表现良好', 2, 1),
(3, '合格', 80.00, 99.99, '表现一般', 3, 1),
(4, '不合格', 0.00, 79.99, '表现较差', 4, 1);
```

### 2.4 考核公示公告表 (prison_score_notice)

```sql
CREATE TABLE `prison_score_notice` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '公告ID',
    `title` varchar(200) NOT NULL COMMENT '公告标题',
    `notice_type` tinyint NOT NULL DEFAULT 1 COMMENT '公示类型：1-月度考核结果 2-专项考核',
    `start_date` date NOT NULL COMMENT '公示开始日期',
    `end_date` date NOT NULL COMMENT '公示结束日期',
    `scope_type` tinyint NOT NULL DEFAULT 1 COMMENT '公示范围：1-全狱 2-指定监区',
    `scope_prison_area_ids` varchar(500) DEFAULT NULL COMMENT '指定监区ID列表',
    `content` text COMMENT '公示内容',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1-草稿 2-已发布 3-已撤回',
    `publisher_id` bigint DEFAULT NULL COMMENT '发布人ID',
    `publisher_name` varchar(50) DEFAULT NULL COMMENT '发布人姓名',
    `publish_time` datetime DEFAULT NULL COMMENT '发布时间',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_status` (`status`),
    KEY `idx_publish_time` (`publish_time`)
) ENGINE=InnoDB COMMENT='考核公示公告表';
```

---

## 三、后端接口设计

### 3.1 考核规则科目接口

**Controller路径**：`controller/admin/score/subject/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| POST | `/prison/score/subject/create` | prison:score:subject:create | 创建规则 |
| PUT | `/prison/score/subject/update` | prison:score:subject:update | 更新规则 |
| DELETE | `/prison/score/subject/delete` | prison:score:subject:delete | 删除规则 |
| GET | `/prison/score/subject/get` | prison:score:subject:query | 获取详情 |
| GET | `/prison/score/subject/page` | prison:score:subject:query | 分页查询 |
| GET | `/prison/score/subject/list` | prison:score:subject:query | 列表查询（无分页） |
| PUT | `/prison/score/subject/update-status` | prison:score:subject:update | 更新状态 |
| GET | `/prison/score/subject/export-excel` | prison:score:subject:export | 导出Excel |

**VO对象**：
```java
// ScoreSubjectSaveReqVO.java
public class ScoreSubjectSaveReqVO {
    @ApiModelProperty(value = "规则编码", required = true, example = "RULE001")
    @NotBlank(message = "规则编码不能为空")
    private String code;

    @ApiModelProperty(value = "规则名称", required = true, example = "超额完成生产任务")
    @NotBlank(message = "规则名称不能为空")
    private String name;

    @ApiModelProperty(value = "考核类别", required = true, example = "1", notes = "1-劳动改造 2-教育改造 3-日常行为 4-卫生纪律 5-加分项 6-扣分项")
    @NotNull(message = "考核类别不能为空")
    private Integer category;

    @ApiModelProperty(value = "分值", required = true, example = "2.00")
    @NotNull(message = "分值不能为空")
    private BigDecimal score;

    @ApiModelProperty(value = "日最高分限制", example = "5.00")
    private BigDecimal dailyLimit;

    @ApiModelProperty(value = "月最高分限制", example = "30.00")
    private BigDecimal monthlyLimit;

    @ApiModelProperty(value = "规则说明", example = "超额完成生产任务")
    private String description;

    @ApiModelProperty(value = "状态", example = "1")
    private Integer status;

    @ApiModelProperty(value = "排序", example = "1")
    private Integer sort;
}

// ScoreSubjectRespVO.java
public class ScoreSubjectRespVO {
    private Long id;
    private String code;
    private String name;
    private Integer category;
    private String categoryName;
    private BigDecimal score;
    private BigDecimal dailyLimit;
    private BigDecimal monthlyLimit;
    private String description;
    private Integer status;
    private String statusName;
    private Integer sort;
    private Date createTime;
}
```

### 3.2 日常考核记录接口

**Controller路径**：`controller/admin/score/record/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| POST | `/prison/score/record/create` | prison:score:record:create | 创建记录 |
| POST | `/prison/score/record/batch-create` | prison:score:record:create | 批量创建记录 |
| PUT | `/prison/score/record/update` | prison:score:record:update | 更新记录 |
| DELETE | `/prison/score/record/delete` | prison:score:record:delete | 删除记录 |
| GET | `/prison/score/record/get` | prison:score:record:query | 获取详情 |
| GET | `/prison/score/record/page` | prison:score:record:query | 分页查询 |
| GET | `/prison/score/record/export-excel` | prison:score:record:export | 导出Excel |
| GET | `/prison/score/record/get-by-prisoner` | prison:score:record:query | 获取罪犯考核明细 |

**VO对象**：
```java
// ScoreRecordSaveReqVO.java
public class ScoreRecordSaveReqVO {
    @ApiModelProperty(value = "罪犯ID", required = true)
    @NotNull(message = "罪犯ID不能为空")
    private Long prisonerId;

    @ApiModelProperty(value = "考核日期", required = true, example = "2026-01-14")
    @NotNull(message = "考核日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date recordDate;

    @ApiModelProperty(value = "考核规则ID", required = true)
    @NotNull(message = "考核规则ID不能为空")
    private Long subjectId;

    @ApiModelProperty(value = "得分", required = true, example = "2.00")
    @NotNull(message = "得分不能为空")
    private BigDecimal score;

    @ApiModelProperty(value = "备注说明")
    private String remark;
}

// ScoreRecordBatchCreateReqVO.java
public class ScoreRecordBatchCreateReqVO {
    @ApiModelProperty(value = "考核日期", required = true)
    @NotNull(message = "考核日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date recordDate;

    @ApiModelProperty(value = "罪犯ID列表", required = true)
    @NotEmpty(message = "罪犯ID列表不能为空")
    private List<Long> prisonerIds;

    @ApiModelProperty(value = "考核规则ID", required = true)
    @NotNull(message = "考核规则ID不能为空")
    private Long subjectId;

    @ApiModelProperty(value = "得分", required = true)
    @NotNull(message = "得分不能为空")
    private BigDecimal score;

    @ApiModelProperty(value = "备注说明")
    private String remark;
}

// ScoreRecordRespVO.java
public class ScoreRecordRespVO {
    private Long id;
    private Long prisonerId;
    private String prisonerNo;
    private String prisonerName;
    private Long prisonAreaId;
    private String prisonAreaName;
    private Date recordDate;
    private Long subjectId;
    private String subjectName;
    private Integer category;
    private String categoryName;
    private BigDecimal score;
    private BigDecimal actualScore;
    private String remark;
    private Long recorderId;
    private String recorderName;
    private Date createTime;
}
```

### 3.3 月度考核汇总接口

**Controller路径**：`controller/admin/score/monthly/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| POST | `/prison/score/monthly/calculate` | prison:score:monthly:calculate | 手动触发月度汇总计算 |
| GET | `/prison/score/monthly/get-summary` | prison:score:monthly:query | 获取月度汇总详情 |
| GET | `/prison/score/monthly/page` | prison:score:monthly:query | 分页查询月度汇总 |
| POST | `/prison/score/monthly/submit-audit` | prison:score:monthly:audit | 提交审核 |
| POST | `/prison/score/monthly/audit` | prison:score:monthly:audit | 审核通过/驳回 |
| GET | `/prison/score/monthly/export-excel` | prison:score:monthly:export | 导出Excel |
| GET | `/prison/score/monthly/get-detail` | prison:score:monthly:query | 获取月度汇总明细 |

**业务逻辑**：
```java
/**
 * 月度汇总计算逻辑
 */
public void calculateMonthlySummary(Integer year, Integer month) {
    // 1. 获取所有罪犯列表
    List<Prisoner> prisoners = prisonerService.getActivePrisonerList();

    // 2. 遍历每个罪犯
    for (Prisoner prisoner : prisoners) {
        // 3. 获取该罪犯当月所有日常考核记录
        List<ScoreRecord> records = getMonthlyRecords(prisoner.getId(), year, month);

        // 4. 计算加分合计（考虑日限月限）
        BigDecimal rewardScore = calculateRewardScore(records);

        // 5. 计算扣分合计（考虑日限月限）
        BigDecimal penaltyScore = calculatePenaltyScore(records);

        // 6. 获取基础分配置
        BigDecimal baseScore = getBaseScoreConfig();

        // 7. 计算总分
        BigDecimal totalScore = baseScore.add(rewardScore).add(penaltyScore);

        // 8. 评定等级
        Integer level = assessLevel(totalScore);

        // 9. 保存或更新月度汇总记录
        saveOrUpdateMonthlySummary(prisoner, year, month, baseScore, rewardScore, penaltyScore, totalScore, level);
    }
}

/**
 * 计算加分（考虑日限月限）
 */
private BigDecimal calculateRewardScore(List<ScoreRecord> records) {
    // 按规则分组，计算每条规则的加分
    // 超过日限的按日限计算
    // 超过月限的按月限计算
    // 返回最终加分合计
}
```

### 3.4 考核等级规则接口

**Controller路径**：`controller/admin/score/level/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| PUT | `/prison/score/level/update` | prison:score:level:update | 更新等级规则 |
| GET | `/prison/score/level/get` | prison:score:level:query | 获取等级规则列表 |
| GET | `/prison/score/level/get-base-score` | prison:score:level:query | 获取基础分配置 |
| PUT | `/prison/score/level/update-base-score` | prison:score:level:update | 更新基础分配置 |

### 3.5 考核公示公告接口

**Controller路径**：`controller/admin/score/notice/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| POST | `/prison/score/notice/create` | prison:score:notice:create | 创建公示 |
| PUT | `/prison/score/notice/update` | prison:score:notice:update | 更新公示 |
| PUT | `/prison/score/notice/publish` | prison:score:notice:publish | 发布公示 |
| PUT | `/prison/score/notice/withdraw` | prison:score:notice:publish | 撤回公示 |
| DELETE | `/prison/score/notice/delete` | prison:score:notice:delete | 删除公示 |
| GET | `/prison/score/notice/get` | prison:score:notice:query | 获取详情 |
| GET | `/prison/score/notice/page` | prison:score:notice:query | 分页查询 |

### 3.6 减刑假释数据提取接口

**Controller路径**：`controller/admin/score/parole/`

| 方法 | 端点 | 权限 | 说明 |
|-----|-----|-----|------|
| GET | `/prison/score/parole/get-data` | prison:score:parole:query | 获取减刑假释考核数据 |
| POST | `/prison/score/parole/generate-suggestion` | prison:score:parole:query | 生成减刑假释建议 |

**返回数据结构**：
```java
public class ScoreParoleDataVO {
    private Long prisonerId;
    private String prisonerNo;
    private String prisonerName;

    // 近6个月月度考核数据
    private List<MonthlyScoreVO> monthlyScores;

    // 年度累计考核分
    private BigDecimal yearlyTotalScore;

    // 表扬次数
    private Integer praiseCount;

    // 警告次数
    private Integer warningCount;

    // 等级评定记录
    private List<LevelRecordVO> levelRecords;

    // 减刑假释建议
    private ParoleSuggestionVO suggestion;
}
```

---

## 四、批量SQL脚本

```sql
-- ==================== 计分考核模块 DDL ====================

-- 1. 考核规则科目表
CREATE TABLE `prison_score_subject` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '规则ID',
    `code` varchar(50) NOT NULL COMMENT '规则编码',
    `name` varchar(100) NOT NULL COMMENT '规则名称',
    `category` tinyint NOT NULL COMMENT '考核类别',
    `score` decimal(10,2) NOT NULL COMMENT '分值',
    `daily_limit` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '日最高分限制',
    `monthly_limit` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '月最高分限制',
    `description` varchar(500) DEFAULT NULL COMMENT '规则说明',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态',
    `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_code` (`code`),
    KEY `idx_category` (`category`),
    KEY `idx_status` (`status`)
) ENGINE=InnoDB COMMENT='考核规则科目表';

-- 2. 日常考核记录表
CREATE TABLE `prison_score_record` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
    `prisoner_id` bigint NOT NULL COMMENT '罪犯ID',
    `prisoner_no` varchar(50) NOT NULL COMMENT '罪犯编号',
    `record_date` date NOT NULL COMMENT '考核日期',
    `subject_id` bigint NOT NULL COMMENT '考核规则ID',
    `subject_name` varchar(100) NOT NULL COMMENT '规则名称',
    `category` tinyint NOT NULL COMMENT '考核类别',
    `score` decimal(10,2) NOT NULL COMMENT '得分',
    `actual_score` decimal(10,2) NOT NULL COMMENT '实际得分',
    `remark` varchar(500) DEFAULT NULL COMMENT '备注说明',
    `recorder_id` bigint NOT NULL COMMENT '记录人ID',
    `recorder_name` varchar(50) NOT NULL COMMENT '记录人姓名',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_prisoner_date` (`prisoner_no`, `record_date`),
    KEY `idx_record_date` (`record_date`),
    KEY `idx_subject` (`subject_id`)
) ENGINE=InnoDB COMMENT='日常考核记录表';

-- 3. 考核等级评定规则表
CREATE TABLE `prison_score_level_rule` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '规则ID',
    `level` tinyint NOT NULL COMMENT '等级',
    `level_name` varchar(20) NOT NULL COMMENT '等级名称',
    `min_score` decimal(10,2) NOT NULL COMMENT '最低分',
    `max_score` decimal(10,2) NOT NULL COMMENT '最高分',
    `description` varchar(500) DEFAULT NULL COMMENT '说明',
    `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_level` (`level`),
    KEY `idx_min_score` (`min_score`)
) ENGINE=InnoDB COMMENT='考核等级评定规则表';

-- 4. 考核公示公告表
CREATE TABLE `prison_score_notice` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '公告ID',
    `title` varchar(200) NOT NULL COMMENT '公告标题',
    `notice_type` tinyint NOT NULL DEFAULT 1 COMMENT '公示类型',
    `start_date` date NOT NULL COMMENT '公示开始日期',
    `end_date` date NOT NULL COMMENT '公示结束日期',
    `scope_type` tinyint NOT NULL DEFAULT 1 COMMENT '公示范围',
    `scope_prison_area_ids` varchar(500) DEFAULT NULL COMMENT '指定监区ID列表',
    `content` text COMMENT '公示内容',
    `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态',
    `publisher_id` bigint DEFAULT NULL COMMENT '发布人ID',
    `publisher_name` varchar(50) DEFAULT NULL COMMENT '发布人姓名',
    `publish_time` datetime DEFAULT NULL COMMENT '发布时间',
    `creator` varchar(64) DEFAULT '' COMMENT '创建者',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater` varchar(64) DEFAULT '' COMMENT '更新者',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
    `tenant_id` bigint DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_status` (`status`),
    KEY `idx_publish_time` (`publish_time`)
) ENGINE=InnoDB COMMENT='考核公示公告表';

-- 5. 初始化等级规则数据
INSERT INTO `prison_score_level_rule` (`level`, `level_name`, `min_score`, `max_score`, `description`, `sort`, `status`) VALUES
(1, '优秀', 120.00, 9999.99, '表现突出', 1, 1),
(2, '良好', 100.00, 119.99, '表现良好', 2, 1),
(3, '合格', 80.00, 99.99, '表现一般', 3, 1),
(4, '不合格', 0.00, 79.99, '表现较差', 4, 1);

-- 6. 初始化示例规则数据
INSERT INTO `prison_score_subject` (`code`, `name`, `category`, `score`, `daily_limit`, `monthly_limit`, `description`, `status`, `sort`) VALUES
('LABOR001', '超额完成生产任务', 1, 2.00, 5.00, 30.00, '超额完成生产任务', 1, 1),
('LABOR002', '完成生产任务', 1, 1.00, 3.00, 20.00, '完成生产任务', 1, 2),
('EDU001', '参加义务劳动', 2, 1.00, 2.00, 10.00, '参加义务劳动', 1, 1),
('EDU002', '考试合格', 2, 1.00, 3.00, 15.00, '考试合格', 1, 2),
('DAILY001', '获得表扬', 3, 2.00, 5.00, 20.00, '获得表扬', 1, 1),
('DAILY002', '主动报告隐患', 3, 1.00, 2.00, 10.00, '主动报告隐患', 1, 2),
('HYGIENE001', '内务不整洁', 4, -0.50, -3.00, -10.00, '内务不整洁', 1, 1),
('HYGIENE002', '违规吸烟', 4, -2.00, -5.00, -20.00, '违规吸烟', 1, 2),
('PENALTY001', '打架斗殴', 6, -5.00, -10.00, -30.00, '打架斗殴', 1, 1),
('PENALTY002', '私藏违禁品', 6, -10.00, -20.00, -50.00, '私藏违禁品', 1, 2);
```

---

## 五、目录结构

```
backend/yudao-module-prison/src/main/java/cn/iocoder/yudao/module/prison/
├── controller/admin/score/
│   ├── subject/                           # 考核规则科目
│   │   ├── PrisonScoreSubjectController.java
│   │   └── vo/
│   │       ├── ScoreSubjectPageReqVO.java
│   │       ├── ScoreSubjectSaveReqVO.java
│   │       └── ScoreSubjectRespVO.java
│   ├── record/                            # 日常考核记录
│   │   ├── PrisonScoreRecordController.java
│   │   └── vo/
│   │       ├── ScoreRecordPageReqVO.java
│   │       ├── ScoreRecordSaveReqVO.java
│   │       ├── ScoreRecordBatchCreateReqVO.java
│   │       └── ScoreRecordRespVO.java
│   ├── monthly/                           # 月度汇总
│   │   ├── PrisonScoreMonthlyController.java
│   │   └── vo/
│   │       ├── ScoreMonthlyPageReqVO.java
│   │       ├── ScoreMonthlyRespVO.java
│   │       └── ScoreMonthlyDetailRespVO.java
│   ├── level/                             # 等级规则
│   │   ├── PrisonScoreLevelController.java
│   │   └── vo/
│   │       └── ScoreLevelRespVO.java
│   ├── notice/                            # 公示公告
│   │   ├── PrisonScoreNoticeController.java
│   │   └── vo/
│   │       ├── ScoreNoticePageReqVO.java
│   │       ├── ScoreNoticeSaveReqVO.java
│   │       └── ScoreNoticeRespVO.java
│   └── parole/                            # 减刑假释
│       ├── PrisonScoreParoleController.java
│       └── vo/
│           └── ScoreParoleDataRespVO.java
│
├── service/score/
│   ├── ScoreSubjectService.java
│   ├── impl/ScoreSubjectServiceImpl.java
│   ├── ScoreRecordService.java
│   ├── impl/ScoreRecordServiceImpl.java
│   ├── ScoreMonthlyService.java
│   ├── impl/ScoreMonthlyServiceImpl.java
│   ├── ScoreLevelService.java
│   ├── impl/ScoreLevelServiceImpl.java
│   ├── ScoreNoticeService.java
│   ├── impl/ScoreNoticeServiceImpl.java
│   └── ScoreParoleService.java
│   └── impl/ScoreParoleServiceImpl.java
│
├── dal/dataobject/score/
│   ├── ScoreSubjectDO.java
│   ├── ScoreRecordDO.java
│   ├── ScoreLevelRuleDO.java
│   ├── ScoreNoticeDO.java
│   └── ScoreDO.java                       # 已有
│
└── dal/mysql/score/
    ├── ScoreSubjectMapper.java
    ├── ScoreRecordMapper.java
    ├── ScoreLevelRuleMapper.java
    ├── ScoreNoticeMapper.java
    └── ScoreMapper.java                    # 已有
```

---

## 六、验收标准

- [ ] 创建考核规则科目表并实现CRUD接口
- [ ] 创建日常考核记录表并实现CRUD接口（含批量录入）
- [ ] 创建考核等级规则表并实现配置接口
- [ ] 创建考核公示公告表并实现发布功能
- [ ] 实现月度汇总自动计算逻辑
- [ ] 实现日/月最高分限制校验
- [ ] 实现减刑假释数据提取接口
- [ ] 所有接口通过单元测试
