package com.steering.pss.plnsaleord.processOrder;

import java.util.ArrayList;

import net.sf.json.JSONObject;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.plnsaleord.processOrder.entity.SlmBaseMaterialCPlEntity;

public class FrmBasematerialCPl extends DBCommon {
	public CoreReturnObject getBaseMaterialC(String inMaterialNo,
			String outMaterialNo) {
		Object[] params = new Object[] { inMaterialNo, outMaterialNo };
		return this.getDataBySqlID("FrmBaseMaterialCPl.getBaseMaterialC",
				params);
	}

	public CoreReturnObject getBaseMaterialCPl(String inMaterialNo,
			String outMaterialNo) {
		Object[] params = new Object[] { inMaterialNo, outMaterialNo };
		return this.getDataBySqlID("FrmBaseMaterialCPl.getBaseMaterialCPl",
				params);
	}

	/**
	 * 修改
	 * 
	 * @param jsonStrList
	 * @return
	 */
	public CoreReturnObject updateBaseMaterialCPl(ArrayList<String> jsonStrList) {
		ArrayList<String> sqlList = new ArrayList<String>();
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmBaseMaterialCPl.updateBaseMaterialCPl");
		for (String jsonStr : jsonStrList) {
			JSONObject obj = JSONObject.fromObject(jsonStr);
			SlmBaseMaterialCPlEntity entity = (SlmBaseMaterialCPlEntity) JSONObject
					.toBean(obj, SlmBaseMaterialCPlEntity.class);
			if (entity.getDisableFl().equals("True")) {
				entity.setDisableFl("1");
			} else {
				entity.setDisableFl("0");
			}
			sql = EntityTool.fillSqlByEntity(sql, entity);
			sqlList.add(sql);
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqlList);
	}
}
