中介黑名单更新
This commit is contained in:
@@ -1,192 +0,0 @@
|
||||
import openpyxl
|
||||
from openpyxl import Workbook
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# 机构名称前缀
|
||||
org_prefixes = [
|
||||
"北京", "上海", "广州", "深圳", "杭州", "成都", "重庆", "武汉", "西安", "南京",
|
||||
"天津", "苏州", "长沙", "郑州", "东莞", "青岛", "沈阳", "宁波", "厦门", "佛山"
|
||||
]
|
||||
|
||||
# 机构类型关键词
|
||||
org_types = [
|
||||
"投资咨询", "资产管理", "证券投资", "基金管理", "股权投资",
|
||||
"财富管理", "金融信息服务", "商务咨询", "企业咨询", "投资顾问"
|
||||
]
|
||||
|
||||
# 机构后缀
|
||||
org_suffixes = ["有限公司", "股份有限公司", "集团", "企业", "事务所"]
|
||||
|
||||
# 主体类型
|
||||
entity_types = ["企业", "事业单位", "社会组织"]
|
||||
|
||||
# 企业性质
|
||||
corp_natures = [
|
||||
"有限责任公司", "股份有限公司", "国有独资", "集体企业",
|
||||
"私营企业", "中外合资", "外商独资", "港澳台合资"
|
||||
]
|
||||
|
||||
# 行业分类
|
||||
industry_classes = ["金融业", "商务服务业", "科学研究和技术服务业"]
|
||||
|
||||
# 所属行业
|
||||
industries = [
|
||||
"货币金融服务", "资本市场服务", "保险业", "其他金融业",
|
||||
"企业管理服务", "法律服务", "咨询与调查", "广告业",
|
||||
"研究和试验发展", "专业技术服务业", "科技推广和应用服务业"
|
||||
]
|
||||
|
||||
# 证件类型
|
||||
id_types = ["身份证", "护照", "其他"]
|
||||
|
||||
# 统一社会信用代码生成(18位)
|
||||
def generate_credit_code():
|
||||
area_code = f"{random.randint(110000, 659900):06d}"
|
||||
org_code = ''.join([str(random.randint(0, 9)) for _ in range(9)])
|
||||
check_code = random.randint(0, 9)
|
||||
return f"{area_code}{org_code}{check_code}"
|
||||
|
||||
# 生成法定代表人姓名
|
||||
def generate_person_name():
|
||||
surnames = ["王", "李", "张", "刘", "陈", "杨", "黄", "赵", "周", "吴",
|
||||
"徐", "孙", "马", "胡", "朱", "郭", "何", "罗", "高", "林"]
|
||||
names1 = ["伟", "芳", "娜", "敏", "静", "丽", "强", "磊", "军", "洋",
|
||||
"勇", "艳", "杰", "娟", "涛", "明", "超", "秀英", "霞", "平"]
|
||||
names2 = ["", "刚", "英", "华", "文", "平", "建", "国", "志", "海"]
|
||||
return random.choice(surnames) + random.choice(names1) + random.choice(names2)
|
||||
|
||||
# 生成身份证号(18位)
|
||||
def generate_id_card():
|
||||
# 地区码(6位) + 出生日期(8位) + 顺序码(3位) + 校验码(1位)
|
||||
area_code = f"{random.randint(110000, 659900):06d}"
|
||||
year = random.randint(1960, 1995)
|
||||
month = f"{random.randint(1, 12):02d}"
|
||||
day = f"{random.randint(1, 28):02d}"
|
||||
birth_date = f"{year}{month}{day}"
|
||||
sequence = f"{random.randint(1, 999):03d}"
|
||||
check_code = random.randint(0, 9)
|
||||
return f"{area_code}{birth_date}{sequence}{check_code}"
|
||||
|
||||
# 生成注册地址
|
||||
def generate_address():
|
||||
districts = ["朝阳区", "海淀区", "西城区", "东城区", "丰台区",
|
||||
"浦东新区", "黄浦区", "静安区", "徐汇区", "天河区",
|
||||
"福田区", "南山区", "罗湖区", "西湖区", "江干区"]
|
||||
streets = ["建设路", "人民路", "解放路", "和平路", "文化路",
|
||||
"科技路", "创新路", "发展路", "创业路", "工业路"]
|
||||
buildings = ["大厦", "中心", "广场", "写字楼", "科技园"]
|
||||
return f"{random.choice(districts)}{random.choice(streets)}{random.randint(1,999)}号{random.choice(buildings)}"
|
||||
|
||||
# 生成成立日期
|
||||
def generate_establish_date():
|
||||
start_date = datetime(2000, 1, 1)
|
||||
end_date = datetime(2024, 12, 31)
|
||||
days_between = (end_date - start_date).days
|
||||
random_days = random.randint(0, days_between)
|
||||
return (start_date + timedelta(days=random_days)).strftime("%Y-%m-%d")
|
||||
|
||||
# 生成股东名称
|
||||
def generate_shareholder():
|
||||
types = [
|
||||
lambda: f"{random.choice(org_prefixes)}{random.choice(['投资', '资本', '控股', '集团'])}有限公司",
|
||||
lambda: generate_person_name() + random.choice(["", "(自然人)"])
|
||||
]
|
||||
return random.choice(types)()
|
||||
|
||||
# 生成备注
|
||||
def generate_remark():
|
||||
remarks = [
|
||||
"", "", "", "",
|
||||
"重点监控", "已整改", "存在风险", "待核查"
|
||||
]
|
||||
return random.choice(remarks)
|
||||
|
||||
# 生成单条机构数据
|
||||
def generate_org_data(index):
|
||||
# 随机决定有几个股东(1-5个)
|
||||
shareholder_count = random.randint(1, 5)
|
||||
shareholders = [generate_shareholder() for _ in range(shareholder_count)]
|
||||
# 补齐到5个
|
||||
while len(shareholders) < 5:
|
||||
shareholders.append("")
|
||||
|
||||
# 证件类型
|
||||
id_type = random.choice(id_types)
|
||||
id_card = generate_id_card() if id_type == "身份证" else f"{random.choice(['A', 'B', 'C'])}{random.randint(10000, 99999)}"
|
||||
|
||||
return {
|
||||
"id": index,
|
||||
"orgName": f"{random.choice(org_prefixes)}{random.choice(org_types)}{random.choice(org_suffixes)}",
|
||||
"creditCode": generate_credit_code(),
|
||||
"entityType": random.choice(entity_types),
|
||||
"corpNature": random.choice(corp_natures) if random.choice([True, False]) else "",
|
||||
"industryClass": random.choice(industry_classes),
|
||||
"industry": random.choice(industries),
|
||||
"establishDate": generate_establish_date(),
|
||||
"regAddress": generate_address(),
|
||||
"legalRep": generate_person_name(),
|
||||
"legalRepIdType": id_type,
|
||||
"legalRepIdNo": id_card,
|
||||
"shareholder1": shareholders[0],
|
||||
"shareholder2": shareholders[1],
|
||||
"shareholder3": shareholders[2],
|
||||
"shareholder4": shareholders[3],
|
||||
"shareholder5": shareholders[4],
|
||||
"remark": generate_remark()
|
||||
}
|
||||
|
||||
# 生成数据并保存到Excel
|
||||
def generate_org_test_data(filename, count=1000, start_id=1):
|
||||
# 读取模板获取表头
|
||||
template_path = "机构中介黑名单模板_1769674571626.xlsx"
|
||||
template_wb = openpyxl.load_workbook(template_path)
|
||||
template_ws = template_wb.active
|
||||
|
||||
# 创建新工作簿
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "机构中介黑名单"
|
||||
|
||||
# 复制表头
|
||||
for cell in template_ws[1]:
|
||||
new_cell = ws.cell(row=1, column=cell.column, value=cell.value)
|
||||
|
||||
# 生成数据
|
||||
data_list = []
|
||||
for i in range(count):
|
||||
data = generate_org_data(start_id + i)
|
||||
data_list.append(data)
|
||||
|
||||
# 按照模板列顺序写入数据
|
||||
# 列顺序:机构名称、统一社会信用代码、主体类型、企业性质、行业分类、所属行业、
|
||||
# 成立日期、注册地址、法定代表人、法定代表人证件类型、法定代表人证件号码、
|
||||
# 股东1、股东2、股东3、股东4、股东5、备注
|
||||
for row_idx, data in enumerate(data_list, start=2):
|
||||
ws.cell(row=row_idx, column=1, value=data["orgName"])
|
||||
ws.cell(row=row_idx, column=2, value=data["creditCode"])
|
||||
ws.cell(row=row_idx, column=3, value=data["entityType"])
|
||||
ws.cell(row=row_idx, column=4, value=data["corpNature"])
|
||||
ws.cell(row=row_idx, column=5, value=data["industryClass"])
|
||||
ws.cell(row=row_idx, column=6, value=data["industry"])
|
||||
ws.cell(row=row_idx, column=7, value=data["establishDate"])
|
||||
ws.cell(row=row_idx, column=8, value=data["regAddress"])
|
||||
ws.cell(row=row_idx, column=9, value=data["legalRep"])
|
||||
ws.cell(row=row_idx, column=10, value=data["legalRepIdType"])
|
||||
ws.cell(row=row_idx, column=11, value=data["legalRepIdNo"])
|
||||
ws.cell(row=row_idx, column=12, value=data["shareholder1"])
|
||||
ws.cell(row=row_idx, column=13, value=data["shareholder2"])
|
||||
ws.cell(row=row_idx, column=14, value=data["shareholder3"])
|
||||
ws.cell(row=row_idx, column=15, value=data["shareholder4"])
|
||||
ws.cell(row=row_idx, column=16, value=data["shareholder5"])
|
||||
ws.cell(row=row_idx, column=17, value=data["remark"])
|
||||
|
||||
# 保存文件
|
||||
wb.save(filename)
|
||||
print(f"已生成文件: {filename}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("开始生成机构中介黑名单测试数据...")
|
||||
generate_org_test_data("机构中介黑名单测试数据_1000条.xlsx", 1000, 1)
|
||||
generate_org_test_data("机构中介黑名单测试数据_1000条_第2批.xlsx", 1000, 1001)
|
||||
print("完成!")
|
||||
BIN
doc/test-data/intermediary/entity_1770260448522.xlsx
Normal file
BIN
doc/test-data/intermediary/entity_1770260448522.xlsx
Normal file
Binary file not shown.
181
doc/test-data/intermediary/generate_1000_entity_data.py
Normal file
181
doc/test-data/intermediary/generate_1000_entity_data.py
Normal file
@@ -0,0 +1,181 @@
|
||||
import random
|
||||
import string
|
||||
from datetime import datetime, timedelta
|
||||
import pandas as pd
|
||||
|
||||
# 机构名称前缀
|
||||
company_prefixes = ['北京市', '上海市', '广州市', '深圳市', '杭州市', '成都市', '武汉市', '南京市', '西安市', '重庆市']
|
||||
company_keywords = ['房产', '地产', '置业', '中介', '经纪', '咨询', '投资', '资产', '物业', '不动产']
|
||||
company_suffixes = ['有限公司', '股份有限公司', '集团', '企业', '合伙企业', '有限责任公司']
|
||||
|
||||
# 主体类型
|
||||
entity_types = ['企业', '个体工商户', '农民专业合作社', '其他组织']
|
||||
|
||||
# 企业性质
|
||||
enterprise_natures = ['国有企业', '集体企业', '私营企业', '混合所有制企业', '外商投资企业', '港澳台投资企业']
|
||||
|
||||
# 行业分类
|
||||
industry_classes = ['房地产业', '金融业', '租赁和商务服务业', '建筑业', '批发和零售业']
|
||||
|
||||
# 所属行业
|
||||
industry_names = [
|
||||
'房地产中介服务', '房地产经纪', '房地产开发经营', '物业管理',
|
||||
'投资咨询', '资产管理', '商务咨询', '市场调查',
|
||||
'建筑工程', '装饰装修', '园林绿化'
|
||||
]
|
||||
|
||||
# 法定代表人姓名
|
||||
surnames = ['王', '李', '张', '刘', '陈', '杨', '黄', '赵', '周', '吴', '徐', '孙', '马', '胡', '朱', '郭', '何', '罗', '高', '林']
|
||||
given_names = ['伟', '芳', '娜', '敏', '静', '丽', '强', '磊', '军', '洋', '勇', '艳', '杰', '娟', '涛', '明', '超', '秀英', '霞', '平']
|
||||
|
||||
# 证件类型
|
||||
cert_types = ['身份证', '护照', '港澳通行证', '台胞证', '其他']
|
||||
|
||||
# 常用地址
|
||||
provinces = ['北京市', '上海市', '广东省', '浙江省', '江苏省', '四川省', '湖北省', '河南省', '山东省', '福建省']
|
||||
cities = ['朝阳区', '海淀区', '浦东新区', '黄浦区', '天河区', '福田区', '西湖区', '滨江区', '鼓楼区', '玄武区',
|
||||
'武侯区', '江汉区', '金水区', '市南区', '思明区']
|
||||
districts = ['街道', '大道', '路', '巷', '小区', '花园', '广场', '大厦']
|
||||
street_numbers = ['1号', '2号', '3号', '88号', '66号', '108号', '188号', '888号', '666号', '168号']
|
||||
|
||||
# 股东姓名
|
||||
shareholder_names = [
|
||||
'张伟', '李芳', '王强', '刘军', '陈静', '杨洋', '黄勇', '赵艳',
|
||||
'周杰', '吴娟', '徐涛', '孙明', '马超', '胡秀英', '朱霞', '郭平',
|
||||
'何桂英', '罗玉兰', '高萍', '林毅', '王浩', '李宇', '张轩', '刘然'
|
||||
]
|
||||
|
||||
def generate_company_name():
|
||||
"""生成机构名称"""
|
||||
prefix = random.choice(company_prefixes)
|
||||
keyword = random.choice(company_keywords)
|
||||
suffix = random.choice(company_suffixes)
|
||||
return f"{prefix}{keyword}{suffix}"
|
||||
|
||||
def generate_social_credit_code():
|
||||
"""生成统一社会信用代码(18位)"""
|
||||
# 统一社会信用代码规则:18位,第一位为登记管理部门代码(1-5),第二位为机构类别代码(1-9)
|
||||
dept_code = random.choice(['1', '2', '3', '4', '5'])
|
||||
org_code = random.choice(['1', '2', '3', '4', '5', '6', '7', '8', '9'])
|
||||
rest = ''.join([str(random.randint(0, 9)) for _ in range(16)])
|
||||
return f"{dept_code}{org_code}{rest}"
|
||||
|
||||
def generate_id_card():
|
||||
"""生成身份证号码(18位,简化版)"""
|
||||
# 地区码(前6位)
|
||||
area_code = f"{random.randint(110000, 650000):06d}"
|
||||
# 出生日期(8位)
|
||||
birth_year = random.randint(1960, 1990)
|
||||
birth_month = f"{random.randint(1, 12):02d}"
|
||||
birth_day = f"{random.randint(1, 28):02d}"
|
||||
birth_date = f"{birth_year}{birth_month}{birth_day}"
|
||||
# 顺序码(3位)
|
||||
sequence = f"{random.randint(1, 999):03d}"
|
||||
# 校验码(1位)
|
||||
check_code = random.randint(0, 9)
|
||||
return f"{area_code}{birth_date}{sequence}{check_code}"
|
||||
|
||||
def generate_other_id():
|
||||
"""生成其他证件号码"""
|
||||
return f"{random.randint(10000000, 99999999):08d}"
|
||||
|
||||
def generate_register_address():
|
||||
"""生成注册地址"""
|
||||
province = random.choice(provinces)
|
||||
city = random.choice(cities)
|
||||
district = random.choice(districts)
|
||||
number = random.choice(street_numbers)
|
||||
return f"{province}{city}{district}{number}"
|
||||
|
||||
def generate_establish_date():
|
||||
"""生成成立日期(2000-2024年之间)"""
|
||||
start_date = datetime(2000, 1, 1)
|
||||
end_date = datetime(2024, 12, 31)
|
||||
time_between = end_date - start_date
|
||||
days_between = time_between.days
|
||||
random_days = random.randrange(days_between)
|
||||
return start_date + timedelta(days=random_days)
|
||||
|
||||
def generate_legal_representative():
|
||||
"""生成法定代表人"""
|
||||
name = random.choice(surnames) + random.choice(given_names)
|
||||
cert_type = random.choice(cert_types)
|
||||
cert_no = generate_id_card() if cert_type == '身份证' else generate_other_id()
|
||||
return name, cert_type, cert_no
|
||||
|
||||
def generate_shareholders():
|
||||
"""生成股东列表(1-5个股东)"""
|
||||
shareholder_count = random.randint(1, 5)
|
||||
selected_shareholders = random.sample(shareholder_names, shareholder_count)
|
||||
shareholders = [None] * 5
|
||||
for i, shareholder in enumerate(selected_shareholders):
|
||||
shareholders[i] = shareholder
|
||||
return shareholders
|
||||
|
||||
def generate_entity(index):
|
||||
"""生成单条机构中介数据"""
|
||||
# 基本信息
|
||||
enterprise_name = generate_company_name()
|
||||
social_credit_code = generate_social_credit_code()
|
||||
entity_type = random.choice(entity_types)
|
||||
enterprise_nature = random.choice(enterprise_natures)
|
||||
industry_class = random.choice(industry_classes)
|
||||
industry_name = random.choice(industry_names)
|
||||
|
||||
# 成立日期
|
||||
establish_date = generate_establish_date()
|
||||
|
||||
# 注册地址
|
||||
register_address = generate_register_address()
|
||||
|
||||
# 法定代表人信息
|
||||
legal_name, legal_cert_type, legal_cert_no = generate_legal_representative()
|
||||
|
||||
# 股东
|
||||
shareholders = generate_shareholders()
|
||||
|
||||
return {
|
||||
'机构名称*': enterprise_name,
|
||||
'统一社会信用代码*': social_credit_code,
|
||||
'主体类型': entity_type,
|
||||
'企业性质': enterprise_nature if random.random() > 0.3 else '',
|
||||
'行业分类': industry_class if random.random() > 0.3 else '',
|
||||
'所属行业': industry_name if random.random() > 0.2 else '',
|
||||
'成立日期': establish_date.strftime('%Y-%m-%d') if random.random() > 0.4 else '',
|
||||
'注册地址': register_address,
|
||||
'法定代表人': legal_name,
|
||||
'法定代表人证件类型': legal_cert_type,
|
||||
'法定代表人证件号码': legal_cert_no,
|
||||
'股东1': shareholders[0] if shareholders[0] else '',
|
||||
'股东2': shareholders[1] if shareholders[1] else '',
|
||||
'股东3': shareholders[2] if shareholders[2] else '',
|
||||
'股东4': shareholders[3] if shareholders[3] else '',
|
||||
'股东5': shareholders[4] if shareholders[4] else '',
|
||||
'备注': f'测试数据{index}' if random.random() > 0.5 else ''
|
||||
}
|
||||
|
||||
# 生成第一个1000条数据
|
||||
print("正在生成第一批1000条机构中介黑名单数据...")
|
||||
data = [generate_entity(i) for i in range(1, 1001)]
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
# 保存第一个文件
|
||||
output1 = r'D:\ccdi\ccdi\doc\test-data\intermediary\机构中介黑名单测试数据_1000条_第1批.xlsx'
|
||||
df.to_excel(output1, index=False, engine='openpyxl')
|
||||
print(f"已生成第一个文件: {output1}")
|
||||
|
||||
# 生成第二个1000条数据
|
||||
print("正在生成第二批1000条机构中介黑名单数据...")
|
||||
data2 = [generate_entity(i) for i in range(1, 1001)]
|
||||
df2 = pd.DataFrame(data2)
|
||||
|
||||
# 保存第二个文件
|
||||
output2 = r'D:\ccdi\ccdi\doc\test-data\intermediary\机构中介黑名单测试数据_1000条_第2批.xlsx'
|
||||
df2.to_excel(output2, index=False, engine='openpyxl')
|
||||
print(f"已生成第二个文件: {output2}")
|
||||
|
||||
print("\n✅ 生成完成!")
|
||||
print(f"文件1: {output1}")
|
||||
print(f"文件2: {output2}")
|
||||
print(f"\n每个文件包含1000条测试数据")
|
||||
print(f"数据格式与CcdiIntermediaryEntityExcel.java定义一致")
|
||||
110
doc/test-data/intermediary/generate_1000_intermediary_data.py
Normal file
110
doc/test-data/intermediary/generate_1000_intermediary_data.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import random
|
||||
import string
|
||||
from datetime import datetime
|
||||
import pandas as pd
|
||||
|
||||
# 常用姓氏和名字
|
||||
surnames = ['王', '李', '张', '刘', '陈', '杨', '黄', '赵', '周', '吴', '徐', '孙', '马', '胡', '朱', '郭', '何', '罗', '高', '林']
|
||||
given_names = ['伟', '芳', '娜', '敏', '静', '丽', '强', '磊', '军', '洋', '勇', '艳', '杰', '娟', '涛', '明', '超', '秀英', '霞', '平', '刚', '桂英', '玉兰', '萍', '毅', '浩', '宇', '轩', '然', '凯']
|
||||
|
||||
# 人员类型
|
||||
person_types = ['中介', '职业背债人', '房产中介']
|
||||
person_sub_types = ['本人', '配偶', '子女', '其他']
|
||||
genders = ['M', 'F', 'O']
|
||||
id_types = ['身份证', '护照', '港澳通行证', '台胞证', '军官证']
|
||||
relation_types = ['配偶', '子女', '父母', '兄弟姐妹', '其他']
|
||||
|
||||
# 常用地址
|
||||
provinces = ['北京市', '上海市', '广东省', '浙江省', '江苏省', '四川省', '湖北省', '河南省', '山东省', '福建省']
|
||||
cities = ['朝阳区', '海淀区', '浦东新区', '黄浦区', '天河区', '福田区', '西湖区', '滨江区', '鼓楼区', '玄武区']
|
||||
districts = ['街道1号', '大道2号', '路3号', '巷4号', '小区5栋', '花园6号', '广场7号', '大厦8号楼']
|
||||
|
||||
# 公司和职位
|
||||
companies = ['房产中介有限公司', '置业咨询公司', '房产经纪公司', '地产代理公司', '不动产咨询公司', '房屋租赁公司', '物业管理公司', '投资咨询公司']
|
||||
positions = ['房产经纪人', '销售经理', '业务员', '置业顾问', '店长', '区域经理', '高级经纪人', '项目经理']
|
||||
|
||||
# 生成身份证号码(简化版,仅用于测试)
|
||||
def generate_id_card():
|
||||
# 地区码(前6位)
|
||||
area_code = f"{random.randint(110000, 650000):06d}"
|
||||
# 出生日期(8位)
|
||||
birth_year = random.randint(1960, 2000)
|
||||
birth_month = f"{random.randint(1, 12):02d}"
|
||||
birth_day = f"{random.randint(1, 28):02d}"
|
||||
birth_date = f"{birth_year}{birth_month}{birth_day}"
|
||||
# 顺序码(3位)
|
||||
sequence = f"{random.randint(1, 999):03d}"
|
||||
# 校验码(1位)
|
||||
check_code = random.randint(0, 9)
|
||||
return f"{area_code}{birth_date}{sequence}{check_code}"
|
||||
|
||||
# 生成手机号
|
||||
def generate_phone():
|
||||
second_digits = ['3', '5', '7', '8', '9']
|
||||
second = random.choice(second_digits)
|
||||
return f"1{second}{''.join([str(random.randint(0, 9)) for _ in range(9)])}"
|
||||
|
||||
# 生成统一信用代码
|
||||
def generate_credit_code():
|
||||
return f"91{''.join([str(random.randint(0, 9)) for _ in range(16)])}"
|
||||
|
||||
# 生成微信号
|
||||
def generate_wechat():
|
||||
return f"wx_{''.join([random.choice(string.ascii_lowercase + string.digits) for _ in range(8)])}"
|
||||
|
||||
# 生成单条数据
|
||||
def generate_person(index):
|
||||
person_type = random.choice(person_types)
|
||||
gender = random.choice(genders)
|
||||
|
||||
# 根据性别选择更合适的名字
|
||||
if gender == 'M':
|
||||
name = random.choice(surnames) + random.choice(['伟', '强', '磊', '军', '勇', '杰', '涛', '明', '超', '毅', '浩', '宇', '轩'])
|
||||
else:
|
||||
name = random.choice(surnames) + random.choice(['芳', '娜', '敏', '静', '丽', '艳', '娟', '秀英', '霞', '平', '桂英', '玉兰', '萍'])
|
||||
|
||||
id_type = random.choice(id_types)
|
||||
id_card = generate_id_card() if id_type == '身份证' else f"{random.randint(10000000, 99999999):08d}"
|
||||
|
||||
return {
|
||||
'姓名': name,
|
||||
'人员类型': person_type,
|
||||
'人员子类型': random.choice(person_sub_types),
|
||||
'性别': gender,
|
||||
'证件类型': id_type,
|
||||
'证件号码': id_card,
|
||||
'手机号码': generate_phone(),
|
||||
'微信号': generate_wechat() if random.random() > 0.3 else '',
|
||||
'联系地址': f"{random.choice(provinces)}{random.choice(cities)}{random.choice(districts)}",
|
||||
'所在公司': random.choice(companies) if random.random() > 0.2 else '',
|
||||
'企业统一信用码': generate_credit_code() if random.random() > 0.5 else '',
|
||||
'职位': random.choice(positions) if random.random() > 0.3 else '',
|
||||
'关联人员ID': f"ID{random.randint(10000, 99999)}" if random.random() > 0.6 else '',
|
||||
'关系类型': random.choice(relation_types) if random.random() > 0.6 else '',
|
||||
'备注': f'测试数据{index}' if random.random() > 0.5 else ''
|
||||
}
|
||||
|
||||
# 生成1000条数据
|
||||
print("正在生成1000条个人中介黑名单数据...")
|
||||
data = [generate_person(i) for i in range(1, 1001)]
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
# 保存第一个文件
|
||||
output1 = r'D:\ccdi\ccdi\doc\test-data\intermediary\个人中介黑名单测试数据_1000条_第1批.xlsx'
|
||||
df.to_excel(output1, index=False)
|
||||
print(f"已生成第一个文件: {output1}")
|
||||
|
||||
# 生成第二个1000条数据
|
||||
print("正在生成第二批1000条个人中介黑名单数据...")
|
||||
data2 = [generate_person(i) for i in range(1, 1001)]
|
||||
df2 = pd.DataFrame(data2)
|
||||
|
||||
# 保存第二个文件
|
||||
output2 = r'D:\ccdi\ccdi\doc\test-data\intermediary\个人中介黑名单测试数据_1000条_第2批.xlsx'
|
||||
df2.to_excel(output2, index=False)
|
||||
print(f"已生成第二个文件: {output2}")
|
||||
|
||||
print("\n生成完成!")
|
||||
print(f"文件1: {output1}")
|
||||
print(f"文件2: {output2}")
|
||||
print(f"\n每个文件包含1000条测试数据")
|
||||
BIN
doc/test-data/intermediary/个人中介黑名单模板_1770258896626.xlsx
Normal file
BIN
doc/test-data/intermediary/个人中介黑名单模板_1770258896626.xlsx
Normal file
Binary file not shown.
BIN
doc/test-data/intermediary/个人中介黑名单测试数据_1000条_第1批.xlsx
Normal file
BIN
doc/test-data/intermediary/个人中介黑名单测试数据_1000条_第1批.xlsx
Normal file
Binary file not shown.
BIN
doc/test-data/intermediary/个人中介黑名单测试数据_1000条_第2批.xlsx
Normal file
BIN
doc/test-data/intermediary/个人中介黑名单测试数据_1000条_第2批.xlsx
Normal file
Binary file not shown.
BIN
doc/test-data/intermediary/机构中介黑名单测试数据_1000条_第1批.xlsx
Normal file
BIN
doc/test-data/intermediary/机构中介黑名单测试数据_1000条_第1批.xlsx
Normal file
Binary file not shown.
BIN
doc/test-data/intermediary/机构中介黑名单测试数据_1000条_第2批.xlsx
Normal file
BIN
doc/test-data/intermediary/机构中介黑名单测试数据_1000条_第2批.xlsx
Normal file
Binary file not shown.
@@ -1,268 +0,0 @@
|
||||
"""
|
||||
中介黑名单导入功能测试脚本
|
||||
|
||||
测试目标:
|
||||
1. 验证机构中介导入时 certificate_no 字段不能为 null 的修复
|
||||
2. 验证个人中介导入功能正常
|
||||
3. 验证更新模式功能正常
|
||||
|
||||
测试数据准备:
|
||||
- 个人中介:2条记录
|
||||
- 机构中介:2条记录
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
BASE_URL = "http://localhost:8080"
|
||||
|
||||
def login():
|
||||
"""登录并获取token"""
|
||||
url = f"{BASE_URL}/login/test"
|
||||
data = {
|
||||
"username": "admin",
|
||||
"password": "admin123"
|
||||
}
|
||||
response = requests.post(url, json=data)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
if result.get("code") == 200:
|
||||
token = result.get("token")
|
||||
print(f"✓ 登录成功,获取token: {token[:20]}...")
|
||||
return token
|
||||
print(f"✗ 登录失败: {response.text}")
|
||||
return None
|
||||
|
||||
def get_headers(token):
|
||||
"""获取请求头"""
|
||||
return {
|
||||
"Authorization": f"Bearer {token}"
|
||||
}
|
||||
|
||||
def test_import_person_intermediary(token):
|
||||
"""测试个人中介导入"""
|
||||
print("\n" + "="*60)
|
||||
print("测试1: 个人中介导入功能")
|
||||
print("="*60)
|
||||
|
||||
# 准备个人中介数据(直接通过API调用测试)
|
||||
url = f"{BASE_URL}/dpc/intermediary"
|
||||
headers = get_headers(token)
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
person_data = {
|
||||
"name": "测试个人中介",
|
||||
"certificateNo": "110101199001011234",
|
||||
"intermediaryType": "1",
|
||||
"status": "0",
|
||||
"remark": "测试个人中介导入",
|
||||
"indivType": "中介",
|
||||
"indivSubType": "本人",
|
||||
"indivGender": "M",
|
||||
"indivCertType": "身份证",
|
||||
"indivPhone": "13800138000",
|
||||
"indivWechat": "test_wx_id",
|
||||
"indivAddress": "北京市朝阳区",
|
||||
"indivCompany": "测试公司",
|
||||
"indivPosition": "经纪人"
|
||||
}
|
||||
|
||||
response = requests.post(url, json=person_data, headers=headers)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
if result.get("code") == 200:
|
||||
print("✓ 个人中介导入成功")
|
||||
return True
|
||||
else:
|
||||
print(f"✗ 个人中介导入失败: {result.get('msg')}")
|
||||
return False
|
||||
else:
|
||||
print(f"✗ 个人中介导入请求失败: {response.status_code} - {response.text}")
|
||||
return False
|
||||
|
||||
def test_import_entity_intermediary(token):
|
||||
"""测试机构中介导入"""
|
||||
print("\n" + "="*60)
|
||||
print("测试2: 机构中介导入功能")
|
||||
print("="*60)
|
||||
|
||||
# 准备机构中介数据
|
||||
url = f"{BASE_URL}/dpc/intermediary"
|
||||
headers = get_headers(token)
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
entity_data = {
|
||||
"name": "测试机构中介有限公司",
|
||||
"certificateNo": "91110108MA0000001A", # 统一社会信用代码
|
||||
"intermediaryType": "2",
|
||||
"status": "0",
|
||||
"remark": "测试机构中介导入",
|
||||
"corpCreditCode": "91110108MA0000001A",
|
||||
"corpType": "有限责任公司",
|
||||
"corpNature": "民营企业",
|
||||
"corpIndustryCategory": "房地产业",
|
||||
"corpIndustry": "房地产中介服务",
|
||||
"corpEstablishDate": "2020-01-01",
|
||||
"corpAddress": "北京市海淀区",
|
||||
"corpLegalRep": "张三",
|
||||
"corpLegalCertType": "身份证",
|
||||
"corpLegalCertNo": "110101199001011235",
|
||||
"corpShareholder1": "李四",
|
||||
"corpShareholder2": "王五"
|
||||
}
|
||||
|
||||
response = requests.post(url, json=entity_data, headers=headers)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
if result.get("code") == 200:
|
||||
print("✓ 机构中介导入成功")
|
||||
print(f" - 机构名称: {entity_data['name']}")
|
||||
print(f" - 统一社会信用代码: {entity_data['corpCreditCode']}")
|
||||
print(f" - 证件号字段: {entity_data['certificateNo']}")
|
||||
return True
|
||||
else:
|
||||
print(f"✗ 机构中介导入失败: {result.get('msg')}")
|
||||
return False
|
||||
else:
|
||||
print(f"✗ 机构中介导入请求失败: {response.status_code} - {response.text}")
|
||||
return False
|
||||
|
||||
def test_import_entity_without_credit_code(token):
|
||||
"""测试机构中介导入时统一社会信用代码为空的情况"""
|
||||
print("\n" + "="*60)
|
||||
print("测试4: 机构中介导入时统一社会信用代码为空(应该失败)")
|
||||
print("="*60)
|
||||
|
||||
url = f"{BASE_URL}/dpc/intermediary"
|
||||
headers = get_headers(token)
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
# 故意不提供统一社会信用代码
|
||||
entity_data = {
|
||||
"name": "测试机构中介有限公司(无信用代码)",
|
||||
"certificateNo": "", # 空字符串
|
||||
"intermediaryType": "2",
|
||||
"status": "0",
|
||||
"remark": "测试统一社会信用代码为空的情况",
|
||||
"corpCreditCode": "", # 空字符串
|
||||
"corpType": "有限责任公司"
|
||||
}
|
||||
|
||||
response = requests.post(url, json=entity_data, headers=headers)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
if result.get("code") != 200:
|
||||
# 预期失败
|
||||
print(f"✓ 预期行为:导入被拒绝,错误信息: {result.get('msg')}")
|
||||
return True
|
||||
else:
|
||||
# 不应该成功
|
||||
print(f"✗ 测试失败:统一社会信用代码为空时不应该导入成功")
|
||||
return False
|
||||
else:
|
||||
print(f"✗ 请求失败: {response.status_code} - {response.text}")
|
||||
return False
|
||||
|
||||
def test_query_intermediary_list(token):
|
||||
"""测试查询中介列表"""
|
||||
print("\n" + "="*60)
|
||||
print("测试3: 查询中介列表")
|
||||
print("="*60)
|
||||
|
||||
url = f"{BASE_URL}/dpc/intermediary/list"
|
||||
headers = get_headers(token)
|
||||
|
||||
params = {
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
|
||||
response = requests.get(url, params=params, headers=headers)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
if result.get("code") == 200:
|
||||
rows = result.get("rows", [])
|
||||
total = result.get("total", 0)
|
||||
print(f"✓ 查询成功,共 {total} 条记录")
|
||||
for item in rows:
|
||||
print(f" - {item['name']} ({item.get('intermediaryTypeName', '未知')}) - 证件号: {item.get('certificateNo', '无')}")
|
||||
return True
|
||||
else:
|
||||
print(f"✗ 查询失败: {result.get('msg')}")
|
||||
return False
|
||||
else:
|
||||
print(f"✗ 查询请求失败: {response.status_code} - {response.text}")
|
||||
return False
|
||||
|
||||
def generate_test_report(results):
|
||||
"""生成测试报告"""
|
||||
print("\n" + "="*60)
|
||||
print("测试报告")
|
||||
print("="*60)
|
||||
|
||||
total_tests = len(results)
|
||||
passed_tests = sum(1 for r in results.values() if r)
|
||||
failed_tests = total_tests - passed_tests
|
||||
|
||||
print(f"\n总测试数: {total_tests}")
|
||||
print(f"通过: {passed_tests}")
|
||||
print(f"失败: {failed_tests}")
|
||||
print(f"通过率: {passed_tests/total_tests*100:.1f}%")
|
||||
|
||||
print("\n详细结果:")
|
||||
for test_name, result in results.items():
|
||||
status = "✓ 通过" if result else "✗ 失败"
|
||||
print(f" {test_name}: {status}")
|
||||
|
||||
# 保存报告到文件
|
||||
report_content = {
|
||||
"测试时间": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"总测试数": total_tests,
|
||||
"通过": passed_tests,
|
||||
"失败": failed_tests,
|
||||
"通过率": f"{passed_tests/total_tests*100:.1f}%",
|
||||
"详细结果": {k: "通过" if v else "失败" for k, v in results.items()}
|
||||
}
|
||||
|
||||
with open("doc/test-data/import_test_report.json", "w", encoding="utf-8") as f:
|
||||
json.dump(report_content, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"\n测试报告已保存至: doc/test-data/import_test_report.json")
|
||||
|
||||
def main():
|
||||
"""主测试函数"""
|
||||
print("="*60)
|
||||
print("中介黑名单导入功能测试")
|
||||
print(f"测试时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print("="*60)
|
||||
|
||||
results = {}
|
||||
|
||||
# 1. 登录
|
||||
token = login()
|
||||
if not token:
|
||||
print("登录失败,无法继续测试")
|
||||
return
|
||||
|
||||
# 2. 测试个人中介导入
|
||||
results["个人中介导入"] = test_import_person_intermediary(token)
|
||||
|
||||
# 3. 测试机构中介导入
|
||||
results["机构中介导入"] = test_import_entity_intermediary(token)
|
||||
|
||||
# 4. 测试统一社会信用代码为空的情况
|
||||
results["机构中介无信用代码校验"] = test_import_entity_without_credit_code(token)
|
||||
|
||||
# 5. 测试查询列表
|
||||
results["查询列表"] = test_query_intermediary_list(token)
|
||||
|
||||
# 5. 生成测试报告
|
||||
generate_test_report(results)
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("测试完成")
|
||||
print("="*60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,22 +0,0 @@
|
||||
字段中文名,数据类型,长度/精度,是否为空,默认值,说明
|
||||
统一社会信用代码,VARCHAR,18,是,-,统一社会信用代码
|
||||
主体名称,VARCHAR,200,否,-,企业注册名称
|
||||
主体类型,VARCHAR,50,否,-,企业类型:有限责任公司、股份有限公司、合伙企业、个体工商户、外资企业等
|
||||
企业性质,VARCHAR,50,是,-,国企、民企、外企、合资、其他
|
||||
行业分类,VARCHAR,100,是,-,行业分类代码或名称
|
||||
所属行业,VARCHAR,100,是,-,所属行业
|
||||
成立日期,DATE,-,是,-,企业成立日期
|
||||
注册地址,VARCHAR,500,是,-,工商注册地址
|
||||
法定代表人,VARCHAR,50,是,-,法定代表人姓名
|
||||
法定代表人证件类型,VARCHAR,30,是,-,法定代表人证件类型
|
||||
法定代表人证件号码,VARCHAR,30,是,-,法定代表人证件号码
|
||||
股东1,VARCHAR,30,是,-,股东姓名
|
||||
股东2,VARCHAR,30,是,-,股东姓名
|
||||
股东3,VARCHAR,30,是,-,股东姓名
|
||||
股东4,VARCHAR,30,是,-,股东姓名
|
||||
股东5,VARCHAR,30,是,-,股东姓名
|
||||
创建时间,DATETIME,-,否,当前时间,记录创建时间
|
||||
更新时间,DATETIME,-,否,当前时间,记录更新时间
|
||||
创建人,VARCHAR,50,否,-,记录创建人
|
||||
更新人,VARCHAR,50,是,-,记录更新人
|
||||
数据来源,VARCHAR,30,是,MANUAL,"MANUAL:手动录入, SYSTEM:系统同步, API:接口获取, IMPORT:批量导入"
|
||||
|
@@ -1,20 +0,0 @@
|
||||
字段中文名,数据类型,长度/精度,是否为空,默认值,说明
|
||||
人员ID,VARCHAR,20,否,-,中介、职业背债人、房产中介等
|
||||
人员类型,VARCHAR,30,否,-,中介、职业背债人、房产中介等
|
||||
人员子类型,VARCHAR,50,是,-,如:本人、配偶等
|
||||
姓名,VARCHAR,50,否,-,人员姓名
|
||||
性别,CHAR,1,是,-,"M:男, F:女, O:其他"
|
||||
证件类型,VARCHAR,30,否,身份证,身份证、护照、港澳通行证、台胞证、军官证等
|
||||
证件号码,VARCHAR,30,否,-,证件号码(加密存储)
|
||||
手机号码,VARCHAR,20,是,-,手机号码(加密存储)
|
||||
微信号,VARCHAR,50,是,-,微信号
|
||||
联系地址,VARCHAR,200,是,-,详细联系地址
|
||||
所在公司,VARCHAR,100,是,-,当前就职公司
|
||||
职位,VARCHAR,100,是,-,职位/职务
|
||||
关联人员ID,VARCHAR,20,是,-,关联“人员ID”
|
||||
关联关系,VARCHAR,50,是,-,与关联员工的关系
|
||||
创建时间,DATETIME,-,否,当前时间,记录创建时间
|
||||
更新时间,DATETIME,-,否,当前时间,记录更新时间
|
||||
创建人,VARCHAR,50,否,-,记录创建人
|
||||
更新人,VARCHAR,50,是,-,记录更新人
|
||||
数据来源,VARCHAR,30,是,MANUAL,"MANUAL:手动录入, SYSTEM:系统同步, IMPORT:批量导入, API:接口获取"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user