Ejemplo n.º 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;
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  public String createFlowNode() throws Exception {
    if (this.approvalFlowId == 0) return null;
    ApprovalFlow flow = this.approvalFlowService.getApprovalFlow(this.approvalFlowId);
    if (flow.getFlowNodes().size() >= Constants.approvalNodesLimit)
      throw new Exception("最多进行" + Constants.approvalNodesLimit + "次审批");
    FlowNode newNode = new FlowNode();
    newNode.setAddTime(new Date());
    newNode.setInitiator(flow.getInitiator());
    newNode.setNodeStatus(Constants.approvalFlowNodeStart);
    newNode.setFlow(flow);

    this.approvalFlowService.addApprovalFlowNode(flow, newNode);
    writerFlowJson(this.approvalFlowService.getApprovalFlow(this.approvalFlowId));

    return null;
  }
Ejemplo n.º 4
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);
  }
Ejemplo n.º 5
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;
  }
Ejemplo n.º 6
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;
  }