Browse Source

添加流程定义

master
Yen 3 years ago
parent
commit
c01cd9a521
  1. 4
      src/main/java/com/qs/serve/controller/WxMpPortalApi.java
  2. 4
      src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java
  3. 1
      src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java
  4. 50
      src/main/java/com/qs/serve/modules/bpm/service/IFlowDefinitionService.java
  5. 84
      src/main/java/com/qs/serve/modules/bpm/service/impl/IFlowDefinitionServiceImpl.java
  6. 2
      src/main/java/com/qs/serve/modules/wx/common/conf/WxMpConfig.java
  7. 2
      src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java
  8. 8
      src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java
  9. 7
      src/main/resources/application-dev.yml
  10. 4
      src/main/resources/application.yml

4
src/main/java/com/qs/serve/controller/WxMpPortalApi.java

@ -23,8 +23,8 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
*/ */
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
@RestController //@RestController
@RequestMapping("/api/wx/mp/portal/{appid}") //@RequestMapping("/api/wx/mp/portal/{appid}")
public class WxMpPortalApi { public class WxMpPortalApi {
private final WxMpService wxService; private final WxMpService wxService;

4
src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java

@ -27,8 +27,8 @@ public class FlowServiceFactory {
@Resource @Resource
protected TaskService taskService; protected TaskService taskService;
@Resource //@Resource
protected FormService formService; //protected FormService formService;
@Resource @Resource
protected HistoryService historyService; protected HistoryService historyService;

1
src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java

@ -22,5 +22,6 @@ public class BpmFlowDefinitionController {
//删除流程 //删除流程
//启动流程实例 //启动流程实例
//激活或挂起流程定义 //激活或挂起流程定义
//
} }

50
src/main/java/com/qs/serve/modules/bpm/service/IFlowDefinitionService.java

@ -0,0 +1,50 @@
package com.qs.serve.modules.bpm.service;
import com.qs.serve.modules.bpm.entity.dto.FlowProcDefDto;
import java.util.Map;
import java.util.List;
/**
* 流程定义服务
* @author YenHex
* @since 2022/8/22
*/
public interface IFlowDefinitionService {
/**
* 流程定义列表
* @param procDefName
* @return
*/
List<FlowProcDefDto> list(String procDefName);
/**
* 检查流程实例是否存在
* @param processDefinitionKey
* @return
*/
boolean exist(String processDefinitionKey);
/**
* 根据流程定义ID启动流程实例
* @param procDefId
* @param variables
* @return
*/
void startProcessInstanceById(String procDefId, Map<String, Object> variables);
/**
* 激活或挂起流程定义
* @param state 状态: 1=激活 ;2=挂起
* @param deployId 流程部署ID
*/
void updateState(Integer state, String deployId);
/**
* 删除流程定义
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
*/
void delete(String deployId);
}

84
src/main/java/com/qs/serve/modules/bpm/service/impl/IFlowDefinitionServiceImpl.java

@ -0,0 +1,84 @@
package com.qs.serve.modules.bpm.service.impl;
import com.qs.serve.common.util.Assert;
import com.qs.serve.modules.bpm.common.consts.ProcessConstants;
import com.qs.serve.modules.bpm.common.enums.FlowComment;
import com.qs.serve.modules.bpm.conf.FlowServiceFactory;
import com.qs.serve.modules.bpm.entity.dto.FlowProcDefDto;
import com.qs.serve.modules.bpm.mapper.FlowDeployMapper;
import com.qs.serve.modules.bpm.service.IFlowDefinitionService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author YenHex
* @since 2022/8/22
*/
@Slf4j
@Service
@AllArgsConstructor
public class IFlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
private final FlowDeployMapper flowDeployMapper;
@Override
public List<FlowProcDefDto> list(String procDefName) {
return flowDeployMapper.selectDeployList(procDefName);
}
@Override
public boolean exist(String processDefinitionKey) {
ProcessDefinitionQuery processDefinitionQuery
= repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey);
long count = processDefinitionQuery.count();
return count > 0;
}
@Override
public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
.latestVersion().singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
Assert.throwEx("流程已被挂起,请先激活流程");
}
// variables.put("skip", true);
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
// 设置流程发起人Id到流程中
identityService.setAuthenticatedUserId("TODO");
variables.put(ProcessConstants.PROCESS_INITIATOR, "");
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
if (Objects.nonNull(task)) {
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), "sysUser.getNickName()发起流程申请");
// taskService.setAssignee(task.getId(), sysUser.getUserId().toString());
taskService.complete(task.getId(), variables);
}
}
@Override
public void updateState(Integer state, String deployId) {
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
if (state == 1) {
repositoryService.activateProcessDefinitionById(procDef.getId(), true, null);
}
if (state == 2) {
repositoryService.suspendProcessDefinitionById(procDef.getId(), true, null);
}
}
@Override
public void delete(String deployId) {
// true 允许级联删除 ,不设置会导致数据库外键关联异常
repositoryService.deleteDeployment(deployId, true);
}
}

2
src/main/java/com/qs/serve/modules/wx/common/conf/WxMpConfig.java

@ -33,7 +33,7 @@ import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
*/ */
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
@Configuration(proxyBeanMethods = false) //@Configuration(proxyBeanMethods = false)
public class WxMpConfig { public class WxMpConfig {
private final LogHandler logHandler; private final LogHandler logHandler;

2
src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java

@ -20,7 +20,7 @@ import org.springframework.stereotype.Service;
* @since 2022/3/16 * @since 2022/3/16
*/ */
@Slf4j @Slf4j
@Service //@Service
@AllArgsConstructor @AllArgsConstructor
public class WxPushServiceImpl implements WxPushService { public class WxPushServiceImpl implements WxPushService {

8
src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java

@ -25,6 +25,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.service.WxOAuth2Service; import me.chanjar.weixin.common.service.WxOAuth2Service;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -34,12 +35,13 @@ import org.springframework.stereotype.Service;
*/ */
@Slf4j @Slf4j
@Service @Service
@AllArgsConstructor
public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> implements WxUserService { public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> implements WxUserService {
private final WxMpConfig wxMpConfig; @Autowired(required = false)
private WxMpConfig wxMpConfig;
private final WxAppService wxAppService; @Autowired(required = false)
private WxAppService wxAppService;
@Override @Override
public WxUser getCurrentWxUser() { public WxUser getCurrentWxUser() {

7
src/main/resources/application-dev.yml

@ -1,15 +1,14 @@
#服务配置 #服务配置
server: server:
port: 7200 port: 7777
servlet: servlet:
context-path: / context-path: /
#SpringBoot相关 #SpringBoot相关
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
#url: jdbc:mysql://192.168.0.9:3306/gy_oa_qs?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai #url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm-demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
# &nullCatalogMeansCurrent=true url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm-demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: 123456 password: 123456
redis: redis:

4
src/main/resources/application.yml

@ -30,8 +30,8 @@ project:
#mybatis plus #mybatis plus
mybatis-plus: mybatis-plus:
mapper-locations: classpath*:mapper/*/*.xml mapper-locations: classpath:mapper/*/*.xml
type-aliases-package: com.qs.gyoa.modules.*.entity.* type-aliases-package: com.qs.serve.modules.*.entity.*
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
global-config: global-config:

Loading…
Cancel
Save