Ejemplo n.º 1
0
  public Report saveReport(Report r, String reportType) {
    if ("year".equals(r.getType())) {
      r.setTime(null);
    }
    User user = (User) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    if (user instanceof Org) {
      Org org = (Org) user;
      Cun cun = org.getCun();
      Report report =
          reportDao.getReport(reportType, org, cun, r.getYear(), r.getType(), r.getTime());
      for (int i = 1; i <= 60; i++) {
        report.setItem(i, r.getItem(i));
      }
      report.setCun(cun);
      report.setOrg(org);
      report.setYear(r.getYear());
      report.setType(r.getType());
      report.setTime(r.getTime());
      report.setLock(1); // 1表示已经锁定
      reportDao.saveOrUpdate(report);

      // 如果是月份的报表,则生成季度和年份的报表
      if ("month".equals(r.getType())) {
        generateSeasonAndYear(reportType, org, cun, r);
      }

      return report;
    }
    return null;
  }
Ejemplo n.º 2
0
 private void clearItemsZero(Report report) {
   for (int i = 1; i <= 60; i++) {
     if ("0.0".equals(report.getItem(i))) {
       report.setItem(i, null);
     }
   }
 }
Ejemplo n.º 3
0
 private void addItems(Report report, Report mReport) {
   for (int i = 1; i <= 60; i++) {
     try {
       Double temp = 0.0;
       // 原来的item的值
       if (Util.isEmpty(report.getItem(i))) {
         temp = 0.0;
       } else {
         temp = Double.valueOf(report.getItem(i));
       }
       // 月份的item的值
       if (Util.isEmpty(mReport.getItem(i))) {
         temp += 0.0;
       } else {
         temp += Double.valueOf(mReport.getItem(i));
       }
       report.setItem(i, temp + "");
     } catch (NumberFormatException e) {
       e.printStackTrace();
     }
   }
 }
Ejemplo n.º 4
0
 private void clearItems(Report report) {
   for (int i = 1; i <= 60; i++) {
     report.setItem(i, "");
   }
 }