✨ 添加新特性。 工作流
This commit is contained in:
1 parent
8b9b541cee
commit
1d2d8f6e32
29 files changed
+251
-44
No files matched your search
+1
-1
@@ -4,7 +4,7 @@
|
||||
Source Server : RDS本地使用
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50721
|
||||
Source Host : 114.116.21.191
|
||||
Source Host : 127.0.0.1
|
||||
Source Database : pigxx
|
||||
|
||||
Target Server Type : MySQL
|
||||
|
||||
@@ -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/
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 EnumTaskStatus {
|
||||
/**
|
||||
* 未提交
|
||||
*/
|
||||
UNSUBMIT("0", "未提交"),
|
||||
|
||||
/**
|
||||
* 审核中
|
||||
*/
|
||||
CHECK("1", "审核中"),
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
COMPLETED("2", "已完成"),
|
||||
|
||||
/**
|
||||
* 驳回
|
||||
*/
|
||||
OVERRULE("9", "驳回");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String status;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
}
|
||||
@@ -19,7 +19,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/
|
||||
|
||||
# 暴露监控端点
|
||||
management:
|
||||
|
||||
@@ -6,7 +6,7 @@ jasypt:
|
||||
spring:
|
||||
redis:
|
||||
password:
|
||||
host: 192.168.0.22
|
||||
host: localhost
|
||||
# 暴露监控端点
|
||||
management:
|
||||
endpoints:
|
||||
@@ -94,7 +94,7 @@ swagger:
|
||||
## spring security 配置
|
||||
security:
|
||||
auth:
|
||||
server: http://192.168.0.20:9999/auth/oauth
|
||||
server: http://localhost:9999/auth/oauth
|
||||
oauth2:
|
||||
resource:
|
||||
token-info-uri: ${security.auth.server}/check_token
|
||||
@@ -4,5 +4,5 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: Bjyjht2017!@#
|
||||
url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: 123456
|
||||
url: jdbc:mysql://127.0.0.1:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
@@ -12,8 +12,8 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: Bjyjht2017!@#
|
||||
url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: 123456
|
||||
url: jdbc:mysql://127.0.0.1:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
|
||||
@@ -13,8 +13,8 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: Bjyjht2017!@#
|
||||
url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: 123456
|
||||
url: jdbc:mysql://127.0.0.1:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
elasticjob:
|
||||
# 分布式任务协调依赖zookeeper
|
||||
zookeeper:
|
||||
|
||||
@@ -12,8 +12,8 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: Bjyjht2017!@#
|
||||
url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
|
||||
password: 123456
|
||||
url: jdbc:mysql://127.0.0.1:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
|
||||
|
||||
# swagger相关配置,覆盖全局配置
|
||||
swagger:
|
||||
|
||||
@@ -13,7 +13,7 @@ spring:
|
||||
# 类似的 redis 使用pigx-redis ,gateway 换成 pigx-gateway
|
||||
eureka:
|
||||
instance:
|
||||
hostname: 192.168.0.20
|
||||
hostname: localhost
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
register-with-eureka: false
|
||||
|
||||
@@ -22,6 +22,6 @@ 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/
|
||||
|
||||
|
||||
+14
@@ -20,6 +20,7 @@
|
||||
package com.pig4cloud.pigx.admin.api.feign;
|
||||
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.feign.factory.RemoteUserServiceFallbackFactory;
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
@@ -28,6 +29,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/6/22
|
||||
@@ -53,4 +56,15 @@ public interface RemoteUserService {
|
||||
*/
|
||||
@GetMapping("/social/info/{inStr}")
|
||||
R<UserInfo> social(@PathVariable("inStr") String inStr);
|
||||
|
||||
/**
|
||||
* 查询上级部门的用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param from 调用标志
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/user/ancestorUsers/{username}")
|
||||
R<List<SysUser>> ancestorUsers(@PathVariable("username") String username
|
||||
, @RequestHeader("from") String from);
|
||||
}
|
||||
+16
@@ -20,12 +20,15 @@
|
||||
package com.pig4cloud.pigx.admin.api.feign.fallback;
|
||||
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/6/26
|
||||
@@ -60,4 +63,17 @@ public class RemoteUserServiceFallbackImpl implements RemoteUserService {
|
||||
log.error("feign 查询用户信息失败:{}", inStr, cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上级部门的用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param from 调用标志
|
||||
* @return R
|
||||
*/
|
||||
@Override
|
||||
public R<List<SysUser>> ancestorUsers(String username, String from) {
|
||||
log.error("feign 查询用户上级部门用户列失败:{}", username, cause);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+14
-4
@@ -36,14 +36,15 @@ import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -51,11 +52,11 @@ import java.util.Map;
|
||||
* @date 2017/10/28
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
private final SysUserService userService;
|
||||
|
||||
/**
|
||||
* 获取当前用户信息(角色、权限)
|
||||
@@ -124,7 +125,7 @@ public class UserController {
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
sysUser.setDelFlag(CommonConstant.STATUS_NORMAL);
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
userService.insert(sysUser);
|
||||
userDto.getRole().forEach(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
@@ -169,4 +170,13 @@ public class UserController {
|
||||
public R<Boolean> editInfo(@Valid @RequestBody UserDTO userDto) {
|
||||
return userService.updateUserInfo(userDto, SecurityUtils.getUser().getUsername());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username 用户名称
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/ancestorUsers/{username}")
|
||||
public R<List<SysUser>> ancestorUsers(@PathVariable String username) {
|
||||
return new R<>(userService.ancestorUsers(username));
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -28,6 +28,8 @@ import com.pig4cloud.pigx.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pigx.common.core.util.Query;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/31
|
||||
@@ -102,5 +104,11 @@ public interface SysUserService extends IService<SysUser> {
|
||||
*/
|
||||
Boolean deleteSysUserByUsernameAndUserId(String username, Integer userId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询上级部门的用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return R
|
||||
*/
|
||||
List<SysUser> ancestorUsers(String username);
|
||||
}
|
||||
+28
-6
@@ -27,10 +27,7 @@ import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysRole;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUserRole;
|
||||
import com.pig4cloud.pigx.admin.api.entity.*;
|
||||
import com.pig4cloud.pigx.admin.api.vo.MenuVO;
|
||||
import com.pig4cloud.pigx.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
|
||||
@@ -68,6 +65,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
private final SysMenuService sysMenuService;
|
||||
private final SysUserMapper sysUserMapper;
|
||||
private final SysRoleService sysRoleService;
|
||||
private final SysDeptService sysDeptService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final SysDeptRelationService sysDeptRelationService;
|
||||
|
||||
@@ -78,7 +76,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "user_details", key = "#username", unless="#result == null")
|
||||
@Cacheable(value = "user_details", key = "#username", unless = "#result == null")
|
||||
public UserInfo findUserInfo(String type, String username) {
|
||||
SysUser condition = new SysUser();
|
||||
if (EnumLoginType.PWD.getType().equals(type)) {
|
||||
@@ -91,7 +89,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
SysUser sysUser = this.selectOne(new EntityWrapper<>(condition));
|
||||
if (sysUser == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setSysUser(sysUser);
|
||||
@@ -224,6 +222,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上级部门的用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return R
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> ancestorUsers(String username) {
|
||||
SysUser condition = new SysUser();
|
||||
condition.setUsername(username);
|
||||
SysUser sysUser = this.selectOne(new EntityWrapper<>(condition));
|
||||
|
||||
Integer deptId = sysUser.getDeptId();
|
||||
SysDept sysDept = sysDeptService.selectById(deptId);
|
||||
if (sysDept == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer parentId = sysDept.getParentId();
|
||||
SysUser condition2 = new SysUser();
|
||||
condition2.setDeptId(parentId);
|
||||
return this.selectList(new EntityWrapper<>(condition2));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的子部门信息
|
||||
*
|
||||
|
||||
@@ -23,4 +23,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/
|
||||
@@ -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