继续完善保险项目和养殖端小程序

This commit is contained in:
xuqiuyun
2025-09-29 18:35:03 +08:00
parent 4af8368097
commit 4e8d4dc92d
192 changed files with 4886 additions and 35384 deletions

View File

@@ -1,177 +0,0 @@
const { DataTypes } = require('sequelize');
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('supervision_tasks', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '监管任务ID'
},
applicationId: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '申请单号',
field: 'application_id'
},
policyId: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '保单编号',
field: 'policy_id'
},
productName: {
type: DataTypes.STRING(100),
allowNull: false,
comment: '产品名称',
field: 'product_name'
},
insurancePeriod: {
type: DataTypes.STRING(100),
allowNull: false,
comment: '保险期间',
field: 'insurance_period'
},
customerName: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '客户姓名',
field: 'customer_name'
},
documentType: {
type: DataTypes.STRING(20),
allowNull: false,
comment: '证件类型',
field: 'document_type'
},
documentNumber: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '证件号码',
field: 'document_number'
},
applicableAmount: {
type: DataTypes.DECIMAL(15, 2),
allowNull: false,
comment: '适用金额',
field: 'applicable_amount'
},
supervisionDataCount: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '监管生成数量',
field: 'supervision_data_count'
},
status: {
type: DataTypes.ENUM('pending', 'processing', 'completed', 'rejected'),
defaultValue: 'pending',
comment: '状态: pending-待处理, processing-处理中, completed-已完成, rejected-已拒绝'
},
taskType: {
type: DataTypes.ENUM('new_application', 'task_guidance', 'batch_operation'),
allowNull: false,
comment: '任务类型: new_application-新增监管任务, task_guidance-任务导入, batch_operation-批量新增',
field: 'task_type'
},
assignedTo: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '分配给用户ID',
field: 'assigned_to',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
priority: {
type: DataTypes.ENUM('low', 'medium', 'high', 'urgent'),
defaultValue: 'medium',
comment: '优先级'
},
dueDate: {
type: DataTypes.DATE,
allowNull: true,
comment: '截止日期',
field: 'due_date'
},
completedAt: {
type: DataTypes.DATE,
allowNull: true,
comment: '完成时间',
field: 'completed_at'
},
remarks: {
type: DataTypes.TEXT,
allowNull: true,
comment: '备注'
},
createdBy: {
type: DataTypes.INTEGER,
allowNull: false,
comment: '创建人ID',
field: 'created_by',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'RESTRICT'
},
updatedBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '更新人ID',
field: 'updated_by',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: Sequelize.NOW,
field: 'created_at'
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: Sequelize.NOW,
field: 'updated_at'
}
}, {
comment: '监管任务表',
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci'
});
// 添加索引
await queryInterface.addIndex('supervision_tasks', ['application_id']);
await queryInterface.addIndex('supervision_tasks', ['policy_id']);
await queryInterface.addIndex('supervision_tasks', ['customer_name']);
await queryInterface.addIndex('supervision_tasks', ['status']);
await queryInterface.addIndex('supervision_tasks', ['task_type']);
await queryInterface.addIndex('supervision_tasks', ['assigned_to']);
await queryInterface.addIndex('supervision_tasks', ['created_by']);
await queryInterface.addIndex('supervision_tasks', ['created_at']);
// 添加唯一索引
await queryInterface.addIndex('supervision_tasks', ['application_id'], {
unique: true,
name: 'unique_application_id'
});
await queryInterface.addIndex('supervision_tasks', ['policy_id'], {
unique: true,
name: 'unique_policy_id'
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('supervision_tasks');
}
};

View File

@@ -1,16 +0,0 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('users', 'fixed_token', {
type: Sequelize.STRING(255),
allowNull: true,
unique: true,
comment: '用户固定token用于API访问验证'
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('users', 'fixed_token');
}
};

View File

@@ -1,146 +0,0 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('operation_logs', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
user_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
operation_type: {
type: Sequelize.ENUM(
'login', // 登录
'logout', // 登出
'create', // 创建
'update', // 更新
'delete', // 删除
'view', // 查看
'export', // 导出
'import', // 导入
'approve', // 审批
'reject', // 拒绝
'system_config', // 系统配置
'user_manage', // 用户管理
'role_manage', // 角色管理
'other' // 其他
),
allowNull: false,
comment: '操作类型'
},
operation_module: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '操作模块(如:用户管理、设备管理、预警管理等)'
},
operation_content: {
type: Sequelize.TEXT,
allowNull: false,
comment: '操作内容描述'
},
operation_target: {
type: Sequelize.STRING(100),
allowNull: true,
comment: '操作目标用户ID、设备ID等'
},
request_method: {
type: Sequelize.ENUM('GET', 'POST', 'PUT', 'DELETE', 'PATCH'),
allowNull: true,
comment: 'HTTP请求方法'
},
request_url: {
type: Sequelize.STRING(500),
allowNull: true,
comment: '请求URL'
},
request_params: {
type: Sequelize.TEXT,
allowNull: true,
comment: '请求参数JSON格式'
},
response_status: {
type: Sequelize.INTEGER,
allowNull: true,
comment: '响应状态码'
},
ip_address: {
type: Sequelize.STRING(45),
allowNull: true,
comment: 'IP地址支持IPv6'
},
user_agent: {
type: Sequelize.TEXT,
allowNull: true,
comment: '用户代理信息'
},
execution_time: {
type: Sequelize.INTEGER,
allowNull: true,
comment: '执行时间(毫秒)'
},
status: {
type: Sequelize.ENUM('success', 'failed', 'error'),
defaultValue: 'success',
comment: '操作状态'
},
error_message: {
type: Sequelize.TEXT,
allowNull: true,
comment: '错误信息'
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
}, {
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
comment: '系统操作日志表'
});
// 创建索引
await queryInterface.addIndex('operation_logs', ['user_id'], {
name: 'idx_operation_logs_user_id'
});
await queryInterface.addIndex('operation_logs', ['operation_type'], {
name: 'idx_operation_logs_operation_type'
});
await queryInterface.addIndex('operation_logs', ['operation_module'], {
name: 'idx_operation_logs_operation_module'
});
await queryInterface.addIndex('operation_logs', ['created_at'], {
name: 'idx_operation_logs_created_at'
});
await queryInterface.addIndex('operation_logs', ['status'], {
name: 'idx_operation_logs_status'
});
await queryInterface.addIndex('operation_logs', ['ip_address'], {
name: 'idx_operation_logs_ip_address'
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('operation_logs');
}
};

View File

@@ -1,181 +0,0 @@
/**
* 创建监管任务表的迁移文件
*/
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('supervisory_tasks', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID'
},
applicationNumber: {
type: Sequelize.STRING(50),
allowNull: false,
unique: true,
field: 'application_number',
comment: '申请单号'
},
policyNumber: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'policy_number',
comment: '保单编号'
},
productName: {
type: Sequelize.STRING(100),
allowNull: false,
field: 'product_name',
comment: '产品名称'
},
insurancePeriod: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'insurance_period',
comment: '保险周期'
},
customerName: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'customer_name',
comment: '客户姓名'
},
idType: {
type: Sequelize.ENUM('身份证', '护照', '军官证', '士兵证', '港澳台居民居住证', '其他'),
allowNull: false,
defaultValue: '身份证',
field: 'id_type',
comment: '证件类型'
},
idNumber: {
type: Sequelize.STRING(30),
allowNull: false,
field: 'id_number',
comment: '证件号码'
},
applicableSupplies: {
type: Sequelize.TEXT,
allowNull: true,
field: 'applicable_supplies',
comment: '适用生资JSON格式存储'
},
supervisorySuppliesQuantity: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
field: 'supervisory_supplies_quantity',
comment: '监管生资数量'
},
taskStatus: {
type: Sequelize.ENUM('待处理', '处理中', '已完成', '已取消'),
allowNull: false,
defaultValue: '待处理',
field: 'task_status',
comment: '任务状态'
},
priority: {
type: Sequelize.ENUM('低', '中', '高', '紧急'),
allowNull: false,
defaultValue: '中',
comment: '任务优先级'
},
assignedTo: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'assigned_to',
comment: '分配给用户ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
dueDate: {
type: Sequelize.DATE,
allowNull: true,
field: 'due_date',
comment: '截止日期'
},
completedAt: {
type: Sequelize.DATE,
allowNull: true,
field: 'completed_at',
comment: '完成时间'
},
notes: {
type: Sequelize.TEXT,
allowNull: true,
comment: '备注信息'
},
createdBy: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'created_by',
comment: '创建人ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
updatedBy: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'updated_by',
comment: '更新人ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
field: 'created_at',
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
field: 'updated_at',
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
}, {
comment: '监管任务表'
});
// 创建索引
await queryInterface.addIndex('supervisory_tasks', ['application_number'], {
name: 'idx_application_number'
});
await queryInterface.addIndex('supervisory_tasks', ['policy_number'], {
name: 'idx_policy_number'
});
await queryInterface.addIndex('supervisory_tasks', ['customer_name'], {
name: 'idx_customer_name'
});
await queryInterface.addIndex('supervisory_tasks', ['task_status'], {
name: 'idx_task_status'
});
await queryInterface.addIndex('supervisory_tasks', ['created_at'], {
name: 'idx_created_at'
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('supervisory_tasks');
}
};

View File

@@ -1,190 +0,0 @@
/**
* 创建待安装任务表的迁移文件
*/
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('installation_tasks', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID'
},
applicationNumber: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'application_number',
comment: '申请单号'
},
policyNumber: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'policy_number',
comment: '保单编号'
},
productName: {
type: Sequelize.STRING(100),
allowNull: false,
field: 'product_name',
comment: '产品名称'
},
customerName: {
type: Sequelize.STRING(50),
allowNull: false,
field: 'customer_name',
comment: '客户姓名'
},
idType: {
type: Sequelize.ENUM('身份证', '护照', '军官证', '士兵证', '港澳台居民居住证', '其他'),
allowNull: false,
defaultValue: '身份证',
field: 'id_type',
comment: '证件类型'
},
idNumber: {
type: Sequelize.STRING(30),
allowNull: false,
field: 'id_number',
comment: '证件号码'
},
livestockSupplyType: {
type: Sequelize.STRING(100),
allowNull: false,
field: 'livestock_supply_type',
comment: '养殖生资种类'
},
pendingDevices: {
type: Sequelize.TEXT,
allowNull: true,
field: 'pending_devices',
comment: '待安装设备JSON格式存储'
},
installationStatus: {
type: Sequelize.ENUM('待安装', '安装中', '已安装', '安装失败', '已取消'),
allowNull: false,
defaultValue: '待安装',
field: 'installation_status',
comment: '安装状态'
},
taskGeneratedTime: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
field: 'task_generated_time',
comment: '生成安装任务时间'
},
installationCompletedTime: {
type: Sequelize.DATE,
allowNull: true,
field: 'installation_completed_time',
comment: '安装完成生效时间'
},
priority: {
type: Sequelize.ENUM('低', '中', '高', '紧急'),
allowNull: false,
defaultValue: '中',
comment: '安装优先级'
},
assignedTechnician: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'assigned_technician',
comment: '分配的技术员ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
installationAddress: {
type: Sequelize.TEXT,
allowNull: true,
field: 'installation_address',
comment: '安装地址'
},
contactPhone: {
type: Sequelize.STRING(20),
allowNull: true,
field: 'contact_phone',
comment: '联系电话'
},
remarks: {
type: Sequelize.TEXT,
allowNull: true,
comment: '备注信息'
},
createdBy: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'created_by',
comment: '创建人ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
updatedBy: {
type: Sequelize.INTEGER,
allowNull: true,
field: 'updated_by',
comment: '更新人ID',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
field: 'created_at',
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
field: 'updated_at',
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
}, {
comment: '待安装任务表'
});
// 创建索引
await queryInterface.addIndex('installation_tasks', ['application_number'], {
name: 'idx_application_number'
});
await queryInterface.addIndex('installation_tasks', ['policy_number'], {
name: 'idx_policy_number'
});
await queryInterface.addIndex('installation_tasks', ['customer_name'], {
name: 'idx_customer_name'
});
await queryInterface.addIndex('installation_tasks', ['installation_status'], {
name: 'idx_installation_status'
});
await queryInterface.addIndex('installation_tasks', ['task_generated_time'], {
name: 'idx_task_generated_time'
});
await queryInterface.addIndex('installation_tasks', ['installation_completed_time'], {
name: 'idx_installation_completed_time'
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('installation_tasks');
}
};