package com.szpg;

import java.util.List;

import com.szpg.db.dao.PgDeviceDao;
import com.szpg.db.dao.PgHjsbblDao;
import com.szpg.db.dao.impl.PgDeviceDaoImpl;
import com.szpg.db.dao.impl.PgHjsbblDaoImpl;
import com.szpg.db.data.PgDevice;
import com.szpg.db.data.PgHjsbbl;
import com.szpg.util.Configure;
import com.szpg.util.HttpRequest;

public class SendBaseTest {

	public static void main(String[] args) {
		// 1根据ACU获取其所有的资产设备Device
		PgHjsbblDao blDao = new PgHjsbblDaoImpl();
		List<PgHjsbbl> blList = blDao.findBlByAcu("THXC.ACU002");

		System.out.println("开始推送变量数据" + blList.size());
		
		int count = 0;

		// 2遍历ACU列表，获取其IP地址与端口号
		for (PgHjsbbl bl : blList) {
			// 发送 POST 请求
			// 推送资产表
			StringBuilder sb = new StringBuilder();
			sb.append("tableName=HJSBBLB");
			sb.append("&Ent.BLBH=").append(bl.getBlbh());
			sb.append("&Ent.ZCBH=").append(bl.getZcbh());
			sb.append("&Ent.PLCDB=").append(bl.getPlcdb());
			sb.append("&Ent.BLMS=").append(bl.getBlms());
			sb.append("&Ent.BLZLX=").append(bl.getBlzlx());
			sb.append("&Ent.CJPL=").append(bl.getCjpl());

//			String sr = HttpRequest.sendPostByHttp("http://10.10.2.19:9056/GLTHXC/api/Common/AddData", sb.toString());
//			System.out.println(sr + " ====> " + count++);
		}

//		System.out.println("推送资产数据结束" + count);
		
		PgDeviceDao deviceDao = new PgDeviceDaoImpl();
		
		String zcbh = "THXC.ACU001.X.SCH01";
		String acucode = zcbh.substring(0, zcbh.indexOf(".", 6));
		String cabin = zcbh.substring(zcbh.lastIndexOf(".") + 1, zcbh.lastIndexOf(".") + 2);
		List<PgDevice> fjs = deviceDao.findDeviceByPositionAndType(acucode, "F", cabin);
		if (null != fjs && fjs.isEmpty() == false) {
			String baseURL = Configure.getProperty("sys", "PGDSC_API_URL");
			for (PgDevice fj : fjs) {
				String fjzcbh = fj.getAssetcode();
				
				System.out.println(fjzcbh);
			}
		}
	}
}
