package com.steering.pss.qcm.DAL;

import java.util.ArrayList;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.comm.tools.StringTool;
import com.steering.pss.qcm.model.ComBasePhyRSizeEntity;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;

public class ComBasePhyRSizeDAL extends DBCommon{
	
	public CoreReturnObject queryPhy(){
		String sql = CoreXmlSqlParsersFactory.getSql("ComBasePhyRSizeDAL.queryPhy");
		return this.getData(sql);
	}
	
	public CoreReturnObject queryPhySize(String phyCode){
		String sql = CoreXmlSqlParsersFactory.getSql("ComBasePhyRSizeDAL.queryPhySize");
		sql = StringTool.ReplaceAll(sql, "#PHY_CODE#", phyCode);
		return this.getData(sql);
	}
	
	public CoreReturnObject save(ArrayList<String> listJSON){
		ArrayList<String> sqllist = new ArrayList<String>();
		String sqlDel = CoreXmlSqlParsersFactory.getSql("ComBasePhyRSizeDAL.delete");
		if(listJSON.size() > 0){
			ComBasePhyRSizeEntity phyRSizeEntity = EntityTool.getEntityByJSONStr(listJSON.get(0), ComBasePhyRSizeEntity.class);
			sqlDel = EntityTool.fillSqlByEntity(sqlDel, phyRSizeEntity);
			sqllist.add(sqlDel);
		}
		for(String strJSON : listJSON){
			ComBasePhyRSizeEntity phyRSizeEntity = EntityTool.getEntityByJSONStr(strJSON, ComBasePhyRSizeEntity.class);
			String sql = CoreXmlSqlParsersFactory.getSql("ComBasePhyRSizeDAL.save");
			sql = EntityTool.fillSqlByEntity(sql, phyRSizeEntity);
			sqllist.add(sql);
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
	}
}
