package com.steering.pss.sale.order.qualityDesign.server.iserver;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.converter.CoreConverter;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.sale.order.model.ComBaseProcessCEntity;
import com.steering.pss.sale.order.model.CoreBaseProcessEntity;
import com.steering.pss.sale.order.model.DesignMscPlEntity;
import com.steering.pss.sale.order.model.DesignMscPlPcEntity;
import com.steering.pss.sale.order.model.DesignMscPlPcLstEntity;
import com.steering.pss.sale.order.model.DesignMscPlPrcEntity;
import com.steering.pss.sale.order.model.OrderLineDeliveryEntity;
import com.steering.pss.sale.order.qualityDesign.Dao.factory.FactoryDao;
import com.steering.pss.sale.order.qualityDesign.Dao.idao.IProCycleDao;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.ProCycleDaoImp;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.ReProEntity;
import com.steering.pss.sale.order.qualityDesign.server.imp.ProCycleImp;

/**
 * 生产周期业务类
 * @author Administrator
 */
public class IProCycle implements ProCycleImp {

    // 公式:IF(C3=0,E2/100*C2+D2,IF(C2<=C3,C2+D2,IF((C2-C3)*E2/100>=D2,(C2-C3)*E2/100,D2)+D2))
    // C2 生产时间，D2等待时间 E2是合同量 C3代表后一工序的生产时间
    /**
     * 牵扯到理化的 硫化氢实验的 需要增加试验时间和实验等待时间 新增 将每个工序下的工序点的时间 加入到最终的生产时间
     */
    public String generateProCycle(Connection con, String msc, String designKey,
            String ordLnPk, String form) throws SQLException {
        String errMsg = "";
        IProCycleDao iPcd = new IProCycleDao();
        ProCycleDaoImp proCycleDaoImp = FactoryDao.getProductCycleDaoImp();

        List<OrderLineDeliveryEntity> deliverys = new ArrayList<OrderLineDeliveryEntity>();
        deliverys = proCycleDaoImp.getLineDelivery(con, ordLnPk, form);

        if (deliverys == null || deliverys.size() == 0) {
            errMsg = "合同找不到交货行";
            return errMsg;
        }

        for (OrderLineDeliveryEntity delivery : deliverys) {
            // 查询有效制程
            List<DesignMscPlEntity> mscPls = proCycleDaoImp.getValidZC(con,
                    designKey);
            // 如果质量设计通过，肯定能得到有效制程
            if (mscPls == null || mscPls.size() == 0) {
                errMsg = "找不到有效的制程";
                return errMsg;
            }
            double delQty = Double.parseDouble(delivery.getWgtEstmt());
            double countN = delQty / 100; // 对于铸造必须向上取整，其他工序不用。

            HashMap<DesignMscPlEntity, Double> map = new HashMap<DesignMscPlEntity, Double>();
            HashMap<DesignMscPlEntity, Double> map1 = new HashMap<DesignMscPlEntity, Double>();

            for (DesignMscPlEntity mscPl : mscPls) {
                ReProEntity re = getTime(mscPl, con, msc, designKey, countN);
                if (re.getFlag()) {
                    map.put(mscPl, re.getMaxTime());
                    map1.put(mscPl, re.getMaxTimeBatch());
                }
                else {
                    errMsg = re.getErrMessage();
                    return errMsg;
                }
            }

            List<DesignMscPlPcLstEntity> plLst = new ArrayList<DesignMscPlPcLstEntity>();
            Collection<Double> c = map.values();
            Object[] obj = c.toArray();
            Arrays.sort(obj);
            double maxtime = Double.parseDouble(obj[obj.length - 1].toString());
            DesignMscPlEntity pl = keyString(map, maxtime); // 得到最大生产周期的制程
            plLst = getTimeByPl(pl, con, msc, designKey, countN,
                    delivery.getOrdLnDlyPk());
            if (plLst == null) {
                errMsg = "冶金规范码下制程与质量设计制程不对应，可能是MSC已被修改或者被作废！";
                return errMsg;
            }
            DesignMscPlPcEntity pLpc = new DesignMscPlPcEntity();

            pLpc.setDesginKey(designKey);
            pLpc.setOrdLnDlyPk(delivery.getOrdLnDlyPk());
            pLpc.setMscPline(pl.getMscPline());
            pLpc.setDelvryEdate(delivery.getDelvryEdate());
            pLpc.setDelvryQty(delivery.getDelvryQty());
            pLpc.setOrderUnit(delivery.getOrderUnit());
            pLpc.setReceivNo(delivery.getReceivNo());
            pLpc.setReceivNm(delivery.getReceivNm());
            pLpc.setPrdCyc(String.valueOf(Math.ceil(maxtime / 24)));
            pLpc.setPrdCycBtch(String.valueOf(Math.ceil(map1.get(pl) / 24)));

            // 先取出之前保存的周期修正。
            String sql = CoreXmlSqlParsersFactory
                    .getSql("IProCycleDao.getCycEdit");
            PreparedStatement ps = con.prepareStatement(sql);
            ps.setObject(1, delivery.getOrdLnDlyPk());
            ResultSet rs = ps.executeQuery();
            String cycEdit = "";
            if (rs.next()) {
                cycEdit = rs.getString(1);
            }
            rs.close();
            ps.close();
            pLpc.setCycEdit(cycEdit); // 之前的生产周期。

            if (plLst != null && plLst.size() > 0) {
                // 先删除上一次计算的时间
                iPcd.deleteMscPLPC(con, delivery.getOrdLnDlyPk());
                iPcd.deleteMscPLPCLST(con, delivery.getOrdLnDlyPk());

                for (int j = 0; j < plLst.size(); j++) {
                    iPcd.saveMSCPLPCLST(con, plLst.get(j));
                }
                iPcd.saveMSCPLPC(con, pLpc);
            }
        }
        return errMsg;
    }

    /**
     * 根据value得到key值
     * @param map hashmap
     * @param o 值
     * @return key值
     */
    public static DesignMscPlEntity keyString(
            HashMap<DesignMscPlEntity, Double> map, double o) {
        Iterator<Entry<DesignMscPlEntity, Double>> it = map.entrySet()
                .iterator();
        while (it.hasNext()) {
            Entry<DesignMscPlEntity, Double> entry = it.next();
            if (entry.getValue().equals(o)) {
                return entry.getKey();
            }
        }
        return null;
    }

    /**
     * 算制程的生产周期
     * @param mscPl
     * @param con
     * @param msc
     * @param designKey
     * @param countN
     * @return
     * @throws SQLException
     */
    public ReProEntity getTime(DesignMscPlEntity mscPl, Connection con,
            String msc, String designKey, double countN) throws SQLException {
        double proTime = 0;
        double plTime = 0; // 一个制程的总时间

        double proTimeBatch = 0;
        double plTimeBatch = 0;
        ReProEntity rePro = new ReProEntity();
        String[] processCodes = mscPl.getWholeBacklog().split("-");
        // 查询当前制程的所有二级工序信息
        Map<String, DesignMscPlPrcEntity> map = getProcessCodeCEntity(con,
                designKey, mscPl.getMscPline());

        for (int i = 0; i < processCodes.length; i++) {
            if (i <= processCodes.length - 2) {

                ComBaseProcessCEntity process = getComBaseProcessC(con,
                        processCodes[i],
                        map.get(processCodes[i]).getProcessCodeC());
                ComBaseProcessCEntity process1 = getComBaseProcessC(con,
                        processCodes[i + 1],
                        map.get(processCodes[i + 1]).getProcessCodeC());

                if (process.getMinuteProduct().equals("")) {
                    process.setMinuteProduct("0");
                }

                if (process.getBatchWaite().equals("")) {
                    process.setBatchWaite("0");
                }

                if (process1.getMinuteProduct().equals("")) {
                    process1.setMinuteProduct("0");
                }

                if (process1.getBatchWaite().equals("")) {
                    process1.setBatchWaite("0");
                }
                if (Double.parseDouble(process1.getMinuteProduct()) == 0) {
                    double newCount = 0;
                    if (process.getProcessCdoe().equals("B"))
                        newCount = Math.ceil(countN);
                    else
                        newCount = countN;

                    proTime = newCount
                            * Double.parseDouble(process.getMinuteProduct())
                            + Double.parseDouble(process.getMinuteWaite());
                    plTime += proTime;

                    proTimeBatch = newCount
                            * Double.parseDouble(process.getMinuteProduct())
                            + Double.parseDouble(process.getBatchWaite());
                    plTimeBatch += proTimeBatch;

                }
                else {
                    if (Double.parseDouble(process.getMinuteProduct()) < Double
                            .parseDouble(process1.getMinuteProduct())) {

                        proTime = Double.parseDouble(process.getMinuteProduct())
                                + Double.parseDouble(process.getMinuteWaite());
                        plTime += proTime;

                        proTimeBatch = Double
                                .parseDouble(process.getMinuteProduct())
                                + Double.parseDouble(process.getBatchWaite());
                        plTimeBatch += proTimeBatch;
                    }
                    else {
                        double newCount = 0;
                        if (process1.getProcessCdoe().equals("B"))
                            newCount = Math.ceil(countN);
                        else
                            newCount = countN;

                        if ((Double.parseDouble(process.getMinuteProduct())
                                - Double.parseDouble(
                                        process1.getMinuteProduct()))
                                * newCount >= Double
                                        .parseDouble(process.getBatchWaite())) {

                            proTimeBatch = (Double
                                    .parseDouble(process.getMinuteProduct())
                                    - Double.parseDouble(
                                            process1.getMinuteProduct()))
                                    * newCount
                                    + Double.parseDouble(
                                            process.getBatchWaite());
                            plTimeBatch += proTimeBatch;
                        }

                        if ((Double.parseDouble(process.getMinuteProduct())
                                - Double.parseDouble(
                                        process1.getMinuteProduct()))
                                * newCount >= Double.parseDouble(
                                        process.getMinuteWaite())) {

                            proTime = (Double
                                    .parseDouble(process.getMinuteProduct())
                                    - Double.parseDouble(
                                            process1.getMinuteProduct()))
                                    * newCount
                                    + Double.parseDouble(
                                            process.getMinuteWaite());
                            plTime += proTime;
                        }
                        else {
                            proTime = Double
                                    .parseDouble(process.getMinuteWaite())
                                    + Double.parseDouble(
                                            process.getMinuteWaite());
                            plTime += proTime;

                            proTimeBatch = Double
                                    .parseDouble(process.getBatchWaite())
                                    + Double.parseDouble(
                                            process.getBatchWaite());
                            plTimeBatch += proTimeBatch;

                        }
                    }
                }
            }
            if (i == processCodes.length - 1) {
                ComBaseProcessCEntity process = getComBaseProcessC(con,
                        processCodes[i],
                        map.get(processCodes[i]).getProcessCodeC());

                if (process.getMinuteProduct().equals("")) {
                    process.setMinuteProduct("0");
                }

                if (process.getBatchWaite().equals("")) {
                    process.setBatchWaite("0");
                }
                double newCount = 0;
                if (process.getProcessCdoe().equals("B"))
                    newCount = Math.ceil(countN);
                else
                    newCount = countN;
                proTime = newCount
                        * Double.parseDouble(process.getMinuteProduct())
                        + Double.parseDouble(process.getMinuteWaite());
                plTime += proTime;

                proTimeBatch = newCount
                        * Double.parseDouble(process.getMinuteProduct())
                        + Double.parseDouble(process.getBatchWaite());
                plTimeBatch += proTimeBatch;
            }
        }

        List<String> list = getPhyCode(con, designKey);
        if (list != null && list.size() > 0) {
            String[] arr = new String[list.size()];
            list.toArray(arr);
            String condition = CoreConverter.toSqlConditionString("PHY_CODE",
                    arr);
            ResultSet rs = getTestTime(con, condition);
            if (rs.next()) {
                plTime += rs.getDouble(1);
                plTimeBatch += rs.getDouble(1);
            }
            rs.close();
        }
        double d = getPlStationHour(con, msc, mscPl.getMscPline());
        plTime += d;
        plTimeBatch += d;
        rePro.setFlag(true);
        rePro.setMaxTime(plTime);
        rePro.setMaxTimeBatch(plTimeBatch);
        return rePro;
    }

    /**
     * 得到最大制程的每个工序的生产周期
     * @param mscPl
     * @param con
     * @param msc
     * @param designKey
     * @param countN
     * @param ordLnDlyPk
     * @return
     * @throws SQLException
     */
    public List<DesignMscPlPcLstEntity> getTimeByPl(DesignMscPlEntity mscPl,
            Connection con, String msc, String designKey, double countN,
            String ordLnDlyPk) throws SQLException {
        double proTime = 0;
        double proTimeBatch = 0;

        List<DesignMscPlPcLstEntity> list = new ArrayList<DesignMscPlPcLstEntity>();
        String[] processCodes = mscPl.getWholeBacklog().split("-");
        Map<String, DesignMscPlPrcEntity> map = getProcessCodeCEntity(con,
                designKey, mscPl.getMscPline());
        for (int i = 0; i < processCodes.length; i++) {
            DesignMscPlPcLstEntity plLst = new DesignMscPlPcLstEntity();
            // 查询工序
            if (i <= processCodes.length - 2) {
                ComBaseProcessCEntity process = getComBaseProcessC(con,
                        processCodes[i],
                        map.get(processCodes[i]).getProcessCodeC());
                ComBaseProcessCEntity process1 = getComBaseProcessC(con,
                        processCodes[i+1],
                        map.get(processCodes[i + 1]).getProcessCodeC());

                if (process.getMinuteProduct().equals("")) {
                    process.setMinuteProduct("0");
                }

                if (process1.getMinuteProduct().equals("")) {
                    process1.setMinuteProduct("0");
                }
                if (process.getBatchWaite().equals("")) {
                    process.setBatchWaite("0");
                }
                if (process1.getBatchWaite().equals("")) {
                    process1.setBatchWaite("0");
                }
                if (Double.parseDouble(process1.getMinuteProduct()) == 0) {
                    double newCount = 0;
                    if (process.getProcessCdoe().equals("B"))
                        newCount = Math.ceil(countN);
                    else
                        newCount = countN;
                    proTime = newCount
                            * Double.parseDouble(process.getMinuteProduct())
                            + Double.parseDouble(process.getMinuteWaite());

                    proTimeBatch = newCount
                            * Double.parseDouble(process.getMinuteProduct())
                            + Double.parseDouble(process.getBatchWaite());

                }
                else {
                    if (Double.parseDouble(process.getMinuteProduct()) < Double
                            .parseDouble(process1.getMinuteProduct())) {
                        proTime = Double.parseDouble(process.getMinuteProduct())
                                + Double.parseDouble(process.getMinuteWaite());

                        proTimeBatch = Double
                                .parseDouble(process.getMinuteProduct())
                                + Double.parseDouble(process.getBatchWaite());

                    }
                    else {
                        double newCount = 0;
                        if (process1.getProcessCdoe().equals("B"))
                            newCount = Math.ceil(countN);
                        else
                            newCount = countN;
                        if ((Double.parseDouble(process.getMinuteProduct())
                                - Double.parseDouble(
                                        process1.getMinuteProduct()))
                                * newCount >= Double
                                        .parseDouble(process.getBatchWaite())) {

                            proTimeBatch = (Double
                                    .parseDouble(process.getMinuteProduct())
                                    - Double.parseDouble(
                                            process1.getMinuteProduct()))
                                    * newCount
                                    + Double.parseDouble(
                                            process.getBatchWaite());

                        }

                        if ((Double.parseDouble(process.getMinuteProduct())
                                - Double.parseDouble(
                                        process1.getMinuteProduct()))
                                * newCount >= Double.parseDouble(
                                        process.getMinuteWaite())) {
                            proTime = (Double
                                    .parseDouble(process.getMinuteProduct())
                                    - Double.parseDouble(
                                            process1.getMinuteProduct()))
                                    * newCount
                                    + Double.parseDouble(
                                            process.getMinuteWaite());

                        }
                        else {
                            proTime = Double
                                    .parseDouble(process.getMinuteWaite())
                                    + Double.parseDouble(
                                            process.getMinuteWaite());

                            proTimeBatch = Double
                                    .parseDouble(process.getBatchWaite())
                                    + Double.parseDouble(
                                            process.getBatchWaite());

                        }
                    }
                }
                if (process.getProcessCdoe().equals("F")) {
                    List<String> list1 = getPhyCode(con, designKey);
                    if (list1 != null && list1.size() > 0) {
                        String[] arr = new String[list1.size()];
                        list1.toArray(arr);
                        String condition = CoreConverter
                                .toSqlConditionString("PHY_CODE", arr);

                        ResultSet rs = getTestTime(con, condition);
                        if (rs.next()) {
                            proTime += rs.getDouble(1);
                            proTimeBatch += rs.getDouble(1);
                        }
                    }
                }

                double d = getPlStationHour(con, msc, mscPl.getMscPline(),
                        process.getProcessCdoe());
                proTime += d;
                proTimeBatch += d;

                plLst.setDesginKey(designKey);
                plLst.setOrdLnDlyPk(ordLnDlyPk);
                plLst.setProcessCode(process.getProcessCdoe());
                plLst.setProcessDesc(process.getProcessDesc());
                plLst.setPrdCyc(String.valueOf(proTime / 24));
                plLst.setPrdCycBtch(String.valueOf(proTimeBatch / 24));
                plLst.setMscPline(mscPl.getMscPline());
                plLst.setBacklogSeq(map.get(processCodes[i]).getBacklogSeq());
                list.add(plLst);
            }
            if (i == processCodes.length - 1) {
                ComBaseProcessCEntity process = getComBaseProcessC(con,
                        processCodes[i],
                        map.get(processCodes[i]).getProcessCodeC());

                if (process.getMinuteProduct().equals("")) {
                    process.setMinuteProduct("0");
                }
                if (process.getMinuteWaite().equals("")) {
                    process.setMinuteWaite("0");
                }
                if (process.getBatchWaite().equals("")) {
                    process.setBatchWaite("0");
                }

                double newCount = 0;
                if (process.getProcessCdoe().equals("B"))
                    newCount = Math.ceil(countN);
                else
                    newCount = countN;
                proTime = newCount
                        * Double.parseDouble(process.getMinuteProduct())
                        + Double.parseDouble(process.getMinuteWaite());

                proTimeBatch = newCount
                        * Double.parseDouble(process.getMinuteProduct())
                        + Double.parseDouble(process.getBatchWaite());

                if (process.getProcessCdoe().equals("F")) {
                    List<String> list1 = getPhyCode(con, designKey);
                    if (list1 != null && list1.size() > 0) {
                        String[] arr = new String[list1.size()];
                        list1.toArray(arr);
                        String condition = CoreConverter
                                .toSqlConditionString("PHY_CODE", arr);
                        ResultSet rs = getTestTime(con, condition);
                        if (rs.next()) {
                            proTime += rs.getDouble(1);
                            proTimeBatch += rs.getDouble(1);
                        }
                    }
                }

                double d = getPlStationHour(con, msc, mscPl.getMscPline(),
                        process.getProcessCdoe());
                proTime += d;
                proTimeBatch += d;

                plLst.setDesginKey(designKey);
                plLst.setOrdLnDlyPk(ordLnDlyPk);
                plLst.setProcessCode(process.getProcessCdoe());
                plLst.setProcessDesc(process.getProcessDesc());
                plLst.setPrdCyc(String.valueOf(proTime / 24));
                plLst.setPrdCycBtch(String.valueOf(proTimeBatch / 24));
                plLst.setMscPline(mscPl.getMscPline());
                plLst.setBacklogSeq(map.get(processCodes[i]).getBacklogSeq());
                list.add(plLst);
            }
        }
        return list;
    }

    /**
     * 获取理化标准的检验项目
     * @param con
     * @param designKey
     * @return
     * @throws SQLException
     */
    public List<String> getPhyCode(Connection con, String designKey)
            throws SQLException {
        List<String> list = new ArrayList<String>();
        String sql = CoreXmlSqlParsersFactory.getSql("IProCycleDao.getPhyCode");

        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, designKey);
        ResultSet rs = ps.executeQuery();

        while (rs.next()) {
            list.add(rs.getString(1));
        }
        rs.close();
        ps.close();
        return list;
    }

    /**
     * 获取检验项目准备、试验时间
     * @param con
     * @param phyCode
     * @return
     * @throws SQLException
     */
    public ResultSet getTestTime(Connection con, String phyCode)
            throws SQLException {
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getPhyItemTime");
        sql += phyCode;
        PreparedStatement ps = con.prepareStatement(sql);

        ResultSet rs = ps.executeQuery();
        return rs;
    }

    /**
     * 获取基础工序的生产时间。
     * @param con
     * @param processCode
     * @return
     * @throws SQLException
     */
    public List<CoreBaseProcessEntity> getComBaseProcess(Connection con,
            String processCode) throws SQLException {
        List<CoreBaseProcessEntity> list = new ArrayList<CoreBaseProcessEntity>();
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getComBaseProcess");
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, processCode);
        ResultSet rs = ps.executeQuery();

        list = EntityTool.getEntitysByRs(rs, CoreBaseProcessEntity.class);
        rs.close();
        ps.close();
        return list;
    }

    /**
     * 获取制程所有工序的生产时间
     * @param con
     * @param msc
     * @param mscPline
     * @return
     * @throws SQLException
     */
    public double getPlStationHour(Connection con, String msc, String mscPline)
            throws SQLException {
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getPlStationHourAllProcess");
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, msc);
        ps.setObject(2, mscPline);
        ResultSet rs = ps.executeQuery();
        double d = 0;
        if (rs.next()) {
            d = rs.getDouble(1);
        }

        rs.close();
        ps.close();
        return d;
    }

    /**
     * 获取制程指定工序的生产时间
     * @param con
     * @param msc
     * @param mscPline
     * @param processCode 工序代码
     * @return
     * @throws SQLException
     */
    public double getPlStationHour(Connection con, String msc, String mscPline,
            String processCode) throws SQLException {
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getPlStationHourOnlyProcess");
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, msc);
        ps.setObject(2, mscPline);
        ps.setObject(3, processCode);
        ResultSet rs = ps.executeQuery();
        double d = 0;
        if (rs.next()) {
            d = rs.getDouble(1);
        }
        rs.close();
        ps.close();
        return d;
    }

    /**
     * 获取制程的所有二级工序信息
     * @param con
     * @param mscPl 制程
     * @param designKey 质量设计主键
     * @return
     * @throws SQLException
     */
    public Map<String, DesignMscPlPrcEntity> getProcessCodeCEntity(
            Connection con, String designKey, String mscPline)
                    throws SQLException {
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getProcessCodeCEntity");
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, designKey);
        ps.setObject(2, mscPline);
        ResultSet rs = ps.executeQuery();
        List<DesignMscPlPrcEntity> list = EntityTool.getEntitysByRs(rs,
                DesignMscPlPrcEntity.class);
        rs.close();
        ps.close();
        Map<String, DesignMscPlPrcEntity> map = new HashMap<String, DesignMscPlPrcEntity>();
        for (int i = 0; i < list.size(); i++) {
            DesignMscPlPrcEntity mscPlPrc = list.get(i);
            map.put(mscPlPrc.getProcessCode(), mscPlPrc);
        }
        return map;
    }

    /**
     * 获取二级工序的基础信息
     * @param con
     * @param processCode
     * @param processCodec
     * @return
     * @throws SQLException
     */
    public ComBaseProcessCEntity getComBaseProcessC(Connection con,
            String processCode, String processCodec) throws SQLException {
        String sql = CoreXmlSqlParsersFactory
                .getSql("IProCycleDao.getComProcessCodeCEntity");
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setObject(1, processCode);
        ps.setObject(2, processCodec);
        ResultSet rs = ps.executeQuery();
        ComBaseProcessCEntity list = EntityTool.getEntityByRs(rs,
                ComBaseProcessCEntity.class);
        rs.close();
        ps.close();
        return list;
    }

}
