/**
  * 批量删除附件 @Title deleteUser
  *
  * @author hedaojun
  * @date 2015-2-15
  * @return String
  */
 public String deleteAttachs() {
   try {
     String attachIds = this.getRequest().getParameter("attachIds");
     for (String attachId : attachIds.split(",")) {
       Attach attach = attachService.getAttach(Integer.parseInt(attachId));
       // 删除数据库记录
       attachService.removeAttach(attach.getAttachId());
       // 从服务器硬盘删除文件
       FileUtil.delFile(attach.getAttachUrl());
     }
     JsonUtil.outJson("{success:true,msg:'删除成功!'}");
   } catch (Exception e) {
     JsonUtil.outJson("{success:false,msg:'删除失败!'}");
     this.excepAndLogHandle(UserAction.class, "批量删除附件", e, false);
   }
   return null;
 }
  /**
   * 删除附件
   *
   * @author 何道军
   * @date 2011-1-7
   * @return String
   */
  public String deleteAttach() {
    try {
      if (attachId == 0) {
        result = "不存在的附件ID,删除失败,请稍后再试!";
        return "success";
      }
      Attach attach = attachService.getAttach(attachId);
      // 删除数据库记录
      attachService.removeAttach(attach.getAttachId());
      // 从服务器硬盘删除文件
      FileUtil.delFile(attach.getAttachUrl());

      result = "Y";
    } catch (Exception e) {
      e.printStackTrace();
      result = "删除失败,请稍后再试!";
    }
    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("result", result);
    JsonUtil.outJson(resultMap);
    return null;
  }
  /**
   * 添加附件
   * {"attachType":null,"attachName":"intel_ICS_Dx32.exe","result":"Y","attachGroupId":281,"attachId":345,"attachSize":"7.42
   * MB"}
   *
   * @author 何道军
   * @date 2011-1-7
   * @return String
   */
  public String addAttach() {
    Map<String, Object> attachMap = new HashMap<String, Object>();
    if (uploadAttach == null) {
      attachMap.put("success", false);
      attachMap.put("result", "添加失败。");
      JsonUtil.outJson(attachMap);
      return null;
    }

    if (uploadAttach.length() == 0) {
      attachMap.put("success", false);
      attachMap.put("result", "添加失败:不能上传大小为0 KB的文件。");
      JsonUtil.outJson(attachMap);
      return null;
    }

    if (maximumSize != null && maximumSize > 0 && maximumSize < uploadAttach.length()) {
      attachMap.put("success", false);
      attachMap.put(
          "result",
          "添加失败:文件大小不能超过 "
              + FormatUnitsUtil.formatBytes(maximumSize)
              + "。当前文件大小为:"
              + FormatUnitsUtil.formatBytes(uploadAttach.length()));
      JsonUtil.outJson(attachMap);
      return null;
    }
    if (StringUtils.isNotBlank(allowedExtensions)
        && !allowedExtensions.contains(FileUtil.getFileExp(uploadAttachFileName))) {
      attachMap.put("success", false);
      attachMap.put("result", "添加失败:只能上传后缀名为:" + allowedExtensions + "的文件。");
      JsonUtil.outJson(attachMap);
      return null;
    }
    try {
      if (attachGroupId != 0) {
        attachGroup = attachGroupService.getAttachGroup(attachGroupId);
        if (attachGroup == null) {
          attachMap.put("success", false);
          attachMap.put(
              "result", "系统错误:更新的附件组ID:" + attachGroupId + "不存在,如果要重新生成附件组ID,请设置附件组ID为空或0!");
          JsonUtil.outJson(attachMap);
          return null;
        }
      } else {
        attachGroup = new AttachGroup();
        attachGroup.setStatus(STATUS_NOT_DELETE);
        attachGroup.setSubmitDate(new Date());
        attachGroupService.saveAttachGroup(attachGroup);
      }

      dealSavePath();

      attach = new Attach();
      attach.setStatus(STATUS_NOT_DELETE);
      attach.setAttachName(uploadAttachFileName);
      attach.setAttachType(attachType);
      String attachURL = FileUtil.upload(uploadAttach, uploadAttachFileName, savePath);
      attach.setAttachUrl(attachURL);
      attach.setAttachGroup(attachGroup);
      attach.setSubmitDate(new Date());
      attach.setFileSize(FormatUnitsUtil.formatBytes(uploadAttach.length()));
      attach.setDownloadTime(0);
      attachService.saveAttach(attach);

      attachMap.put("attachGroupId", attachGroup.getAttachGroupId());
      attachMap.put("attachName", attach.getAttachName());
      attachMap.put("attachId", attach.getAttachId());
      attachMap.put("attachType", attach.getAttachType());
      attachMap.put("fileSize", attach.getFileSize());
      attachMap.put("success", true);
    } catch (Exception e) {
      attachMap.put("success", false);
      attachMap.put("result", "添加失败:" + e.getMessage());
      e.printStackTrace();
    }
    JsonUtil.outJson(attachMap);
    return null;
  }