提交 e3966687 authored 作者: 1239068511@qq.com's avatar 1239068511@qq.com

[代码更新] 加了一点东西

上级 49d728d4
......@@ -14,8 +14,10 @@
<name>workflow-core</name>
<description>Demo project for Spring Boot</description>
<properties>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<java.version>1.8</java.version>
</properties>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -222,8 +224,24 @@
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<!-- <resource>-->
......@@ -242,26 +260,27 @@
<!-- </resource>-->
</resources>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source> <!--指明源码用的Jdk版本-->
<target>1.8</target> <!--指明打包后的Jdk版本-->
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skipTests>true</skipTests>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>1.8</source> &lt;!&ndash;指明源码用的Jdk版本&ndash;&gt;-->
<!-- <target>1.8</target> &lt;!&ndash;指明打包后的Jdk版本&ndash;&gt;-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
......
......@@ -47,9 +47,9 @@ public class Swagger2Config {
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 文档标题
.title("装备系统接口文档")
.title("工作流接口文档")
// 文档描述
.description("装备系统的接口文档与测试页面")
.description("工作流")
.termsOfServiceUrl("git地址待更新")
.version("v1")
.contact(new Contact("efs", "git", "ty@example.com"))
......
......@@ -40,7 +40,7 @@ public class WorkflowCoreRunner implements CommandLineRunner {
}
public void createXmlMkdir(){
File file = new File(System.getProperty("user.dir")+"\\xml");
File file = new File(System.getProperty("user.dir")+File.separator+"xml");
if (!file.exists()){
file.mkdir();
}
......
......@@ -2,12 +2,16 @@ package com.tykj.workflowcore.user.authencation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tykj.workflowcore.user.authencation.filter.CustomJwtAuthenticationFilter;
import com.tykj.workflowcore.user.authencation.filter.CustomUsernamePasswordAuthenticationFilter;
import com.tykj.workflowcore.user.authencation.filter.SuccessHandler;
import com.tykj.workflowcore.user.authencation.provider.JwtAuthenticationProvider;
import com.tykj.workflowcore.user.authencation.provider.UsernamePasswordAuthenticationProvider;
import com.tykj.workflowcore.user.service.CenterUserService;
import com.tykj.workflowcore.user.service.StorageKeyService;
import com.tykj.workflowcore.user.util.AuthenticationUtils;
import com.tykj.workflowcore.user.util.JwtTokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
......@@ -69,11 +73,23 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
final JwtTokenUtils jwtTokenUtils;
public SecurityWebConfig(UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider, CenterUserService centerUserService, AuthenticationUtils authenticationUtils, JwtTokenUtils jwtTokenUtils) {
final
StorageKeyService storageKeyService;
/**
*自定义Jwt用户验证类
**/
final
JwtAuthenticationProvider jwtAuthenticationProvider;
public SecurityWebConfig(UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider, CenterUserService centerUserService, AuthenticationUtils authenticationUtils, JwtTokenUtils jwtTokenUtils, JwtAuthenticationProvider jwtAuthenticationProvider, StorageKeyService storageKeyService) {
this.usernamePasswordAuthenticationProvider = usernamePasswordAuthenticationProvider;
this.centerUserService = centerUserService;
this.authenticationUtils = authenticationUtils;
this.jwtTokenUtils = jwtTokenUtils;
this.jwtAuthenticationProvider = jwtAuthenticationProvider;
this.storageKeyService = storageKeyService;
}
/**
......@@ -137,7 +153,9 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
out.close();
}), ConcurrentSessionFilter.class)
.addFilterAt(customUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
// .addFilterAt(new JwtAuthenticationTokenFilter(jwtTokenUtils), BasicAuthenticationFilter.class);
http.addFilterAt(customJwtUsernamePasswordAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class);
// .addFilterAt(new JwtAuthenticationTokenFilter(jwtTokenUtils), BasicAuthenticationFilter.class);
}
/***
......@@ -156,8 +174,13 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
}
@Bean
public SessionRegistryImpl sessionRegistry() {
return new SessionRegistryImpl();
CustomJwtAuthenticationFilter customJwtUsernamePasswordAuthenticationFilter() throws Exception {
CustomJwtAuthenticationFilter filter = new CustomJwtAuthenticationFilter();
filter.setStorageKeyService(storageKeyService);
filter.setAuthenticationManager(authenticationManager());
filter.setAuthenticationSuccessHandler(new CustomAuthenticationSuccessHandler());
filter.setAuthenticationFailureHandler(new CustomAuthenticationFailureHandler());
return filter;
}
/***
......@@ -168,9 +191,16 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(jwtAuthenticationProvider);
auth.authenticationProvider(usernamePasswordAuthenticationProvider);
}
@Bean
public SessionRegistryImpl sessionRegistry() {
return new SessionRegistryImpl();
}
/***
* 登录成功后干些啥
*/
......
/*
* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tykj.workflowcore.user.authencation.filter;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.user.authencation.token.JwtAuthencationToken;
import com.tykj.workflowcore.user.pojo.StorageKey;
import com.tykj.workflowcore.user.pojo.User;
import com.tykj.workflowcore.user.service.StorageKeyService;
import com.tykj.workflowcore.user.util.CipherUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Jwt凭证验证拦截器
*
* @author HuangXiahao
* @version V1.0
* @class CustomJWTAuthenticationFilter
* @packageName com.example.personnelmanager.common.authencation.filter
* @data 2020/6/13
**/
public class CustomJwtAuthenticationFilter extends
AbstractAuthenticationProcessingFilter {
public static final String JWT_KEY = "jwt";
/**
* Jwt公钥路径
*/
String jwtFilePath;
StorageKeyService storageKeyService;
public void setStorageKeyService(StorageKeyService storageKeyService) {
this.storageKeyService = storageKeyService;
}
public CustomJwtAuthenticationFilter() {
//设置用户接口的路径以及访问方式
super(new AntPathRequestMatcher("/user/login", "GET"));
}
/***
* 在这个方法中执行验证操作
* @param request
* @param response
* @Return : org.springframework.security.core.Authentication
*/
@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException {
JwtAuthencationToken authRequest ;
User userByJwt;
//如果请求头中没有jwt凭证的话说明不应该使用该类进行验证,直接报错
if (!StringUtils.isEmpty(request.getHeader(JWT_KEY))) {
//通过请求头获取jwt凭证中的用户信息
userByJwt = getuserbyjwt(request);
authRequest = new JwtAuthencationToken(
userByJwt);
//为用于验证的用户注入session信息
setDetails(request, authRequest);
//进行验证
return getAuthenticationManager().authenticate(authRequest);
} else {
throw new ApiException("未设置token");
}
}
/***
* 为用户注入session信息
* @param request
* @param authRequest
* @Return : void
*/
protected void setDetails(HttpServletRequest request,
JwtAuthencationToken authRequest) {
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
}
/***
* 通过请求头获取请求头中的用户信息
*
* @param request
* @Return : com.example.personnelmanager.entity.User
*/
public User getuserbyjwt(HttpServletRequest request) {
StorageKey storageKey = storageKeyService.getKeys();
String rsaPrivateKey = storageKey.getRsaPrivateKey();
String signPublicKey = storageKey.getSignPublicKey();
String jwt = request.getHeader("jwt");
try {
String decrypt = CipherUtil.decrypt(jwt, CipherUtil.string2PrivateKey(rsaPrivateKey));
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(CipherUtil.string2PublicKey(signPublicKey)).parseClaimsJws(decrypt);
logger.info("接收到的用户信息为:"+claimsJws.getBody());
User userRight = new User();
Claims body = claimsJws.getBody();
userRight.setUsername((String) body.get("username"));
userRight.setPhone((String) body.get("phone"));
return userRight;
}catch (Exception e){
logger.error("用户凭证无效");
throw new UsernameNotFoundException("用户凭证无效");
}
}
}
package com.tykj.workflowcore.user.authencation.provider;
import com.tykj.workflowcore.user.authencation.checks.DefaultPreAuthenticationChecks;
import com.tykj.workflowcore.user.authencation.token.JwtAuthencationToken;
import com.tykj.workflowcore.user.pojo.User;
import com.tykj.workflowcore.user.service.CenterUserService;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsChecker;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
/**
* 自定义SpringSecurity的用户处理类类
* 当用户通过统一登录平台访问本系统时由该类进行用户验证
*
* @author HuangXiahao
* @version V1.0
* @class JWTAuthenticationProvider
* @packageName com.example.personnelmanager.common.SpringSecurityProvider
* @data 2020/6/13
**/
@Component
public class JwtAuthenticationProvider implements AuthenticationProvider {
private final CenterUserService userDetailsService;
/**
* 用户可用性检查类
*/
private final UserDetailsChecker preAuthenticationChecks = new DefaultPreAuthenticationChecks();
public JwtAuthenticationProvider(CenterUserService centerUserService) {
this.userDetailsService = centerUserService;
}
/***
* 验证用户
*
* @param authentication
* @Return : org.springframework.security.core.Authentication
*/
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Assert.isInstanceOf(JwtAuthencationToken.class, authentication,
"错误的凭证");
String username = (authentication.getPrincipal() == null) ? "NONE_PROVIDED"
: ((User)authentication.getPrincipal()).getUsername();
UserDetails user = retrieveUser(username);
preAuthenticationChecks.check(user);
return createSuccessAuthentication(user,authentication,user);
}
/***
* 返回True则由该对象进行用户验证
*
* @param authentication
* @Return : boolean
*/
@Override
public boolean supports(Class<?> authentication) {
return (JwtAuthencationToken.class.isAssignableFrom(authentication));
}
/***
* 通过用户名获取对应的用户
*
* @param username
* @Return : org.springframework.security.core.userdetails.UserDetails
*/
protected final UserDetails retrieveUser(String username) {
UserDetails loadedUser = userDetailsService.selectByUserName(username);
if (loadedUser == null) {
throw new InternalAuthenticationServiceException(
"UserDetailsService returned null, which is an interface contract violation");
}
return loadedUser;
}
/***
* 创建一个已经通过验证的用户实例
* 该方法由SpringSecurity源码魔改得到
* @param principal
* @param authentication
* @param user
* @Return : org.springframework.security.core.Authentication
*/
protected Authentication createSuccessAuthentication(Object principal,
Authentication authentication, UserDetails user) {
JwtAuthencationToken result = new JwtAuthencationToken(principal,
user.getAuthorities());
result.setDetails(authentication.getDetails());
return result;
}
}
......@@ -34,5 +34,11 @@ public class DataHistoryController {
dataHistoryService.save(dataHistory);
}
@PostMapping("/test")
@ApiOperation(value = "test")
public void test(){
dataHistoryService.test();
}
}
......@@ -4,6 +4,7 @@ package com.tykj.workflowcore.workflow_editer.dao;
import com.tykj.workflowcore.workflow_editer.entity.DataHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* ClassName: FlowsInfoMapper
......
......@@ -11,6 +11,7 @@ import org.hibernate.annotations.Where;
import javax.persistence.Entity;
import javax.persistence.Lob;
import java.util.Date;
/**
* ClassName: DataHistory
......@@ -77,6 +78,27 @@ public class DataHistory extends BaseEntity {
@Lob
private String IndexKey;
@ApiModelProperty("流程KEY")
private String processKey;
@ApiModelProperty("节点类型")
private String activityType;
@ApiModelProperty("流程发起人")
private String businessKey;
@ApiModelProperty("任务执行人")
private String taskAssign;
@ApiModelProperty("任务名称")
private String taskName;
@ApiModelProperty
private Date startTime;
@ApiModelProperty
private Date endTime;
public static String initUniqueString(String executionId,String processInstanceId,String activityId){
return executionId+"_"+processInstanceId+"_"+activityId ;
}
......
package com.tykj.workflowcore.workflow_editer.entity.vo;
import com.tykj.workflowcore.base.entity.BaseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.Entity;
import javax.persistence.Lob;
/**
* ClassName: DataHistory
* Package: com.tykj.workflowcore.workflow_editer.entity
* Description:
* Datetime: 2021/4/16 15:21
*
* @Author: zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Api("历史数据")
public class DataHistoryVo extends BaseEntity {
@ApiModelProperty("执行实例ID")
private String executionId;
@ApiModelProperty("流程实例id")
private String processInstanceId;
@ApiModelProperty("节点Id")
private String activityId;
@ApiModelProperty("执行实例ID_流程实例id_节点Id 用于作为索引")
private String uniqueString;
@ApiModelProperty("页面id")
private String pageId;
@ApiModelProperty("页面名称")
private String pageName;
@ApiModelProperty("页面描述")
private String pageDesc;
@ApiModelProperty("模板")
@Lob
private String template;
@ApiModelProperty("页面js")
@Lob
private String js;
@ApiModelProperty("页面css")
@Lob
private String css;
@ApiModelProperty("json描述文件")
@Lob
private String descFile;
@ApiModelProperty("变量数据")
@Lob
private String datas;
@ApiModelProperty("页面操作用户id")
private Integer userId;
@ApiModelProperty("索引Key")
@Lob
private String IndexKey;
@ApiModelProperty("流程KEY")
private String processKey;
@ApiModelProperty("节点类型")
private String activityType;
@ApiModelProperty("流程发起人")
private String businessKey;
@ApiModelProperty("任务执行人")
private String taskAssign;
@ApiModelProperty("任务名称")
private String taskName;
private String processName;
private String processDes;
public static String initUniqueString(String executionId,String processInstanceId,String activityId){
return executionId+"_"+processInstanceId+"_"+activityId ;
}
}
......@@ -3,22 +3,30 @@ package com.tykj.workflowcore.workflow_editer.listener;
import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.workflow_editer.entity.DataHistory;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.entity.enums.JavaTypeEnum;
import com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo;
import com.tykj.workflowcore.workflow_editer.service.DataHistoryService;
import com.tykj.workflowcore.workflow_editer.service.FlowInfoService;
import com.tykj.workflowcore.workflow_editer.service.FormPageService;
import org.flowable.bpmn.model.StartEvent;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.engine.*;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
import org.flowable.engine.delegate.event.FlowableActivityEvent;
import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl;
import org.flowable.engine.delegate.event.impl.FlowableEntityWithVariablesEventImpl;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -56,6 +64,12 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
@Autowired
FormPageService formPageService;
@Autowired
HistoryService historyService;
@Autowired
FlowInfoService flowInfoService;
@Override
protected void processCompleted(FlowableEngineEntityEvent event) {
}
......@@ -63,6 +77,7 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
@Override
protected void taskCompleted(FlowableEngineEntityEvent event) {
super.taskCompleted(event);
initDataHistory(event);
}
@Override
......@@ -74,80 +89,106 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
@Override
protected void activityCompleted(FlowableActivityEvent event) {
super.activityCompleted(event);
if (event instanceof FlowableActivityEventImpl){
DelegateExecution execution = ((FlowableActivityEventImpl) event).getExecution();
initDataHistory(execution);
// //开始节点
// if (execution.getCurrentFlowElement() instanceof StartEvent){
// DataHistory dataHistory = new DataHistory();
// StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
// //流程id 实例id pageId datas userId
// String processInstanceBusinessKey = execution.getProcessInstanceBusinessKey();
// dataHistory.setFlowKey(processInstanceBusinessKey);
// dataHistory.setProcessInstanceId(execution.getProcessInstanceId());
// dataHistory.setPageId(startEvent.getFormKey());
//// dataHistory.setUserId();
//// dataHistory.setDatas();
// System.out.println(processInstanceBusinessKey);
//
// String formKey = startEvent.getFormKey();
// //通过formKey查询出页面
//
// }
// if (execution.getCurrentFlowElement() instanceof UserTask){
// //查询任务
// Task task = taskService.createTaskQuery().singleResult();
// Map<String, Object> variables = taskService.getVariables(task.getId());
// DataHistory dataHistory = new DataHistory();
// String datas = JSON.toJSONString(variables);
// //流程实例id
// String processInstanceId = task.getProcessInstanceId();
// //当前节点id
// String processInstanceBusinessKey = execution.getProcessInstanceBusinessKey();
//
//// dataHistory.setTaskId(taskId);
// dataHistory.setDatas(datas);
// dataHistory.setProcessInstanceId(processInstanceId);
// dataHistoryService.saveData(dataHistory);
// }
}
initDataHistory(event);
}
public void initDataHistory(DelegateExecution execution){
public void initDataHistory(FlowableEngineEvent event){
//页面ID
String formKey;
//页面信息
FormPage page = null;
if (execution.getCurrentFlowElement() instanceof UserTask){
UserTask userTask = (UserTask) execution.getCurrentFlowElement();
String formKey = userTask.getFormKey();
//查询出这个节点的页面
page = formPageService.getPage(Integer.valueOf(formKey));
}else
if (execution.getCurrentFlowElement() instanceof StartEvent){
StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
String formKey = startEvent.getFormKey();
//查询出这个节点的页面
page = formPageService.getPage(Integer.valueOf(formKey));
//流程信息
FlowsInfo flowsInfo;
//执行节点信息
DelegateExecution execution;
//流程执行用户
String taskAssign = "";
//流程发起人
String businessKey = "";
//流程实例
HistoricProcessInstance historicProcessInstance;
//processKey
String processKey;
//任务名称
String taskName;
//节点类型
String activityType;
if (event instanceof FlowableActivityEventImpl){
//从这里取出了startEvent开始事件的信息
execution = ((FlowableActivityEventImpl) event).getExecution();
if (execution.getCurrentFlowElement() instanceof StartEvent){
StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
formKey = startEvent.getFormKey();
//查出这个节点的流程实例信息(获取流程发起的用户)
historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(execution.getProcessInstanceId())
.list().get(0);
taskAssign = historicProcessInstance.getBusinessKey();
businessKey = historicProcessInstance.getBusinessKey();
taskName = startEvent.getName();
activityType = "StartEvent";
}else {
return;
}
}else if (event instanceof FlowableEntityWithVariablesEventImpl){
//从这里取出了UserTask用户任务的信息
execution = ((FlowableEntityWithVariablesEventImpl) event).getExecution();
if (execution.getCurrentFlowElement() instanceof UserTask){
UserTask userTask = (UserTask) execution.getCurrentFlowElement();
formKey = userTask.getFormKey();
//查询出这个节点的页面
page = formPageService.getPage(Integer.valueOf(formKey));
//查出这个这个任务的执行人
taskAssign = ((TaskEntityImpl)((FlowableEntityWithVariablesEventImpl) event).getEntity()).getAssignee();
//查出这个节点的流程实例信息(获取流程发起的用户)
historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(execution.getProcessInstanceId())
.list().get(0);
businessKey = historicProcessInstance.getBusinessKey();
taskName = userTask.getName();
activityType = "UserTask";
}else {
return;
}
}else {
return;
}
DataHistory dataHistory = new DataHistory();
//获取processKey
processKey = historicProcessInstance.getProcessDefinitionKey();
//查询出这个节点的页面
page = formPageService.getPage(Integer.valueOf(formKey));
//查出这个节点内的临时数据
Map<String, Object> variables = execution.getVariables();
DataHistory dataHistory = new DataHistory();
//设置processInstanceId
dataHistory.setProcessInstanceId(execution.getProcessInstanceId());
//设置节点Id
//设置执行Id
dataHistory.setExecutionId(execution.getId());
dataHistory.setProcessInstanceId(execution.getProcessInstanceId());
//设置节点ID
dataHistory.setActivityId(execution.getCurrentFlowElement().getId());
//生成查询索引字符串
dataHistory.setUniqueString(DataHistory.initUniqueString(dataHistory.getExecutionId(),dataHistory.getProcessInstanceId(),dataHistory.getActivityId()));
//生成索引JSON 预留字段以后方便前端使用
dataHistory.setIndexKey(initDataHistoryIndexKey(dataHistory));
//下面试一下前端的内容
dataHistory.setTaskName(taskName);
dataHistory.setActivityType(activityType);
dataHistory.setJs(page.getJs());
dataHistory.setCss(page.getCss());
dataHistory.setTemplate(page.getTemplate());
dataHistory.setDescFile(page.getDescFile());
dataHistory.setDatas(JSONObject.toJSONString(variables));
dataHistory.setIndexKey(initDataHistoryIndexKey(dataHistory));
dataHistory.setProcessKey(processKey);
dataHistory.setStartTime(((ExecutionEntityImpl) execution).getStartTime());
dataHistory.setEndTime(new Date());
//拼接用户信息
dataHistory.setTaskAssign(taskAssign);
dataHistory.setBusinessKey(businessKey);
if (StringUtils.isEmpty(dataHistory.getProcessKey())){
System.out.println("1");
}
//保存下来
dataHistoryService.save(dataHistory);
}
public String initDataHistoryIndexKey(DataHistory dataHistory){
......
......@@ -21,6 +21,8 @@ public interface DataHistoryService {
DataHistory findByUniqueString(String uniqueString);
public Object test();
......
......@@ -2,10 +2,19 @@ package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.workflow_editer.dao.DataHistoryMapper;
import com.tykj.workflowcore.workflow_editer.entity.DataHistory;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.vo.DataHistoryVo;
import com.tykj.workflowcore.workflow_editer.service.DataHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.support.PageableExecutionUtils;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
/**
* ClassName: DataHistoryServiceImpl
* Package: com.tykj.workflowcore.workflow_editer.service.impl
......@@ -20,6 +29,9 @@ public class DataHistoryServiceImpl implements DataHistoryService {
@Autowired
private DataHistoryMapper dataHistoryMapper;
@Autowired
private EntityManager entityManager;
@Override
public DataHistory save(DataHistory dataHistory) {
return dataHistoryMapper.save(dataHistory);
......@@ -31,4 +43,16 @@ public class DataHistoryServiceImpl implements DataHistoryService {
return byUniqueString;
}
public Object test(){
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<DataHistoryVo> query = cb.createQuery(DataHistoryVo.class);
Root<DataHistory> root = query.from(DataHistory.class);
List<Selection<?>> list = new ArrayList<Selection<?>>();
list.add(root.get("uniqueString"));
Selection<?>[] selections = list.toArray(new Selection<?>[list.size()]);
query.multiselect(selections);
List<DataHistoryVo> resultList = entityManager.createQuery(query).getResultList();
return null;
}
}
......@@ -452,7 +452,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} else {
throw new ApiException(null, "流程不存在");
}
}
@Override
......@@ -505,22 +504,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override
public PageReturnVo<List<TaskHistoryReturnVo>> findHistoryTask(MyTaskSelectVo myTaskSelectVo) {
//拼接processInstance查询器
// HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery();
// historicProcessInstanceQuery.processInstanceBusinessKey(myTaskSelectVo.getUserId());
// List<HistoricProcessInstance> myStartProcessInstance = historicProcessInstanceQuery.list();
// //根据processInstance查询出所有开始节点的信息
// List<HistoricActivityInstance> userHistoricStartActivityInstance = new ArrayList<>();
// for (HistoricProcessInstance historicProcessInstance : myStartProcessInstance) {
// HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
// historicActivityInstanceQuery.processInstanceId(historicProcessInstance.getId());
// if (!StringUtils.isEmpty(myTaskSelectVo.getTaskName())){
// }
// List<HistoricActivityInstance> startEvent = historyService.createHistoricActivityInstanceQuery()
// .processInstanceId(historicProcessInstance.getId())
// .activityType("startEvent")
// .list();
// }
//由于这里存在两种数据的查询 无法正常分页 所以需要一点特殊的手段
//前区的偏移
long offset1 = 0;
......@@ -587,6 +570,12 @@ public class WorkFlowServiceImpl implements WorkFlowService {
taskHistoryReturnVo.setCreateUser(centerUserService.findById(historicProcessInstance.getBusinessKey()).getRealName());
taskHistoryReturnVo.setId(historicActivityInstance.getId());
taskHistoryReturnVo.setProcessInstanceId(historicProcessInstance.getId());
if (historicProcessInstance.getEndTime()!=null){
taskHistoryReturnVo.setState(0);
}else{
taskHistoryReturnVo.setState(1);
}
taskHistoryReturnVoList.add(taskHistoryReturnVo);
}
//查出我执行的任务,并添加到最后返回的列表
......@@ -628,18 +617,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
taskHistoryReturnVo.setProcessInstanceId(historicProcessInstance.getId());
taskHistoryReturnVoList.add(taskHistoryReturnVo);
}
// List<HistoricActivityInstance> taskInstanceList =
// historyService
// .createHistoricActivityInstanceQuery()
// .taskAssignee(userService.getCurrentUser().getId()+"")
// .finished()
// .orderByHistoricActivityInstanceStartTime()
// .desc()
// .list();
// ArrayList<Object> arrayList = new ArrayList<>();
// arrayList.addAll(taskInstanceList);
return new PageReturnVo<>(allCount, taskHistoryReturnVoList
);
......
......@@ -4,8 +4,8 @@ spring:
time-zone: GMT+8
datasource:
username: root
password: Huang123+
url: jdbc:mysql://47.106.142.73:3306/www2?useSSL=true&verifyServerCertificate=false&useUnicode=true&autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
password: root
url: jdbc:mysql://192.168.100.248:3306/workflow?useSSL=true&verifyServerCertificate=false&useUnicode=true&autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
read-only: false
......@@ -23,18 +23,8 @@ spring:
physical-strategy: com.tykj.workflowcore.base.config.ToUpperCase
ddl-auto: update
database-platform: org.hibernate.dialect.MySQL8Dialect
application:
name: workflow
sync:
ip: 192.168.102.171
ip: 192.168.102.248
port: 8880
server:
port: 8088
eureka:
instance:
prefer-ip-address: true
lease-expiration-duration-in-seconds: 3
lease-renewal-interval-in-seconds: 7
client:
service-url:
defaultZone: http://192.168.100.248:1111/eureka/
port: 13765
spring:
profiles:
active: mysql
application:
name: workflow
jwt:
header: Authorization
tokenStartWith: Bearer
base64Secret: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJb8U08NrX0XplcemWh2JiJ7O6274GmqnYkH0zKpp7FE3xmmeSJ9tcSij9s8RK4HRxUlBQLsAzsS9+ZDRbdtGz+ITmGTRmidpWAR61tX8AaB/PrRWAWHLrMr7keMN6B9aUVxCXm58j5HO2d77OoIvpC6SzwH1E1xtu8lk51kxJSvAgMBAAECgYBh5EkzWR/hmgLMO1elZe0FsDaaRtSSTf+Dx+ID2AGUqp2nqMqjNTQzwF5a+3FgD/HjYLQmF9VkaMD3tygta/0crQyNJwv82xKxXYq8TmHvkVx8XDgWzWzSwQSVSBjvc+Cvg5FNC6p1xVZxtXqacHEXBlpcMu6TvZNu+vh07Uq1iQJBANc8cCNV7MdT5bFBYimSGSnGPfvkTHxDzmtzS577Ro9EXDdPKJQfJCN3CWv4l5ub/u20uLCLEzl0uzETxG/nzNsCQQCzlMCh+wcZpe/od+6nsvGGJYhPsttL7W3OG0KbCbvMXkhsAw6JpxBtz4Thb1rihnIpBjKTocB5wNKrjGXUezW9AkBHUcuGqe4vjmlJ9vRj+flEkl/vm5KMiptXl3izUWfsCSbVXPGBQ2BiMAt7L4BtG5+5fGzGcw8HttpgRMCOpCyJAkEApT6e1y5XhTlU/fPGDlgxuL+2o6ev9TkADmS1MFaPkWm8eG+DpBSvoGwRGSPPXJxcVfWW+pQfuak98Y8acKADfQJBAL4UcsTdfkwycQqnCJepOyJtqxW8HHo8raqC0b8D2UGvmoPE3/fCVhdco8yBdrvvWErMEz+PxGwZS4VkPezSs0w=
tokenValidityInSeconds: 43200000
eureka:
instance:
prefer-ip-address: true
lease-expiration-duration-in-seconds: 3
lease-renewal-interval-in-seconds: 7
client:
service-url:
defaultZone: http://192.168.100.248:1111/eureka/
server:
servlet:
session:
cookie:
name: workflow1
\ No newline at end of file
<!doctype html><html lang="zh"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=0,maximum-scale=0,user-scalable=yes,shrink-to-fit=no"><link rel="icon" href="favicon.ico"><title>workFlow</title><style>.pre-loader{position:absolute;top:calc(50% - 32px);left:calc(50% - 32px);width:64px;height:64px;border-radius:50%;perspective:800px}.pre-loader .inner{position:absolute;box-sizing:border-box;width:100%;height:100%;border-radius:50%}.pre-loader .inner.one{left:0;top:0;-webkit-animation:rotate-one 1s linear infinite;animation:rotate-one 1s linear infinite;border-bottom:3px solid #bc9048}.pre-loader .inner.two{right:0;top:0;-webkit-animation:rotate-two 1s linear infinite;animation:rotate-two 1s linear infinite;border-right:3px solid #74aeff}.pre-loader .inner.three{right:0;bottom:0;-webkit-animation:rotate-three 1s linear infinite;animation:rotate-three 1s linear infinite;border-top:3px solid #caef74}@keyframes rotate-one{0%{-webkit-transform:rotateX(35deg) rotateY(-45deg) rotateZ(0);transform:rotateX(35deg) rotateY(-45deg) rotateZ(0)}100%{-webkit-transform:rotateX(35deg) rotateY(-45deg) rotateZ(360deg);transform:rotateX(35deg) rotateY(-45deg) rotateZ(360deg)}}@keyframes rotate-two{0%{-webkit-transform:rotateX(50deg) rotateY(10deg) rotateZ(0);transform:rotateX(50deg) rotateY(10deg) rotateZ(0)}100%{-webkit-transform:rotateX(50deg) rotateY(10deg) rotateZ(360deg);transform:rotateX(50deg) rotateY(10deg) rotateZ(360deg)}}@keyframes rotate-three{0%{-webkit-transform:rotateX(35deg) rotateY(55deg) rotateZ(0);transform:rotateX(35deg) rotateY(55deg) rotateZ(0)}100%{-webkit-transform:rotateX(35deg) rotateY(55deg) rotateZ(360deg);transform:rotateX(35deg) rotateY(55deg) rotateZ(360deg)}}</style><link href="https://lib.baomitu.com/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet"><link href="https://lib.baomitu.com/monaco-editor/0.19.3/min/vs/editor/editor.main.css" rel="stylesheet"><script src="https://lib.baomitu.com/vue/2.6.11/vue.min.js"></script><script src="https://lib.baomitu.com/vue-router/3.1.3/vue-router.min.js"></script><script src="https://lib.baomitu.com/element-ui/2.13.2/index.js"></script><link href="css/chunk-02a5a3a9.5ca0b091.css" rel="prefetch"><link href="css/chunk-18e0ea77.04c9f0cf.css" rel="prefetch"><link href="css/chunk-29fd0152.5ca0b091.css" rel="prefetch"><link href="css/chunk-3006e7c0.263a45f1.css" rel="prefetch"><link href="css/chunk-30179e6c.f89cccc5.css" rel="prefetch"><link href="css/chunk-358e2103.ad6bf27a.css" rel="prefetch"><link href="css/chunk-525fc2d8.84a55126.css" rel="prefetch"><link href="css/chunk-5a68d65e.265b8789.css" rel="prefetch"><link href="css/chunk-5b2534c0.404c0fca.css" rel="prefetch"><link href="css/chunk-6aa30806.5ca0b091.css" rel="prefetch"><link href="css/chunk-7c52297c.61b80532.css" rel="prefetch"><link href="css/chunk-e78c3d4c.2ab27357.css" rel="prefetch"><link href="css/parser-home.b5026cff.css" rel="prefetch"><link href="css/tinymce-example.0e433876.css" rel="prefetch"><link href="js/chunk-02a5a3a9.78f2297b.js" rel="prefetch"><link href="js/chunk-18e0ea77.71a934e6.js" rel="prefetch"><link href="js/chunk-29fd0152.ac2e6d8a.js" rel="prefetch"><link href="js/chunk-3006e7c0.3c1f4d0c.js" rel="prefetch"><link href="js/chunk-30179e6c.485a62e2.js" rel="prefetch"><link href="js/chunk-358e2103.62d5b25a.js" rel="prefetch"><link href="js/chunk-525fc2d8.4b415298.js" rel="prefetch"><link href="js/chunk-5a68d65e.33db689d.js" rel="prefetch"><link href="js/chunk-5b2534c0.a0d64759.js" rel="prefetch"><link href="js/chunk-6aa30806.fc92c339.js" rel="prefetch"><link href="js/chunk-7c52297c.c0a80b51.js" rel="prefetch"><link href="js/chunk-e78c3d4c.09ead955.js" rel="prefetch"><link href="js/chunk-fec0be80.46ae2c64.js" rel="prefetch"><link href="js/parser-home.1cbe416e.js" rel="prefetch"><link href="js/tinymce-example.0f8d90cb.js" rel="prefetch"><link href="css/index.4307d532.css" rel="preload" as="style"><link href="js/chunk-vendors.0fa4ad9a.js" rel="preload" as="script"><link href="js/index.f19c1f4f.js" rel="preload" as="script"><link href="css/index.4307d532.css" rel="stylesheet"></head><body><noscript><strong>抱歉,javascript被禁用,请开启后重试。</strong></noscript><div id="app"></div><div class="pre-loader" id="pre-loader"><div class="inner one"></div><div class="inner two"></div><div class="inner three"></div></div><script src="js/chunk-vendors.0fa4ad9a.js"></script><script src="js/index.f19c1f4f.js"></script></body></html>
\ No newline at end of file
<!doctype html><html lang="zh"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=0,maximum-scale=0,user-scalable=yes,shrink-to-fit=no"><link rel="icon" href="favicon.ico"><title>workFlow</title><style>.pre-loader{position:absolute;top:calc(50% - 32px);left:calc(50% - 32px);width:64px;height:64px;border-radius:50%;perspective:800px}.pre-loader .inner{position:absolute;box-sizing:border-box;width:100%;height:100%;border-radius:50%}.pre-loader .inner.one{left:0;top:0;-webkit-animation:rotate-one 1s linear infinite;animation:rotate-one 1s linear infinite;border-bottom:3px solid #bc9048}.pre-loader .inner.two{right:0;top:0;-webkit-animation:rotate-two 1s linear infinite;animation:rotate-two 1s linear infinite;border-right:3px solid #74aeff}.pre-loader .inner.three{right:0;bottom:0;-webkit-animation:rotate-three 1s linear infinite;animation:rotate-three 1s linear infinite;border-top:3px solid #caef74}@keyframes rotate-one{0%{-webkit-transform:rotateX(35deg) rotateY(-45deg) rotateZ(0);transform:rotateX(35deg) rotateY(-45deg) rotateZ(0)}100%{-webkit-transform:rotateX(35deg) rotateY(-45deg) rotateZ(360deg);transform:rotateX(35deg) rotateY(-45deg) rotateZ(360deg)}}@keyframes rotate-two{0%{-webkit-transform:rotateX(50deg) rotateY(10deg) rotateZ(0);transform:rotateX(50deg) rotateY(10deg) rotateZ(0)}100%{-webkit-transform:rotateX(50deg) rotateY(10deg) rotateZ(360deg);transform:rotateX(50deg) rotateY(10deg) rotateZ(360deg)}}@keyframes rotate-three{0%{-webkit-transform:rotateX(35deg) rotateY(55deg) rotateZ(0);transform:rotateX(35deg) rotateY(55deg) rotateZ(0)}100%{-webkit-transform:rotateX(35deg) rotateY(55deg) rotateZ(360deg);transform:rotateX(35deg) rotateY(55deg) rotateZ(360deg)}}</style><link href="https://lib.baomitu.com/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet"><link href="https://lib.baomitu.com/monaco-editor/0.19.3/min/vs/editor/editor.main.css" rel="stylesheet"><script src="https://lib.baomitu.com/vue/2.6.11/vue.min.js"></script><script src="https://lib.baomitu.com/vue-router/3.1.3/vue-router.min.js"></script><script src="https://lib.baomitu.com/element-ui/2.13.2/index.js"></script><link href="css/chunk-02a5a3a9.5ca0b091.css" rel="prefetch"><link href="css/chunk-18e0ea77.04c9f0cf.css" rel="prefetch"><link href="css/chunk-29fd0152.5ca0b091.css" rel="prefetch"><link href="css/chunk-3006e7c0.263a45f1.css" rel="prefetch"><link href="css/chunk-30179e6c.f89cccc5.css" rel="prefetch"><link href="css/chunk-525fc2d8.84a55126.css" rel="prefetch"><link href="css/chunk-5a68d65e.265b8789.css" rel="prefetch"><link href="css/chunk-5b2534c0.404c0fca.css" rel="prefetch"><link href="css/chunk-6aa30806.5ca0b091.css" rel="prefetch"><link href="css/chunk-7c52297c.61b80532.css" rel="prefetch"><link href="css/chunk-d57021c4.e910a08a.css" rel="prefetch"><link href="css/chunk-e78c3d4c.2ab27357.css" rel="prefetch"><link href="css/parser-home.49a6f01c.css" rel="prefetch"><link href="js/chunk-02a5a3a9.78f2297b.js" rel="prefetch"><link href="js/chunk-18e0ea77.71a934e6.js" rel="prefetch"><link href="js/chunk-29fd0152.ac2e6d8a.js" rel="prefetch"><link href="js/chunk-3006e7c0.f130947b.js" rel="prefetch"><link href="js/chunk-30179e6c.485a62e2.js" rel="prefetch"><link href="js/chunk-525fc2d8.4b415298.js" rel="prefetch"><link href="js/chunk-5a68d65e.33db689d.js" rel="prefetch"><link href="js/chunk-5b2534c0.a0d64759.js" rel="prefetch"><link href="js/chunk-6aa30806.b84291da.js" rel="prefetch"><link href="js/chunk-7c52297c.c0a80b51.js" rel="prefetch"><link href="js/chunk-d57021c4.30f0b978.js" rel="prefetch"><link href="js/chunk-e78c3d4c.d6819a29.js" rel="prefetch"><link href="js/parser-home.b9b583f2.js" rel="prefetch"><link href="css/index.4307d532.css" rel="preload" as="style"><link href="js/chunk-vendors.0fa4ad9a.js" rel="preload" as="script"><link href="js/index.ed799595.js" rel="preload" as="script"><link href="css/index.4307d532.css" rel="stylesheet"></head><body><noscript><strong>抱歉,javascript被禁用,请开启后重试。</strong></noscript><div id="app"></div><div class="pre-loader" id="pre-loader"><div class="inner one"></div><div class="inner two"></div><div class="inner three"></div></div><script src="js/chunk-vendors.0fa4ad9a.js"></script><script src="js/index.ed799595.js"></script></body></html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论