From 9015e720487b737743232b0b3aa464c2ac9e8d17 Mon Sep 17 00:00:00 2001
From: heheng <heheng@123456>
Date: 星期五, 15 十一月 2024 17:31:24 +0800
Subject: [PATCH] 修改请求地址

---
 src/main/java/com/ruoyi/project/tr/HiddenDangerCheckJob/controller/HiddenDangerCheckJobController.java |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/project/tr/HiddenDangerCheckJob/controller/HiddenDangerCheckJobController.java b/src/main/java/com/ruoyi/project/tr/HiddenDangerCheckJob/controller/HiddenDangerCheckJobController.java
index 036db18..22d5747 100644
--- a/src/main/java/com/ruoyi/project/tr/HiddenDangerCheckJob/controller/HiddenDangerCheckJobController.java
+++ b/src/main/java/com/ruoyi/project/tr/HiddenDangerCheckJob/controller/HiddenDangerCheckJobController.java
@@ -4,6 +4,10 @@
 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;
@@ -24,7 +28,9 @@
 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.*;
@@ -56,6 +62,8 @@
     private IRegionService regionService;
     @Autowired
     private IDeptService deptService;
+    @Autowired
+    private RiskService riskService;
 
     @GetMapping()
     public String hiddenDangerCheckJob() {
@@ -83,8 +91,16 @@
     @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();
     }
 
@@ -152,10 +168,12 @@
 
     /**
      * 新增保存调度
+     * 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(",");
@@ -212,6 +230,14 @@
                                 }
                             }
                             hiddenDangerCheckJobService.insertJob(hiddenDangerCheckJob);
+
+                            //todo- 2022 保存job与管控措施的对应关系
+                            hiddenDangerCheckJob.getJobId();
+                            int result = riskService.insertJobAndMeasure(hiddenDangerCheckJob.getJobId(),hiddenDangerCheckJob);{
+                                if (result < 0 ){
+                                    throw new RuntimeException("保存job与管控措施的对应关系失败");
+                                }
+                            }
                         }
                     }
                 }
@@ -259,6 +285,8 @@
             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;
     }
@@ -310,6 +338,7 @@
     @Log(title = "定时任务", businessType = BusinessType.UPDATE)
     @PostMapping("/edit")
     @ResponseBody
+    @Transactional
     public AjaxResult editSave(@Validated HiddenDangerCheckJob hiddenDangerCheckJob) throws
             SchedulerException, TaskException {
         HiddenDangerCheckJob tempJob = hiddenDangerCheckJobService.selectJobById(hiddenDangerCheckJob.getJobId());
@@ -350,6 +379,17 @@
                 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));
     }
 

--
Gitblit v1.9.2