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;
  }
 public void requestUnlock(Report r, String reportType) {
   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());
     report.setLock(2); // 2表示请求解锁
     reportDao.saveOrUpdate(report);
   }
 }
  public String getExcelReportFilePath(Report r, String reportType) throws Exception {
    // 获取参数
    Integer year = r.getYear();
    String type = r.getType();
    String time = r.getTime();

    // 文件拷贝
    String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
    path = path.substring(0, path.indexOf("WEB-INF"));
    path += "excel";
    String sourceFile = path + File.separator + "report" + reportType + ".xls";
    String targetFile =
        path + File.separator + "report" + reportType + "_" + year + type + time + ".xls";

    // 获取数据
    Org org = (Org) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    Cun cun = org.getCun();
    Report report = reportDao.getReport(reportType, org, cun, year, type, time);

    if (report != null && report.getId() != null) {
      // 打开excel文件
      Workbook rw = Workbook.getWorkbook(new File(sourceFile));
      WritableWorkbook workbook = Workbook.createWorkbook(new File(targetFile), rw);
      if ("1".equals(reportType)) {
        // 重新更新一下季度和年度的数据
        if ("year".equals(report.getType()) || "season".equals(report.getType())) {
          generateSeasonAndYear(
              "1", org, cun, reportDao.getReport("1", org, cun, year, "month", "6"));
        }
        // 日期类型
        String str = year + "年";
        if ("season".equals(report.getType())) {
          str += time + "季";
        } else if ("month".equals(report.getType())) {
          str += time + "月";
        }
        WritableSheet sheet1 = workbook.getSheet(0);
        WritableSheet sheet2 = workbook.getSheet(1);
        sheet1.addCell(new Label(0, 2, str));
        sheet2.addCell(new Label(0, 2, str));
        fillReportRow1(7, workbook, org, cun, report, false);
        if (!"year".equals(report.getType())) {
          Report leijiReport = reportDao.getReport(reportType, org, cun, year, "year", null);
          // 特殊字段处理
          if ("season".equals(report.getType())) {
            leijiReport.setItem13(report.getItem13());
            leijiReport.setItem14(report.getItem14());
            leijiReport.setItem31(report.getItem31());
          }
          // fillReportRow1(8, workbook, org, cun, leijiReport,true);
        }
      } else if ("2".equals(reportType)) {
        // 重新更新一下季度和年度的数据
        if ("year".equals(report.getType()) || "season".equals(report.getType())) {
          generateSeasonAndYear(
              "2", org, cun, reportDao.getReport("2", org, cun, year, "month", "6"));
        }
        // 日期类型
        String str = year + "年";
        if ("season".equals(report.getType())) {
          str += time + "季";
        } else if ("month".equals(report.getType())) {
          str += time + "月";
        }
        WritableSheet sheet1 = workbook.getSheet(0);
        sheet1.addCell(new Label(0, 2, str));
        fillReportRow2(6, workbook, org, cun, report, false);
        if (!"year".equals(report.getType())) {
          // fillReportRow2(7, workbook, org, cun,
          // reportDao.getReport(reportType, org, cun, year, "year",
          // null),true);
        }
      }
      // 关闭
      workbook.write();
      workbook.close();
      rw.close();
      return targetFile;
    }

    return null;
  }