请问:Reporting组件是否可以实现定时任务

如题,场景如下:
1、使用定时任务,让Reporting组件生成Excel(或PDF)
2、生成成功后调用程序把结果推到企业微信(企业微信接口是现成的,主要的问题是怎么调方法)

你好,

  1. 关于定时执行报表可以使用 计划报表扩展,同时这个扩展提供了一个事件: ScheduledReportRun ,可以在此事件中去调用微信消息发送API。
  2. 一般与外部系统交互都使用 RestAPI,你可以使用一个第三方库来简化 API的调用。比如 unirest

另外请注意,一个帖子只讨论一个问题。

在执行定时报表任务时报了这个错,请问是什么原因呢?

09:58:00.980 ERROR c.h.cuba.core.sys.ServiceInterceptor    - Exception: 
java.lang.NoSuchMethodError: com.haulmont.cuba.core.global.DataManager.create(Ljava/lang/Class;)Ljava/lang/Object;
	at de.diedavids.cuba.scheduledreports.service.ScheduledReportRunServiceBean.createExecution(ScheduledReportRunServiceBean.java:149) ~[scheduledreports-core-0.2.0.jar:na]
	at de.diedavids.cuba.scheduledreports.service.ScheduledReportRunServiceBean.runReport(ScheduledReportRunServiceBean.java:86) ~[scheduledreports-core-0.2.0.jar:na]
	at de.diedavids.cuba.scheduledreports.service.ScheduledReportRunServiceBean.runReport(ScheduledReportRunServiceBean.java:77) ~[scheduledreports-core-0.2.0.jar:na]
	at de.diedavids.cuba.scheduledreports.service.ScheduledReportRunServiceBean.runScheduledReport(ScheduledReportRunServiceBean.java:60) ~[scheduledreports-core-0.2.0.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:90) ~[cuba-core-7.2.5.jar:7.2.5]
	at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at com.sun.proxy.$Proxy280.runScheduledReport(Unknown Source) [na:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at com.haulmont.cuba.core.app.scheduling.RunnerBean.executeTask(RunnerBean.java:241) [cuba-core-7.2.5.jar:7.2.5]
	at com.haulmont.cuba.core.app.scheduling.RunnerBean.lambda$runTask$0(RunnerBean.java:141) [cuba-core-7.2.5.jar:7.2.5]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_131]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]

framework 是哪个版本?

CUBA Platform version: 7.2.5
CUBA Studio plugin version: 13.4-191
IntelliJ version: CUBA Studio 2019.2

Spring的版本是5.2.3

换成7.1.7版本就没报错了,但界面显示如下的信息,貌似是成功的,但邮箱并没有收到邮件。查看电子邮件历史时,发现计划任务的邮件状态是“排队中”这是什么意思呢?
16:25:01.043 INFO c.h.r.libintegration.CubaReporting - Started report [CustomerInfo] with parameters []
16:25:01.066 INFO c.h.r.libintegration.CubaReporting - Finished report [CustomerInfo] with parameters []
16:25:01.089 INFO d.d.c.s.s.ScheduledReportRunServiceBean - Email for scheduled report is sent: de.diedavids.cuba.scheduledreports.entity.ScheduledReport-0d62951d-cd30-30e1-cd00-0f31fcf4eb4b [detached]
16:25:01.123 INFO c.h.r.libintegration.CubaReporting - Started report [CustomerInfo] with parameters []
16:25:01.145 INFO c.h.r.libintegration.CubaReporting - Finished report [CustomerInfo] with parameters []

是否配置了发送邮件相关的参数?
https://doc.cuba-platform.cn/manual-7.2-chs/email_sending_properties.html

配置过了,手工发的能收到,电子邮件历史显示“已发送”,Scheduled Report发的就显示“排队中”

从日志中能否找到原因?

转到 Administration > Email History 界面。如果发送成功,电子邮件的状态将为 Sent 。否则最有可能为 SendingQueue 。在后一种情况下,可以在 build/tomcat/logs/app.log 中打开应用程序日志并找出原因。电子邮件发送机制将尝试多次(默认为 10 次)发送邮件消息,如果失败,设置状态为 Not sent
https://doc.cuba-platform.cn/manual-7.2-chs/sending_emails_recipe.html