From 8766cfc344d3635cd7e50a7c674cd5feb54d5a3d Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期一, 02 十二月 2024 09:30:35 +0800 Subject: [PATCH] 预警mq监听并发送 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/service/impl/ScheduleJobServiceImpl.java | 53 +++++++++++++++++++++++++---------------------------- 1 files changed, 25 insertions(+), 28 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/service/impl/ScheduleJobServiceImpl.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/service/impl/ScheduleJobServiceImpl.java index ad9b2ad..53da04f 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/service/impl/ScheduleJobServiceImpl.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/service/impl/ScheduleJobServiceImpl.java @@ -1,45 +1,45 @@ package com.iailab.module.shasteel.job.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.pojo.PageResult; +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.framework.security.core.util.SecurityFrameworkUtils; -import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.shasteel.job.dao.ScheduleJobDao; import com.iailab.module.shasteel.job.dto.ScheduleJobDTO; import com.iailab.module.shasteel.job.entity.ScheduleJobEntity; import com.iailab.module.shasteel.job.service.ScheduleJobService; import com.iailab.module.shasteel.job.utils.ScheduleUtils; -import com.iailab.module.shasteel.job.vo.ScheduleJobReqVO; import org.apache.commons.lang3.StringUtils; import org.quartz.Scheduler; +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.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Map; @Service -public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { - @Resource +public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { + @Autowired private Scheduler scheduler; - @Resource - private ScheduleJobDao scheduleJobDao; - @Override - public PageResult<ScheduleJobEntity> page(ScheduleJobReqVO reqVO) { - return scheduleJobDao.selectPage(reqVO); + public PageData<ScheduleJobDTO> page(Map<String, Object> params) { + IPage<ScheduleJobEntity> page = baseDao.selectPage( + getPage(params, "create_date", false), + getWrapper(params) + ); + return getPageData(page, ScheduleJobDTO.class); } @Override public ScheduleJobDTO get(Long id) { - ScheduleJobEntity entity = scheduleJobDao.selectById(id); + ScheduleJobEntity entity = baseDao.selectById(id); return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class); } @@ -56,14 +56,12 @@ @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()); - scheduleJobDao.insert(entity); + entity.setCreator(SecurityFrameworkUtils.getLoginUser().getId()); + entity.setStatus(Constant.ScheduleStatus.NORMAL.getValue()); + this.insert(entity); ScheduleUtils.createScheduleJob(scheduler, entity); } @@ -71,11 +69,9 @@ @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); @@ -83,10 +79,13 @@ @Override @Transactional(rollbackFor = Exception.class) - public void deleteBatch(Long id) { - ScheduleUtils.deleteScheduleJob(scheduler, id); + public void deleteBatch(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.deleteScheduleJob(scheduler, id); + } - scheduleJobDao.deleteById(id); + //删除数据 + this.deleteBatchIds(Arrays.asList(ids)); } @Override @@ -94,15 +93,13 @@ Map<String, Object> map = new HashMap<>(2); map.put("ids", ids); map.put("status", status); - return scheduleJobDao.updateBatch(map); + return baseDao.updateBatch(map); } @Override @Transactional(rollbackFor = Exception.class) - public void run(Long[] ids) { - for(Long id : ids){ - ScheduleUtils.run(scheduler, scheduleJobDao.selectById(id)); - } + public void run(Long id) { + ScheduleUtils.run(scheduler, this.selectById(id)); } @Override -- Gitblit v1.9.3