package com.steering.pss.sale.order;

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

import com.steering.comm.db.DBCommon;

public class CoreTransitLine extends DBCommon {

	
	
	
	/**
	 * 运输方式数据源
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetCydw() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetCydw");
		return cro;
	}
	
	/**
	 * 运输方式数据源
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetYsfs() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetYsfs");
		return cro;
	}
	
	/**
	 * 专用线数据源
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetSpclNo() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetSpclNo");
		return cro;
	}
	
	/**
	 * 始发地类型和终止地类型数据源绑定
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetType() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetType");
		return cro;
	}
	
	/**
	 * 获取到站信息
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetStation() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetStation");
		return cro;
	}
	
	
	/**
	 * 获取港口码头
	 * @param saleRegion
	 * @return
	 */
	public CoreReturnObject GetPort() {
		CoreReturnObject cro =  this.getDataBySqlID("CoreTransitLine.GetPort");
		return cro;
	}
	
	/**
	 * 判断主线路描述是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isRepeatMain(String startDesc,String terminationDesc) {
		Object[] obj = new Object[] { startDesc,terminationDesc };
		return this.getDataBySqlID("CoreTransitLine.isRepeatMain", obj);
	}
	
	/**
	 * 判断线路明细是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isRepeatModeLine(String transitNo, String modeNo, String startDesc,String terminationDesc) {
		Object[] obj = new Object[] { transitNo,modeNo,startDesc,terminationDesc };
		return this.getDataBySqlID("CoreTransitLine.isRepeatModeLine", obj);
	}
	
	
	/**
	 * 判断方案描述是否重复
	 * @param name
	 * @return
	 */
	public CoreReturnObject isRepeatMode(String transitNo,String modeDesc) {
		Object[] obj = new Object[] { transitNo,modeDesc };
		return this.getDataBySqlID("CoreTransitLine.isRepeatMode", obj);
	}
	
	
	
	
	/**
	 * 自动生成编号
	 * @param name
	 * @return
	 */
	public CoreReturnObject GetMaxCode_Main(String type) {
		Object[] obj = new Object[] { type };
		return this.getDataBySqlID("CoreTransitLine.GetMaxCode_Main", obj);
	}
	
	/**
	 * 获取最大顺序号
	 * @param name
	 * @return
	 */
	public CoreReturnObject GetMaxIndexSeq(String transitNo, String modeNo) {
		Object[] obj = new Object[] { transitNo,modeNo };
		return this.getDataBySqlID("CoreTransitLine.GetMaxIndexSeq", obj);
	}
	
	
	
	/**
	 * 获取当前线路下，最大方案编号
	 * @param name
	 * @return
	 */
	public CoreReturnObject GetMaxCode_Mode(String transitNo) {
		Object[] obj = new Object[] { transitNo };
		return this.getDataBySqlID("CoreTransitLine.GetMaxCode_Mode", obj);
	}
	
	/**
	 * 获取总费用
	 * @param name
	 * @return
	 */
	public CoreReturnObject GetTransitMny(String transitNo,String modeNo) {
		Object[] obj = new Object[] { transitNo,modeNo };
		return this.getDataBySqlID("CoreTransitLine.GetTransitMny", obj);
	}
	
	/**
	 * 总费用更新
	 * @param name
	 * @return
	 */
	public CoreReturnObject UpdateTransitMny(String transitMny,String transitNo,String modeNo) {
		Object[] obj = new Object[] { transitMny,transitNo,modeNo };
		return this.setDataBySqlID("CoreTransitLine.UpdateTransitMny",obj);
	}
	
	
	
	/**
     * 线路明细表废除
     * @param plineCodes 产线代码集合
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doDelete_ModeLine(ArrayList<Object> plineCodes,Boolean isDelete) {  	
            if (isDelete) {
            	return this.setDataBySqlID("CoreTransitLine.doDelete_ModeLine",plineCodes.toArray());
                
            }
            else {
                return this.setDataBySqlID("CoreTransitLine.doResume_ModeLine",plineCodes.toArray());
            }
	}
    
    /**
     * 线路明细表废除
     * @param plineCodes 产线代码集合
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doDelete_Mode(ArrayList<Object> plineCodes,Boolean isDelete) {  	
            if (isDelete) {
            	return this.setDataBySqlID("CoreTransitLine.doDelete_Mode",plineCodes.toArray());
                
            }
            else {
                return this.setDataBySqlID("CoreTransitLine.doResume_Mode",plineCodes.toArray());
            }
	}
    
    /**
     * 方案子记录废除或恢复
     * @param plineCodes 产线代码集合
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doDelete_Mode_Item(ArrayList<Object> plineCodes,Boolean isDelete) {  	
            if (isDelete) {
            	return this.setDataBySqlID("CoreTransitLine.doDelete_Mode_Item",plineCodes.toArray());
                
            }
            else {
                return this.setDataBySqlID("CoreTransitLine.doResume_Mode_Item",plineCodes.toArray());
            }
	}
    
    /**
     * 主线路删除
     * @param plineCodes 产线代码集合
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doDelete_Main(ArrayList<Object> plineCodes,Boolean isDelete) {  	
		ArrayList<String> sqlIDList = new ArrayList<String>();  
        
        ArrayList<Object[]> params = new ArrayList<Object[]>();
        
        if(isDelete)
        {
        	sqlIDList.add("CoreTransitLine.doDelete_Main_Mode_Line");
        	sqlIDList.add("CoreTransitLine.doDelete_Main_Mode");
        	sqlIDList.add("CoreTransitLine.doDelete_Main");
        	params.add(plineCodes.toArray());
        	params.add(plineCodes.toArray());
        	params.add(plineCodes.toArray());
        }
        else
        {
        	sqlIDList.add("CoreTransitLine.doResume_Main_Mode_Line");
        	sqlIDList.add("CoreTransitLine.doResume_Main_Mode");
        	sqlIDList.add("CoreTransitLine.doResume_Main");
        	params.add(plineCodes.toArray());
        	params.add(plineCodes.toArray());
        	params.add(plineCodes.toArray());
        }
        
        return this.setDataById(sqlIDList, params);
	}
    
    public CoreReturnObject deleteLineInfo(ArrayList<Object> plineCodes,
            String operator, Boolean isDelete) {  	
    	
        ArrayList<String> sqlIDList = new ArrayList<String>();  
        
        ArrayList<Object[]> params = new ArrayList<Object[]>();    
        
        for (int i = 0; i < plineCodes.size(); i++) {
            if (isDelete) {
                sqlIDList.add("CoreBuckleType.DELETE");
                params.add(new Object[] { operator,
                        plineCodes.get(i).toString() });
            }
            else {
                sqlIDList.add("CoreBuckleType.RESUME");
                params.add(new Object[] { plineCodes.get(i).toString() });
            }
        }
		return this.setDataById(sqlIDList, params);
	}
    
	
	
	/**
     * 新增
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
	public CoreReturnObject doAdd_Main(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doAdd_Main");
		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 doAdd_Mode(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doAdd_Mode");
		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 doAdd_ModeLine(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doAdd_ModeLine");
		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 doUpdate_Main(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doUpdate_Main");
		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 doUpdate_Mode(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doUpdate_Mode");
		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 doUpdate_ModeLine(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		String strSql = CoreXmlSqlParsersFactory.getSql("CoreTransitLine.doUpdate_ModeLine");
		try {
			cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
		} catch (SQLException e) {
			cro = cro.SetErrInfo(e.getMessage());
		}
		return cro;
	}
	
	
	
	
	
	
	
	/**
	 * 查询
	 * @return CoreReturnObject 必须返回CoreReturnObject
	 */
	public CoreReturnObject doQuery(String qsd,String mdd) {
		Object[] obj = new Object[] { qsd,mdd };
		return this.getDataBySqlID("CoreTransitLine.doQuery", obj);
	}
	
	
	
	/**
	 * 方案表查询
	 * @return CoreReturnObject 必须返回CoreReturnObject
	 */
	public CoreReturnObject doQuery_Mode(String transitNo) {
		Object[] obj = new Object[] { transitNo };
		return this.getDataBySqlID("CoreTransitLine.doQuery_Mode", obj);
	}
	
	/**
	 * 线路明细查询
	 * @return CoreReturnObject 必须返回CoreReturnObject
	 */
	public CoreReturnObject doQuery_ModeLine(String transitNo,String modeNo) {
		Object[] obj = new Object[] { transitNo,modeNo };
		return this.getDataBySqlID("CoreTransitLine.doQuery_ModeLine", obj);
	}
	
	
	
}

