Compare commits
10 Commits
1595605817
...
dev_1
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d1ab61705 | |||
| 1b5d1178f6 | |||
| 112463fcd3 | |||
| a46ffdb7db | |||
| 29b541730b | |||
| aaa6256735 | |||
| 9e3609b8ad | |||
| 9776d76d1a | |||
| af7ec6f43d | |||
| 497e040c81 |
195
doc/api-docs/api/员工亲属关系导入API文档.md
Normal file
195
doc/api-docs/api/员工亲属关系导入API文档.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# 员工亲属关系导入 API 文档
|
||||
|
||||
## 概述
|
||||
|
||||
员工亲属关系导入模块提供员工亲属关系的批量导入功能。
|
||||
|
||||
**基础路径**: `/ccdi/staffFmyRelation`
|
||||
|
||||
**权限标识前缀**: `ccdi:staffFmyRelation`
|
||||
|
||||
**数据表**: `ccdi_cust_fmy_relation`
|
||||
|
||||
**关联表**:
|
||||
- `ccdi_base_staff` - 员工基础信息表(通过id_card关联)
|
||||
|
||||
---
|
||||
|
||||
## API 接口
|
||||
|
||||
### 1. 异步导入员工亲属关系
|
||||
|
||||
**接口地址**: `POST /ccdi/staffFmyRelation/importData`
|
||||
|
||||
**权限要求**: `ccdi:staffFmyRelation:import`
|
||||
|
||||
**请求参数**: FormData
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| file | File | 是 | Excel文件 |
|
||||
| updateSupport | Boolean | 否 | 是否更新已存在的记录(默认false) |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "导入任务已提交,正在后台处理",
|
||||
"data": {
|
||||
"taskId": "abc123-def456-ghi789",
|
||||
"status": "PROCESSING",
|
||||
"message": "导入任务已提交,正在后台处理"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**导入流程**:
|
||||
1. 上传Excel文件
|
||||
2. 后台立即返回taskId
|
||||
3. 使用taskId轮询查询导入状态
|
||||
4. 导入完成后查看失败记录(如有)
|
||||
|
||||
**导入验证规则**:
|
||||
|
||||
导入时会验证以下字段:
|
||||
|
||||
| 字段名 | 验证规则 | 错误提示 |
|
||||
|--------|---------|---------|
|
||||
| 员工身份证号 | 必须在员工信息表(ccdi_base_staff)中存在 | "第N行: 身份证号[XXX]不存在于员工信息表中,请先添加员工信息" |
|
||||
| 关系类型 | 不能为空,必须在字典中存在 | "第N行: 关系类型不能为空" |
|
||||
| 关系人姓名 | 不能为空 | "第N行: 关系人姓名不能为空" |
|
||||
| 关系人证件类型 | 不能为空 | "第N行: 关系人证件类型不能为空" |
|
||||
| 关系人证件号码 | 不能为空 | "第N行: 关系人证件号码不能为空" |
|
||||
| 手机号码1 | 如果填写,必须为有效手机号 | "第N行: 手机号码1格式不正确" |
|
||||
| 手机号码2 | 如果填写,必须为有效手机号 | "第N行: 手机号码2格式不正确" |
|
||||
| 性别 | 如果填写,必须是"男"、"女"、"其他"或"M"、"F"、"O" | "第N行: 性别只能是:男、女、其他 或 M、F、O" |
|
||||
|
||||
**性能优化**:
|
||||
- 采用批量预验证方式,仅1次数据库查询身份证号存在性
|
||||
- 批量查询已存在的身份证号+关系人证件号码组合,避免重复导入
|
||||
|
||||
---
|
||||
|
||||
### 2. 查询导入状态
|
||||
|
||||
**接口地址**: `GET /ccdi/staffFmyRelation/importStatus/{taskId}`
|
||||
|
||||
**权限要求**: `ccdi:staffFmyRelation:import`
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| taskId | String | 是 | 导入任务ID |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "查询成功",
|
||||
"data": {
|
||||
"taskId": "abc123-def456-ghi789",
|
||||
"status": "COMPLETED",
|
||||
"total": 100,
|
||||
"successCount": 95,
|
||||
"failureCount": 5,
|
||||
"message": "导入完成"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**状态说明**:
|
||||
|
||||
| 状态 | 说明 |
|
||||
|------|------|
|
||||
| PENDING | 等待处理 |
|
||||
| PROCESSING | 处理中 |
|
||||
| SUCCESS | 全部成功 |
|
||||
| PARTIAL_SUCCESS | 部分成功 |
|
||||
| FAILED | 处理失败 |
|
||||
|
||||
---
|
||||
|
||||
### 3. 查询导入失败记录
|
||||
|
||||
**接口地址**: `GET /ccdi/staffFmyRelation/importFailures/{taskId}`
|
||||
|
||||
**权限要求**: `ccdi:staffFmyRelation:import`
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| taskId | String | 是 | 导入任务ID |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "查询成功",
|
||||
"data": [
|
||||
{
|
||||
"personId": "999999999999999999",
|
||||
"relationType": "父亲",
|
||||
"relationName": "张三",
|
||||
"relationCertType": "身份证",
|
||||
"relationCertNo": "110101195501017890",
|
||||
"errorMessage": "第2行: 身份证号[999999999999999999]不存在于员工信息表中,请先添加员工信息",
|
||||
"rowNumber": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**失败记录字段说明**:
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| personId | String | 员工身份证号 |
|
||||
| relationType | String | 关系类型 |
|
||||
| relationName | String | 关系人姓名 |
|
||||
| relationCertType | String | 关系人证件类型 |
|
||||
| relationCertNo | String | 关系人证件号码 |
|
||||
| errorMessage | String | 错误信息 |
|
||||
| rowNumber | Integer | Excel行号 |
|
||||
|
||||
---
|
||||
|
||||
## Excel 模板字段说明
|
||||
|
||||
| 字段名 | 是否必填 | 说明 |
|
||||
|--------|---------|------|
|
||||
| 员工身份证号 | 是 | 必须在员工信息表中存在 |
|
||||
| 关系类型 | 是 | 下拉选择字典 |
|
||||
| 关系人姓名 | 是 | 不能为空 |
|
||||
| 性别 | 否 | 下拉选择字典 |
|
||||
| 出生日期 | 否 | 日期格式 |
|
||||
| 关系人证件类型 | 是 | 下拉选择字典 |
|
||||
| 关系人证件号码 | 是 | 不能为空 |
|
||||
| 手机号码1 | 否 | 手机号格式 |
|
||||
| 手机号码2 | 否 | 手机号格式 |
|
||||
| 微信名称1-3 | 否 | 自由输入 |
|
||||
| 详细联系地址 | 否 | 自由输入 |
|
||||
| 关系详细描述 | 否 | 自由输入 |
|
||||
| 生效日期 | 否 | 日期格式 |
|
||||
| 失效日期 | 否 | 日期格式 |
|
||||
| 备注 | 否 | 自由输入 |
|
||||
|
||||
---
|
||||
|
||||
## 错误码说明
|
||||
|
||||
| 错误码 | 说明 |
|
||||
|--------|------|
|
||||
| 200 | 操作成功 |
|
||||
| 401 | 未授权 |
|
||||
| 403 | 无权限 |
|
||||
| 500 | 服务器错误 |
|
||||
|
||||
---
|
||||
|
||||
## 更新日志
|
||||
|
||||
**2026-02-11**:
|
||||
- 新增员工身份证号存在性校验
|
||||
- 优化导入性能,采用批量预验证方式
|
||||
178
doc/api-docs/api/员工实体关系导入API文档.md
Normal file
178
doc/api-docs/api/员工实体关系导入API文档.md
Normal file
@@ -0,0 +1,178 @@
|
||||
# 员工实体关系导入 API 文档
|
||||
|
||||
## 概述
|
||||
|
||||
员工实体关系导入模块提供员工与企业实体关系的批量导入功能。
|
||||
|
||||
**基础路径**: `/ccdi/staffEnterpriseRelation`
|
||||
|
||||
**权限标识前缀**: `ccdi:staffEnterpriseRelation`
|
||||
|
||||
**数据表**: `ccdi_cust_enterprise_relation`
|
||||
|
||||
**关联表**:
|
||||
- `ccdi_base_staff` - 员工基础信息表(通过id_card关联)
|
||||
|
||||
---
|
||||
|
||||
## API 接口
|
||||
|
||||
### 1. 异步导入员工实体关系
|
||||
|
||||
**接口地址**: `POST /ccdi/staffEnterpriseRelation/importData`
|
||||
|
||||
**权限要求**: `ccdi:staffEnterpriseRelation:import`
|
||||
|
||||
**请求参数**: FormData
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| file | File | 是 | Excel文件 |
|
||||
| updateSupport | Boolean | 否 | 是否更新已存在的记录(默认false) |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "导入任务已提交,正在后台处理",
|
||||
"data": {
|
||||
"taskId": "abc123-def456-ghi789",
|
||||
"status": "PROCESSING",
|
||||
"message": "导入任务已提交,正在后台处理"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**导入流程**:
|
||||
1. 上传Excel文件
|
||||
2. 后台立即返回taskId
|
||||
3. 使用taskId轮询查询导入状态
|
||||
4. 导入完成后查看失败记录(如有)
|
||||
|
||||
**导入验证规则**:
|
||||
|
||||
导入时会验证以下字段:
|
||||
|
||||
| 字段名 | 验证规则 | 错误提示 |
|
||||
|--------|---------|---------|
|
||||
| 身份证号 | 必须在员工信息表(ccdi_base_staff)中存在 | "第N行: 身份证号[XXX]不存在于员工信息表中,请先添加员工信息" |
|
||||
| 统一社会信用代码 | 必须为18位有效统一社会信用代码 | "第N行: 统一社会信用代码格式不正确" |
|
||||
| 企业名称 | 不能为空,长度不超过200字符 | "第N行: 企业名称不能为空" 或 "企业名称长度不能超过200个字符" |
|
||||
|
||||
**性能优化**:
|
||||
- 采用批量预验证方式,仅1次数据库查询身份证号存在性
|
||||
- 批量查询已存在的身份证号+统一社会信用代码组合,避免重复导入
|
||||
|
||||
---
|
||||
|
||||
### 2. 查询导入状态
|
||||
|
||||
**接口地址**: `GET /ccdi/staffEnterpriseRelation/importStatus/{taskId}`
|
||||
|
||||
**权限要求**: `ccdi:staffEnterpriseRelation:import`
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| taskId | String | 是 | 导入任务ID |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "查询成功",
|
||||
"data": {
|
||||
"taskId": "abc123-def456-ghi789",
|
||||
"status": "COMPLETED",
|
||||
"total": 100,
|
||||
"successCount": 95,
|
||||
"failureCount": 5,
|
||||
"message": "导入完成"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**状态说明**:
|
||||
|
||||
| 状态 | 说明 |
|
||||
|------|------|
|
||||
| PENDING | 等待处理 |
|
||||
| PROCESSING | 处理中 |
|
||||
| SUCCESS | 全部成功 |
|
||||
| PARTIAL_SUCCESS | 部分成功 |
|
||||
| FAILED | 处理失败 |
|
||||
|
||||
---
|
||||
|
||||
### 3. 查询导入失败记录
|
||||
|
||||
**接口地址**: `GET /ccdi/staffEnterpriseRelation/importFailures/{taskId}`
|
||||
|
||||
**权限要求**: `ccdi:staffEnterpriseRelation:import`
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| taskId | String | 是 | 导入任务ID |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "查询成功",
|
||||
"data": [
|
||||
{
|
||||
"personId": "999999999999999999",
|
||||
"socialCreditCode": "91110000987654321X",
|
||||
"enterpriseName": "测试企业",
|
||||
"relationPersonPost": "总经理",
|
||||
"errorMessage": "第2行: 身份证号[999999999999999999]不存在于员工信息表中,请先添加员工信息",
|
||||
"rowNumber": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**失败记录字段说明**:
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| personId | String | 身份证号 |
|
||||
| socialCreditCode | String | 统一社会信用代码 |
|
||||
| enterpriseName | String | 企业名称 |
|
||||
| relationPersonPost | String | 关联人在企业的职务 |
|
||||
| errorMessage | String | 错误信息 |
|
||||
| rowNumber | Integer | Excel行号 |
|
||||
|
||||
---
|
||||
|
||||
## Excel 模板字段说明
|
||||
|
||||
| 字段名 | 是否必填 | 说明 |
|
||||
|--------|---------|------|
|
||||
| 身份证号 | 是 | 必须在员工信息表中存在 |
|
||||
| 统一社会信用代码 | 是 | 18位有效统一社会信用代码 |
|
||||
| 企业名称 | 是 | 长度不超过200字符 |
|
||||
| 关联人在企业的职务 | 否 | 长度不超过100字符 |
|
||||
| 补充说明 | 否 | 备注信息 |
|
||||
|
||||
---
|
||||
|
||||
## 错误码说明
|
||||
|
||||
| 错误码 | 说明 |
|
||||
|--------|------|
|
||||
| 200 | 操作成功 |
|
||||
| 401 | 未授权 |
|
||||
| 403 | 无权限 |
|
||||
| 500 | 服务器错误 |
|
||||
|
||||
---
|
||||
|
||||
## 更新日志
|
||||
|
||||
**2026-02-11**:
|
||||
- 新增员工身份证号存在性校验
|
||||
- 优化导入性能,采用批量预验证方式
|
||||
@@ -327,6 +327,21 @@
|
||||
3. 使用taskId轮询查询导入状态
|
||||
4. 导入完成后查看失败记录(如有)
|
||||
|
||||
**导入验证规则**:
|
||||
|
||||
导入时会验证以下字段:
|
||||
|
||||
| 字段名 | 验证规则 | 错误提示 |
|
||||
|--------|---------|---------|
|
||||
| 员工ID | 必须在员工信息表(ccdi_base_staff)中存在 | "第N行: 员工ID XXX 不存在" |
|
||||
| 调动前部门ID | 必须在部门表(sys_dept)中存在 | "第N行: 调动前部门ID XXX 不存在" |
|
||||
| 调动后部门ID | 必须在部门表(sys_dept)中存在 | "第N行: 调动后部门ID XXX 不存在" |
|
||||
| 调动日期 | 必须符合yyyy-MM-dd格式 | "第N行: 调动日期格式不正确" |
|
||||
|
||||
**性能优化**:
|
||||
- 采用批量预验证方式,仅1次数据库查询员工ID存在性
|
||||
- 从2次遍历优化为1次遍历,提升导入性能
|
||||
|
||||
---
|
||||
|
||||
### 9. 查询导入状态
|
||||
|
||||
23
doc/信贷客户实体关联维护功能/ccdi_cust_enterprise_relation.sql
Normal file
23
doc/信贷客户实体关联维护功能/ccdi_cust_enterprise_relation.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- 信贷客户实体关联关系表
|
||||
CREATE TABLE IF NOT EXISTS `ccdi_cust_enterprise_relation` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键,唯一标识',
|
||||
`person_id` VARCHAR(18) NOT NULL COMMENT '身份证号',
|
||||
`relation_person_post` VARCHAR(100) DEFAULT NULL COMMENT '关联人在企业的职务:股东、法人、高管、实际控制人等',
|
||||
`social_credit_code` VARCHAR(18) NOT NULL COMMENT '统一社会信用代码,关联企业主体信息表的外键',
|
||||
`enterprise_name` VARCHAR(200) DEFAULT NULL COMMENT '企业名称(冗余存储,便于快速查询)',
|
||||
`status` INT NOT NULL DEFAULT 1 COMMENT '关系是否有效:0 - 无效、1 - 有效(默认有效)',
|
||||
`remark` TEXT COMMENT '补充说明',
|
||||
`data_source` VARCHAR(50) DEFAULT NULL COMMENT '数据来源',
|
||||
`is_employee` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是员工:0-否 1-是',
|
||||
`is_emp_family` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是员工家庭关联人:0-否 1-是',
|
||||
`is_customer` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是信贷客户:0-否 1-是',
|
||||
`is_cust_family` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是信贷客户关联人:0-否 1-是',
|
||||
`created_by` VARCHAR(64) NOT NULL COMMENT '记录创建人',
|
||||
`updated_by` VARCHAR(64) DEFAULT NULL COMMENT '记录更新人',
|
||||
`create_time` DATETIME NOT NULL COMMENT '记录创建时间',
|
||||
`update_time` DATETIME NOT NULL COMMENT '记录更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_person_id` (`person_id`),
|
||||
KEY `idx_social_credit_code` (`social_credit_code`),
|
||||
UNIQUE KEY `uk_person_enterprise` (`person_id`, `social_credit_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='信贷客户实体关联关系表';
|
||||
516
doc/信贷客户实体关联维护功能/test_cust_enterprise_relation_api.sh
Normal file
516
doc/信贷客户实体关联维护功能/test_cust_enterprise_relation_api.sh
Normal file
@@ -0,0 +1,516 @@
|
||||
#!/bin/bash
|
||||
|
||||
################################################################################
|
||||
# 信贷客户实体关联信息后端功能测试脚本
|
||||
# 测试所有接口,生成Markdown格式测试报告
|
||||
# 遇到失败立即停止
|
||||
################################################################################
|
||||
|
||||
# 配置
|
||||
BASE_URL="http://localhost:8080"
|
||||
REPORT_FILE="doc/信贷客户实体关联维护功能/测试报告.md"
|
||||
TEST_DATA_DIR="doc/信贷客户实体关联维护功能/test_data"
|
||||
TOKEN=""
|
||||
|
||||
# 测试数据(动态生成唯一数据)
|
||||
TIMESTAMP=$(date +%s)
|
||||
# 身份证号格式:18位,正则 ^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[0-9Xx]$
|
||||
# 110101(地区码) + 19900101(合法日期) + 随机3位顺序码 + X(校验码)
|
||||
RANDOM_SUFFIX=$((TIMESTAMP % 1000))
|
||||
TEST_PERSON_ID="11010119900101123X"
|
||||
if [ $((RANDOM_SUFFIX % 2)) -eq 0 ]; then
|
||||
TEST_PERSON_ID="110101199001011234"
|
||||
fi
|
||||
# 统一社会信用代码格式:18位,正则 ^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$
|
||||
# 使用固定的合法格式
|
||||
TEST_SOCIAL_CREDIT_CODE="9111000010000644$((TIMESTAMP % 10))C"
|
||||
TEST_ENTERPRISE_NAME="测试企业有限公司_${TIMESTAMP}"
|
||||
TEST_RELATION_POST="股东"
|
||||
TEST_REMARK="自动化测试数据_${TIMESTAMP}"
|
||||
TEST_ID=""
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 计数器
|
||||
TOTAL_TESTS=0
|
||||
PASSED_TESTS=0
|
||||
FAILED_TESTS=0
|
||||
|
||||
# 测试结果存储
|
||||
declare -a TEST_RESULTS
|
||||
|
||||
# 初始化报告文件
|
||||
init_report() {
|
||||
mkdir -p "doc/信贷客户实体关联维护功能"
|
||||
cat > "$REPORT_FILE" << 'EOF'
|
||||
# 信贷客户实体关联信息后端功能测试报告
|
||||
|
||||
## 测试概述
|
||||
|
||||
| 项目 | 内容 |
|
||||
|------|------|
|
||||
| 测试模块 | 信贷客户实体关联信息管理 |
|
||||
| 测试环境 | 后端API接口测试 |
|
||||
| 测试时间 | EOF
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S')" >> "$REPORT_FILE"
|
||||
cat >> "$REPORT_FILE" << 'EOF'
|
||||
| 测试人员 | 自动化测试脚本 |
|
||||
|
||||
## 测试接口列表
|
||||
|
||||
| 序号 | 接口名称 | 请求方法 | 接口路径 |
|
||||
|------|----------|----------|----------|
|
||||
| 1 | 获取Token | POST | /login/test |
|
||||
| 2 | 分页查询列表 | GET | /ccdi/custEnterpriseRelation/list |
|
||||
| 3 | 新增记录 | POST | /ccdi/custEnterpriseRelation |
|
||||
| 4 | 查询详情 | GET | /ccdi/custEnterpriseRelation/{id} |
|
||||
| 5 | 修改记录 | PUT | /ccdi/custEnterpriseRelation |
|
||||
| 6 | 删除记录 | DELETE | /ccdi/custEnterpriseRelation/{ids} |
|
||||
| 7 | 导出Excel | POST | /ccdi/custEnterpriseRelation/export |
|
||||
| 8 | 下载导入模板 | GET | /ccdi/custEnterpriseRelation/importTemplate |
|
||||
| 9 | 导入数据 | POST | /ccdi/custEnterpriseRelation/importData |
|
||||
| 10 | 查询导入状态 | GET | /ccdi/custEnterpriseRelation/importStatus/{taskId} |
|
||||
| 11 | 查询导入失败记录 | GET | /ccdi/custEnterpriseRelation/importFailures/{taskId} |
|
||||
|
||||
## 测试结果汇总
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# 记录测试结果
|
||||
log_test() {
|
||||
local test_name="$1"
|
||||
local status="$2"
|
||||
local response="$3"
|
||||
local duration="$4"
|
||||
|
||||
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
||||
|
||||
if [ "$status" == "PASS" ]; then
|
||||
PASSED_TESTS=$((PASSED_TESTS + 1))
|
||||
echo -e "${GREEN}[PASS]${NC} $test_name (${duration}ms)"
|
||||
else
|
||||
FAILED_TESTS=$((FAILED_TESTS + 1))
|
||||
echo -e "${RED}[FAIL]${NC} $test_name (${duration}ms)"
|
||||
fi
|
||||
|
||||
# 存储测试结果
|
||||
TEST_RESULTS+=("$test_name|$status|$duration|${response:0:200}")
|
||||
}
|
||||
|
||||
# 完成报告
|
||||
finalize_report() {
|
||||
local success_rate=0
|
||||
if [ $TOTAL_TESTS -gt 0 ]; then
|
||||
success_rate=$((PASSED_TESTS * 100 / TOTAL_TESTS))
|
||||
fi
|
||||
|
||||
cat >> "$REPORT_FILE" << EOF
|
||||
|
||||
| 统计项 | 数值 |
|
||||
|--------|------|
|
||||
| 总测试数 | $TOTAL_TESTS |
|
||||
| 通过数 | $PASSED_TESTS |
|
||||
| 失败数 | $FAILED_TESTS |
|
||||
| 通过率 | ${success_rate}% |
|
||||
|
||||
## 详细测试结果
|
||||
|
||||
| 序号 | 测试接口 | 状态 | 耗时(ms) | 响应摘要 |
|
||||
|------|----------|------|----------|----------|
|
||||
EOF
|
||||
|
||||
local idx=1
|
||||
for result in "${TEST_RESULTS[@]}"; do
|
||||
IFS='|' read -r name status duration response <<< "$result"
|
||||
local status_icon=":white_check_mark:"
|
||||
if [ "$status" != "PASS" ]; then
|
||||
status_icon=":x:"
|
||||
fi
|
||||
echo "| $idx | $name | $status_icon $status | $duration | ${response:0:50}... |" >> "$REPORT_FILE"
|
||||
idx=$((idx + 1))
|
||||
done
|
||||
|
||||
cat >> "$REPORT_FILE" << EOF
|
||||
|
||||
## 测试结论
|
||||
|
||||
EOF
|
||||
|
||||
if [ $FAILED_TESTS -eq 0 ]; then
|
||||
echo "**所有测试通过!** 后端接口功能正常。" >> "$REPORT_FILE"
|
||||
else
|
||||
echo "**存在测试失败!** 请检查失败的接口和错误信息。" >> "$REPORT_FILE"
|
||||
fi
|
||||
|
||||
echo -e "\n${YELLOW}测试报告已生成: $REPORT_FILE${NC}"
|
||||
}
|
||||
|
||||
# 失败退出
|
||||
fail_exit() {
|
||||
local test_name="$1"
|
||||
local message="$2"
|
||||
echo -e "${RED}测试失败: $test_name${NC}"
|
||||
echo -e "${RED}错误信息: $message${NC}"
|
||||
finalize_report
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 检查命令是否存在
|
||||
check_command() {
|
||||
if ! command -v "$1" &> /dev/null; then
|
||||
echo -e "${RED}错误: 未找到命令 '$1',请先安装${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试1: 获取Token
|
||||
test_login() {
|
||||
echo -e "\n${YELLOW}=== 测试1: 获取Token ===${NC}"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X POST \
|
||||
"${BASE_URL}/login/test" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin123"}')
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"token"'; then
|
||||
TOKEN=$(echo "$response" | grep -o '"token":"[^"]*"' | sed 's/"token":"//;s/"//')
|
||||
log_test "获取Token" "PASS" "$response" "$duration"
|
||||
echo "Token获取成功: ${TOKEN:0:20}..."
|
||||
else
|
||||
log_test "获取Token" "FAIL" "$response" "$duration"
|
||||
fail_exit "获取Token" "无法获取Token,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试2: 分页查询列表
|
||||
test_list() {
|
||||
echo -e "\n${YELLOW}=== 测试2: 分页查询列表 ===${NC}"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/list?pageNum=1&pageSize=10" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"total"'; then
|
||||
local total=$(echo "$response" | grep -o '"total":[0-9]*' | sed 's/"total"://')
|
||||
log_test "分页查询列表" "PASS" "$response" "$duration"
|
||||
echo "查询成功,总数: $total"
|
||||
else
|
||||
log_test "分页查询列表" "FAIL" "$response" "$duration"
|
||||
fail_exit "分页查询列表" "查询失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试3: 新增记录
|
||||
test_add() {
|
||||
echo -e "\n${YELLOW}=== 测试3: 新增记录 ===${NC}"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X POST \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"personId\": \"${TEST_PERSON_ID}\",
|
||||
\"socialCreditCode\": \"${TEST_SOCIAL_CREDIT_CODE}\",
|
||||
\"enterpriseName\": \"${TEST_ENTERPRISE_NAME}\",
|
||||
\"relationPersonPost\": \"${TEST_RELATION_POST}\",
|
||||
\"status\": 1,
|
||||
\"remark\": \"${TEST_REMARK}\"
|
||||
}")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"code":200'; then
|
||||
log_test "新增记录" "PASS" "$response" "$duration"
|
||||
echo "新增成功"
|
||||
else
|
||||
log_test "新增记录" "FAIL" "$response" "$duration"
|
||||
fail_exit "新增记录" "新增失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试4: 查询详情(先查询列表获取ID)
|
||||
test_get_by_id() {
|
||||
echo -e "\n${YELLOW}=== 测试4: 查询详情 ===${NC}"
|
||||
|
||||
# 先查询列表获取刚新增的记录ID
|
||||
local list_response=$(curl -s -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/list?pageNum=1&pageSize=1&personId=${TEST_PERSON_ID}" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
|
||||
TEST_ID=$(echo "$list_response" | grep -o '"id":[0-9]*' | head -1 | sed 's/"id"://')
|
||||
|
||||
if [ -z "$TEST_ID" ]; then
|
||||
fail_exit "查询详情" "无法获取测试记录ID"
|
||||
fi
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/${TEST_ID}" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"personId"'; then
|
||||
log_test "查询详情" "PASS" "$response" "$duration"
|
||||
echo "查询成功,ID: $TEST_ID"
|
||||
else
|
||||
log_test "查询详情" "FAIL" "$response" "$duration"
|
||||
fail_exit "查询详情" "查询失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试5: 修改记录
|
||||
test_edit() {
|
||||
echo -e "\n${YELLOW}=== 测试5: 修改记录 ===${NC}"
|
||||
|
||||
local new_enterprise_name="${TEST_ENTERPRISE_NAME}_已修改"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X PUT \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"id\": ${TEST_ID},
|
||||
\"enterpriseName\": \"${new_enterprise_name}\",
|
||||
\"relationPersonPost\": \"法人\",
|
||||
\"status\": 1,
|
||||
\"remark\": \"修改后的备注\"
|
||||
}")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"code":200'; then
|
||||
log_test "修改记录" "PASS" "$response" "$duration"
|
||||
echo "修改成功"
|
||||
else
|
||||
log_test "修改记录" "FAIL" "$response" "$duration"
|
||||
fail_exit "修改记录" "修改失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试6: 导出Excel
|
||||
test_export() {
|
||||
echo -e "\n${YELLOW}=== 测试6: 导出Excel ===${NC}"
|
||||
|
||||
local output_file="${TEST_DATA_DIR}/export_test.xlsx"
|
||||
mkdir -p "$TEST_DATA_DIR"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local http_code=$(curl -s -o "$output_file" -w "%{http_code}" -X POST \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/export" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}')
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if [ "$http_code" == "200" ] && [ -f "$output_file" ]; then
|
||||
local file_size=$(stat -c%s "$output_file" 2>/dev/null || stat -f%z "$output_file" 2>/dev/null || echo "0")
|
||||
log_test "导出Excel" "PASS" "HTTP $http_code, 文件大小: ${file_size}bytes" "$duration"
|
||||
echo "导出成功,文件: $output_file"
|
||||
else
|
||||
log_test "导出Excel" "FAIL" "HTTP $http_code" "$duration"
|
||||
fail_exit "导出Excel" "导出失败,HTTP状态码: $http_code"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试7: 下载导入模板
|
||||
test_import_template() {
|
||||
echo -e "\n${YELLOW}=== 测试7: 下载导入模板 ===${NC}"
|
||||
|
||||
local output_file="${TEST_DATA_DIR}/import_template.xlsx"
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local http_code=$(curl -s -o "$output_file" -w "%{http_code}" -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/importTemplate" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if [ "$http_code" == "200" ] && [ -f "$output_file" ]; then
|
||||
local file_size=$(stat -c%s "$output_file" 2>/dev/null || stat -f%z "$output_file" 2>/dev/null || echo "0")
|
||||
log_test "下载导入模板" "PASS" "HTTP $http_code, 文件大小: ${file_size}bytes" "$duration"
|
||||
echo "下载成功,文件: $output_file"
|
||||
else
|
||||
log_test "下载导入模板" "FAIL" "HTTP $http_code" "$duration"
|
||||
fail_exit "下载导入模板" "下载失败,HTTP状态码: $http_code"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试8: 导入数据(非核心接口,失败不停止)
|
||||
test_import_data() {
|
||||
echo -e "\n${YELLOW}=== 测试8: 导入数据 ===${NC}"
|
||||
|
||||
# 创建测试导入文件(使用multipart/form-data)
|
||||
# 创建一个有实际数据的CSV模拟文件
|
||||
local import_csv="${TEST_DATA_DIR}/import_test.csv"
|
||||
|
||||
# 创建CSV数据(身份证号,统一社会信用代码,企业名称,职务,备注)
|
||||
cat > "$import_csv" << 'CSVEOF'
|
||||
身份证号,统一社会信用代码,企业名称,关联人在企业的职务,补充说明
|
||||
120101199002021234,91110000100006442D,导入测试企业A,股东,导入测试数据1
|
||||
120101199003031234,91110000100006443E,导入测试企业B,法人,导入测试数据2
|
||||
CSVEOF
|
||||
|
||||
# 由于需要xlsx格式,我们先创建一个简单的multipart请求
|
||||
# 这里直接测试接口的响应,即使文件格式可能不对
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X POST \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/importData" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-F "file=@${TEST_DATA_DIR}/import_template.xlsx")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应(导入可能是异步的,返回taskId或错误信息)
|
||||
if echo "$response" | grep -qE '"taskId"'; then
|
||||
local task_id=$(echo "$response" | grep -o '"taskId":"[^"]*"' | sed 's/"taskId":"//;s/"//')
|
||||
log_test "导入数据" "PASS" "$response" "$duration"
|
||||
echo "导入任务已提交,TaskId: $task_id"
|
||||
# 保存taskId供后续测试使用
|
||||
echo "$task_id" > "${TEST_DATA_DIR}/last_task_id.txt"
|
||||
else
|
||||
# 导入失败(可能是文件格式问题),记录但不停止测试
|
||||
log_test "导入数据" "FAIL" "$response" "$duration"
|
||||
echo -e "${YELLOW}导入测试失败(可能是测试文件格式问题),继续后续测试...${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试9: 查询导入状态
|
||||
test_import_status() {
|
||||
echo -e "\n${YELLOW}=== 测试9: 查询导入状态 ===${NC}"
|
||||
|
||||
local task_id=$(cat "${TEST_DATA_DIR}/last_task_id.txt" 2>/dev/null)
|
||||
|
||||
if [ -z "$task_id" ]; then
|
||||
# 如果没有taskId,使用一个测试ID
|
||||
task_id="test-task-id-$(date +%s)"
|
||||
fi
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/importStatus/${task_id}" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应(即使任务不存在,接口也应该正常响应)
|
||||
if echo "$response" | grep -qE '"status"|"code"'; then
|
||||
log_test "查询导入状态" "PASS" "$response" "$duration"
|
||||
echo "查询成功"
|
||||
else
|
||||
log_test "查询导入状态" "FAIL" "$response" "$duration"
|
||||
fail_exit "查询导入状态" "查询失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试10: 查询导入失败记录
|
||||
test_import_failures() {
|
||||
echo -e "\n${YELLOW}=== 测试10: 查询导入失败记录 ===${NC}"
|
||||
|
||||
local task_id=$(cat "${TEST_DATA_DIR}/last_task_id.txt" 2>/dev/null)
|
||||
|
||||
if [ -z "$task_id" ]; then
|
||||
task_id="test-task-id-$(date +%s)"
|
||||
fi
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X GET \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/importFailures/${task_id}?pageNum=1&pageSize=10" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -qE '"total"|"code"'; then
|
||||
log_test "查询导入失败记录" "PASS" "$response" "$duration"
|
||||
echo "查询成功"
|
||||
else
|
||||
log_test "查询导入失败记录" "FAIL" "$response" "$duration"
|
||||
fail_exit "查询导入失败记录" "查询失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试11: 删除记录
|
||||
test_delete() {
|
||||
echo -e "\n${YELLOW}=== 测试11: 删除记录 ===${NC}"
|
||||
|
||||
if [ -z "$TEST_ID" ]; then
|
||||
fail_exit "删除记录" "没有可删除的记录ID"
|
||||
fi
|
||||
|
||||
local start_time=$(date +%s%3N)
|
||||
local response=$(curl -s -X DELETE \
|
||||
"${BASE_URL}/ccdi/custEnterpriseRelation/${TEST_ID}" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
local end_time=$(date +%s%3N)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
# 检查响应
|
||||
if echo "$response" | grep -q '"code":200'; then
|
||||
log_test "删除记录" "PASS" "$response" "$duration"
|
||||
echo "删除成功"
|
||||
else
|
||||
log_test "删除记录" "FAIL" "$response" "$duration"
|
||||
fail_exit "删除记录" "删除失败,响应: $response"
|
||||
fi
|
||||
}
|
||||
|
||||
# 主函数
|
||||
main() {
|
||||
echo "========================================"
|
||||
echo " 信贷客户实体关联信息后端功能测试"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# 检查必要命令
|
||||
check_command curl
|
||||
check_command date
|
||||
|
||||
# 初始化报告
|
||||
init_report
|
||||
|
||||
# 执行测试
|
||||
test_login
|
||||
test_list
|
||||
test_add
|
||||
test_get_by_id
|
||||
test_edit
|
||||
test_export
|
||||
test_import_template
|
||||
test_import_data
|
||||
test_import_status
|
||||
test_import_failures
|
||||
test_delete
|
||||
|
||||
# 完成报告
|
||||
finalize_report
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo -e "${GREEN}所有测试完成!${NC}"
|
||||
echo "========================================"
|
||||
}
|
||||
|
||||
# 运行主函数
|
||||
main
|
||||
BIN
doc/信贷客户实体关联维护功能/test_data/export_test.xlsx
Normal file
BIN
doc/信贷客户实体关联维护功能/test_data/export_test.xlsx
Normal file
Binary file not shown.
BIN
doc/信贷客户实体关联维护功能/test_data/import_template.xlsx
Normal file
BIN
doc/信贷客户实体关联维护功能/test_data/import_template.xlsx
Normal file
Binary file not shown.
3
doc/信贷客户实体关联维护功能/test_data/import_test.csv
Normal file
3
doc/信贷客户实体关联维护功能/test_data/import_test.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
身份证号,统一社会信用代码,企业名称,关联人在企业的职务,补充说明
|
||||
120101199002021234,91110000100006442D,导入测试企业A,股东,导入测试数据1
|
||||
120101199003031234,91110000100006443E,导入测试企业B,法人,导入测试数据2
|
||||
|
1
doc/信贷客户实体关联维护功能/test_data/import_test.xlsx
Normal file
1
doc/信贷客户实体关联维护功能/test_data/import_test.xlsx
Normal file
@@ -0,0 +1 @@
|
||||
{"msg":"请求参数类型不匹配,参数[id]要求类型为:'java.lang.Long',但输入值为:'importTemplate'","code":500}
|
||||
BIN
doc/信贷客户实体关联维护功能/test_data/test_import_data.xlsx
Normal file
BIN
doc/信贷客户实体关联维护功能/test_data/test_import_data.xlsx
Normal file
Binary file not shown.
243
doc/信贷客户实体关联维护功能/代码校验报告.md
Normal file
243
doc/信贷客户实体关联维护功能/代码校验报告.md
Normal file
@@ -0,0 +1,243 @@
|
||||
# 信贷客户实体关联维护功能 - 代码校验报告
|
||||
|
||||
## 一、校验概述
|
||||
|
||||
本文档对信贷客户实体关联维护功能与员工实体关系维护功能进行逻辑一致性校验,确保前端交互方式和后端实现逻辑保持一致。
|
||||
|
||||
---
|
||||
|
||||
## 二、后端逻辑校验
|
||||
|
||||
### 2.1 Controller层对比
|
||||
|
||||
| 接口功能 | 员工实体关系 | 信贷客户实体关联 | 一致性 |
|
||||
|----------|-------------|-----------------|--------|
|
||||
| 分页查询 | /list | /list | ✓ |
|
||||
| 导出 | /export | /export | ✓ |
|
||||
| 详情查询 | /{id} | /{id} | ✓ |
|
||||
| 新增 | POST / | POST / | ✓ |
|
||||
| 修改 | PUT / | PUT / | ✓ |
|
||||
| 删除 | DELETE /{ids} | DELETE /{ids} | ✓ |
|
||||
| 下载模板 | /importTemplate | /importTemplate | ✓ |
|
||||
| 异步导入 | /importData | /importData | ✓ |
|
||||
| 查询导入状态 | /importStatus/{taskId} | /importStatus/{taskId} | ✓ |
|
||||
| 查询失败记录 | /importFailures/{taskId} | /importFailures/{taskId} | ✓ |
|
||||
|
||||
**结论**:Controller层接口设计完全一致 ✓
|
||||
|
||||
### 2.2 Service层对比
|
||||
|
||||
| 方法 | 员工实体关系 | 信贷客户实体关联 | 一致性 |
|
||||
|------|-------------|-----------------|--------|
|
||||
| selectRelationPage | ✓ | ✓ | ✓ |
|
||||
| selectRelationListForExport | ✓ | ✓ | ✓ |
|
||||
| selectRelationById | ✓ | ✓ | ✓ |
|
||||
| insertRelation | ✓ | ✓ | ✓(差异在默认值) |
|
||||
| updateRelation | ✓ | ✓ | ✓ |
|
||||
| deleteRelationByIds | ✓ | ✓ | ✓ |
|
||||
| importRelation | ✓ | ✓ | ✓ |
|
||||
|
||||
**结论**:Service层方法设计完全一致 ✓
|
||||
|
||||
### 2.3 异步导入逻辑对比
|
||||
|
||||
| 导入步骤 | 员工实体关系 | 信贷客户实体关联 | 差异说明 |
|
||||
|----------|-------------|-----------------|----------|
|
||||
| 1. 记录导入开始日志 | ✓ | ✓ | 一致 |
|
||||
| 2. 批量查询已存在组合 | ✓ | ✓ | 一致 |
|
||||
| 3. 验证必填字段 | ✓ | ✓ | 一致 |
|
||||
| 4. 验证身份证格式 | ✓ | ✓ | 一致 |
|
||||
| 5. 验证社会信用代码格式 | ✓ | ✓ | 一致 |
|
||||
| 6. **验证身份证号存在性** | ✓ | **无** | **差异** |
|
||||
| 7. 检查组合唯一性 | ✓ | ✓ | 一致 |
|
||||
| 8. 检查文件内重复 | ✓ | ✓ | 一致 |
|
||||
| 9. 设置身份标识 | is_emp_family=1 | is_cust_family=1 | **差异** |
|
||||
| 10. 设置数据来源 | IMPORT | IMPORT | 一致 |
|
||||
| 11. 批量插入 | 500条/批 | 500条/批 | 一致 |
|
||||
| 12. 保存失败记录到Redis | ✓ | ✓ | 一致 |
|
||||
| 13. 更新导入状态 | ✓ | ✓ | 一致 |
|
||||
| 14. 记录导入完成日志 | ✓ | ✓ | 一致 |
|
||||
|
||||
**关键差异说明**:
|
||||
- **身份证号验证**:员工实体关系需要验证身份证号存在于员工表;信贷客户实体关联不需要
|
||||
- **身份标识默认值**:员工实体关系 `is_emp_family=1`;信贷客户实体关联 `is_cust_family=1`
|
||||
|
||||
**结论**:导入逻辑框架一致,仅按需求有指定差异 ✓
|
||||
|
||||
### 2.4 Redis Key对比
|
||||
|
||||
| 用途 | 员工实体关系 | 信贷客户实体关联 |
|
||||
|------|-------------|-----------------|
|
||||
| 导入状态 | import:staffEnterpriseRelation:{taskId} | import:custEnterpriseRelation:{taskId} |
|
||||
| 失败记录 | import:staffEnterpriseRelation:{taskId}:failures | import:custEnterpriseRelation:{taskId}:failures |
|
||||
| 过期时间 | 7天 | 7天 |
|
||||
|
||||
**结论**:Redis key设计模式一致 ✓
|
||||
|
||||
### 2.5 Mapper XML对比
|
||||
|
||||
| SQL功能 | 员工实体关系 | 信贷客户实体关联 | 差异说明 |
|
||||
|---------|-------------|-----------------|----------|
|
||||
| 分页查询 | LEFT JOIN员工表获取姓名 | 不JOIN | **差异** |
|
||||
| 详情查询 | LEFT JOIN员工表获取姓名 | 不JOIN | **差异** |
|
||||
| 唯一性检查 | person_id + social_credit_code | person_id + social_credit_code | 一致 |
|
||||
| 批量存在检查 | ✓ | ✓ | 一致 |
|
||||
| 批量插入 | ✓ | ✓ | 一致 |
|
||||
|
||||
**结论**:Mapper SQL框架一致,差异在于是否JOIN员工表 ✓
|
||||
|
||||
---
|
||||
|
||||
## 三、前端逻辑校验
|
||||
|
||||
### 3.1 页面功能对比
|
||||
|
||||
| 功能 | 员工实体关系 | 信贷客户实体关联 | 一致性 |
|
||||
|------|-------------|-----------------|--------|
|
||||
| 搜索表单 | ✓ | ✓ | ✓ |
|
||||
| 新增按钮 | ✓ | ✓ | ✓ |
|
||||
| 导入按钮 | ✓ | ✓ | ✓ |
|
||||
| 导出按钮 | ✓ | ✓ | ✓ |
|
||||
| 查看失败记录按钮 | ✓ | ✓ | ✓ |
|
||||
| 列表展示 | ✓ | ✓ | ✓(差异在列) |
|
||||
| 分页 | ✓ | ✓ | ✓ |
|
||||
| 新增/编辑弹窗 | ✓ | ✓ | ✓ |
|
||||
| 详情弹窗 | ✓ | ✓ | ✓ |
|
||||
| 导入弹窗 | ✓ | ✓ | ✓ |
|
||||
| 失败记录弹窗 | ✓ | ✓ | ✓ |
|
||||
|
||||
**结论**:页面功能完全一致 ✓
|
||||
|
||||
### 3.2 表单交互对比
|
||||
|
||||
| 交互项 | 员工实体关系 | 信贷客户实体关联 | 差异说明 |
|
||||
|--------|-------------|-----------------|----------|
|
||||
| 身份证号输入 | 远程搜索下拉框 | 普通输入框 | **差异** |
|
||||
| 统一社会信用代码 | 输入框 | 输入框 | 一致 |
|
||||
| 企业名称 | 输入框 | 输入框 | 一致 |
|
||||
| 职务 | 输入框 | 输入框 | 一致 |
|
||||
| 状态(编辑时) | 下拉选择 | 下拉选择 | 一致 |
|
||||
| 补充说明 | 文本域 | 文本域 | 一致 |
|
||||
|
||||
**结论**:除身份证号输入方式外,其他表单交互一致 ✓
|
||||
|
||||
### 3.3 列表展示对比
|
||||
|
||||
| 列 | 员工实体关系 | 信贷客户实体关联 | 差异说明 |
|
||||
|----|-------------|-----------------|----------|
|
||||
| 选择框 | ✓ | ✓ | 一致 |
|
||||
| 身份证号 | ✓ | ✓ | 一致 |
|
||||
| **员工姓名** | ✓ | **无** | **差异** |
|
||||
| 企业名称 | ✓ | ✓ | 一致 |
|
||||
| 职务 | ✓ | ✓ | 一致 |
|
||||
| 状态 | ✓ | ✓ | 一致 |
|
||||
| 数据来源 | ✓ | ✓ | 一致 |
|
||||
| 创建时间 | ✓ | ✓ | 一致 |
|
||||
| 操作列 | ✓ | ✓ | 一致 |
|
||||
|
||||
**结论**:除员工姓名列外,其他列一致 ✓
|
||||
|
||||
### 3.4 详情弹窗对比
|
||||
|
||||
| 展示项 | 员工实体关系 | 信贷客户实体关联 | 差异说明 |
|
||||
|--------|-------------|-----------------|----------|
|
||||
| **员工姓名** | ✓ | **无** | **差异** |
|
||||
| 身份证号 | ✓ | ✓ | 一致 |
|
||||
| 统一社会信用代码 | ✓ | ✓ | 一致 |
|
||||
| 企业名称 | ✓ | ✓ | 一致 |
|
||||
| 职务 | ✓ | ✓ | 一致 |
|
||||
| 状态 | ✓ | ✓ | 一致 |
|
||||
| 数据来源 | ✓ | ✓ | 一致 |
|
||||
| 补充说明 | ✓ | ✓ | 一致 |
|
||||
| 创建时间/人 | ✓ | ✓ | 一致 |
|
||||
| 更新时间/人 | ✓ | ✓ | 一致 |
|
||||
|
||||
**结论**:除员工姓名外,详情展示一致 ✓
|
||||
|
||||
### 3.5 导入流程对比
|
||||
|
||||
| 导入步骤 | 员工实体关系 | 信贷客户实体关联 | 一致性 |
|
||||
|----------|-------------|-----------------|--------|
|
||||
| 点击导入按钮 | ✓ | ✓ | ✓ |
|
||||
| 弹出上传对话框 | ✓ | ✓ | ✓ |
|
||||
| 下载模板 | ✓ | ✓ | ✓ |
|
||||
| 选择文件上传 | ✓ | ✓ | ✓ |
|
||||
| 提交后立即返回taskId | ✓ | ✓ | ✓ |
|
||||
| 显示后台处理提示 | ✓ | ✓ | ✓ |
|
||||
| 开始轮询导入状态 | 2秒/次 | 2秒/次 | ✓ |
|
||||
| 处理完成后通知 | ✓ | ✓ | ✓ |
|
||||
| 显示失败记录按钮 | 有失败时显示 | 有失败时显示 | ✓ |
|
||||
| 查看失败记录弹窗 | ✓ | ✓ | ✓ |
|
||||
| 分页展示失败记录 | ✓ | ✓ | ✓ |
|
||||
| 清除历史记录 | ✓ | ✓ | ✓ |
|
||||
|
||||
**结论**:导入流程完全一致 ✓
|
||||
|
||||
### 3.6 localStorage对比
|
||||
|
||||
| 用途 | 员工实体关系 | 信贷客户实体关联 |
|
||||
|------|-------------|-----------------|
|
||||
| 存储key | staff_enterprise_relation_import_last_task | cust_enterprise_relation_import_last_task |
|
||||
| 存储内容 | taskId, status, counts, saveTime | 相同 |
|
||||
| 过期检查 | 7天 | 7天 |
|
||||
|
||||
**结论**:localStorage使用模式一致 ✓
|
||||
|
||||
---
|
||||
|
||||
## 四、权限配置对比
|
||||
|
||||
| 权限 | 员工实体关系 | 信贷客户实体关联 |
|
||||
|------|-------------|-----------------|
|
||||
| 列表 | ccdi:staffEnterpriseRelation:list | ccdi:custEnterpriseRelation:list |
|
||||
| 查询 | ccdi:staffEnterpriseRelation:query | ccdi:custEnterpriseRelation:query |
|
||||
| 新增 | ccdi:staffEnterpriseRelation:add | ccdi:custEnterpriseRelation:add |
|
||||
| 编辑 | ccdi:staffEnterpriseRelation:edit | ccdi:custEnterpriseRelation:edit |
|
||||
| 删除 | ccdi:staffEnterpriseRelation:remove | ccdi:custEnterpriseRelation:remove |
|
||||
| 导出 | ccdi:staffEnterpriseRelation:export | ccdi:custEnterpriseRelation:export |
|
||||
| 导入 | ccdi:staffEnterpriseRelation:import | ccdi:custEnterpriseRelation:import |
|
||||
|
||||
**结论**:权限命名规范一致 ✓
|
||||
|
||||
---
|
||||
|
||||
## 五、校验总结
|
||||
|
||||
### 5.1 一致性检查结果
|
||||
|
||||
| 检查项 | 状态 |
|
||||
|--------|------|
|
||||
| Controller接口设计 | ✓ 一致 |
|
||||
| Service方法设计 | ✓ 一致 |
|
||||
| 异步导入框架 | ✓ 一致 |
|
||||
| Redis状态管理 | ✓ 一致 |
|
||||
| Mapper SQL框架 | ✓ 一致 |
|
||||
| 前端页面功能 | ✓ 一致 |
|
||||
| 前端表单交互 | ✓ 一致(除身份证输入方式) |
|
||||
| 前端列表展示 | ✓ 一致(除姓名列) |
|
||||
| 前端详情展示 | ✓ 一致(除姓名) |
|
||||
| 导入流程 | ✓ 一致 |
|
||||
| localStorage使用 | ✓ 一致 |
|
||||
| 权限命名规范 | ✓ 一致 |
|
||||
|
||||
### 5.2 预期差异确认
|
||||
|
||||
| 差异项 | 员工实体关系 | 信贷客户实体关联 | 状态 |
|
||||
|--------|-------------|-----------------|------|
|
||||
| 身份证号验证 | 验证存在员工表 | 不验证 | ✓ 符合预期 |
|
||||
| 员工搜索功能 | 有 | 无 | ✓ 符合预期 |
|
||||
| 姓名显示 | 有 | 无 | ✓ 符合预期 |
|
||||
| 身份标识默认值 | is_emp_family=1 | is_cust_family=1 | ✓ 符合预期 |
|
||||
| API路径 | staffEnterpriseRelation | custEnterpriseRelation | ✓ 符合预期 |
|
||||
| 权限标识 | staffEnterpriseRelation | custEnterpriseRelation | ✓ 符合预期 |
|
||||
| localStorage key | staff_enterprise_relation | cust_enterprise_relation | ✓ 符合预期 |
|
||||
|
||||
### 5.3 校验结论
|
||||
|
||||
**信贷客户实体关联维护功能的实施方案与员工实体关系维护功能在逻辑上完全一致**,所有差异均符合需求预期:
|
||||
|
||||
1. ✓ 后端实现逻辑一致(CRUD、异步导入、Redis状态管理)
|
||||
2. ✓ 前端交互方式一致(弹窗、导入流程、状态轮询)
|
||||
3. ✓ 预期差异均已正确处理(无员工搜索、无姓名显示、身份标识默认值不同)
|
||||
|
||||
**实施方案可直接用于开发实施。**
|
||||
1088
doc/信贷客户实体关联维护功能/前端实施方案.md
Normal file
1088
doc/信贷客户实体关联维护功能/前端实施方案.md
Normal file
File diff suppressed because it is too large
Load Diff
1511
doc/信贷客户实体关联维护功能/后端实施方案.md
Normal file
1511
doc/信贷客户实体关联维护功能/后端实施方案.md
Normal file
File diff suppressed because it is too large
Load Diff
58
doc/信贷客户实体关联维护功能/测试报告.md
Normal file
58
doc/信贷客户实体关联维护功能/测试报告.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 信贷客户实体关联信息后端功能测试报告
|
||||
|
||||
## 测试概述
|
||||
|
||||
| 项目 | 内容 |
|
||||
|------|------|
|
||||
| 测试模块 | 信贷客户实体关联信息管理 |
|
||||
| 测试环境 | 后端API接口测试 |
|
||||
| 测试时间 | EOF
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S')" >> "$REPORT_FILE"
|
||||
cat >> "$REPORT_FILE" << 'EOF'
|
||||
| 测试人员 | 自动化测试脚本 |
|
||||
|
||||
## 测试接口列表
|
||||
|
||||
| 序号 | 接口名称 | 请求方法 | 接口路径 |
|
||||
|------|----------|----------|----------|
|
||||
| 1 | 获取Token | POST | /login/test |
|
||||
| 2 | 分页查询列表 | GET | /ccdi/custEnterpriseRelation/list |
|
||||
| 3 | 新增记录 | POST | /ccdi/custEnterpriseRelation |
|
||||
| 4 | 查询详情 | GET | /ccdi/custEnterpriseRelation/{id} |
|
||||
| 5 | 修改记录 | PUT | /ccdi/custEnterpriseRelation |
|
||||
| 6 | 删除记录 | DELETE | /ccdi/custEnterpriseRelation/{ids} |
|
||||
| 7 | 导出Excel | POST | /ccdi/custEnterpriseRelation/export |
|
||||
| 8 | 下载导入模板 | GET | /ccdi/custEnterpriseRelation/importTemplate |
|
||||
| 9 | 导入数据 | POST | /ccdi/custEnterpriseRelation/importData |
|
||||
| 10 | 查询导入状态 | GET | /ccdi/custEnterpriseRelation/importStatus/{taskId} |
|
||||
| 11 | 查询导入失败记录 | GET | /ccdi/custEnterpriseRelation/importFailures/{taskId} |
|
||||
|
||||
## 测试结果汇总
|
||||
|
||||
|
||||
| 统计项 | 数值 |
|
||||
|--------|------|
|
||||
| 总测试数 | 11 |
|
||||
| 通过数 | 10 |
|
||||
| 失败数 | 1 |
|
||||
| 通过率 | 90% |
|
||||
|
||||
## 详细测试结果
|
||||
|
||||
| 序号 | 测试接口 | 状态 | 耗时(ms) | 响应摘要 |
|
||||
|------|----------|------|----------|----------|
|
||||
| 1 | 获取Token | :white_check_mark: PASS | 754 | {"msg":"操作成功","code":200,"token":"eyJhbGciOiJIUzUx... |
|
||||
| 2 | 分页查询列表 | :white_check_mark: PASS | 276 | {"total":1,"rows":[{"id":1,"personId":"11010119900... |
|
||||
| 3 | 新增记录 | :white_check_mark: PASS | 419 | {"msg":"操作成功","code":200}... |
|
||||
| 4 | 查询详情 | :white_check_mark: PASS | 187 | {"msg":"操作成功","code":200,"data":{"id":2,"personId"... |
|
||||
| 5 | 修改记录 | :white_check_mark: PASS | 413 | {"msg":"操作成功","code":200}... |
|
||||
| 6 | 导出Excel | :white_check_mark: PASS | 309 | HTTP 200, 文件大小: 3880bytes... |
|
||||
| 7 | 下载导入模板 | :white_check_mark: PASS | 172 | HTTP 200, 文件大小: 132bytes... |
|
||||
| 8 | 导入数据 | :x: FAIL | 187 | {"msg":"导入Excel失败","code":500}... |
|
||||
| 9 | 查询导入状态 | :white_check_mark: PASS | 215 | {"msg":"任务不存在或已过期","code":500}... |
|
||||
| 10 | 查询导入失败记录 | :white_check_mark: PASS | 236 | {"total":0,"rows":[],"code":200,"msg":"查询成功"}... |
|
||||
| 11 | 删除记录 | :white_check_mark: PASS | 364 | {"msg":"操作成功","code":200}... |
|
||||
|
||||
## 测试结论
|
||||
|
||||
**存在测试失败!** 请检查失败的接口和错误信息。
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.ruoyi.ccdi.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiCustEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiCustEnterpriseRelationVO;
|
||||
import com.ruoyi.ccdi.domain.vo.CustEnterpriseRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportResultVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.service.ICcdiCustEnterpriseRelationImportService;
|
||||
import com.ruoyi.ccdi.service.ICcdiCustEnterpriseRelationService;
|
||||
import com.ruoyi.ccdi.utils.EasyExcelUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Tag(name = "信贷客户实体关联信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/ccdi/custEnterpriseRelation")
|
||||
public class CcdiCustEnterpriseRelationController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ICcdiCustEnterpriseRelationService relationService;
|
||||
|
||||
@Resource
|
||||
private ICcdiCustEnterpriseRelationImportService relationImportService;
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联列表
|
||||
*/
|
||||
@Operation(summary = "查询信贷客户实体关联列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CcdiCustEnterpriseRelationQueryDTO queryDTO) {
|
||||
// 使用MyBatis Plus分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Page<CcdiCustEnterpriseRelationVO> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
Page<CcdiCustEnterpriseRelationVO> result = relationService.selectRelationPage(page, queryDTO);
|
||||
return getDataTable(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出信贷客户实体关联列表
|
||||
*/
|
||||
@Operation(summary = "导出信贷客户实体关联列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:export')")
|
||||
@Log(title = "信贷客户实体关联信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CcdiCustEnterpriseRelationQueryDTO queryDTO) {
|
||||
List<CcdiCustEnterpriseRelationExcel> list = relationService.selectRelationListForExport(queryDTO);
|
||||
EasyExcelUtil.exportExcel(response, list, CcdiCustEnterpriseRelationExcel.class, "信贷客户实体关联信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信贷客户实体关联详细信息
|
||||
*/
|
||||
@Operation(summary = "获取信贷客户实体关联详细信息")
|
||||
@Parameter(name = "id", description = "主键ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable Long id) {
|
||||
return success(relationService.selectRelationById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增信贷客户实体关联
|
||||
*/
|
||||
@Operation(summary = "新增信贷客户实体关联")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:add')")
|
||||
@Log(title = "信贷客户实体关联信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody CcdiCustEnterpriseRelationAddDTO addDTO) {
|
||||
return toAjax(relationService.insertRelation(addDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改信贷客户实体关联
|
||||
*/
|
||||
@Operation(summary = "修改信贷客户实体关联")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:edit')")
|
||||
@Log(title = "信贷客户实体关联信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody CcdiCustEnterpriseRelationEditDTO editDTO) {
|
||||
return toAjax(relationService.updateRelation(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信贷客户实体关联
|
||||
*/
|
||||
@Operation(summary = "删除信贷客户实体关联")
|
||||
@Parameter(name = "ids", description = "主键ID数组", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:remove')")
|
||||
@Log(title = "信贷客户实体关联信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(relationService.deleteRelationByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*/
|
||||
@Operation(summary = "下载导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiCustEnterpriseRelationExcel.class, "信贷客户实体关联信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步导入信贷客户实体关联
|
||||
*/
|
||||
@Operation(summary = "异步导入信贷客户实体关联")
|
||||
@Parameter(name = "file", description = "导入文件", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:import')")
|
||||
@Log(title = "信贷客户实体关联信息", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(@Parameter(description = "导入文件") MultipartFile file) throws Exception {
|
||||
List<CcdiCustEnterpriseRelationExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), CcdiCustEnterpriseRelationExcel.class);
|
||||
|
||||
if (list == null || list.isEmpty()) {
|
||||
return error("至少需要一条数据");
|
||||
}
|
||||
|
||||
// 提交异步任务
|
||||
String taskId = relationService.importRelation(list);
|
||||
|
||||
// 立即返回
|
||||
ImportResultVO result = new ImportResultVO();
|
||||
result.setTaskId(taskId);
|
||||
result.setStatus("PROCESSING");
|
||||
result.setMessage("导入任务已提交,正在后台处理");
|
||||
|
||||
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*/
|
||||
@Operation(summary = "查询导入状态")
|
||||
@Parameter(name = "taskId", description = "任务ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:import')")
|
||||
@GetMapping("/importStatus/{taskId}")
|
||||
public AjaxResult getImportStatus(@PathVariable String taskId) {
|
||||
ImportStatusVO statusVO = relationImportService.getImportStatus(taskId);
|
||||
return success(statusVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入失败记录
|
||||
*/
|
||||
@Operation(summary = "查询导入失败记录")
|
||||
@Parameter(name = "taskId", description = "任务ID", required = true)
|
||||
@Parameter(name = "pageNum", description = "页码", required = false)
|
||||
@Parameter(name = "pageSize", description = "每页条数", required = false)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:custEnterpriseRelation:import')")
|
||||
@GetMapping("/importFailures/{taskId}")
|
||||
public TableDataInfo getImportFailures(
|
||||
@PathVariable String taskId,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
|
||||
List<CustEnterpriseRelationImportFailureVO> failures = relationImportService.getImportFailures(taskId);
|
||||
|
||||
// 手动分页
|
||||
int fromIndex = (pageNum - 1) * pageSize;
|
||||
int toIndex = Math.min(fromIndex + pageSize, failures.size());
|
||||
|
||||
// 检查 fromIndex 是否超出范围
|
||||
if (fromIndex >= failures.size()) {
|
||||
return getDataTable(new ArrayList<>(), failures.size());
|
||||
}
|
||||
|
||||
List<CustEnterpriseRelationImportFailureVO> pageData = failures.subList(fromIndex, toIndex);
|
||||
|
||||
return getDataTable(pageData, failures.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.ccdi.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息对象 ccdi_cust_enterprise_relation
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@TableName("ccdi_cust_enterprise_relation")
|
||||
@Schema(description = "信贷客户实体关联信息")
|
||||
public class CcdiCustEnterpriseRelation implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 身份证号 */
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 关联人在企业的职务 */
|
||||
@Schema(description = "关联人在企业的职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 状态(0-无效 1-有效) */
|
||||
@Schema(description = "状态(0-无效 1-有效)")
|
||||
private Integer status;
|
||||
|
||||
/** 补充说明 */
|
||||
@Schema(description = "补充说明")
|
||||
private String remark;
|
||||
|
||||
/** 数据来源 */
|
||||
@Schema(description = "数据来源")
|
||||
private String dataSource;
|
||||
|
||||
/** 是否为员工(0-否 1-是) */
|
||||
@Schema(description = "是否为员工(0-否 1-是)")
|
||||
private Integer isEmployee;
|
||||
|
||||
/** 是否为员工家属(0-否 1-是) */
|
||||
@Schema(description = "是否为员工家属(0-否 1-是)")
|
||||
private Integer isEmpFamily;
|
||||
|
||||
/** 是否为客户(0-否 1-是) */
|
||||
@Schema(description = "是否为客户(0-否 1-是)")
|
||||
private Integer isCustomer;
|
||||
|
||||
/** 是否为客户家属(0-否 1-是) */
|
||||
@Schema(description = "是否为客户家属(0-否 1-是)")
|
||||
private Integer isCustFamily;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/** 创建人 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createdBy;
|
||||
|
||||
/** 更新人 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新人")
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息新增DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息新增")
|
||||
public class CcdiCustEnterpriseRelationAddDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 身份证号 */
|
||||
@NotBlank(message = "身份证号不能为空")
|
||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "身份证号格式不正确")
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 关联人在企业的职务 */
|
||||
@Size(max = 100, message = "关联人在企业的职务长度不能超过100个字符")
|
||||
@Schema(description = "关联人在企业的职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@NotBlank(message = "统一社会信用代码不能为空")
|
||||
@Pattern(regexp = "^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$", message = "统一社会信用代码格式不正确")
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@NotBlank(message = "企业名称不能为空")
|
||||
@Size(max = 200, message = "企业名称长度不能超过200个字符")
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 状态(0-无效 1-有效) */
|
||||
@Schema(description = "状态(0-无效 1-有效)")
|
||||
private Integer status;
|
||||
|
||||
/** 补充说明 */
|
||||
@Schema(description = "补充说明")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息编辑DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息编辑")
|
||||
public class CcdiCustEnterpriseRelationEditDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@NotNull(message = "主键ID不能为空")
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 身份证号(不可修改) */
|
||||
@Schema(description = "身份证号(不可修改)")
|
||||
private String personId;
|
||||
|
||||
/** 关联人在企业的职务 */
|
||||
@Size(max = 100, message = "关联人在企业的职务长度不能超过100个字符")
|
||||
@Schema(description = "关联人在企业的职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
/** 统一社会信用代码(不可修改) */
|
||||
@Schema(description = "统一社会信用代码(不可修改)")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@NotBlank(message = "企业名称不能为空")
|
||||
@Size(max = 200, message = "企业名称长度不能超过200个字符")
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 状态(0-无效 1-有效) */
|
||||
@Schema(description = "状态(0-无效 1-有效)")
|
||||
private Integer status;
|
||||
|
||||
/** 补充说明 */
|
||||
@Schema(description = "补充说明")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息查询DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息查询条件")
|
||||
public class CcdiCustEnterpriseRelationQueryDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 身份证号 */
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 状态(0-无效 1-有效) */
|
||||
@Schema(description = "状态(0-无效 1-有效)")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.ccdi.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.common.annotation.Required;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息Excel导入导出对象")
|
||||
public class CcdiCustEnterpriseRelationExcel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 身份证号 */
|
||||
@ExcelProperty(value = "身份证号", index = 0)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@ExcelProperty(value = "统一社会信用代码", index = 1)
|
||||
@ColumnWidth(25)
|
||||
@Required
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@ExcelProperty(value = "企业名称", index = 2)
|
||||
@ColumnWidth(30)
|
||||
@Required
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 关联人在企业的职务 */
|
||||
@ExcelProperty(value = "关联人在企业的职务", index = 3)
|
||||
@ColumnWidth(25)
|
||||
@Schema(description = "关联人在企业的职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
/** 补充说明 */
|
||||
@ExcelProperty(value = "补充说明", index = 4)
|
||||
@ColumnWidth(40)
|
||||
@Schema(description = "补充说明")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ruoyi.ccdi.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息VO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息")
|
||||
public class CcdiCustEnterpriseRelationVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 身份证号 */
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 关联人在企业的职务 */
|
||||
@Schema(description = "关联人在企业的职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 状态(0-无效 1-有效) */
|
||||
@Schema(description = "状态(0-无效 1-有效)")
|
||||
private Integer status;
|
||||
|
||||
/** 补充说明 */
|
||||
@Schema(description = "补充说明")
|
||||
private String remark;
|
||||
|
||||
/** 数据来源 */
|
||||
@Schema(description = "数据来源")
|
||||
private String dataSource;
|
||||
|
||||
/** 是否为员工(0-否 1-是) */
|
||||
@Schema(description = "是否为员工(0-否 1-是)")
|
||||
private Integer isEmployee;
|
||||
|
||||
/** 是否为员工家属(0-否 1-是) */
|
||||
@Schema(description = "是否为员工家属(0-否 1-是)")
|
||||
private Integer isEmpFamily;
|
||||
|
||||
/** 是否为客户(0-否 1-是) */
|
||||
@Schema(description = "是否为客户(0-否 1-是)")
|
||||
private Integer isCustomer;
|
||||
|
||||
/** 是否为客户家属(0-否 1-是) */
|
||||
@Schema(description = "是否为客户家属(0-否 1-是)")
|
||||
private Integer isCustFamily;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/** 创建人 */
|
||||
@Schema(description = "创建人")
|
||||
private String createdBy;
|
||||
|
||||
/** 更新人 */
|
||||
@Schema(description = "更新人")
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.ccdi.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息导入失败记录VO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "信贷客户实体关联信息导入失败记录")
|
||||
public class CustEnterpriseRelationImportFailureVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 身份证号 */
|
||||
@Schema(description = "身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 企业名称 */
|
||||
@Schema(description = "企业名称")
|
||||
private String enterpriseName;
|
||||
|
||||
/** 错误信息 */
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMessage;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.ruoyi.ccdi.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.CcdiCustEnterpriseRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiCustEnterpriseRelationVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Mapper
|
||||
public interface CcdiCustEnterpriseRelationMapper extends BaseMapper<CcdiCustEnterpriseRelation> {
|
||||
|
||||
/**
|
||||
* 分页查询信贷客户实体关联列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联VO分页结果
|
||||
*/
|
||||
Page<CcdiCustEnterpriseRelationVO> selectRelationPage(@Param("page") Page<CcdiCustEnterpriseRelationVO> page,
|
||||
@Param("query") CcdiCustEnterpriseRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 信贷客户实体关联VO
|
||||
*/
|
||||
CcdiCustEnterpriseRelationVO selectRelationById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 判断身份证号和统一社会信用代码的组合是否已存在
|
||||
*
|
||||
* @param personId 身份证号
|
||||
* @param socialCreditCode 统一社会信用代码
|
||||
* @return 存在返回true,否则返回false
|
||||
*/
|
||||
boolean existsByPersonIdAndSocialCreditCode(@Param("personId") String personId,
|
||||
@Param("socialCreditCode") String socialCreditCode);
|
||||
|
||||
/**
|
||||
* 批量查询已存在的person_id + social_credit_code组合
|
||||
* 优化导入性能,一次性查询所有组合
|
||||
*
|
||||
* @param combinations 组合列表,格式为 ["personId1|socialCreditCode1", "personId2|socialCreditCode2", ...]
|
||||
* @return 已存在的组合集合
|
||||
*/
|
||||
Set<String> batchExistsByCombinations(@Param("combinations") List<String> combinations);
|
||||
|
||||
/**
|
||||
* 批量插入信贷客户实体关联数据
|
||||
*
|
||||
* @param list 信贷客户实体关联列表
|
||||
* @return 插入行数
|
||||
*/
|
||||
int insertBatch(@Param("list") List<CcdiCustEnterpriseRelation> list);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.ccdi.service;
|
||||
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiCustEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CustEnterpriseRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息异步导入服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
public interface ICcdiCustEnterpriseRelationImportService {
|
||||
|
||||
/**
|
||||
* 异步导入信贷客户实体关联数据
|
||||
*
|
||||
* @param excelList Excel数据列表
|
||||
* @param taskId 任务ID
|
||||
* @param userName 用户名
|
||||
*/
|
||||
void importRelationAsync(List<CcdiCustEnterpriseRelationExcel> excelList, String taskId, String userName);
|
||||
|
||||
/**
|
||||
* 获取导入失败记录
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 失败记录列表
|
||||
*/
|
||||
List<CustEnterpriseRelationImportFailureVO> getImportFailures(String taskId);
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 导入状态信息
|
||||
*/
|
||||
ImportStatusVO getImportStatus(String taskId);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.ccdi.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiCustEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiCustEnterpriseRelationVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
public interface ICcdiCustEnterpriseRelationService {
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联列表
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联VO集合
|
||||
*/
|
||||
List<CcdiCustEnterpriseRelationVO> selectRelationList(CcdiCustEnterpriseRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 分页查询信贷客户实体关联列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联VO分页结果
|
||||
*/
|
||||
Page<CcdiCustEnterpriseRelationVO> selectRelationPage(Page<CcdiCustEnterpriseRelationVO> page, CcdiCustEnterpriseRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联Excel实体集合
|
||||
*/
|
||||
List<CcdiCustEnterpriseRelationExcel> selectRelationListForExport(CcdiCustEnterpriseRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 信贷客户实体关联VO
|
||||
*/
|
||||
CcdiCustEnterpriseRelationVO selectRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 新增信贷客户实体关联
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int insertRelation(CcdiCustEnterpriseRelationAddDTO addDTO);
|
||||
|
||||
/**
|
||||
* 修改信贷客户实体关联
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int updateRelation(CcdiCustEnterpriseRelationEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 批量删除信贷客户实体关联
|
||||
*
|
||||
* @param ids 需要删除的主键ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRelationByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入信贷客户实体关联数据(异步)
|
||||
*
|
||||
* @param excelList Excel实体列表
|
||||
* @return 任务ID
|
||||
*/
|
||||
String importRelation(List<CcdiCustEnterpriseRelationExcel> excelList);
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.ccdi.domain.CcdiCustEnterpriseRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiCustEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CustEnterpriseRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportResult;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.mapper.CcdiCustEnterpriseRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiCustEnterpriseRelationImportService;
|
||||
import com.ruoyi.ccdi.utils.ImportLogUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息异步导入服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Service
|
||||
@EnableAsync
|
||||
public class CcdiCustEnterpriseRelationImportServiceImpl implements ICcdiCustEnterpriseRelationImportService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CcdiCustEnterpriseRelationImportServiceImpl.class);
|
||||
|
||||
@Resource
|
||||
private CcdiCustEnterpriseRelationMapper relationMapper;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
@Transactional
|
||||
public void importRelationAsync(List<CcdiCustEnterpriseRelationExcel> excelList, String taskId, String userName) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// 记录导入开始
|
||||
ImportLogUtils.logImportStart(log, taskId, "信贷客户实体关联", excelList.size(), userName);
|
||||
|
||||
List<CcdiCustEnterpriseRelation> newRecords = new ArrayList<>();
|
||||
List<CustEnterpriseRelationImportFailureVO> failures = new ArrayList<>();
|
||||
|
||||
// 【关键差异】不需要验证身份证号是否存在
|
||||
// 员工实体关系导入会验证身份证号是否存在于员工表,信贷客户实体关联不需要此验证
|
||||
|
||||
// 批量查询已存在的person_id + social_credit_code组合
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的客户企业关系组合", excelList.size());
|
||||
Set<String> existingCombinations = getExistingCombinations(excelList);
|
||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "客户企业关系组合", existingCombinations.size());
|
||||
|
||||
// 用于跟踪Excel文件内已处理的组合
|
||||
Set<String> processedCombinations = new HashSet<>();
|
||||
|
||||
// 分类数据
|
||||
for (int i = 0; i < excelList.size(); i++) {
|
||||
CcdiCustEnterpriseRelationExcel excel = excelList.get(i);
|
||||
|
||||
try {
|
||||
// 转换为AddDTO进行验证
|
||||
CcdiCustEnterpriseRelationAddDTO addDTO = new CcdiCustEnterpriseRelationAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
|
||||
// 验证数据(不验证身份证号是否存在)
|
||||
validateRelationData(addDTO);
|
||||
|
||||
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||
|
||||
CcdiCustEnterpriseRelation relation = new CcdiCustEnterpriseRelation();
|
||||
BeanUtils.copyProperties(excel, relation);
|
||||
|
||||
if (existingCombinations.contains(combination)) {
|
||||
// 组合已存在,直接报错
|
||||
throw new RuntimeException(String.format("身份证号[%s]和统一社会信用代码[%s]的组合已存在,请勿重复导入",
|
||||
excel.getPersonId(), excel.getSocialCreditCode()));
|
||||
} else if (processedCombinations.contains(combination)) {
|
||||
// Excel文件内部重复
|
||||
throw new RuntimeException(String.format("身份证号[%s]和统一社会信用代码[%s]的组合在导入文件中重复,已跳过此条记录",
|
||||
excel.getPersonId(), excel.getSocialCreditCode()));
|
||||
} else {
|
||||
relation.setCreatedBy(userName);
|
||||
relation.setUpdatedBy(userName);
|
||||
|
||||
// 设置默认值
|
||||
relation.setStatus(1);
|
||||
// 信贷客户实体关联的身份标识
|
||||
relation.setIsEmployee(0);
|
||||
relation.setIsEmpFamily(0);
|
||||
relation.setIsCustomer(0);
|
||||
relation.setIsCustFamily(1); // 信贷客户关联人标识为1
|
||||
relation.setDataSource("IMPORT");
|
||||
|
||||
newRecords.add(relation);
|
||||
processedCombinations.add(combination); // 标记为已处理
|
||||
}
|
||||
|
||||
// 记录进度
|
||||
ImportLogUtils.logProgress(log, taskId, i + 1, excelList.size(),
|
||||
newRecords.size(), failures.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
CustEnterpriseRelationImportFailureVO failure = new CustEnterpriseRelationImportFailureVO();
|
||||
BeanUtils.copyProperties(excel, failure);
|
||||
failure.setErrorMessage(e.getMessage());
|
||||
failures.add(failure);
|
||||
|
||||
// 记录验证失败日志
|
||||
String keyData = String.format("身份证号=%s, 统一社会信用代码=%s, 企业名称=%s",
|
||||
excel.getPersonId(), excel.getSocialCreditCode(), excel.getEnterpriseName());
|
||||
ImportLogUtils.logValidationError(log, taskId, i + 1, e.getMessage(), keyData);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量插入新数据
|
||||
if (!newRecords.isEmpty()) {
|
||||
ImportLogUtils.logBatchOperationStart(log, taskId, "插入",
|
||||
(newRecords.size() + 499) / 500, 500);
|
||||
saveBatch(newRecords, 500);
|
||||
}
|
||||
|
||||
// 保存失败记录到Redis
|
||||
if (!failures.isEmpty()) {
|
||||
try {
|
||||
String failuresKey = "import:custEnterpriseRelation:" + taskId + ":failures";
|
||||
redisTemplate.opsForValue().set(failuresKey, failures, 7, TimeUnit.DAYS);
|
||||
ImportLogUtils.logRedisOperation(log, taskId, "保存失败记录", failures.size());
|
||||
} catch (Exception e) {
|
||||
ImportLogUtils.logRedisError(log, taskId, "保存失败记录", e);
|
||||
}
|
||||
}
|
||||
|
||||
ImportResult result = new ImportResult();
|
||||
result.setTotalCount(excelList.size());
|
||||
result.setSuccessCount(newRecords.size());
|
||||
result.setFailureCount(failures.size());
|
||||
|
||||
// 更新最终状态
|
||||
String finalStatus = result.getFailureCount() == 0 ? "SUCCESS" : "PARTIAL_SUCCESS";
|
||||
updateImportStatus(taskId, finalStatus, result);
|
||||
|
||||
// 记录导入完成
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
ImportLogUtils.logImportComplete(log, taskId, "信贷客户实体关联",
|
||||
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入失败记录
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 失败记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<CustEnterpriseRelationImportFailureVO> getImportFailures(String taskId) {
|
||||
String key = "import:custEnterpriseRelation:" + taskId + ":failures";
|
||||
Object failuresObj = redisTemplate.opsForValue().get(key);
|
||||
|
||||
if (failuresObj == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return JSON.parseArray(JSON.toJSONString(failuresObj), CustEnterpriseRelationImportFailureVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 导入状态信息
|
||||
*/
|
||||
@Override
|
||||
public ImportStatusVO getImportStatus(String taskId) {
|
||||
String key = "import:custEnterpriseRelation:" + taskId;
|
||||
Boolean hasKey = redisTemplate.hasKey(key);
|
||||
|
||||
if (Boolean.FALSE.equals(hasKey)) {
|
||||
throw new RuntimeException("任务不存在或已过期");
|
||||
}
|
||||
|
||||
Map<Object, Object> statusMap = redisTemplate.opsForHash().entries(key);
|
||||
|
||||
ImportStatusVO statusVO = new ImportStatusVO();
|
||||
statusVO.setTaskId((String) statusMap.get("taskId"));
|
||||
statusVO.setStatus((String) statusMap.get("status"));
|
||||
statusVO.setTotalCount((Integer) statusMap.get("totalCount"));
|
||||
statusVO.setSuccessCount((Integer) statusMap.get("successCount"));
|
||||
statusVO.setFailureCount((Integer) statusMap.get("failureCount"));
|
||||
statusVO.setProgress((Integer) statusMap.get("progress"));
|
||||
statusVO.setStartTime((Long) statusMap.get("startTime"));
|
||||
statusVO.setEndTime((Long) statusMap.get("endTime"));
|
||||
statusVO.setMessage((String) statusMap.get("message"));
|
||||
|
||||
return statusVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导入状态
|
||||
*/
|
||||
private void updateImportStatus(String taskId, String status, ImportResult result) {
|
||||
String key = "import:custEnterpriseRelation:" + taskId;
|
||||
Map<String, Object> statusData = new HashMap<>();
|
||||
statusData.put("status", status);
|
||||
statusData.put("successCount", result.getSuccessCount());
|
||||
statusData.put("failureCount", result.getFailureCount());
|
||||
statusData.put("progress", 100);
|
||||
statusData.put("endTime", System.currentTimeMillis());
|
||||
|
||||
if ("SUCCESS".equals(status)) {
|
||||
statusData.put("message", "全部成功!共导入" + result.getTotalCount() + "条数据");
|
||||
} else {
|
||||
statusData.put("message", "成功" + result.getSuccessCount() + "条,失败" + result.getFailureCount() + "条");
|
||||
}
|
||||
|
||||
redisTemplate.opsForHash().putAll(key, statusData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询已存在的person_id + social_credit_code组合
|
||||
* 性能优化:一次性查询所有组合,避免N+1查询问题
|
||||
*
|
||||
* @param excelList Excel导入数据列表
|
||||
* @return 已存在的组合集合
|
||||
*/
|
||||
private Set<String> getExistingCombinations(List<CcdiCustEnterpriseRelationExcel> excelList) {
|
||||
// 提取所有的person_id和social_credit_code组合
|
||||
List<String> combinations = excelList.stream()
|
||||
.map(excel -> excel.getPersonId() + "|" + excel.getSocialCreditCode())
|
||||
.filter(Objects::nonNull)
|
||||
.distinct() // 去重
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (combinations.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
// 一次性查询所有已存在的组合
|
||||
// 优化前:循环调用existsByPersonIdAndSocialCreditCode,N次数据库查询
|
||||
// 优化后:批量查询,1次数据库查询
|
||||
return new HashSet<>(relationMapper.batchExistsByCombinations(combinations));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*/
|
||||
private void saveBatch(List<CcdiCustEnterpriseRelation> list, int batchSize) {
|
||||
// 使用真正的批量插入,分批次执行以提高性能
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, list.size());
|
||||
List<CcdiCustEnterpriseRelation> subList = list.subList(i, end);
|
||||
relationMapper.insertBatch(subList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证信贷客户实体关联数据
|
||||
* 【关键差异】不验证身份证号是否存在于员工表
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
*/
|
||||
private void validateRelationData(CcdiCustEnterpriseRelationAddDTO addDTO) {
|
||||
// 验证必填字段
|
||||
if (StringUtils.isEmpty(addDTO.getPersonId())) {
|
||||
throw new RuntimeException("身份证号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getSocialCreditCode())) {
|
||||
throw new RuntimeException("统一社会信用代码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getEnterpriseName())) {
|
||||
throw new RuntimeException("企业名称不能为空");
|
||||
}
|
||||
|
||||
// 验证身份证号格式(18位)
|
||||
if (!addDTO.getPersonId().matches("^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$")) {
|
||||
throw new RuntimeException("身份证号格式不正确,必须为18位有效身份证号");
|
||||
}
|
||||
|
||||
// 验证统一社会信用代码格式(18位)
|
||||
if (!addDTO.getSocialCreditCode().matches("^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$")) {
|
||||
throw new RuntimeException("统一社会信用代码格式不正确,必须为18位有效统一社会信用代码");
|
||||
}
|
||||
|
||||
// 验证字段长度
|
||||
if (StringUtils.isNotEmpty(addDTO.getRelationPersonPost()) && addDTO.getRelationPersonPost().length() > 100) {
|
||||
throw new RuntimeException("关联人在企业的职务长度不能超过100个字符");
|
||||
}
|
||||
if (addDTO.getEnterpriseName().length() > 200) {
|
||||
throw new RuntimeException("企业名称长度不能超过200个字符");
|
||||
}
|
||||
|
||||
// 【注意】不验证身份证号是否存在于员工表
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.CcdiCustEnterpriseRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiCustEnterpriseRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiCustEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiCustEnterpriseRelationVO;
|
||||
import com.ruoyi.ccdi.mapper.CcdiCustEnterpriseRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiCustEnterpriseRelationImportService;
|
||||
import com.ruoyi.ccdi.service.ICcdiCustEnterpriseRelationService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 信贷客户实体关联信息 服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Service
|
||||
public class CcdiCustEnterpriseRelationServiceImpl implements ICcdiCustEnterpriseRelationService {
|
||||
|
||||
@Resource
|
||||
private CcdiCustEnterpriseRelationMapper relationMapper;
|
||||
|
||||
@Resource
|
||||
private ICcdiCustEnterpriseRelationImportService relationImportService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联列表
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联VO集合
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<CcdiCustEnterpriseRelationVO> selectRelationList(CcdiCustEnterpriseRelationQueryDTO queryDTO) {
|
||||
Page<CcdiCustEnterpriseRelationVO> page = new Page<>(1, Integer.MAX_VALUE);
|
||||
Page<CcdiCustEnterpriseRelationVO> resultPage = relationMapper.selectRelationPage(page, queryDTO);
|
||||
return resultPage.getRecords();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信贷客户实体关联列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联VO分页结果
|
||||
*/
|
||||
@Override
|
||||
public Page<CcdiCustEnterpriseRelationVO> selectRelationPage(Page<CcdiCustEnterpriseRelationVO> page, CcdiCustEnterpriseRelationQueryDTO queryDTO) {
|
||||
return relationMapper.selectRelationPage(page, queryDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 信贷客户实体关联Excel实体集合
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<CcdiCustEnterpriseRelationExcel> selectRelationListForExport(CcdiCustEnterpriseRelationQueryDTO queryDTO) {
|
||||
Page<CcdiCustEnterpriseRelationVO> page = new Page<>(1, Integer.MAX_VALUE);
|
||||
Page<CcdiCustEnterpriseRelationVO> resultPage = relationMapper.selectRelationPage(page, queryDTO);
|
||||
|
||||
return resultPage.getRecords().stream().map(vo -> {
|
||||
CcdiCustEnterpriseRelationExcel excel = new CcdiCustEnterpriseRelationExcel();
|
||||
BeanUtils.copyProperties(vo, excel);
|
||||
return excel;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询信贷客户实体关联详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 信贷客户实体关联VO
|
||||
*/
|
||||
@Override
|
||||
public CcdiCustEnterpriseRelationVO selectRelationById(Long id) {
|
||||
return relationMapper.selectRelationById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增信贷客户实体关联
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertRelation(CcdiCustEnterpriseRelationAddDTO addDTO) {
|
||||
// 检查身份证号+统一社会信用代码唯一性
|
||||
if (relationMapper.existsByPersonIdAndSocialCreditCode(addDTO.getPersonId(), addDTO.getSocialCreditCode())) {
|
||||
throw new RuntimeException("该身份证号和统一社会信用代码组合已存在");
|
||||
}
|
||||
|
||||
CcdiCustEnterpriseRelation relation = new CcdiCustEnterpriseRelation();
|
||||
BeanUtils.copyProperties(addDTO, relation);
|
||||
|
||||
// 设置默认值
|
||||
// 新增时强制设置状态为有效
|
||||
relation.setStatus(1);
|
||||
|
||||
// 信贷客户实体关联的身份标识默认值
|
||||
if (relation.getIsEmployee() == null) {
|
||||
relation.setIsEmployee(0);
|
||||
}
|
||||
if (relation.getIsEmpFamily() == null) {
|
||||
relation.setIsEmpFamily(0);
|
||||
}
|
||||
if (relation.getIsCustomer() == null) {
|
||||
relation.setIsCustomer(0);
|
||||
}
|
||||
if (relation.getIsCustFamily() == null) {
|
||||
relation.setIsCustFamily(1); // 信贷客户关联人标识为1
|
||||
}
|
||||
if (StringUtils.isEmpty(relation.getDataSource())) {
|
||||
relation.setDataSource("MANUAL");
|
||||
}
|
||||
|
||||
int result = relationMapper.insert(relation);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改信贷客户实体关联
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRelation(CcdiCustEnterpriseRelationEditDTO editDTO) {
|
||||
// 使用LambdaUpdateWrapper只更新非null字段,保护系统字段不被覆盖
|
||||
LambdaUpdateWrapper<CcdiCustEnterpriseRelation> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CcdiCustEnterpriseRelation::getId, editDTO.getId());
|
||||
|
||||
// 只更新前端可编辑的字段
|
||||
updateWrapper.set(editDTO.getRelationPersonPost() != null, CcdiCustEnterpriseRelation::getRelationPersonPost, editDTO.getRelationPersonPost());
|
||||
updateWrapper.set(editDTO.getEnterpriseName() != null, CcdiCustEnterpriseRelation::getEnterpriseName, editDTO.getEnterpriseName());
|
||||
updateWrapper.set(editDTO.getStatus() != null, CcdiCustEnterpriseRelation::getStatus, editDTO.getStatus());
|
||||
updateWrapper.set(editDTO.getRemark() != null, CcdiCustEnterpriseRelation::getRemark, editDTO.getRemark());
|
||||
|
||||
// 注意:以下字段不可修改
|
||||
// - personId(身份证号,业务主键)
|
||||
// - socialCreditCode(统一社会信用代码,业务主键)
|
||||
// - dataSource(数据来源,系统字段)
|
||||
// - isEmployee(是否为员工,系统字段)
|
||||
// - isEmpFamily(是否为员工家属,系统字段)
|
||||
// - isCustomer(是否为客户,系统字段)
|
||||
// - isCustFamily(是否为客户家属,系统字段)
|
||||
|
||||
int result = relationMapper.update(null, updateWrapper);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除信贷客户实体关联
|
||||
*
|
||||
* @param ids 需要删除的主键ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRelationByIds(Long[] ids) {
|
||||
return relationMapper.deleteBatchIds(java.util.List.of(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入信贷客户实体关联数据(异步)
|
||||
*
|
||||
* @param excelList Excel实体列表
|
||||
* @return 任务ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public String importRelation(java.util.List<CcdiCustEnterpriseRelationExcel> excelList) {
|
||||
if (StringUtils.isNull(excelList) || excelList.isEmpty()) {
|
||||
throw new RuntimeException("至少需要一条数据");
|
||||
}
|
||||
|
||||
// 生成任务ID
|
||||
String taskId = UUID.randomUUID().toString();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// 获取当前用户名
|
||||
String userName = SecurityUtils.getUsername();
|
||||
|
||||
// 初始化Redis状态
|
||||
String statusKey = "import:custEnterpriseRelation:" + taskId;
|
||||
Map<String, Object> statusData = new HashMap<>();
|
||||
statusData.put("taskId", taskId);
|
||||
statusData.put("status", "PROCESSING");
|
||||
statusData.put("totalCount", excelList.size());
|
||||
statusData.put("successCount", 0);
|
||||
statusData.put("failureCount", 0);
|
||||
statusData.put("progress", 0);
|
||||
statusData.put("startTime", startTime);
|
||||
statusData.put("message", "正在处理...");
|
||||
|
||||
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
||||
redisTemplate.expire(statusKey, 7, TimeUnit.DAYS);
|
||||
|
||||
// 调用异步导入服务
|
||||
relationImportService.importRelationAsync(excelList, taskId, userName);
|
||||
|
||||
return taskId;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.ccdi.domain.CcdiBaseStaff;
|
||||
import com.ruoyi.ccdi.domain.CcdiStaffEnterpriseRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportResult;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.domain.vo.StaffEnterpriseRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.mapper.CcdiBaseStaffMapper;
|
||||
import com.ruoyi.ccdi.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffEnterpriseRelationImportService;
|
||||
import com.ruoyi.ccdi.utils.ImportLogUtils;
|
||||
@@ -43,6 +46,9 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private CcdiBaseStaffMapper baseStaffMapper;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
@Transactional
|
||||
@@ -55,6 +61,28 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
||||
List<CcdiStaffEnterpriseRelation> newRecords = new ArrayList<>();
|
||||
List<StaffEnterpriseRelationImportFailureVO> failures = new ArrayList<>();
|
||||
|
||||
// 批量验证员工身份证号是否存在
|
||||
Set<String> excelPersonIds = excelList.stream()
|
||||
.map(CcdiStaffEnterpriseRelationExcel::getPersonId)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> existingPersonIds = new HashSet<>();
|
||||
if (!excelPersonIds.isEmpty()) {
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "员工身份证号", excelPersonIds.size());
|
||||
|
||||
LambdaQueryWrapper<CcdiBaseStaff> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(CcdiBaseStaff::getIdCard)
|
||||
.in(CcdiBaseStaff::getIdCard, excelPersonIds);
|
||||
|
||||
List<CcdiBaseStaff> existingStaff = baseStaffMapper.selectList(wrapper);
|
||||
existingPersonIds = existingStaff.stream()
|
||||
.map(CcdiBaseStaff::getIdCard)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工身份证号", existingPersonIds.size());
|
||||
}
|
||||
|
||||
// 批量查询已存在的person_id + social_credit_code组合
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的员工企业关系组合", excelList.size());
|
||||
Set<String> existingCombinations = getExistingCombinations(excelList);
|
||||
@@ -75,6 +103,13 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
||||
// 验证数据
|
||||
validateRelationData(addDTO);
|
||||
|
||||
// 身份证号存在性检查(在基本验证之后)
|
||||
if (!existingPersonIds.contains(excel.getPersonId())) {
|
||||
throw new RuntimeException(String.format(
|
||||
"第%d行: 身份证号[%s]不存在于员工信息表中,请先添加员工信息",
|
||||
i + 1, excel.getPersonId()));
|
||||
}
|
||||
|
||||
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||
|
||||
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.ccdi.domain.CcdiBaseStaff;
|
||||
import com.ruoyi.ccdi.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
@@ -8,6 +10,7 @@ import com.ruoyi.ccdi.domain.vo.ImportResult;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.domain.vo.StaffFmyRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.enums.GenderEnum;
|
||||
import com.ruoyi.ccdi.mapper.CcdiBaseStaffMapper;
|
||||
import com.ruoyi.ccdi.mapper.CcdiStaffFmyRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationImportService;
|
||||
import com.ruoyi.ccdi.utils.ImportLogUtils;
|
||||
@@ -24,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工亲属关系异步导入服务层处理
|
||||
@@ -43,6 +47,9 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private CcdiBaseStaffMapper baseStaffMapper;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
@Transactional
|
||||
@@ -55,14 +62,32 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
||||
List<CcdiStaffFmyRelation> newRecords = new ArrayList<>();
|
||||
List<StaffFmyRelationImportFailureVO> failures = new ArrayList<>();
|
||||
|
||||
// 批量验证员工身份证号是否存在
|
||||
Set<String> excelPersonIds = excelList.stream()
|
||||
.map(CcdiStaffFmyRelationExcel::getPersonId)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> existingPersonIds = new HashSet<>();
|
||||
if (!excelPersonIds.isEmpty()) {
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "员工身份证号", excelPersonIds.size());
|
||||
|
||||
LambdaQueryWrapper<CcdiBaseStaff> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(CcdiBaseStaff::getIdCard)
|
||||
.in(CcdiBaseStaff::getIdCard, excelPersonIds);
|
||||
|
||||
List<CcdiBaseStaff> existingStaff = baseStaffMapper.selectList(wrapper);
|
||||
existingPersonIds = existingStaff.stream()
|
||||
.map(CcdiBaseStaff::getIdCard)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工身份证号", existingPersonIds.size());
|
||||
}
|
||||
|
||||
// ========== 第一步:批量唯一性校验 ==========
|
||||
// 1. 提取Excel中所有的personId和relationCertNo
|
||||
Set<String> excelPersonIds = new HashSet<>();
|
||||
// 1. 提取Excel中所有的relationCertNo(personId已在前面提取)
|
||||
Set<String> excelRelationCertNos = new HashSet<>();
|
||||
for (CcdiStaffFmyRelationExcel excel : excelList) {
|
||||
if (StringUtils.isNotEmpty(excel.getPersonId())) {
|
||||
excelPersonIds.add(excel.getPersonId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(excel.getRelationCertNo())) {
|
||||
excelRelationCertNos.add(excel.getRelationCertNo());
|
||||
}
|
||||
@@ -70,7 +95,7 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
||||
|
||||
// 2. 批量查询数据库中已存在的记录
|
||||
Set<String> existingKeys = new HashSet<>();
|
||||
if (!excelPersonIds.isEmpty() && !excelRelationCertNos.isEmpty()) {
|
||||
if (!excelRelationCertNos.isEmpty()) {
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的亲属关系", excelList.size());
|
||||
List<CcdiStaffFmyRelation> existingRecords = relationMapper.selectExistingRelations(
|
||||
new ArrayList<>(excelPersonIds),
|
||||
@@ -100,6 +125,13 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
||||
// 验证数据
|
||||
validateRelationData(addDTO);
|
||||
|
||||
// 身份证号存在性检查(在基本验证之后)
|
||||
if (!existingPersonIds.contains(excel.getPersonId())) {
|
||||
throw new RuntimeException(String.format(
|
||||
"第%d行: 身份证号[%s]不存在于员工信息表中,请先添加员工信息",
|
||||
i + 1, excel.getPersonId()));
|
||||
}
|
||||
|
||||
// 生成唯一键
|
||||
String uniqueKey = excel.getPersonId() + "|" + excel.getRelationCertNo();
|
||||
|
||||
|
||||
@@ -65,8 +65,27 @@ public class CcdiStaffTransferImportServiceImpl implements ICcdiStaffTransferImp
|
||||
List<CcdiStaffTransfer> newRecords = new ArrayList<>();
|
||||
List<StaffTransferImportFailureVO> failures = new ArrayList<>();
|
||||
|
||||
// 批量验证员工ID是否存在
|
||||
Set<Long> existingStaffIds = batchValidateStaffIds(excelList, taskId, failures);
|
||||
// 批量查询员工ID存在性
|
||||
Set<Long> excelStaffIds = excelList.stream()
|
||||
.map(CcdiStaffTransferExcel::getStaffId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<Long> existingStaffIds = new HashSet<>();
|
||||
if (!excelStaffIds.isEmpty()) {
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "员工ID", excelStaffIds.size());
|
||||
|
||||
LambdaQueryWrapper<CcdiBaseStaff> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(CcdiBaseStaff::getStaffId)
|
||||
.in(CcdiBaseStaff::getStaffId, excelStaffIds);
|
||||
|
||||
List<CcdiBaseStaff> existingStaff = baseStaffMapper.selectList(wrapper);
|
||||
existingStaffIds = existingStaff.stream()
|
||||
.map(CcdiBaseStaff::getStaffId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工ID", existingStaffIds.size());
|
||||
}
|
||||
|
||||
// 批量查询已存在的唯一键组合
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的调动记录", excelList.size());
|
||||
@@ -80,12 +99,14 @@ public class CcdiStaffTransferImportServiceImpl implements ICcdiStaffTransferImp
|
||||
for (int i = 0; i < excelList.size(); i++) {
|
||||
CcdiStaffTransferExcel excel = excelList.get(i);
|
||||
|
||||
// 跳过已在预验证阶段失败的记录
|
||||
if (isRowAlreadyFailed(excel, failures)) {
|
||||
continue;
|
||||
try {
|
||||
// 员工ID存在性检查
|
||||
if (excel.getStaffId() != null && !existingStaffIds.contains(excel.getStaffId())) {
|
||||
throw new RuntimeException(String.format(
|
||||
"第%d行: 员工ID %s 不存在",
|
||||
i + 1, excel.getStaffId()));
|
||||
}
|
||||
|
||||
try {
|
||||
// 转换为AddDTO进行验证
|
||||
CcdiStaffTransferAddDTO addDTO = new CcdiStaffTransferAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
@@ -356,75 +377,4 @@ public class CcdiStaffTransferImportServiceImpl implements ICcdiStaffTransferImp
|
||||
|
||||
return JSON.parseArray(JSON.toJSONString(failuresObj), StaffTransferImportFailureVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量验证员工ID是否存在
|
||||
*
|
||||
* @param excelList Excel数据列表
|
||||
* @param taskId 任务ID
|
||||
* @param failures 失败记录列表(会追加验证失败的记录)
|
||||
* @return 存在的员工ID集合
|
||||
*/
|
||||
private Set<Long> batchValidateStaffIds(List<CcdiStaffTransferExcel> excelList,
|
||||
String taskId,
|
||||
List<StaffTransferImportFailureVO> failures) {
|
||||
// 1. 提取并去重员工ID
|
||||
Set<Long> allStaffIds = excelList.stream()
|
||||
.map(CcdiStaffTransferExcel::getStaffId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (allStaffIds.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
// 2. 批量查询存在的员工ID
|
||||
ImportLogUtils.logBatchQueryStart(log, taskId, "员工ID", allStaffIds.size());
|
||||
|
||||
LambdaQueryWrapper<CcdiBaseStaff> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(CcdiBaseStaff::getStaffId)
|
||||
.in(CcdiBaseStaff::getStaffId, allStaffIds);
|
||||
|
||||
List<CcdiBaseStaff> existingStaff = baseStaffMapper.selectList(wrapper);
|
||||
Set<Long> existingStaffIds = existingStaff.stream()
|
||||
.map(CcdiBaseStaff::getStaffId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工ID", existingStaffIds.size());
|
||||
|
||||
// 3. 预验证并标记不存在的员工ID
|
||||
for (int i = 0; i < excelList.size(); i++) {
|
||||
CcdiStaffTransferExcel excel = excelList.get(i);
|
||||
Long staffId = excel.getStaffId();
|
||||
|
||||
if (staffId != null && !existingStaffIds.contains(staffId)) {
|
||||
StaffTransferImportFailureVO failure = new StaffTransferImportFailureVO();
|
||||
BeanUtils.copyProperties(excel, failure);
|
||||
failure.setErrorMessage(String.format("第%d行: 员工ID %s 不存在", i + 1, staffId));
|
||||
failures.add(failure);
|
||||
|
||||
String keyData = String.format("员工ID=%s", staffId);
|
||||
ImportLogUtils.logValidationError(log, taskId, i + 1,
|
||||
failure.getErrorMessage(), keyData);
|
||||
}
|
||||
}
|
||||
|
||||
return existingStaffIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查某行数据是否已在失败列表中
|
||||
*
|
||||
* @param excel Excel数据
|
||||
* @param failures 失败记录列表
|
||||
* @return true-已失败,false-未失败
|
||||
*/
|
||||
private boolean isRowAlreadyFailed(CcdiStaffTransferExcel excel,
|
||||
List<StaffTransferImportFailureVO> failures) {
|
||||
return failures.stream()
|
||||
.anyMatch(f -> Objects.equals(f.getStaffId(), excel.getStaffId())
|
||||
&& Objects.equals(f.getTransferDate(), excel.getTransferDate())
|
||||
&& Objects.equals(f.getDeptIdBefore(), excel.getDeptIdBefore())
|
||||
&& Objects.equals(f.getDeptIdAfter(), excel.getDeptIdAfter()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ccdi.mapper.CcdiCustEnterpriseRelationMapper">
|
||||
|
||||
<!-- 信贷客户实体关联信息ResultMap -->
|
||||
<resultMap type="com.ruoyi.ccdi.domain.vo.CcdiCustEnterpriseRelationVO" id="CcdiCustEnterpriseRelationVOResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="personId" column="person_id"/>
|
||||
<result property="relationPersonPost" column="relation_person_post"/>
|
||||
<result property="socialCreditCode" column="social_credit_code"/>
|
||||
<result property="enterpriseName" column="enterprise_name"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="dataSource" column="data_source"/>
|
||||
<result property="isEmployee" column="is_employee"/>
|
||||
<result property="isEmpFamily" column="is_emp_family"/>
|
||||
<result property="isCustomer" column="is_customer"/>
|
||||
<result property="isCustFamily" column="is_cust_family"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="createdBy" column="created_by"/>
|
||||
<result property="updatedBy" column="updated_by"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询信贷客户实体关联列表 -->
|
||||
<select id="selectRelationPage" resultMap="CcdiCustEnterpriseRelationVOResult">
|
||||
SELECT
|
||||
id, person_id, relation_person_post,
|
||||
social_credit_code, enterprise_name, status, remark,
|
||||
data_source, is_employee, is_emp_family, is_customer,
|
||||
is_cust_family, created_by, create_time, updated_by,
|
||||
update_time
|
||||
FROM ccdi_cust_enterprise_relation
|
||||
<where>
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND person_id LIKE CONCAT('%', #{query.personId}, '%')
|
||||
</if>
|
||||
<if test="query.socialCreditCode != null and query.socialCreditCode != ''">
|
||||
AND social_credit_code LIKE CONCAT('%', #{query.socialCreditCode}, '%')
|
||||
</if>
|
||||
<if test="query.enterpriseName != null and query.enterpriseName != ''">
|
||||
AND enterprise_name LIKE CONCAT('%', #{query.enterpriseName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND status = #{query.status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询信贷客户实体关联详情 -->
|
||||
<select id="selectRelationById" resultMap="CcdiCustEnterpriseRelationVOResult">
|
||||
SELECT
|
||||
id, person_id, relation_person_post,
|
||||
social_credit_code, enterprise_name, status, remark,
|
||||
data_source, is_employee, is_emp_family, is_customer,
|
||||
is_cust_family, created_by, create_time, updated_by,
|
||||
update_time
|
||||
FROM ccdi_cust_enterprise_relation
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 判断身份证号和统一社会信用代码的组合是否已存在 -->
|
||||
<select id="existsByPersonIdAndSocialCreditCode" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM ccdi_cust_enterprise_relation
|
||||
WHERE person_id = #{personId}
|
||||
AND social_credit_code = #{socialCreditCode}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询已存在的person_id + social_credit_code组合 -->
|
||||
<!-- 优化导入性能:一次性查询所有组合,避免N+1查询问题 -->
|
||||
<select id="batchExistsByCombinations" resultType="string">
|
||||
SELECT CONCAT(person_id, '|', social_credit_code) AS combination
|
||||
FROM ccdi_cust_enterprise_relation
|
||||
WHERE CONCAT(person_id, '|', social_credit_code) IN
|
||||
<foreach collection="combinations" item="combination" open="(" separator="," close=")">
|
||||
#{combination}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入信贷客户实体关联数据 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO ccdi_cust_enterprise_relation
|
||||
(person_id, relation_person_post, social_credit_code, enterprise_name,
|
||||
status, remark, data_source, is_employee, is_emp_family, is_customer, is_cust_family,
|
||||
created_by, create_time, updated_by, update_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.personId}, #{item.relationPersonPost}, #{item.socialCreditCode}, #{item.enterpriseName},
|
||||
#{item.status}, #{item.remark}, #{item.dataSource}, #{item.isEmployee}, #{item.isEmpFamily}, #{item.isCustomer}, #{item.isCustFamily},
|
||||
#{item.createdBy}, NOW(), #{item.updatedBy}, NOW())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -45,7 +45,7 @@
|
||||
FROM ccdi_cust_fmy_relation r
|
||||
WHERE r.is_cust_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
AND r.person_id LIKE CONCAT('%', #{query.personId}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
|
||||
89
ruoyi-ui/src/api/ccdiCustEnterpriseRelation.js
Normal file
89
ruoyi-ui/src/api/ccdiCustEnterpriseRelation.js
Normal file
@@ -0,0 +1,89 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询信贷客户实体关联列表
|
||||
export function listRelation(query) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询信贷客户实体关联详情
|
||||
export function getRelation(id) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增信贷客户实体关联
|
||||
export function addRelation(data) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改信贷客户实体关联
|
||||
export function updateRelation(data) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除信贷客户实体关联
|
||||
export function delRelation(ids) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/' + ids,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出信贷客户实体关联
|
||||
export function exportRelation(query) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/export',
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 下载导入模板
|
||||
export function importTemplate() {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/importTemplate',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
// 导入信贷客户实体关联
|
||||
export function importData(file) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/importData',
|
||||
method: 'post',
|
||||
data: formData
|
||||
})
|
||||
}
|
||||
|
||||
// 查询导入状态
|
||||
export function getImportStatus(taskId) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/importStatus/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询导入失败记录
|
||||
export function getImportFailures(taskId, pageNum, pageSize) {
|
||||
return request({
|
||||
url: '/ccdi/custEnterpriseRelation/importFailures/' + taskId,
|
||||
method: 'get',
|
||||
params: { pageNum, pageSize }
|
||||
})
|
||||
}
|
||||
855
ruoyi-ui/src/views/ccdiCustEnterpriseRelation/index.vue
Normal file
855
ruoyi-ui/src/views/ccdiCustEnterpriseRelation/index.vue
Normal file
@@ -0,0 +1,855 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
|
||||
<el-form-item label="身份证号" prop="personId">
|
||||
<el-input
|
||||
v-model="queryParams.personId"
|
||||
placeholder="请输入身份证号"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
||||
<el-input
|
||||
v-model="queryParams.socialCreditCode"
|
||||
placeholder="请输入统一社会信用代码"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="企业名称" prop="enterpriseName">
|
||||
<el-input
|
||||
v-model="queryParams.enterpriseName"
|
||||
placeholder="请输入企业名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 240px">
|
||||
<el-option label="有效" :value="1" />
|
||||
<el-option label="无效" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:import']"
|
||||
>导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5" v-if="showFailureButton">
|
||||
<el-tooltip
|
||||
:content="getLastImportTooltip()"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-warning"
|
||||
size="mini"
|
||||
@click="viewImportFailures"
|
||||
>查看导入失败记录</el-button>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="relationList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="身份证号" align="center" prop="personId" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="企业名称" align="center" prop="enterpriseName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="关联人在企业的职务" align="center" prop="relationPersonPost" width="150" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.ccdi_relation_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数据来源" align="center" prop="dataSource" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.ccdi_data_source" :value="scope.row.dataSource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-view"
|
||||
@click="handleDetail(scope.row)"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:query']"
|
||||
>详情</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:edit']"
|
||||
>编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['ccdi:custEnterpriseRelation:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="160px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="身份证号" prop="personId">
|
||||
<el-input
|
||||
v-model="form.personId"
|
||||
placeholder="请输入18位身份证号"
|
||||
maxlength="18"
|
||||
:disabled="!isAdd"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
||||
<el-input v-model="form.socialCreditCode" placeholder="请输入18位统一社会信用代码" maxlength="18" :disabled="!isAdd" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="企业名称" prop="enterpriseName">
|
||||
<el-input v-model="form.enterpriseName" placeholder="请输入企业名称" maxlength="200" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关联人在企业的职务" prop="relationPersonPost">
|
||||
<el-input v-model="form.relationPersonPost" placeholder="请输入职务" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="!isAdd">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态">
|
||||
<el-option label="有效" :value="1" />
|
||||
<el-option label="无效" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="补充说明" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入补充说明" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 详情对话框 -->
|
||||
<el-dialog title="信贷客户实体关联详情" :visible.sync="detailOpen" width="900px" append-to-body>
|
||||
<div class="detail-container">
|
||||
<el-divider content-position="left">基本信息</el-divider>
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="身份证号">{{ relationDetail.personId || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="统一社会信用代码">{{ relationDetail.socialCreditCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="企业名称" :span="2">{{ relationDetail.enterpriseName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="关联人在企业的职务">{{ relationDetail.relationPersonPost || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<dict-tag :options="dict.type.ccdi_relation_status" :value="relationDetail.status"/>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="数据来源">
|
||||
<dict-tag :options="dict.type.ccdi_data_source" :value="relationDetail.dataSource"/>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">补充信息</el-divider>
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="补充说明">{{ relationDetail.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">审计信息</el-divider>
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ relationDetail.createTime ? parseTime(relationDetail.createTime) : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">{{ relationDetail.createdBy || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ relationDetail.updateTime ? parseTime(relationDetail.updateTime) : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新人">{{ relationDetail.updatedBy || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="detailOpen = false" icon="el-icon-close">关 闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog
|
||||
:title="upload.title"
|
||||
:visible.sync="upload.open"
|
||||
width="400px"
|
||||
append-to-body
|
||||
@close="handleImportDialogClose"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:limit="1"
|
||||
accept=".xlsx, .xls"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<span>仅允许导入"xls"或"xlsx"格式文件。</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm" :loading="upload.isUploading">确 定</el-button>
|
||||
<el-button @click="upload.open = false" :disabled="upload.isUploading">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入结果对话框 -->
|
||||
<import-result-dialog
|
||||
:visible.sync="importResultVisible"
|
||||
:content="importResultContent"
|
||||
title="导入结果"
|
||||
@close="handleImportResultClose"
|
||||
/>
|
||||
|
||||
<!-- 导入失败记录对话框 -->
|
||||
<el-dialog
|
||||
title="导入失败记录"
|
||||
:visible.sync="failureDialogVisible"
|
||||
width="1200px"
|
||||
append-to-body
|
||||
>
|
||||
<el-alert
|
||||
v-if="lastImportInfo"
|
||||
:title="lastImportInfo"
|
||||
type="info"
|
||||
:closable="false"
|
||||
style="margin-bottom: 15px"
|
||||
/>
|
||||
|
||||
<el-table :data="failureList" v-loading="failureLoading">
|
||||
<el-table-column label="身份证号" prop="personId" align="center" width="180" />
|
||||
<el-table-column label="企业名称" prop="enterpriseName" align="center" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="统一社会信用代码" prop="socialCreditCode" align="center" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="失败原因" prop="errorMessage" align="center" min-width="200" :show-overflow-tooltip="true" />
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="failureTotal > 0"
|
||||
:total="failureTotal"
|
||||
:page.sync="failureQueryParams.pageNum"
|
||||
:limit.sync="failureQueryParams.pageSize"
|
||||
@pagination="getFailureList"
|
||||
/>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="failureDialogVisible = false">关闭</el-button>
|
||||
<el-button type="danger" plain @click="clearImportHistory">清除历史记录</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addRelation,
|
||||
delRelation,
|
||||
getImportFailures,
|
||||
getImportStatus,
|
||||
getRelation,
|
||||
listRelation,
|
||||
updateRelation
|
||||
} from "@/api/ccdiCustEnterpriseRelation";
|
||||
import {getToken} from "@/utils/auth";
|
||||
import ImportResultDialog from "@/components/ImportResultDialog.vue";
|
||||
|
||||
export default {
|
||||
name: "CustEnterpriseRelation",
|
||||
dicts: ['ccdi_relation_status', 'ccdi_data_source'],
|
||||
components: { ImportResultDialog },
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 信贷客户实体关联表格数据
|
||||
relationList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否显示详情弹出层
|
||||
detailOpen: false,
|
||||
// 信贷客户实体关联详情
|
||||
relationDetail: {},
|
||||
// 是否为新增操作
|
||||
isAdd: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
personId: null,
|
||||
socialCreditCode: null,
|
||||
enterpriseName: null,
|
||||
status: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
personId: [
|
||||
{ required: true, message: "身份证号不能为空", trigger: "blur" },
|
||||
{ pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: "请输入正确的18位身份证号", trigger: "blur" }
|
||||
],
|
||||
socialCreditCode: [
|
||||
{ required: true, message: "统一社会信用代码不能为空", trigger: "blur" },
|
||||
{ pattern: /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/, message: "请输入正确的18位统一社会信用代码", trigger: "blur" }
|
||||
],
|
||||
enterpriseName: [
|
||||
{ required: true, message: "企业名称不能为空", trigger: "blur" },
|
||||
{ max: 200, message: "企业名称长度不能超过200个字符", trigger: "blur" }
|
||||
],
|
||||
relationPersonPost: [
|
||||
{ max: 100, message: "职务长度不能超过100个字符", trigger: "blur" }
|
||||
],
|
||||
status: [
|
||||
{ required: true, message: "状态不能为空", trigger: "change" }
|
||||
],
|
||||
remark: [
|
||||
{ max: 500, message: "补充说明长度不能超过500个字符", trigger: "blur" }
|
||||
]
|
||||
},
|
||||
// 导入参数
|
||||
upload: {
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/ccdi/custEnterpriseRelation/importData"
|
||||
},
|
||||
// 导入结果弹窗
|
||||
importResultVisible: false,
|
||||
importResultContent: "",
|
||||
// 导入轮询定时器
|
||||
importPollingTimer: null,
|
||||
// 是否显示查看失败记录按钮
|
||||
showFailureButton: false,
|
||||
// 当前导入任务ID
|
||||
currentTaskId: null,
|
||||
// 失败记录对话框
|
||||
failureDialogVisible: false,
|
||||
failureList: [],
|
||||
failureLoading: false,
|
||||
failureTotal: 0,
|
||||
failureQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* 上次导入信息摘要
|
||||
*/
|
||||
lastImportInfo() {
|
||||
const savedTask = this.getImportTaskFromStorage();
|
||||
if (savedTask && savedTask.totalCount) {
|
||||
return `导入时间: ${this.parseTime(savedTask.saveTime)} | 总数: ${savedTask.totalCount}条 | 成功: ${savedTask.successCount}条 | 失败: ${savedTask.failureCount}条`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.restoreImportState();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 清理定时器
|
||||
if (this.importPollingTimer) {
|
||||
clearInterval(this.importPollingTimer);
|
||||
this.importPollingTimer = null;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 查询信贷客户实体关联列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listRelation(this.queryParams).then(response => {
|
||||
this.relationList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
personId: null,
|
||||
relationPersonPost: null,
|
||||
socialCreditCode: null,
|
||||
enterpriseName: null,
|
||||
status: 1,
|
||||
remark: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 多选框选中数据 */
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加信贷客户实体关联";
|
||||
this.isAdd = true;
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids[0];
|
||||
getRelation(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改信贷客户实体关联";
|
||||
this.isAdd = false;
|
||||
});
|
||||
},
|
||||
/** 详情按钮操作 */
|
||||
handleDetail(row) {
|
||||
const id = row.id;
|
||||
getRelation(id).then(response => {
|
||||
this.relationDetail = response.data;
|
||||
this.detailOpen = true;
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.isAdd) {
|
||||
addRelation(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
updateRelation(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除数据项?').then(function() {
|
||||
return delRelation(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('ccdi/custEnterpriseRelation/export', {
|
||||
...this.queryParams
|
||||
}, `信贷客户实体关联_${new Date().getTime()}.xlsx`);
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
this.upload.title = "信贷客户实体关联数据导入";
|
||||
this.upload.open = true;
|
||||
},
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
this.download('ccdi/custEnterpriseRelation/importTemplate', {}, `信贷客户实体关联导入模板_${new Date().getTime()}.xlsx`);
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
this.upload.isUploading = false;
|
||||
this.upload.open = false;
|
||||
|
||||
if (response.code === 200) {
|
||||
if (!response.data || !response.data.taskId) {
|
||||
this.$modal.msgError('导入任务创建失败:缺少任务ID');
|
||||
this.upload.isUploading = false;
|
||||
this.upload.open = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const taskId = response.data.taskId;
|
||||
|
||||
// 清除旧的轮询定时器
|
||||
if (this.importPollingTimer) {
|
||||
clearInterval(this.importPollingTimer);
|
||||
this.importPollingTimer = null;
|
||||
}
|
||||
|
||||
this.clearImportTaskFromStorage();
|
||||
|
||||
// 保存新任务的初始状态
|
||||
this.saveImportTaskToStorage({
|
||||
taskId: taskId,
|
||||
status: 'PROCESSING',
|
||||
timestamp: Date.now(),
|
||||
hasFailures: false
|
||||
});
|
||||
|
||||
// 重置状态
|
||||
this.showFailureButton = false;
|
||||
this.currentTaskId = taskId;
|
||||
|
||||
// 显示后台处理提示
|
||||
this.$notify({
|
||||
title: '导入任务已提交',
|
||||
message: '正在后台处理中,处理完成后将通知您',
|
||||
type: 'info',
|
||||
duration: 3000
|
||||
});
|
||||
|
||||
// 开始轮询检查状态
|
||||
this.startImportStatusPolling(taskId);
|
||||
} else {
|
||||
this.$modal.msgError(response.msg);
|
||||
}
|
||||
},
|
||||
/** 开始轮询导入状态 */
|
||||
startImportStatusPolling(taskId) {
|
||||
let pollCount = 0;
|
||||
const maxPolls = 150;
|
||||
|
||||
this.importPollingTimer = setInterval(async () => {
|
||||
try {
|
||||
pollCount++;
|
||||
|
||||
if (pollCount > maxPolls) {
|
||||
clearInterval(this.importPollingTimer);
|
||||
this.$modal.msgWarning('导入任务处理超时,请联系管理员');
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await getImportStatus(taskId);
|
||||
|
||||
if (response.data && response.data.status !== 'PROCESSING') {
|
||||
clearInterval(this.importPollingTimer);
|
||||
this.handleImportComplete(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clearInterval(this.importPollingTimer);
|
||||
this.$modal.msgError('查询导入状态失败: ' + error.message);
|
||||
}
|
||||
}, 2000);
|
||||
},
|
||||
/** 查询失败记录列表 */
|
||||
getFailureList() {
|
||||
this.failureLoading = true;
|
||||
getImportFailures(
|
||||
this.currentTaskId,
|
||||
this.failureQueryParams.pageNum,
|
||||
this.failureQueryParams.pageSize
|
||||
).then(response => {
|
||||
this.failureList = response.rows;
|
||||
this.failureTotal = response.total;
|
||||
this.failureLoading = false;
|
||||
}).catch(error => {
|
||||
this.failureLoading = false;
|
||||
|
||||
if (error.response) {
|
||||
const status = error.response.status;
|
||||
|
||||
if (status === 404) {
|
||||
this.$modal.msgWarning('导入记录已过期,无法查看失败记录');
|
||||
this.clearImportTaskFromStorage();
|
||||
this.showFailureButton = false;
|
||||
this.currentTaskId = null;
|
||||
this.failureDialogVisible = false;
|
||||
} else if (status === 500) {
|
||||
this.$modal.msgError('服务器错误,请稍后重试');
|
||||
} else {
|
||||
this.$modal.msgError(`查询失败: ${error.response.data.msg || '未知错误'}`);
|
||||
}
|
||||
} else if (error.request) {
|
||||
this.$modal.msgError('网络连接失败,请检查网络');
|
||||
} else {
|
||||
this.$modal.msgError('查询失败记录失败: ' + error.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查看导入失败记录 */
|
||||
viewImportFailures() {
|
||||
this.failureDialogVisible = true;
|
||||
this.getFailureList();
|
||||
},
|
||||
/** 处理导入完成 */
|
||||
handleImportComplete(statusResult) {
|
||||
this.saveImportTaskToStorage({
|
||||
taskId: statusResult.taskId,
|
||||
status: statusResult.status,
|
||||
hasFailures: statusResult.failureCount > 0,
|
||||
totalCount: statusResult.totalCount,
|
||||
successCount: statusResult.successCount,
|
||||
failureCount: statusResult.failureCount
|
||||
});
|
||||
|
||||
if (statusResult.status === 'SUCCESS') {
|
||||
this.$notify({
|
||||
title: '导入完成',
|
||||
message: `全部成功!共导入${statusResult.totalCount}条数据`,
|
||||
type: 'success',
|
||||
duration: 5000
|
||||
});
|
||||
this.showFailureButton = false;
|
||||
this.getList();
|
||||
} else if (statusResult.failureCount > 0) {
|
||||
this.$notify({
|
||||
title: '导入完成',
|
||||
message: `成功${statusResult.successCount}条,失败${statusResult.failureCount}条`,
|
||||
type: 'warning',
|
||||
duration: 5000
|
||||
});
|
||||
|
||||
this.showFailureButton = true;
|
||||
this.currentTaskId = statusResult.taskId;
|
||||
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
// 导入结果弹窗关闭
|
||||
handleImportResultClose() {
|
||||
this.importResultVisible = false;
|
||||
this.importResultContent = "";
|
||||
},
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit();
|
||||
},
|
||||
// 关闭导入对话框
|
||||
handleImportDialogClose() {
|
||||
this.upload.isUploading = false;
|
||||
this.$refs.upload.clearFiles();
|
||||
},
|
||||
/**
|
||||
* 恢复导入状态
|
||||
*/
|
||||
restoreImportState() {
|
||||
const savedTask = this.getImportTaskFromStorage();
|
||||
|
||||
if (!savedTask) {
|
||||
this.showFailureButton = false;
|
||||
this.currentTaskId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (savedTask.hasFailures && savedTask.taskId) {
|
||||
this.currentTaskId = savedTask.taskId;
|
||||
this.showFailureButton = true;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取上次导入的提示信息
|
||||
*/
|
||||
getLastImportTooltip() {
|
||||
const savedTask = this.getImportTaskFromStorage();
|
||||
if (savedTask && savedTask.saveTime) {
|
||||
const date = new Date(savedTask.saveTime);
|
||||
const timeStr = this.parseTime(date, '{y}-{m}-{d} {h}:{i}');
|
||||
return `上次导入: ${timeStr}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* 保存导入任务到localStorage
|
||||
*/
|
||||
saveImportTaskToStorage(taskData) {
|
||||
try {
|
||||
const data = {
|
||||
...taskData,
|
||||
saveTime: Date.now()
|
||||
};
|
||||
localStorage.setItem('cust_enterprise_relation_import_last_task', JSON.stringify(data));
|
||||
} catch (error) {
|
||||
console.error('保存导入任务状态失败:', error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 从localStorage读取导入任务
|
||||
*/
|
||||
getImportTaskFromStorage() {
|
||||
try {
|
||||
const data = localStorage.getItem('cust_enterprise_relation_import_last_task');
|
||||
if (!data) return null;
|
||||
|
||||
const task = JSON.parse(data);
|
||||
|
||||
if (!task || !task.taskId) {
|
||||
this.clearImportTaskFromStorage();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (task.saveTime && typeof task.saveTime !== 'number') {
|
||||
this.clearImportTaskFromStorage();
|
||||
return null;
|
||||
}
|
||||
|
||||
// 过期检查(7天)
|
||||
const sevenDays = 7 * 24 * 60 * 60 * 1000;
|
||||
if (Date.now() - task.saveTime > sevenDays) {
|
||||
this.clearImportTaskFromStorage();
|
||||
return null;
|
||||
}
|
||||
|
||||
return task;
|
||||
} catch (error) {
|
||||
console.error('读取导入任务状态失败:', error);
|
||||
this.clearImportTaskFromStorage();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 清除导入历史记录
|
||||
*/
|
||||
clearImportHistory() {
|
||||
this.$confirm('确认清除上次导入记录?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.clearImportTaskFromStorage();
|
||||
this.showFailureButton = false;
|
||||
this.currentTaskId = null;
|
||||
this.failureDialogVisible = false;
|
||||
this.$message.success('已清除');
|
||||
}).catch(() => {});
|
||||
},
|
||||
/**
|
||||
* 清除localStorage中的导入任务
|
||||
*/
|
||||
clearImportTaskFromStorage() {
|
||||
try {
|
||||
localStorage.removeItem('cust_enterprise_relation_import_last_task');
|
||||
} catch (error) {
|
||||
console.error('清除导入任务状态失败:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detail-container {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.el-divider {
|
||||
margin: 16px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@
|
||||
<el-form-item label="信贷客户身份证号" prop="personId">
|
||||
<el-input
|
||||
v-model="queryParams.personId"
|
||||
placeholder="请输入信贷客户身份证号"
|
||||
placeholder="请输入身份证号(支持模糊搜索)"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
|
||||
Reference in New Issue
Block a user