tangweijie 76bdb3a931 feat: 新增AI监控仪表盘功能和监管对象位置字段
- 新增AI监控仪表盘相关接口(监狱概况统计、重点人员查询)
- 新增监管对象位置字段(province/city/district)到各DO实体
- 新增重点人员页面相关VO(FocusPersonPageReqVO、FocusPersonVO)
- 新增AI监控入口菜单SQL脚本
- 新增监管对象位置升级SQL脚本
- 完善监控仪表盘服务实现(实时数据、统计分析、风险预警)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-21 00:17:53 +08:00

604 lines
41 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =====================================================
-- XL监狱综合管理平台 - 监狱模块数据库脚本
-- 生成时间: 2026-01-12
-- =====================================================
-- 注意: 执行前请确保已经创建了 prison 模块的基础表 prison_prisoner
-- 此脚本包含 8 个子模块的表结构和菜单权限
-- =====================================================
-- 1. 监区信息表 (prison_area)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_area` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '监区ID',
`name` varchar(100) NOT NULL COMMENT '监区名称',
`code` varchar(50) NOT NULL COMMENT '监区编码',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '监区类型1-普通监区 2-严管监区 3-医院 4-禁闭室',
`capacity` int NOT NULL DEFAULT 0 COMMENT '容纳人数',
`current_count` int NOT NULL DEFAULT 0 COMMENT '当前人数',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态1-启用 2-禁用',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_code` (`code`),
KEY `idx_prison_area_code` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 2. 监室信息表 (prison_cell)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_cell` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`area_id` bigint NOT NULL COMMENT 'ID',
`name` varchar(100) NOT NULL COMMENT '',
`code` varchar(50) NOT NULL COMMENT '',
`capacity` int NOT NULL DEFAULT 0 COMMENT '',
`current_count` int NOT NULL DEFAULT 0 COMMENT '',
`sort` int NOT NULL DEFAULT 0 COMMENT '',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2-',
`remark` varchar(500) DEFAULT NULL COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_code` (`code`),
KEY `idx_prison_cell_area_id` (`area_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='监室信息表';
-- =====================================================
-- 3. 消费订单表 (prison_consumption)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_consumption` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '消费ID',
`prisoner_id` bigint NOT NULL COMMENT '罪犯ID',
`prisoner_no` varchar(50) NOT NULL COMMENT '罪犯编号',
`order_no` varchar(64) DEFAULT NULL COMMENT '订单号',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '类型1-购物 2-餐饮 3-医疗 4-通讯 5-其他',
`total_amount` decimal(10,2) NOT NULL COMMENT '订单总金额',
`balance` decimal(10,2) NOT NULL COMMENT '账户余额(消费后)',
`trade_time` datetime NOT NULL COMMENT '交易时间',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态1-成功 2-失败',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_consumption_prisoner_id` (`prisoner_id`),
KEY `idx_prison_consumption_prisoner_no` (`prisoner_no`),
KEY `idx_prison_consumption_order_no` (`order_no`),
KEY `idx_prison_consumption_trade_time` (`trade_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 3.1 消费明细表 (prison_consumption_detail)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_consumption_detail` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`consumption_id` bigint NOT NULL COMMENT 'ID',
`prisoner_id` bigint NOT NULL COMMENT 'ID便',
`goods_name` varchar(100) NOT NULL COMMENT '',
`goods_code` varchar(50) DEFAULT NULL COMMENT '',
`goods_price` decimal(10,2) NOT NULL COMMENT '',
`goods_count` int NOT NULL COMMENT '',
`subtotal` decimal(10,2) NOT NULL COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_consumption_detail_consumption_id` (`consumption_id`),
KEY `idx_consumption_detail_prisoner_id` (`prisoner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='消费明细表';
-- =====================================================
-- 4. 问卷模板表 (prison_questionnaire)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_questionnaire` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '问卷ID',
`title` varchar(200) NOT NULL COMMENT '问卷标题',
`description` varchar(500) DEFAULT NULL COMMENT '问卷描述',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '问卷类型1-心理测评 2-风险评估 3-日常调查',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态1-草稿 2-已发布 3-已停用',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_questionnaire_status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 5. 问卷问题表 (prison_question)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_question` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`questionnaire_id` bigint NOT NULL COMMENT 'ID',
`title` varchar(500) NOT NULL COMMENT '',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4-',
`options` text COMMENT 'JSON格式[{ "label": "选项1", "value": "1" }]',
`score` int DEFAULT 0 COMMENT '',
`sort` int NOT NULL DEFAULT 0 COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_prison_question_questionnaire_id` (`questionnaire_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='问卷问题表';
-- =====================================================
-- 6. 问卷答题记录表 (prison_questionnaire_record)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_questionnaire_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`questionnaire_id` bigint NOT NULL COMMENT '问卷ID',
`prisoner_id` bigint NOT NULL COMMENT '罪犯ID',
`prisoner_no` varchar(50) NOT NULL COMMENT '罪犯编号',
`answers` text NOT NULL COMMENT '答案JSON格式',
`score` int DEFAULT 0 COMMENT '得分',
`result` text COMMENT '评估结果',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态1-待评估 2-已完成',
`answer_time` datetime NOT NULL COMMENT '答题时间',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_questionnaire_record_questionnaire_id` (`questionnaire_id`),
KEY `idx_prison_questionnaire_record_prisoner_id` (`prisoner_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 7. 危险评估表 (prison_risk_assessment)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_risk_assessment` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`prisoner_id` bigint NOT NULL COMMENT 'ID',
`prisoner_no` varchar(50) NOT NULL COMMENT '',
`assessment_type` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3-',
`risk_level` tinyint NOT NULL COMMENT '1- 2- 3-',
`risk_score` int DEFAULT 0 COMMENT '',
`factors` text COMMENT 'JSON格式',
`measures` text COMMENT '',
`assessor_id` bigint DEFAULT NULL COMMENT 'ID',
`assessor_name` varchar(50) DEFAULT NULL COMMENT '',
`assessment_date` date NOT NULL COMMENT '',
`next_date` date DEFAULT NULL COMMENT '',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2-',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_prison_risk_assessment_prisoner_id` (`prisoner_id`),
KEY `idx_prison_risk_assessment_assessment_date` (`assessment_date`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='危险评估表';
-- =====================================================
-- 8. 计分考核表 (prison_score)
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_score` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`prisoner_id` bigint NOT NULL COMMENT '罪犯ID',
`prisoner_no` varchar(50) NOT NULL COMMENT '罪犯编号',
`year` int NOT NULL COMMENT '考核年份',
`month` int NOT NULL COMMENT '考核月份',
`base_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '基础分',
`reward_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '加分',
`penalty_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '扣分',
`total_score` decimal(10,2) NOT NULL COMMENT '总分',
`level` tinyint DEFAULT NULL COMMENT '考核等级1-优秀 2-良好 3-合格 4-不合格',
`assessor_id` bigint DEFAULT NULL COMMENT '考核人ID',
`assessor_name` varchar(50) DEFAULT NULL COMMENT '考核人姓名',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态1-待审核 2-已通过 3-已驳回',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`prison_area_id` bigint DEFAULT NULL COMMENT '监区ID',
`prison_cell_id` bigint DEFAULT NULL COMMENT '监室ID',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0 COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_prisoner_year_month` (`prisoner_no`, `year`, `month`),
KEY `idx_prison_score_prisoner_id` (`prisoner_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 菜单权限 SQL
-- 注意: 请将 ${table.parentMenuId} 替换为实际的父菜单ID
-- 监狱管理模块的父菜单ID通常为 5047 (系统管理) 或对应的监狱模块菜单ID
-- =====================================================
-- 获取监狱模块父菜单ID (假设为 5047请根据实际情况调整)
-- SELECT @parentId := 5047;
-- 1. 监区信息管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 1, 5047, 'area', '', 'prison/area/index', 0, 'Area');
SELECT @areaParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:area:query', 3, 1, @areaParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:area:create', 3, 2, @areaParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:area:update', 3, 3, @areaParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:area:delete', 3, 4, @areaParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:area:export', 3, 5, @areaParentId, '', '', '', 0);
-- 2. 监室信息管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 2, 5047, 'cell', '', 'prison/cell/index', 0, 'Cell');
SELECT @cellParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:cell:query', 3, 1, @cellParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:cell:create', 3, 2, @cellParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:cell:update', 3, 3, @cellParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:cell:delete', 3, 4, @cellParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:cell:export', 3, 5, @cellParentId, '', '', '', 0);
-- 3. 消费记录管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 3, 5047, 'consumption', '', 'prison/consumption/index', 0, 'Consumption');
SELECT @consumptionParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:consumption:query', 3, 1, @consumptionParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:consumption:create', 3, 2, @consumptionParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:consumption:update', 3, 3, @consumptionParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:consumption:delete', 3, 4, @consumptionParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:consumption:export', 3, 5, @consumptionParentId, '', '', '', 0);
-- 4. 问卷模板管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 4, 5047, 'questionnaire', '', 'prison/questionnaire/index', 0, 'Questionnaire');
SELECT @questionnaireParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire:query', 3, 1, @questionnaireParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire:create', 3, 2, @questionnaireParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire:update', 3, 3, @questionnaireParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire:delete', 3, 4, @questionnaireParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire:export', 3, 5, @questionnaireParentId, '', '', '', 0);
-- 5. 问卷问题管理菜单 (已移除独立页面,问题管理集成在问卷模板页面内)
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
-- VALUES ('', '', 2, 5, 5047, 'question', '', 'prison/question/index', 0, 'Question');
-- SELECT @questionParentId := LAST_INSERT_ID();
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
-- VALUES ('', 'prison:question:query', 3, 1, @questionParentId, '', '', '', 0);
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
-- VALUES ('', 'prison:question:create', 3, 2, @questionParentId, '', '', '', 0);
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
-- VALUES ('', 'prison:question:update', 3, 3, @questionParentId, '', '', '', 0);
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
-- VALUES ('', 'prison:question:delete', 3, 4, @questionParentId, '', '', '', 0);
-- INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
-- VALUES ('', 'prison:question:export', 3, 5, @questionParentId, '', '', '', 0);
-- 5. 问卷答题记录管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 5, 5047, 'questionnaire-record', '', 'prison/questionnairerecord/index', 0, 'QuestionnaireRecord');
SELECT @recordParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire-record:query', 3, 1, @recordParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire-record:create', 3, 2, @recordParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire-record:update', 3, 3, @recordParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire-record:delete', 3, 4, @recordParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:questionnaire-record:export', 3, 5, @recordParentId, '', '', '', 0);
-- 6. 危险评估管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 6, 5047, 'risk-assessment', '', 'prison/riskassessment/index', 0, 'RiskAssessment');
SELECT @riskParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:risk-assessment:query', 3, 1, @riskParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:risk-assessment:create', 3, 2, @riskParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:risk-assessment:update', 3, 3, @riskParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:risk-assessment:delete', 3, 4, @riskParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:risk-assessment:export', 3, 5, @riskParentId, '', '', '', 0);
-- 8. 计分考核管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 8, 5047, 'score', '', 'prison/score/index', 0, 'Score');
SELECT @scoreParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:score:query', 3, 1, @scoreParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:score:create', 3, 2, @scoreParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:score:update', 3, 3, @scoreParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:score:delete', 3, 4, @scoreParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:score:export', 3, 5, @scoreParentId, '', '', '', 0);
-- 9. 狱情收集管理菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status, component_name)
VALUES ('', '', 2, 9, 5047, 'situation', '', 'prison/situation/index', 0, 'Situation');
SELECT @situationParentId := LAST_INSERT_ID();
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:situation:query', 3, 1, @situationParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:situation:create', 3, 2, @situationParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:situation:update', 3, 3, @situationParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:situation:delete', 3, 4, @situationParentId, '', '', '', 0);
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'prison:situation:export', 3, 5, @situationParentId, '', '', '', 0);
-- =====================================================
-- 10. 数据结构迁移 SQL (2026-01-20)
-- =====================================================
-- 补充 prison_prisoner 表缺失字段
-- 执行此迁移前请备份数据库
ALTER TABLE `prison_prisoner`
ADD COLUMN IF NOT EXISTS `release_type` tinyint DEFAULT 0 COMMENT '0- 1- 2- 3- 4- 5- 6- 7- 8-',
ADD COLUMN IF NOT EXISTS `release_reason` varchar(500) DEFAULT NULL COMMENT '',
ADD COLUMN IF NOT EXISTS `photo` varchar(512) DEFAULT NULL COMMENT 'URL',
ADD COLUMN IF NOT EXISTS `sub_area_id` bigint DEFAULT NULL COMMENT 'ID',
ADD COLUMN IF NOT EXISTS `marital_status` tinyint DEFAULT NULL COMMENT '1- 2- 3- 4-',
ADD COLUMN IF NOT EXISTS `crime_type` varchar(100) DEFAULT NULL COMMENT '',
ADD COLUMN IF NOT EXISTS `sentence` varchar(100) DEFAULT NULL COMMENT '';
-- =====================================================
-- 10. 字典数据 SQL
-- =====================================================
-- 监室状态字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_cell_status', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_cell_status', 1, '', '1', 'success', '', 0, 'admin', NOW()),
('prison_cell_status', 2, '', '2', 'danger', '', 0, 'admin', NOW());
-- =====================================================
-- 11. 狱情收集表 (prison_situation) - 新增 2026-01-16
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_situation` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(200) NOT NULL COMMENT '',
`content` text COMMENT '',
`category` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4- 5- 6-',
`level` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3-',
`source` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4- 5-',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3-',
`area_id` bigint DEFAULT NULL COMMENT 'ID',
`cell_id` bigint DEFAULT NULL COMMENT 'ID',
`reporter` varchar(50) DEFAULT NULL COMMENT '',
`handler` varchar(50) DEFAULT NULL COMMENT '',
`handle_time` datetime DEFAULT NULL COMMENT '',
`handle_result` text COMMENT '',
`occur_time` datetime DEFAULT NULL COMMENT '',
`remark` varchar(500) DEFAULT NULL COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_situation_status` (`status`),
KEY `idx_prison_situation_category` (`category`),
KEY `idx_prison_situation_level` (`level`),
KEY `idx_prison_situation_area_id` (`area_id`),
KEY `idx_prison_situation_cell_id` (`cell_id`),
KEY `idx_prison_situation_occur_time` (`occur_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 12. 预警管理表 (prison_warning) - 新增 2026-01-16
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_warning` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(200) NOT NULL COMMENT '',
`content` text COMMENT '',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4- 5- 6-',
`level` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4-',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4-',
`source` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4- 5- 6-',
`situation_id` bigint DEFAULT NULL COMMENT 'ID',
`area_id` bigint DEFAULT NULL COMMENT 'ID',
`cell_id` bigint DEFAULT NULL COMMENT 'ID',
`alert_time` datetime DEFAULT NULL COMMENT '',
`verify_time` datetime DEFAULT NULL COMMENT '',
`verifier` varchar(50) DEFAULT NULL COMMENT '',
`verify_result` text COMMENT '',
`handle_time` datetime DEFAULT NULL COMMENT '',
`handler` varchar(50) DEFAULT NULL COMMENT '',
`handle_method` varchar(200) DEFAULT NULL COMMENT '',
`handle_result` text COMMENT '',
`release_time` datetime DEFAULT NULL COMMENT '',
`releaser` varchar(50) DEFAULT NULL COMMENT '',
`release_reason` text COMMENT '',
`occur_time` datetime DEFAULT NULL COMMENT '',
`remark` varchar(500) DEFAULT NULL COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_warning_status` (`status`),
KEY `idx_prison_warning_level` (`level`),
KEY `idx_prison_warning_type` (`type`),
KEY `idx_prison_warning_situation_id` (`situation_id`),
KEY `idx_prison_warning_area_id` (`area_id`),
KEY `idx_prison_warning_cell_id` (`cell_id`),
KEY `idx_prison_warning_alert_time` (`alert_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 13. 风险评估表 (prison_risk) - 新增 2026-01-16
-- =====================================================
CREATE TABLE IF NOT EXISTS `prison_risk` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`prisoner_id` bigint NOT NULL COMMENT 'ID',
`prisoner_no` varchar(50) NOT NULL COMMENT '',
`prisoner_name` varchar(50) DEFAULT NULL COMMENT '',
`assessment_type` tinyint NOT NULL DEFAULT 1 COMMENT '1- 2- 3- 4-',
`assessment_date` date NOT NULL COMMENT '',
`overall_score` decimal(5,2) DEFAULT NULL COMMENT '',
`risk_level` tinyint DEFAULT NULL COMMENT '1- 2- 3- 4-',
`mental_state` varchar(500) DEFAULT NULL COMMENT '',
`escape_risk` varchar(500) DEFAULT NULL COMMENT '',
`violence_risk` varchar(500) DEFAULT NULL COMMENT '',
`revolt_risk` varchar(500) DEFAULT NULL COMMENT '',
`self_harm_risk` varchar(500) DEFAULT NULL COMMENT '',
`recommendation` text COMMENT '',
`assessor` varchar(50) DEFAULT NULL COMMENT '',
`assess_method` tinyint DEFAULT NULL COMMENT '1- 2- 3-',
`item_scores` text COMMENT 'JSON',
`conclusion` text COMMENT '',
`remark` varchar(500) DEFAULT NULL COMMENT '',
`creator` varchar(64) DEFAULT '' COMMENT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`updater` varchar(64) DEFAULT '' COMMENT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '',
PRIMARY KEY (`id`),
KEY `idx_prison_risk_prisoner_id` (`prisoner_id`),
KEY `idx_prison_risk_prisoner_no` (`prisoner_no`),
KEY `idx_prison_risk_assessment_type` (`assessment_type`),
KEY `idx_prison_risk_assessment_date` (`assessment_date`),
KEY `idx_prison_risk_risk_level` (`risk_level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- =====================================================
-- 14. 字典数据 SQL (2026-01-16)
-- =====================================================
-- 狱情分类字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_situation_category', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_situation_category', 1, '', '1', 'danger', '', 0, 'admin', NOW()),
('prison_situation_category', 2, '', '2', 'warning', '', 0, 'admin', NOW()),
('prison_situation_category', 3, '', '3', 'success', '', 0, 'admin', NOW()),
('prison_situation_category', 4, '', '4', 'info', '', 0, 'admin', NOW()),
('prison_situation_category', 5, '', '5', 'danger', '', 0, 'admin', NOW()),
('prison_situation_category', 6, '', '6', '', '', 0, 'admin', NOW());
-- 狱情等级字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_situation_level', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_situation_level', 1, '', '1', 'success', '', 0, 'admin', NOW()),
('prison_situation_level', 2, '', '2', 'warning', '', 0, 'admin', NOW()),
('prison_situation_level', 3, '', '3', 'danger', '', 0, 'admin', NOW());
-- 狱情来源字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_situation_source', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_situation_source', 1, '', '1', '', '', 0, 'admin', NOW()),
('prison_situation_source', 2, '', '2', '', '', 0, 'admin', NOW()),
('prison_situation_source', 3, '', '3', '', '', 0, 'admin', NOW()),
('prison_situation_source', 4, '', '4', '', '', 0, 'admin', NOW()),
('prison_situation_source', 5, '', '5', '', '', 0, 'admin', NOW());
-- 狱情状态字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_situation_status', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_situation_status', 1, '', '1', 'warning', '', 0, 'admin', NOW()),
('prison_situation_status', 2, '', '2', 'info', '', 0, 'admin', NOW()),
('prison_situation_status', 3, '', '3', 'success', '', 0, 'admin', NOW());
-- 预警类型字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_warning_type', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_warning_type', 1, '', '1', 'danger', '', 0, 'admin', NOW()),
('prison_warning_type', 2, '', '2', 'warning', '', 0, 'admin', NOW()),
('prison_warning_type', 3, '', '3', 'info', '', 0, 'admin', NOW()),
('prison_warning_type', 4, '', '4', '', '', 0, 'admin', NOW()),
('prison_warning_type', 5, '', '5', 'success', '', 0, 'admin', NOW()),
('prison_warning_type', 6, '', '6', '', '', 0, 'admin', NOW());
-- 预警等级字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_warning_level', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_warning_level', 1, '', '1', 'success', '', 0, 'admin', NOW()),
('prison_warning_level', 2, '', '2', 'warning', '', 0, 'admin', NOW()),
('prison_warning_level', 3, '', '3', 'danger', '', 0, 'admin', NOW()),
('prison_warning_level', 4, '', '4', 'danger', '', 0, 'admin', NOW());
-- 预警状态字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_warning_status', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_warning_status', 1, '', '1', 'warning', '', 0, 'admin', NOW()),
('prison_warning_status', 2, '', '2', 'info', '', 0, 'admin', NOW()),
('prison_warning_status', 3, '', '3', 'success', '', 0, 'admin', NOW()),
('prison_warning_status', 4, '', '4', '', '', 0, 'admin', NOW());
-- 预警来源字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_warning_source', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_warning_source', 1, '', '1', '', '', 0, 'admin', NOW()),
('prison_warning_source', 2, '', '2', '', '', 0, 'admin', NOW()),
('prison_warning_source', 3, '', '3', '', '', 0, 'admin', NOW()),
('prison_warning_source', 4, '', '4', '', '', 0, 'admin', NOW()),
('prison_warning_source', 5, '', '5', '', '', 0, 'admin', NOW()),
('prison_warning_source', 6, '', '6', '', '', 0, 'admin', NOW());
-- 风险评估类型字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_risk_assessment_type', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_risk_assessment_type', 1, '', '1', 'info', '', 0, 'admin', NOW()),
('prison_risk_assessment_type', 2, '', '2', 'success', '', 0, 'admin', NOW()),
('prison_risk_assessment_type', 3, '', '3', 'warning', '', 0, 'admin', NOW()),
('prison_risk_assessment_type', 4, '', '4', '', '', 0, 'admin', NOW());
-- 风险等级字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_risk_level', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_risk_level', 1, '', '1', 'success', '', 0, 'admin', NOW()),
('prison_risk_level', 2, '', '2', 'warning', '', 0, 'admin', NOW()),
('prison_risk_level', 3, '', '3', 'danger', '', 0, 'admin', NOW()),
('prison_risk_level', 4, '', '4', 'danger', '', 0, 'admin', NOW());
-- 评估方式字典
INSERT INTO system_dict_type (name, type, status, creator, create_time) VALUES ('', 'prison_risk_assess_method', 0, 'admin', NOW());
INSERT INTO system_dict_data (dict_type, sort, label, value, color_type, css_class, status, creator, create_time) VALUES
('prison_risk_assess_method', 1, '', '1', '', '', 0, 'admin', NOW()),
('prison_risk_assess_method', 2, '', '2', '', '', 0, 'admin', NOW()),
('prison_risk_assess_method', 3, '', '3', '', '', 0, 'admin', NOW());