From 2780e6717df31ee605dd8ce525afcb43914ca2de Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 06 一月 2025 13:25:00 +0800 Subject: [PATCH] writePointRealValue打印异常 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java index 489738f..bc3eaad 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java @@ -1,19 +1,13 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - package com.iailab.module.data.job.utils; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.exception.ExceptionUtils; import com.iailab.framework.common.util.spring.SpringContextUtils; -import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.job.entity.ScheduleJobEntity; import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.service.ScheduleJobLogService; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +22,7 @@ * * @author Mark sunlightcs@gmail.com */ +@DisallowConcurrentExecution public class ScheduleJob extends QuartzJobBean { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -36,12 +31,18 @@ ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap(). get(ScheduleUtils.JOB_PARAM_KEY); + //设置当前租户 + TenantContextHolder.setTenantId(scheduleJob.getTenantId()); + Long tenantId = TenantContextHolder.getRequiredTenantId(); + //数据库保存执行记录 ScheduleJobLogEntity log = new ScheduleJobLogEntity(); + log.setId(System.currentTimeMillis()); log.setJobId(scheduleJob.getId()); log.setBeanName(scheduleJob.getBeanName()); log.setParams(scheduleJob.getParams()); log.setCreateDate(new Date()); + log.setTenantId(tenantId); //任务开始时间 long startTime = System.currentTimeMillis(); @@ -72,8 +73,8 @@ log.setError(ExceptionUtils.getErrorStackTrace(e)); }finally { //获取spring bean - /*ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); - scheduleJobLogService.insert(log);*/ + ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); + //scheduleJobLogService.insert(log); } } } \ No newline at end of file -- Gitblit v1.9.3