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; }
private void writerFlowNodeJson(FlowNode flowNode) { FlowNodeDTO nodeDTO = new FlowNodeDTO(); nodeDTO.setId(flowNode.getId()); if (flowNode.getApproverORLender() != null) { nodeDTO.setApproverORLenderName(flowNode.getApproverORLender().getName()); } if (flowNode.getInitiator() != null) { nodeDTO.setInitiatorId(flowNode.getInitiator().getId()); } nodeDTO.setNodeStatus(flowNode.getNodeStatus()); JSONUtil.write(response, nodeDTO); }
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); }
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; }
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; }
/** 根据模块接口显示实例与关联实例的所有数据 */ public List<InterfaceDataDTO> getInterfaceDataByInterfaceModId(long interfaceModuleId) throws HibernateException { // 保存父集合 List<InterfaceDataDTO> idDTOs = new ArrayList<InterfaceDataDTO>(); // List counts =interfaceDataDao.createQuery("select count(*) from InterfaceData iData where // iData.interfaceModule.id =4 group by iData.interfaceInstance").list(); // List counts =interfaceDataDao.createQuery("select iI.partNumber,count(*) from InterfaceData // iData inner join iData.interfaceInstance iI where iData.interfaceModule.id =4 group by // iI.partNumber").list(); List counts = interfaceDataDao .createQuery( "select iData.interfaceInstance.id,count(*) from InterfaceData iData where iData.interfaceModule.id =? group by iData.interfaceInstance.id", interfaceModuleId) .list(); Iterator it = counts.iterator(); while (it.hasNext()) { Object obj = (Object) it.next(); String objStr = JSONUtil.write(obj); objStr = objStr.substring(1, objStr.length() - 1); String[] strArr = objStr.split(","); // 获得模块接口的实例1的id long interfaceInstanceId = Long.parseLong(strArr[0]); // 模块接口中包含实例1的记录数 int count = Integer.parseInt(strArr[1]); // 根据实例1id查找 实例型号 Part p = partDao.get(interfaceInstanceId); String interfaceInstanceNumber = p.getPartNumber(); // 获得模块接口中的实例1名称以及该实例对应的接口数据记录数 String parentStr = interfaceInstanceNumber + "(" + count + "条)"; InterfaceDataDTO idDTO = new InterfaceDataDTO(); idDTO.setInterfaceInstanceNumber(parentStr); idDTO.setInterfaceInstanceId(interfaceInstanceId); List<InterfaceData> iDatas = interfaceDataDao.find( "from InterfaceData iData where iData.interfaceInstance.id=? and iData.interfaceModule.id = ?", interfaceInstanceId, interfaceModuleId); // 保存子集合 List<InterfaceDataDTO> idDTO2s = new ArrayList<InterfaceDataDTO>(); // 根据接口模块id和接口模块实例1id取得分组后的组内记录信息 for (int i = 0; i < iDatas.size(); i++) { InterfaceData iData = iDatas.get(i); List<InterfaceDataInstance> idis = interfaceDataInstanceDao.find( "from InterfaceDataInstance idi where idi.interfaceData.id=?", iData.getId()); String interfaceInstance2Ids = ""; String interfaceInstance2Number = ""; for (int j = 0; j < idis.size(); j++) { InterfaceDataInstance idi = idis.get(j); Part p2 = idi.getInterfaceInstance2(); interfaceInstance2Ids += p2.getId() + ","; interfaceInstance2Number += p2.getPartNumber() + ","; } interfaceInstance2Ids = interfaceInstance2Ids.substring(0, interfaceInstance2Ids.length() - 1); interfaceInstance2Number = interfaceInstance2Number.substring(0, interfaceInstance2Number.length() - 1); InterfaceDataDTO idDTO2 = new InterfaceDataDTO(); idDTO2.setId(iData.getId()); idDTO2.setChildren(null); idDTO2.setInterfaceElement(iData.getInterfaceElement()); idDTO2.setInterfaceInstance2Id(interfaceInstance2Ids); idDTO2.setInterfaceInstance2Number(interfaceInstance2Number); idDTO2.setInterfaceInstanceId(interfaceInstanceId); idDTO2.setInterfaceInstanceNumber(interfaceInstanceNumber); idDTO2.setInterfaceNumber(iData.getInterfaceNumber()); idDTO2.setInterfaceParams(iData.getInterfaceParams()); idDTO2.setInterfaceType(iData.getInterfaceType()); idDTO2s.add(idDTO2); } idDTO.setChildren(idDTO2s); idDTOs.add(idDTO); } return idDTOs; }