package com.steering.pss.plnsaleord.steelMarkingPlan;

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

import java.text.MessageFormat;
import java.util.ArrayList;

/**
 * Created by 朱少波 on 2017/10/23.
 */
public class StlChemical extends DBCommon {

    public CoreReturnObject GetStlChemicalStd(String CraftNo) {
        CoreReturnObject cro = new CoreReturnObject();
        try {

            cro = getDataBySqlID("StlChemicalStd.Select", new Object[]{CraftNo,CraftNo});
        } catch (Exception e) {
            logger.error(e);
            cro.setV_errCode(-1);
            cro.setV_errMsg(e.getMessage());
        }
        return cro;
    }

    public CoreReturnObject GetStlChemicalStd(String[] CIC_GIDS) {
        CoreReturnObject cro = new CoreReturnObject();
        try {

            String Where = CoreConverter.toSqlConditionString("CIC_GID",
                    CIC_GIDS);


            String sql = MessageFormat.format(CoreXmlSqlParsersFactory.getSql("StlChemicalStd.Select1").replace("'","''")
                    , Where);



            cro = getData(sql);
        } catch (Exception e) {
            logger.error(e);
            cro.setV_errCode(-1);
            cro.setV_errMsg(e.getMessage());
        }
        return cro;
    }


    public CoreReturnObject GetStlChemicalData(String Stove) {
        CoreReturnObject cro = new CoreReturnObject();
        try {


            cro = getDataBySqlID("StlChemica.Select", new Object[]{Stove});
        } catch (Exception e) {
            logger.error(e);
            cro.setV_errCode(-1);
            cro.setV_errMsg(e.getMessage());
        }
        return cro;
    }


    public CoreReturnObject GetChemicalStd(String[] DesignKey) {
        CoreReturnObject cro = new CoreReturnObject();
        try {

            String Where = CoreConverter.toSqlConditionString("GPREQ_ID",
                    DesignKey);

            String sql = MessageFormat.format(CoreXmlSqlParsersFactory.getSql("StlChemica.Std1").replace("'","''")
                    , Where);



            cro = getData(sql);
        } catch (Exception e) {
            logger.error(e);
            cro.setV_errCode(-1);
            cro.setV_errMsg(e.getMessage());
        }
        return cro;
    }


    public CoreReturnObject GetChemicalStd(String[] DesignKey,String[] SPECL_FLs) {
        CoreReturnObject cro = new CoreReturnObject();
        try {

            String Where = CoreConverter.toSqlConditionString("GPREQ_ID",
                    DesignKey);

            String Where2 = CoreConverter.toSqlConditionString("SPECL_FL",
                    SPECL_FLs);

            String sql = MessageFormat.format(CoreXmlSqlParsersFactory.getSql("StlChemica.Std").replace("'","''")
                    , Where,Where2);



            cro = getData(sql);
        } catch (Exception e) {
            logger.error(e);
            cro.setV_errCode(-1);
            cro.setV_errMsg(e.getMessage());
        }
        return cro;
    }
}