Merge remote-tracking branch 'origin/master'
| | |
| | | package com.iailab.module.data.api.point.dto; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.framework.excel.core.util.ExcelUtils; |
| | | import com.iailab.module.data.api.dto.DeviceValueDTO; |
| | | import com.iailab.module.data.api.dto.IndexQueryDTO; |
| | |
| | | import com.iailab.module.data.common.ApiDataQueryDTO; |
| | | import com.iailab.module.data.common.ApiDataValueDTO; |
| | | import com.iailab.module.data.common.utils.ApiSecurityUtils; |
| | | import com.iailab.module.data.ind.collection.IndItemCollector; |
| | | import com.iailab.module.data.ind.item.vo.IndItemValueVO; |
| | | import com.iailab.module.data.plan.item.entity.PlanItemEntity; |
| | | import com.iailab.module.data.plan.item.service.PlanItemService; |
| | | import com.iailab.module.data.plan.item.vo.PlanItemValueExportVO; |
| | |
| | | |
| | | @Autowired |
| | | private IndItemApi indItemApi; |
| | | |
| | | @Autowired |
| | | private IndItemCollector indItemCollector; |
| | | |
| | | @Autowired |
| | | private PlanItemService planItemService; |
| | |
| | | //JobStore配置 |
| | | prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); |
| | | //集群配置 |
| | | prop.put("org.quartz.jobStore.isClustered", "true"); |
| | | prop.put("org.quartz.jobStore.isClustered", "false"); |
| | | prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); |
| | | prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); |
| | | |
对比新文件 |
| | |
| | | package com.iailab.module.data.job.config; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月06日 |
| | | */ |
| | | @Component |
| | | public class ScheduleJobListConfig { |
| | | public static List<String> scheduleJobList = new ArrayList<>(); |
| | | |
| | | public ScheduleJobListConfig() { |
| | | scheduleJobList.add("devCameraDahuaTask"); |
| | | scheduleJobList.add("devCameraHikvisionTask"); |
| | | scheduleJobList.add("pointCollectTaskNet1h"); |
| | | scheduleJobList.add("pointCollectTaskNet10"); |
| | | scheduleJobList.add("pointCollectTaskNet30"); |
| | | scheduleJobList.add("pointCollectTaskNet60"); |
| | | scheduleJobList.add("pointCollectTaskNetKIO10"); |
| | | scheduleJobList.add("pointCollectTaskNetKIO60"); |
| | | } |
| | | } |
| | |
| | | import com.iailab.framework.common.exception.ExceptionUtils; |
| | | import com.iailab.framework.common.util.spring.SpringContextUtils; |
| | | import com.iailab.framework.tenant.core.context.TenantContextHolder; |
| | | import com.iailab.module.data.job.config.ScheduleJobListConfig; |
| | | import com.iailab.module.data.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.data.job.entity.ScheduleJobLogEntity; |
| | | import com.iailab.module.data.job.service.ScheduleJobLogService; |
| | |
| | | ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap(). |
| | | get(ScheduleUtils.JOB_PARAM_KEY); |
| | | |
| | | // 过滤定时任务 |
| | | if (!ScheduleJobListConfig.scheduleJobList.contains(scheduleJob.getBeanName())) { |
| | | logger.info("过滤定时任务,BeanName=" + scheduleJob.getBeanName()); |
| | | return; |
| | | } |
| | | |
| | | //设置当前租户 |
| | | TenantContextHolder.setTenantId(scheduleJob.getTenantId()); |
| | | Long tenantId = TenantContextHolder.getRequiredTenantId(); |
| | |
| | | @Operation(summary = "添加调度建议") |
| | | Boolean createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); |
| | | |
| | | @GetMapping(PREFIX + "/schedule-suggest/list") |
| | | @PostMapping(PREFIX + "/schedule-suggest/list") |
| | | @Operation(summary = "获取调度建议列表") |
| | | List<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam Map<String, Object> params); |
| | | List<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestBody ScheduleSuggestReqDTO vo); |
| | | |
| | | @PostMapping(PREFIX + "/predict-model-setting/modify") |
| | | @Operation(summary = "修改预测模型设置参数") |
| | |
| | | @Operation(summary = "添加电价时段配置列表") |
| | | Boolean createElectricityPrice(@RequestBody List<ElectricityPriceSegmentedDTO> list); |
| | | |
| | | @PostMapping(PREFIX + "/schedule/model/setting/update") |
| | | @Operation(summary = "修改调度模型配置") |
| | | Boolean updateScheduleModelSetting(@RequestParam("modelCode") String modelCode, @RequestParam("key") String key, @RequestParam("value") String value); |
| | | |
| | | } |
| | |
| | | private String modelId; |
| | | |
| | | @Schema(description = "调整对象") |
| | | private String adjustObj; |
| | | private String scheduleObj; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | |
| | | <version>6.8.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <version>2.3.2</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | import com.iailab.module.model.mcs.pre.vo.MmItemOutputRespVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleRecordService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleSuggestService; |
| | | import com.iailab.module.model.mcs.sche.service.*; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestSaveReqVO; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import com.iailab.module.model.mpk.service.ChartParamService; |
| | |
| | | |
| | | @Autowired |
| | | private ElectricityPriceSegmentedService electricityPriceSegmentedService; |
| | | |
| | | @Autowired |
| | | private StScheduleModelService stScheduleModelService; |
| | | |
| | | @Autowired |
| | | private StScheduleModelSettingService stScheduleModelSettingService; |
| | | |
| | | |
| | | private int HOUR_MINS = 60; |
| | | |
| | |
| | | }).collect(Collectors.toList()); |
| | | dataView.setPreMax(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | dataView.setPreMin(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | dataView.setPreLast(new BigDecimal(curList.get(curList.size() - 1))); |
| | | dataView.setPreCumulant(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).sum())); |
| | | dataView.setPreLast(new BigDecimal(curList.get(curList.size() - 1)).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | dataView.setPreCumulant(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).sum()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | |
| | | String alarmObj = chartParams.get(CommonConstant.ALARM_OBJ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ScheduleSuggestRespDTO> listScheduleSuggest(Map<String, Object> params) { |
| | | return Collections.emptyList(); |
| | | public List<ScheduleSuggestRespDTO> listScheduleSuggest(ScheduleSuggestReqDTO vo) { |
| | | return stScheduleSuggestService.list(vo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateScheduleModelSetting(String modelCode, String key, String value) { |
| | | StScheduleModelEntity model = stScheduleModelService.getByModelCode(modelCode); |
| | | stScheduleModelSettingService.updateByModelIdAndKey(model.getId(), key, value); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 计算功率因数 p²/(根号:p²+Q²) |
| | | **/ |
| | |
| | | } |
| | | |
| | | @GetMapping("/schedule-suggest/last-limit") |
| | | @Operation(summary = "根据监控对象获取最新预警信息") |
| | | @Operation(summary = "根据监控对象获取最新调度建议") |
| | | public CommonResult<List<ScheduleSuggestRespDTO>> getLastLimitScheduleSuggest(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit) { |
| | | List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit); |
| | | return CommonResult.success(data); |
| | | } |
| | | |
| | | @PostMapping("/schedule-suggest/list") |
| | | @Operation(summary = "获取调度建议") |
| | | public CommonResult<List<ScheduleSuggestRespDTO>> listScheduleSuggest(@RequestBody ScheduleSuggestReqDTO vo) { |
| | | List<ScheduleSuggestRespDTO> list = mcsApi.listScheduleSuggest(vo); |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/alarm-suggest/page") |
| | |
| | | List<ElectricityPriceSegmentedDTO> electricityPriceSegmentedList = mcsApi.getElectricityPriceList(year, time); |
| | | return CommonResult.success(electricityPriceSegmentedList); |
| | | } |
| | | |
| | | @GetMapping("/schedule/model/setting/update") |
| | | @Operation(summary = "修改调度模型配置") |
| | | public CommonResult<Boolean> updateScheduleModelSetting(@RequestParam("modelCode") String modelCode, @RequestParam("key") String key, @RequestParam("value") String value){ |
| | | mcsApi.updateScheduleModelSetting(modelCode, key, value); |
| | | return success( true); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * <p> |
| | | * https://www.renren.io |
| | | * <p> |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.common.utils; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.joda.time.DateTime; |
| | | import org.joda.time.LocalDate; |
| | | import org.joda.time.format.DateTimeFormat; |
| | | import org.joda.time.format.DateTimeFormatter; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 日期处理 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class DateUtils { |
| | | /** 时间格式(yyyy-MM-dd) */ |
| | | public final static String DATE_PATTERN = "yyyy-MM-dd"; |
| | | /** 时间格式(yyyy-MM-dd HH:mm:ss) */ |
| | | public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | public final static String DATE_TIME_PATTERN_MIN = "yyyy-MM-dd HH:mm"; |
| | | |
| | | public final static String TIME2_PATTERN = "mmss"; |
| | | |
| | | public final static String DATE_PATTERN_MON = "yyyy-MM"; |
| | | |
| | | public final static String DATE_PATTERN_YEAR = "yyyy"; |
| | | |
| | | /** |
| | | * 日期格式化 日期格式为:yyyy-MM-dd |
| | | * @param date 日期 |
| | | * @return 返回yyyy-MM-dd格式日期 |
| | | */ |
| | | public static String format(Date date) { |
| | | return format(date, DATE_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * 日期格式化 日期格式为:yyyy-MM-dd |
| | | * @param date 日期 |
| | | * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN |
| | | * @return 返回yyyy-MM-dd格式日期 |
| | | */ |
| | | public static String format(Date date, String pattern) { |
| | | if (date != null) { |
| | | SimpleDateFormat df = new SimpleDateFormat(pattern); |
| | | return df.format(date); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 日期解析 |
| | | * @param date 日期 |
| | | * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN |
| | | * @return 返回Date |
| | | */ |
| | | public static Date parse(String date, String pattern) { |
| | | try { |
| | | return new SimpleDateFormat(pattern).parse(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 字符串转换成日期 |
| | | * @param strDate 日期字符串 |
| | | * @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN |
| | | */ |
| | | public static Date stringToDate(String strDate, String pattern) { |
| | | if (StringUtils.isBlank(strDate)) { |
| | | return null; |
| | | } |
| | | |
| | | DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); |
| | | return fmt.parseLocalDateTime(strDate).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 根据周数,获取开始日期、结束日期 |
| | | * @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周 |
| | | * @return 返回date[0]开始日期、date[1]结束日期 |
| | | */ |
| | | public static Date[] getWeekStartAndEnd(int week) { |
| | | DateTime dateTime = new DateTime(); |
| | | LocalDate date = new LocalDate(dateTime.plusWeeks(week)); |
| | | |
| | | date = date.dayOfWeek().withMinimumValue(); |
| | | Date beginDate = date.toDate(); |
| | | Date endDate = date.plusDays(6).toDate(); |
| | | return new Date[]{beginDate, endDate}; |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【秒】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param seconds 秒数,负数为减 |
| | | * @return 加/减几秒后的日期 |
| | | */ |
| | | public static Date addDateSeconds(Date date, int seconds) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusSeconds(seconds).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【分钟】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param minutes 分钟数,负数为减 |
| | | * @return 加/减几分钟后的日期 |
| | | */ |
| | | public static Date addDateMinutes(Date date, int minutes) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusMinutes(minutes).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【小时】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param hours 小时数,负数为减 |
| | | * @return 加/减几小时后的日期 |
| | | */ |
| | | public static Date addDateHours(Date date, int hours) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusHours(hours).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【天】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param days 天数,负数为减 |
| | | * @return 加/减几天后的日期 |
| | | */ |
| | | public static Date addDateDays(Date date, int days) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusDays(days).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【周】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param weeks 周数,负数为减 |
| | | * @return 加/减几周后的日期 |
| | | */ |
| | | public static Date addDateWeeks(Date date, int weeks) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusWeeks(weeks).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【月】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param months 月数,负数为减 |
| | | * @return 加/减几月后的日期 |
| | | */ |
| | | public static Date addDateMonths(Date date, int months) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusMonths(months).toDate(); |
| | | } |
| | | |
| | | /** |
| | | * 对日期的【年】进行加/减 |
| | | * |
| | | * @param date 日期 |
| | | * @param years 年数,负数为减 |
| | | * @return 加/减几年后的日期 |
| | | */ |
| | | public static Date addDateYears(Date date, int years) { |
| | | DateTime dateTime = new DateTime(date); |
| | | return dateTime.plusYears(years).toDate(); |
| | | } |
| | | |
| | | public static List<String> getDays(Date startDate, Date endDate) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (calendar.getTime().compareTo(endDate) < 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), "yyyy-MM-dd")); |
| | | calendar.add(6, 1); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | public static Date getTime(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | public static List<String> getYearTime(Date startDate, Date endDate) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (calendar.getTime().compareTo(endDate) <= 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN_YEAR)); |
| | | calendar.add(Calendar.YEAR, 1); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | public static List<String> getMonTime(Date startDate, Date endDate) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (calendar.getTime().compareTo(endDate) <= 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN_MON)); |
| | | calendar.add(Calendar.MONTH, 1); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | public static List<String> getDayTime(Date startDate, Date endDate) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (calendar.getTime().compareTo(endDate) <= 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN)); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | public static List<String> getDayTime(Date startDate, Date endDate, int seconds) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | while (calendar.getTime().compareTo(endDate) <= 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_TIME_PATTERN)); |
| | | calendar.add(Calendar.SECOND, seconds); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | public static List<String> getClassTime(Date startDate, Date endDate) { |
| | | List<String> days = new ArrayList<String>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | while (calendar.getTime().compareTo(endDate) <= 0) { |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 0点班"); |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 8点班"); |
| | | days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 16点班"); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | } |
| | | return days; |
| | | } |
| | | |
| | | |
| | | public static Map<String, Date> getIntervalDate(int days) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DAY_OF_YEAR, days); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | Date tEndDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, -1); |
| | | Date tStartDate = calendar.getTime(); |
| | | Map<String, Date> tMap = new HashMap<String, Date>(2); |
| | | tMap.put("startdate", tStartDate); |
| | | tMap.put("enddate", tEndDate); |
| | | return tMap; |
| | | |
| | | } |
| | | |
| | | public static boolean isNotBlank(Date date) { |
| | | if (date == null) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * 定时任务配置 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Configuration |
| | | public class ScheduleConfig { |
| | | |
| | | @Bean |
| | | public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) { |
| | | SchedulerFactoryBean factory = new SchedulerFactoryBean(); |
| | | factory.setDataSource(dataSource); |
| | | |
| | | //quartz参数 |
| | | Properties prop = new Properties(); |
| | | prop.put("org.quartz.scheduler.instanceName", "IailabModelScheduler"); |
| | | prop.put("org.quartz.scheduler.instanceId", "AUTO"); |
| | | //线程池配置 |
| | | prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); |
| | | prop.put("org.quartz.threadPool.threadCount", "20"); |
| | | prop.put("org.quartz.threadPool.threadPriority", "5"); |
| | | //JobStore配置 |
| | | prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); |
| | | //集群配置 |
| | | prop.put("org.quartz.jobStore.isClustered", "false"); |
| | | prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); |
| | | prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); |
| | | |
| | | prop.put("org.quartz.jobStore.misfireThreshold", "12000"); |
| | | prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); |
| | | prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); |
| | | |
| | | //PostgreSQL数据库,需要打开此注释 |
| | | //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate"); |
| | | |
| | | factory.setQuartzProperties(prop); |
| | | |
| | | factory.setSchedulerName("IailabModelScheduler"); |
| | | //延时启动 |
| | | factory.setStartupDelay(30); |
| | | factory.setApplicationContextSchedulerContextKey("applicationContextKey"); |
| | | //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 |
| | | factory.setOverwriteExistingJobs(true); |
| | | //设置自动启动,默认为true |
| | | factory.setAutoStartup(true); |
| | | |
| | | return factory; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.config; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月06日 |
| | | */ |
| | | @Component |
| | | public class ScheduleJobListConfig { |
| | | public static List<String> scheduleJobList = new ArrayList<>(); |
| | | |
| | | public ScheduleJobListConfig() { |
| | | scheduleJobList.add("cleanItemResultJsonTask"); |
| | | scheduleJobList.add("cleanMmPredictAlarmMessageTask"); |
| | | scheduleJobList.add("cleanScheduleRecordTask"); |
| | | scheduleJobList.add("cleanStScheduleSuggestTask"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.controller.admin; |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.common.util.validation.ValidationUtils; |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.DefaultGroup; |
| | | import com.iailab.framework.common.validation.group.UpdateGroup; |
| | | import com.iailab.framework.tenant.core.context.TenantContextHolder; |
| | | import com.iailab.module.model.job.dto.ScheduleJobDTO; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.service.ScheduleJobService; |
| | | import com.iailab.module.model.job.vo.ScheduleJobReqVO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/model/job/schedule") |
| | | @Tag(name = "定时任务") |
| | | public class ScheduleJobController { |
| | | @Resource |
| | | private ScheduleJobService scheduleJobService; |
| | | |
| | | @GetMapping("page") |
| | | @Operation(summary = "分页") |
| | | @Parameters({ |
| | | @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
| | | @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
| | | @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
| | | @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , |
| | | @Parameter(name = "beanName", description = "beanName") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('model:schedule:query')") |
| | | public CommonResult<PageResult<ScheduleJobDTO>> page(@Validated ScheduleJobReqVO reqVO){ |
| | | reqVO.setTenantId(TenantContextHolder.getTenantId()); |
| | | PageResult<ScheduleJobEntity> page = scheduleJobService.page(reqVO); |
| | | |
| | | return success(BeanUtils.toBean(page, ScheduleJobDTO.class)); |
| | | } |
| | | |
| | | @GetMapping("info") |
| | | @Operation(summary = "信息") |
| | | @PreAuthorize("@ss.hasPermission('model:schedule:query')") |
| | | public CommonResult<ScheduleJobDTO> info(@RequestParam("id") Long id){ |
| | | ScheduleJobDTO schedule = scheduleJobService.get(id); |
| | | |
| | | return new CommonResult<ScheduleJobDTO>().setData(schedule); |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "保存") |
| | | @PreAuthorize("@ss.hasPermission('model:schedule:create')") |
| | | public CommonResult save(@RequestBody ScheduleJobDTO dto){ |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | |
| | | scheduleJobService.save(dto); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "修改") |
| | | @PreAuthorize("@ss.hasPermission('model:schedule:update')") |
| | | public CommonResult update(@RequestBody ScheduleJobDTO dto){ |
| | | ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); |
| | | |
| | | scheduleJobService.update(dto); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除") |
| | | @PreAuthorize("@ss.hasPermission('model:schedule:delete')") |
| | | public CommonResult delete(@RequestParam("id") Long id){ |
| | | scheduleJobService.deleteBatch(id); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/run") |
| | | @Operation(summary = "立即执行") |
| | | public CommonResult run(@RequestParam("id") Long id){ |
| | | Long[] ids = new Long[1]; |
| | | ids[0] = id; |
| | | scheduleJobService.run(ids); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/pause") |
| | | @Operation(summary = "暂停") |
| | | public CommonResult pause(@RequestParam("id") Long id){ |
| | | Long[] ids = new Long[1]; |
| | | ids[0] = id; |
| | | scheduleJobService.pause(ids); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/resume") |
| | | @Operation(summary = "恢复") |
| | | public CommonResult resume(@RequestParam("id") Long id){ |
| | | Long[] ids = new Long[1]; |
| | | ids[0] = id; |
| | | scheduleJobService.resume(ids); |
| | | |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.controller.admin; |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.model.job.dto.ScheduleJobLogDTO; |
| | | import com.iailab.module.model.job.service.ScheduleJobLogService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 定时任务日志 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/sys/scheduleLog") |
| | | @Tag(name = "定时任务日志") |
| | | public class ScheduleJobLogController { |
| | | @Resource |
| | | private ScheduleJobLogService scheduleJobLogService; |
| | | |
| | | @GetMapping("page") |
| | | @Operation(summary = "分页") |
| | | @Parameters({ |
| | | @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
| | | @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
| | | @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
| | | @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , |
| | | @Parameter(name = "jobId", description = "jobId") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('sys:schedule:log')") |
| | | public CommonResult<PageData<ScheduleJobLogDTO>> page(@RequestParam Map<String, Object> params){ |
| | | PageData<ScheduleJobLogDTO> page = scheduleJobLogService.page(params); |
| | | |
| | | return new CommonResult<PageData<ScheduleJobLogDTO>>().setData(page); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @Operation(summary = "信息") |
| | | @PreAuthorize("@ss.hasPermission('sys:schedule:log')") |
| | | public CommonResult<ScheduleJobLogDTO> info(@PathVariable("id") Long id){ |
| | | ScheduleJobLogDTO log = scheduleJobLogService.get(id); |
| | | |
| | | return new CommonResult<ScheduleJobLogDTO>().setData(log); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.dao; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.Master; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.vo.ScheduleJobReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Master |
| | | @Mapper |
| | | public interface ScheduleJobDao extends BaseMapperX<ScheduleJobEntity> { |
| | | |
| | | default PageResult<ScheduleJobEntity> selectPage(ScheduleJobReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<ScheduleJobEntity>() |
| | | .likeIfPresent(ScheduleJobEntity::getBeanName, reqVO.getBeanName()) |
| | | .eqIfPresent(ScheduleJobEntity::getTenantId, reqVO.getTenantId()) |
| | | .orderByDesc(ScheduleJobEntity::getCreateDate)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 批量更新状态 |
| | | */ |
| | | int updateBatch(Map<String, Object> map); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.dao; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.Master; |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.model.job.entity.ScheduleJobLogEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * 定时任务日志 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Master |
| | | @Mapper |
| | | public interface ScheduleJobLogDao extends BaseDao<ScheduleJobLogEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.DefaultGroup; |
| | | import com.iailab.framework.common.validation.group.UpdateGroup; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import javax.validation.constraints.Null; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | @Data |
| | | @Tag(name = "定时任务") |
| | | public class ScheduleJobDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "id") |
| | | @Null(message="{id.null}", groups = AddGroup.class) |
| | | @NotNull(message="{id.require}", groups = UpdateGroup.class) |
| | | private Long id; |
| | | |
| | | @Schema(description = "spring bean名称") |
| | | @NotBlank(message = "{schedule.bean.require}", groups = DefaultGroup.class) |
| | | private String beanName; |
| | | |
| | | @Schema(description = "参数") |
| | | private String params; |
| | | |
| | | @Schema(description = "cron表达式") |
| | | @NotBlank(message = "{schedule.cron.require}", groups = DefaultGroup.class) |
| | | private String cronExpression; |
| | | |
| | | @Schema(description = "任务状态 0:暂停 1:正常") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "备注") |
| | | private String remark; |
| | | |
| | | @Schema(description = "创建时间") |
| | | @JsonProperty(access = JsonProperty.Access.READ_ONLY) |
| | | private Date createDate; |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 定时任务日志 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | @Data |
| | | @Tag(name = "定时任务日志") |
| | | public class ScheduleJobLogDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "id") |
| | | private Long id; |
| | | |
| | | @Schema(description = "任务id") |
| | | private Long jobId; |
| | | |
| | | @Schema(description = "spring bean名称") |
| | | private String beanName; |
| | | |
| | | @Schema(description = "参数") |
| | | private String params; |
| | | |
| | | @Schema(description = "任务状态 0:失败 1:成功") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "失败信息") |
| | | private String error; |
| | | |
| | | @Schema(description = "耗时(单位:毫秒)") |
| | | private Integer times; |
| | | |
| | | @Schema(description = "创建时间") |
| | | private Date createDate; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.common.entity.BaseEntity; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=false) |
| | | @TableName("schedule_job") |
| | | public class ScheduleJobEntity extends BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * spring bean名称 |
| | | */ |
| | | private String beanName; |
| | | /** |
| | | * 参数 |
| | | */ |
| | | private String params; |
| | | /** |
| | | * cron表达式 |
| | | */ |
| | | private String cronExpression; |
| | | /** |
| | | * 任务状态 0:暂停 1:正常 |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | /** |
| | | * 更新者 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updater; |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateDate; |
| | | |
| | | /** |
| | | * 多租户编号 |
| | | */ |
| | | private Long tenantId; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 定时任务日志 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Data |
| | | @TableName("schedule_job_log") |
| | | public class ScheduleJobLogEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * 任务id |
| | | */ |
| | | private Long jobId; |
| | | /** |
| | | * spring bean名称 |
| | | */ |
| | | private String beanName; |
| | | /** |
| | | * 参数 |
| | | */ |
| | | private String params; |
| | | /** |
| | | * 任务状态 0:失败 1:成功 |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 失败信息 |
| | | */ |
| | | private String error; |
| | | /** |
| | | * 耗时(单位:毫秒) |
| | | */ |
| | | private Integer times; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createDate; |
| | | |
| | | /** |
| | | * 多租户编号 |
| | | */ |
| | | private Long tenantId; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.init; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.module.model.job.dao.ScheduleJobDao; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.utils.ScheduleUtils; |
| | | import org.quartz.CronTrigger; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.stereotype.Component; |
| | | import org.quartz.Scheduler; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 初始化定时任务数据 |
| | | */ |
| | | @Component |
| | | public class JobCommandLineRunner implements CommandLineRunner { |
| | | @Resource |
| | | private Scheduler scheduler; |
| | | @Resource |
| | | private ScheduleJobDao scheduleJobDao; |
| | | |
| | | @Override |
| | | public void run(String... args) { |
| | | List<ScheduleJobEntity> scheduleJobList = scheduleJobDao.selectList(new QueryWrapper<>()); |
| | | for(ScheduleJobEntity scheduleJob : scheduleJobList){ |
| | | CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getId()); |
| | | //如果不存在,则创建 |
| | | if(cronTrigger == null) { |
| | | ScheduleUtils.createScheduleJob(scheduler, scheduleJob); |
| | | }else { |
| | | ScheduleUtils.updateScheduleJob(scheduler, scheduleJob); |
| | | } |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job; |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.job.dto.ScheduleJobLogDTO; |
| | | import com.iailab.module.model.job.entity.ScheduleJobLogEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 定时任务日志 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public interface ScheduleJobLogService extends BaseService<ScheduleJobLogEntity> { |
| | | |
| | | PageData<ScheduleJobLogDTO> page(Map<String, Object> params); |
| | | |
| | | ScheduleJobLogDTO get(Long id); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.service; |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.job.dto.ScheduleJobDTO; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.vo.ScheduleJobReqVO; |
| | | |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public interface ScheduleJobService extends BaseService<ScheduleJobEntity> { |
| | | |
| | | PageResult<ScheduleJobEntity> page(ScheduleJobReqVO reqVO); |
| | | |
| | | ScheduleJobDTO get(Long id); |
| | | |
| | | /** |
| | | * 保存定时任务 |
| | | */ |
| | | void save(ScheduleJobDTO dto); |
| | | |
| | | /** |
| | | * 更新定时任务 |
| | | */ |
| | | void update(ScheduleJobDTO dto); |
| | | |
| | | /** |
| | | * 批量删除定时任务 |
| | | */ |
| | | void deleteBatch(Long id); |
| | | |
| | | /** |
| | | * 批量更新定时任务状态 |
| | | */ |
| | | int updateBatch(Long[] ids, int status); |
| | | |
| | | /** |
| | | * 立即执行 |
| | | */ |
| | | void run(Long[] ids); |
| | | |
| | | /** |
| | | * 暂停运行 |
| | | */ |
| | | void pause(Long[] ids); |
| | | |
| | | /** |
| | | * 恢复运行 |
| | | */ |
| | | void resume(Long[] ids); |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.model.job.dao.ScheduleJobLogDao; |
| | | import com.iailab.module.model.job.dto.ScheduleJobLogDTO; |
| | | import com.iailab.module.model.job.entity.ScheduleJobLogEntity; |
| | | import com.iailab.module.model.job.service.ScheduleJobLogService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class ScheduleJobLogServiceImpl extends BaseServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService { |
| | | |
| | | @Override |
| | | public PageData<ScheduleJobLogDTO> page(Map<String, Object> params) { |
| | | IPage<ScheduleJobLogEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_DATE, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, ScheduleJobLogDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<ScheduleJobLogEntity> getWrapper(Map<String, Object> params){ |
| | | String jobId = (String)params.get("jobId"); |
| | | |
| | | QueryWrapper<ScheduleJobLogEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(StringUtils.isNotBlank(jobId), "job_id", jobId); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public ScheduleJobLogDTO get(Long id) { |
| | | ScheduleJobLogEntity entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, ScheduleJobLogDTO.class); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
| | | import com.iailab.framework.tenant.core.context.TenantContextHolder; |
| | | import com.iailab.module.model.job.dao.ScheduleJobDao; |
| | | import com.iailab.module.model.job.dto.ScheduleJobDTO; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.service.ScheduleJobService; |
| | | import com.iailab.module.model.job.utils.ScheduleUtils; |
| | | import com.iailab.module.model.job.vo.ScheduleJobReqVO; |
| | | import org.quartz.Scheduler; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { |
| | | @Resource |
| | | private Scheduler scheduler; |
| | | |
| | | @Override |
| | | public PageResult<ScheduleJobEntity> page(ScheduleJobReqVO reqVO) { |
| | | return baseDao.selectPage(reqVO); |
| | | } |
| | | |
| | | @Override |
| | | public ScheduleJobDTO get(Long id) { |
| | | ScheduleJobEntity entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<ScheduleJobEntity> getWrapper(Map<String, Object> params){ |
| | | String beanName = (String)params.get("beanName"); |
| | | |
| | | QueryWrapper<ScheduleJobEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(beanName), "bean_name", beanName); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void save(ScheduleJobDTO dto) { |
| | | Long tenantId = TenantContextHolder.getRequiredTenantId(); |
| | | ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); |
| | | entity.setId(System.currentTimeMillis()); |
| | | entity.setStatus(Constant.ScheduleStatus.NORMAL.getValue()); |
| | | entity.setTenantId(tenantId); |
| | | entity.setCreator(SecurityFrameworkUtils.getLoginUser().getId()); |
| | | entity.setCreateDate(new Date()); |
| | | this.insert(entity); |
| | | |
| | | ScheduleUtils.createScheduleJob(scheduler, entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ScheduleJobDTO dto) { |
| | | Long tenantId = TenantContextHolder.getRequiredTenantId(); |
| | | ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); |
| | | entity.setUpdateDate(new Date()); |
| | | entity.setUpdater(SecurityFrameworkUtils.getLoginUser().getId()); |
| | | entity.setTenantId(tenantId); |
| | | ScheduleUtils.updateScheduleJob(scheduler, entity); |
| | | |
| | | this.updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteBatch(Long id) { |
| | | ScheduleUtils.deleteScheduleJob(scheduler, id); |
| | | |
| | | baseDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int updateBatch(Long[] ids, int status){ |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("ids", ids); |
| | | map.put("status", status); |
| | | return baseDao.updateBatch(map); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void run(Long[] ids) { |
| | | for(Long id : ids){ |
| | | ScheduleUtils.run(scheduler, this.selectById(id)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void pause(Long[] ids) { |
| | | for(Long id : ids){ |
| | | ScheduleUtils.pauseJob(scheduler, id); |
| | | } |
| | | |
| | | updateBatch(ids, Constant.ScheduleStatus.PAUSE.getValue()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void resume(Long[] ids) { |
| | | for(Long id : ids){ |
| | | ScheduleUtils.resumeJob(scheduler, id); |
| | | } |
| | | |
| | | updateBatch(ids, Constant.ScheduleStatus.NORMAL.getValue()); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.task; |
| | | |
| | | import com.iailab.module.model.common.utils.DateUtils; |
| | | import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 清理预测json数据表 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月05日 |
| | | */ |
| | | @Component("cleanItemResultJsonTask") |
| | | public class CleanItemResultJsonTask implements ITask { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | |
| | | @Autowired |
| | | private MmItemResultJsonService mmItemResultJsonService; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("CleanItemResultJsonTask定时任务正在执行,参数为:{}",params ); |
| | | try { |
| | | int days = -40; |
| | | if (StringUtils.isNotBlank(params)) { |
| | | days = Math.abs(Integer.parseInt(params)) * -1; |
| | | } |
| | | Map<String, Date> tMap = DateUtils.getIntervalDate(days); |
| | | mmItemResultJsonService.cleanResultJson(tMap); |
| | | } catch (Exception ex) { |
| | | logger.error("CleanItemResultJsonTask运行异常"); |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("CleanItemResultJsonTask运行完成"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.task; |
| | | |
| | | import com.iailab.module.model.common.utils.DateUtils; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictAlarmMessageService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 清理预警消息表 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月05日 |
| | | */ |
| | | @Component("cleanMmPredictAlarmMessageTask") |
| | | public class CleanMmPredictAlarmMessageTask implements ITask { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | |
| | | @Autowired |
| | | private MmPredictAlarmMessageService mmPredictAlarmMessageService; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("CleanMmPredictAlarmMessageTask定时任务正在执行,参数为:{}",params ); |
| | | try { |
| | | int days = -40; |
| | | if (StringUtils.isNotBlank(params)) { |
| | | days = Math.abs(Integer.parseInt(params)) * -1; |
| | | } |
| | | Map<String, Date> tMap = DateUtils.getIntervalDate(days); |
| | | mmPredictAlarmMessageService.cleanAlarmMessage(tMap); |
| | | } catch (Exception ex) { |
| | | logger.error("CleanMmPredictAlarmMessageTask运行异常"); |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("CleanMmPredictAlarmMessageTask运行完成"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.task; |
| | | |
| | | import com.iailab.module.model.common.utils.DateUtils; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleRecordDetailService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleRecordService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 清理调度记录表 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月05日 |
| | | */ |
| | | @Component("cleanScheduleRecordTask") |
| | | public class CleanScheduleRecordTask implements ITask { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | |
| | | @Autowired |
| | | private StScheduleRecordService stScheduleRecordService; |
| | | |
| | | @Autowired |
| | | private StScheduleRecordDetailService stScheduleRecordDetailService; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("CleanScheduleRecordTask定时任务正在执行,参数为:{}",params ); |
| | | try { |
| | | int days = -40; |
| | | if (StringUtils.isNotBlank(params)) { |
| | | days = Math.abs(Integer.parseInt(params)) * -1; |
| | | } |
| | | Map<String, Date> tMap = DateUtils.getIntervalDate(days); |
| | | stScheduleRecordService.cleanScheduleRecord(tMap); |
| | | stScheduleRecordDetailService.cleanScheduleRecordDetail(tMap); |
| | | } catch (Exception ex) { |
| | | logger.error("CleanScheduleRecordTask运行异常"); |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("CleanScheduleRecordTask运行完成"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.task; |
| | | |
| | | import com.iailab.module.model.common.utils.DateUtils; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleSuggestService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 清理调度建议表 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2025年02月05日 |
| | | */ |
| | | @Component("cleanStScheduleSuggestTask") |
| | | public class CleanStScheduleSuggestTask implements ITask { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | |
| | | @Autowired |
| | | private StScheduleSuggestService stScheduleSuggestService; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("CleanStScheduleSuggestTask定时任务正在执行,参数为:{}",params ); |
| | | try { |
| | | int days = -40; |
| | | if (StringUtils.isNotBlank(params)) { |
| | | days = Math.abs(Integer.parseInt(params)) * -1; |
| | | } |
| | | Map<String, Date> tMap = DateUtils.getIntervalDate(days); |
| | | stScheduleSuggestService.cleanScheduleSuggest(tMap); |
| | | } catch (Exception ex) { |
| | | logger.error("CleanStScheduleSuggestTask运行异常"); |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("CleanStScheduleSuggestTask运行完成"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.model.job.task; |
| | | |
| | | /** |
| | | * 定时任务接口,所有定时任务都要实现该接口 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface ITask { |
| | | |
| | | /** |
| | | * 执行定时任务接口 |
| | | * |
| | | * @param params 参数,多参数使用JSON数据 |
| | | */ |
| | | void run(String params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.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.framework.tenant.core.context.TenantContextHolder; |
| | | import com.iailab.module.model.job.config.ScheduleJobListConfig; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import com.iailab.module.model.job.entity.ScheduleJobLogEntity; |
| | | import com.iailab.module.model.job.service.ScheduleJobLogService; |
| | | import org.quartz.DisallowConcurrentExecution; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.scheduling.quartz.QuartzJobBean; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 定时任务 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @DisallowConcurrentExecution |
| | | public class ScheduleJob extends QuartzJobBean { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Override |
| | | protected void executeInternal(JobExecutionContext context) { |
| | | ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap(). |
| | | get(ScheduleUtils.JOB_PARAM_KEY); |
| | | |
| | | // 过滤定时任务 |
| | | if (!ScheduleJobListConfig.scheduleJobList.contains(scheduleJob.getBeanName())) { |
| | | logger.info("过滤定时任务,BeanName=" + scheduleJob.getBeanName()); |
| | | return; |
| | | } |
| | | |
| | | //设置当前租户 |
| | | 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(); |
| | | |
| | | try { |
| | | //执行任务 |
| | | logger.info("任务准备执行,任务ID:{}", scheduleJob.getId()); |
| | | Object target = SpringContextUtils.getBean(scheduleJob.getBeanName()); |
| | | Method method = target.getClass().getDeclaredMethod("run", String.class); |
| | | method.invoke(target, scheduleJob.getParams()); |
| | | |
| | | //任务执行总时长 |
| | | long times = System.currentTimeMillis() - startTime; |
| | | log.setTimes((int)times); |
| | | //任务状态 |
| | | log.setStatus(Constant.SUCCESS); |
| | | |
| | | logger.info("任务执行完毕,任务ID:{} 总共耗时:{} 毫秒", scheduleJob.getId(), times); |
| | | } catch (Exception e) { |
| | | logger.error("任务执行失败,任务ID:{}", scheduleJob.getId(), e); |
| | | |
| | | //任务执行总时长 |
| | | long times = System.currentTimeMillis() - startTime; |
| | | log.setTimes((int)times); |
| | | |
| | | //任务状态 |
| | | log.setStatus(Constant.FAIL); |
| | | log.setError(ExceptionUtils.getErrorStackTrace(e)); |
| | | }finally { |
| | | //获取spring bean |
| | | ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); |
| | | //scheduleJobLogService.insert(log); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.utils; |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.enums.ErrorCode; |
| | | import com.iailab.framework.common.exception.ServerException; |
| | | import com.iailab.module.model.job.entity.ScheduleJobEntity; |
| | | import org.quartz.*; |
| | | |
| | | /** |
| | | * 定时任务工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class ScheduleUtils { |
| | | private final static String JOB_NAME = "TASK_"; |
| | | /** |
| | | * 任务调度参数key |
| | | */ |
| | | public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY"; |
| | | |
| | | /** |
| | | * 获取触发器key |
| | | */ |
| | | public static TriggerKey getTriggerKey(Long jobId) { |
| | | return TriggerKey.triggerKey(JOB_NAME + jobId); |
| | | } |
| | | |
| | | /** |
| | | * 获取jobKey |
| | | */ |
| | | public static JobKey getJobKey(Long jobId) { |
| | | return JobKey.jobKey(JOB_NAME + jobId); |
| | | } |
| | | |
| | | /** |
| | | * 获取表达式触发器 |
| | | */ |
| | | public static CronTrigger getCronTrigger(Scheduler scheduler, Long jobId) { |
| | | try { |
| | | return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建定时任务 |
| | | */ |
| | | public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { |
| | | try { |
| | | //构建job信息 |
| | | JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getId())).build(); |
| | | |
| | | //表达式调度构建器 |
| | | CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) |
| | | .withMisfireHandlingInstructionDoNothing(); |
| | | |
| | | //按新的cronExpression表达式构建一个新的trigger |
| | | CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getId())).withSchedule(scheduleBuilder).build(); |
| | | |
| | | //放入参数,运行时的方法可以获取 |
| | | jobDetail.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); |
| | | |
| | | scheduler.scheduleJob(jobDetail, trigger); |
| | | |
| | | //暂停任务 |
| | | if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ |
| | | pauseJob(scheduler, scheduleJob.getId()); |
| | | } |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新定时任务 |
| | | */ |
| | | public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { |
| | | try { |
| | | TriggerKey triggerKey = getTriggerKey(scheduleJob.getId()); |
| | | |
| | | //表达式调度构建器 |
| | | CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) |
| | | .withMisfireHandlingInstructionDoNothing(); |
| | | |
| | | CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getId()); |
| | | |
| | | //按新的cronExpression表达式重新构建trigger |
| | | trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); |
| | | |
| | | //参数 |
| | | trigger.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); |
| | | |
| | | scheduler.rescheduleJob(triggerKey, trigger); |
| | | |
| | | //暂停任务 |
| | | if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ |
| | | pauseJob(scheduler, scheduleJob.getId()); |
| | | } |
| | | |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 立即执行任务 |
| | | */ |
| | | public static void run(Scheduler scheduler, ScheduleJobEntity scheduleJob) { |
| | | try { |
| | | //参数 |
| | | JobDataMap dataMap = new JobDataMap(); |
| | | dataMap.put(JOB_PARAM_KEY, scheduleJob); |
| | | |
| | | scheduler.triggerJob(getJobKey(scheduleJob.getId()), dataMap); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 暂停任务 |
| | | */ |
| | | public static void pauseJob(Scheduler scheduler, Long jobId) { |
| | | try { |
| | | scheduler.pauseJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 恢复任务 |
| | | */ |
| | | public static void resumeJob(Scheduler scheduler, Long jobId) { |
| | | try { |
| | | scheduler.resumeJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除定时任务 |
| | | */ |
| | | public static void deleteScheduleJob(Scheduler scheduler, Long jobId) { |
| | | try { |
| | | scheduler.deleteJob(getJobKey(jobId)); |
| | | } catch (SchedulerException e) { |
| | | throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.job.vo; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年08月23日 |
| | | */ |
| | | @Schema(description = "数据平台 - 定时任务分页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class ScheduleJobReqVO extends PageParam { |
| | | |
| | | private String beanName; |
| | | |
| | | private Long tenantId; |
| | | } |
| | |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | |
| | | @TenantDS |
| | | @Mapper |
| | | public interface MmItemResultJsonDao extends BaseMapperX<MmItemResultJsonEntity> { |
| | | void cleanResultJson(Map<String, Date> tMap); |
| | | } |
| | |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | |
| | | .leIfPresent(MmPredictAlarmMessageEntity::getAlarmTime, reqVO.getEndTime()) |
| | | .orderByDesc(MmPredictAlarmMessageEntity::getCreateTime)); |
| | | } |
| | | |
| | | void cleanAlarmMessage(Map<String, Date> tMap); |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | List<Object[]> getData(String outputId, Date predictTime, String timeFormat); |
| | | |
| | | void insert(List<MmItemResultJsonEntity> resultJsonList); |
| | | |
| | | void cleanResultJson(Map<String, Date> tMap); |
| | | } |
| | |
| | | List<DataValueVO> getPredictValue(String outputid, Date startTime, Date endTime); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat); |
| | | |
| | | void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime); |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | void update(MmPredictAlarmMessageSaveReqVO reqVO); |
| | | |
| | | void delete(String id); |
| | | |
| | | void cleanAlarmMessage(Map<String, Date> tMap); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | public void insert(List<MmItemResultJsonEntity> resultJsonList) { |
| | | baseDao.insertBatch(resultJsonList); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanResultJson(Map<String, Date> tMap) { |
| | | baseDao.cleanResultJson(tMap); |
| | | } |
| | | } |
| | |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime) { |
| | | List<InfluxModelResultPOJO> list = new ArrayList<>(); |
| | | for (Map.Entry<MmItemOutputEntity, Double> entry : predictDoubleValues.entrySet()) { |
| | | InfluxModelResultSimPOJO pojo = new InfluxModelResultSimPOJO(); |
| | | pojo.setValue(entry.getValue()); |
| | | pojo.setTimestamp(predictTime.toInstant()); |
| | | pojo.setOutPutId(entry.getKey().getId()); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | list.add(pojo); |
| | | } |
| | | influxDBService.asyncWriteModelResults(list); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | public void delete(String id) { |
| | | baseDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanAlarmMessage(Map<String, Date> tMap) { |
| | | baseDao.cleanAlarmMessage(tMap); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.model.mcs.pre.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | |
| | | private BigDecimal currentValue; |
| | | |
| | | @Schema(description = "超出时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date outTime; |
| | | |
| | | @Schema(description = "超出值") |
| | |
| | | private String alarmType; |
| | | |
| | | @Schema(description = "预警时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date alarmTime; |
| | | |
| | | @Schema(description = "创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | } |
| | |
| | | @Mapper |
| | | public interface StScheduleModelSettingDao extends BaseMapperX<StScheduleModelSettingEntity> { |
| | | void updatePyFile(@Param("likeValue") String likeValue, @Param("value") String value); |
| | | |
| | | void updateByModelIdAndKey(@Param("modelId") String modelId, @Param("key") String key, @Param("value") String value); |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | } |
| | | |
| | | List<StScheduleRecordVO> getLastScheduleResult(@Param("scheduleCode") String scheduleCode, @Param("limit") Integer limit); |
| | | |
| | | void cleanScheduleRecord(Map<String, Date> tMap); |
| | | } |
| | |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | |
| | | @TenantDS |
| | | @Mapper |
| | | public interface StScheduleRecordDetailDao extends BaseMapperX<StScheduleRecordDetailEntity> { |
| | | void cleanScheduleRecordDetail(Map<String, Date> tMap); |
| | | } |
| | |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | |
| | | .likeIfPresent(StScheduleSuggestEntity::getScheduleObj, reqVO.getScheduleObj()) |
| | | .orderByDesc(StScheduleSuggestEntity::getCreateTime)); |
| | | } |
| | | |
| | | void cleanScheduleSuggest(Map<String, Date> tMap); |
| | | } |
| | |
| | | package com.iailab.module.model.mcs.sche.service; |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleModelPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleModelSaveReqVO; |
| | |
| | | Long check(StScheduleModelSaveReqVO reqVO); |
| | | |
| | | Long count(); |
| | | |
| | | StScheduleModelEntity getByModelCode(String modelCode); |
| | | } |
| | |
| | | void saveList(String modelId, List<StScheduleModelSettingSaveReqVO> saveList); |
| | | |
| | | void updatePyFile(String pyModule, String fileName); |
| | | |
| | | void updateByModelIdAndKey(String modelId, String key, String value); |
| | | } |
| | |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity; |
| | | import com.iailab.module.model.mdk.vo.ScheduleResultVO; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | void create(String recordId, ScheduleResultVO resultVO); |
| | | |
| | | List<StScheduleRecordDetailEntity> getByRecordId(String recordId); |
| | | |
| | | void cleanScheduleRecordDetail(Map<String, Date> tMap); |
| | | } |
| | |
| | | import com.iailab.module.model.mdk.vo.ScheduleResultVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | void create(ScheduleResultVO resultVO); |
| | | |
| | | List<StScheduleRecordVO> getLastScheduleResult(String scheduleCode, Integer limit); |
| | | |
| | | void cleanScheduleRecord(Map<String, Date> tMap); |
| | | } |
| | |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestReqDTO; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestSaveReqVO; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | StScheduleSuggestEntity getInfo(String id); |
| | | |
| | | List<StScheduleSuggestEntity> getList(String scheduleObj, Integer limit); |
| | | |
| | | void cleanScheduleSuggest(Map<String, Date> tMap); |
| | | |
| | | List<ScheduleSuggestRespDTO> list(ScheduleSuggestReqDTO vo); |
| | | } |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>(); |
| | | return stScheduleModelDao.selectCount(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public StScheduleModelEntity getByModelCode(String modelCode) { |
| | | return stScheduleModelDao.selectOne("model_code", modelCode); |
| | | } |
| | | } |
| | |
| | | public void updatePyFile(String pyModule, String fileName) { |
| | | baseDao.updatePyFile(pyModule + "." + fileName.substring(0,fileName.lastIndexOf("_")+1),pyModule + "." + fileName); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByModelIdAndKey(String modelId, String key, String value) { |
| | | baseDao.updateByModelIdAndKey(modelId, key, value); |
| | | } |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | |
| | | queryWrapper.orderByAsc("result_key"); |
| | | return baseDao.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanScheduleRecordDetail(Map<String, Date> tMap) { |
| | | baseDao.cleanScheduleRecordDetail(tMap); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | public List<StScheduleRecordVO> getLastScheduleResult(String scheduleCode, Integer limit) { |
| | | return baseDao.getLastScheduleResult(scheduleCode,limit); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanScheduleRecord(Map<String, Date> tMap) { |
| | | baseDao.cleanScheduleRecord(tMap); |
| | | } |
| | | } |
| | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestReqDTO; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; |
| | | import com.iailab.module.model.common.enums.ScheduleSuggestStatusEnum; |
| | | import com.iailab.module.model.mcs.sche.dao.StScheduleSuggestDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleSuggestService; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestSaveReqVO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | .last("limit " + limit); |
| | | return baseDao.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanScheduleSuggest(Map<String, Date> tMap) { |
| | | baseDao.cleanScheduleSuggest(tMap); |
| | | } |
| | | |
| | | @Override |
| | | public List<ScheduleSuggestRespDTO> list(ScheduleSuggestReqDTO vo) { |
| | | QueryWrapper<StScheduleSuggestEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq(StringUtils.isNotBlank(vo.getScheduleObj()),"schedule_obj", vo.getScheduleObj()) |
| | | .ge(null != vo.getStartTime(),"schedule_time",vo.getStartTime()) |
| | | .le(null != vo.getEndTime(),"schedule_time",vo.getEndTime()); |
| | | return ConvertUtils.sourceToTarget(baseDao.selectList(queryWrapper),ScheduleSuggestRespDTO.class); |
| | | } |
| | | } |
| | |
| | | public void savePredictResult(PredictResultVO predictResult) { |
| | | Map<String, List<DataValueVO>> resultMap = convertToPredictData(predictResult); |
| | | mmItemResultService.savePredictValue(resultMap, predictResult.getLt(), "n", predictResult.getPredictTime()); |
| | | // 存double类型输出 |
| | | if (!CollectionUtils.isEmpty(predictResult.getPredictDoubleValues())) { |
| | | mmItemResultService.savePredictValue(predictResult.getPredictDoubleValues(), predictResult.getPredictTime()); |
| | | } |
| | | } |
| | | |
| | | public List<DataValueVO> getPredictValueByItemNo(String itemNo, Date start, Date end) { |
| | |
| | | |
| | | List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid()); |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(); |
| | | Map<MmItemOutputEntity, Double> predictDoubleValues = new HashMap<>(); |
| | | for (MmItemOutputEntity output : itemOutputList) { |
| | | if (!modelResult.containsKey(output.getResultstr())) { |
| | | continue; |
| | |
| | | break; |
| | | case D: |
| | | Double temp3 = (Double) modelResult.get(output.getResultstr()); |
| | | predictDoubleValues.put(output, temp3); |
| | | predictMatrixs.put(output, new double[]{temp3}); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | result.setPredictMatrixs(predictMatrixs); |
| | | result.setPredictDoubleValues(predictDoubleValues); |
| | | result.setModelResult(modelResult); |
| | | result.setPredictTime(predictTime); |
| | | } catch (ModelResultErrorException ex) { |
| | |
| | | private Map<MmItemOutputEntity, double[]> predictMatrixs; |
| | | |
| | | /** |
| | | * double类型的模型输出 |
| | | */ |
| | | private Map<MmItemOutputEntity, Double> predictDoubleValues; |
| | | |
| | | /** |
| | | * 时间间隔 (当前预测时间 与 上一次预测时间 相差的分钟数;系统计算得出) |
| | | */ |
| | | private int t; |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao"> |
| | | <delete id="cleanResultJson"> |
| | | delete from t_mm_item_result_json |
| | | where predicttime between #{startdate} and #{enddate} |
| | | </delete> |
| | | </mapper> |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.pre.dao.MmPredictAlarmMessageDao"> |
| | | <delete id="cleanAlarmMessage"> |
| | | delete from t_mm_predict_alarm_message |
| | | where alarm_time between #{startdate} and #{enddate} |
| | | </delete> |
| | | </mapper> |
| | |
| | | <update id="updatePyFile"> |
| | | update t_st_schedule_model_setting set value = #{value} where `key` = 'pyFile' and `value` like CONCAT(#{likeValue},'%') |
| | | </update> |
| | | |
| | | <update id="updateByModelIdAndKey"> |
| | | update t_st_schedule_model_setting set value = #{value} where `modelid` = #{modelId} and `key` = #{key} |
| | | </update> |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao"> |
| | | <delete id="cleanScheduleRecord"> |
| | | delete from t_st_schedule_record |
| | | where schedule_time between #{startdate} and #{enddate} |
| | | </delete> |
| | | <select id="getLastScheduleResult" resultType="com.iailab.module.model.api.mdk.dto.StScheduleRecordVO"> |
| | | SELECT t2.* FROM t_st_schedule_scheme t1 LEFT JOIN t_st_schedule_record t2 on t1.id = t2.scheme_id |
| | | WHERE t1.`code` = #{scheduleCode} AND result_code = "100" |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.sche.dao.StScheduleRecordDetailDao"> |
| | | <delete id="cleanScheduleRecordDetail"> |
| | | delete from t_st_schedule_record_detail |
| | | where schedule_time between #{startdate} and #{enddate} |
| | | </delete> |
| | | </mapper> |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.sche.dao.StScheduleSuggestDao"> |
| | | <delete id="cleanScheduleSuggest"> |
| | | delete from t_st_schedule_suggest |
| | | where schedule_time between #{startdate} and #{enddate} |
| | | </delete> |
| | | </mapper> |