| | |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.doublePrevention.entity.PreventReportConfig; |
| | | import com.ruoyi.doublePrevention.entity.PreventRiskJobAndMeasure; |
| | | import com.ruoyi.doublePrevention.enums.SyncEnum; |
| | | import com.ruoyi.doublePrevention.service.RiskService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | |
| | | import com.ruoyi.project.tr.troubleshootType.service.ITroubleshootTypeService; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.ModelMap; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private IRegionService regionService; |
| | | @Autowired |
| | | private IDeptService deptService; |
| | | @Autowired |
| | | private RiskService riskService; |
| | | |
| | | @GetMapping() |
| | | public String hiddenDangerCheckJob() { |
| | |
| | | @Log(title = "定时任务", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult remove(String ids) throws SchedulerException { |
| | | hiddenDangerCheckJobService.deleteJobByIds(ids); |
| | | |
| | | //todo-2022 删除job与措施的关联关系 |
| | | int result = riskService.deleteJobAndMeasure(ids); |
| | | if (result < 1){ |
| | | throw new RuntimeException("删除调度与管控措施的关联失败"); |
| | | } |
| | | |
| | | return success(); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 新增保存调度 |
| | | * todo-2022 对应work |
| | | */ |
| | | @Log(title = "定时任务", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult addSave(@Validated HiddenDangerCheckJob hiddenDangerCheckJob) throws SchedulerException, TaskException { |
| | | if (!StringUtils.isEmpty(hiddenDangerCheckJob.getExecuteUserIdString())) { |
| | | String[] executeUserIdArray = hiddenDangerCheckJob.getExecuteUserIdString().split(","); |
| | |
| | | } |
| | | } |
| | | hiddenDangerCheckJobService.insertJob(hiddenDangerCheckJob); |
| | | |
| | | //todo- 2022 保存job与管控措施的对应关系 |
| | | hiddenDangerCheckJob.getJobId(); |
| | | int result = riskService.insertJobAndMeasure(hiddenDangerCheckJob.getJobId(),hiddenDangerCheckJob);{ |
| | | if (result < 0 ){ |
| | | throw new RuntimeException("保存job与管控措施的对应关系失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | cronExpression = secondStr + " " + minuteStr + " " + hourStr + " " + dayStr + " " + initMonth + "/" + typeCycleNum + " ? *"; |
| | | } else if (hiddenDangerCheckJob.getTroubleshootTypeCycleType() == 5) {//年 |
| | | cronExpression = secondStr + " " + minuteStr + " " + hourStr + " " + dayStr + " " + monthStr + " ? " + yearStr + "/" + "" + typeCycleNum; |
| | | } else if (hiddenDangerCheckJob.getTroubleshootTypeCycleType() == 6) {// todo - 2022 测试 ,分钟 |
| | | cronExpression = "* 0/5 * * * ?"; |
| | | } |
| | | return cronExpression; |
| | | } |
| | |
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult editSave(@Validated HiddenDangerCheckJob hiddenDangerCheckJob) throws |
| | | SchedulerException, TaskException { |
| | | HiddenDangerCheckJob tempJob = hiddenDangerCheckJobService.selectJobById(hiddenDangerCheckJob.getJobId()); |
| | |
| | | hiddenDangerCheckJob.setRiskDeptName(d.getDeptName()); |
| | | } |
| | | } |
| | | |
| | | //todo- 2022 保存job与管控措施的对应关系 |
| | | //1、先查询基础清单是否有变更 |
| | | Long jobIds = hiddenDangerCheckJob.getJobId(); |
| | | HiddenDangerCheckJob jobById = hiddenDangerCheckJobService.getJobById(hiddenDangerCheckJob.getJobId()); |
| | | |
| | | if (!jobById.getRiskId().equals(hiddenDangerCheckJob.getRiskId())){ |
| | | // 2、若有变更,再次添加关联关系 |
| | | riskService.updateJobAndMeasure(hiddenDangerCheckJob); |
| | | } |
| | | |
| | | return toAjax(hiddenDangerCheckJobService.updateJob(hiddenDangerCheckJob)); |
| | | } |
| | | |