Skip to content

Commit

Permalink
整合了activiti,实现了基于工作流的请假审批
Browse files Browse the repository at this point in the history
  • Loading branch information
qiujie committed Apr 28, 2024
1 parent 2a43bdd commit effff2c
Show file tree
Hide file tree
Showing 56 changed files with 3,222 additions and 588 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
1. 完成了项目的加班模块 2024/3/23
2. 解决了当数据表格的列fixed时,行未对齐的问题 2024/3/26

#### master
#### v2.0-240428

1. 整合了spring security,实现了基于jwt的认证以及授权 2024/4/3
2. 解决了文件上传、下载,数据导入、导出的跨域问题 2024/4/5
Expand All @@ -32,6 +32,9 @@
5. 修复了一些小bug,完善了权限控制 2024/4/13
6. 整合了redis,实现了验证码登录功能 2024/4/18

#### master
1. 整合了activiti,实现了基于工作流的请假审批 2024/5/1

### 项目介绍

#### 项目概述
Expand All @@ -46,7 +49,7 @@

2. 后端

Spring Boot、Jwt、MyBatis-Plus、MySQL、Hutool、Spring Security、Redis
Spring Boot、Jwt、MyBatis-Plus、MySQL、Hutool、Spring Security、Redis、Activiti

### 系统设计

Expand All @@ -69,13 +72,11 @@

![请假](https://image-qiu.oss-cn-hangzhou.aliyuncs.com/project/hrm/README-20240326-1711451261849.png?x-oss-process=image/auto-orient,1/interlace,1/quality,q_50/format,jpg)


在请假面板中,员工可以进行请假。在右侧的请假记录中可以查看以往的请假申请,或对当前未被审核的申请进行撤销。

![审批](https://image-qiu.oss-cn-hangzhou.aliyuncs.com/project/hrm/README-20240326-1711451327500.png?x-oss-process=image/auto-orient,1/interlace,1/quality,q_50/format,jpg)

![审批](https://image-qiu.oss-cn-hangzhou.aliyuncs.com/project/hrm/README-20240428-1714314768552.png?x-oss-process=image/auto-orient,1/interlace,1/quality,q_50/format,jpg)

管理员可以对员工的请假进行审批,比如通过或驳回。员工申请请假之后,等待管理员进行审批。如果管理员审批通过,则将员工休假时间段的考勤状态设置为休假(但当请假类型是调休时,考勤状态要设为调休)。
对员工的请假进行审批,比如通过或驳回。员工申请请假之后,等待相关人员进行审批。如果审批通过,则将员工休假时间段的考勤状态设置为休假(但当请假类型是调休时,考勤状态要设为调休)。

#### 五险一金

Expand Down
421 changes: 191 additions & 230 deletions hrm.sql

Large diffs are not rendered by default.

69 changes: 45 additions & 24 deletions hrm/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<version>2.5.6</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
Expand All @@ -30,7 +31,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand All @@ -47,7 +47,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
<version>8.0.33</version>
</dependency>

<dependency>
Expand All @@ -62,7 +62,6 @@
<version>3.5.1</version>
</dependency>


<!--代码生成器模板-->
<dependency>
<groupId>org.apache.velocity</groupId>
Expand Down Expand Up @@ -97,23 +96,47 @@
<version>3.19.0</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
</dependency>

<!-- 数据导入与导出 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.20</version>
<version>5.8.25</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
<version>5.2.3</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
<exclusions>
<exclusion>
<artifactId>xmlbeans</artifactId>
<groupId>org.apache.xmlbeans</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -133,22 +156,22 @@
<artifactId>commons-pool2</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.activiti/activiti-spring-boot-starter -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>7.0.0.GA</version>
<exclusions>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
</dependency>

</dependencies>

<!-- 打包 -->
Expand All @@ -160,6 +183,4 @@
</plugin>
</plugins>
</build>


</project>
</project>
148 changes: 148 additions & 0 deletions hrm/src/main/java/com/qiujie/config/DataSourceConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package com.qiujie.config;

import org.activiti.api.runtime.shared.identity.UserGroupManager;
import org.activiti.engine.cfg.ProcessEngineConfigurator;
import org.activiti.engine.impl.persistence.StrongUuidGenerator;
import org.activiti.spring.SpringAsyncExecutor;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration;
import org.activiti.spring.boot.ActivitiProperties;
import org.activiti.spring.boot.ProcessDefinitionResourceFinder;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.activiti.spring.boot.process.validation.AsyncPropertyValidator;
import org.activiti.spring.bpmn.parser.CloudActivityBehaviorFactory;
import org.activiti.validation.ProcessValidatorImpl;
import org.activiti.validation.validator.ValidatorSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;

@Configuration
public class DataSourceConfig extends AbstractProcessEngineAutoConfiguration {

@Primary
@Bean
@ConfigurationProperties(prefix = "spring.datasource.master")
public DataSource masterDataSource() {
return DataSourceBuilder.create().build();
}


@Bean
@ConfigurationProperties(prefix = "spring.datasource.activiti")
public DataSource activitiDataSource() {
return DataSourceBuilder.create().build();
}

/**
* activiti7的数据源配置
* @param transactionManager
* @param springAsyncExecutor
* @param activitiProperties
* @param processDefinitionResourceFinder
* @param processEngineConfigurationConfigurer
* @param processEngineConfigurators
* @param userGroupManager
* @return
* @throws IOException
*/
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor,
ActivitiProperties activitiProperties,
ProcessDefinitionResourceFinder processDefinitionResourceFinder,
@Autowired(required = false) ProcessEngineConfigurationConfigurer processEngineConfigurationConfigurer,
@Autowired(required = false) List<ProcessEngineConfigurator> processEngineConfigurators,
UserGroupManager userGroupManager) throws IOException {

SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration();
conf.setConfigurators(processEngineConfigurators);
configureProcessDefinitionResources(processDefinitionResourceFinder,
conf);
conf.setDataSource(activitiDataSource());
conf.setTransactionManager(transactionManager);

if (springAsyncExecutor != null) {
conf.setAsyncExecutor(springAsyncExecutor);
}
conf.setDeploymentName(activitiProperties.getDeploymentName());
conf.setDatabaseSchema(activitiProperties.getDatabaseSchema());
conf.setDatabaseSchemaUpdate(activitiProperties.getDatabaseSchemaUpdate());
conf.setDbHistoryUsed(activitiProperties.isDbHistoryUsed());
conf.setAsyncExecutorActivate(activitiProperties.isAsyncExecutorActivate());
if (!activitiProperties.isAsyncExecutorActivate()) {
ValidatorSet springBootStarterValidatorSet = new ValidatorSet("activiti-spring-boot-starter");
springBootStarterValidatorSet.addValidator(new AsyncPropertyValidator());
if (conf.getProcessValidator() == null) {
ProcessValidatorImpl processValidator = new ProcessValidatorImpl();
processValidator.addValidatorSet(springBootStarterValidatorSet);
conf.setProcessValidator(processValidator);
} else {
conf.getProcessValidator().getValidatorSets().add(springBootStarterValidatorSet);
}
}
conf.setMailServerHost(activitiProperties.getMailServerHost());
conf.setMailServerPort(activitiProperties.getMailServerPort());
conf.setMailServerUsername(activitiProperties.getMailServerUserName());
conf.setMailServerPassword(activitiProperties.getMailServerPassword());
conf.setMailServerDefaultFrom(activitiProperties.getMailServerDefaultFrom());
conf.setMailServerUseSSL(activitiProperties.isMailServerUseSsl());
conf.setMailServerUseTLS(activitiProperties.isMailServerUseTls());

if (userGroupManager != null) {
conf.setUserGroupManager(userGroupManager);
}

conf.setHistoryLevel(activitiProperties.getHistoryLevel());
conf.setCopyVariablesToLocalForTasks(activitiProperties.isCopyVariablesToLocalForTasks());
conf.setSerializePOJOsInVariablesToJson(activitiProperties.isSerializePOJOsInVariablesToJson());
conf.setJavaClassFieldForJackson(activitiProperties.getJavaClassFieldForJackson());

if (activitiProperties.getCustomMybatisMappers() != null) {
conf.setCustomMybatisMappers(getCustomMybatisMapperClasses(activitiProperties.getCustomMybatisMappers()));
}

if (activitiProperties.getCustomMybatisXMLMappers() != null) {
conf.setCustomMybatisXMLMappers(new HashSet<>(activitiProperties.getCustomMybatisXMLMappers()));
}

if (activitiProperties.getCustomMybatisXMLMappers() != null) {
conf.setCustomMybatisXMLMappers(new HashSet<>(activitiProperties.getCustomMybatisXMLMappers()));
}

if (activitiProperties.isUseStrongUuids()) {
conf.setIdGenerator(new StrongUuidGenerator());
}

if (activitiProperties.getDeploymentMode() != null) {
conf.setDeploymentMode(activitiProperties.getDeploymentMode());
}

conf.setActivityBehaviorFactory(new CloudActivityBehaviorFactory());

if (processEngineConfigurationConfigurer != null) {
processEngineConfigurationConfigurer.configure(conf);
}

return conf;
}

private void configureProcessDefinitionResources(ProcessDefinitionResourceFinder processDefinitionResourceFinder,
SpringProcessEngineConfiguration conf) throws IOException {
List<Resource> procDefResources = processDefinitionResourceFinder.discoverProcessDefinitionResources();
if (!procDefResources.isEmpty()) {
conf.setDeploymentResources(procDefResources.toArray(new Resource[0]));
}
}
}
14 changes: 5 additions & 9 deletions hrm/src/main/java/com/qiujie/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factor
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
redisTemplate.setConnectionFactory(factory);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringRedisSerializer); // key的序列化类型
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 方法过期,改为下面代码
// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance , ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
redisTemplate.setKeySerializer(stringRedisSerializer); // key的序列化类型
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); // value的序列化类型
redisTemplate.setHashKeySerializer(stringRedisSerializer);
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setHashKeySerializer(stringRedisSerializer); // hash key的序列化类型
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); // hash value的序列化类型
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
Expand Down
7 changes: 4 additions & 3 deletions hrm/src/main/java/com/qiujie/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.qiujie.filter.JwtAuthenticationFilter;
import com.qiujie.handler.AccessDeniedExceptionHandler;
import com.qiujie.handler.AuthenticationEntryPointHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
Expand All @@ -26,13 +27,13 @@
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig {

@Resource
@Autowired
private AuthenticationEntryPointHandler authenticationEntryPointHandler;

@Resource
@Autowired
private AccessDeniedExceptionHandler accessDeniedExceptionHandler;

@Resource
@Autowired
private JwtAuthenticationFilter jwtAuthenticationFilter;

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.qiujie.dto.ResponseDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -27,7 +28,7 @@
@RequestMapping("/attendance")
public class AttendanceController {

@Resource
@Autowired
private AttendanceService attendanceService;

@ApiOperation("新增")
Expand Down
Loading

0 comments on commit effff2c

Please sign in to comment.