package kr.co.kihyun.beans.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
//import java.io.ByteArrayOutputStream;
//import java.io.ByteArrayInputStream;
//import java.util.Arrays;
//
//import java.sql.Blob;
//
//import kr.co.kihyun.beans.entity.MDept;
//import kr.co.kihyun.beans.entity.MUser;
//import kr.co.kihyun.beans.entity.MoumiEntity;
//import kr.co.kihyun.beans.entity.SysAuth;
//import kr.co.kihyun.beans.entity.TotDoc;
//import kr.co.kihyun.beans.entity.TotReport;
//import kr.co.kihyun.beans.entity.TotReportProcess;
//import kr.co.kihyun.beans.entity.TotReportType;
//
//import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.Collections;
import java.util.Date;
//import java.util.HashMap;
//import java.util.HashSet;
import java.util.List;
//import java.util.Map;
//import java.util.Set;
//import javax.jdo.JDOObjectNotFoundException;
//import javax.jdo.PersistenceManager;
//import javax.jdo.Query;
//import javax.jdo.annotations.IdentityType;
//import javax.jdo.annotations.NullValue;
//import javax.jdo.annotations.PersistenceCapable;
//import javax.jdo.annotations.Persistent;
//import kr.co.kihyun.beans.entity.ecross.IRemotePersistable;
//import kr.co.kihyun.beans.entity.util.QueryImpl;
//import kr.co.kihyun.io.IUploadable;
//import kr.co.kihyun.lang.MString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kr.co.kihyun.db.DBManager;


public class SubmitReport  extends DBManager {

   private static final Logger LOG = LoggerFactory.getLogger(SubmitReport.class);


	private ResultSet rs = null;

	private int count = 0;
	private String[] nameList = null;
    private String[] nameUp   = null;
	private String[] nameDept = null;   
  
	private String[] ownerName = null;   
    private String[] phone = null;
    private String[] submitDate = null;
    private String[] founDation = null;
    private String upperDept = null;
    private int[] prss = null;
    private int[] downDocId = null;
    private byte[] attachments = null;
    private int tCount;
    private String[] nullNameup = null;

    //새로 추가 문정호
    private int grade = 0;
    private String organ = null;
    private String[] id = null;
    private String[] execCode = null;
    private Date[] startDate = null;
    private Date[] endDate = null;
    private int[] docId = null;

    private String[] docOwnerName=null;
    private String[] rptOwnerName = null;
    private String[] UserId = null;
    private Date[] SubmitDate = null;
    private int[] moumiacptLimitstrategy = null;
    private int[] Appro = null;
    private int sysAuth;
	
	private String[] secuOption = null;

  /*private String[] data = null;
    private String[] totData = null;*/	

   /******** 카테고리 전체 리스트 ********/
	public void executeQuery(String usID,String findOption,Object filterValue) {
		    StringBuilder sql = new StringBuilder(250);
        try {

            if(filterValue != null && findOption == null){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp') ")
                    .append(" ,dc.name ")
                    .append(" ,dt.name ")
                    .append(" ,sp_cm_dec_fu(dc.owner_name) ")
                    .append(" ,sp_cm_dec_fu(rt.owner_name) ")
                    .append(" ,dc.start_date ")
                    .append(" ,dc.end_date ")
                    .append(" ,rt.prss ")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0) ")
                    .append(" ,rt.id ")
                    .append(" ,rt.user_id ")
                    .append(" ,rt.SUBMIT_DATE ")
                    .append(" ,AC.SUBMIT_LIMIT_CNT ")
                    .append(" ,RT.APPRO ")
                        .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.name")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                         .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    .append("  and dc.name like '%"+filterValue+"%'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.executionCode")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                         .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    //.append("  and dc.exec_code like '%"+filterValue+"%'")
                    .append("  and  dc.owner_name = sp_cm_enc_fu('"+filterValue+"')")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.mUser.name")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                         .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    .append("  and  dc.owner_name = sp_cm_enc_fu('"+filterValue+"')")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.mUser.name2")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                         .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    .append("  and  dc.owner_name = sp_cm_enc_fu('"+filterValue+"')")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else{
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                         .append(" ,rt.secu_yn" )
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.user_id = '"+usID+"'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }
                         
			rs = execQuery(sql);
			if (rs != null) {
				rs.last();
				count = rs.getRow();
				rs.beforeFirst();
			} else {
				return;
			}
            
			execCode  = new String[count];
			nameList  = new String[count];
			nameUp    = new String[count];
            docOwnerName = new String[count];
            rptOwnerName = new String[count];
            startDate = new Date[count];
            endDate   = new Date[count];
            prss      = new int[count];
            downDocId = new int[count];
            id        = new String[count];
            UserId    = new String[count];
            SubmitDate= new Date[count];
            moumiacptLimitstrategy = new int[count];
            Appro = new int[count];
            secuOption = new String[count];
            tCount    = count;

			for (int i = 0; rs.next(); i++) {
				execCode[i] = rs.getString(1);
				nameList[i] = rs.getString(2);
				nameUp[i] = rs.getString(3);
                docOwnerName[i] = rs.getString(4);
                rptOwnerName[i] = rs.getString(5);
				startDate[i] = rs.getDate(6);
				endDate[i] = rs.getDate(7);
                prss[i] = rs.getInt(8);
                downDocId[i] =  rs.getInt(9);
                id[i]        = rs.getString(10);
                UserId[i]    = rs.getString(11);
                SubmitDate[i]= rs.getDate(12);
                moumiacptLimitstrategy[i] = rs.getInt(13);
                Appro[i] = rs.getInt(14);
                secuOption[i]    = rs.getString(15);
			}
            //System.out.println(sql+"\nfindOption:::::"+findOption+"\nfilterValue::::::"+filterValue);

		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
					new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage() });
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}

     /******** 카테고리 전체 리스트 ********/
	public void executeQuery2(String dtID,String findOption,Object filterValue) {
		    StringBuilder sql = new StringBuilder(250);
        try {
              if(filterValue != null && findOption == null){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.name")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  and dc.name like '%"+filterValue+"%'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.executionCode")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  and dc.exec_code like '%"+filterValue+"%'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.mUser.name")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  and  dc.owner_name = sp_cm_enc_fu('"+filterValue+"')")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else if(filterValue != null && findOption.equals("totDoc.mUser.name2")){
                 sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("  AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  and  rt.owner_name = sp_cm_enc_fu('"+filterValue+"')")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }else{
                sql.append(" select ")
                    .append(" coalesce(dc.exec_code,'&nbsp')")
                    .append(" ,dc.name")
                    .append(" ,dt.name")
                    .append(" ,sp_cm_dec_fu(dc.owner_name)")
                    .append(" ,sp_cm_dec_fu(rt.owner_name)")
                    .append(" ,dc.start_date")
                    .append(" ,dc.end_date")
                    .append(" ,rt.prss")
                    .append(" ,coalesce(rt.DOWN_DOC_ID,0)")
                    .append(" ,rt.id")
                    .append(" ,rt.user_id")
                    .append(" ,rt.SUBMIT_DATE")
                    .append(" ,AC.SUBMIT_LIMIT_CNT")
                    .append(" ,RT.APPRO ")
                    .append("  from moumi_tot_doc dc,MOUMI_TOT_REPORT rt,moumi_dept dt,MOUMI_ACPT_LIMIT_STRATEGY AC")
                    .append("  where rt.doc_id = dc.id and dc.dept_id = dt.id and dc.del_type='N'")
                    .append("  and rt.del_type='N' and rt.prss in (6,12,14) ")
                    .append("  AND DC.ACPT_LIMIT = AC.ID")
                    .append("  and rt.dept_id = '"+dtID+"'")
                    .append("  order by case when rt.SUBMIT_DATE is null then 0 else 1 end desc,rt.SUBMIT_DATE desc");
                }

			rs = execQuery(sql);
			if (rs != null) {
				rs.last();
				count = rs.getRow();
				rs.beforeFirst();
			} else {
				return;
			}

			execCode  = new String[count];
			nameList  = new String[count];
			nameUp    = new String[count];
            docOwnerName = new String[count];
            rptOwnerName = new String[count];
            startDate = new Date[count];
            endDate   = new Date[count];
            prss      = new int[count];
            downDocId = new int[count];
            id        = new String[count];
            UserId    = new String[count];
            SubmitDate= new Date[count];
            moumiacptLimitstrategy = new int[count];
            Appro = new int[count];
            tCount    = count;

			for (int i = 0; rs.next(); i++) {
				execCode[i] = rs.getString(1);
				nameList[i] = rs.getString(2);
				nameUp[i] = rs.getString(3);
                docOwnerName[i] = rs.getString(4);
                rptOwnerName[i] = rs.getString(5);
				startDate[i] = rs.getDate(6);
				endDate[i] = rs.getDate(7);
                prss[i] = rs.getInt(8);
                downDocId[i] =  rs.getInt(9);
                id[i]        = rs.getString(10);
                UserId[i]    = rs.getString(11);
                SubmitDate[i]= rs.getDate(12);
                moumiacptLimitstrategy[i] = rs.getInt(13);
                Appro[i] = rs.getInt(14);

			}
            //System.out.println(sql+"\nfindOption:::::"+findOption+"\nfilterValue::::::"+filterValue);

		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
					new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage() });
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}
	
	public void updateSecuOptn(List<Long> reportIDs, Boolean SecuOptn)
	{
		StringBuilder sql = new StringBuilder(250);
		StringBuilder sqlParam = new StringBuilder(250);

		try {
			for (int i = 0; i < reportIDs.size(); i++)
			{
				sqlParam.append("id = " + reportIDs.get(i));
				if (i < (reportIDs.size() - 1))
				{
					sqlParam.append(" or ");
				}
			}

			String SecuOptnStr;
			if (SecuOptn == true)
			{
				SecuOptnStr = "Y";
			}
			else
			{
				SecuOptnStr = "N";
			}

			sql.append("update moumi_tot_report ")
				.append("	set secu_yn='" + SecuOptnStr + "' ")
				.append("	where " + sqlParam.substring(0));
			execUpdate(sql.toString());
		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
					new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage(), sql });
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}
	
    public void getSysAuth(String id) {
		StringBuilder sql = new StringBuilder(150);
		try {
			sql.append("select sys_auth from moumi_muser where ID = '"+id+"'");
			rs = execQuery(sql);
			if (rs.next()) {
				sysAuth = rs.getInt(1);
			}
		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
					new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage(), sql });
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}


    public String[] getNameList() {
            //24.Public 메소드로부터 반환된 Private배열_CWE-495 : Update by KWON,HAN
	    //	return nameList;
        
            String[] ret = null;
            if( this.nameList != null) {
                ret = new String[nameList.length];
                for (int i=0; i<nameList.length; i++) {
                    ret[i] = this.nameList[i];
                }
            }
            return ret;
            //====================================================================        
	}

     public String[] getNameUp() {
	    //	return nameUp;
                
            String[] ret = null;
            if( this.nameUp != null) {
                ret = new String[nameUp.length];
                for (int i=0; i<nameUp.length; i++) {
                    ret[i] = this.nameUp[i];
                }
            }
            return ret;                
	}

    public String[] getNameDept() {
	    //	return nameDept;
                
            String[] ret = null;
            if( this.nameDept != null) {
                ret = new String[nameDept.length];
                for (int i=0; i<nameDept.length; i++) {
                    ret[i] = this.nameDept[i];
                }
            }
            return ret;                   
	}

    public String[] getOwnerName() {
	    //	return ownerName;
                
            String[] ret = null;
            if( this.ownerName != null) {
                ret = new String[ownerName.length];
                for (int i=0; i<ownerName.length; i++) {
                    ret[i] = this.ownerName[i];
                }
            }
            return ret;                 
	}

    public String[] getId() {
	    //	return id;
                
            String[] ret = null;
            if( this.id != null) {
                ret = new String[id.length];
                for (int i=0; i<id.length; i++) {
                    ret[i] = this.id[i];
                }
            }
            return ret;                     
	}

    public String[]  getPhone(){
        //  return phone;
          
        String[] ret = null;
        if( this.phone != null) {
            ret = new String[phone.length];
            for (int i=0; i<phone.length; i++) {
                ret[i] = this.phone[i];
            }
        }
        return ret;           
      }

    public String[]  getFounDation(){
        //  return founDation;
          
        String[] ret = null;
        if( this.founDation != null) {
            ret = new String[founDation.length];
            for (int i=0; i<founDation.length; i++) {
                ret[i] = this.founDation[i];
            }
        }
        return ret;            
      }

     public int[]  getDowndocid(){
        //  return downDocId;
          
        int[] ret = null;
        if( this.downDocId != null) {
            ret = new int[downDocId.length];
            for (int i=0; i<downDocId.length; i++) {
                ret[i] = this.downDocId[i];
            }
        }
        return ret;           
      }

    public String[]  getDocOwnername(){
        //  return docOwnerName;
          
        String[] ret = null;
        if( this.docOwnerName != null) {
            ret = new String[docOwnerName.length];
            for (int i=0; i<docOwnerName.length; i++) {
                ret[i] = this.docOwnerName[i];
            }
        }
        return ret;           
      }

     public String[]  getRptOwnername(){
        //  return rptOwnerName;
          
        String[] ret = null;
        if( this.rptOwnerName != null) {
            ret = new String[rptOwnerName.length];
            for (int i=0; i<rptOwnerName.length; i++) {
                ret[i] = this.rptOwnerName[i];
            }
        }
        return ret;                  
      }
 
    public int  getGrade(){
          return grade;
      }

   public int[]  getPrss(){
        //  return prss;
          
        int[] ret = null;
        if( this.prss != null) {
            ret = new int[prss.length];
            for (int i=0; i<prss.length; i++) {
                ret[i] = this.prss[i];
            }
        }
        return ret;           
      }

  public String  getOrgan(){
          return organ;
      }

  public String  getUpperDept(){
          return upperDept;
      }
  

   public byte[]  getAttachments(){
        //  return attachments;
          
        byte[] ret = null;
        if( this.attachments != null) {
            ret = new byte[attachments.length];
            for (int i=0; i<attachments.length; i++) {
                ret[i] = this.attachments[i];
            }
        }
        return ret;                
      }

   public int  getCount(){
          return tCount;
      }

   public String[]  getNullnameup(){
        //  return nullNameup;
          
        String[] ret = null;
        if( this.nullNameup != null) {
            ret = new String[nullNameup.length];
            for (int i=0; i<nullNameup.length; i++) {
                ret[i] = this.nullNameup[i];
            }
        }
        return ret;           
     }

    public String[]  getExeccode(){
        //  return execCode;
          
        String[] ret = null;
        if( this.execCode != null) {
            ret = new String[execCode.length];
            for (int i=0; i<execCode.length; i++) {
                ret[i] = this.execCode[i];
            }
        }
        return ret;                
      }
    public Date[]  getStartdate(){
        //  return startDate;
          
        Date[] ret = null;
        if( this.startDate != null) {
            ret = new Date[startDate.length];
            for (int i=0; i<startDate.length; i++) {
                ret[i] = this.startDate[i];
            }
        }
        return ret;             
      }
    public Date[]  getEnddate(){
        //  return endDate;
          
        Date[] ret = null;
        if( this.endDate != null) {
            ret = new Date[endDate.length];
            for (int i=0; i<endDate.length; i++) {
                ret[i] = this.endDate[i];
            }
        }
        return ret;           
      }

   public int[]  getDocid(){
        //  return docId;
          
        int[] ret = null;
        if( this.docId != null) {
            ret = new int[docId.length];
            for (int i=0; i<docId.length; i++) {
                ret[i] = this.docId[i];
            }
        }
        return ret;          
      }

   public String[]  getUserId(){
        //  return UserId;
          
        String[] ret = null;
        if( this.UserId != null) {
            ret = new String[UserId.length];
            for (int i=0; i<UserId.length; i++) {
                ret[i] = this.UserId[i];
            }
        }
        return ret;           
      }

   public Date[]  getSubmitDate(){
        //  return SubmitDate;
          
        Date[] ret = null;
        if( this.SubmitDate != null) {
            ret = new Date[SubmitDate.length];
            for (int i=0; i<SubmitDate.length; i++) {
                ret[i] = this.SubmitDate[i];
            }
        }
        return ret;          
      }

   public int[]  getMoumiAcptLimitStrategy(){
        //  return moumiacptLimitstrategy;
          
        int[] ret = null;
        if( this.moumiacptLimitstrategy != null) {
            ret = new int[moumiacptLimitstrategy.length];
            for (int i=0; i<moumiacptLimitstrategy.length; i++) {
                ret[i] = this.moumiacptLimitstrategy[i];
            }
        }
        return ret;           
      }
   
   public int[]  getAppro(){
        //  return Appro;
          
        int[] ret = null;
        if( this.Appro != null) {
            ret = new int[Appro.length];
            for (int i=0; i<Appro.length; i++) {
                ret[i] = this.Appro[i];
            }
        }
        return ret;            
      }

    public int getAuthNum(){
          return sysAuth;
      }

	public String[] getSecuOptn() {
	    //	return secuOption;
                
            String[] ret = null;
            if( this.secuOption != null) {
                ret = new String[secuOption.length];
                for (int i=0; i<secuOption.length; i++) {
                    ret[i] = this.secuOption[i];
                }
            }
            return ret;                  
	}

}
