package com.steering.mes.port.mil;

import java.util.ArrayList;

import com.steering.comm.db.DBCommon;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

/**
 * 轧管工序合同 工艺设计检验项目确认
 * 
 * @author HC 2015/09/16
 * @version v1.0
 * @modify
 */
public class FrmMilConfirmItems extends DBCommon {

	/**
	 * 查询轧管工序合同
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject QueryPln_Order_Zg(ArrayList<Object> arrayList,
			String strPlcode) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmMilConfirmItems.QueryPln_Order_Zg");

		sql += " AND PLINE_CODE IN " + strPlcode;

		sql += " ORDER BY CREATE_TIME";
		return this.getData(sql, arrayList.toArray());
	}

	/**
	 * 检验确认项目
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject UpdatePln_Order_Zg(ArrayList<Object> al) {

		return this.setDataBySqlID("FrmMilConfirmItems.UpdatePln_Order_Zg", al
				.toArray());
	}

	/**
	 * 合同检验项确认
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject UpdatePln_Order_Zg_(
			ArrayList<ArrayList<ArrayList<Object>>> al) {
		ArrayList<String> sqlIdList = new ArrayList<String>();// 存放执行语句
		ArrayList<Object[]> params = new ArrayList<Object[]>();// 存放参数

		for (int i = 0; i < al.get(0).size(); i++) {
			sqlIdList.add("FrmMilConfirmItems.UpdatePln_Order_Zg");
			params.add(al.get(0).get(i).toArray());// 
		}

		if (al.size() > 1) {
			for (int i = 0; i < al.get(1).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPicSmp");
				params.add(al.get(1).get(i).toArray());// 增加
			}
		}

		if (al.size() > 2) {
			for (int i = 0; i < al.get(2).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPic");
				params.add(al.get(2).get(i).toArray());// 增加项目明细
			}
		}

		if (al.size() > 3) {
			for (int i = 0; i < al.get(3).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPicSmpSelect");
				params.add(al.get(3).get(i).toArray());// 增加项目明细
			}
		}

		if (al.size() > 4) {
			for (int i = 0; i < al.get(4).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPicSelect");
				params.add(al.get(4).get(i).toArray());// 增加项目明细
			}
		}

		return this.setDataById(sqlIdList, params);
	}

	public CoreReturnObject CancelUpdatePln_Order_Zg(
			ArrayList<ArrayList<ArrayList<Object>>> al) {
		ArrayList<String> sqlIdList = new ArrayList<String>();// 存放执行语句
		ArrayList<Object[]> params = new ArrayList<Object[]>();// 存放参数

		for (int i = 0; i < al.get(0).size(); i++) {
			sqlIdList.add("FrmMilConfirmItems.UpdatePln_Order_Zg");
			params.add(al.get(0).get(i).toArray());// 
		}

		if (al.size() > 1) {
			for (int i = 0; i < al.get(1).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.DeletePortCraftStdPicSmp");
				params.add(al.get(1).get(i).toArray());// 增加
			}
		}

		if (al.size() > 2) {
			for (int i = 0; i < al.get(2).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.DeletePortCraftStdPic");
				params.add(al.get(2).get(i).toArray());// 增加项目明细
			}
		}

		return this.setDataById(sqlIdList, params);
	}

	/**
	 * 查询取样要求(根据轧管工序合同号)
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject QueryGetSampleReq(ArrayList<Object> arrayList) {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryGetSampleReq",
				arrayList.toArray());
	}

	/**
	 * 查询取样要求(根据轧管工序合同号)
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject QueryGetSampleReq_(ArrayList<Object> arrayList) {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryGetSampleReq_",
				arrayList.toArray());
	}

	/**
	 * 查询取样要求明细理化(根据轧管工序合同号) CRAFT_ORD_DESIGN_STD_PIC
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject QueryGetSampleReqDetail_Phy(
			ArrayList<Object> arrayList) {
		return this.getDataBySqlID(
				"FrmMilConfirmItems.QueryGetSampleReqDetail_Phy", arrayList
						.toArray());
	}

	public CoreReturnObject QueryGetSampleReqDetail_Phy_(
			ArrayList<Object> arrayList) {
		return this.getDataBySqlID(
				"FrmMilConfirmItems.QueryGetSampleReqDetail_Phy_", arrayList
						.toArray());
	}

	/**
	 * 检验确认项目
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject ConfirmPhy(ArrayList<Object> al) {

		return this.setDataBySqlID("FrmMilConfirmItems.ConfirmPhy", al
				.toArray());
	}

	/**
	 * 合同检验项确认
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject ConfirmPhy_(
			ArrayList<ArrayList<ArrayList<Object>>> al) {
		ArrayList<String> sqlIdList = new ArrayList<String>();// 存放执行语句
		ArrayList<Object[]> params = new ArrayList<Object[]>();// 存放参数

		for (int i = 0; i < al.get(0).size(); i++) {
			sqlIdList.add("FrmMilConfirmItems.ConfirmPhy");
			params.add(al.get(0).get(i).toArray());// 
		}

		if (al.size() > 1) {
			for (int i = 0; i < al.get(1).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPicSmp");
				params.add(al.get(1).get(i).toArray());// 增加
			}
		}

		if (al.size() > 2) {
			for (int i = 0; i < al.get(2).size(); i++) {
				sqlIdList.add("FrmMilConfirmItems.AddPortCraftStdPic");
				params.add(al.get(2).get(i).toArray());// 增加项目明细
			}
		}
		return this.setDataById(sqlIdList, params);
	}

	/**
	 * 查询理化项目大类信息
	 * 
	 * @return
	 */
	public CoreReturnObject QueryPhyMaxItems() {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhyMaxItems");
	}

	/**
	 * 查询取样码
	 * 
	 * @return
	 */
	public CoreReturnObject QueryPhySampleCode() {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhySampleCode");
	}

	/**
	 * 查询理化项目小类信息
	 * 
	 * @return
	 */
	public CoreReturnObject QueryPhyMinItems() {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhyMinItems");
	}

	/**
	 * 查询理化项目方向、温度、尺寸信息
	 * 
	 * @return
	 */
	public CoreReturnObject QueryPhyRItems_All() {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhyRItems_All");
	}

	/**
	 * 查询理化项目方向、温度、尺寸信息
	 * 
	 * @return
	 */
	public CoreReturnObject QueryPhyRItems(ArrayList<String> arrayList) {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhyRItems",
				arrayList.toArray());
	}

	/**
	 * 查询理化项目检验补充项信息
	 * 
	 * @return arrayList 补充项类型 ABC
	 */
	public CoreReturnObject QueryPhyItems(ArrayList<String> arrayList) {
		return this.getDataBySqlID("FrmMilConfirmItems.QueryPhyItems",
				arrayList.toArray());
	}

	public CoreReturnObject GetSPEC_JG() {
		return this.getDataBySqlID("FrmMilConfirmItems.GetSPEC_JG"); // 接箍规格描述
	}

	public CoreReturnObject GetBaseData(String strId) {
		return this.getDataBySqlID("FrmMilConfirmItems.GetBaseData",
				new String[] { strId }); // 取大小值4071
	}
}
