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.SocketCreate;
import cn.net.cpzslibs.prot.handset.Prot10060FarmActivate;
import cn.net.cpzslibs.prot.handset.bean.Prot10060FarmActivateBean;

public class HandsetFarm {
	public static void main(String[] args) {

		
		String ip = "218.245.0.109";// 218.245.0.109 192.168.0.46
		int port = 8899;
		SocketCreate create = new SocketCreate(ip, port, "358000477");
		try {
			create.createLoginCpzsHandset(358000477L);//1000022
			System.out.println(" " + create.isResult() +"  " + create.getiCompanyId());
			
			
			if (create.isResult()) {
				Prot10060FarmActivate activate = new Prot10060FarmActivate();
				System.out.println("   上传的数据：" + getActiveBean(create.getiCompanyId()));
				activate.dealActiveList(create, getActiveBean(create.getiCompanyId()));
			}

		} 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();
			System.err.println("IOException:" + e.getLocalizedMessage());
		} finally {
			new Prot02Logout().dealLogout(create);
		}

	
//		Gson gson = new Gson();
//		System.err.println("  testJsonData: " + gson.toJson(getT51ReqBean()));
		
	
	
		
		
	}

	private static Prot10060FarmActivateBean getActiveBean(int companyID) {
		
		Prot10060FarmActivateBean bean = new Prot10060FarmActivateBean();
		bean.setCompany_id(companyID+"");
		bean.setProduct_id("100003");
		bean.setProduce_date("2016-10-21");
		bean.setBatch_number("22222");
		bean.setOrigin("北京");
		bean.setUrl("www.url.com");
		bean.setStart_label_id("1002185596310884");
		bean.setEnd_label_id("1002185596310884");
		
		
		
		return bean;
	}

}
