Пример #1
0
 /* ***************************************************************
  Added by   :Sandhya Pochareddy
  Reason     :NeWSIS :: Error In AP Newsis
  Incident no:INC000000467784
  Date       : 06-11-2012
 ***************************************************************/
 public void updateReport(Long reportCode, Long orgCode, Long userId, String countryCode)
     throws Exception {
   String strHql =
       "update td_backgrounder_report set report_Status='complete' where report_Status='running' and report_code="
           + reportCode
           + " and create_by="
           + userId
           + " and organization_code="
           + orgCode;
   String[] batchSql = new String[1];
   batchSql[0] = strHql;
   ReportExecutor re = (ReportExecutor) SpringContextUtil.getBean("reportExecutor" + countryCode);
   re.updateBgTable(batchSql);
 }
Пример #2
0
    /** Start threads */
    public void run() {
      //			ReportExecutor re = (ReportExecutor)SpringContextUtil.getBean("reportExecutor");
      // Add multi-country by XT
      ReportExecutor re =
          (ReportExecutor) SpringContextUtil.getBean("reportExecutor" + countryCode);

      try {
        if (this.reportCode == REPAIRALREADY) { // 已修复清单
          RepairAlreadyModel model = new RepairAlreadyModel();
          model.setParam((String[]) sqlCondition);
          re.setInCoding("UTF-16LE");
          fileName = re.reportFile(model, countryCode);

        } else if (this.reportCode == SENDREPAIR) { // 已发机清单
          DeliveriedListModel model = new DeliveriedListModel();
          model.setParam((String[]) sqlCondition);
          re.setInCoding("UTF-16LE");
          fileName = re.reportFile(model, countryCode);

        } else if (this.reportCode == CR90) { // CR90 报表
          Cr90Model model = new Cr90Model();
          model.setParam((HttpServletRequest) sqlCondition);
          re.setInCoding("UTF-16LE");
          fileName = re.reportFile(model, countryCode);

        } else if (this.reportCode == NOTSENDREPAIR) { // 未发机清单
          // fileName=notSendRepairReport.createTxtFileT((String[])sqlCondition);
        }

        if (fileName == null) {
          throw new Exception("create report Exception,please contact the system administrator");
        }

      } catch (ReportException erp) {
        errInfo = erp.getMessage();
      } catch (Exception e) {
        errInfo = e.getMessage();
        e.printStackTrace();
      } finally {
        try {
          // 更新DB
          if (fileName == null) fileName = "";
          if (errInfo != null && errInfo.indexOf("'") != -1)
            errInfo = errInfo.replaceAll("'", "\"");
          ReportBackgroundBo.updateBgTable(bgId, fileName, errInfo, timeZone, countryCode);
        } catch (Exception er) {
          er.printStackTrace();

          //					try{
          //						//如果更新失败,发邮件提醒
          ////						APMailSender sender = new APMailSender();
          ////						String errMess=reportCode+":\r\n"+errInfo+"\r\n\r\n"+"
          // update:\r\n"+er.toString();
          ////
          ////						sender.send("BackgrounderReport_Exception:"+bgId, errMess, "*****@*****.**");
          //					}catch (Exception em){
          //						em.printStackTrace();
          //					}
        }
      }
    }
Пример #3
0
  /**
   * Update database after generation reports
   *
   * @param reportCode
   * @param reportFile
   * @throws Exception
   */
  public static void updateBgTable(
      Long bgId, String reportFile, String errInfo, double timeZone, String countryCode)
      throws Exception {
    Date date = new Date(System.currentTimeMillis() + (int) (timeZone * 60 * 60 * 1000));

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String endDate = "to_date('" + sdf.format(date) + "','yyyy-mm-dd hh24:mi:ss')";

    String elapsedTime = "(" + endDate + "-r.BEGIN_TIME)*24*3600";
    String status = "complete";
    if (errInfo != null) status = "exception";

    String[] batchSql = new String[2];
    String fileName = "";
    String sqlCondition = "";
    String writePath = Operate.getReportPath()[0];

    if (!"".equals(reportFile)) {
      try {
        fileName = reportFile.split(String.valueOf(CommonSearch.split1))[0];
        fileName = fileName.split("reports/")[1];
        sqlCondition = reportFile.split(String.valueOf(CommonSearch.split1))[1];
        sqlCondition = sqlCondition.replace("'", "’");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    String updBgReport =
        "update td_backgrounder_report r set r.REPORT_FILE='"
            + fileName
            + "',r.END_TIME="
            + endDate
            + ",r.REPORT_STATUS='"
            + status
            + "'";
    if (errInfo != null) {
      updBgReport += ",r.EXCEPTION_MESSAGE='" + errInfo + "' ";
    }
    File file = new File(writePath + fileName);
    String FileSize = String.valueOf(Double.parseDouble(file.length() + "") / 1024);
    updBgReport += ",r.ELAPSED_TIME= " + elapsedTime + " where r.BG_ID=" + bgId;
    batchSql[0] = updBgReport;

    String insBgFlow =
        "insert into td_backgrounder_report_flow"
            + "  (select seq_background_flow_id.nextval,"
            + "          r.bg_id,"
            + "          r.organization_code,"
            + "          r.report_user_name,"
            + "          r.begin_time,"
            + endDate
            + ","
            + elapsedTime
            + ","
            + "          r.report_code,"
            + "'"
            + sqlCondition
            + "',"
            + "'"
            + fileName
            + "',"
            + "'"
            + status
            + "',"
            + "          r.exception_message,"
            + "          r.create_by,"
            + "          sysdate,"
            + "'"
            + FileSize
            + "'"
            + "     from td_backgrounder_report r"
            + "    where r.bg_id = "
            + bgId
            + ")";

    batchSql[1] = insBgFlow;
    //		ReportExecutor re = (ReportExecutor)SpringContextUtil.getBean("reportExecutor");
    // Add multi-country by XT
    ReportExecutor re = (ReportExecutor) SpringContextUtil.getBean("reportExecutor" + countryCode);

    re.updateBgTable(batchSql);

    //		ArrayList al = new ArrayList();
    //		BackgrounderReportForm bgrf =
    // (BackgrounderReportForm)this.getDao().findById(BackgrounderReportForm.class, bgId);
    //		bgrf.setReportFile(reportFile);
    //		bgrf.setExceptionMessage(errInfo);
    //		bgrf.setEndTime(endDate);
    //		long elapsedTime=((endDate.getTime()-bgrf.getBeginTime().getTime())/1000);
    //		bgrf.setElapsedTime(elapsedTime);
    //		al.add(bgrf);
    //
    //		BackgrounderReportFlowForm bgrlf = new BackgrounderReportFlowForm();
    //		bgrlf.setBgId(bgrf.getBgId());
    //		bgrlf.setOrganizationCode(bgrf.getOrganizationCode());
    //		bgrlf.setReportUserName(bgrf.getReportUserName());
    //		bgrlf.setBeginTime(bgrf.getBeginTime());
    //		bgrlf.setEndTime(bgrf.getEndTime());
    //		bgrlf.setElapsedTime(bgrf.getElapsedTime());
    //		bgrlf.setReportCode(bgrf.getReportCode());
    //		bgrlf.setSqlCondition(bgrf.getSqlCondition());
    //		bgrlf.setReportFile(bgrf.getReportFile());
    //		bgrlf.setReportStatus(bgrf.getReportStatus());
    //		bgrlf.setExceptionMessage(bgrf.getExceptionMessage());
    //		bgrlf.setCreateBy(bgrf.getCreateBy());
    //		al.add(bgrlf);
    //
    //		this.getBatchDao().saveOrUpdateBatch(al);

  }