jmeter针对订单做导出功能(根据接口返回字段进行筛选导出)
程序员文章站
2022-05-04 16:57:31
...
重点1:正则表达式提取需要导出的值
重点2:后置处理器的BeanShell PostProcessor进行脚本编写
String a = "截止17点";
String b = "${__time(dd,)}日";
String path = "G:/data/"+b+"订单数据导出"+a+".csv";
String orderStatus = vars.get("orderStatus");
String type;
//根据订单状态码进行对应文案转换
if(orderStatus.equals("1"))
{
type = "待付款";
}else if(orderStatus.equals("2"))
{
type = "订单待审核";
}else if(orderStatus.equals("3"))
{
type = "车辆待维护";
}else if(orderStatus.equals("4"))
{
type = "物流询价中";
}else if(orderStatus.equals("5"))
{
type = "待提货";
}else if(orderStatus.equals("6"))
{
type = "提货中";
}else if(orderStatus.equals("7"))
{
type = "已完成";
}else if(orderStatus.equals("8"))
{
type = "换货";
}else if(orderStatus.equals("9"))
{
type = "退货退款";
}else if(orderStatus.equals("10"))
{
type = "已取消";
}else if(orderStatus.equals("20"))
{
type = "派单中";
}else if(orderStatus.equals("21"))
{
type = "初次派单";
}else if(orderStatus.equals("22"))
{
type = "重新派单中";
}else if(orderStatus.equals("23"))
{
type = "延期待审核";
}else if(orderStatus.equals("31"))
{
type = "供应商车辆维护";
}else if(orderStatus.equals("32"))
{
type = "车辆待维护";
}else if(orderStatus.equals("41"))
{
type = "物流待支付";
}else if(orderStatus.equals("42"))
{
type = "询价审核中";
}else if(orderStatus.equals("61"))
{
type = "运输中";
}else if(orderStatus.equals("62"))
{
type = "待收货";
}else if(orderStatus.equals("70"))
{
type = "涨亏吨待处理";
}else if(orderStatus.equals("71"))
{
type = "涨亏吨待审核";
}else if(orderStatus.equals("91"))
{
type = "仅退款";
};
//创建文件流
FileWriter fstream = new FileWriter(path, true);
BufferedWriter out = new BufferedWriter(fstream);
//写入数据到文档中 “,”是指换列
out.write( vars.get("consumerName"));
out.write(",");
out.write( vars.get("itemName"));
out.write(",");
out.write( vars.get("itemTotalNum"));
out.write(",");
out.write( vars.get("orderRealNum"));
out.write(",");
out.write(type);
//此处是为了换行
out.write(System.getProperty("line.separator"));
//关闭流
out.close();
fstream.close();