/* *************************************************************** 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); }
/** * 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); }