parent
3df5541559
commit
cfc19c4f05
@ -0,0 +1,105 @@ |
||||
package com.alops.web.controller.equManagement; |
||||
|
||||
import java.util.List; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.alops.common.annotation.Log; |
||||
import com.alops.common.core.controller.BaseController; |
||||
import com.alops.common.core.domain.AjaxResult; |
||||
import com.alops.common.core.page.TableDataInfo; |
||||
import com.alops.common.enums.BusinessType; |
||||
import com.alops.common.utils.poi.ExcelUtil; |
||||
import com.alops.system.domain.EquSupplier; |
||||
import com.alops.system.service.IEquSupplierService; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.PutMapping; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* 【请填写功能名称】Controller |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-09-19 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/system/supplier") |
||||
public class EquSupplierController extends BaseController |
||||
{ |
||||
@Autowired |
||||
private IEquSupplierService equSupplierService; |
||||
|
||||
/** |
||||
* 查询【请填写功能名称】列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:list')") |
||||
@GetMapping("/list") |
||||
public TableDataInfo list(EquSupplier equSupplier) |
||||
{ |
||||
startPage(); |
||||
List<EquSupplier> list = equSupplierService.selectEquSupplierList(equSupplier); |
||||
return getDataTable(list); |
||||
} |
||||
|
||||
/** |
||||
* 导出【请填写功能名称】列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:export')") |
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) |
||||
@PostMapping("/export") |
||||
public void export(HttpServletResponse response, EquSupplier equSupplier) |
||||
{ |
||||
List<EquSupplier> list = equSupplierService.selectEquSupplierList(equSupplier); |
||||
ExcelUtil<EquSupplier> util = new ExcelUtil<EquSupplier>(EquSupplier.class); |
||||
util.exportExcel(response, list, "【请填写功能名称】数据"); |
||||
} |
||||
|
||||
/** |
||||
* 获取【请填写功能名称】详细信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:query')") |
||||
@GetMapping(value = "/{id}") |
||||
public AjaxResult getInfo(@PathVariable("id") String id) |
||||
{ |
||||
return success(equSupplierService.selectEquSupplierById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 新增【请填写功能名称】 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:add')") |
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) |
||||
@PostMapping |
||||
public AjaxResult add(@RequestBody EquSupplier equSupplier) |
||||
{ |
||||
return toAjax(equSupplierService.insertEquSupplier(equSupplier)); |
||||
} |
||||
|
||||
/** |
||||
* 修改【请填写功能名称】 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:edit')") |
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) |
||||
@PutMapping |
||||
public AjaxResult edit(@RequestBody EquSupplier equSupplier) |
||||
{ |
||||
return toAjax(equSupplierService.updateEquSupplier(equSupplier)); |
||||
} |
||||
|
||||
/** |
||||
* 删除【请填写功能名称】 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:supplier:remove')") |
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) |
||||
@DeleteMapping("/{ids}") |
||||
public AjaxResult remove(@PathVariable String[] ids) |
||||
{ |
||||
return toAjax(equSupplierService.deleteEquSupplierByIds(ids)); |
||||
} |
||||
} |
||||
@ -0,0 +1,125 @@ |
||||
package com.alops.system.domain; |
||||
|
||||
import com.alops.common.annotation.Excel; |
||||
import com.alops.common.core.domain.BaseEntity; |
||||
import lombok.Data; |
||||
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||
import org.apache.commons.lang3.builder.ToStringStyle; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 【请填写功能名称】对象 equ_supplier |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-09-19 |
||||
*/ |
||||
@Data |
||||
public class EquSupplier |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** 供应商id */ |
||||
private String id; |
||||
|
||||
/** 供应商名称 */ |
||||
@Excel(name = "供应商名称") |
||||
private String name; |
||||
|
||||
/** 供应商简介 */ |
||||
@Excel(name = "供应商简介") |
||||
private String description; |
||||
|
||||
/** 联系人姓名 */ |
||||
@Excel(name = "联系人姓名") |
||||
private String contactBy; |
||||
|
||||
/** l联系方式 */ |
||||
@Excel(name = "l联系方式") |
||||
private String contactWay; |
||||
/** 联系人姓名 */ |
||||
@Excel(name = "创建人id") |
||||
private long createBy; |
||||
|
||||
/** l联系方式 */ |
||||
@Excel(name = "创建时间") |
||||
private Date createTime; |
||||
|
||||
/** 状态(0禁1启用) */ |
||||
@Excel(name = "状态", readConverterExp = "0=禁1启用") |
||||
private Long status; |
||||
|
||||
public void setId(String id) |
||||
{ |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getId() |
||||
{ |
||||
return id; |
||||
} |
||||
|
||||
public void setName(String name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getName() |
||||
{ |
||||
return name; |
||||
} |
||||
|
||||
public void setDescription(String description) |
||||
{ |
||||
this.description = description; |
||||
} |
||||
|
||||
public String getDescription() |
||||
{ |
||||
return description; |
||||
} |
||||
|
||||
public void setContactBy(String contactBy) |
||||
{ |
||||
this.contactBy = contactBy; |
||||
} |
||||
|
||||
public String getContactBy() |
||||
{ |
||||
return contactBy; |
||||
} |
||||
|
||||
public void setContactWay(String contactWay) |
||||
{ |
||||
this.contactWay = contactWay; |
||||
} |
||||
|
||||
public String getContactWay() |
||||
{ |
||||
return contactWay; |
||||
} |
||||
|
||||
public void setStatus(Long status) |
||||
{ |
||||
this.status = status; |
||||
} |
||||
|
||||
public Long getStatus() |
||||
{ |
||||
return status; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
||||
.append("id", getId()) |
||||
.append("name", getName()) |
||||
.append("description", getDescription()) |
||||
.append("contactBy", getContactBy()) |
||||
.append("contactWay", getContactWay()) |
||||
.append("createBy", getCreateBy()) |
||||
.append("createTime", getCreateTime()) |
||||
.append("status", getStatus()) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
package com.alops.system.domain.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class AlertDto { |
||||
private Date minTime; |
||||
private Date maxTime; |
||||
private Long level; |
||||
private String status; |
||||
private String location; |
||||
private String inCharge; |
||||
} |
||||
@ -0,0 +1,11 @@ |
||||
package com.alops.system.domain.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class RolePickerVo { |
||||
|
||||
private Long roleId; |
||||
private String roleName; |
||||
private String roleKey; |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
package com.alops.system.domain.vo; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class dropDownVo { |
||||
private String id; |
||||
private String name; |
||||
} |
||||
@ -0,0 +1,8 @@ |
||||
package com.alops.system.domain.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class imageVo { |
||||
private byte[] equImage; |
||||
} |
||||
@ -0,0 +1,101 @@ |
||||
package com.alops.system.job; |
||||
|
||||
import com.alops.system.domain.InternalMessage; |
||||
import com.alops.system.domain.ScheduleRules; |
||||
import com.alops.system.mapper.ScheduleRulesMapper; |
||||
import com.alops.system.service.IAlertSenderService; |
||||
import com.alops.system.service.IScheduleRulesService; |
||||
import com.alops.system.service.impl.ScheduleRulesServiceImpl; |
||||
import org.quartz.*; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
; |
||||
import java.util.Date; |
||||
|
||||
@Component |
||||
public class GatherJob implements Job { |
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GatherJob.class); |
||||
@Autowired |
||||
private ScheduleRulesMapper scheduleRulesMapper; |
||||
|
||||
@Autowired |
||||
private IScheduleRulesService iScheduleRulesService; |
||||
|
||||
@Autowired |
||||
private IAlertSenderService iAlertSenderService; |
||||
|
||||
@Override |
||||
public void execute(JobExecutionContext context) throws JobExecutionException { |
||||
|
||||
Long ruleId = context.getJobDetail().getJobDataMap().getLong("ruleId"); |
||||
ScheduleRules rule = scheduleRulesMapper.selectScheduleRulesById(ruleId); |
||||
|
||||
// 统一使用 Date
|
||||
Date now = new Date(); |
||||
try { |
||||
if (rule == null) return; |
||||
|
||||
// 按频率判断时间范围
|
||||
if (rule.getRuleType() == 0) { |
||||
Date start = rule.getStartTime(); |
||||
Date end = rule.getEndTime(); |
||||
if (start != null && end != null) { |
||||
// 当前时间不在范围内
|
||||
if ( now.after(end)) { |
||||
rule.setStatus(2); // 超出范围标记完成
|
||||
scheduleRulesMapper.updateScheduleRules(rule); |
||||
|
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 执行任务
|
||||
iScheduleRulesService.executeImmediately(); |
||||
|
||||
// 执行成功
|
||||
if (rule.getRuleType() == 0 || rule.getRuleType() == 1) { |
||||
rule.setStatus(2); |
||||
} |
||||
scheduleRulesMapper.updateScheduleRules(rule); |
||||
|
||||
} catch (Exception e) { |
||||
//执行失败是不会有采集信息和预警信息的
|
||||
|
||||
// 记录详细异常日志,方便排查
|
||||
log.error("GatherJob 执行失败, ruleId={}, 原因: {}", rule.getId(), e.getMessage(), e); |
||||
|
||||
// 更新数据库任务状态为失败
|
||||
rule.setStatus(3); |
||||
scheduleRulesMapper.updateScheduleRules(rule); |
||||
try { |
||||
String Content=String.format("任务执行失败,规则ID=%s,规则名称=%s,原因:%s", |
||||
rule.getId(), rule.getRuleName(), e.getMessage()); |
||||
|
||||
iAlertSenderService.sendInternalMessage( Content,"2" ); |
||||
|
||||
log.info("已发送失败通知给运维人员"); |
||||
} catch (Exception ne) { |
||||
log.error("发送站内信失败: {}", ne.getMessage(), ne); |
||||
} |
||||
|
||||
|
||||
// 如果是定时类规则,取消后续调度
|
||||
if (rule.getRuleType() == 0) { |
||||
try { |
||||
// 从上下文取出 Scheduler
|
||||
Scheduler scheduler = context.getScheduler(); |
||||
JobKey jobKey = context.getJobDetail().getKey(); |
||||
scheduler.deleteJob(jobKey); // 取消后续执行
|
||||
log.info("已取消定时任务: {}", jobKey); |
||||
} catch (SchedulerException se) { |
||||
log.error("取消后续定时任务失败: {}", se.getMessage(), se); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,67 @@ |
||||
package com.alops.system.mapper; |
||||
|
||||
import com.alops.system.domain.EquSupplier; |
||||
import com.alops.system.domain.vo.dropDownVo; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 【请填写功能名称】Mapper接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-09-19 |
||||
*/ |
||||
@Mapper |
||||
public interface EquSupplierMapper |
||||
{ |
||||
|
||||
List<dropDownVo> selectEquSupDropDown(); |
||||
/** |
||||
* 查询【请填写功能名称】 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 【请填写功能名称】 |
||||
*/ |
||||
public EquSupplier selectEquSupplierById(String id); |
||||
|
||||
/** |
||||
* 查询【请填写功能名称】列表 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 【请填写功能名称】集合 |
||||
*/ |
||||
public List<EquSupplier> selectEquSupplierList(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 新增【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
public int insertEquSupplier(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 修改【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
public int updateEquSupplier(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 删除【请填写功能名称】 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 结果 |
||||
*/ |
||||
public int deleteEquSupplierById(String id); |
||||
|
||||
/** |
||||
* 批量删除【请填写功能名称】 |
||||
* |
||||
* @param ids 需要删除的数据主键集合 |
||||
* @return 结果 |
||||
*/ |
||||
public int deleteEquSupplierByIds(String[] ids); |
||||
} |
||||
@ -1,7 +1,8 @@ |
||||
package com.alops.system.service; |
||||
|
||||
import java.util.List; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
public interface IAlertLaunchService { |
||||
public void executeImmediateAlerts(List<Long> ruleIds); |
||||
public void executeImmediateAlerts() throws ExecutionException, InterruptedException; |
||||
} |
||||
|
||||
@ -0,0 +1,62 @@ |
||||
package com.alops.system.service; |
||||
|
||||
import com.alops.system.domain.EquSupplier; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 【请填写功能名称】Service接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-09-19 |
||||
*/ |
||||
public interface IEquSupplierService |
||||
{ |
||||
/** |
||||
* 查询【请填写功能名称】 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 【请填写功能名称】 |
||||
*/ |
||||
public EquSupplier selectEquSupplierById(String id); |
||||
|
||||
/** |
||||
* 查询【请填写功能名称】列表 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 【请填写功能名称】集合 |
||||
*/ |
||||
public List<EquSupplier> selectEquSupplierList(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 新增【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
public int insertEquSupplier(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 修改【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
public int updateEquSupplier(EquSupplier equSupplier); |
||||
|
||||
/** |
||||
* 批量删除【请填写功能名称】 |
||||
* |
||||
* @param ids 需要删除的【请填写功能名称】主键集合 |
||||
* @return 结果 |
||||
*/ |
||||
public int deleteEquSupplierByIds(String[] ids); |
||||
|
||||
/** |
||||
* 删除【请填写功能名称】信息 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 结果 |
||||
*/ |
||||
public int deleteEquSupplierById(String id); |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
package com.alops.system.service; |
||||
|
||||
import com.alops.system.domain.ScheduleRules; |
||||
import com.alops.system.service.impl.QuartzService; |
||||
import org.quartz.SchedulerException; |
||||
|
||||
public interface IQuartzService { |
||||
|
||||
public void createOrUpdateJob(ScheduleRules rule); |
||||
public void deleteJob(Long ruleId) throws SchedulerException; |
||||
|
||||
} |
||||
@ -0,0 +1,99 @@ |
||||
package com.alops.system.service.impl; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import com.alops.common.utils.DateUtils; |
||||
import com.alops.system.domain.EquSupplier; |
||||
import com.alops.system.mapper.EquSupplierMapper; |
||||
import com.alops.system.service.IEquSupplierService; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 【请填写功能名称】Service业务层处理 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-09-19 |
||||
*/ |
||||
@Service |
||||
public class EquSupplierServiceImpl implements IEquSupplierService |
||||
{ |
||||
@Autowired |
||||
private EquSupplierMapper equSupplierMapper; |
||||
|
||||
/** |
||||
* 查询【请填写功能名称】 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 【请填写功能名称】 |
||||
*/ |
||||
@Override |
||||
public EquSupplier selectEquSupplierById(String id) |
||||
{ |
||||
return equSupplierMapper.selectEquSupplierById(id); |
||||
} |
||||
|
||||
/** |
||||
* 查询【请填写功能名称】列表 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 【请填写功能名称】 |
||||
*/ |
||||
@Override |
||||
public List<EquSupplier> selectEquSupplierList(EquSupplier equSupplier) |
||||
{ |
||||
return equSupplierMapper.selectEquSupplierList(equSupplier); |
||||
} |
||||
|
||||
/** |
||||
* 新增【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int insertEquSupplier(EquSupplier equSupplier) |
||||
{ |
||||
equSupplier.setCreateTime(new Date()); |
||||
return equSupplierMapper.insertEquSupplier(equSupplier); |
||||
} |
||||
|
||||
/** |
||||
* 修改【请填写功能名称】 |
||||
* |
||||
* @param equSupplier 【请填写功能名称】 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int updateEquSupplier(EquSupplier equSupplier) |
||||
{ |
||||
return equSupplierMapper.updateEquSupplier(equSupplier); |
||||
} |
||||
|
||||
/** |
||||
* 批量删除【请填写功能名称】 |
||||
* |
||||
* @param ids 需要删除的【请填写功能名称】主键 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int deleteEquSupplierByIds(String[] ids) |
||||
{ |
||||
return equSupplierMapper.deleteEquSupplierByIds(ids); |
||||
} |
||||
|
||||
/** |
||||
* 删除【请填写功能名称】信息 |
||||
* |
||||
* @param id 【请填写功能名称】主键 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int deleteEquSupplierById(String id) |
||||
{ |
||||
return equSupplierMapper.deleteEquSupplierById(id); |
||||
} |
||||
} |
||||
@ -0,0 +1,105 @@ |
||||
package com.alops.system.service.impl; |
||||
|
||||
import com.alops.system.domain.ScheduleRules; |
||||
import com.alops.system.job.GatherJob; |
||||
import com.alops.system.service.IQuartzService; |
||||
import org.quartz.*; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.quartz.Trigger; // ✅ Quartz 的 Trigger
|
||||
import org.quartz.TriggerBuilder; |
||||
import org.quartz.Scheduler; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Date; |
||||
|
||||
|
||||
@Service |
||||
public class QuartzService implements IQuartzService { |
||||
|
||||
@Autowired |
||||
private Scheduler scheduler; |
||||
|
||||
@Override |
||||
public void createOrUpdateJob(ScheduleRules rule) { |
||||
try { |
||||
String jobName = "job_" + rule.getId(); |
||||
String groupName = "gather_rules"; |
||||
|
||||
JobDetail jobDetail = JobBuilder.newJob(GatherJob.class) |
||||
.withIdentity(jobName, groupName) |
||||
.usingJobData("ruleId", rule.getId()) |
||||
.build(); |
||||
|
||||
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger() |
||||
.withIdentity("trigger_" + rule.getId(), groupName); |
||||
|
||||
if (rule.getRuleType() == 1 && rule.getGatherTime() != null) { |
||||
triggerBuilder.startAt(Date.from(rule.getGatherTime() |
||||
.toInstant())); |
||||
} else if (rule.getRuleType() == 0 && rule.getFrequency() != null) { |
||||
if (rule.getStartTime() != null) { |
||||
triggerBuilder.startAt(rule.getStartTime()); |
||||
} |
||||
if (rule.getEndTime() != null) { |
||||
triggerBuilder.endAt(rule.getEndTime()); |
||||
} |
||||
// 替换这里:不再使用 Cron,而是使用 SimpleSchedule
|
||||
triggerBuilder.withSchedule( |
||||
SimpleScheduleBuilder.simpleSchedule() |
||||
.withIntervalInMinutes(rule.getFrequency()) // 每 rule.getFrequency() 分钟
|
||||
.repeatForever() // 一直重复,直到 endTime
|
||||
); |
||||
} |
||||
|
||||
Trigger trigger = triggerBuilder.build(); |
||||
|
||||
if (scheduler.checkExists(jobDetail.getKey())) { |
||||
scheduler.deleteJob(jobDetail.getKey()); |
||||
} |
||||
scheduler.scheduleJob(jobDetail, trigger); |
||||
if (!scheduler.isStarted()) { |
||||
scheduler.start(); |
||||
} |
||||
|
||||
} catch (SchedulerException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
// /**
|
||||
// * 将分钟频率转换为 Quartz Cron 表达式
|
||||
// * 支持 frequency >= 1
|
||||
// * 最大间隔是23小时59分钟 !!!!!!!!!!!!!!1
|
||||
// */
|
||||
// private String convertFrequencyToCron(Integer frequency) {
|
||||
// if (frequency == null || frequency <= 0) {
|
||||
// throw new IllegalArgumentException("frequency 必须是大于 0 的分钟数");
|
||||
// }
|
||||
//
|
||||
// // 计算小时和分钟
|
||||
// int hours = frequency / 60; // 每隔多少小时
|
||||
// int minutes = frequency % 60; // 余下多少分钟
|
||||
//
|
||||
// if (hours > 0 && minutes == 0) {
|
||||
// // 整小时倍数
|
||||
// return String.format("0 0 0/%d * * ?", hours);
|
||||
// } else if (hours > 0) {
|
||||
// // 既有小时又有分钟,折中为:每 hours 小时的第 minutes 分
|
||||
// return String.format("0 %d 0/%d * * ?", minutes, hours);
|
||||
// } else {
|
||||
// // 纯分钟且小于 60
|
||||
// return String.format("0 0/%d * * * ?", minutes);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override |
||||
public void deleteJob(Long ruleId) throws SchedulerException { |
||||
String jobName = "job_" + ruleId; |
||||
String groupName = "gather_rules"; |
||||
JobKey key = JobKey.jobKey(jobName, groupName); |
||||
if (scheduler.checkExists(key)) { |
||||
scheduler.deleteJob(key); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,92 @@ |
||||
<?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.alops.system.mapper.EquSupplierMapper"> |
||||
|
||||
<resultMap type="EquSupplier" id="EquSupplierResult"> |
||||
<result property="id" column="id" /> |
||||
<result property="name" column="name" /> |
||||
<result property="description" column="description" /> |
||||
<result property="contactBy" column="contact_by" /> |
||||
<result property="contactWay" column="contact_way" /> |
||||
<result property="createBy" column="create_by" /> |
||||
<result property="createTime" column="create_time" /> |
||||
<result property="status" column="status" /> |
||||
</resultMap> |
||||
<select id="selectEquSupDropDown" |
||||
resultType="com.alops.system.domain.vo.dropDownVo"> |
||||
SELECT id, |
||||
name |
||||
FROM equ_supplier |
||||
ORDER BY name |
||||
</select> |
||||
<sql id="selectEquSupplierVo"> |
||||
select id, name, description, contact_by, contact_way, create_by, create_time, status from equ_supplier |
||||
</sql> |
||||
|
||||
<select id="selectEquSupplierList" parameterType="EquSupplier" resultMap="EquSupplierResult"> |
||||
<include refid="selectEquSupplierVo"/> |
||||
<where> |
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
||||
<if test="description != null and description != ''"> and description = #{description}</if> |
||||
<if test="contactBy != null and contactBy != ''"> and contact_by = #{contactBy}</if> |
||||
<if test="contactWay != null and contactWay != ''"> and contact_way = #{contactWay}</if> |
||||
<if test="status != null "> and status = #{status}</if> |
||||
</where> |
||||
</select> |
||||
|
||||
<select id="selectEquSupplierById" parameterType="String" resultMap="EquSupplierResult"> |
||||
<include refid="selectEquSupplierVo"/> |
||||
where id = #{id} |
||||
</select> |
||||
|
||||
<insert id="insertEquSupplier" parameterType="EquSupplier"> |
||||
insert into equ_supplier |
||||
<trim prefix="(" suffix=")" suffixOverrides=","> |
||||
<if test="id != null">id,</if> |
||||
<if test="name != null">name,</if> |
||||
<if test="description != null">description,</if> |
||||
<if test="contactBy != null">contact_by,</if> |
||||
<if test="contactWay != null">contact_way,</if> |
||||
<if test="createBy != null">create_by,</if> |
||||
<if test="createTime != null">create_time,</if> |
||||
<if test="status != null">status,</if> |
||||
</trim> |
||||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
||||
<if test="id != null">#{id},</if> |
||||
<if test="name != null">#{name},</if> |
||||
<if test="description != null">#{description},</if> |
||||
<if test="contactBy != null">#{contactBy},</if> |
||||
<if test="contactWay != null">#{contactWay},</if> |
||||
<if test="createBy != null">#{createBy},</if> |
||||
<if test="createTime != null">#{createTime},</if> |
||||
<if test="status != null">#{status},</if> |
||||
</trim> |
||||
</insert> |
||||
|
||||
<update id="updateEquSupplier" parameterType="EquSupplier"> |
||||
update equ_supplier |
||||
<trim prefix="SET" suffixOverrides=","> |
||||
<if test="name != null">name = #{name},</if> |
||||
<if test="description != null">description = #{description},</if> |
||||
<if test="contactBy != null">contact_by = #{contactBy},</if> |
||||
<if test="contactWay != null">contact_way = #{contactWay},</if> |
||||
<if test="createBy != null">create_by = #{createBy},</if> |
||||
<if test="createTime != null">create_time = #{createTime},</if> |
||||
<if test="status != null">status = #{status},</if> |
||||
</trim> |
||||
where id = #{id} |
||||
</update> |
||||
|
||||
<delete id="deleteEquSupplierById" parameterType="String"> |
||||
delete from equ_supplier where id = #{id} |
||||
</delete> |
||||
|
||||
<delete id="deleteEquSupplierByIds" parameterType="String"> |
||||
delete from equ_supplier where id in |
||||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
||||
#{id} |
||||
</foreach> |
||||
</delete> |
||||
</mapper> |
||||
Loading…
Reference in new issue