mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
BPM: 实现业务流程结果监听器
This commit is contained in:
parent
acb8d3f23b
commit
624b35988e
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
|||||||
<module>yudao-module-system</module>
|
<module>yudao-module-system</module>
|
||||||
<module>yudao-module-infra</module>
|
<module>yudao-module-infra</module>
|
||||||
<!-- <module>yudao-module-member</module>-->
|
<!-- <module>yudao-module-member</module>-->
|
||||||
<!-- <module>yudao-module-bpm</module>-->
|
<module>yudao-module-bpm</module>
|
||||||
<!-- <module>yudao-module-report</module>-->
|
<!-- <module>yudao-module-report</module>-->
|
||||||
<!-- <module>yudao-module-mp</module>-->
|
<!-- <module>yudao-module-mp</module>-->
|
||||||
<!-- <module>yudao-module-pay</module>-->
|
<!-- <module>yudao-module-pay</module>-->
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.api.listener;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务流程实例的结果发生变化的监听器 Api
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
public interface BpmResultListenerApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听的流程定义 Key
|
||||||
|
*
|
||||||
|
* @return 返回监听的流程定义 Key
|
||||||
|
*/
|
||||||
|
String getProcessDefinitionKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理事件
|
||||||
|
*
|
||||||
|
* @param event 事件
|
||||||
|
*/
|
||||||
|
void onEvent(BpmResultListenerRespDTO event);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.api.listener.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务流程实例的结果 Response DTO
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BpmResultListenerRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程实例的编号
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 流程实例的 key
|
||||||
|
*/
|
||||||
|
private String processDefinitionKey;
|
||||||
|
/**
|
||||||
|
* 流程实例的结果
|
||||||
|
*/
|
||||||
|
private Integer result;
|
||||||
|
/**
|
||||||
|
* 流程实例对应的业务标识
|
||||||
|
* 例如说,请假
|
||||||
|
*/
|
||||||
|
private String businessKey;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.framework.bpm.listener;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.listener.BpmResultListenerApi;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务流程结果监听器实现类
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class BpmServiceResultListener implements ApplicationListener<BpmProcessInstanceResultEvent> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private List<BpmResultListenerApi> bpmResultListenerApis;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void onApplicationEvent(BpmProcessInstanceResultEvent event) {
|
||||||
|
bpmResultListenerApis.forEach(bpmResultListenerApi -> {
|
||||||
|
if (!StrUtil.equals(event.getProcessDefinitionKey(), bpmResultListenerApi.getProcessDefinitionKey())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bpmResultListenerApi.onEvent(BeanUtils.toBean(event, BpmResultListenerRespDTO.class));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,6 +28,7 @@ import com.mzt.logapi.context.LogRecordContext;
|
|||||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -56,6 +57,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CrmBusinessProductService businessProductService;
|
private CrmBusinessProductService businessProductService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy
|
||||||
private CrmContractService contractService;
|
private CrmContractService contractService;
|
||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService permissionService;
|
private CrmPermissionService permissionService;
|
||||||
|
@ -25,6 +25,7 @@ import com.mzt.logapi.context.LogRecordContext;
|
|||||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -56,6 +57,7 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService permissionService;
|
private CrmPermissionService permissionService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy
|
||||||
private CrmContractService contractService;
|
private CrmContractService contractService;
|
||||||
@Resource
|
@Resource
|
||||||
private CrmContactBusinessService contactBusinessService;
|
private CrmContactBusinessService contactBusinessService;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.contract;
|
package cn.iocoder.yudao.module.crm.service.contract;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
||||||
@ -65,6 +66,12 @@ public interface CrmContractService {
|
|||||||
*/
|
*/
|
||||||
void handleApprove(Long id, Long userId);
|
void handleApprove(Long id, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新合同流程审批结果
|
||||||
|
*
|
||||||
|
* @param event 审批结果
|
||||||
|
*/
|
||||||
|
void updateContractAuditStatus(BpmResultListenerRespDTO event);
|
||||||
/**
|
/**
|
||||||
* 获得合同
|
* 获得合同
|
||||||
*
|
*
|
||||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
|
||||||
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
@ -33,6 +34,7 @@ import com.mzt.logapi.context.LogRecordContext;
|
|||||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -73,8 +75,10 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CrmCustomerService customerService;
|
private CrmCustomerService customerService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy
|
||||||
private CrmContactService contactService;
|
private CrmContactService contactService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy
|
||||||
private CrmBusinessService businessService;
|
private CrmBusinessService businessService;
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
@ -244,6 +248,12 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
.setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus()));
|
.setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateContractAuditStatus(BpmResultListenerRespDTO event) {
|
||||||
|
contractMapper.updateById(new CrmContractDO().setId(Long.parseLong(event.getBusinessKey())).setAuditStatus(event.getResult()));
|
||||||
|
}
|
||||||
|
|
||||||
//======================= 查询相关 =======================
|
//======================= 查询相关 =======================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,31 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.contract.listener;
|
package cn.iocoder.yudao.module.crm.service.contract.listener;
|
||||||
|
|
||||||
public class CrmContractResultListener {
|
import cn.iocoder.yudao.module.bpm.api.listener.BpmResultListenerApi;
|
||||||
// TODO puhui999: @芋艿: 艿艿写一下这个,没研究明白哈哈
|
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contract.CrmContractServiceImpl;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同审批的结果的监听器实现类
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CrmContractResultListener implements BpmResultListenerApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmContractService contractService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getProcessDefinitionKey() {
|
||||||
|
return CrmContractServiceImpl.CONTRACT_APPROVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(BpmResultListenerRespDTO event) {
|
||||||
|
contractService.updateContractAuditStatus(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@
|
|||||||
<!-- <version>${revision}</version>-->
|
<!-- <version>${revision}</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
<!-- 工作流。默认注释,保证编译速度 -->
|
<!-- 工作流。默认注释,保证编译速度 -->
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<!-- <artifactId>yudao-module-bpm-biz</artifactId>-->
|
<artifactId>yudao-module-bpm-biz</artifactId>
|
||||||
<!-- <version>${revision}</version>-->
|
<version>${revision}</version>
|
||||||
<!-- </dependency>-->
|
</dependency>
|
||||||
<!-- 支付服务。默认注释,保证编译速度 -->
|
<!-- 支付服务。默认注释,保证编译速度 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||||
|
Loading…
Reference in New Issue
Block a user