/** 查询待阅读的信息 */
 @Override
 public TSuperviseTable querySuperviseRecive(TSuperviseTable sup) throws Exception {
   if (sup != null) { // 未阅状态
     if ("0".equals(sup.getStatus()) || "".equals(sup.getStatus()))
       tSuperviseTableDAO.updateSuperviseStatus(sup);
   }
   return tSuperviseTableDAO.querySuperviseTable1(sup);
 }
 /** 查询督办信息 */
 @Override
 public TSuperviseTable querySuperviseTable(String superviseId, String flowId) throws Exception {
   TSuperviseTable sup = new TSuperviseTable();
   if (superviseId != null && !"".equals(superviseId))
     sup.setSuperviseId(Long.valueOf(superviseId));
   if (flowId != null && !"".equals(flowId)) sup.setFlowId(flowId);
   return tSuperviseTableDAO.querySuperviseTable(sup);
 }
 @Override
 public List<TSuperviseTable> queryTaskAssignPerson(String possionId, MUOUserSession muo)
     throws Exception {
   HashMap<String, Object> hmp = new HashMap<String, Object>();
   hmp.put("positionid", possionId);
   hmp.put("orgid", muo.getOrgid());
   hmp.put("empid", muo.getEmpid());
   return tSuperviseTableDAO.queryTaskAssignPerson(hmp);
 }
 /** 查询督办信息列表 */
 @Override
 public List<TSuperviseTable> querySuperviseTabls(
     TSuperviseTable siup, MUOUserSession muo, Page page) throws Exception {
   if (siup == null) {
     siup = new TSuperviseTable();
   }
   siup.setOracleStart(page.getBegin());
   siup.setOracleEnd(page.getBegin() + page.getLength());
   siup.setEmpid(String.valueOf(muo.getEmpid()));
   return tSuperviseTableDAO.querySuperviseTables(siup, page);
 }
  public String updateBuShiAssignStatus2(
      TaskAssgineeDto dto, MUOUserSession muo, TSuperviseTable sup) throws Exception {
    if (dto.getExecutionId() == null || "".equals(dto.getExecutionId())) return "无法获取该实例ID!";
    String type = "10";
    sup.setNodeName1(jbpmService.getTaskById(dto.getTaskId()).getName());
    if (sup.getOpninion() == null || "".equals(sup.getOpninion())) sup.setOpninion("");

    // 删除当前人员办理信息
    // 删除当前已办人员
    TProcessTaskAssigneePerson tpap = new TProcessTaskAssigneePerson();
    tpap.setTaskAssigneeId(muo.getEmpid());
    tpap.setExecutionId(dto.getExecutionId());
    this.tProcessTaskAssigneePersonDAO.deleteByTemplate(tpap);

    String preTaskId = dto.getTaskId();
    // 插入下一个节点信息
    insertTask(dto, muo);
    // 更新当前执行人信息

    TProcessTaskAssignee tptagee = new TProcessTaskAssignee();
    tptagee.setId(dto.getProcessTaskAssigneeId());
    tptagee.setExecutionId(dto.getExecutionId());
    tptagee.setPreTaskId(preTaskId);
    tptagee.setPreTaskAssingee(muo.getEmpid().toString());
    tptagee.setPreTaskOrg(muo.getOrgid());
    tptagee.setPreTaskTime(TimeUtil.getCntDtStr(new Date(), "yyyyMMddHHmmss"));
    tptagee.setNextTaskId(dto.getTaskId());
    tptagee.setBusinessKey(sup.getSuperviseId());

    // 插入下一步执行人员
    this.gettProcessTaskAssigneeDAO().updateByPrimaryKeySelective(tptagee);
    TProcessTaskAssigneePerson record = new TProcessTaskAssigneePerson();
    TProcessTaskAssigneePerson example = new TProcessTaskAssigneePerson();
    record.setExecutionId(dto.getExecutionId());
    record.setTaskId(dto.getTaskId());
    example.setExecutionId(dto.getExecutionId());
    example.setProcessTaskAssigneeId(dto.getProcessTaskAssigneeId());
    this.gettProcessTaskAssigneePersonDAO().updateEntityByTemplate(record, example);
    dto.setTaskAssigneeState("0");
    // 判断内部办理是否是所有人都已经办理
    List<TProcessTaskAssigneePerson> task = jbpmService.getBsUnCompleted(dto);
    if (task.size() < 1) {
      // 获取下个节点人id,姓名
      HashMap<String, Object> hmp = new HashMap<String, Object>();
      hmp.put("empid", muo.getEmpid());
      // 获取部门主要负责人信息
      TSuperviseTable sp = tSuperviseTableDAO.queryTaskAssignZyPerson(hmp);
      if (sp != null && sp.getEmpid() != null && !"".equals(sp.getEmpid()))
        dto.setEmpIds(sp.getEmpid());
      if (sp != null && sp.getEmpname() != null && !"".equals(sp.getEmpname()))
        dto.setEmpNames(sp.getEmpname());
      dto.setIsChild("0"); // 用来判断是否负责人,显示对应按钮信息
      dto.setTaskAssigneeState("0"); // 部室提交下一步使用,如果是多个为0,则流程不走下一个节点。
      if (!(dto.getEmpIds() == null || dto.getEmpIds().equals(""))) {
        jbpmService.insertTaskAssignPerson(dto);
      }
    }
    // 插入办理意见
    insertApproveOpninion2(sup, muo, dto.getTaskId(), type, dto);
    return "success";
  }
  /** 督办处理2 */
  @Override
  public TaskAssgineeDto insertSuperviseTable2(
      TSuperviseTable supervise,
      File[] files,
      String[] filesFileName,
      MUOUserSession muo,
      String btnType,
      TaskAssgineeDto taskAssgineeDto,
      String isFirst)
      throws Exception {
    String taskId = taskAssgineeDto.getNextTaskId();
    // if(taskAssgineeDto.getTransitionName()!=null&&!"".equals(taskAssgineeDto.getTransitionName()))
    // taskAssgineeDto.setTransitionName(new
    // String(taskAssgineeDto.getTransitionName().getBytes("iso-8859-1"),"UTF-8"));
    // 生成督办信息
    String submitType = "";
    if (supervise.getSuperviseId() == null || "".equals(supervise.getSuperviseId())) {
      supervise.setOrgid(String.valueOf(muo.getOrgid()));
      supervise.setCreateor(String.valueOf(muo.getEmpid()));
      String currDate = TimeUtil.getCntDtStr(new Date(), "yyyyMMddHHmmss");
      supervise.setCreateDate(currDate.substring(0, 8));
      supervise.setCreateTime(currDate.substring(8));
      HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("user", String.valueOf(muo.getEmpid()));
      TaskAssgineeDto dto1 =
          jbpmService.startProcessByDefinition(taskAssgineeDto.getDefinitionId(), map);
      taskId = dto1.getNextTaskId();
      supervise.setNodeId(taskId);
      supervise.setNodeName1(jbpmService.getTaskById(taskId).getName());
      supervise.setFlowId(dto1.getExecutionId());
      taskAssgineeDto.setExecutionId(dto1.getExecutionId());
      tSuperviseTableDAO.insertSuperviseTable(supervise);
      // 保存流程的信息
      jbpmService.saveProcessBusiness(muo, insertProcessBusiness(supervise, taskAssgineeDto));
      supervise.setOpninion("");
      submitType = "05";
    } else {
      // 修改
      tSuperviseTableDAO.updateSuperviseTable(supervise);
      // 20140902修改督办单更新时出现一倍数据的问题
      TProcessBusiness business = jbpmService.findProcessBusiness(taskAssgineeDto);
      business.setBusinessTitle(supervise.getSuperviseItem());

      jbpmService.updateProcessBusiness(business);
      submitType = "05";
      /** 2014093 */
      if (supervise.getOpninion() == null || "null".equals(supervise.getOpninion()))
        supervise.setOpninion("");
      /* jbpmService.updateProcessBusiness(insertProcessBusiness(supervise,taskAssgineeDto));*/
    }
    tFileResourceTableService.fileUploads(
        makeFileBean(supervise, taskAssgineeDto), files, filesFileName, muo); // 保存文件
    if (!"1".equals(btnType)) {
      supervise.setNodeName1(jbpmService.getTaskById(taskId).getName());
      taskAssgineeDto.setTaskExeAssginee(String.valueOf(muo.getEmpid()));
      taskAssgineeDto.setTaskId(taskId);
      jbpmService.assignTask(taskAssgineeDto);
      if (!"退回".equals(taskAssgineeDto.getTransitionName())
          && !"退回办理".equals(taskAssgineeDto.getTransitionName())) { // 进入下一步
        taskAssgineeDto.setTaskAssigneeState("0");
        // taskAssgineeDto.setPreTaskAssingee(muo.getEmpid());
        jbpmService.updateTaskAssigneeState(taskAssgineeDto);
        // 20140903 解决下个操作人为null的问题

        if ("null".equals(taskAssgineeDto.getEmpNames())) taskAssgineeDto.setEmpNames("");
        if (isFirst == null
            && taskAssgineeDto.getEmpIds() != null
            && !"".equals(taskAssgineeDto.getEmpIds())) submitType = "01";
        /*if("处理".equals(taskAssgineeDto.getTransitionName())){//
            //暂无

        }else if("批示".equals(taskAssgineeDto.getTransitionName())){
            //String[] receiveEmp=taskAssgineeDto.getEmpIds().split(",");
            //for(int i=0;i<receiveEmp.length;i++){
        //  TSuperviceReceive record=new TSuperviceReceive();
            //record.setNodeId(taskId);
            //record.setNodeName(jbpmService.getTaskById(taskId).getName());
            //record.setContent(supervise.getContent());
            //record.setSuperviseId(supervise.getSuperviseId());
            //record.setReceiveEmp(receiveEmp[i]);
            //record.setReceiveDate("");
            //record.setReceiveTime("");
            //生成督办的人。
            //tSuperviceReceiveDAO.insert(record);
        //  }
        }else*/
        if ("反馈".equals(taskAssgineeDto.getTransitionName())) {
          submitType = "07";
          List<TProcessTaskAssigneePerson> task = jbpmService.getUnCompleted(taskAssgineeDto);
          /*                  taskAssgineeDto.setPreTaskAssingee(muo.getEmpid());
                              jbpmService.updateTaskAssigneeState(taskAssgineeDto);
                              TaskAssgineeDto tad=new TaskAssgineeDto();
                              tad.setParentId(taskAssgineeDto.getParentId());
                              tad.setExecutionId(taskAssgineeDto.getExecutionId());
                              tad.setIsUpdate("10");//10:子处理节点未完成的
                              tad.setTaskAssigneeState("3");//3:作废
                              jbpmService.updateTaskAssigneeState1(tad);//将部室下子处理节点未签的前辈作废
          */ if (task != null && task.size() <= 1) { // 用于所有人都操作完成后进入下一个节点
            jbpmService.completeTask(taskId, taskAssgineeDto.getTransitionName(), null);
            String nextTaskId = jbpmService.getNextTaskId(taskAssgineeDto.getExecutionId());
            taskAssgineeDto.setNextTaskId(nextTaskId);
            supervise.setNodeId(taskId);
            TaskAssgineeDto dto = makeTaskAssgineeDto(supervise, muo, taskAssgineeDto);
            jbpmService.saceTaskAssignee(dto);
          } else {
            // 删除当前节点办理人员,表示已经办理过
            TProcessTaskAssigneePerson tpap = new TProcessTaskAssigneePerson();
            tpap.setTaskAssigneeId(muo.getEmpid());
            tpap.setExecutionId(taskAssgineeDto.getExecutionId());
            this.tProcessTaskAssigneePersonDAO.deleteByTemplate(tpap);
          }

        } else if ("结束".equals(taskAssgineeDto.getTransitionName())) {
          supervise.setNodeId(taskId);
          TaskAssgineeDto taskAssginee = makeTaskAssgineeDto(supervise, muo, taskAssgineeDto);
          taskAssginee.setNextTaskId("");
          jbpmService.saceTaskAssignee(taskAssginee);
          jbpmService.completeTask(taskId, taskAssgineeDto.getTransitionName(), null);
          // 20140904 添加操作类型为结束
          submitType = "08";
        } else { // 进入下一步
          if ("批示".equals(taskAssgineeDto.getTransitionName())) submitType = "05";
          jbpmService.completeTask(taskId, taskAssgineeDto.getTransitionName(), null);
          String nextTaskId = jbpmService.getNextTaskId(taskAssgineeDto.getExecutionId());
          taskAssgineeDto.setNextTaskId(nextTaskId);
          supervise.setNodeId(taskId);
          jbpmService.saceTaskAssignee(makeTaskAssgineeDto(supervise, muo, taskAssgineeDto));
        }

        insertApproveOpninion(supervise, muo, taskId, submitType, taskAssgineeDto);
      } else { // 退回
        insertApproveOpninion(supervise, muo, taskId, "02", taskAssgineeDto);
        jbpmService.completeTask(taskId, taskAssgineeDto.getTransitionName(), null);
        jbpmService.turnBackTaskAssignee(makeTaskAssgineeDtoBack(taskAssgineeDto, supervise, muo));
      }
    }
    return null;
  }
 @Override
 public List<TSuperviseTable> queryLeader(String positionCode, MUOUserSession muo) {
   HashMap<String, Object> hmp = new HashMap<String, Object>();
   hmp.put("positionCode", positionCode);
   return tSuperviseTableDAO.queryLeader(hmp);
 }