package com.steering.pss.qcm;

import java.util.ArrayList;

import CoreFS.SA06.CoreReturnObject;
import com.steering.comm.db.DBCommon;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

public class CoreProcessParametersD extends DBCommon {

	
	
	
	/**
	 * 获取工序点代码和关联条数
	 * 
	 * @return
	 */
	public CoreReturnObject GetProcessGL() {
		return this.getDataBySqlID("CoreProcessParametersD.GetProcessGL");
	}
	
	
	/**
	 * 保存之前，先清除之前工序点对应的所有工艺参数
	 * 
	 * @return
	 */
	public void doClear(String processCode) {
		String DeleteSql = CoreXmlSqlParsersFactory
				.getSql("CoreProcessParametersD.doDelete");

		Object[] params = new Object[] { processCode };

		try {
			this.getDao("TgDao").ExcuteNonQuery(DeleteSql, params);
		} catch (Exception e) {

		}

	}

	/**
	 * 保存
	 */
	public CoreReturnObject doSave(ArrayList<ArrayList<Object>> Params,
			String stationCode) {
		// 删除对应表里面当前工序点所对应的全部字段。
		doClear(stationCode);

		CoreReturnObject spbCro = new CoreReturnObject();

		String spbAddSql = CoreXmlSqlParsersFactory
				.getSql("CoreProcessParametersD.doSave");

		ArrayList<Object> spbSqlList = new ArrayList<Object>();
		ArrayList<Object[]> spbParmList = new ArrayList<Object[]>();

		if (Params.size() > 0) {
			for (int i = 0; i < Params.size(); i++) {
				spbSqlList.add(spbAddSql);
				spbParmList.add(Params.get(i).toArray());
			}
		}
		try {
			spbCro = this.getDao("TgDao").ExcuteTransction(spbSqlList,
					spbParmList);
		} catch (Exception e) {
			spbCro = spbCro.SetErrInfo(e.getMessage());
		}

		return spbCro;

	}

	/**
	 * 根据工序点代码获取工艺参数
	 * 
	 * @return
	 */
	public CoreReturnObject GetParameters(String processCode) {
		Object[] params = new Object[] { processCode };
		return this.getDataBySqlID("CoreProcessParametersD.GetParameters",
				params);
	}

	/**
	 * 工艺参数基础信息查询
	 * 
	 * @param includeDeleted
	 *            是否包含已删除数据getLineList
	 * @param name
	 *            工艺参数描述
	 * @return CoreReturnObject 必须返回CoreReturnObject
	 */
	public CoreReturnObject getLineList(String processCode) {
		Object[] params = new Object[] { processCode };
		return this.getDataBySqlID("CoreProcessParametersD.QUERY",params);
	}
}
