mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-14 06:09:03 +08:00
✨ 添加新特性。 工作流
This commit is contained in:
1 parent
8b9b541cee
commit
1d2d8f6e32
29 files changed
+251
-44
No files matched your search
@@ -38,6 +38,11 @@
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-upms-api</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
||||
+2
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.act;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
|
||||
import org.activiti.spring.boot.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
*/
|
||||
@EnableCircuitBreaker
|
||||
@EnableDiscoveryClient
|
||||
@EnablePigxFeignClients
|
||||
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
|
||||
public class PigxActivitiApplication {
|
||||
|
||||
|
||||
+4
@@ -23,8 +23,10 @@ import com.pig4cloud.pigx.act.entity.LeaveBill;
|
||||
import com.pig4cloud.pigx.act.service.ActTaskService;
|
||||
import com.pig4cloud.pigx.act.service.LeaveBillService;
|
||||
import com.pig4cloud.pigx.act.service.ProcessService;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.EnumTaskStatus;
|
||||
import com.pig4cloud.pigx.common.core.util.Query;
|
||||
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.*;
|
||||
|
||||
@@ -78,6 +80,8 @@ public class LeaveBillController {
|
||||
*/
|
||||
@PostMapping
|
||||
public R save(@RequestBody LeaveBill leaveBill) {
|
||||
leaveBill.setUsername(SecurityUtils.getUsername());
|
||||
leaveBill.setState(EnumTaskStatus.UNSUBMIT.getStatus());
|
||||
return new R<>(leaveBillService.insert(leaveBill));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.pig4cloud.pigx.act.entity.LeaveBill;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@@ -43,4 +44,11 @@ public class LeaveBillDto extends LeaveBill {
|
||||
* 批准信息
|
||||
*/
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 连线信息
|
||||
*/
|
||||
private List<String> flagList;
|
||||
|
||||
private String taskFlag;
|
||||
}
|
||||
+33
-2
@@ -17,17 +17,48 @@
|
||||
|
||||
package com.pig4cloud.pigx.act.listener;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/9/27
|
||||
* 请假流程监听器对于
|
||||
* 请假流程监听器
|
||||
*/
|
||||
@Slf4j
|
||||
public class LeaveProcessTaskListener implements TaskListener {
|
||||
|
||||
/**
|
||||
* 查询提交人的上级
|
||||
*
|
||||
* @param delegateTask
|
||||
*/
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
delegateTask.addCandidateUser("admin");
|
||||
RemoteUserService userService = SpringContextHolder.getBean(RemoteUserService.class);
|
||||
|
||||
R<List<SysUser>> result = userService.ancestorUsers(
|
||||
SecurityUtils.getUsername(), SecurityConstants.FROM_IN);
|
||||
|
||||
if (CollUtil.isEmpty(result.getData())) {
|
||||
log.error("用户 {} 不存在上级,任务单由当前用户审批", SecurityUtils.getUsername());
|
||||
delegateTask.addCandidateUser(SecurityUtils.getUsername());
|
||||
} else {
|
||||
List<String> userList = result.getData().stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
log.error("当前任务 {},由 {}处理", delegateTask.getId(), userList);
|
||||
delegateTask.addCandidateUsers(userList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+33
-6
@@ -26,6 +26,7 @@ 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.core.constant.enums.EnumTaskStatus;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -36,6 +37,8 @@ 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.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Comment;
|
||||
import org.activiti.engine.task.Task;
|
||||
@@ -46,10 +49,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@@ -59,6 +59,7 @@ import java.util.Map;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ActTaskServiceImpl implements ActTaskService {
|
||||
private static final String FLAG = "审批";
|
||||
private final LeaveBillMapper leaveBillMapper;
|
||||
private final TaskService taskService;
|
||||
private final RuntimeService runtimeService;
|
||||
@@ -117,6 +118,8 @@ public class ActTaskServiceImpl implements ActTaskService {
|
||||
//截取字符串,取buniness_key小数点的第2个值
|
||||
businessKey = businessKey.split("_")[1];
|
||||
}
|
||||
|
||||
List<String> comeList = findOutFlagListByTaskId(task, pi);
|
||||
//查询请假单对象
|
||||
LeaveBill leaveBill = leaveBillMapper.selectById(businessKey);
|
||||
|
||||
@@ -124,6 +127,7 @@ public class ActTaskServiceImpl implements ActTaskService {
|
||||
BeanUtils.copyProperties(leaveBill, leaveBillDto);
|
||||
leaveBillDto.setTaskId(taskId);
|
||||
leaveBillDto.setTime(task.getCreateTime());
|
||||
leaveBillDto.setFlagList(comeList);
|
||||
return leaveBillDto;
|
||||
}
|
||||
|
||||
@@ -152,8 +156,13 @@ public class ActTaskServiceImpl implements ActTaskService {
|
||||
Authentication.setAuthenticatedUserId(SecurityUtils.getUsername());
|
||||
taskService.addComment(taskId, processInstanceId, message);
|
||||
|
||||
Map<String, Object> variables = new HashMap<>(1);
|
||||
|
||||
if (!StrUtil.equals(FLAG, leaveBillDto.getTaskFlag())) {
|
||||
variables.put("flag", leaveBillDto.getTaskFlag());
|
||||
}
|
||||
//使用任务ID,完成当前人的个人任务
|
||||
taskService.complete(taskId);
|
||||
taskService.complete(taskId, variables);
|
||||
|
||||
//在完成任务之后,判断流程是否结束
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
|
||||
@@ -163,7 +172,9 @@ public class ActTaskServiceImpl implements ActTaskService {
|
||||
if (pi == null) {
|
||||
LeaveBill bill = new LeaveBill();
|
||||
bill.setLeaveId(id);
|
||||
bill.setState("2");
|
||||
bill.setState(StrUtil.equals(EnumTaskStatus.OVERRULE.getDescription()
|
||||
, leaveBillDto.getTaskFlag()) ? EnumTaskStatus.OVERRULE.getStatus()
|
||||
: EnumTaskStatus.COMPLETED.getStatus());
|
||||
leaveBillMapper.updateById(bill);
|
||||
}
|
||||
return null;
|
||||
@@ -238,4 +249,20 @@ public class ActTaskServiceImpl implements ActTaskService {
|
||||
null, 1.0);
|
||||
|
||||
}
|
||||
|
||||
private List<String> findOutFlagListByTaskId(Task task, ProcessInstance pi) {
|
||||
//返回存放连线的名称集合
|
||||
List<String> list = new ArrayList<>();
|
||||
//查询ProcessDefinitionEntiy对象
|
||||
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) repositoryService
|
||||
.getProcessDefinition(task.getProcessDefinitionId());
|
||||
|
||||
ActivityImpl activityImpl = processDefinitionEntity.findActivity(pi.getActivityId());
|
||||
//获取当前活动完成之后连线的名称
|
||||
activityImpl.getOutgoingTransitions().forEach(pvm -> {
|
||||
String name = (String) pvm.getProperty("name");
|
||||
list.add(StrUtil.isNotBlank(name) ? name : FLAG);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -26,6 +26,7 @@ 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 com.pig4cloud.pigx.common.core.constant.enums.EnumTaskStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
@@ -157,7 +158,7 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
public Boolean saveStartProcess(Integer leaveId) {
|
||||
//1:获取请假单ID,使用请假单ID,查询请假单的对象LeaveBill
|
||||
LeaveBill leaveBill = leaveBillMapper.selectById(leaveId);
|
||||
leaveBill.setState("1");
|
||||
leaveBill.setState(EnumTaskStatus.CHECK.getStatus());
|
||||
//2:使用当前对象获取到流程定义的key(对象的名称就是流程定义的key)
|
||||
String key = leaveBill.getClass().getSimpleName();
|
||||
//3: 格式:LeaveBill_id的形式(使用流程变量)
|
||||
|
||||
@@ -14,9 +14,9 @@ spring:
|
||||
enabled: true
|
||||
service-id: pigx-config
|
||||
datasource:
|
||||
url: jdbc:mysql://114.116.21.191:3306/ac?characterEncoding=UTF-8&useSSL=false
|
||||
url: jdbc:mysql://127.0.0.1:3306/ac?characterEncoding=UTF-8&useSSL=false
|
||||
username: root
|
||||
password: Bjyjht2017!@#
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
activiti:
|
||||
check-process-definitions: false
|
||||
@@ -27,7 +27,7 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
|
||||
defaultZone: http://pig:pig@localhost:1025/eureka/
|
||||
|
||||
## spring security 配置
|
||||
security:
|
||||
@@ -39,7 +39,7 @@ security:
|
||||
resource:
|
||||
token-info-uri: ${security.auth.server}/check_token
|
||||
auth:
|
||||
server: http://192.168.0.20:9999/auth/oauth
|
||||
server: http://localhost:9999/auth/oauth
|
||||
|
||||
# 加解密根密码
|
||||
jasypt:
|
||||
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
|
||||
defaultZone: http://pig:pig@localhost:1025/eureka/
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
|
||||
defaultZone: http://pig:pig@localhost:1025/eureka/
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
|
||||
defaultZone: http://pig:pig@localhost:1025/eureka/
|
||||
@@ -20,5 +20,5 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@192.168.0.20:1025/eureka/
|
||||
defaultZone: http://pig:pig@localhost:1025/eureka/
|
||||
|
||||
Reference in new issue
Block a user