我目前有一张表 A表的字段有(gmt_create, gmt_modified, qualification_id, partner_id, cust_name, qualification_name, cust_from, cust_id, ali_uid, ali_account, ali_create_time, ali_cid, alicom_halt_status, cbm_work_id, any_param, illegal_case_count, sms_halt_status, voice_halt_status, alicom_create_time, alicom_industry, alicom_cust_type, remark, free_sign_flag, organization_code, data_type, sms_illegal_count, voice_illegal_count, active_flag) 帮我造几个假数据
时间: 2024-04-28 16:25:43 浏览: 120
好的,以下是一个示例的Java程序,可以方便地生成A表的假数据:
```java
import java.util.Date;
import java.util.Random;
public class DataGenerator {
private static final int NUM_ROWS = 100; // 生成100行数据
private static final String[] CUST_NAMES = {"张三", "李四", "王五", "赵六", "钱七", "孙八", "周九", "吴十"};
private static final String[] QUALIFICATION_NAMES = {"工商注册证", "税务登记证", "组织机构代码证", "营业执照", "法人身份证"};
private static final String[] CUST_FROMS = {"淘宝", "天猫", "京东", "苏宁易购", "唯品会", "拼多多"};
private static final String[] ALICOM_INDUSTRIES = {"电商", "餐饮", "旅游", "教育", "医疗", "房地产"};
private static final String[] ALICOM_CUST_TYPES = {"企业", "个体工商户", "个人"};
private static final String[] REMARKS = {"无", "一般", "重要", "紧急"};
private static final String[] ORGANIZATION_CODES = {"123456", "654321", "234567", "876543", "345678", "987654"};
private static final Random random = new Random();
public static void main(String[] args) {
for (int i = 0; i < NUM_ROWS; i++) {
Date now = new Date();
Date gmtCreate = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间
Date gmtModified = new Date(now.getTime() - random.nextInt(10000) * 1000L); // 随机生成最近的时间
long qualificationId = random.nextInt(100000) + 1; // 从1到100000随机生成qualification_id
String partnerId = String.format("%06d", random.nextInt(1000000)); // 随机生成6位数字的partner_id
String custName = CUST_NAMES[random.nextInt(CUST_NAMES.length)];
String qualificationName = QUALIFICATION_NAMES[random.nextInt(QUALIFICATION_NAMES.length)];
String custFrom = CUST_FROMS[random.nextInt(CUST_FROMS.length)];
String custId = String.format("%012d", random.nextInt(1000000000000L)); // 随机生成12位数字的cust_id
String aliUid = String.format("%08d", random.nextInt(100000000)); // 随机生成8位数字的ali_uid
String aliAccount = "ali_" + String.format("%06d", random.nextInt(1000000)); // 随机生成ali_后面跟6位数字的ali_account
Date aliCreateTime = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间
String aliCid = String.format("%08d", random.nextInt(100000000)); // 随机生成8位数字的ali_cid
String alicomHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成alicon_halt_status
String cbmWorkId = "cbm_" + String.format("%06d", random.nextInt(1000000)); // 随机生成cbm_后面跟6位数字的cbm_work_id
String anyParam = "param_" + String.format("%06d", random.nextInt(1000000)); // 随机生成param_后面跟6位数字的any_param
int illegalCaseCount = random.nextInt(10); // 随机生成0到9之间的数字
String smsHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成sms_halt_status
String voiceHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成voice_halt_status
Date alicomCreateTime = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间
String alicomIndustry = ALICOM_INDUSTRIES[random.nextInt(ALICOM_INDUSTRIES.length)];
String alicomCustType = ALICOM_CUST_TYPES[random.nextInt(ALICOM_CUST_TYPES.length)];
String remark = REMARKS[random.nextInt(REMARKS.length)];
String freeSignFlag = random.nextInt(2) == 0 ? "Y" : "N"; // 随机生成Y或N的free_sign_flag
String organizationCode = ORGANIZATION_CODES[random.nextInt(ORGANIZATION_CODES.length)];
String dataType = "A表";
int smsIllegalCount = random.nextInt(10); // 随机生成0到9之间的数字
int voiceIllegalCount = random.nextInt(10); // 随机生成0到9之间的数字
String activeFlag = random.nextInt(2) == 0 ? "Y" : "N"; // 随机生成Y或N的active_flag
System.out.printf("%s, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s\n",
gmtCreate, gmtModified, qualificationId, partnerId, custName, qualificationName, custFrom, custId, aliUid, aliAccount, aliCreateTime,
aliCid, alicomHaltStatus, cbmWorkId, anyParam, illegalCaseCount, smsHaltStatus, voiceHaltStatus, alicomCreateTime, alicomIndustry,
alicomCustType, remark, freeSignFlag, organizationCode, dataType, smsIllegalCount, voiceIllegalCount, activeFlag);
}
}
}
```
该程序使用Java的Random类生成假数据,其中包括:
- gmt_create和gmt_modified字段:随机生成过去的时间和最近的时间
- qualification_id字段:从1到100000随机生成qualification_id
- partner_id字段:随机生成6位数字的partner_id
- cust_name字段:从预定义的名字列表中随机选择
- qualification_name字段:从预定义的资质名称列表中随机选择
- cust_from字段:从预定义的来源列表中随机选择
- cust_id字段:随机生成12位数字的cust_id
- ali_uid字段:随机生成8位数字的ali_uid
- ali_account字段:随机生成ali_后面跟6位数字的ali_account
- ali_create_time字段:随机生成过去的时间
- ali_cid字段:随机生成8位数字的ali_cid
- alicom_halt_status字段:随机生成"正常"或"停用"
- cbm_work_id字段:随机生成cbm_后面跟6位数字的cbm_work_id
- any_param字段:随机生成param_后面跟6位数字的any_param
- illegal_case_count字段:随机生成0到9之间的数字
- sms_halt_status字段:随机生成"正常"或"停用"
- voice_halt_status字段:随机生成"正常"或"停用"
- alicom_create_time字段:随机生成过去的时间
- alicom_industry字段:从预定义的行业列表中随机选择
- alicom_cust_type字段:从预定义的客户类型列表中随机选择
- remark字段:从预定义的备注列表中随机选择
- free_sign_flag字段:随机生成"Y"或"N"
- organization_code字段:从预定义的组织机构代码列表中随机选择
- data_type字段:固定为"A表"
- sms_illegal_count字段:随机生成0到9之间的数字
- voice_illegal_count字段:随机生成0到9之间的数字
- active_flag字段:随机生成"Y"或"N"
你可以根据自己的需求修改或扩展这个程序来生成更多的假数据。
阅读全文