mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	BPM: 实现业务流程结果监听器
This commit is contained in:
		| @@ -28,6 +28,7 @@ import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.service.impl.DiffParseFunction; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -56,6 +57,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||||
|     @Resource | ||||
|     private CrmBusinessProductService businessProductService; | ||||
|     @Resource | ||||
|     @Lazy | ||||
|     private CrmContractService contractService; | ||||
|     @Resource | ||||
|     private CrmPermissionService permissionService; | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.service.impl.DiffParseFunction; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -56,6 +57,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||||
|     @Resource | ||||
|     private CrmPermissionService permissionService; | ||||
|     @Resource | ||||
|     @Lazy | ||||
|     private CrmContractService contractService; | ||||
|     @Resource | ||||
|     private CrmContactBusinessService contactBusinessService; | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.contract; | ||||
|  | ||||
| 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.CrmContractSaveReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; | ||||
| @@ -65,6 +66,12 @@ public interface CrmContractService { | ||||
|      */ | ||||
|     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.util.number.MoneyUtils; | ||||
| 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.dto.BpmProcessInstanceCreateReqDTO; | ||||
| 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.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -73,8 +75,10 @@ public class CrmContractServiceImpl implements CrmContractService { | ||||
|     @Resource | ||||
|     private CrmCustomerService customerService; | ||||
|     @Resource | ||||
|     @Lazy | ||||
|     private CrmContactService contactService; | ||||
|     @Resource | ||||
|     @Lazy | ||||
|     private CrmBusinessService businessService; | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
| @@ -244,6 +248,12 @@ public class CrmContractServiceImpl implements CrmContractService { | ||||
|                 .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 | ||||
|   | ||||
| @@ -1,5 +1,31 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.contract.listener; | ||||
|  | ||||
| public class CrmContractResultListener { | ||||
|     // TODO puhui999: @芋艿: 艿艿写一下这个,没研究明白哈哈 | ||||
| import cn.iocoder.yudao.module.bpm.api.listener.BpmResultListenerApi; | ||||
| 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); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999