Przeglądaj źródła

Fix issues:
1. 如果流程选择了跳过第一个节点,在定时任务中有些会跳过,有些不会跳过。
2. 定时任务启动的流程在subject中丢失部门信息
3. 去除一些不必要的打印log

liyuan 2 lat temu
rodzic
commit
eb52cfaae1

+ 1 - 1
ibps-basic-root/modules/basic-feign/src/main/java/com/lc/ibps/cloud/feign/interceptor/GlobalFeignInterceptor.java

@@ -44,7 +44,7 @@ public class GlobalFeignInterceptor implements RequestInterceptor {
 		
 		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
 		if(null == attributes) {
-			LOGGER.warn("== ServletRequestAttributes is null.");
+			LOGGER.debug("== ServletRequestAttributes is null.");
 		}
 		else {
 			HttpServletRequest request = attributes.getRequest();

+ 30 - 123
ibps-bpmn-root/modules/bpmn-biz/src/main/java/com/lc/ibps/bpmn/service/impl/BpmProcInstServiceImpl.java

@@ -153,126 +153,23 @@ public class BpmProcInstServiceImpl implements BpmProcInstService {
 			// 在流程发起之前发布事件。 改异步
 			StopWatchUtil.stopAndStartNewLocal(stepId, step, "BpmStartEventPrev");
 			AppUtil.publishEvent(getBpmStartEvent(instance,baseActionCmd,AopType.PREV));//TODO 性能点
-			new Thread(() ->{
-				try {
-					// 设置流程变量。
-					StopWatchUtil.stopAndStartNewLocal(stepId, step, "addVariable");
-					baseActionCmd.addVariable(BpmConstants.BUSINESS_KEY, finalInstance.getBizKey());
-					baseActionCmd.addVariable(BpmConstants.SUBJECT, finalInstance.getSubject());
-					baseActionCmd.addVariable(BpmConstants.PROCESS_INST_ID, finalInstance.getId());
-					baseActionCmd.addVariable(BpmConstants.PROCESS_DEF_ID, finalInstance.getProcDefId());
-					baseActionCmd.addVariable(BpmConstants.BPM_FLOW_KEY, finalInstance.getProcDefKey());
-
-					String bpmnInstId = "";
-					String jumpType = baseActionCmd.getJumpType();
-					if (JumpType.COMMON.getKey().equalsIgnoreCase(jumpType)) {
-						StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.0");
-						// 启动流程实例
-						bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
-								baseActionCmd.getVariables(), curUser);//TODO 性能点
-					} else {
-						//是否指定目标节点
-						String destination = baseActionCmd.getDestination();
-						boolean isDestEmpty = StringUtil.isBlank(destination);
-
-						if (isDestEmpty) {
-							StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.1");
-							// 启动流程实例
-							bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
-									baseActionCmd.getVariables(), curUser);//TODO 性能点
-						} else {
-							StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.2");
-							bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
-									baseActionCmd.getVariables(), curUser, destination);//TODO 性能点
-						}
-					}
-					finalInstance.setBpmnInstId(bpmnInstId);
-
-					StopWatchUtil.stopAndStartNewLocal(stepId, step, "BpmStartEventPost");
-					// 在流程发起之后发布事件
-					AppUtil.publishEvent(getBpmStartEvent(finalInstance, baseActionCmd, AopType.POST));
-					// 是否从草稿启动。
-					StopWatchUtil.stopAndStartNewLocal(stepId, step, "bpmInstSave");
-					BpmInst bpmInst = bpmInstRepository.newInstance(finalInstance);//TODO 性能点,频繁创建对象的损耗
-					if (isAdd) {
-						bpmInst.create();
-					} else {
-						bpmInst.update();
-					}
-					// 处理任务跳过.
-					StopWatchUtil.stopAndStartNewLocal(stepId, step, "handlerSkipTask");
-					handlerSkipTask(finalInstance, curUser, step, stepId);
-				}catch (Exception e){
-					throw e;
-				}finally {
-					StopWatchUtil.stopAndPrintLocal(stepId, step);
-				}
-			}).start();
-		} catch (Exception e) {
-			throw e;
-		}
-
-		return instance;
-	}
-	/*自定义,单线程开启流程*/
-	@Override
-	public IBpmProcInst startProcInst(ProcInstCmd procInstCmd,String subject,String userId,String userName) {
-		if(BeanUtils.isEmpty(procInstCmd)){
-			throw new RuntimeException("流程实例命令对象为空!");
-		}
-
-		String step = "startProcInst";
-		String stepId = UniqueIdUtil.getId();
-		// 主键从cmd中获取
-		BpmInstPo instance = null;
-		try {
-			StopWatchUtil.initAndStartLocal(stepId, Level.DEBUG, step, "getBpmInst");
-			instance = getBpmInst(procInstCmd, false);//TODO 性能点
-
-			/*流程标题参数*/
-			if(StringUtil.isNotEmpty(subject)) {
-				instance.setSubject(subject); //设置标题
-			}else{
-				instance.setSubject(instance.getSubject());
-			}
-			StopWatchUtil.stopAndStartNewLocal(stepId, step, "baseActionCmd");
-			String curUser = StringUtil.isNotEmpty(userId)  ? userId :  procInstCmd.getCurUser();
-			String curUserName = StringUtil.isNotEmpty(userName)  ? userName : procInstCmd.getCurUserName();
-
-			BaseActionCmd baseActionCmd = (BaseActionCmd) procInstCmd;
-			// 设置流程实例
-			boolean isAdd = StringUtil.isEmpty(procInstCmd.getInstId());
-			baseActionCmd.setInstId(instance.getId());
-			baseActionCmd.addTransitVars(BpmConstants.PROCESS_INST, instance);
-			baseActionCmd.setCurUser(curUser);
-			baseActionCmd.setTenantId(procInstCmd.getTenantId());
-			baseActionCmd.setCurUserName(curUserName);
-			baseActionCmd.setFormOptions(procInstCmd.getFormOptions());
-			baseActionCmd.setVersion(procInstCmd.getVersion());
-
-			StopWatchUtil.stopAndStartNewLocal(stepId, step, "setActionCmd");
-			BpmnContextUtil.setActionCmd(baseActionCmd);
-			// 在流程发起之前发布事件。
-			StopWatchUtil.stopAndStartNewLocal(stepId, step, "BpmStartEventPrev");
-			AppUtil.publishEvent(getBpmStartEvent(instance,baseActionCmd,AopType.PREV));//TODO 性能点
 
 			// 设置流程变量。
 			StopWatchUtil.stopAndStartNewLocal(stepId, step, "addVariable");
-			baseActionCmd.addVariable(BpmConstants.BUSINESS_KEY, instance.getBizKey());
-			baseActionCmd.addVariable(BpmConstants.SUBJECT, instance.getSubject());
-			baseActionCmd.addVariable(BpmConstants.PROCESS_INST_ID, instance.getId());
-			baseActionCmd.addVariable(BpmConstants.PROCESS_DEF_ID, instance.getProcDefId());
-			baseActionCmd.addVariable(BpmConstants.BPM_FLOW_KEY, instance.getProcDefKey());
+			baseActionCmd.addVariable(BpmConstants.BUSINESS_KEY, finalInstance.getBizKey());
+			baseActionCmd.addVariable(BpmConstants.SUBJECT, finalInstance.getSubject());
+			baseActionCmd.addVariable(BpmConstants.PROCESS_INST_ID, finalInstance.getId());
+			baseActionCmd.addVariable(BpmConstants.PROCESS_DEF_ID, finalInstance.getProcDefId());
+			baseActionCmd.addVariable(BpmConstants.BPM_FLOW_KEY, finalInstance.getProcDefKey());
 
 			String bpmnInstId = "";
 			String jumpType = baseActionCmd.getJumpType();
-			if(JumpType.COMMON.getKey().equalsIgnoreCase(jumpType)) {
+			if (JumpType.COMMON.getKey().equalsIgnoreCase(jumpType)) {
 				StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.0");
 				// 启动流程实例
-				bpmnInstId = natProInstService.startProcInst(instance.getBpmnDefId(), instance.getBizKey(),
+				bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
 						baseActionCmd.getVariables(), curUser);//TODO 性能点
-			}
-			else {
+			} else {
 				//是否指定目标节点
 				String destination = baseActionCmd.getDestination();
 				boolean isDestEmpty = StringUtil.isBlank(destination);
@@ -280,42 +177,52 @@ public class BpmProcInstServiceImpl implements BpmProcInstService {
 				if (isDestEmpty) {
 					StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.1");
 					// 启动流程实例
-					bpmnInstId = natProInstService.startProcInst(instance.getBpmnDefId(), instance.getBizKey(),
+					bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
 							baseActionCmd.getVariables(), curUser);//TODO 性能点
 				} else {
 					StopWatchUtil.stopAndStartNewLocal(stepId, step, "natProInstService.startProcInst.2");
-					bpmnInstId = natProInstService.startProcInst(instance.getBpmnDefId(), instance.getBizKey(),
+					bpmnInstId = natProInstService.startProcInst(finalInstance.getBpmnDefId(), finalInstance.getBizKey(),
 							baseActionCmd.getVariables(), curUser, destination);//TODO 性能点
 				}
 			}
-
-			instance.setBpmnInstId(bpmnInstId);
+			finalInstance.setBpmnInstId(bpmnInstId);
 
 			StopWatchUtil.stopAndStartNewLocal(stepId, step, "BpmStartEventPost");
 			// 在流程发起之后发布事件
-			AppUtil.publishEvent(getBpmStartEvent(instance, baseActionCmd,  AopType.POST));
-
+			AppUtil.publishEvent(getBpmStartEvent(finalInstance, baseActionCmd, AopType.POST));
 			// 是否从草稿启动。
 			StopWatchUtil.stopAndStartNewLocal(stepId, step, "bpmInstSave");
-			BpmInst bpmInst = bpmInstRepository.newInstance(instance);//TODO 性能点,频繁创建对象的损耗
+			BpmInst bpmInst = bpmInstRepository.newInstance(finalInstance);//TODO 性能点,频繁创建对象的损耗
 			if (isAdd) {
 				bpmInst.create();
 			} else {
 				bpmInst.update();
 			}
-
 			// 处理任务跳过.
 			StopWatchUtil.stopAndStartNewLocal(stepId, step, "handlerSkipTask");
-			this.handlerSkipTask(instance, curUser, step, stepId);
+			handlerSkipTask(finalInstance, curUser, step, stepId);
+
 		} catch (Exception e) {
 			throw e;
-		}
-		finally {
+		} finally {
 			StopWatchUtil.stopAndPrintLocal(stepId, step);
 		}
-
 		return instance;
 	}
+	/*自定义,单线程开启流程*/
+	@Override
+	public IBpmProcInst startProcInst(ProcInstCmd procInstCmd,String subject,String userId,String userName) {
+		if(BeanUtils.isEmpty(procInstCmd)){
+			throw new RuntimeException("流程实例命令对象为空!");
+		}
+		if(StringUtil.isNotEmpty(userId)){
+			procInstCmd.setCurUser(userId);
+		}
+		if(StringUtil.isNotEmpty(userName)){
+			procInstCmd.setCurUserName(userName);
+		}
+		return startProcInst(procInstCmd);
+	}
 	public String getSysYear(){
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
 		Date data = new Date();

+ 30 - 26
ibps-bpmn-root/modules/bpmn-biz/src/main/java/com/lc/ibps/bpmn/service/impl/BpmTaskActionServiceImpl.java

@@ -133,7 +133,7 @@ public class BpmTaskActionServiceImpl implements BpmTaskActionService{
 
 		String localId = UniqueIdUtil.getId();
 		String step = "stop watch finishTask";
-		StopWatchUtil.initAndStartLocal(localId, Level.DEBUG, step, "isSuspendByInst");
+		StopWatchUtil.initAndStartLocal(localId, Level.WARN, step, "isSuspendByInst");
 		try {
 			// 流程挂起
 			boolean isSuspend = bpmInstService.isSuspendByInst(cmd.getInstId());
@@ -177,13 +177,14 @@ public class BpmTaskActionServiceImpl implements BpmTaskActionService{
 				//update subject
 				updateSubject(cmd,task);
 			}
-			new Thread(() ->{
-				StopWatchUtil.stopAndStartNewLocal(localId, step, "publicDoNextEvent.prev");
-				AppUtil.publishEvent(getDoNextEvent(cmd, AopType.PREV));//TODO 性能很低
-			}).start();
-			//前置事件抛出 改异步
-			//StopWatchUtil.stopAndStartNewLocal(localId, step, "publicDoNextEvent.prev");
-			//AppUtil.publishEvent(getDoNextEvent(cmd, AopType.PREV));//TODO 性能很低
+//			前置事件抛出 改异步
+//			new Thread(() ->{
+//				StopWatchUtil.stopAndStartNewLocal(localId, step, "publicDoNextEvent.prev");
+//				AppUtil.publishEvent(getDoNextEvent(cmd, AopType.PREV));//TODO 性能很低
+//			}).start();
+
+			StopWatchUtil.stopAndStartNewLocal(localId, step, "publicDoNextEvent.prev");
+			AppUtil.publishEvent(getDoNextEvent(cmd, AopType.PREV));//TODO 性能很低
 
 			//构造会话数据
 			StopWatchUtil.stopAndStartNewLocal(localId, step, "buildTaskActionPluginSession");
@@ -196,10 +197,13 @@ public class BpmTaskActionServiceImpl implements BpmTaskActionService{
 			ITaskActionHandlerDefine def = (ITaskActionHandlerDefine)taskActionHandlerConfig.getTaskActionHandlerDef(taskCmd.getActionName());
 			//执行和返回
 			StopWatchUtil.stopAndStartNewLocal(localId, step, "execute");
-			new Thread(() ->{
-				//boolean result =h handler.execute(taskActionPluginSession,def);
-				handler.execute(taskActionPluginSession,def);//TODO 性能很低
-			}).start();
+
+			boolean result = handler.execute(taskActionPluginSession,def);
+
+//			new Thread(() ->{
+//				handler.execute(taskActionPluginSession,def);//TODO 性能很低
+//			}).start();
+
 			//后置事件抛出
 			StopWatchUtil.stopAndStartNewLocal(localId, step, "publicDoNextEvent.post");
 			AppUtil.publishEvent(getDoNextEvent(cmd, AopType.POST));
@@ -208,21 +212,21 @@ public class BpmTaskActionServiceImpl implements BpmTaskActionService{
 			StopWatchUtil.stopAndStartNewLocal(localId, step, "clearTaskByInstId");
 			BpmnContextUtil.clearTaskByInstId(taskCmd.getInstId());
 
-			//if(result) {
-			StopWatchUtil.stopAndStartNewLocal(localId, step, "updataTimes");
-			bpmCommonStatmentService.updateTimes(cmd.getApprovalOpinion(), cmd.getCurUser(), cmd.getActionName());
-			StopWatchUtil.stopAndStartNewLocal(localId, step, "getActionCmd.1");
-			ActionCmd finsActionCmd = BpmnContextUtil.getActionCmd(cmd.getInstId());
-			StopWatchUtil.stopAndStartNewLocal(localId, step, "getTransitVars.1");
-			Object rejectAfterExecutionId = finsActionCmd.getTransitVars("rejectAfterExecutionId");
-			if (rejectAfterExecutionId != null && StringUtil.isNotEmpty(rejectAfterExecutionId.toString())) {
-				// 调整Activiti的执行表数据
-				StopWatchUtil.stopAndStartNewLocal(localId, step, "multipleInstancesRejectAdjust");
-				BpmExecUtil.multipleInstancesRejectAdjust(rejectAfterExecutionId.toString());
+			if(result) {
+				StopWatchUtil.stopAndStartNewLocal(localId, step, "updataTimes");
+				bpmCommonStatmentService.updateTimes(cmd.getApprovalOpinion(), cmd.getCurUser(), cmd.getActionName());
+				StopWatchUtil.stopAndStartNewLocal(localId, step, "getActionCmd.1");
+				ActionCmd finsActionCmd = BpmnContextUtil.getActionCmd(cmd.getInstId());
+				StopWatchUtil.stopAndStartNewLocal(localId, step, "getTransitVars.1");
+				Object rejectAfterExecutionId = finsActionCmd.getTransitVars("rejectAfterExecutionId");
+				if (rejectAfterExecutionId != null && StringUtil.isNotEmpty(rejectAfterExecutionId.toString())) {
+					// 调整Activiti的执行表数据
+					StopWatchUtil.stopAndStartNewLocal(localId, step, "multipleInstancesRejectAdjust");
+					BpmExecUtil.multipleInstancesRejectAdjust(rejectAfterExecutionId.toString());
+				}
+				return true;
 			}
-			return true;
-			//	}
-			//throw new BaseException("任务办理失败");
+			throw new BaseException("任务办理失败");
 		}
 		catch (Exception e) {
 			Throwable t = e.getCause();//org.activiti.engine.ActivitiException

+ 0 - 2
ibps-bpmn-root/modules/bpmn-biz/src/main/java/com/lc/ibps/bpmn/utils/BpmTaskQueryUtil.java

@@ -50,12 +50,10 @@ public class BpmTaskQueryUtil {
 			// 1、解析获得用户相关的ID、类型
 			StopWatchUtil.initAndStartLocal(localId, Level.DEBUG, step, "buildTrans");
 			PartyEntityTransVo trans = BpmTaskBuilder.buildTrans(list, ContextUtil.getCurrentUserId());
-			System.out.println("trans = " + trans);
 
 			// 2、合并请求转换用户信息
 			StopWatchUtil.stopAndStartNewLocal(localId, step, "trans");
 			APIResult<PartyEntityTransResultVo> result = partyEntityService.trans(trans);
-			System.out.println("result = " + result);
 			if(result.isFailed()) {
 				throw new BaseException(result.getCause());
 			}

+ 0 - 3
ibps-provider-base-root/modules/provider-platform-api/src/main/java/com/lc/ibps/org/vo/PartyEntityTransResultVo.java

@@ -57,17 +57,14 @@ public class PartyEntityTransResultVo implements Serializable {
 	@JsonIgnore
 	public TransResultVo getTransResultVo(String taskId) {
 		if(StringUtil.isBlank(taskId)) {
-			System.out.println(("getTransResultVo>>>StringUtil.isBlank(taskId)=="+taskId));
 			return null;
 		}
 		
 		for(TransResultVo vo : trans) {
 			if(vo!=null && taskId.equals(vo.getTaskId())) {
-				System.out.println("vo!=null && taskId.equals(vo.getTaskId())=========================================");
 				return vo;
 			}
 		}
-		System.out.println("getTransResultVo>>>return null=====================================================================");
 		return null;
 	}
 	

+ 2 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/task/services/FeignHeaderInterceptor.java

@@ -27,7 +27,7 @@ public class FeignHeaderInterceptor  implements RequestInterceptor {
             modToken = request.getHeader("X-Authorization-access_token");
             tempToken=modToken;
         }catch (Exception e){
-            System.out.println(e.toString());
+//            System.out.println(e.toString());
         }
         if(modToken ==null) {
             requestTemplate.header("X-Authorization-access_token", tempToken);
@@ -40,7 +40,7 @@ public class FeignHeaderInterceptor  implements RequestInterceptor {
         try {
             return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
         } catch (Exception e) {
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
     }