package com.steering.pss.qcm;

import java.sql.SQLException;
import java.util.ArrayList;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.db.DBCommon;

/**
 * 轧管产线与管坯规格对应基础信息管理类
 * @author WQ 2014/10/16
 * @version v1.0
 * @modify
 */
public class CoreTubeRolling extends DBCommon {
	
	
	
	
	/**
	 * 判断产线、孔型、产品规格是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isOnly(String proLineInfo, String kType, String ggType) {
		Object[] obj = new Object[] { proLineInfo,kType,ggType };
		return this.getDataBySqlID("CoreTubeRolling.isOnly", obj);
	}
	
	/**
	 * 判断产品规格代码是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isGGType(String name) {
		Object[] obj = new Object[] { name };
		return this.getDataBySqlID("CoreTubeRolling.isGGType", obj);
	}
	
	/**
	 * 判断孔型代码是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isKType(String name) {
		Object[] obj = new Object[] { name };
		return this.getDataBySqlID("CoreTubeRolling.isKType", obj);
	}
	
	/**
	 * 判断产线代码是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isProLineInfo(String name) {
		Object[] obj = new Object[] { name };
		return this.getDataBySqlID("CoreTubeRolling.isProLineInfo", obj);
	}
	
	
	/**
	 * 获取管坯规格代码和描述
	 * @return
	 */
	public CoreReturnObject GetGGType() {
		return this.getDataBySqlID("CoreTubeRolling.GetGGType");
	}
	
	/**
	 * 获取孔型代码和描述
	 * 
	 * @return
	 */
	public CoreReturnObject GetKType() {
		return this.getDataBySqlID("CoreTubeRolling.GetKType");
	}
	
	/**
	 * 获取产线代码和描述
	 * 
	 * @return
	 */
	public CoreReturnObject GetProLineInfo() {
		return this.getDataBySqlID("CoreTubeRolling.GetProLineInfo");
	}
	
	
	/**
     * 轧管产线与管坯规格对应基础信息查询
     * @param includeDeleted 是否包含已删除数据
     * @param name 轧管产线与管坯规格对应描述
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
	public CoreReturnObject getLineList(Boolean includeDeleted,
            String name) {
        String deletedFlag = includeDeleted ? "0" : "";
        Object[] params = new Object[] { deletedFlag, name};
        return this.getDataBySqlID("CoreTubeRolling.QUERY", params);
	}
	
	/**
     * 轧管产线与管坯规格对应基础信息新增
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
	public CoreReturnObject doAdd(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTubeRolling.ADD");
		try {
			cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
		} catch (SQLException e) {
			cro = cro.SetErrInfo(e.getMessage());
		}
		return cro;
	}
	
	/**
     * 轧管产线与管坯规格对应基础信息修改
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
	public CoreReturnObject doModify(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTubeRolling.MODIFY");
		try {
			cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
		} catch (SQLException e) {
			cro = cro.SetErrInfo(e.getMessage());
		}
		return cro;
	}

	/**
     * 轧管产线与管坯规格对应基础信息删除或恢复
     * @param plineCodes 产线代码集合
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject deleteLineInfo(ArrayList<Object> Codes,
            String operator, Boolean isDelete) {  	
    	CoreReturnObject cro = new CoreReturnObject();
    	
    	ArrayList<Object> params=new ArrayList<Object>();
    	
    	String plineCode=Codes.get(0).toString();
    	String passCode=Codes.get(1).toString();
    	String specCode=Codes.get(2).toString();
    	
    	
    	
    	
    	String strSql="";
    	
    	if(isDelete)
    	{
    		params.add(operator);
        	params.add(plineCode);
        	params.add(passCode);
        	params.add(specCode);
    		strSql=CoreXmlSqlParsersFactory.getSql("CoreTubeRolling.DELETE");
    	}
    	else
    	{
    		params.add(plineCode);
        	params.add(passCode);
        	params.add(specCode);
    		strSql=CoreXmlSqlParsersFactory.getSql("CoreTubeRolling.RESUME");
    	}
    	
    	
    	try {
			cro = this.getDao("TgDao").ExcuteNonQuery(strSql, params.toArray());
		} catch (SQLException e) {
			cro = cro.SetErrInfo(e.getMessage());
		}
    	
    	return cro;
	}
}
