package com.steering.pss.ydm.base;

import java.sql.SQLException;
import java.util.ArrayList;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.StringTool;

/**
 * 产线与仓库管理分组关联.
 * @author WQ 2014/1/23
 * @version v1.0
 * @modify
 */
public class FrmBasePlineGroup extends DBCommon {
    /**
     *产线与仓库管理分组关联查询.
     *@param doQuery
     * @param storage 库存编码
     * @param unit gdf
     * @return CoreReturnObject
     */
    public CoreReturnObject doQuery(String plineCode, String groupNo) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("FrmBasePlineGroup.doQuery");
        if (!StringTool.isNullOrEmpty(plineCode)) {
            sql += " and PLINE_CODE_M = '" + plineCode + "'";
        }
        if (!StringTool.isNullOrEmpty(groupNo)) {
            sql += " and STOCK_GROUP_CODE = '" + groupNo + "'";
        }
        sql += " order by CREATE_TIME desc";
        return this.getData(sql);
    }
    /**
     * 查询产线
     * @param storageCode 库号编码
     * @return CoreReturnObject
     */
    public CoreReturnObject doPlineCodeQuery(){
        return this.getDataBySqlID("FrmBasePlineGroup.doPlineCodeQuery");
    }
    /**
     * 查询到站
     * @return CoreReturnObject
     */
    public CoreReturnObject getStationQuery(){
        return this.getDataBySqlID("FrmBasePlineGroup.getStationQuery");
    }
 
   /**
    * 管理分组
    * @param value
    * @return
    */
  public CoreReturnObject getGroupStoage(String sortCode)
  {
      return this.getDataBySqlID("FrmBasePlineGroup.getGroupStoage",new Object[]{sortCode});
  }
  /**
   * 查询仓库
   * @return CoreReturnObject
   */
  public CoreReturnObject getBsStorage(){
      return this.getDataBySqlID("FrmBasePlineGroup.getBsStorage");
  }
  /**
   * 判断是否唯一.
   * @return CoreReturnObject
   */
  public CoreReturnObject storageRepeatCode(String plineCode,String storageCode){
      Object[] obj = new Object[] { plineCode,storageCode };
      return this.getDataBySqlID("FrmBasePlineGroup.storageRepeatCode",
              obj);
  }
    /**
     *新增.
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doAdd(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBasePlineGroup.doAdd");
        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(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBasePlineGroup.doUpdate");
        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 doDelete(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBasePlineGroup.doDelete");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }
}
