Пример #1
0
  public String createBatchApprovalFlowWithFirstNode() throws Exception {
    System.out.println("knowledgeIdString::" + knowledgeIdString);
    ArrayList al = new ArrayList();
    // pl 拿到js传过来的String
    String knowledgeidstring = knowledgeIdString;

    // pl 将拿到的String变为数组
    String[] knowledgeid = knowledgeidstring.split(" ");
    int num = 0;
    num = knowledgeid.length;
    long[] knowledgeidlong = new long[num];
    for (int i = 0; i < knowledgeid.length; i++) {
      String s = knowledgeid[i];
      long l = Long.parseLong(s);
      knowledgeidlong[i] = l;
    }
    for (int a = 0; a < num; a++) {
      ApprovalFlow flow;
      SystemUser initiator = getUser();
      knowledgeId = knowledgeidlong[a];

      if (this.knowledgeId == 0) return null;
      MetaKnowledge knowledge = this.knowledgeService.getMetaknowledge(knowledgeId);
      ApprovalFlow existFlow = this.approvalFlowService.getApprovalFlow(knowledge);
      if (existFlow != null) {
        flow = existFlow;
      } else flow = this.approvalFlowService.createApprovalFlow(initiator, knowledge);
      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;
  }
Пример #2
0
  private void writerFlowJson(ApprovalFlow flow) throws Exception {
    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);

    JSONUtil.write(response, flowDTO);
  }
Пример #3
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;
  }