BEANSHELL SAMPLE 生成身份证号
来源:互联网 发布:景德镇房管局交易数据 编辑:程序博客网 时间:2024/06/01 08:54
import java.util.*;
StringBuilder generater = new StringBuilder();
Map areaCode = new HashMap();
Map areaCode = new HashMap();
areaCode.put("北京市", 110000);
areaCode.put("市辖区", 110100);
areaCode.put("东城区", 110101);
areaCode.put("西城区", 110102);
areaCode.put("崇文区", 110103);
areaCode.put("宣武区", 110104);
areaCode.put("朝阳区", 110105);
areaCode.put("丰台区", 110106);
areaCode.put("石景山区", 110107);
areaCode.put("清河门区", 210905);
areaCode.put("细河区", 210911);
areaCode.put("彰武县", 210922);
areaCode.put("辽阳市", 211000);
areaCode.put("市辖区", 211001);
areaCode.put("白塔区", 211002);
areaCode.put("文圣区", 211003);
areaCode.put("宏伟区", 211004);
areaCode.put("新北区", 320411);
areaCode.put("武进区", 320412);
areaCode.put("溧阳市", 320481);
areaCode.put("金坛市", 320482);
areaCode.put("苏州市", 320500);
areaCode.put("市辖区", 320501);
areaCode.put("鹤壁市", 410600);
areaCode.put("市辖区", 410601);
areaCode.put("鹤山区", 410602);
areaCode.put("山城区", 410603);
areaCode.put("淇滨区", 410611);
areaCode.put("浚 县", 410621);
areaCode.put("淇 县", 410622);
areaCode.put("新乡市", 410700);
areaCode.put("青白江区", 510113);
areaCode.put("新都区", 510114);
areaCode.put("温江区", 510115);
areaCode.put("金堂县", 510121);
areaCode.put("双流县", 510122);
areaCode.put("郫 县", 510124);
areaCode.put("大邑县", 510129);
areaCode.put("蒲江县", 510131);
areaCode.put("新津县", 510132);
areaCode.put("乾 县", 610424);
areaCode.put("礼泉县", 610425);
areaCode.put("永寿县", 610426);
areaCode.put("彬 县", 610427);
areaCode.put("长武县", 610428);
areaCode.put("旬邑县", 610429);
areaCode.put("淳化县", 610430);
areaCode.put("武功县", 610431);
areaCode.put("兴平市", 610481);
areaCode.put("渭南市", 610500);
//地区号
String randomAreaCode="";
int index = (int) (Math.random() * areaCode.size());
Collection values = areaCode.values();
Iterator it = values.iterator();
int i = 0;
int code = 0;
while (i < index && it.hasNext()) {
i++;
randomAreaCode = it.next().toString();
}
generater.append(randomAreaCode);
//生日
String randomBirthday="";
Calendar birthday = Calendar.getInstance();
birthday.set(Calendar.YEAR, (int) (Math.random() * 60) + 1950);
birthday.set(Calendar.MONTH, (int) (Math.random() * 12));
birthday.set(Calendar.DATE, (int) (Math.random() * 31));
StringBuilder builder = new StringBuilder();
builder.append(birthday.get(Calendar.YEAR));
long month = birthday.get(Calendar.MONTH) + 1;
if (month < 10) {
builder.append("0");
}
builder.append(month);
long date = birthday.get(Calendar.DATE);
if (date < 10) {
builder.append("0");
}
builder.append(date);
randomBirthday= builder.toString();
generater.append(randomBirthday);
//随机码
String randomCode="";
int code = (int) (Math.random() * 1000);
if (code < 10) {
randomCode= "00" + code;
} else if (code < 100) {
randomCode= "0" + code;
} else {
randomCode= "" + code;
}
generater.append(randomCode);
//验证码
char[] chars= generater.toString().toCharArray();
int[] c = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
char[] r = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
int[] n = new int[17];
int result = 0;
for (int i = 0; i < n.length; i++) {
n[i] = Integer.parseInt(chars[i] + "");
}
for (int i = 0; i < n.length; i++) {
result += c[i] * n[i];
}
char validateCode = r[result % 11];
generater.append(validateCode);
vars.put("idNumber",generater.toString()) ;
SampleResult.setResponseData(generater.toString());
builder.append(birthday.get(Calendar.YEAR));
long month = birthday.get(Calendar.MONTH) + 1;
if (month < 10) {
builder.append("0");
}
builder.append(month);
long date = birthday.get(Calendar.DATE);
if (date < 10) {
builder.append("0");
}
builder.append(date);
randomBirthday= builder.toString();
generater.append(randomBirthday);
//随机码
String randomCode="";
int code = (int) (Math.random() * 1000);
if (code < 10) {
randomCode= "00" + code;
} else if (code < 100) {
randomCode= "0" + code;
} else {
randomCode= "" + code;
}
generater.append(randomCode);
//验证码
char[] chars= generater.toString().toCharArray();
int[] c = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
char[] r = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
int[] n = new int[17];
int result = 0;
for (int i = 0; i < n.length; i++) {
n[i] = Integer.parseInt(chars[i] + "");
}
for (int i = 0; i < n.length; i++) {
result += c[i] * n[i];
}
char validateCode = r[result % 11];
generater.append(validateCode);
vars.put("idNumber",generater.toString()) ;
SampleResult.setResponseData(generater.toString());
阅读全文
0 0
- BEANSHELL SAMPLE 生成身份证号
- JMETER BEANSHELL SAMPLE 加密
- BeanShell Sample与控制台交互
- 根据 身份证号 生成出生日期
- Excel自动生成身份证号
- php 生成身份证号
- Beanshell
- BeanShell
- BeanShell
- BeanShell
- beanshell
- BeanShell
- 随机生成身份证号和年龄
- C++自动生成身份证号代码
- python3.4 自动生成身份证号
- 身份证号
- 身份证号
- Random生成随机可用的身份证号
- Promise红绿灯
- cximage DrawStringEx 绘制中文文本时,会造成文字丢失问题
- Maven的依赖范围、依赖冲突、依赖排除和版本限定
- 1006. 换个格式输出整数 (15)
- 【python】简单的图片隐写术
- BEANSHELL SAMPLE 生成身份证号
- BZOJ 1085: [SCOI2005]骑士精神 启发式搜索+迭代加深
- Sublime Text快捷键去除空白行
- 套路/错误集/黑科技/好写法
- 页面前进一页
- 坚持#第224天~零基础自学云计算基础语言应用之Shell18~22节
- 银行数据
- 如何让文本可复制
- 五天面试五家硅谷顶尖公司并拿到五个Offer