Package com.narirelays.ems.persistence.orm

Examples of com.narirelays.ems.persistence.orm.MonthReport


    String queryStyle = null;
    if(queryStyleObj==null)//如果前台不传刷新与否,默认不刷新
      queryStyle = "unrefresh";
    else queryStyle = stringValue(queryStyleObj);
    DayReport dayReport = null;
    MonthReport monthReport = null;
    YearReport yearReport = null;
    OtherReport otherReport = null;

    //不是以刷新方式查询,则优先查找报表库***_report中是否有
    //如有,则直接返回      
    String reportType = template.getReportType();
    if(reportType==null||reportType.equals(""))
    {
      reportType="other";//默认以other处理
    }
    if(reportType.equalsIgnoreCase("day"))//日报表
    {
      DayReportId reportID = new DayReportId(template.getId(),new Timestamp(queryDatePar.getTime()));
      dayReport = dayReportDAO.findById(reportID);
      if(dayReport!=null&&!queryStyle.equalsIgnoreCase("refresh"))//说明在报表库中找到了该报表,直接返回
      {
        //不是刷新模式,则直接返回离线库中的值
        bean.set("code", dayReport.getCode());
        result.setData(bean);
        result.setSucceed();
        return result;
      }
    }
    else if(reportType.equalsIgnoreCase("month"))//月报表
    {
      SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM");
      try {
        String mDateString = sdfm.format(queryDatePar);
        Date mDate = sdfm.parse(mDateString);//得到的日期是yyyy-MM-1
        MonthReportId reportID = new MonthReportId(template.getId(), new Timestamp(mDate.getTime()));
        monthReport = monthReportDAO.findById(reportID);
        if(monthReport!=null&&!queryStyle.equalsIgnoreCase("refresh"))
        {
          //不是刷新模式,则直接返回离线库中的值
          bean.set("code", monthReport.getCode());
          result.setData(bean);
          result.setSucceed();
          return result;
        }
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        result.setFailed("Time Format Error!");
        return result;
      }
    }
    else if(reportType.equalsIgnoreCase("year"))//年报表
    {
      SimpleDateFormat sdfy = new SimpleDateFormat("yyyy");//得到的日期是yyyy-1-1
      try {
        String yDateString = sdfy.format(queryDatePar);
        Date yDate = sdfy.parse(stringValue(yDateString));
        YearReportId reportID = new YearReportId(template.getId(), new Timestamp(yDate.getTime()));
        yearReport = yearReportDAO.findById(reportID);
        if(yearReport!=null&&!queryStyle.equalsIgnoreCase("refresh"))
        {
          //不是刷新模式,则直接返回离线库中的值
          bean.set("code", yearReport.getCode());
          result.setData(bean);
          result.setSucceed();
          return result;
        }
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        result.setFailed("Time Format Error!");
        return result;
      }       
    }
    else //其它类型(other)的报表
    {
      otherReport = otherReportDAO.findById(templateID);
      if(otherReport!=null&&!queryStyle.equalsIgnoreCase("refresh"))
      {
        bean.set("code", otherReport.getCode());
        result.setData(bean);
        result.setSucceed();
        return result;
      }
    }
   
    //通过模板中所有单元格的查询条件,查询数据并组织报表    
    String code = getReport(template, queryDatePar);
    if(code!=null)
    {
      bean.set("code", code);
      //以下用来更新离线库
      if(reportType.equalsIgnoreCase("other"))
      {
        //其它类型报表,在此处需要更新离线库
        //如果离线库中报表存在,则直接覆盖;否则新建报表后覆盖
        if(otherReport==null)
        {
          otherReport = new OtherReport(templateID);
        }
        otherReport.setCode(code);
        otherReport.setUpdateTime(new Timestamp(new Date().getTime()));
        otherReportDAO.merge(otherReport);
      }
      else
      {
        //报表类型为年月日,如果报表存在离线库中,则更新;
        //否则,不操作,等待定时任务写离线报表库
        if(dayReport!=null)
        {
          //此时,肯定是刷新模式,否则在查询离线库时变返回了
          //刷新模式,查到数据后,如果离线报表已存在,需要更新离线报表库
          dayReport.setCode(code);
          dayReport.setUpdateTime(new Timestamp(new Date().getTime()));
          dayReportDAO.merge(dayReport);
        }
        else if(monthReport!=null)
        {
          monthReport.setCode(code);
          monthReport.setUpdateTime(new Timestamp(new Date().getTime()));
          monthReportDAO.merge(monthReport);
        }
        else if(yearReport!=null)
        {
          yearReport.setCode(code);
View Full Code Here


    Date timeStamp = new Date();
    for(ReportTemplate template:templates)
    {
      String code = getReport(template, date);//实例化报表
      MonthReportId ID = new MonthReportId(template.getId(), new Timestamp(date.getTime()));
      MonthReport monthReport = new MonthReport(ID);
      monthReport.setCode(code);
      monthReport.setUpdateTime(new Timestamp(timeStamp.getTime()));
      monthReportDAO.merge(monthReport);
    }
    return true;   
  }
View Full Code Here

TOP

Related Classes of com.narirelays.ems.persistence.orm.MonthReport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.