Пример #1
0
  public String saveOrUpdateApprovalor() throws Exception {
    if (this.approvalFlowId == 0 || this.approvalorId == 0) return null;
    SystemUser approvalor = this.userService.getUser(this.approvalorId);
    ApprovalFlow flow = this.approvalFlowService.getApprovalFlow(this.approvalFlowId);
    FlowNode currentNode = flow.getFlowNodes().get(flow.getIndex());
    currentNode.setApproverORLender(approvalor);
    currentNode.setNodeStatus(Constants.approvalFlowNodePending);
    flow.setStatus(Constants.approvalFlowPending);
    // 可能还包括流状态
    this.approvalFlowService.saveApprovalFlow(flow);

    return null;
  }
Пример #2
0
  public String batchSaveOrUpdateApprovalor() throws Exception {
    ArrayList al = new ArrayList();
    String[] approvalFlowIdArray = approvalFlowIdString.split("@");
    for (int a = 0; a < approvalFlowIdArray.length; a++) {
      approvalFlowId = Long.parseLong(approvalFlowIdArray[a]);
      if (this.approvalFlowId == 0 || this.approvalorId == 0) return null;
      SystemUser approvalor = this.userService.getUser(this.approvalorId);
      ApprovalFlow flow = this.approvalFlowService.getApprovalFlow(this.approvalFlowId);
      FlowNode currentNode = flow.getFlowNodes().get(flow.getIndex());
      currentNode.setApproverORLender(approvalor);
      currentNode.setNodeStatus(Constants.approvalFlowNodePending);
      flow.setStatus(Constants.approvalFlowPending);
      // 可能还包括流状态
      this.approvalFlowService.saveApprovalFlow(flow);

      if (flow == null) return null;

      FlowDTO flowDTO = new FlowDTO();
      flowDTO.setStatus(flow.getStatus());
      flowDTO.setId(flow.getId());
      List<FlowNodeDTO> nodeDTOs = new ArrayList<FlowNodeDTO>();
      List<FlowNode> nodes = flow.getFlowNodes();
      for (FlowNode node : nodes) {
        FlowNodeDTO flowNodeDTO = new FlowNodeDTO();
        if (node.getApproverORLender() != null) {
          flowNodeDTO.setApproverORLenderName(node.getApproverORLender().getName());
        }
        flowNodeDTO.setNodeStatus(node.getNodeStatus());
        flowNodeDTO.setApprovalORBorrowOpinion(node.getApprovalORBorrowOpinion());
        nodeDTOs.add(flowNodeDTO);
      }
      flowDTO.setNodes(nodeDTOs);

      al.add(flowDTO);
    }
    JSONUtil.write(response, al);
    return null;
  }
Пример #3
0
  public String approval() throws Exception {

    // pl 定义一个String数组
    String[] knowledgeid = new String[] {};

    // pl 拿到js传过来的String
    String knowledgeidstring = knowledgeIdString;
    System.out.println(knowledgeidstring);

    knowledgeidstring = knowledgeidstring.substring(9);

    // pl 将拿到的String变为数组
    knowledgeid = knowledgeidstring.split(" ");
    int num = 0;
    num = knowledgeid.length;
    long[] knowledgeidlong = new long[num];

    // pl 将knowledgeid数组转变为long型的数组
    for (int i = 0; i < knowledgeid.length; i++) {
      //				System.out.println(knowledgeid[i]);
      String s = knowledgeid[i];
      long l = Long.parseLong(s);
      knowledgeidlong[i] = l;
    }

    System.out.println(opinion + ":::::" + approvalResult);
    approvalResult = approvalResult.substring(9);
    opinion = opinion.substring(9);
    System.out.println(opinion + ":::::" + approvalResult);
    for (int i = 0; i < knowledgeidlong.length; i++) {
      knowledgeId = knowledgeidlong[i];

      if (knowledgeId == 0 || approvalResult == null) return null;
      MetaKnowledge knowledge = this.knowledgeService.getMetaknowledge(knowledgeId);
      if (knowledge == null) return null;
      ApprovalFlow flow = this.approvalFlowService.getApprovalFlow(knowledge);
      FlowNode currentNode = flow.getFlowNodes().get(flow.getIndex());
      SystemUser approvalor = getUser();
      if (approvalor.getId().equals(currentNode.getApproverORLender().getId())) {
        currentNode.setApprovalORBorrowTime(new Date());
        currentNode.setApprovalORBorrowOpinion(opinion);
        currentNode.setNodeStatus(approvalResult);
        currentNode.setFlow(flow);
        if (approvalResult.equals(Constants.approvalFlowNodeResult_Pass)) {
          if (flow.getFlowNodes().size() == Constants.approvalNodesLimit)
            flow.setStatus(Constants.approvalEnd);
          else flow.setStatus(Constants.approvalFlowPass);
          String knowledgeStatus = String.valueOf(flow.getIndex() + 1);
          flow.getKnowledge().setStatus(knowledgeStatus);
          // 如果第一级被审批通过则构建索引
          if (knowledgeStatus.equals("1")) {
            this.fulltextService.indexKnowledge(knowledge);
          }
        } else if (approvalResult.equals(Constants.approvalFlowNodeResult_UnPass)) {
          if (flow.getFlowNodes().size() == 1) {
            flow.setStatus(Constants.approvalFlowUNPass);
            flow.getKnowledge().setStatus("0");
          }

          flow.setStatus(Constants.approvalFlowUNPass);
        } else if (approvalResult.equals(Constants.approvalFlowNodeResult_PassButBlock)) {
          flow.setStatus(Constants.approvalBlock);
          String knowledgeStatus = String.valueOf(flow.getIndex() + 1);
          flow.getKnowledge().setStatus(knowledgeStatus);
        }

        this.approvalFlowService.saveApprovalFlow(flow);

        // writerFlowJson(this.approvalFlowService.getApprovalFlow(approvalFlowId));
      }
    }

    JSONUtil.write(response, num + "篇知识审批成功");
    return null;
  }