package nc.bs.tbb.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.codehaus.jettison.json.JSONException;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.adaptor.IHttpServletAdaptor;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.server.ISecurityTokenCallback;
import nc.bs.servlet.service.BaseServlet;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pub.util.DataSourceUtil;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.lang.UFDateTime;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class InitBudgetServlet extends BaseServlet implements IHttpServletAdaptor{

	BaseDAO basedao = new BaseDAO();
	IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
	String kyye = "CORPYS0000";//可用余额编码
	String ysze = "CORPYS0003";//预算总额编码
	String sjsy = "Actual";//实际使用数编码
	String yzs = "PreActual";//预占数编码
	String yss = "Budget";//预算数编码
	String pk_yss = "TBPTZ410000000001CME";//预算数pk
	String pk_ysze = "1001A81000000001EVAZ";//预算总额pk
	String pk_kyye = "1001A8100000000FT9DY";//可用余额pk
	
	@Override
	public void doAction(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO 自动生成的方法存根
		try {
//			DataSourceUtil.setDataSource();
//			InvocationInfoProxy.getInstance().setUserDataSource("NC20230608");
			InvocationInfoProxy.getInstance().setUserDataSource("NC6337");
			NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
			String createStr = buildJson(req, resp, this.getClass().getName());
			JSONObject json = JSONObject.fromObject(createStr);
			JSONObject returnobj = new JSONObject();
			JSONArray result = new JSONArray();
			JSONArray errMessage = new JSONArray();
			String checkresult = checkJson(json);
			if(checkresult != null){
				errMessage.add(formatRSJsonData("失败",
						checkresult,""));
				returnobj.put("info", "失败");
				returnobj.put("errMessage", checkresult);
				returnobj.put("result", errMessage);
				resp.getWriter().write(returnobj.toString());
				return;
			}
			JSONArray bodyArray = json.getJSONArray("result");
			
			for (Object Object : bodyArray) {
				JSONObject bodyObject = JSONObject.fromObject(Object);
				String objcode = QueryModelCode(bodyObject.getString("objname"));//应用模型编码
				String code_entity = bodyObject.getString("code_entity");//责任主体
				String entityPk = QueryOrgPk(code_entity);//责任主体pk
				if(entityPk==null){
					errMessage.add(formatRSJsonData("失败",
							"责任主体"+bodyObject.getString("code_entity")+"未查到，请检查","").toString());
					returnobj.put("info", "失败");
					returnobj.put("errMessage", "责任主体"+bodyObject.getString("code_entity")+"未查到，请检查");
					returnobj.put("result", errMessage);
					resp.getWriter().write(returnobj.toString());
					return;
				}
				String pk_year = bodyObject.getString("pk_year");//会计年度
				List<String> ListMeasure = QueryMeasureCode(bodyObject.getString("code_measure"));//预算编码
				if(ListMeasure.get(0)==null){
					errMessage.add(formatRSJsonData("失败",
							"预算编码"+bodyObject.getString("code_measure")+"未查到，请检查","").toString());
					returnobj.put("info", "失败");
					returnobj.put("errMessage", "预算编码"+bodyObject.getString("code_measure")+"未查到，请检查");
					returnobj.put("result", errMessage);
					resp.getWriter().write(returnobj.toString());
					return;
				}
				String code_measure = ListMeasure.get(0);//预算编码
				String measurePk = ListMeasure.get(1);//预算编码pk
				List<String> ListVersion = QueryVersionCode(bodyObject.getString("code_version"));
				if(ListVersion.get(0)==null){
					errMessage.add(formatRSJsonData("失败",
							"预算版本"+bodyObject.getString("code_version")+"未查到，请检查","").toString());
					returnobj.put("info", "失败");
					returnobj.put("errMessage", "预算版本"+bodyObject.getString("code_version")+"未查到，请检查");
					returnobj.put("result", errMessage);
					resp.getWriter().write(returnobj.toString());
					return;
				}
				String code_version = ListVersion.get(0);//预算版本编码
				String versionPk = ListVersion.get(1);//预算版本pk
				UFDouble value = new UFDouble(bodyObject.getString("value"));//预算总额
				UFDouble actualUse = new UFDouble(QueryNmny(objcode,code_entity,pk_year,code_measure,code_version,sjsy));//本年度实际使用数
				UFDouble pupremny = new UFDouble(QueryNmny(objcode,code_entity,pk_year,code_measure,code_version,yzs));//预占数
				UFDouble Frozen = new UFDouble(QueryFrozen(code_entity,pk_year,code_measure));//冻结金额
				//预算总额-本年度实际使用数-预占数-冻结金额<0抛异常
				if(value.sub(actualUse).sub(pupremny).sub(Frozen).compareTo(UFDouble.ZERO_DBL)<0){
					errMessage.add(formatRSJsonData("失败",
							bodyObject.getString("objname")+pk_year+"年"+bodyObject.getString("code_measure")+"可用额度不足，请检查","").toString());
					returnobj.put("info", "失败");
					returnobj.put("errMessage", bodyObject.getString("objname")+pk_year+"年"+bodyObject.getString("code_measure")+"可用额度不足，请检查");
					returnobj.put("result", errMessage);
					resp.getWriter().write(returnobj.toString());
					return;
				}
				else{
					//查询一些不知道什么东西的数据
//					List<String> ListCorp = QueryCorpYS(objcode,code_measure);
					String pk_corpYS001 = bodyObject.getString("pk_corpYS001");
					String code_corpYS001 = bodyObject.getString("code_corpYS001");
					String pk_corpYS002 = bodyObject.getString("pk_corpYS002");
					String code_corpYS002 = bodyObject.getString("code_corpYS002");
					String pk_corpYS003 = bodyObject.getString("pk_corpYS003");
					String code_corpYS003 = bodyObject.getString("code_corpYS003");
					String pk_corpYS0004 = bodyObject.getString("pk_corpYS0004");
					String code_corpYS0004 = bodyObject.getString("code_corpYS0004");
//					if(ListCorp.get(0)!=null&&ListCorp.get(1)!=null&&ListCorp.get(2)!=null&&ListCorp.get(3)!=null&&ListCorp.get(4)!=null&&ListCorp.get(5)!=null&&ListCorp.get(6)!=null&&ListCorp.get(7)!=null){
//						pk_corpYS001 = ListCorp.get(0);
//						code_corpYS001 = ListCorp.get(1);
//						pk_corpYS002 = ListCorp.get(2);
//						code_corpYS002 = ListCorp.get(3);
//						pk_corpYS003 = ListCorp.get(4);
//						code_corpYS003 = ListCorp.get(5);
//						pk_corpYS0004 = ListCorp.get(6);
//						code_corpYS0004 = ListCorp.get(7);
//					}
					Object ndyspk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,yss);//预算数pk
					if(ndyspk!=null){
						//修改本年度预算数
						UpdateSql(objcode,value.toString(),ndyspk.toString());
					}
					else{
						//新增一条预算的记录
						String ts = new UFDateTime().toString();
						nc.jdbc.framework.generator.IdGenerator idGenerator = new nc.jdbc.framework.generator.SequenceGenerator();
						String pk = idGenerator.generate(ts.substring(0, 4));
						InsertSql(pk,objcode,entityPk,code_entity,pk_year,measurePk,code_measure,versionPk,code_version,pk_yss,yss,pk_corpYS001,code_corpYS001,pk_corpYS002,code_corpYS002,pk_corpYS003,code_corpYS003,pk_corpYS0004,code_corpYS0004,value.toString(),ts);
					}
					Object yszepk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,ysze);//预算总额pk
					if(yszepk!=null){
						//修改预算总额
						UpdateSql(objcode,value.toString(),yszepk.toString());
					}
					else{
						//新增一条预算总额的记录
						String ts = new UFDateTime().toString();
						nc.jdbc.framework.generator.IdGenerator idGenerator = new nc.jdbc.framework.generator.SequenceGenerator();
						String pk = idGenerator.generate(ts.substring(0, 4));
						InsertSql(pk,objcode,entityPk,code_entity,pk_year,measurePk,code_measure,versionPk,code_version,pk_ysze,ysze,pk_corpYS001,code_corpYS001,pk_corpYS002,code_corpYS002,pk_corpYS003,code_corpYS003,pk_corpYS0004,code_corpYS0004,value.toString(),ts);
					}
					Object kyyepk = QueryPk(objcode,code_entity,pk_year,code_measure,code_version,kyye);//可用余额pk
					if(kyyepk!=null){
						UpdateSql(objcode,value.sub(actualUse).sub(pupremny).toString(),kyyepk.toString());
					}
					else{
						//新增一条可用余额的记录
						String ts = new UFDateTime().toString();
						nc.jdbc.framework.generator.IdGenerator idGenerator = new nc.jdbc.framework.generator.SequenceGenerator();
						String pk = idGenerator.generate(ts.substring(0, 4));
						InsertSql(pk,objcode,entityPk,code_entity,pk_year,measurePk,code_measure,versionPk,code_version,pk_kyye,kyye,pk_corpYS001,code_corpYS001,pk_corpYS002,code_corpYS002,pk_corpYS003,code_corpYS003,pk_corpYS0004,code_corpYS0004,value.sub(actualUse).sub(pupremny).toString(),ts);
					}
					result.add(formatRSJsonData("成功",
						     "",bodyObject.getString("objname")+pk_year+"年"+bodyObject.getString("code_measure")+"预算修改成功").toString());
				}
			}
			returnobj.put("info", "成功");
			returnobj.put("errMessage", "");
			returnobj.put("result", result);
			resp.getWriter().write(returnobj.toString());
			
		}  catch (Exception e) {
			// TODO 自动生成的 catch 块
			resp.getWriter().write(formatRSJsonData("失败",
			         "",e.getMessage()).toString());
		}
	}
	
	
	/*
	 * 非空判断
	 */
	private String checkJson(JSONObject json) throws Exception {
		
		StringBuffer mags = new StringBuffer();
		Boolean empty = true;
		
		String body = "result";//表体
		
		if (json.getJSONArray(body)==null) {
			empty = false;
			mags.append("表体不存在！ ");
		}
		
		JSONArray oprepObjectBs = json.getJSONArray("result");
		
		if (oprepObjectBs == null || oprepObjectBs.size() == 0) {
			return "表体内容不可为空！";
		}
		
		String objname = "objname";//应用模型
		String code_entity = "code_entity";//责任主体
		String pk_year = "pk_year";//会计年份
		String code_measure = "code_measure";//预算编码
		String code_version = "code_version";//预算版本

		String value = "value";//预算额度
		
		String pk_corpYS001 = "pk_corpYS001";
		String code_corpYS001 = "code_corpYS001";
		String pk_corpYS002 = "pk_corpYS002";
		String code_corpYS002 = "code_corpYS002";
		String pk_corpYS003 = "pk_corpYS003";
		String code_corpYS003 = "code_corpYS003";
		String pk_corpYS0004 = "pk_corpYS0004";
		String code_corpYS0004 = "code_corpYS0004";
		
		for(int i = 0; i < oprepObjectBs.size(); i++) {
			
			JSONObject oprepJsonObjectB = oprepObjectBs.getJSONObject(i);
			String[] BodyKey = {objname,code_entity,pk_year,code_measure,code_version,value,pk_corpYS001,code_corpYS001,pk_corpYS002,code_corpYS002,pk_corpYS003,code_corpYS003,pk_corpYS0004,code_corpYS0004};
			int num = i+1;
			
			mags.append("第"+num+"块表体：{");
			for (String as : BodyKey) {

				if (oprepJsonObjectB.getString(as).isEmpty()) {
					empty = false;
					mags.append("'" + as + "' ");
				}
			}
			mags.append("}");
		}
		
		if (!empty) {
			return "以下字段不可为空："+mags;
		}
		return null;
	}
	
	/**
	 * 查询应用模型编码
	 * @param objname
	 * @return
	 * @throws Exception
	 */
	public String QueryModelCode(String objname) throws Exception{
		String qrysql = "select objcode from tb_cubedef where objname = '"+objname+"' and nvl(dr,0) = 0";
		Object object;
		object = iuap.executeQuery(qrysql, new ColumnProcessor());
		if (object==null) {
			return null;
		}else {
			return object.toString();
		}
	}
	
	/**
	 * 查询责任主体pk
	 * @param code_entity
	 * @return
	 * @throws Exception
	 */
	public String QueryOrgPk(String code_entity) throws Exception{
		String qrysql = "select pk_org from org_orgs where code = '"+code_entity+"' and nvl(dr,0) = 0";
		Object object;
		object = iuap.executeQuery(qrysql, new ColumnProcessor());
		if (object==null) {
			return null;
		}else {
			return object.toString();
		}
	}
	
	/**
	 * 查询预算编码
	 * @param code_measure
	 * @return
	 * @throws Exception
	 */
	public List<String> QueryMeasureCode(String code_measure) throws Exception{
		List<String> ListMeasure = new ArrayList<String>();
		String qrysql = "select code,pk_inoutbusiclass  from bd_inoutbusiclass where name = '"+code_measure+"' and nvl(dr,0) = 0";
		Object code;
		code = iuap.executeQuery(qrysql, new ColumnProcessor("code"));
		if (code==null) {
			ListMeasure.add(null);
		}else {
			ListMeasure.add(code.toString());
		}
		Object pk_inoutbusiclass;
		pk_inoutbusiclass = iuap.executeQuery(qrysql, new ColumnProcessor("pk_inoutbusiclass"));
		if(pk_inoutbusiclass==null){
			ListMeasure.add(null);
		}else {
			ListMeasure.add(pk_inoutbusiclass.toString());
		}
		return ListMeasure;
	}
	
	/**
	 * 查询版本编码
	 * @param code_version
	 * @return
	 * @throws Exception
	 */
	public List<String> QueryVersionCode(String code_version) throws Exception{
		List<String> ListVersion = new ArrayList<String>();
		String qrysql = "select objcode,pk_obj from tb_version where objname = '"+code_version+"' and nvl(dr,0) = 0";
		Object objcode;
		objcode = iuap.executeQuery(qrysql, new ColumnProcessor("objcode"));
		if (objcode==null) {
			ListVersion.add(null);
		}else {
			ListVersion.add(objcode.toString());
		}
		Object pk_obj;
		pk_obj = iuap.executeQuery(qrysql, new ColumnProcessor("pk_obj"));
		if(pk_obj==null){
			ListVersion.add(null);
		}else {
			ListVersion.add(pk_obj.toString());
		}
		return ListVersion;
	}
	
	/**
	 * 查询金额
	 * @param objcode
	 * @param code_entity
	 * @param pk_year
	 * @param code_measure
	 * @param code_version
	 * @param code_mvtype
	 * @return
	 * @throws Exception 
	 */
	public String QueryNmny(String objcode,String code_entity,String pk_year,String code_measure,String code_version,String code_mvtype) throws Exception{
		String qrysql = "select value from tb_cube_"+objcode+" where code_entity = '"+code_entity+"' and pk_year = '"+pk_year+"' and code_measure = '"+code_measure+"'  and code_version = '"+code_version+"' and code_mvtype = '"+code_mvtype+"'";
		Object object = "";
			object = iuap.executeQuery(qrysql, new ColumnProcessor());
		if (object==null) {
			return "0";
		}else {
			return object.toString();
		}
	}
	
	/**
	 * 查询冻结金额
	 * @param code_entity
	 * @param pk_year
	 * @param code_measure
	 * @return
	 * @throws Exception
	 */
	public String QueryFrozen(String code_entity,String pk_year,String yscode) throws Exception{
		String qrysql = "select PreActual from V_THAPE_YS where code_entity = '"+code_entity+"' and pk_year = '"+pk_year+"' and yscode = '"+yscode+"'";
		Object object = "";
			object = iuap.executeQuery(qrysql, new ColumnProcessor());
		if (object==null) {
			return "0";
		}else {
			return object.toString();
		}
	}
	
	/**
	 * 查询pk
	 * @param objcode
	 * @param code_entity
	 * @param pk_year
	 * @param code_measure
	 * @param code_version
	 * @param code_mvtype
	 * @return
	 * @throws Exception 
	 */
	public String QueryPk(String objcode,String code_entity,String pk_year,String code_measure,String code_version,String code_mvtype) throws Exception{
		String qrysql = "select pk_obj from tb_cube_"+objcode+" where code_entity = '"+code_entity+"' and pk_year = '"+pk_year+"' and code_measure = '"+code_measure+"'  and code_version = '"+code_version+"' and code_mvtype = '"+code_mvtype+"'";
		Object object = "";
			object = iuap.executeQuery(qrysql, new ColumnProcessor());
		if (object==null) {
			return null;
		}else {
			return object.toString();
		}
	}
	
	public List<String> QueryCorpYS(String objcode,String code_measure) throws Exception{
		List<String> ListCorp = new ArrayList<String>();
		String qrysql = "select distinct pk_corpYS001,code_corpYS001,pk_corpYS002,code_corpYS002,pk_corpYS003,code_corpYS003,pk_corpYS0004,code_corpYS0004 from tb_cube_"+objcode+" where  code_measure = '"+code_measure+"' and pk_corpYS001 != '~' and pk_corpYS002 !='~' and pk_corpYS003 != '~' and pk_corpYS0004 != '~'";
		Object pk_corpYS001;
		pk_corpYS001 = iuap.executeQuery(qrysql, new ColumnProcessor("pk_corpYS001"));
		if (pk_corpYS001==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(pk_corpYS001.toString());
		}
		Object code_corpYS001;
		code_corpYS001 = iuap.executeQuery(qrysql, new ColumnProcessor("code_corpYS001"));
		if (pk_corpYS001==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(code_corpYS001.toString());
		}
		Object pk_corpYS002;
		pk_corpYS002 = iuap.executeQuery(qrysql, new ColumnProcessor("pk_corpYS002"));
		if (pk_corpYS002==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(pk_corpYS002.toString());
		}
		Object code_corpYS002;
		code_corpYS002 = iuap.executeQuery(qrysql, new ColumnProcessor("code_corpYS002"));
		if (code_corpYS002==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(code_corpYS002.toString());
		}
		Object pk_corpYS003;
		pk_corpYS003 = iuap.executeQuery(qrysql, new ColumnProcessor("pk_corpYS003"));
		if (pk_corpYS003==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(pk_corpYS003.toString());
		}
		Object code_corpYS003;
		code_corpYS003 = iuap.executeQuery(qrysql, new ColumnProcessor("code_corpYS003"));
		if (code_corpYS003==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(code_corpYS003.toString());
		}
		Object pk_corpYS0004;
		pk_corpYS0004 = iuap.executeQuery(qrysql, new ColumnProcessor("pk_corpYS0004"));
		if (pk_corpYS0004==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(pk_corpYS0004.toString());
		}
		Object code_corpYS0004;
		code_corpYS0004 = iuap.executeQuery(qrysql, new ColumnProcessor("code_corpYS0004"));
		if (code_corpYS0004==null) {
			ListCorp.add(null);
		}else {
			ListCorp.add(code_corpYS0004.toString());
		}
		return ListCorp;
	}
	
	/**
	 * 修改预算额度
	 * @param objcode
	 * @param value
	 * @param pk
	 * @throws DAOException
	 */
	public void UpdateSql(String objcode,String value,String pk) throws DAOException{
		String sql = "update tb_cube_"+objcode+" set value = '"+value+"' where pk_obj = '"+pk+"'";
		basedao.executeUpdate(sql);
		
	}
	
	/**
	 * 执行插入
	 * @param pk
	 * @param objcode
	 * @param entityPk
	 * @param code_entity
	 * @param pk_year
	 * @param measurePk
	 * @param code_measure
	 * @param versionPk
	 * @param code_version
	 * @param pk_mvtype
	 * @param code_mvtype
	 * @param pk_corpYS001
	 * @param code_corpYS001
	 * @param pk_corpYS002
	 * @param code_corpYS002
	 * @param pk_corpYS003
	 * @param code_corpYS003
	 * @param pk_corpYS0004
	 * @param code_corpYS0004
	 * @param value
	 * @param ts
	 * @throws DAOException
	 */
	public void InsertSql(String pk,String objcode,String entityPk,String code_entity,String pk_year,String measurePk,String code_measure,String versionPk,String code_version,String pk_mvtype,String code_mvtype,String pk_corpYS001,String code_corpYS001,String pk_corpYS002,String code_corpYS002,String pk_corpYS003,String code_corpYS003,String pk_corpYS0004,String code_corpYS0004,String value,String ts) throws DAOException{
		StringBuffer str = new StringBuffer();
		str.append("insert into tb_cube_"+objcode);
		str.append(" (PK_OBJ, UNIQKEY, PK_VERSION, CODE_VERSION, PK_ALL_CURR, CODE_ALL_CURR, PK_CURR, CODE_CURR, PK_ALL_CURR_MAP, CODE_ALL_CURR_MAP, PK_AIMCURR, CODE_AIMCURR, PK_MVTYPE, CODE_MVTYPE, PK_ENTITY, CODE_ENTITY, PK_YEAR, CODE_YEAR, PK_MEASURE, CODE_MEASURE, PK_ALL_CORPYS000, CODE_ALL_CORPYS000, PK_CORPYS000, CODE_CORPYS000, PK_ALL_CORPYS001, CODE_ALL_CORPYS001, PK_CORPYS001, CODE_CORPYS001, PK_ALL_CORPYS002, CODE_ALL_CORPYS002, PK_CORPYS002, CODE_CORPYS002, PK_ALL_CORPYS003, CODE_ALL_CORPYS003, PK_CORPYS003, CODE_CORPYS003, PK_ALL_CORPYS0004, CODE_ALL_CORPYS0004, PK_CORPYS0004, CODE_CORPYS0004, VALUE, TXTVALUE, STATUS2, STATUS3, TS, DR)");
		str.append(" values ('");
		str.append(pk+"','");
		str.append(pk+"','");
		str.append(versionPk+"','");
		str.append(code_version+"','");
		str.append("TB_DIMHIALLMURR_0000','");
		str.append("ALL','");
		str.append("1002Z0100000000001K1','");
		str.append("CNY','");
		str.append("TB_DIMHIALLMURR_0000','");
		str.append("ALL','");
		str.append("1002Z0100000000001K1','");
		str.append("CNY','");
		str.append(pk_mvtype+"','");
		str.append(code_mvtype+"','");
		str.append(entityPk+"','");
		str.append(code_entity+"','");
		str.append(pk_year+"','");
		str.append(pk_year+"','");
		str.append(measurePk+"','");
		str.append(code_measure+"','");
		str.append("1001A810ALLM0001EYD0','");
		str.append("ALL','");
		str.append("~','");
		str.append("~','");
		str.append("1001A810ALLM0001EX0Q','");
		str.append("ALL','");
		str.append(pk_corpYS001+"','");
		str.append(code_corpYS001+"','");
		str.append("1001A810ALLM0001EX17','");
		str.append("ALL','");
		str.append(pk_corpYS002+"','");
		str.append(code_corpYS002+"','");
		str.append("1001A810ALLM0001EX1N','");
		str.append("ALL','");
		str.append(pk_corpYS003+"','");
		str.append(code_corpYS003+"','");
		str.append("1001A810ALLM0001EX24','");
		str.append("ALL','");
		str.append(pk_corpYS0004+"','");
		str.append(code_corpYS0004+"',");
		str.append(value+",");
		str.append("null,");
		str.append("32,");
		str.append("0,'");
		str.append(ts+"',");
		str.append("null)");
		basedao.executeUpdate(str.toString());
	}
	
	
	
	
}
