• 工具类输出当前ApplicationContext所有被装配的类


    package org.springblade.desk.utils;
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.stereotype.Component;
    @Component
    public class SpringUtil implements ApplicationContextAware {
    
        /**
         * 当前IOC
         *
         */
        private static ApplicationContext applicationContext;
        /**
         * 设置applicationContext
         */
        @Override
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            this.applicationContext = applicationContext;
        }
    
        /**
         * 从当前IOC获取bean
         */
        public static <T> T getObject(Class<T> clazz){
            return applicationContext.getBean(clazz);
        }
    
        public static void showClass(){
            String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
            for(String beanDefinitionName : beanDefinitionNames){
                System.out.println(beanDefinitionName);
            }
        }
    }
    
    //业务类
    package org.springblade.desk.listener.task;
    import org.flowable.engine.delegate.TaskListener;
    import org.flowable.task.service.delegate.DelegateTask;
    import org.springblade.core.mp.support.Condition;
    import org.springblade.desk.entity.ProcessPurchaseOrder;
    import org.springblade.desk.entity.ProcessPurchaseOrderDetail;
    import org.springblade.desk.service.impl.PurchaseOrderDetailServiceImpl;
    import org.springblade.desk.service.impl.PurchaseOrderServiceImpl;
    import org.springblade.desk.utils.SpringUtil;
    import org.springframework.stereotype.Component;
    import java.util.List;
    
    /**
     * create by Dell on 2020/6/23
     */
    @Component
    public class PurchaseOrderTaskListener implements TaskListener {
        @Override
        public void notify(DelegateTask delegateTask) {
            PurchaseOrderServiceImpl purchaseOrderServiceImpl= SpringUtil.getObject(PurchaseOrderServiceImpl.class);
            PurchaseOrderDetailServiceImpl purchaseOrderDetailServiceImpl= SpringUtil.getObject(PurchaseOrderDetailServiceImpl.class);
            System.out.println("采购订单进入监听事件delegateTask=========================="+delegateTask);
            String processInstanceId = delegateTask.getProcessInstanceId() ;
            ProcessPurchaseOrder entity = new ProcessPurchaseOrder();
            entity.setProcessInstanceId(processInstanceId);
            List<ProcessPurchaseOrder> list = purchaseOrderServiceImpl.list(Condition.getQueryWrapper(entity));
            if(list!=null&&!list.isEmpty()){
                for(ProcessPurchaseOrder bean : list){
                    ProcessPurchaseOrderDetail line = new ProcessPurchaseOrderDetail();
                    line.setOrderNumber(bean.getOrderNumber());
                    List<ProcessPurchaseOrderDetail> lineList = purchaseOrderDetailServiceImpl.list(Condition.getQueryWrapper(line));
                }
            }
            System.out.println("taskListener"+ list.size()+"--------");
        }
    }

    //借鉴=============== https://www.jianshu.com/p/56d5be0dab91
  • 相关阅读:
    Java 中文 乱码问题
    JQuery 操作 radio 被坑一例
    标准I/O库之打开和关闭流
    标准I/O库之缓冲
    标准I/O库之标准输入、标准输出和标准出错
    标准I/O库之流和FILE对象
    文件和目录之文件访问权限位小结
    文件和目录之设备特殊文件
    文件和目录之chdir、fchdir和getcwd函数
    文件和目录之读目录
  • 原文地址:https://www.cnblogs.com/xianz666/p/13274829.html
Copyright © 2020-2023  润新知