🔀 合并分支。

This commit is contained in:
冷冷 committed 2018-09-30 10:01:01 +08:00
commit 8b9b541cee
30 files changed
+4523 -4448

No files matched your search

+2
View File
@@ -7,3 +7,5 @@
> [代码生成使用](codegen.md)
> [社交登录使用](social.md)
> [任务监控平台搭建](elastic-job-monitor-platform.md)
+74
View File
@@ -0,0 +1,74 @@
# Elastic-Job作业监控平台搭建
## 获取源码
首先是上github下载elastic-job的源码,目前最新的地址如下: https://github.com/elasticjob/elastic-job-lite
下载前要注意源码需要和你使用的elastic-job版本一致。
![20189416555](http://p7sojn4oj.bkt.clouddn.com/20189416555.png)
1. 在你喜欢的终端应用里执行以下命令:
```bash
git clone https://github.com/elasticjob/elastic-job-lite.git
```
2. 下载完成以后cd到仓库
3. 以PigX所使用的2.1.5版本为例,执行以下命令切换到2.1.5标签的代码:
```bash
git checkout 2.1.5
```
## 编译源码
这个过程很简单,执行命令:
```bash
mvn package -DskipTests
```
## 开始使用
1. 进入/elastic-job-lite/elastic-job-lite-console/target文件夹,有一个叫做```elastic-job-lite-console-2.1.5.tar.gz```的文件就是我们需要的了。
2. 解压之,执行bin目录下的start脚本,这货默认运行在```8899```端口,以用户名:```root```和密码:```root```进行登录
3. 知道大家可能看不懂,右上角切换一波语言吧!
4. 以pigx最新的1.6.0的稳定版代码为例,查看配置中心下的```pigx-daemon-dev.yml```文件,与我们目前相关的配置文件如下:
```yml
## 定时任务
spring:
# 保存定时任务的数据源
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
elasticjob:
# 分布式任务协调依赖zookeeper
zookeeper:
server-lists: 127.0.0.1:2181
namespace: pigx-daemon
```
通过全局配置-注册中心配置,填入以下参数:
![201894174025](http://p7sojn4oj.bkt.clouddn.com/201894174025.png)
然后修改全局配置-事件追踪数据源配置,填入以下参数:
![20189417457](http://p7sojn4oj.bkt.clouddn.com/20189417457.png)
在操作处点击连接,出现已连的字样表示连接成功。
![201894174634](http://p7sojn4oj.bkt.clouddn.com/201894174634.png)
最终效果如下:
![20189418110](http://p7sojn4oj.bkt.clouddn.com/20189418110.png)
@@ -22,6 +22,7 @@ package com.pig4cloud.pigx.auth.endpoint;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.security.service.PigxUser;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
@@ -54,7 +55,7 @@ import java.util.Map;
@AllArgsConstructor
@RequestMapping("/oauth")
public class PigxTokenEndpoint {
private static final String PIGX_OAUTH_ACCESS = "pigx_oauth:access:";
private static final String PIGX_OAUTH_ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "access:";
private final TokenStore tokenStore;
private final RedisTemplate redisTemplate;
@@ -47,16 +47,6 @@ public interface CommonConstant {
*/
String MENU = "0";
/**
* 按钮
*/
String BUTTON = "1";
/**
* 删除标记
*/
String DEL_FLAG = "del_flag";
/**
* 编码
*/
@@ -66,4 +56,14 @@ public interface CommonConstant {
* JSON 资源
*/
String CONTENT_TYPE = "application/json; charset=utf-8";
/**
* 前端工程名
*/
String FRONT_END_PROJECT = "pigx-ui";
/**
* 后端工程名
*/
String BACK_END_PROJECT = "pigx";
}
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.core.constant.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author lengleng
* @date 2018/9/30
* 流程状态
*/
@Getter
@AllArgsConstructor
public enum EnumProcessStatus {
/**
* 图片资源
*/
ACTIVE("active", "图片资源"),
/**
* xml资源
*/
SUSPEND("suspend", "xml资源");
/**
* 类型
*/
private final String status;
/**
* 描述
*/
private final String description;
}
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.core.constant.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author lengleng
* @date 2018/9/30
* 资源类型
*/
@Getter
@AllArgsConstructor
public enum EnumResourceType {
/**
* 图片资源
*/
IMAGE("image", "图片资源"),
/**
* xml资源
*/
XML("xml", "xml资源");
/**
* 类型
*/
private final String type;
/**
* 描述
*/
private final String description;
}
@@ -50,6 +50,15 @@ public class SecurityUtils {
/**
* 获取用户
*
* @param authentication
* @return PigxUser
* <p>
* 获取当前用户的全部信息
* 每次check—token 后根据用户名调用 remoteService 查询用户信息,效率比较低。
* 建议长链路调用不要使用,重写configure() 例如 codegen 模块ResourceServerConfigurer
* 1.前提使用继承BaseResourceServerConfigurerAdapter
* 2. 使用默认 configure()
*/
public static PigxUser getUser(Authentication authentication) {
Object principal = authentication.getPrincipal();
@@ -59,6 +68,20 @@ public class SecurityUtils {
return null;
}
/**
* 获取当前用名
*
* @return String
*/
public static String getUsername() {
Object principal = getAuthentication().getPrincipal();
if (principal instanceof String) {
return principal.toString();
}
return null;
}
public static String getClientId() {
Authentication authentication = getAuthentication();
if (authentication instanceof OAuth2Authentication) {
@@ -17,7 +17,6 @@
package com.pig4cloud.pigx.common.swagger.config;
import cn.hutool.core.collection.CollUtil;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -34,6 +33,7 @@ import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -46,7 +46,10 @@ import java.util.List;
@EnableAutoConfiguration
public class SwaggerAutoConfiguration {
private static final String DEFAULT_EXCLUDE_PATH = "/error";
/**
* 默认的排除路径,排除Spring Boot默认的错误处理路径和端点
*/
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error","/actuator/**");
private static final String BASE_PATH = "/**";
@Bean
@@ -58,7 +61,7 @@ public class SwaggerAutoConfiguration {
@Bean
public Docket api(SwaggerProperties swaggerProperties) {
// base-path处理
if (CollUtil.isEmpty(swaggerProperties.getBasePath())) {
if (swaggerProperties.getBasePath().isEmpty()) {
swaggerProperties.getBasePath().add(BASE_PATH);
}
//noinspection unchecked
@@ -66,8 +69,8 @@ public class SwaggerAutoConfiguration {
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
// exclude-path处理
if (CollUtil.isEmpty(swaggerProperties.getExcludePath())) {
swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH);
if (swaggerProperties.getExcludePath().isEmpty()) {
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
}
List<Predicate<String>> excludePath = new ArrayList<>();
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
@@ -72,25 +72,22 @@ mybatis-plus:
#swagger公共信息
swagger:
title: 'PigX Swagger API'
description: '全宇宙最牛逼的Spring Cloud微服务开发脚手架'
version: '1.4.0'
license: 'Powered By PigX'
licenseUrl: 'https://gitee.com/log4j/pig/wikis'
terms-of-service-url: 'https://gitee.wang/pig/pigx'
exclude-path:
- /actuator/**
- /error
title: PigX Swagger API
description: 全宇宙最牛逼的Spring Cloud微服务开发脚手架
version: 1.6.2
license: Powered By PigX
licenseUrl: https://pig4cloud.com/
terms-of-service-url: https://pig4cloud.com/
contact:
name: '冷冷'
email: 'wangiegie@gmail.com'
url: 'https://gitee.wang/pig/pigx'
name: 冷冷
email: wangiegie@gmail.com
url: https://pig4cloud.com/about.html
authorization:
name: 'pigX OAuth'
auth-regex: '^.*$'
name: pigX OAuth
auth-regex: ^.*$
authorization-scope-list:
- scope: 'server'
description: 'server all'
- scope: server
description: server all
token-url-list:
- ${security.auth.server}/token
@@ -19,28 +19,3 @@ spring:
date-format: yyyy-MM-dd HH:mm:ss
resources:
static-locations: classpath:/static/,classpath:/views/
# mybaits 模块配置
mybatis-plus:
typeAliasesPackage: com.pig4cloud.pigx.codegen.entity
#mybaits-plus配置,修改主键类型,mapper.xml、type 别名等
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 0
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 1
#驼峰下划线转换
db-column-underline: true
#刷新mapper 调试神器
refresh-mapper: false
# 逻辑删除字段
logic-delete-value: 1
logic-not-delete-value: 0
#自定义SQL注入器
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
@@ -15,10 +15,6 @@ spring:
password: Bjyjht2017!@#
url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
# mybaits 模块配置
mybatis-plus:
typeAliasesPackage: com.pig4cloud.pigx.admin.api.entity
# swagger相关配置,覆盖全局配置
swagger:
authorization:
@@ -71,7 +71,6 @@ public class DictController {
*/
@GetMapping("/dictPage")
public Page dictPage(@RequestParam Map<String, Object> params) {
params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL);
return sysDictService.selectPage(new Query<>(params), new EntityWrapper<>());
}
@@ -25,7 +25,6 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.admin.api.entity.SysLog;
import com.pig4cloud.pigx.admin.api.vo.PreLogVo;
import com.pig4cloud.pigx.admin.service.SysLogService;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import lombok.AllArgsConstructor;
@@ -58,7 +57,6 @@ public class LogController {
*/
@GetMapping("/logPage")
public Page logPage(@RequestParam Map<String, Object> params) {
params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL);
return sysLogService.selectPage(new Query<>(params), new EntityWrapper<>());
}
@@ -110,7 +110,6 @@ public class RoleController {
*/
@GetMapping("/rolePage")
public Page rolePage(@RequestParam Map<String, Object> params) {
params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL);
return sysRoleService.selectwithDeptPage(new Query<>(params), new EntityWrapper<>());
}
+25
View File
@@ -59,12 +59,32 @@
<groupId>org.activiti</groupId>
<artifactId>activiti-modeler</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-diagram-rest</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--web 模块-->
<dependency>
@@ -78,6 +98,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -17,9 +17,9 @@
package com.pig4cloud.pigx.act;
import org.activiti.spring.boot.SecurityAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -28,9 +28,9 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
* @date 2018/9/25
* 工作流管理模块
*/
@EnableDiscoveryClient
@EnableCircuitBreaker
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class,org.activiti.spring.boot.SecurityAutoConfiguration.class})
@EnableDiscoveryClient
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class PigxActivitiApplication {
public static void main(String[] args) {
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.act.config;
import com.pig4cloud.pigx.common.security.component.BaseResourceServerConfigurerAdapter;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
/**
* @author lengleng
* @date 2018/6/22
*/
@Configuration
@EnableResourceServer
@AllArgsConstructor
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.headers().frameOptions().disable()
.and().authorizeRequests()
.antMatchers("/actuator/**"
, "/v2/api-docs"
, "/service/**"
, "/editor-app/**"
,"/task/view/*"
,"/process/resource/*/*/image"
, "/modeler.html").permitAll()
.anyRequest().authenticated()
.and().csrf().disable();
}
/**
* 重写抽象类实现,不需要调用feign 获取 userdetils
*
* @param resources
*/
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
.accessDeniedHandler(pigAccessDeniedHandler);
}
}
@@ -21,9 +21,13 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.act.dto.LeaveBillDto;
import com.pig4cloud.pigx.act.service.ActTaskService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
/**
@@ -38,7 +42,7 @@ public class TaskController {
@GetMapping("/todo")
public Page todo(@RequestParam Map<String, Object> params) {
return actTaskService.findTaskByName(params, "lengleng");
return actTaskService.findTaskByName(params, SecurityUtils.getUsername());
}
@GetMapping("/{id}")
@@ -52,8 +56,13 @@ public class TaskController {
}
@GetMapping("/view/{id}")
public R viewCurrentImage(@PathVariable String id) {
return new R(actTaskService.findProcessDefinitionByTaskId(id));
public void viewCurrentImage(@PathVariable String id, HttpServletResponse resp) throws IOException {
InputStream imageStream = actTaskService.viewByTaskId(id);
byte[] b = new byte[1024];
int len;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
resp.getOutputStream().write(b, 0, len);
}
}
@GetMapping("/comment/{id}")
@@ -61,4 +70,5 @@ public class TaskController {
return new R(actTaskService.findCommentByTaskId(id));
}
}
@@ -28,6 +28,6 @@ import org.activiti.engine.delegate.TaskListener;
public class LeaveProcessTaskListener implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.addCandidateUser("lengleng");
delegateTask.addCandidateUser("admin");
}
}
@@ -20,8 +20,8 @@ package com.pig4cloud.pigx.act.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.act.dto.CommentDto;
import com.pig4cloud.pigx.act.dto.LeaveBillDto;
import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@@ -57,14 +57,6 @@ public interface ActTaskService {
*/
Boolean submitTask(LeaveBillDto leaveBillDto);
/**
* 根据 taskId 查询 流程定义 (活动任务坐标)
*
* @param taskId
* @return
*/
ProcessDefDTO findProcessDefinitionByTaskId(String taskId);
/**
* 通过任务ID 查询批注信息
*
@@ -72,4 +64,12 @@ public interface ActTaskService {
* @return
*/
List<CommentDto> findCommentByTaskId(String taskId);
/**
* 追踪图片节点
*
* @param id
* @return
*/
InputStream viewByTaskId(String id);
}
@@ -22,30 +22,32 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.act.dto.CommentDto;
import com.pig4cloud.pigx.act.dto.LeaveBillDto;
import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
import com.pig4cloud.pigx.act.dto.TaskDTO;
import com.pig4cloud.pigx.act.entity.LeaveBill;
import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
import com.pig4cloud.pigx.act.service.ActTaskService;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.*;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.activiti.image.ProcessDiagramGenerator;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -61,6 +63,8 @@ public class ActTaskServiceImpl implements ActTaskService {
private final TaskService taskService;
private final RuntimeService runtimeService;
private final RepositoryService repositoryService;
private final HistoryService historyService;
private final ProcessEngineFactoryBean processEngine;
@Override
public Page findTaskByName(Map<String, Object> params, String name) {
@@ -107,15 +111,14 @@ public class ActTaskServiceImpl implements ActTaskService {
.processInstanceId(processInstanceId)
.singleResult();
//4:使用流程实例对象获取BUSINESS_KEY
String buniness_key = pi.getBusinessKey();
String businessKey = pi.getBusinessKey();
//5:获取BUSINESS_KEY对应的主键ID,使用主键ID,查询请假单对象(LeaveBill.1)
String id = "";
if (StrUtil.isNotBlank(buniness_key)) {
if (StrUtil.isNotBlank(businessKey)) {
//截取字符串,取buniness_key小数点的第2个值
id = buniness_key.split("\\.")[1];
businessKey = businessKey.split("_")[1];
}
//查询请假单对象
LeaveBill leaveBill = leaveBillMapper.selectById(id);
LeaveBill leaveBill = leaveBillMapper.selectById(businessKey);
LeaveBillDto leaveBillDto = new LeaveBillDto();
BeanUtils.copyProperties(leaveBill, leaveBillDto);
@@ -138,7 +141,7 @@ public class ActTaskServiceImpl implements ActTaskService {
String message = leaveBillDto.getComment();
//获取请假单ID
Integer id = leaveBillDto.getLeaveId();
//1:在完成之前,添加一个批注信息,向act_hi_comment表中添加数据,用于记录对当前申请人的一些审核信息
//添加一个批注信息,向act_hi_comment表中添加数据,用于记录对当前申请人的一些审核信息
Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
@@ -146,28 +149,13 @@ public class ActTaskServiceImpl implements ActTaskService {
String processInstanceId = task.getProcessInstanceId();
// 设置批注用户
Authentication.setAuthenticatedUserId("lengleng");
Authentication.setAuthenticatedUserId(SecurityUtils.getUsername());
taskService.addComment(taskId, processInstanceId, message);
/**
* 2:如果连线的名称是“默认提交”,那么就不需要设置,如果不是,就需要设置流程变量
* 在完成任务之前,设置流程变量,按照连线的名称,去完成任务
流程变量的名称:outcome
流程变量的值:连线的名称
*/
Map<String, Object> variables = new HashMap<String, Object>();
String outcome = "";
if (outcome != null && !outcome.equals("默认提交")) {
variables.put("outcome", outcome);
}
//3:使用任务ID,完成当前人的个人任务,同时流程变量
taskService.complete(taskId, variables);
//4:当任务完成之后,需要指定下一个任务的办理人(使用类)-----已经开发完成
//使用任务ID,完成当前人的个人任务
taskService.complete(taskId);
/**
* 5:在完成任务之后,判断流程是否结束
如果流程结束了,更新请假单表的状态从1变成2(审核中-->审核完成)
*/
//在完成任务之后,判断流程是否结束
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
@@ -181,47 +169,6 @@ public class ActTaskServiceImpl implements ActTaskService {
return null;
}
/**
* 根据 taskId 查询 流程定义 (活动任务坐标)
*
* @param taskId
* @return
*/
@Override
public ProcessDefDTO findProcessDefinitionByTaskId(String taskId) {
//使用任务ID,查询任务对象
Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
//获取流程定义ID
String processDefinitionId = task.getProcessDefinitionId();
//查询流程定义的对象act_re_procdef
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId)
.singleResult();
//获取流程定义的实体对象(对应.bpmn文件中的数据)
ProcessDefinitionEntity processDefinitionEntity =
(ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId);
//使用流程实例ID,查询正在执行的执行对象表,获取当前活动对应的流程实例对象
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
.processInstanceId(task.getProcessInstanceId())
.singleResult();
//获取当前活动对象
ActivityImpl activityImpl = processDefinitionEntity.findActivity(pi.getActivityId());
Deployment deployment = repositoryService.createDeploymentQuery()
.deploymentId(processDefinition.getDeploymentId()).singleResult();
ProcessDefDTO processDefDTO = ProcessDefDTO.toProcessDefDTO(processDefinition, deployment);
processDefDTO.setXAxis(activityImpl.getX());
processDefDTO.setYAxis(activityImpl.getY());
processDefDTO.setWidth(activityImpl.getWidth());
processDefDTO.setHeight(activityImpl.getWidth());
return processDefDTO;
}
@Override
public List<CommentDto> findCommentByTaskId(String taskId) {
//使用当前的任务ID,查询当前流程对应的历史任务ID
@@ -247,4 +194,48 @@ public class ActTaskServiceImpl implements ActTaskService {
return commentDtoList;
}
/**
* 追踪图片节点
*
* @param id
*/
@Override
public InputStream viewByTaskId(String id) {
//使用当前任务ID,获取当前任务对象
Task task = taskService.createTaskQuery()
.taskId(id)
.singleResult();
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
HistoricProcessInstance historicProcessInstance =
historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
String processDefinitionId = null;
List<String> executedActivityIdList = new ArrayList<>();
if (processInstance != null) {
processDefinitionId = processInstance.getProcessDefinitionId();
executedActivityIdList = this.runtimeService.getActiveActivityIds(processInstance.getId());
} else if (historicProcessInstance != null) {
processDefinitionId = historicProcessInstance.getProcessDefinitionId();
List<HistoricActivityInstance> historicActivityInstanceList =
historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceId().asc().list();
for (HistoricActivityInstance activityInstance : historicActivityInstanceList) {
executedActivityIdList.add(activityInstance.getActivityId());
}
}
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
return diagramGenerator.generateDiagram(
bpmnModel, "png",
executedActivityIdList, Collections.emptyList(),
processEngine.getProcessEngineConfiguration().getActivityFontName(),
processEngine.getProcessEngineConfiguration().getLabelFontName(),
"宋体",
null, 1.0);
}
}
@@ -112,15 +112,7 @@ public class EditorServiceImpl implements EditorService {
model.setName(name);
repositoryService.saveModel(model);
repositoryService.addModelEditorSource(model.getId(), jsonXml.getBytes(CharsetUtil.UTF_8));
InputStream svgStream = new ByteArrayInputStream(svgXml.getBytes(CharsetUtil.UTF_8));
TranscoderInput input = new TranscoderInput(svgStream);
// Setup output
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
TranscoderOutput output = new TranscoderOutput(outStream);
// PNGTranscoder transcoder = new PNGTranscoder();
// Do the transformation
// transcoder.transcode(input, output);
final byte[] result = outStream.toByteArray();
repositoryService.addModelEditorSourceExtra(model.getId(), result);
outStream.close();
@@ -48,6 +48,7 @@ import java.util.Map;
@Service
@AllArgsConstructor
public class ModelServiceImpl implements ModelService {
private static final String BPMN20_XML = ".bpmn20.xml";
private final RepositoryService repositoryService;
private final ObjectMapper objectMapper;
@@ -77,7 +78,9 @@ public class ModelServiceImpl implements ModelService {
model.setKey(key);
model.setName(name);
model.setCategory(category);
model.setVersion(Integer.parseInt(String.valueOf(repositoryService.createModelQuery().modelKey(model.getKey()).count() + 1)));
model.setVersion(Integer.parseInt(
String.valueOf(repositoryService.createModelQuery()
.modelKey(model.getKey()).count() + 1)));
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
@@ -144,11 +147,12 @@ public class ModelServiceImpl implements ModelService {
BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(objectNode);
String processName = model.getName();
if (!StrUtil.endWithIgnoreCase(processName, ".bpmn20.xml")) {
processName += ".bpmn20.xml";
if (!StrUtil.endWithIgnoreCase(processName, BPMN20_XML)) {
processName += BPMN20_XML;
}
// 部署流程
Deployment deployment = repositoryService.createDeployment().name(model.getName())
Deployment deployment = repositoryService
.createDeployment().name(model.getName())
.addBpmnModel(processName, bpmnModel)
.deploy();
@@ -158,7 +162,7 @@ public class ModelServiceImpl implements ModelService {
list.stream().forEach(processDefinition ->
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), model.getCategory()));
} catch (Exception e) {
log.error("部署失败,异常",e);
log.error("部署失败,异常", e);
}
return Boolean.TRUE;
}
@@ -24,6 +24,8 @@ import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
import com.pig4cloud.pigx.act.entity.LeaveBill;
import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
import com.pig4cloud.pigx.act.service.ProcessService;
import com.pig4cloud.pigx.common.core.constant.enums.EnumProcessStatus;
import com.pig4cloud.pigx.common.core.constant.enums.EnumResourceType;
import lombok.AllArgsConstructor;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
@@ -35,7 +37,6 @@ import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -94,19 +95,26 @@ public class ProcessServiceImpl implements ProcessService {
public InputStream resourceRead(String procDefId, String proInsId, String resType) {
if (StrUtil.isBlank(procDefId)) {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(proInsId).singleResult();
ProcessInstance processInstance = runtimeService
.createProcessInstanceQuery()
.processInstanceId(proInsId)
.singleResult();
procDefId = processInstance.getProcessDefinitionId();
}
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery()
.processDefinitionId(procDefId)
.singleResult();
String resourceName = "";
if (resType.equals("image")) {
if (EnumResourceType.IMAGE.getType().equals(resType)) {
resourceName = processDefinition.getDiagramResourceName();
} else if (resType.equals("xml")) {
} else if (EnumResourceType.XML.getType().equals(resType)) {
resourceName = processDefinition.getResourceName();
}
InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
InputStream resourceAsStream = repositoryService
.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
return resourceAsStream;
}
@@ -119,9 +127,9 @@ public class ProcessServiceImpl implements ProcessService {
*/
@Override
public Boolean updateStatus(String status, String procDefId) {
if (status.equals("active")) {
if (EnumProcessStatus.ACTIVE.getStatus().equals(status)) {
repositoryService.activateProcessDefinitionById(procDefId, true, null);
} else if (status.equals("suspend")) {
} else if (EnumProcessStatus.SUSPEND.getStatus().equals(status)) {
repositoryService.suspendProcessDefinitionById(procDefId, true, null);
}
return Boolean.TRUE;
@@ -150,25 +158,12 @@ public class ProcessServiceImpl implements ProcessService {
//1:获取请假单ID,使用请假单ID,查询请假单的对象LeaveBill
LeaveBill leaveBill = leaveBillMapper.selectById(leaveId);
leaveBill.setState("1");
//3:使用当前对象获取到流程定义的key(对象的名称就是流程定义的key)
//2:使用当前对象获取到流程定义的key(对象的名称就是流程定义的key)
String key = leaveBill.getClass().getSimpleName();
/**
* 4:从Session中获取当前任务的办理人,使用流程变量设置下一个任务的办理人
* inputUser是流程变量的名称,
* 获取的办理人是流程变量的值
*/
Map<String, Object> variables = new HashMap<>(1);
variables.put("aaaaaaa", "lengleng");
/**
* 5:
* (1)使用流程变量设置字符串(格式:LeaveBill.id的形式),通过设置,让启动的流程(流程实例)关联业务
* (2)使用正在执行对象表中的一个字段BUSINESS_KEY(Activiti提供的一个字段),让启动的流程(流程实例)关联业务
*/
//格式:LeaveBill.id的形式(使用流程变量)
String objId = key + "." + leaveBill.getLeaveId();
variables.put("objId", objId);
//6:使用流程定义的key,启动流程实例,同时设置流程变量,同时向正在执行的执行对象表中的字段BUSINESS_KEY添加业务数据,同时让流程关联业务
runtimeService.startProcessInstanceByKey(key, objId, variables);
//3: 格式:LeaveBill_id的形式(使用流程变量)
String businessKey = key + "_" + leaveBill.getLeaveId();
//4:使用流程定义的key,启动流程实例,正在执行的执行对象表中的字段BUSINESS_KEY添加业务数据,同时让流程关联业务
runtimeService.startProcessInstanceByKey(key, businessKey);
leaveBillMapper.updateById(leaveBill);
return Boolean.TRUE;
}
@@ -28,3 +28,21 @@ eureka:
client:
service-url:
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
## spring security 配置
security:
oauth2:
client:
client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)
client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)
scope: server
resource:
token-info-uri: ${security.auth.server}/check_token
auth:
server: http://192.168.0.20:9999/auth/oauth
# 加解密根密码
jasypt:
encryptor:
password: pigx #根密码
# redis 相关
File diff suppressed because it is too large. Load diff
@@ -1,93 +0,0 @@
function getcolumns() {
var c = [
{
checkbox: true
},
{
field: 'category',
title: '流程分类'
},
{
field: 'key',
title: '模型标识'
},
{
field: 'name',
title: '流程名称'
},
{
field: 'revision',
title: '版本号'
},
{
field: 'xmlName',
title: '流程XML',
align: 'center',
formatter: function (value, row, index) {
var procDefId = row.processonDefinitionId;
return '<a href=${url}resource?procDefId=' + procDefId + '&resType=xml>' + value + '</a>';
}
},
{
field: 'picName',
title: '流程图片',
align: 'center',
formatter: function (value, row, index) {
var procDefId = row.processonDefinitionId;
return '<a href=${url}resource?procDefId=' + procDefId + '&resType=image>' + value + '</a>';
}
},
{
field: 'deploymentTime',
title: '部署时间'
},
{
title: '操作',
field: 'id',
align: 'center',
formatter: function (value, row, index) {
return dt_delete_button(row)+dt_active_button(row);
}
}];
return c;
}
load_data_list(getcolumns(), {"revision": "desc"}, 'list')
function dt_delete_button(row) {
var deleteO = '<a class="btn btn-warning btn-sm" href="#" title="删除" mce_href="#" ' +
'onclick="remove(\'' + row.id + '\')">删除</a> ';
return deleteO;
}
function dt_active_button(row) {
var value = '';
var status = '';
if (row.suspend === false) {
value = '挂起';
status = 'suspend';
} else {
value = '激活'
status = 'active';
}
var procDefId = row.processonDefinitionId;
var deleteO = '<a class="btn btn-warning btn-sm" href="#" ' +
'title="挂起/激活" mce_href="#" onclick="active(\'' + procDefId + '\', \'' + status + '\')"> ' + value + ' </a> ';
return deleteO;
}
function active(procDefId, state) {
$.ajax({
url: url + "status",
type: "POST",
data: {
'procDefId': procDefId,
'status': state
},
success: function (r) {
dataTable_rep_message(r)
}
});
}
@@ -1,93 +0,0 @@
function getcolumns() {
var c = [
{
checkbox: true
},
{
field: 'category',
title: '流程分类'
},
{
field: 'applicant',
title: '申请人'
},
{
field: 'taskName',
title: '任务名称'
},
{
field: 'title',
title: '流程主题'
},
{
field: 'xmlName',
title: '流程XML',
align: 'center',
formatter: function (value, row, index) {
var procDefId = row.processonDefinitionId;
return '<a href=${url}resource?procDefId=' + procDefId + '&resType=xml>' + value + '</a>';
}
},
{
field: 'picName',
title: '流程图片',
align: 'center',
formatter: function (value, row, index) {
var procDefId = row.processonDefinitionId;
return '<a href=${url}resource?procDefId=' + procDefId + '&resType=image>' + value + '</a>';
}
},
{
field: 'deploymentTime',
title: '部署时间'
},
{
title: '操作',
field: 'id',
align: 'center',
formatter: function (value, row, index) {
return dt_delete_button(row)+dt_active_button(row);
}
}];
return c;
}
load_data_list(getcolumns(), {"revision": "desc"}, 'list')
function dt_delete_button(row) {
var deleteO = '<a class="btn btn-warning btn-sm" href="#" title="删除" mce_href="#" ' +
'onclick="remove(\'' + row.id + '\')">删除</a> ';
return deleteO;
}
function dt_active_button(row) {
var value = '';
var status = '';
if (row.suspend === false) {
value = '挂起';
status = 'suspend';
} else {
value = '激活'
status = 'active';
}
var procDefId = row.processonDefinitionId;
var deleteO = '<a class="btn btn-warning btn-sm" href="#" ' +
'title="挂起/激活" mce_href="#" onclick="active(\'' + procDefId + '\', \'' + status + '\')"> ' + value + ' </a> ';
return deleteO;
}
function active(procDefId, state) {
$.ajax({
url: url + "status",
type: "POST",
data: {
'procDefId': procDefId,
'status': state
},
success: function (r) {
dataTable_rep_message(r)
}
});
}
@@ -24,6 +24,7 @@ import cn.hutool.core.util.StrUtil;
import com.pig4cloud.pigx.codegen.entity.ColumnEntity;
import com.pig4cloud.pigx.codegen.entity.GenConfig;
import com.pig4cloud.pigx.codegen.entity.TableEntity;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.exception.CheckedException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.configuration.Configuration;
@@ -239,7 +240,7 @@ public class GenUtils {
* 获取文件名
*/
private static String getFileName(String template, String className, String packageName, String moduleName) {
String packagePath = "pigx" + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator;
String packagePath = CommonConstant.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator;
if (StringUtils.isNotBlank(packageName)) {
packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator;
}
@@ -265,7 +266,7 @@ public class GenUtils {
}
if (template.contains(MAPPER_XML_VM)) {
return "pigx" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml";
return CommonConstant.BACK_END_PROJECT + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml";
}
if (template.contains(MENU_SQL_VM)) {
@@ -273,16 +274,16 @@ public class GenUtils {
}
if (template.contains(INDEX_VUE_VM)) {
return "pigx-ui" + File.separator + "src" + File.separator + "views" +
return CommonConstant.FRONT_END_PROJECT + File.separator + "src" + File.separator + "views" +
File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + "index.vue";
}
if (template.contains(API_JS_VM)) {
return "pigx-ui" + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js";
return CommonConstant.FRONT_END_PROJECT + File.separator + "src" + File.separator + "api" + File.separator + className.toLowerCase() + ".js";
}
if (template.contains(CRUD_JS_VM)) {
return "pigx-ui" + File.separator + "src" + File.separator + "const" +
return CommonConstant.FRONT_END_PROJECT + File.separator + "src" + File.separator + "const" +
File.separator + "crud" + File.separator + className.toLowerCase() + ".js";
}
@@ -21,6 +21,3 @@ eureka:
client:
service-url:
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
logging:
level:
root: info