From c9eea9f24aa52ea59dbb8dcf1cb6cf513ddc74a9 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期五, 25 四月 2025 11:37:32 +0800 Subject: [PATCH] 待机停机维护 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ScanDowntimeJob.java | 220 +++++++++++++++++++++++++++--------------------------- 1 files changed, 110 insertions(+), 110 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ScanDowntimeJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ScanDowntimeJob.java index eafa8fc..8468390 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ScanDowntimeJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ScanDowntimeJob.java @@ -1,110 +1,110 @@ -package org.jeecg.modules.mdc.job; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.modules.mdc.dto.MdcEquipmentWaitSectionDto; -import org.jeecg.modules.mdc.entity.MdcDowntime; -import org.jeecg.modules.mdc.entity.MdcEquipmentOvertime; -import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; -import org.jeecg.modules.mdc.service.IMdcDowntimeService; -import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.util.ThrowableUtil; -import org.jeecg.modules.quartz.entity.QuartzJob; -import org.jeecg.modules.quartz.entity.SysQuartzLog; -import org.jeecg.modules.quartz.service.IQuartzJobService; -import org.jeecg.modules.quartz.service.ISysQuartzLogService; -import org.jeecg.modules.system.service.ISysAnnouncementService; -import org.quartz.*; - -import javax.annotation.Resource; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Author: Lius - * @CreateTime: 2025-03-12 - * @Description: 鎵弿鍋滄満浠诲姟 - */ -@PersistJobDataAfterExecution -@DisallowConcurrentExecution -@Slf4j -public class ScanDowntimeJob implements Job { - - /** - * 鑻ュ弬鏁板彉閲忓悕淇敼 QuartzJobController涓篃闇�瀵瑰簲淇敼 鏃堕棿锛� yyyyMMdd 渚嬶細 20230414 - */ - private String parameter; - - public void setParameter(String parameter) { - this.parameter = parameter; - } - - @Resource - private IQuartzJobService quartzJobService; - - @Resource - private ISysAnnouncementService sysAnnouncementService; - - @Resource - private ISysQuartzLogService sysQuartzLogService; - - @Resource - private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; - - @Resource - private IMdcDowntimeService mdcDowntimeService; - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - SysQuartzLog quartzLog = new SysQuartzLog(); - quartzLog.setCreateTime(new Date()); - List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); - if (byJobClassName != null && !byJobClassName.isEmpty()) { - quartzLog.setJobId(byJobClassName.get(0).getId()); - } - quartzLog.setParams(this.parameter); - log.info("瀹氭椂鎵弿寰呮満鏃堕暱瓒�20鍒嗛挓璁惧浠诲姟 ScanDowntimeJob start! 鏃堕棿:{}, 鍙傛暟锛歿}", DateUtils.getNow(), this.parameter); - long startTime = System.currentTimeMillis(); - try { - String date = ""; - if (StringUtils.isNotBlank(this.parameter)) { - date = DateUtils.format(DateUtils.toDate(this.parameter, DateUtils.STRDATE), DateUtils.STR_DATE); - - } else { - date = DateUtils.format(DateUtils.getNow(), DateUtils.STR_DATE); - } - mdcDowntimeService.remove(new LambdaQueryWrapper<MdcDowntime>().eq(MdcDowntime::getTheDate, date).eq(MdcDowntime::getStatus, CommonConstant.DOWNTIME_STATUS_0)); - - List<MdcEquipmentWaitSectionDto> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.findWaitList(date); - - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - String finalDate = date; - List<MdcDowntime> downtimeList = mdcEquipmentRunningSections.stream().map(mdcEquipmentWaitSectionDto -> { - MdcDowntime downtime = new MdcDowntime(); - downtime.setEquipmentId(mdcEquipmentWaitSectionDto.getEquipmentId()); - downtime.setEquipmentName(mdcEquipmentWaitSectionDto.getEquipmentName()); - downtime.setTheDate(finalDate); - downtime.setStartDate(mdcEquipmentWaitSectionDto.getStartTime()); - downtime.setEndDate(mdcEquipmentWaitSectionDto.getEndTime()); - return downtime; - }).collect(Collectors.toList()); - if (!downtimeList.isEmpty()) { - mdcDowntimeService.saveBatch(downtimeList); - } - } - quartzLog.setIsSuccess(0); - } catch (Exception e) { - quartzLog.setIsSuccess(-1); - quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); - // 鍙戦�佹秷鎭�氱煡 - sysAnnouncementService.jobSendMessage("瀹氭椂鎵弿寰呮満鏃堕暱瓒�20鍒嗛挓璁惧浠诲姟", quartzLog.getExceptionDetail()); - } - long endTime = System.currentTimeMillis(); - quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); - sysQuartzLogService.save(quartzLog); - } -} +//package org.jeecg.modules.mdc.job; +// +//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.lang.StringUtils; +//import org.jeecg.common.constant.CommonConstant; +//import org.jeecg.modules.mdc.dto.MdcEquipmentWaitSectionDto; +//import org.jeecg.modules.mdc.entity.MdcDowntime; +//import org.jeecg.modules.mdc.entity.MdcEquipmentOvertime; +//import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; +//import org.jeecg.modules.mdc.service.IMdcDowntimeService; +//import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService; +//import org.jeecg.modules.mdc.util.DateUtils; +//import org.jeecg.modules.mdc.util.ThrowableUtil; +//import org.jeecg.modules.quartz.entity.QuartzJob; +//import org.jeecg.modules.quartz.entity.SysQuartzLog; +//import org.jeecg.modules.quartz.service.IQuartzJobService; +//import org.jeecg.modules.quartz.service.ISysQuartzLogService; +//import org.jeecg.modules.system.service.ISysAnnouncementService; +//import org.quartz.*; +// +//import javax.annotation.Resource; +//import java.util.Date; +//import java.util.List; +//import java.util.stream.Collectors; +// +///** +// * @Author: Lius +// * @CreateTime: 2025-03-12 +// * @Description: 鎵弿鍋滄満浠诲姟 +// */ +//@PersistJobDataAfterExecution +//@DisallowConcurrentExecution +//@Slf4j +//public class ScanDowntimeJob implements Job { +// +// /** +// * 鑻ュ弬鏁板彉閲忓悕淇敼 QuartzJobController涓篃闇�瀵瑰簲淇敼 鏃堕棿锛� yyyyMMdd 渚嬶細 20230414 +// */ +// private String parameter; +// +// public void setParameter(String parameter) { +// this.parameter = parameter; +// } +// +// @Resource +// private IQuartzJobService quartzJobService; +// +// @Resource +// private ISysAnnouncementService sysAnnouncementService; +// +// @Resource +// private ISysQuartzLogService sysQuartzLogService; +// +// @Resource +// private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; +// +// @Resource +// private IMdcDowntimeService mdcDowntimeService; +// +// @Override +// public void execute(JobExecutionContext context) throws JobExecutionException { +// SysQuartzLog quartzLog = new SysQuartzLog(); +// quartzLog.setCreateTime(new Date()); +// List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); +// if (byJobClassName != null && !byJobClassName.isEmpty()) { +// quartzLog.setJobId(byJobClassName.get(0).getId()); +// } +// quartzLog.setParams(this.parameter); +// log.info("瀹氭椂鎵弿寰呮満鏃堕暱瓒�20鍒嗛挓璁惧浠诲姟 ScanDowntimeJob start! 鏃堕棿:{}, 鍙傛暟锛歿}", DateUtils.getNow(), this.parameter); +// long startTime = System.currentTimeMillis(); +// try { +// String date = ""; +// if (StringUtils.isNotBlank(this.parameter)) { +// date = DateUtils.format(DateUtils.toDate(this.parameter, DateUtils.STRDATE), DateUtils.STR_DATE); +// +// } else { +// date = DateUtils.format(DateUtils.getNow(), DateUtils.STR_DATE); +// } +// mdcDowntimeService.remove(new LambdaQueryWrapper<MdcDowntime>().eq(MdcDowntime::getTheDate, date).eq(MdcDowntime::getStatus, CommonConstant.DOWNTIME_STATUS_0)); +// +// List<MdcEquipmentWaitSectionDto> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.findWaitList(date); +// +// if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { +// String finalDate = date; +// List<MdcDowntime> downtimeList = mdcEquipmentRunningSections.stream().map(mdcEquipmentWaitSectionDto -> { +// MdcDowntime downtime = new MdcDowntime(); +// downtime.setEquipmentId(mdcEquipmentWaitSectionDto.getEquipmentId()); +// downtime.setEquipmentName(mdcEquipmentWaitSectionDto.getEquipmentName()); +// downtime.setTheDate(finalDate); +// downtime.setStartDate(mdcEquipmentWaitSectionDto.getStartTime()); +// downtime.setEndDate(mdcEquipmentWaitSectionDto.getEndTime()); +// return downtime; +// }).collect(Collectors.toList()); +// if (!downtimeList.isEmpty()) { +// mdcDowntimeService.saveBatch(downtimeList); +// } +// } +// quartzLog.setIsSuccess(0); +// } catch (Exception e) { +// quartzLog.setIsSuccess(-1); +// quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); +// // 鍙戦�佹秷鎭�氱煡 +// sysAnnouncementService.jobSendMessage("瀹氭椂鎵弿寰呮満鏃堕暱瓒�20鍒嗛挓璁惧浠诲姟", quartzLog.getExceptionDetail()); +// } +// long endTime = System.currentTimeMillis(); +// quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); +// sysQuartzLogService.save(quartzLog); +// } +//} -- Gitblit v1.9.3