package cn.net.test;

import com.jymf.common.LableUtil;

import java.util.List;

import cn.net.cpzslibs.prot.Prot02Logout;
import cn.net.cpzslibs.prot.SocketCreate;
import cn.net.cpzslibs.prot.handset.Prot10054GetDealer;
import cn.net.cpzslibs.prot.handset.Prot10084NewWineLogin;
import cn.net.cpzslibs.prot.handset.bean.Prot10054SendDealerBean;
import cn.net.cpzslibs.prot.handset.bean.Prot10084SendBeanNewWine;

/*
 * 酒类经销商 所有协议
 */
public class NewWineText {

	public static void main(String[] args) {
	// for(int i = 0 ;i<100;i++){  
		String ip = "218.245.0.109"; //218.245.0.109 192.168.0.46
		int port = 8898;
		SocketCreate create = new SocketCreate(ip, port, "");
		try {
			create.createJustCreateSocket();
			// 测试84号登录

			Prot10084NewWineLogin login = new Prot10084NewWineLogin();

			login.dealCpzsNewWine(create, new Prot10084SendBeanNewWine(
					"358000091", "355128005804331", ""));                         
			System.out.println("登录结果" + login.getLoginResult().getiResult());
			/*Prot10082ChukuNewWine p82 = new Prot10082ChukuNewWine();

			// "866622020589697","1000010024695496","31","2016-10-18 13:30:51"
			// ,"测试出库")

			List<String> single = new ArrayList<String>();
			getArray(single, 1999);
			System.out.println("长度" + single.size());*/

			//
			// single.add("1000051981797642");
			// single.add("1000010026782731");
			// single.add("1000010026795783");

			// single.add("1000051981801778");
			// single.add("1000051981815739");
			// 1 出库 2 返库

			/*p82.dealChuKuNewWine(create, new Prot10082SendBeanWine(
					"355128005922687", single, "37", "2016-10-18 13:30:51", 1,
					0, "测试出库"));
			System.out.println(p82.getRes());
*/
			// login.dealCpzsNewWine(create, new
			// Prot10053SendBeanNewWine("358000091", "355128005922687", ""));

			// 83号查询
			/*
			 * Prot10083QueryNewWine p83 = new Prot10083QueryNewWine();
			 * p83.dealQueryNewWine(create, new
			 * Prot10083SendBeanWine("355128005922687", "1000051981797642"));
			 * System.out.println(p83.getRes());
			 */

			// 下载二级经销商

			Prot10054GetDealer p54 = new Prot10054GetDealer();
			p54.dealGetDealer(create, new Prot10054SendDealerBean(1));
			System.out.println(p54.getRes().getList());

			// e10adc3949ba59abbe56e057f20f883e
			// 修改密码
			// Prot10055ChangePassWord p55 = new Prot10055ChangePassWord();
			// p55.dealChangePassWord(create, new
			// Prot10055SendBeanPassWord("358000091", "355128005804331",
			// "e10adc3949ba59abbe56e057f20f883e",
			// "96e79218965eb72c92a549dd5a330112"));
			// 入库
			/*
			 * Prot10056RuKuNewWine p56 = new Prot10056RuKuNewWine();
			 * 
			 * Prot10056SendBeanNewWine bean = new
			 * Prot10056SendBeanNewWine("110", "1000010024949048", "测试1111");
			 * System.out.println(bean.getIemi_id());
			 * 
			 * p56.dealRuKuNewWine(create, bean);
			 */

			/*
			 * Prot10057ChuKuNewWine p57 = new Prot10057ChuKuNewWine();
			 * p57.dealChuKuNewWine(create, new
			 * Prot10057SendBeanNewWine("866622020589697"
			 * ,"1000010024695496","31","2016-10-18 13:30:51" ,"测试出库"));
			 * System.out.println(p57.getRes().getiResult());
			 */
			/*
			 * Prot10058QueryNewWine p58 = new Prot10058QueryNewWine();
			 * p58.dealQueryNewWine(create, new
			 * Prot10058SendBean("866622020589697", "1000010024695496"));
			 * System.out.println(p58.getRes().getiResult());
			 */

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		} finally {
			System.out.println("退出");
			new Prot02Logout().dealLogout(create);
		}
		// }
	}

	private static String getLabelId(String id) {
		String labelId = LableUtil.getCheckNum(id);
		return labelId;
	}

	public static List<String> getArray(List<String> single, int num) {
		for (int i = 0; i <= num; i++) {
			String str = "";
			int b = String.valueOf(i).length();
			switch (b) {
			case 1:// 9位
				str = "10002000300" + i;
				break;
			case 2:
				str = "1000200030" + i;
				break;
			case 3:
				str = "100020003" + i;
				break;
			case 4:
				str = "10002001" + i;
				break;
			default:
				break;
			}

			single.add(getLabelId(str));
		}
		return single;
	}

}
