package cn.net.test;

import java.io.IOException;
import java.net.BindException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

import cn.net.cpzslibs.prot.Prot02Logout;
import cn.net.cpzslibs.prot.Prot03GetImage;
import cn.net.cpzslibs.prot.SocketCreate;

/**
 * 消费者app测试
 * @author zwj
 *
 * 2015-6-3
 */
public class MainCpzsTest {

	/**
	 * <br/>
	 * 2015-6-3上午9:34:28
	 * 
	 * @param args
	 * @throws IOException
	 * @throws UnknownHostException
	 * @throws SocketTimeoutException
	 * @throws ConnectException
	 * @throws BindException
	 */
	public static void main(String[] args) {
//		SocketCreate create = new SocketCreate("192.168.0.46", 8898,
//				"A100003F289D241");
		SocketCreate create = new SocketCreate("218.245.0.108", 8002,
				"A100003F289D241");
		try {
			create.createLoginCpzs(1000460218440638L);
			System.out.println(create.getiCompanyId()+";workStyle:"+create.getiWorkStyle());
//			if (create.isResult()) {
//				Prot11DownConflictInfo conflictInfo = new Prot11DownConflictInfo();
//				conflictInfo.dealDownConflictInfo(create, 1);
//				System.out.println(conflictInfo.getJsonData());
//			}else{
//				System.out.println("登录失败"+create.getErrMsg());
//			}
//			long start = loge("开始");
//			Prot21ProductInfo info = new Prot21ProductInfo();
//			info.dealProductInfo(create);
//			subTime(start);
			
			if(create.isResult()){
				Prot03GetImage image = new Prot03GetImage();
				image.dealRedWineAuthIamge(create);
				String jsonData = image.getJsonData();
				System.out.println("jsonData--->"+jsonData);
				
				image.dealProductIntrodImage(create);
				String s = image.getJsonData();
				System.out.println(s);
//				Prot13QueryCount count = new Prot13QueryCount();
//				count.dealQueryCountSwitch(create);
//				System.out.println("query-->"+count.getiConsCount());
//				count.dealConsCountSwitch(create, 1020600, (short)6211);
//				System.out.println("cons-->"+count.getiConsCount());
				
			}
			
		} catch (BindException e) {
			e.printStackTrace();
		} catch (ConnectException e) {
			e.printStackTrace();
		} catch (SocketTimeoutException e) {
			e.printStackTrace();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			new Prot02Logout().dealLogout(create);
		}

	}
private static long loge(Object obj){
	long time = System.currentTimeMillis();
	System.out.println(time+" ;"+obj.toString());
	return time;
}
private static void subTime(long start){
	long time = System.currentTimeMillis();
	System.out.println(time-start);
}

}
