Commit 721a9ca1 by wanggang

添加优化温度获取执行方法

parent c515e573
......@@ -76,7 +76,7 @@ public class ContainerStatus {
}
@Test
public void containerStatusTest04(){
public void containerStatusTest03(){
String url = "http://manager.mjitech.com/api/machines/50/container_status" ;
try {
json = service.httppostHeaderContainerStatusReturnJson(url);
......@@ -101,7 +101,7 @@ public class ContainerStatus {
}
@Test
public void containerStatusTest05(){
public void containerStatusTest04(){
String url = "http://manager.mjitech.com/api/machines/36/container_status" ;
try {
json = service.httppostHeaderContainerStatusReturnJson(url);
......@@ -127,7 +127,7 @@ public class ContainerStatus {
@Test
public void containerStatusTest07(){
public void containerStatusTest05(){
String url = "http://manager.mjitech.com/api/machines/40/container_status" ;
try {
json = service.httppostHeaderContainerStatusReturnJson(url);
......@@ -152,7 +152,7 @@ public class ContainerStatus {
}
@Test
public void containerStatusTest08(){
public void containerStatusTest06(){
String url = "http://manager.mjitech.com/api/machines/41/container_status" ;
try {
json = service.httppostHeaderContainerStatusReturnJson(url);
......@@ -176,28 +176,5 @@ public class ContainerStatus {
}
@Test
public void containerStatusTest09(){
String url = "http://manager.mjitech.com/api/machines/45/container_status" ;
try {
json = service.httppostHeaderContainerStatusReturnJson(url);
System.out.println("json"+json);
SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
format.setLenient(false);
format.format(date);
buffer.append("45-爱这城店-"+date+"--"+json+"\r\n");
fw = new FileWriter(file,true) ;
fw.write(buffer.toString());
fw.flush();
fw.close();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
......@@ -28,24 +28,27 @@ import okhttp3.Request;
import okhttp3.Response;
import org.testng.annotations.Test;
public class PickUpGoodsTest {
BaseService service = new BaseService();
JSONObject json = JSONObject.fromObject("{}");
List<org.apache.http.cookie.Cookie> cookies=null;
String cookiesValues = "" ;
Map map = new HashMap() ;
List<org.apache.http.cookie.Cookie> cookies = null;
String cookiesValues = "";
Map map = new HashMap();
/**
* 批量获取SKU
* */
*/
public List getSkuList(int warehouse_id) {
List skuList = new ArrayList() ;
List skuList = new ArrayList();
DBConnection db = new DBConnection("test");
ResultSet rs = null ;
String sql = "SELECT sku_id FROM mt_inventory WHERE warehouse_id = "+warehouse_id+" AND quantity >0 AND STATUS = 1; " ;
ResultSet rs = null;
String sql = "SELECT sku_id FROM mt_inventory WHERE warehouse_id = " + warehouse_id
+ " AND quantity >0 AND STATUS = 1; ";
try {
Statement stmt = db.conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()) {
while (rs.next()) {
int sku_id = rs.getInt("sku_id");
skuList.add(sku_id);
}
......@@ -53,18 +56,17 @@ public class PickUpGoodsTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
return skuList ;
return skuList;
}
/**
* 登录
* */
*/
@Test
public void login(){
public void login() {
CookieStore cookieStore = new BasicCookieStore();
String loginUrl = "https://www.mjitech.com/web/login.action";
CloseableHttpClient client = HttpClients.custom()
.setDefaultCookieStore(cookieStore).build();
CloseableHttpClient client = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
HttpPost httpPost = new HttpPost(loginUrl);
JSONObject jsonParam = new JSONObject();
jsonParam.put("username", "gangwang@mjitech.com");
......@@ -81,8 +83,9 @@ public class PickUpGoodsTest {
List<org.apache.http.cookie.Cookie> cookies = cookieStore.getCookies();
if (CollectionUtils.isNotEmpty(cookies)) {
for (org.apache.http.cookie.Cookie cookie : cookies) {
// cookiesValues = cookie.getName() + "=" + cookie.getValue()+";";
System.out.println(cookie.getName() + "=" + cookie.getValue()+";");
// cookiesValues = cookie.getName() + "=" +
// cookie.getValue()+";";
System.out.println(cookie.getName() + "=" + cookie.getValue() + ";");
map.put(cookie.getName(), cookie.getValue());
}
}
......@@ -100,27 +103,26 @@ public class PickUpGoodsTest {
}
/**
* 单品测试
* * */
// @Test(dependsOnMethods="login")
* 单品测试 *
*/
// @Test(dependsOnMethods="login")
public void pickUpGoodsTest01() {
String JSESSIONID = (String)map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'"+";ga=GA1.2.1640278628.1537349020;"+"JSESSIONID="+JSESSIONID ;
System.out.println("CookiesValues="+cookiesValues);
String JSESSIONID = (String) map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'" + ";ga=GA1.2.1640278628.1537349020;"
+ "JSESSIONID=" + JSESSIONID;
System.out.println("CookiesValues=" + cookiesValues);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://www.mjitech.com/web/pick_up_goods/52/86547")
.get()
// .addHeader("Cookie", "mjitech_username='gangwang@mjitech.com'; _ga=GA1.2.1640278628.1537349020; JSESSIONID=E0430372DC47BC880A93537AF0387924")
.addHeader("Cookie", cookiesValues)
.addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe")
.build();
Request request = new Request.Builder().url("http://www.mjitech.com/web/pick_up_goods/52/86547").get()
// .addHeader("Cookie",
// "mjitech_username='gangwang@mjitech.com';
// _ga=GA1.2.1640278628.1537349020;
// JSESSIONID=E0430372DC47BC880A93537AF0387924")
.addHeader("Cookie", cookiesValues).addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe").build();
try {
Response response = client.newCall(request).execute();
System.out.println("抓取结果:"+response);
System.out.println("抓取结果:" + response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......@@ -129,33 +131,30 @@ public class PickUpGoodsTest {
/**
* 多品测试
* */
// @Test
*/
// @Test
public void pickUpGoodsTest03() {
String JSESSIONID = (String)map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'"+";ga=GA1.2.1640278628.1537349020;"+"JSESSIONID="+JSESSIONID ;
System.out.println("CookiesValues="+cookiesValues);
String JSESSIONID = (String) map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'" + ";ga=GA1.2.1640278628.1537349020;"
+ "JSESSIONID=" + JSESSIONID;
System.out.println("CookiesValues=" + cookiesValues);
OkHttpClient client = new OkHttpClient();
List sku_id_list = getSkuList(34);
for(int i=0;i<sku_id_list.size();i++) {
int sku_id = (Integer)sku_id_list.get(i);
Request request = new Request.Builder()
.url("http://test.mjitech.com/web/pick_up_goods/34/"+sku_id+"")
.get()
.addHeader("Cookie",cookiesValues)
.addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe")
.build();
for (int i = 0; i < sku_id_list.size(); i++) {
int sku_id = (Integer) sku_id_list.get(i);
Request request = new Request.Builder().url("http://test.mjitech.com/web/pick_up_goods/34/" + sku_id + "")
.get().addHeader("Cookie", cookiesValues).addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe").build();
try {
Response response = client.newCall(request).execute();
System.out.println("抓取结果:"+sku_id+response);
System.out.println("抓取结果:" + sku_id + response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
//休眠50秒
// 休眠50秒
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
......@@ -167,43 +166,45 @@ public class PickUpGoodsTest {
/**
* 多品测试-按照货道号进行测试-华贸写字楼店
* */
@Test(dependsOnMethods="login")
*/
@Test(dependsOnMethods = "login")
public void pickUpGoodsTestXieZiLou() {
String JSESSIONID = (String)map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'"+";ga=GA1.2.1640278628.1537349020;"+"JSESSIONID="+JSESSIONID ;
System.out.println("CookiesValues="+cookiesValues);
String JSESSIONID = (String) map.get("JSESSIONID");
String cookiesValues = "mjitech_username='gangwang@mjitech.com'" + ";ga=GA1.2.1640278628.1537349020;"
+ "JSESSIONID=" + JSESSIONID;
System.out.println("CookiesValues=" + cookiesValues);
OkHttpClient client = new OkHttpClient();
// List sku_id_list = getSkuList(34);86547
// int mt_new_sku_pass[] = {86509,86509,86509,86509,86509,86547,86547,86547,86547,86547};
// int mt_new_sku_pass[] =
// {86509,86509,86509,86509,86509,86547,86547,86547,86547,86547};
// int mt_new_sku_pass[] = {86575,86575,86575,86575,86575,86575};
//运转标准策略 10 {86450,86551,86555,86514,86490,86489,86569,86486,86519,86497};
int mt_new_sku_pass[] = {86555};
//20
// int mt_new_sku_pass[] = {86593,86561,86555,86495,86490,86591,86635,86633,86528,86459};
//30
// int mt_new_sku_pass[] = {86537,86598,86454,86544,86614,86527,86450,86563,86464,86594};
//34
// 运转标准策略 10
// {86450,86551,86555,86514,86490,86489,86569,86486,86519,86497};
int mt_new_sku_pass[] = { 86555 };
// 20
// int mt_new_sku_pass[] =
// {86593,86561,86555,86495,86490,86591,86635,86633,86528,86459};
// 30
// int mt_new_sku_pass[] =
// {86537,86598,86454,86544,86614,86527,86450,86563,86464,86594};
// 34
// int mt_new_sku_pass[] = {86501,86517,86599,86455};
for(int i=0;i<mt_new_sku_pass.length;i++) {
//int sku_id = (Integer)sku_id_list.get(i);
for (int i = 0; i < mt_new_sku_pass.length; i++) {
// int sku_id = (Integer)sku_id_list.get(i);
Request request = new Request.Builder()
.url("http://www.mjitech.com/web/pick_up_goods/52/"+mt_new_sku_pass[i]+"")
.get()
.addHeader("Cookie",cookiesValues)
.addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe")
.build();
.url("http://www.mjitech.com/web/pick_up_goods/52/" + mt_new_sku_pass[i] + "").get()
.addHeader("Cookie", cookiesValues).addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "ee590a55-6c93-413b-b60b-21b4a88f38fe").build();
try {
Response response = client.newCall(request).execute();
System.out.println("上海测试机器-华贸写字楼店-批量抓测结果-->"+mt_new_sku_pass+response);
System.out.println("上海测试机器-华贸写字楼店-批量抓测结果-->" + mt_new_sku_pass + response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
//休眠50秒
// 休眠50秒
Thread.sleep(30000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment