bladex中flowable中配置监听器
//flow服务下
package org.springblade.flow.engine.listener.execution; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.ExecutionListener; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.Func; import org.springblade.desk.feign.IPurchaseOrderClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Map; /** * create by Dell on 2020/7/16 */ @Slf4j @Component("purchaseOrderExecutionListener") public class PurchaseOrderExecutionListener implements ExecutionListener { @Autowired private IPurchaseOrderClient purchaseOrderClient ; @SneakyThrows @Override public void notify(DelegateExecution execution) { String processInstanceId=execution.getProcessInstanceId(); log.info("采购订单审批流程结束调用监听开始processInstanceId=============="+processInstanceId); Map<String,Object> msg=purchaseOrderClient.purchaseOrderCreate(processInstanceId); log.info("采购订单审批流程结束调用监听结束msg=============="+msg); if(Func.isNotEmpty(msg)){ if(!(boolean)msg.get("msg")){ throw new ServiceException("查询要写入sap的数据为空"); } }else{ throw new ServiceException("数据修改采购申请单或者写入sap出现错误"); } } }
//desk-api fegin目录下类
/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.desk.feign; import org.springblade.core.launch.constant.AppConstant; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.Map; /** * 工作流远程调用接口. * * @author Chill */ @FeignClient( value = AppConstant.APPLICATION_DESK_NAME ) public interface IPurchaseOrderClient { String API_PREFIX = "/client"; String TEST = API_PREFIX + "/purchaseorderCreate"; @GetMapping(TEST) Map<String,Object> purchaseOrderCreate (@RequestParam("processInstanceId") String processInstanceId); }
// desk服务下 fegin目录下类
/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.desk.feign; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.desk.service.IPurchaseOrderService; import org.springblade.desk.service.IPurchaseRequestLineService; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Map; /** * 流程远程调用实现类 * * @author pei */ @Transactional(rollbackFor = Exception.class) @RestController @AllArgsConstructor @Slf4j public class PurchaseOrderClient implements IPurchaseOrderClient { private IPurchaseOrderService purchaseOrderService; private IPurchaseRequestLineService purchaseRequestLineService; @GetMapping(TEST) @Override public Map<String,Object> purchaseOrderCreate(String processInstanceId) { log.info("processInstanceId==============="+processInstanceId); return purchaseOrderService.getOderInfo(processInstanceId); } }