冀北监测点试运行功能提交

This commit is contained in:
cdf
2024-05-22 17:50:08 +08:00
parent 7a7ece5acd
commit 5d97d4489e
26 changed files with 789 additions and 60 deletions

View File

@@ -24,12 +24,12 @@ public class BpmWebConfiguration {
/**
* 配置 Flowable Web 过滤器
*/
@Bean
/* @Bean
public FilterRegistrationBean<FlowableWebFilter> flowableWebFilter() {
FilterRegistrationBean<FlowableWebFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new FlowableWebFilter());
registrationBean.setOrder(WebFilterOrderEnum.FLOWABLE_FILTER);
return registrationBean;
}
}*/
}

View File

@@ -1,38 +1,38 @@
package com.njcn.bpm.config;
import cn.hutool.core.util.StrUtil;
import com.njcn.bpm.utils.FlowableUtils;
import com.njcn.web.utils.RequestUtil;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中
*
* @author jason
*/
public class FlowableWebFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
try {
String userIndex = RequestUtil.getUserIndex();
// 设置工作流的用户
if (StrUtil.isNotBlank(userIndex)) {
FlowableUtils.setAuthenticatedUserId(userIndex);
}
// 过滤
chain.doFilter(request, response);
} finally {
// 清理
FlowableUtils.clearAuthenticatedUserId();
}
}
}
//package com.njcn.bpm.config;
//
//import cn.hutool.core.util.StrUtil;
//import com.njcn.bpm.utils.FlowableUtils;
//import com.njcn.web.utils.RequestUtil;
//import org.springframework.web.filter.OncePerRequestFilter;
//
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * Flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中
// *
// * @author jason
// */
//public class FlowableWebFilter extends OncePerRequestFilter {
//
// @Override
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
// throws ServletException, IOException {
// try {
// String userIndex = RequestUtil.getUserIndex();
// // 设置工作流的用户
// if (StrUtil.isNotBlank(userIndex)) {
// FlowableUtils.setAuthenticatedUserId(userIndex);
// }
// // 过滤
// chain.doFilter(request, response);
// } finally {
// // 清理
// FlowableUtils.clearAuthenticatedUserId();
// }
// }
//
//}

View File

@@ -0,0 +1,28 @@
package com.njcn.bpm.listener.business;
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
import com.njcn.bpm.listener.BpmProcessInstanceStatusEventListener;
import com.njcn.supervision.api.TempLineDebugFeignClient;
import com.njcn.supervision.api.TempLineRunTestFeignClient;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class BpmTempLineRunTestStatusListener extends BpmProcessInstanceStatusEventListener {
@Resource
private TempLineRunTestFeignClient tempLineRunTestFeignClient;
@Override
protected String getProcessDefinitionKey() {
return "line_run_test";
}
@Override
protected void onEvent(BpmProcessInstanceStatusEvent event) {
tempLineRunTestFeignClient.updateStatus(event.getBusinessKey(), event.getStatus());
}
}

View File

@@ -27,6 +27,7 @@ import com.njcn.web.factory.PageFactory;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
@@ -191,6 +192,7 @@ public class BpmProcessInstanceServiceImpl implements IBpmProcessInstanceService
if (CollUtil.isNotEmpty(startUserSelectAssignees)) {
variables.put(BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, startUserSelectAssignees);
}
Authentication.setAuthenticatedUserId(userId);
ProcessInstance instance = runtimeService.createProcessInstanceBuilder()
.processDefinitionId(definition.getId())
.businessKey(businessKey)