diff --git a/src/main/java/com/qs/serve/controller/WxMpPortalApi.java b/src/main/java/com/qs/serve/controller/WxMpPortalApi.java index 2838764..8016d32 100644 --- a/src/main/java/com/qs/serve/controller/WxMpPortalApi.java +++ b/src/main/java/com/qs/serve/controller/WxMpPortalApi.java @@ -23,8 +23,8 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; */ @Slf4j @AllArgsConstructor -@RestController -@RequestMapping("/api/wx/mp/portal/{appid}") +//@RestController +//@RequestMapping("/api/wx/mp/portal/{appid}") public class WxMpPortalApi { private final WxMpService wxService; diff --git a/src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java b/src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java index 3157029..ae06a15 100644 --- a/src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java +++ b/src/main/java/com/qs/serve/modules/bpm/conf/FlowServiceFactory.java @@ -27,8 +27,8 @@ public class FlowServiceFactory { @Resource protected TaskService taskService; - @Resource - protected FormService formService; + //@Resource + //protected FormService formService; @Resource protected HistoryService historyService; diff --git a/src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java b/src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java index 4ba5285..20a22c1 100644 --- a/src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java +++ b/src/main/java/com/qs/serve/modules/bpm/controller/BpmFlowDefinitionController.java @@ -22,5 +22,6 @@ public class BpmFlowDefinitionController { //删除流程 //启动流程实例 //激活或挂起流程定义 + // } diff --git a/src/main/java/com/qs/serve/modules/bpm/service/IFlowDefinitionService.java b/src/main/java/com/qs/serve/modules/bpm/service/IFlowDefinitionService.java new file mode 100644 index 0000000..0c0bd1f --- /dev/null +++ b/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 list(String procDefName); + + /** + * 检查流程实例是否存在 + * @param processDefinitionKey + * @return + */ + boolean exist(String processDefinitionKey); + + /** + * 根据流程定义ID启动流程实例 + * @param procDefId + * @param variables + * @return + */ + void startProcessInstanceById(String procDefId, Map 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); + +} diff --git a/src/main/java/com/qs/serve/modules/bpm/service/impl/IFlowDefinitionServiceImpl.java b/src/main/java/com/qs/serve/modules/bpm/service/impl/IFlowDefinitionServiceImpl.java new file mode 100644 index 0000000..8390165 --- /dev/null +++ b/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 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 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); + } +} diff --git a/src/main/java/com/qs/serve/modules/wx/common/conf/WxMpConfig.java b/src/main/java/com/qs/serve/modules/wx/common/conf/WxMpConfig.java index e0de550..59b2894 100644 --- a/src/main/java/com/qs/serve/modules/wx/common/conf/WxMpConfig.java +++ b/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 @AllArgsConstructor -@Configuration(proxyBeanMethods = false) +//@Configuration(proxyBeanMethods = false) public class WxMpConfig { private final LogHandler logHandler; diff --git a/src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java b/src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java index 23f4f69..d4288f9 100644 --- a/src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java +++ b/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 */ @Slf4j -@Service +//@Service @AllArgsConstructor public class WxPushServiceImpl implements WxPushService { diff --git a/src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java b/src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java index 8da6a3c..e0d3afa 100644 --- a/src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java +++ b/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.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.result.WxMpUser; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -34,12 +35,13 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service -@AllArgsConstructor public class WxUserServiceImpl extends ServiceImpl implements WxUserService { - private final WxMpConfig wxMpConfig; + @Autowired(required = false) + private WxMpConfig wxMpConfig; - private final WxAppService wxAppService; + @Autowired(required = false) + private WxAppService wxAppService; @Override public WxUser getCurrentWxUser() { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 508937e..6b77927 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,15 +1,14 @@ #服务配置 server: - port: 7200 + port: 7777 servlet: context-path: / #SpringBoot相关 spring: datasource: 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 - # &nullCatalogMeansCurrent=true - url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true + #url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm-demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + url: jdbc:mysql://192.168.0.9:3333/qs-base-bpm-demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true username: root password: 123456 redis: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2ff62e7..44864f8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,8 +30,8 @@ project: #mybatis plus mybatis-plus: - mapper-locations: classpath*:mapper/*/*.xml - type-aliases-package: com.qs.gyoa.modules.*.entity.* + mapper-locations: classpath:mapper/*/*.xml + type-aliases-package: com.qs.serve.modules.*.entity.* configuration: map-underscore-to-camel-case: true global-config: