更新政府端和银行端

This commit is contained in:
2025-09-17 18:04:28 +08:00
parent f35ceef31f
commit e4287b83fe
185 changed files with 78320 additions and 189 deletions

View File

@@ -0,0 +1,66 @@
-- 1. 创建监管实体表
CREATE TABLE IF NOT EXISTS supervision_entities (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
type ENUM('farm', 'business', 'facility') NOT NULL,
address TEXT,
contact_person VARCHAR(50),
contact_phone VARCHAR(20),
status ENUM('active', 'inactive', 'suspended') DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_type (type),
INDEX idx_status (status)
);
-- 2. 创建检查记录表
CREATE TABLE IF NOT EXISTS inspections (
id INT AUTO_INCREMENT PRIMARY KEY,
entity_id INT NOT NULL,
inspector_id INT NOT NULL,
date DATE NOT NULL,
result ENUM('passed', 'failed', 'pending') DEFAULT 'pending',
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (entity_id) REFERENCES supervision_entities(id),
INDEX idx_entity (entity_id),
INDEX idx_date (date)
);
-- 3. 创建违规记录表
CREATE TABLE IF NOT EXISTS violations (
id INT AUTO_INCREMENT PRIMARY KEY,
entity_id INT NOT NULL,
inspection_id INT,
type VARCHAR(50) NOT NULL,
description TEXT,
status ENUM('reported', 'processed', 'resolved') DEFAULT 'reported',
penalty DECIMAL(10,2),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (entity_id) REFERENCES supervision_entities(id),
FOREIGN KEY (inspection_id) REFERENCES inspections(id),
INDEX idx_status (status)
);
-- 4. 创建审批流程表
CREATE TABLE IF NOT EXISTS approval_workflows (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
description TEXT,
steps JSON NOT NULL,
created_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
-- 5. 创建用户表
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'manager', 'inspector', 'clerk') NOT NULL,
status ENUM('active', 'inactive') DEFAULT 'active',
last_login TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

View File

@@ -0,0 +1,32 @@
-- 1. 插入测试用户 (密码都是123456的bcrypt哈希)
INSERT INTO users (username, password, role) VALUES
('admin', '$2a$10$xJwL5v5zP6zE5Jf7QYqZNuYQd9WkZf9XvLd1UcJm3VbK6sN8rLbW', 'admin'),
('inspector1', '$2a$10$xJwL5v5zP6zE5Jf7QYqZNuYQd9WkZf9XvLd1UcJm3VbK6sN8rLbW', 'inspector'),
('clerk1', '$2a$10$xJwL5v5zP6zE5Jf7QYqZNuYQd9WkZf9XvLd1UcJm3VbK6sN8rLbW', 'clerk');
-- 2. 插入监管实体
INSERT INTO supervision_entities (name, type, address, contact_person, contact_phone) VALUES
('宁夏第一农场', 'farm', '宁夏银川市兴庆区农场路1号', '张农场主', '13800138001'),
('银川商贸有限公司', 'business', '宁夏银川市金凤区商业街88号', '李经理', '13900139002'),
('银川市污水处理厂', 'facility', '宁夏银川市西夏区环保路5号', '王厂长', '13700137003'),
('贺兰山养殖基地', 'farm', '宁夏银川市贺兰县养殖区88号', '赵场长', '13500135004'),
('银川食品加工厂', 'business', '宁夏银川市永宁县工业区66号', '钱主管', '13600136005');
-- 3. 插入检查记录
INSERT INTO inspections (entity_id, inspector_id, date, result, notes) VALUES
(1, 2, '2025-09-10', 'passed', '防疫措施完善,卫生达标'),
(2, 2, '2025-09-12', 'failed', '消防设备不齐全,限期整改'),
(3, 2, '2025-09-15', 'pending', '例行检查,报告待提交'),
(4, 2, '2025-09-16', 'passed', '养殖环境良好,符合标准'),
(5, 2, '2025-09-17', 'failed', '卫生条件不达标,需整改');
-- 4. 插入违规记录
INSERT INTO violations (entity_id, inspection_id, type, description, status, penalty) VALUES
(2, 2, '消防安全', '灭火器数量不足,安全通道堵塞', 'reported', 5000.00),
(1, NULL, '环保违规', '废弃物处理不规范', 'processed', 3000.00),
(5, 5, '卫生违规', '操作间发现蟑螂,卫生条件差', 'reported', 8000.00);
-- 5. 插入审批流程
INSERT INTO approval_workflows (name, description, steps, created_by) VALUES
('企业注册审批', '新企业注册审批流程', '[{"name":"资料初审","role":"clerk"},{"name":"现场核查","role":"inspector"},{"name":"最终审批","role":"manager"}]', 1),
('违规处理审批', '违规处罚审批流程', '[{"name":"违规确认","role":"inspector"},{"name":"处罚方案","role":"manager"},{"name":"执行确认","role":"clerk"}]', 1);