public void doUpdateInterviewDate(Long[] ids, Calendar interviewDate) {
   Map<String, Object> attributes = new HashMap<String, Object>();
   attributes.put("interviewDate", interviewDate);
   attributes.put("modifiedDate", Calendar.getInstance());
   attributes.put("modifier", SystemContextHolder.get().getUserHistory());
   this.tempDriverDao.update(ids, attributes);
 }
  /**
   * 结案操作
   *
   * @param fromBusinessId
   * @param closeDate
   * @return
   */
  public Case4InfractBusiness doCloseFile(Long fromBusinessId, Calendar closeDate) {
    Case4InfractBusiness business = this.caseBusinessDao.load(fromBusinessId);
    if (business == null) throw new CoreException("要处理的营运违章已不存在!businessId=" + fromBusinessId);

    // 更新营运违章相关信息
    business.setStatus(CaseBase.STATUS_CLOSED);

    // 设置创建人信息和最后修改人信息
    SystemContext context = SystemContextHolder.get();
    business.setModifier(context.getUserHistory());
    business.setModifiedDate(Calendar.getInstance());

    // 设置结案人,结案日期
    business.setCloserId(context.getUserHistory().getId());
    business.setCloserName(context.getUserHistory().getName());
    business.setCloseDate(closeDate);

    return this.caseBusinessDao.save(business);
  }
  // 同步附件
  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);
    }
  }
  public Attach getAttach(
      String subject,
      String code,
      Map<String, Object> args,
      String ptype,
      String puid,
      ActorHistory author,
      Map<String, Object> formatParamSql)
      throws Exception {
    Assert.hasText(subject, "subject is Empty");
    Assert.hasText(code, "code is Empty");
    Assert.hasText(ptype, "ptype is Empty");
    Assert.hasText(puid, "puid is Empty");

    Template template = this.templateDao.loadByCode(code);
    if (template == null) throw new CoreException("Template code:" + code + " not find entity!");

    if (args == null) args = new HashMap<String, Object>();

    if (author == null) {
      if (SystemContextHolder.get() == null) {
        author = this.actorHistoryService.loadByCode("admin");
      } else {
        author = SystemContextHolder.get().getUserHistory();
      }
    }

    Map<String, Object> args4Param = this.getMapParams(template.getId(), formatParamSql);

    if (args4Param != null)
      // 最终替换参数
      args.putAll(this.getMapParams(template.getId(), formatParamSql));

    // 生成附件
    Attach attach = new Attach();
    attach.setAuthor(author);
    attach.setFileDate(Calendar.getInstance());
    attach.setSubject(subject);
    attach.setAppPath(false);
    attach.setFormat(template.getTemplateType().getExtension());
    attach.setStatus(BCConstants.STATUS_ENABLED);
    attach.setPtype(ptype);
    attach.setPuid(puid);

    // 文件存储的相对路径(年月),避免超出目录内文件数的限制
    Calendar now = Calendar.getInstance();
    String datedir = new SimpleDateFormat("yyyyMM").format(now.getTime());

    // 要保存的物理文件
    String realpath; // 绝对路径名
    // uuid
    String fileName =
        UUID.randomUUID().toString().replace("-", "")
            + "."
            + template.getTemplateType().getExtension(); // 不含路径的文件名
    realpath = Attach.DATA_REAL_PATH + "/" + datedir + "/" + fileName;

    // 构建文件要保存到的目录
    File file = new File(realpath);
    if (!file.getParentFile().exists()) {
      if (logger.isInfoEnabled()) {
        logger.info("mkdir=" + file.getParentFile().getAbsolutePath());
      }
      file.getParentFile().mkdirs();
    }

    OutputStream out = new BufferedOutputStream(new FileOutputStream(file));

    this.formatTo(template.getCode(), args, out);

    // 设置附件大小
    attach.setSize(new File(realpath).length());

    // 设置附件相对路径
    attach.setPath(datedir + "/" + fileName);

    return this.attachService.save(attach);
  }
  public String doStartFlow(String key, Long[] ids, boolean flag_status) {
    // 声明变量
    Map<String, Object> variables;
    TempDriver tempDriver;
    // 流程模块关系domain
    WorkflowModuleRelation workflowModuleRelation;
    // 声明返回的流程实例id 多个逗号隔开
    String procInstIds = "";

    // 循环Id数组
    for (Long id : ids) {
      tempDriver = this.tempDriverDao.load(id);
      // 记录同步的详细关键信息
      String desc = "";
      if (flag_status) {
        desc += "将" + tempDriver.getName() + "的招聘信息状态从";
        switch (tempDriver.getStatus()) {
          case TempDriver.STATUS_RESERVE:
            desc += "待聘";
            break;
          case TempDriver.STATUS_CHECK:
            desc += "审批中";
            break;
          case TempDriver.STATUS_PASS:
            desc += "聘用";
            break;
          case TempDriver.STATUS_GIVEUP:
            desc += "未聘用";
            break;
        }
        desc += "修改为审批中";
        // 更新司机的状态为审批中
        tempDriver.setStatus(TempDriver.STATUS_CHECK);
        this.tempDriverDao.save(tempDriver);
      }
      SystemContext sc = SystemContextHolder.get();
      sc.setAttr(ExcutionLog.SYNC_INFO_FLAG, true);
      sc.setAttr(ExcutionLog.SYNC_INFO_VALUE, desc);

      variables = new HashMap<String, Object>();

      // 入职审批流程加载全部信息
      if ("CarManEntry".equals(key)) {
        this.returnParam(tempDriver, variables);
      } else {
        variables.put("tempDriver_id", tempDriver.getId());
        variables.put("name", tempDriver.getName());
        variables.put("certIdentity", tempDriver.getCertIdentity());
      }

      // 发起流程
      String procInstId = this.workflowService.startFlowByKey(key, variables);
      procInstIds += procInstId + ",";
      // 增加流程关系
      workflowModuleRelation = new WorkflowModuleRelation();
      workflowModuleRelation.setMid(id);
      workflowModuleRelation.setPid(procInstId);
      workflowModuleRelation.setMtype(TempDriver.WORKFLOW_MTYPE);
      this.workflowModuleRelationService.save(workflowModuleRelation);
    }

    return procInstIds;
  }
  public Attach doGetAttachFromTemplate(Long id, String templateCode) throws IOException {
    TempDriver tempDriver = this.load(id);

    // 获取模板
    Template template = this.templateService.loadByCode(templateCode);
    if (template == null) {
      logger.error("模板不存在,返回null:code=" + templateCode);
      throw new CoreException("模板不存在,code=" + templateCode);
    }

    String ptype = TempDriver.ATTACH_TYPE;
    String puid = tempDriver.getUid();

    // 不能格式化
    if (!template.isFormatted()) {
      Attach attach = template.format2Attach(null, ptype, puid);
      this.attachService.save(attach);
      return attach;
    }

    // 声明格式化参数
    Map<String, Object> params = new HashMap<String, Object>();
    params = this.returnParam(tempDriver, params);

    // 修改信誉档案的显示
    String credit = params.get("credit").toString();
    if (!"".equals(credit)) {
      credit =
          credit.replace(
              "bc/attach/", SystemContextHolder.get().getAttr("htmlPageNamespace") + "/bc/attach/");
      credit = credit.replaceAll("<font size=\"\\d\">", "");
      credit = credit.replace("</font>", "");
      credit = credit.replace("padding-right:8px;", "");
      params.put("credit", credit);
    }

    params.put("sex", tempDriver.getSex() == 1 ? "男" : "女");

    params.put("age", DateUtils.getAge(tempDriver.getBirthdate()));

    // 出生日期格式化
    date4key("birthdate", tempDriver.getBirthdate(), params);
    // 驾驶证初领日期
    date4key("certDrivingFirstDate", tempDriver.getCertDrivingFirstDate(), params);
    // 驾驶证起效日期
    date4key("certDrivingStartDate", tempDriver.getCertDrivingStartDate(), params);
    // 驾驶证无效日期
    date4key("certDrivingEndDate", tempDriver.getCertDrivingEndDate(), params);

    // 根据模板参数获取的替换值
    Map<String, Object> mapFormatSql = new HashMap<String, Object>();
    mapFormatSql.put("id", id);
    Map<String, Object> mapParams = templateService.getMapParams(template.getId(), mapFormatSql);
    if (mapParams != null) params.putAll(mapParams);

    // 加载系统上下文属性
    params.put(SystemContext.class.getSimpleName(), SystemContextHolder.get());

    Attach attach = template.format2Attach(params, ptype, puid);
    return attach;
  }