/**
 * Copyright (c) 2003-2004 System Integrator Corporation.
 *                 All Rights Reserved.
 */
package jp.co.sint.beans.mallmgr;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;//7.2.0 ST0546 追加
import java.util.Iterator;
import java.util.Calendar;//7.2.0 ST0546 追加
import java.util.GregorianCalendar;//7.2.0 ST0546 追加

import javax.servlet.http.HttpServletRequest;

import jp.co.sint.basic.SIAccesslog;
import jp.co.sint.basic.SIBasic;
//import jp.co.sint.basic.SINameValue; 7.2.0 ST0546 削除
import jp.co.sint.config.SIConfig;
import jp.co.sint.config.SIDBMultiConf;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.database.SIDateTimeType;//7.2.0 ST0546 追加
import jp.co.sint.database.SIDateType;
import jp.co.sint.tools.SICheckDataConf;
import jp.co.sint.tools.SICheckValid;
import jp.co.sint.tools.SICustomErrors;
import jp.co.sint.tools.SIDateTime;
import jp.co.sint.tools.SIUtil;
import jp.co.sint.tools.SIURLParameter;//7.1.1 ST0236 追加

import org.apache.log4j.Category;

/**
 * @version $Id: UIAccesslogListCond.java,v 1.0 2003/09/19 Exp $
 * @author  asakura
 * <br>Description:
 * <p>History</p>
 * <p>Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reason</p>
 *  ============&nbsp;&nbsp;&nbsp;==========&nbsp;&nbsp;===========================<br>
 * asakura        2003/12/24 11:06:28  Original
 * imai           2004/12/01           集計単位の追加に伴い、全体的に修正(7.2.0 ST0546)
 */
public class UIAccesslogListCond extends SIBasic{
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  //期間の年(From)
  private String dateYearFromCbo="";
  
  //期間の月(From)
  private String dateMonthFromCbo="";
  
  //期間の日(From)
  private String dateDayFromCbo="";
  
  //期間の年(To)
  private String dateYearToCbo="";
  
  //期間の月(To)
  private String dateMonthToCbo="";
  
  //期間の日(To)
  private String dateDayToCbo="";
  
  //期間の間
  //private String dateBetweenCbo="";//7.2.0 ST0546 削除
  
  //期間のフラグ
  //private String betweenFlgCbo="";//7.2.0 ST0546 削除
  
  //表示種別
  private String dispFlgRdo="1";
  
  //期間の年(From)
  private String dateYearFromCbo_R="";
  
  //期間の月(From)
  private String dateMonthFromCbo_R="";
  
  //期間の日(From)
  private String dateDayFromCbo_R="";
  
  //7.2.0 ST0546 追加 ここから
  //期間の年(To)
  private String dateYearToCbo_R="";
  
  //期間の月(To)
  private String dateMonthToCbo_R="";
  
  //期間の日(To)
  private String dateDayToCbo_R="";
  
  //7.2.0 ST0546 追加 ここまで
  
  //期間の間
  //private String dateBetweenCbo_R="";//7.2.0 ST0546 削除
  
  //期間のフラグ
  //private String betweenFlgCbo_R="";//7.2.0 ST0546 削除
  
  //表示種別
  private String dispFlgRdo_R="1";
  
  //検索条件エラーフラグ
  private boolean error = false;
  
  //アクセス数Total
  private String totalAccess = "0";
  
  public UIAccesslogListCond(){    
    //7.2.0 ST0546 修正・追加 ここから
    //期間の初期値をセット
    SIDateTime today = new SIDateTime();
    
    //時間帯別のときは、From:一週間前 To:今日
    if(this.getDispFlgRdo().equals("1")){
      this.setDateYearToCbo(today.getYearStr());
      this.setDateMonthToCbo(today.getMonthStr());
      this.setDateDayToCbo(today.getDayStr());
      
      today.addDay(-6);
      this.setDateYearFromCbo(today.getYearStr());
      this.setDateMonthFromCbo(today.getMonthStr());
      this.setDateDayFromCbo(today.getDayStr());
    //月別・日別のときは、From:今月の月初 To:月末
    }else{
      this.setDateYearFromCbo(today.getYearStr());          //期間の年(From)
      this.setDateMonthFromCbo(today.getMonthStr());        //期間の月(From)
      this.setDateDayFromCbo("01");                         //期間の日(From)
      this.setDateYearToCbo(today.getYearStr());            //期間の年(To)
      this.setDateMonthToCbo(today.getMonthStr());          //期間の月(To)
      this.setDateDayToCbo(today.getDayStr());              //期間の日(To)
    }
    
    this.setDateYearFromCbo_R(this.getDateYearFromCbo());   //期間の年(From)
    this.setDateMonthFromCbo_R(this.getDateMonthFromCbo()); //期間の月(From)
    this.setDateDayFromCbo_R(this.getDateDayFromCbo());     //期間の日(From)
    this.setDateYearToCbo_R(this.getDateYearToCbo());       //期間の年(To)
    this.setDateMonthToCbo_R(this.getDateMonthToCbo());     //期間の月(To)
    this.setDateDayToCbo_R(this.getDateDayToCbo());         //期間の日(To)
    //7.2.0 ST0546 修正・追加 ここまで
    
    /* 7.2.0 ST0546 削除 ここから
    //this.setDateBetweenCbo("01");//期間の間
    //this.setDateBetweenCbo_R(this.getDateBetweenCbo());//期間の間
    //this.setBetweenFlgCbo("0");//期間
    //this.setBetweenFlgCbo_R(this.getBetweenFlgCbo());//期間
    
    SimpleDateFormat sdf=new SimpleDateFormat(SIConfig.SIDATE_FORMAT);
    sdf.setLenient(false);
    
    try{
      SIDateTime to = new SIDateTime(sdf.parse(this.getDateFrom()));
      /*if(this.getBetweenFlgCbo().equals("0")){
        to.addDay(Integer.parseInt(this.getDateBetweenCbo()));
      }else if(this.getBetweenFlgCbo().equals("1")){
        to.addMonth(Integer.parseInt(this.getDateBetweenCbo()));
      }
      this.setDateYearToCbo(to.getYearStr());//期間の年(To)
      this.setDateMonthToCbo(to.getMonthStr());//期間の月(To)
      this.setDateDayToCbo(to.getDayStr());//期間の日(To)
    }catch(Exception e){}
    7.2.0 ST0546 削除 ここまで
    */
  }
  
  //setter of 期間の年(From)
  public void setDateYearFromCbo(String lDateYearFromCbo){
    if (SIUtil.isNull(lDateYearFromCbo)) lDateYearFromCbo="";
    this.dateYearFromCbo=SIUtil.changeTo(lDateYearFromCbo.trim(),this.encode);
  }
  
  //setter of 期間の月(From)
  public void setDateMonthFromCbo(String lDateMonthFromCbo){
    if (SIUtil.isNull(lDateMonthFromCbo)) lDateMonthFromCbo="";
    this.dateMonthFromCbo=SIUtil.changeTo(lDateMonthFromCbo.trim(),this.encode);
  }
  
  //setter of 期間の日(From)
  public void setDateDayFromCbo(String lDateDayFromCbo){
    if (SIUtil.isNull(lDateDayFromCbo)) lDateDayFromCbo="";
    this.dateDayFromCbo=SIUtil.changeTo(lDateDayFromCbo.trim(),this.encode);
  }
  
  //setter of 期間の年(To)
  public void setDateYearToCbo(String lDateYearToCbo){
    if (SIUtil.isNull(lDateYearToCbo)) lDateYearToCbo="";
    this.dateYearToCbo=SIUtil.changeTo(lDateYearToCbo.trim(),this.encode);
  }
  
  //setter of 期間の月(To)
  public void setDateMonthToCbo(String lDateMonthToCbo){
    if (SIUtil.isNull(lDateMonthToCbo)) lDateMonthToCbo="";
    this.dateMonthToCbo=SIUtil.changeTo(lDateMonthToCbo.trim(),this.encode);
  }
  
  //setter of 期間の日(To)
  public void setDateDayToCbo(String lDateDayToCbo){
    if (SIUtil.isNull(lDateDayToCbo)) lDateDayToCbo="";
    this.dateDayToCbo=SIUtil.changeTo(lDateDayToCbo.trim(),this.encode);
  }
  
  /*7.2.0 ST0546 削除 ここから
  //setter of 期間の間
  public void setDateBetweenCbo(String lDateBetweenCbo){
    if (SIUtil.isNull(lDateBetweenCbo)) lDateBetweenCbo="";
    this.dateBetweenCbo=SIUtil.changeTo(lDateBetweenCbo.trim(),this.encode);
  }
  
  //setter of 期間のフラグ
  public void setBetweenFlgCbo(String lBetweenFlgCbo){
    if (SIUtil.isNull(lBetweenFlgCbo)) lBetweenFlgCbo="";
    this.betweenFlgCbo=SIUtil.changeTo(lBetweenFlgCbo.trim(),this.encode);
  }
  7.2.0 ST0546 削除 ここまで*/
  
  //setter of 表示種別
  public void setDispFlgRdo(String lDispFlgRdo){
    if (SIUtil.isNull(lDispFlgRdo)) lDispFlgRdo="1";
    this.dispFlgRdo=SIUtil.changeTo(lDispFlgRdo.trim(),this.encode);
  }
  
  //setter of 期間の年(From)
  public void setDateYearFromCbo_R(String lDateYearFromCbo){
    if (SIUtil.isNull(lDateYearFromCbo)) lDateYearFromCbo="";
    this.dateYearFromCbo_R=SIUtil.changeTo(lDateYearFromCbo.trim(),this.encode);
  }
  
  //setter of 期間の月(From)
  public void setDateMonthFromCbo_R(String lDateMonthFromCbo){
    if (SIUtil.isNull(lDateMonthFromCbo)) lDateMonthFromCbo="";
    this.dateMonthFromCbo_R=SIUtil.changeTo(lDateMonthFromCbo.trim(),this.encode);
  }
  
  //setter of 期間の日(From)
  public void setDateDayFromCbo_R(String lDateDayFromCbo){
    if (SIUtil.isNull(lDateDayFromCbo)) lDateDayFromCbo="";
    this.dateDayFromCbo_R=SIUtil.changeTo(lDateDayFromCbo.trim(),this.encode);
  }
  
  //7.2.0 ST0546 追加 ここから
  //setter of 期間の年(To)
  public void setDateYearToCbo_R(String lDateYearToCbo){
    if (SIUtil.isNull(lDateYearToCbo)) lDateYearToCbo="";
    this.dateYearToCbo_R=SIUtil.changeTo(lDateYearToCbo.trim(),this.encode);
  }
  
  //setter of 期間の月(To)
  public void setDateMonthToCbo_R(String lDateMonthToCbo){
    if (SIUtil.isNull(lDateMonthToCbo)) lDateMonthToCbo="";
    this.dateMonthToCbo_R=SIUtil.changeTo(lDateMonthToCbo.trim(),this.encode);
  }
  
  //setter of 期間の日(To)
  public void setDateDayToCbo_R(String lDateDayToCbo){
    if (SIUtil.isNull(lDateDayToCbo)) lDateDayToCbo="";
    this.dateDayToCbo_R=SIUtil.changeTo(lDateDayToCbo.trim(),this.encode);
  }
  
  //7.2.0 ST0546 追加 ここまで
  
  /*7.2.0 ST0546 削除 ここから
  //setter of 期間の間
  public void setDateBetweenCbo_R(String lDateBetweenCbo){
    if (SIUtil.isNull(lDateBetweenCbo)) lDateBetweenCbo="";
    this.dateBetweenCbo_R=SIUtil.changeTo(lDateBetweenCbo.trim(),this.encode);
  }
  
  //setter of 期間のフラグ
  public void setBetweenFlgCbo_R(String lBetweenFlgCbo){
    if (SIUtil.isNull(lBetweenFlgCbo)) lBetweenFlgCbo="";
    this.betweenFlgCbo_R=SIUtil.changeTo(lBetweenFlgCbo.trim(),this.encode);
  }7.2.0 ST0546 削除 ここまで*/
  
  //setter of 表示種別
  public void setDispFlgRdo_R(String lDispFlgRdo){
    if (SIUtil.isNull(lDispFlgRdo)) lDispFlgRdo="1";
    this.dispFlgRdo_R=SIUtil.changeTo(lDispFlgRdo.trim(),this.encode);
  }
  
  //setter of 検索条件エラーフラグ
  public void setError(boolean Error){
    this.error=Error;
  }
  
  //setter of アクセス数Total
  public void setTotalAccess(String lTotalAccess){
    if (SIUtil.isNull(lTotalAccess)) lTotalAccess="0";
    this.totalAccess=SIUtil.changeTo(lTotalAccess.trim(),this.encode);
  }
  
  //getter of 期間の年(From)
  public String getDateYearFromCbo(){
    return this.dateYearFromCbo;
  }
  
  //getter of 期間の月(From)
  public String getDateMonthFromCbo(){
    return this.dateMonthFromCbo;
  }
  
  //getter of 期間の日(From)
  public String getDateDayFromCbo(){
    return this.dateDayFromCbo;
  }
  
  //getter of 期間(From)
  public String getDateFrom(){
    return SIDateTime.getDate(getDateYearFromCbo(),getDateMonthFromCbo(),getDateDayFromCbo());
  }
  
  //getter of 期間の年(To)
  public String getDateYearToCbo(){
    return this.dateYearToCbo;
  }
  
  //getter of 期間の月(To)
  public String getDateMonthToCbo(){
    return this.dateMonthToCbo;
  }
  
  //getter of 期間の日(To)
  public String getDateDayToCbo(){
    return this.dateDayToCbo;
  }
  
  //getter of 期間(To)
  public String getDateTo(){
    return SIDateTime.getDate(getDateYearToCbo(),getDateMonthToCbo(),getDateDayToCbo());
  }
  
  /*7.2.0 ST0546 削除 ここから
  //getter of 期間の間
  public String getDateBetweenCbo(){
    return this.dateBetweenCbo;
  }
  
  //getter of 期間のフラグ
  public String getBetweenFlgCbo(){
    return this.betweenFlgCbo;
  }
  7.2.0 ST0546 削除 ここまで*/
  
  //getter of 表示種別
  public String getDispFlgRdo(){
    return this.dispFlgRdo;
  }
  
  //getter of 期間の年(From)
  public String getDateYearFromCbo_R(){
    return this.dateYearFromCbo_R;
  }
  
  //getter of 期間の月(From)
  public String getDateMonthFromCbo_R(){
    return this.dateMonthFromCbo_R;
  }
  
  //getter of 期間の日(From)
  public String getDateDayFromCbo_R(){
    return this.dateDayFromCbo_R;
  }
  
  //getter of 期間(From)
  public String getDateFrom_R(){
    return SIDateTime.getDate(getDateYearFromCbo_R(),getDateMonthFromCbo_R(),getDateDayFromCbo_R());
  }
  
  //7.2.0 ST0546 追加 ここから
  //getter of 期間の年(To)
  public String getDateYearToCbo_R(){
    return this.dateYearToCbo_R;
  }
  
  //getter of 期間の月(To)
  public String getDateMonthToCbo_R(){
    return this.dateMonthToCbo_R;
  }
  
  //getter of 期間の日(To)
  public String getDateDayToCbo_R(){
    return this.dateDayToCbo_R;
  }
  
  //getter of 期間(To)
  public String getDateTo_R(){
    return SIDateTime.getDate(getDateYearToCbo_R(),getDateMonthToCbo_R(),getDateDayToCbo_R());
  }
  
  //7.2.0 ST0546 追加 ここまで
  
  /*7.2.0 ST0546 削除 ここから
  //getter of 期間の間
  public String getDateBetweenCbo_R(){
    return this.dateBetweenCbo_R;
  }
  
  //getter of 期間のフラグ
  public String getBetweenFlgCbo_R(){
    return this.betweenFlgCbo_R;
  }
  7.2.0 ST0546 削除 ここまで*/
  
  //getter of 表示種別
  public String getDispFlgRdo_R(){
    return this.dispFlgRdo_R;
  }
  //getter of 検索条件エラーフラグ
  public boolean getError(){
    return this.error;
  }
  
  //getter of アクセス数Total
  public String getTotalAccess(){
    return this.totalAccess;
  }
  
  /**
   * <b>init</b>
   * 入力したデータを基づいて、このbeansを設定します。
   * @param request クライアントからリクエスト
   * @param lUrlParam
   * @return なし
   * @throws なし
   */
  public void init(HttpServletRequest lRequest,SIURLParameter lUrlParam){//7.1.1 ST0236 修正
    //7.1.1 ST0236 修正 ここから
    super.init(lRequest,lUrlParam);
    this.setEncode(SIConfig.SIENCODE_SHIFT_JIS);
    this.setActionNameTxt((String)lUrlParam.getParam("actionNameTxt"));       //アクション
    
    //this.setDateBetweenCbo((String)lUrlParam.getParam("dateBetweenCbo"));   //期間の間 //7.2.0 ST0546 削除
    //this.setBetweenFlgCbo((String)lUrlParam.getParam("betweenFlgCbo"));     //期間のフラグ 7.2.0 ST0546 削除
    this.setDispFlgRdo((String)lUrlParam.getParam("dispFlgRdo"));             //表示種別
    this.setDateYearFromCbo((String)lUrlParam.getParam("dateYearFromCbo"));   //期間の年(From)
    this.setDateMonthFromCbo((String)lUrlParam.getParam("dateMonthFromCbo")); //期間の月(From)
    this.setDateDayFromCbo((String)lUrlParam.getParam("dateDayFromCbo"));     //期間の日(From)
    //7.1.1 ST0236 修正 ここまで
    this.setDateYearToCbo((String)lUrlParam.getParam("dateYearToCbo"));       //期間の年(To)
    this.setDateMonthToCbo((String)lUrlParam.getParam("dateMonthToCbo"));     //期間の月(To)
    this.setDateDayToCbo((String)lUrlParam.getParam("dateDayToCbo"));         //期間の日(To)
    
    //7.2.0 ST0546 追加 ここから
    //Fromの日やToの年月日など、自動でセットする
    
    //月別のとき
    if(this.getDispFlgRdo().equalsIgnoreCase("2")){
      //年が入力されていたら月セット
      if(SIUtil.isNotNull(this.getDateYearFromCbo())) this.setDateMonthFromCbo("01");
      if(SIUtil.isNotNull(this.getDateYearToCbo()))   this.setDateMonthToCbo("12");
    }
    
    //時間帯別のとき
    if(this.getDispFlgRdo().equalsIgnoreCase("1")){
      if(SIUtil.isNotNull(this.getDateYearFromCbo()) && SIUtil.isNotNull(this.getDateMonthFromCbo())){
        //一週間後の日付を取得
        SIDateTime dateTo = null;
        SimpleDateFormat sdf=new SimpleDateFormat(SIConfig.SIDATE_FORMAT);
        sdf.setLenient(false);
        try{
          dateTo = new SIDateTime(sdf.parse(this.getDateFrom()));
          dateTo.addDay(6);
          this.setDateYearToCbo(dateTo.getYearStr());    //期間の年(To)
          this.setDateMonthToCbo(dateTo.getMonthStr());  //期間の月(To)
          this.setDateDayToCbo(dateTo.getDayStr());      //期間の日(To)
        }catch(Exception e){
          //Fromにエラーがあった場合は、Toに今日の日付をセット
          SIDateTime today = new SIDateTime();
          this.setDateYearToCbo(today.getYearStr());     //期間の年(To)
          this.setDateMonthToCbo(today.getMonthStr());   //期間の月(To)
          this.setDateDayToCbo(today.getDayStr());       //期間の日(To) 
        }
      }
    //時間帯別以外のとき
    }else{
      //年、月が入力されていたら、日（月初）をセット
      if(SIUtil.isNotNull(this.getDateYearFromCbo()) && SIUtil.isNotNull(this.getDateMonthFromCbo())){
        this.setDateDayFromCbo("01");
      }
      //年、月が入力されていたら、日（月末）をセット
      if(SIUtil.isNotNull(this.getDateYearToCbo()) && SIUtil.isNotNull(this.getDateMonthToCbo())){
        Calendar dateTo = new GregorianCalendar(Integer.parseInt(this.getDateYearToCbo()), Integer.parseInt(this.getDateMonthToCbo())-1, 1); 
        this.setDateDayToCbo(String.valueOf(dateTo.getActualMaximum(Calendar.DAY_OF_MONTH)));
      }
    }
    //7.2.0 ST0546 追加 ここまで
    this.setDispFlgRdo_R(this.getDispFlgRdo());             //表示種別
    //this.setBetweenFlgCbo_R(this.getBetweenFlgCbo());     //期間のフラグ //7.2.0 ST0546 削除
    //this.setDateBetweenCbo_R(this.getDateBetweenCbo());   //期間の間 //7.2.0 ST0546 削除
    this.setDateYearFromCbo_R(this.getDateYearFromCbo());   //期間の年(From)
    this.setDateMonthFromCbo_R(this.getDateMonthFromCbo()); //期間の月(From)
    this.setDateDayFromCbo_R(this.getDateDayFromCbo());     //期間の日(From)
    this.setDateYearToCbo_R(this.getDateYearToCbo());       //期間の年(To)
    this.setDateMonthToCbo_R(this.getDateMonthToCbo());     //期間の月(To)
    this.setDateDayToCbo_R(this.getDateDayToCbo());         //期間の日(To)
  }
  
  /**
   * <b>initRefresh</b>
   * 入力したデータを基づいて、このbeansを設定します。
   * @param request クライアントからリクエスト
   * @param lUrlParam
   * @return なし
   * @throws なし
   */
  
  public void initRefresh(HttpServletRequest lRequest,SIURLParameter lUrlParam){//7.1.1 ST0236 修正
    //7.1.1 ST0236 修正 ここから
    super.init(lRequest,lUrlParam);
    this.setEncode(SIConfig.SIENCODE_SHIFT_JIS);
    this.setDateYearFromCbo_R((String)lUrlParam.getParam("dateYearFromCbo"));//期間の年(From)
    this.setDateMonthFromCbo_R((String)lUrlParam.getParam("dateMonthFromCbo"));//期間の月(From)
    this.setDateDayFromCbo_R((String)lUrlParam.getParam("dateDayFromCbo"));//期間の日(From)  
    //this.setDateBetweenCbo_R((String)lUrlParam.getParam("dateBetweenCbo"));//期間の間 //7.2.0 ST0546 削除
    //this.setBetweenFlgCbo_R((String)lUrlParam.getParam("betweenFlgCbo"));//期間のフラグ//7.2.0 ST0546 削除
    this.setDispFlgRdo_R((String)lUrlParam.getParam("dispFlgRdo"));//表示種別
    this.setActionNameTxt((String)lUrlParam.getParam("actionNameTxt"));//アクション
    //7.1.1 ST0236 修正 ここまで
    
    //7.2.0 ST0546 追加 ここから
    this.setDateYearToCbo_R((String)lUrlParam.getParam("dateYearToCbo"));    //期間の年(To)
    this.setDateMonthToCbo_R((String)lUrlParam.getParam("dateMonthToCbo"));  //期間の月(To)
    this.setDateDayToCbo_R((String)lUrlParam.getParam("dateDayToCbo"));      //期間の日(To)
    
    //未入力のときは今月をセット
    SIDateTime today = new SIDateTime();
    if(SIUtil.isNull(this.getDateYearFromCbo_R()))  this.setDateYearFromCbo_R(today.getYearStr());    //期間の年(From)
    if(SIUtil.isNull(this.getDateMonthFromCbo_R())) this.setDateMonthFromCbo_R(today.getMonthStr());  //期間の月(From)
    if(SIUtil.isNull(this.getDateDayFromCbo_R()))   this.setDateDayFromCbo_R("01");                   //期間の日(From)
    
    if(SIUtil.isNull(this.getDateYearToCbo_R()))    this.setDateYearToCbo_R(today.getYearStr());      //期間の年(To)
    if(SIUtil.isNull(this.getDateMonthToCbo_R()))   this.setDateMonthToCbo_R(today.getMonthStr());    //期間の月(To)
    if(SIUtil.isNull(this.getDateDayToCbo_R()))     this.setDateDayToCbo_R(today.getDayStr());        //期間の日(To)
    
    //時間帯別のときは一週間前の日をセット
    if(this.getDispFlgRdo().equals("1")){
      today.addDay(-6);
      this.setDateDayFromCbo_R(today.getDayStr());
    }
    //7.2.0 ST0546 追加 ここまで
  }
  
  /**
   * <b>getCollection</b>
   * 条件に合ったレコードを検索して、結果のコネクションを作成して、戻します。
   * @param lConnection データベースへの接続コネクション
   * @return レコードのセット
   * @throws なし
   */
  public Collection getCollection(Connection lConnection) throws SIDBAccessException{
    //検索条件でエラーがあったときは検索をしない
    if(this.getError()){
      return new ArrayList();
    }
    
    Statement lStatement=null;
    ResultSet lResultSet=null;
    SIAccesslog lBasic=new SIAccesslog();
    StringBuffer lSqlBuf = new StringBuffer();//7.2.0 ST0546 修正
    
    //7.2.0 ST0546 追加 ここから
    HashMap lMap = new HashMap();
    String groupUnit1 = ""; //集計単位 
    String groupUnit2 = ""; //集計単位 
    StringBuffer whereBuf = new StringBuffer();
    //7.2.0 ST0546 追加 ここまで
    
    Collection lResultColl=new ArrayList();
    
    //7.2.0 ST0546 修正・追加 ここから
    //SELECT句を作成
    //月別のとき
    if(this.getDispFlgRdo().equals("2")){
      if (SIDBMultiConf.SIDB_CURRENT_INX ==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        groupUnit1 = "SUBSTRING(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,7)";
      }else{
        groupUnit1 = "SUBSTR(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,7)";
      }
    //曜日別のとき
    }else if(this.getDispFlgRdo().equals("3")){
      if (SIDBMultiConf.SIDB_CURRENT_INX ==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        groupUnit1 = "SUBSTRING(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,7)";//yyyy/MM/
        groupUnit2 = "EXTRACT(DOW FROM AccessDateTime)";                              //曜日(0:日,1:月,2：火,)
      }else{
        groupUnit1 = "SUBSTR(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,7) ";
        groupUnit2 = "TO_CHAR(AccessDateTime,'D') -1 ";
      }
    //日別のとき
    }else if(this.getDispFlgRdo().equals("0")){
      if (SIDBMultiConf.SIDB_CURRENT_INX ==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        groupUnit1 = "DATE(AccessDateTime)";
      }else{
        groupUnit1 = "TO_CHAR(AccessDateTime,'YYYY/MM/DD')";
      }
    //時間帯別のとき
    }else if(this.getDispFlgRdo().equals("1")){
      if (SIDBMultiConf.SIDB_CURRENT_INX ==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        groupUnit1 = "SUBSTRING(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),12,2)";//hh (ソート用)
        groupUnit2 = "SUBSTRING(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,13)";//yyyy/MM/dd hh
      }else{
        groupUnit1 = "SUBSTR(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),12,2) ";
        groupUnit2 = "SUBSTR(TO_CHAR(AccessDateTime,'YYYY/MM/DD HH24:MI:SS'),1,13)";
      }
    }
    
    //WHERE句を作成
    whereBuf.append(" 1=1 ");
    if (SIDBMultiConf.SIDB_CURRENT_INX==SIDBMultiConf.SIDB_POSTGRESQL_INX){
      if(SIUtil.isNotNull(this.getDateFrom())){
        whereBuf.append("AND AccessDateTime >= ").append(SIDBUtil.SQL2Str(this.getDateFrom(),""));
      }
      if(SIUtil.isNotNull(this.getDateTo())){
        whereBuf.append("AND AccessDateTime <= ").append(SIDBUtil.SQL2Str(this.getDateTo()+" 23:59:59",""));//7.2.0 ST0546 修正
      }
    }else{
      if(SIUtil.isNotNull(this.getDateFrom())){
        whereBuf.append("AND AccessDateTime >= ").append(new SIDateType(this.getDateFrom()).getValue()).append(" ");
      }
      if(SIUtil.isNotNull(this.getDateTo())){
        whereBuf.append("AND AccessDateTime <= ").append(new SIDateTimeType(this.getDateTo()+" 23:59:59").getValue()).append(" ");//7.2.0 ST0546 修正
      }
    }
    
    //SQL文を作成
    //月別と日別のとき
    if(this.getDispFlgRdo().equals("2")||this.getDispFlgRdo().equals("0")){
      lSqlBuf.append("SELECT ").append(groupUnit1).append(" AS AccessDate , COUNT(*) AS Count ");
      lSqlBuf.append(" FROM AccessLogTbl");
      lSqlBuf.append(" WHERE ").append(whereBuf);
      lSqlBuf.append(" GROUP BY ").append(groupUnit1).append(" ORDER BY AccessDate ");
    //曜日別のとき
    }else if(this.getDispFlgRdo().equals("3")){
      lSqlBuf.append("SELECT ").append(groupUnit1).append(" AS AccessDate ,").append(groupUnit2).append(" AS AccessDayOfWeek , COUNT(*) AS Count ");
      lSqlBuf.append(" FROM AccessLogTbl ");
      lSqlBuf.append(" WHERE ").append(whereBuf);
      lSqlBuf.append(" GROUP BY ").append(groupUnit1).append(" ,").append(groupUnit2);
      lSqlBuf.append(" ORDER BY AccessDate ,AccessDayOfWeek ");    
    //時間帯別のとき
    }else if(this.getDispFlgRdo().equals("1")){
      lSqlBuf.append("SELECT ").append(groupUnit1).append(" AS AccessTime ,").append(groupUnit2).append(" AS AccessDateTime , COUNT(*) AS Count ");
      lSqlBuf.append(" FROM AccessLogTbl ");
      lSqlBuf.append(" WHERE ").append(whereBuf);
      lSqlBuf.append(" GROUP BY ").append(groupUnit1).append(" ,").append(groupUnit2);
      lSqlBuf.append(" ORDER BY AccessTime,AccessDateTime ");    
    }
    
    log.debug("lSqlBuf="+lSqlBuf.toString());
    //7.2.0 ST0546 修正・追加 ここまで
    
    //実行
    try{
      lStatement=lConnection.createStatement();
      lResultSet=lStatement.executeQuery(lSqlBuf.toString());//7.2.0 ST0546 修正
      long totalAccess = 0;
      
      //商品レコードのセットの作成
      //月別と日別のとき
      if(this.getDispFlgRdo().equals("2")||this.getDispFlgRdo().equals("0")){ //7.2.0 ST0546 追加
        while (lResultSet.next()){
          lBasic=new SIAccesslog();
          lBasic.setEncode(SIConfig.SIENCODE_NONE);
          //日別
          if(this.getDispFlgRdo().equals("0")){
            if (SIDBMultiConf.SIDB_CURRENT_INX ==SIDBMultiConf.SIDB_POSTGRESQL_INX){
              lBasic.setDate(SIDBUtil.getDate(lResultSet.getTimestamp("AccessDate")));//年／月／日
            }else{
              lBasic.setDate(lResultSet.getString("AccessDate"));//年／月／日
            }
          /*7.2.0 ST0546 削除 ここから
          }else if(this.getDispFlgRdo().equals("1")){
            Basic.setTime(lResultSet.getString("AccessTime"));//時間帯
          7.2.0 ST0546 削除 ここまで*/
          //月別
          //7.2.0 ST0546 修正 ここから
          }else if(this.getDispFlgRdo().equals("2")){
            lBasic.setMonth(lResultSet.getString("AccessDate").substring(5,7));//月
            lBasic.setYear(lResultSet.getString("AccessDate").substring(0,4));//年
          }
          //7.2.0 ST0546 修正 ここまで
          lBasic.setCount(lResultSet.getString("Count"));//アクセス数
          totalAccess = totalAccess + Long.parseLong(lBasic.getCount());//アクセス数Total
          lResultColl.add(lBasic);
        }
        this.setTotalAccess(Long.toString(totalAccess));
        
        //不足データを補う
        lResultColl = this.insertData(lResultColl);
        
        //7.2.0 ST0546 追加 ここから
        //不足データを補いながら、Collectionを作成
        
        //曜日別のとき
      }else if(this.getDispFlgRdo().equals("3")){
        SIAccesslog access = new SIAccesslog();
        int    rowInx = 0;//行番号（From月からの経過月数）
        long   colSum = 0;
        long[] rowSum = {0,0,0,0,0,0,0,0}; //7日＋総合計
        boolean nextExitFlg = true;
        
        //日付を用意
        SimpleDateFormat sdf = new SimpleDateFormat(SIConfig.SIDATE_FORMAT);
        SIDateTime day       = new SIDateTime(sdf.parse(this.getDateFrom()));
        SIDateTime to        = new SIDateTime(sdf.parse(this.getDateTo()));
        to.addMonth(1);
        
        //表示用のCollectionを作る
        nextExitFlg = lResultSet.next();
        while(day.getDateObject().before(to.getDateObject())){
          //初期化
          colSum = 0;
          int dayOfWeek=0;
          access  = new SIAccesslog();
          
          //土曜日までループ
          for(dayOfWeek=0;dayOfWeek<8;dayOfWeek++){
            //縦合計の配列を作成
            if(day.getYear()==to.getYear() && day.getMonth()==to.getMonth()){
              access.setWeekCount(dayOfWeek,rowSum[dayOfWeek]);
            //レコードの値がループと一致したら、レコードのアクセス数をセット
            }else if(
             nextExitFlg
             && lResultSet.getString("AccessDate").equals(day.getYearStr()+"/"+day.getMonthStr())
             && lResultSet.getInt("AccessDayOfWeek") == dayOfWeek){
              access.setWeekCount(dayOfWeek,lResultSet.getLong("Count"));
              //合計を計算
              colSum            += lResultSet.getLong("Count");
              rowSum[dayOfWeek] += lResultSet.getLong("Count");
              nextExitFlg=lResultSet.next();
            //レコードになければアクセス数は0をセット
            }else{
              access.setWeekCount(dayOfWeek,0);
            }
          }
          
          //合計をセット
          if(day.getYear()!=to.getYear() || day.getMonth()!=to.getMonth()){
            access.setWeekCount(7,colSum);//月計
            access.setDate(day.getYearStr()+"/"+day.getMonthStr());
          }else{
            access.setWeekCount(7,rowSum[7]);//総合計
            access.setDate("合計");
            this.setTotalAccess(String.valueOf(rowSum[7]));
          }
          
          //一ヶ月分の集計データをコレクションに入れる
          lResultColl.add(access);
          rowSum[7] += colSum;
          day.addMonth(1);
        }
      //時間帯別
      }else if(this.getDispFlgRdo().equals("1")){
        SIAccesslog access = new SIAccesslog();
        int    rowInx = 0;//列番号（Fromからの経過日数）
        long   colSum = 0;
        long[] rowSum = {0,0,0,0,0,0,0,0}; //7日＋総合計
        boolean nextExitFlg = true;
        
        //日付を用意
        SimpleDateFormat sdf = new SimpleDateFormat(SIConfig.SIDATE_FORMAT);
        SIDateTime day       = new SIDateTime(sdf.parse(this.getDateFrom()));
        SIDateTime to        = new SIDateTime(sdf.parse(this.getDateTo()));
        to.addDay(1);
        
        //表示用のCollectionを作る
        nextExitFlg = lResultSet.next();
        for(int hour=0;hour<25;hour++){
          //初期化
          colSum = 0;
          rowInx  = 0;
          day     = new SIDateTime(sdf.parse(this.getDateFrom()));
          access  = new SIAccesslog();
          
          //Toの日付までループ
          while(day.getDateObject().before(to.getDateObject())){
            //縦合計の配列を作成
            if(hour==24){
              access.setWeekCount(rowInx,rowSum[rowInx]);
              //レコードの値がループと一致したら、レコードのアクセス数をセット
            }else if(nextExitFlg && lResultSet.getString("AccessDateTime").equals(day.getFullDate()+" "+SIUtil.lFillIn(hour,2))){
              access.setWeekCount(rowInx,lResultSet.getLong("Count"));
              //合計を計算  
              colSum         += lResultSet.getLong("Count");
              rowSum[rowInx] += lResultSet.getLong("Count");
              nextExitFlg=lResultSet.next();
              //レコードになければアクセス数は0をセット
            }else{
              access.setWeekCount(rowInx,0);
            }
            
            day.addDay(1);
            rowInx++;
          }
          
          //合計をセット
          if(hour<24){
            access.setWeekCount(rowInx,colSum);//時間合計
            access.setTime(SIUtil.lFillIn(hour,2));
          }else{
            access.setWeekCount(rowInx,rowSum[rowInx]);//総合計
            access.setTime("合計");
            this.setTotalAccess(String.valueOf(rowSum[rowInx]));
          }
          
          //1時間分の集計データをコレクションに入れる
          lResultColl.add(access);
          
          rowSum[rowInx] += colSum;
        }
      }
      //7.2.0 ST0546 追加 ここまで
    }catch(Exception ex){
      throw new SIDBAccessException(ex);
    }finally{
      SIDBUtil.close(lResultSet,lStatement);
    }
    return lResultColl;
  }
  
  /**
   * <b>validate</b>
   * 入力したデータをチェック
   * @param lRequest クライアントからのリクエスト
   * @return なし
   * @throws なし
   */
  public boolean validate(HttpServletRequest lRequest){
    SICustomErrors errors=new SICustomErrors();
    
    //7.2.0 ST0546 修正 ここから
    SICheckValid.checkValid(errors,"期間From",getDateFrom(),SICheckDataConf.SICHECK_DATA_EMPTY_TYPE+SICheckDataConf.SICHECK_DATA_DATE_TYPE);
    
    //Toのチェックは時間帯別以外のとき
    if(!this.getDispFlgRdo().equals("1")){
      SICheckValid.checkValid(errors,"期間To",getDateTo(),SICheckDataConf.SICHECK_DATA_EMPTY_TYPE+SICheckDataConf.SICHECK_DATA_DATE_TYPE);
    }
    
    if(errors.isEmpty()){
      SICheckValid.checkValid(errors,"期間From","期間To",this.getDateFrom(),this.getDateTo(),SICheckDataConf.SICHECK_DATA_DATE_LESS_TYPE);
    }
    //7.2.0 ST0546 修正 ここまで
    
    if (!errors.isEmpty()){
      lRequest.setAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY,errors);
      this.setError(true);
    }else{
      lRequest.removeAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY);
      this.setError(false);
    }
    return errors.isEmpty();
  }
  
  /**
   * <b>insertData</b>
   * 検索した結果の足りない日付(時間)を入れる
   * @param lRequest クライアントからのリクエスト
   * @return なし
   * @throws なし
   */
  public Collection insertData(Collection result){
    Iterator iterator = result.iterator();
    Collection coll = new ArrayList();
    SIAccesslog ins = new SIAccesslog();
    SimpleDateFormat sdf=new SimpleDateFormat(SIConfig.SIDATE_FORMAT);
    sdf.setLenient(false);
    
    SIDateTime current = null;
    SIDateTime to = null;
    SIDateTime db = null;
    if(SIUtil.isNotNull(this.getDateFrom())){
      try{
        current = new SIDateTime(sdf.parse(this.getDateFrom()));
      }catch(Exception e){
        current = null;
      }
    }
    if(SIUtil.isNotNull(this.getDateTo())){
      try{
        to = new SIDateTime(sdf.parse(this.getDateTo()));
      }catch(Exception e){
        to = null;
      }
    }
    
    //表示するために足りない日付を加える（日別）
    if(this.getDispFlgRdo().equals("0")){
      if(to!=null)to.addDay(1);//7.2.0 ST0546 追加
      while(iterator.hasNext()){
        SIAccesslog access = (SIAccesslog)iterator.next();
        try{
          db = new SIDateTime(sdf.parse(access.getDate()));
          //期間Fromが設定されていないときは開始はDBの最初の日付
          if(current==null){
            current = new SIDateTime(sdf.parse(access.getDate()));
          }
        }catch(Exception e){}
        while(current.getDateObject().before(db.getDateObject())){
          ins = new SIAccesslog();
          ins.setDate(current.getFullDate());
          ins.setCount("0");
          coll.add(ins);
          current.addDay(1);
        }
        coll.add(access);
        current.addDay(1);
      }
      //期間Toが設定されていないときは終了はDBの最後の日付
      if(to != null && current.getDateObject().before(to.getDateObject())){
        while(current.getDateObject().before(to.getDateObject())){
          ins = new SIAccesslog();
          ins.setDate(current.getFullDate());
          ins.setCount("0");
          coll.add(ins);
          current.addDay(1);
        }
      }
      /* 7.2.0 ST546 削除 ここから
      //表示するために足りない時間を加える（時間帯別）
      }else if(this.getDispFlgRdo().equals("1")){
        int currentTime = 0;
        while(iterator.hasNext()){
        SIAccesslog access = (SIAccesslog)iterator.next();
        while(currentTime < Integer.parseInt(access.getTime())){
          ins = new SIAccesslog();
          ins.setTime(SIUtil.lFillIn(currentTime,2));
          ins.setCount("0");
          coll.add(ins);
          currentTime++;
        }
        coll.add(access);
        currentTime++;
      }
      if(currentTime<24){
        while(currentTime<24){
          ins = new SIAccesslog();
          ins.setTime(SIUtil.lFillIn(currentTime,2));
          ins.setCount("0");
          coll.add(ins);
          currentTime++;
        }
      }
    7.2.0 ST546 削除 ここまで
    */
    //7.2.0 ST0546 追加 ここから
    //表示するために足りない月を加える（月別）
    }else if(this.getDispFlgRdo().equals("2")){
      while(iterator.hasNext()){
        SIAccesslog access = (SIAccesslog)iterator.next();
        try{
          db = new SIDateTime(sdf.parse(access.getYearMonth()));
          //期間Fromが設定されていないときは開始はDBの最初の日付
          if(current==null){
            current = new SIDateTime(sdf.parse(access.getYearMonth()));
          }
        }catch(Exception e){}
        while(current.getDateObject().before(db.getDateObject())){
          ins = new SIAccesslog();
          ins.setYear(current.getYearStr());
          ins.setMonth(SIUtil.lFillIn(current.getMonth(),2));
          ins.setCount("0");
          coll.add(ins);
          current.addMonth(1);
        }
        coll.add(access);
        current.addMonth(1);
      }
    //期間Toが設定されていないときは終了はDBの最後の日付
      if(to != null && current.getDateObject().before(to.getDateObject())){
        while(current.getDateObject().before(to.getDateObject())){
          ins = new SIAccesslog();
          ins.setYear(current.getYearStr());
          ins.setMonth(SIUtil.lFillIn(current.getMonth(),2));
          ins.setCount("0");
          coll.add(ins);
          current.addMonth(1);
        }
      }
    }
    //7.2.0 ST0546 追加 ここまで
    return coll;
  }
  
  /*7.2.0 ST0546 削除 ここから
  public static Collection getBetweenColl(){
    Collection lResultColl = new ArrayList();
    lResultColl.add(new SINameValue("日間", "0"));
    lResultColl.add(new SINameValue("ヶ月間", "1"));
    return lResultColl;
  }
  7.2.0 ST0546 削除 ここまで
  */
}