完善保险端前后端和养殖端小程序

This commit is contained in:
xuqiuyun
2025-09-22 19:09:45 +08:00
parent 02a25515a9
commit 325c114c38
256 changed files with 48348 additions and 4444 deletions

View File

@@ -0,0 +1,177 @@
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

@@ -0,0 +1,181 @@
/**
* 创建监管任务表的迁移文件
*/
'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

@@ -0,0 +1,190 @@
/**
* 创建待安装任务表的迁移文件
*/
'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');
}
};