package com.steering.pss.ydm.pipemanage;

import java.sql.Connection;
import java.util.ArrayList;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.ydm.entity.ComBaseInfoEntity;

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

public class FrmBaseCarryOver extends DBCommon{

	/***
	 * 查询结转控制数据
	 * @param arr
	 * @return
	 */
	public CoreReturnObject doQuery(String[] arr,String custom)
	{
		String sql = CoreXmlSqlParsersFactory.getSql("FrmBaseCarryOver.doQuery");
//		if(arr.length == 3)
//		{
//			sql += " AND BASECODE IN('800101','800102')";
//		}else
		if(custom.equals("120501"))
		{
			if(arr.length == 2 )
			{
				sql += " AND BASECODE IN('800101','800102')";
			}else if(arr.length == 1)
			{
				if(arr[0].toString().equals("100102")){
					sql += " AND BASECODE = '800102'";
				}else
				{
					sql += " AND BASECODE = '800101'";
				}
			}
		}else if(custom.equals("120504"))
		{
			sql += " AND BASECODE = '800103' ";
		}

		return this.getData(sql);
	}
	/***
	 * 修改结转标识
	 * @param
	 * @return
	 */
	public CoreReturnObject updateCarryOver(String comBaseEntity)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		ArrayList<String> sqllist = new ArrayList<String>();
		ComBaseInfoEntity comBase = EntityTool.getEntityByJSONStr(comBaseEntity, ComBaseInfoEntity.class);
		if(comBase.getMemo().equals("0"))
		{
			comBase.setMemo("1");
		}else
		{
			comBase.setMemo("0");
		}
		String updateSql = CoreXmlSqlParsersFactory.getSql("FrmBaseCarryOver.updateCarryOver");
		updateSql = EntityTool.fillSqlByEntity(updateSql, comBase);
		sqllist.add(updateSql);
		this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
		cro.setV_errMsg("修改成功!");
		return cro;
	}
}
