package com.steering.pss.qcm;

import java.util.ArrayList;

import CoreFS.SA06.CoreReturnObject;

import com.steering.comm.db.DBCommon;

/**
 * 取样要求管理类
 * @author Administrator pdy 2014/11/21
 * @version v1.0
 */
public class CoreComMSCSample extends DBCommon {
    /**
     * 取样要求 查询
     * @return 返回CoreReturnObject
     */
    public CoreReturnObject getComMSCSample(ArrayList<Object> params) {
        return this.getDataBySqlID("CoreComMSCSample.QUERY", params.toArray());
    }

    /**
     * 取样要求 取最大序号
     * @return 返回CoreReturnObject
     */
    public CoreReturnObject getMaxXH(String msc) {
        Object[] params = new Object[] { msc };
        return this.getDataBySqlID("CoreComMSCSample.GETMAXXH", params);
    }

    /**
     * 取样要求 保存
     * @param addList 增加项
     * @param updateList 修改项
     * @return 返回CoreReturnObject
     */
    public CoreReturnObject saveComMSCSample(ArrayList<ArrayList> addList,
            ArrayList<ArrayList> updateList) {
        ArrayList<String> sqlIDlist = new ArrayList<String>();
        ArrayList<Object[]> params = new ArrayList<Object[]>();
        for (int i = 0; i < addList.size(); i++) {
            sqlIDlist.add("CoreComMSCSample.ADD");
            params.add(addList.get(i).toArray());

        }
        for (int i = 0; i < updateList.size(); i++) {
            sqlIDlist.add("CoreComMSCSample.UPDATE");
            params.add(updateList.get(i).toArray());

        }
        return this.setDataById(sqlIDlist, params);
    }

    /**
     * 取样要求 删除或者恢复
     * @return 返回CoreReturnObject
     */
    public CoreReturnObject deleteComMSCSample(ArrayList<ArrayList> list,
            Boolean flag) {
        ArrayList<String> sqlIDlist = new ArrayList<String>();
        ArrayList<Object[]> params = new ArrayList<Object[]>();
        for (int i = 0; i < list.size(); i++) {
            if (flag) {
                sqlIDlist.add("CoreComMSCSample.DELETE");
                params.add(list.get(i).toArray());
            }
            else {
                sqlIDlist.add("CoreComMSCSample.RESUME");
                params.add(list.get(i).toArray());
            }
        }
        return this.setDataById(sqlIDlist, params);
    }
}
