|
@@ -0,0 +1,41 @@
|
|
|
+package com.example.opc_da.task;
|
|
|
+
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.example.opc_common.entity.ReportTable;
|
|
|
+import com.example.opc_common.util.ConstantStr;
|
|
|
+import com.example.opc_common.util.DateUtil;
|
|
|
+import com.example.opc_da.validate.reportTable.ReportTableValidateFactory;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.SerializationUtils;
|
|
|
+import org.quartz.JobDataMap;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class DeviceTableQuartzTask extends QuartzJobBean {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AsyncTask asyncTask;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void executeInternal(JobExecutionContext context) {
|
|
|
+ JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
|
|
+ ReportTable reportTable = (ReportTable) jobDataMap.get("reportTable");
|
|
|
+ log.info("自动报表,{},执行开始,时间为{}", reportTable.getId(), DateUtil.dateChangeStrYmdhmss(new Date()));
|
|
|
+ //使用深拷贝或者其他方式创建一个新的报表对象,并将其设置为运行状态
|
|
|
+ ReportTable newReportTable = SerializationUtils.clone(reportTable);
|
|
|
+ newReportTable.setRunState(ConstantStr.START_UP);
|
|
|
+ //生成一张新的子报表,并添加相应的日志,以及用户组授权
|
|
|
+ String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
+ asyncTask.addHaveKeyChReport(reportTable.getId(), id, ConstantStr.DEVICE_GENERATE_REPORT,
|
|
|
+ ReportTableValidateFactory.getReportTableValidate(
|
|
|
+ reportTable.getReportTableType()
|
|
|
+ ).getData(newReportTable).getReportTableData(), true);
|
|
|
+ log.info("自动报表,{},执行结束,时间为{}", reportTable.getId(), DateUtil.dateChangeStrYmdhmss(new Date()));
|
|
|
+ }
|
|
|
+}
|