private Map<String, Object> date4key(
      String key, Calendar calendar, Map<String, Object> variables) {
    if (variables == null) return null;
    if (key == null || key.length() == 0 || calendar == null) return variables;

    variables.put(key + "4yyyy", DateUtils.formatCalendar(calendar, "yyyy"));
    variables.put(key + "4MM", DateUtils.formatCalendar(calendar, "MM"));
    variables.put(key + "4dd", DateUtils.formatCalendar(calendar, "dd"));

    return variables;
  }
  // 同步附件
  private void syscAttach(Case4InfractBusiness cib, String procInstId, String taskId) {
    if (cib == null || procInstId == null || procInstId.length() == 0) return;

    List<Attach> attachs =
        attachService.findByPtype(Case4InfractBusiness.ATTACH_TYPE, cib.getUid());
    if (attachs == null || attachs.size() == 0) return;

    for (Attach attach : attachs) {
      // 复制附件到流程附件位置中----开始---
      // 扩展名
      String extension = StringUtils.getFilenameExtension(attach.getPath());
      // 文件存储的相对路径(年月),避免超出目录内文件数的限制
      String subFolder = DateUtils.formatCalendar(Calendar.getInstance(), "yyyyMM");
      // 上传文件存储的绝对路径
      String appRealDir = Attach.DATA_REAL_PATH + File.separator + FlowAttach.DATA_SUB_PATH;
      // 所保存文件所在的目录的绝对路径名
      String realFileDir = appRealDir + File.separator + subFolder;
      // 不含路径的文件名
      String fileName =
          DateUtils.formatCalendar(Calendar.getInstance(), "yyyyMMddHHmmssSSSS") + "." + extension;
      // 所保存文件的绝对路径名
      String realFilePath = realFileDir + File.separator + fileName;
      // 构建文件要保存到的目录
      File _fileDir = new File(realFileDir);
      if (!_fileDir.exists()) {
        if (logger.isFatalEnabled()) logger.fatal("mkdir=" + realFileDir);
        _fileDir.mkdirs();
      }
      // 直接复制附件
      if (logger.isInfoEnabled()) logger.info("pure copy file");

      // 附件路径
      String path = Attach.DATA_REAL_PATH + File.separator + attach.getPath();

      // 从附件目录下的指定文件复制到attachment目录下
      try {
        FileCopyUtils.copy(new FileInputStream(new File(path)), new FileOutputStream(realFilePath));
      } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
      }

      // 复制附件到流程附件位置中----结束---

      // 插入流程附件记录信息
      FlowAttach flowAttach = new FlowAttach();
      flowAttach.setUid(idGeneratorService.next(FlowAttach.ATTACH_TYPE));
      flowAttach.setType(FlowAttach.TYPE_ATTACHMENT); // 类型:1-附件,2-意见
      flowAttach.setPid(procInstId); // 流程id
      flowAttach.setPath(subFolder + File.separator + fileName); // 附件路径,物理文件保存的相对路径
      flowAttach.setExt(extension); // 扩展名
      flowAttach.setSubject(attach.getSubject()); // 标题
      flowAttach.setSize(attach.getSize());
      flowAttach.setFormatted(false); // 附件是否需要格式化

      if (taskId == null) {
        flowAttach.setCommon(true); // 公共附件
      } else {
        flowAttach.setCommon(false); // 任务附件
        flowAttach.setTid(taskId);
      }

      // 创建人,最后修改人信息
      SystemContext context = SystemContextHolder.get();
      flowAttach.setAuthor(context.getUserHistory());
      flowAttach.setModifier(context.getUserHistory());
      flowAttach.setFileDate(Calendar.getInstance());
      flowAttach.setModifiedDate(Calendar.getInstance());
      this.flowAttachService.save(flowAttach);
    }
  }