From a23e66f179586eeffc55d116f5a3bb53eab9cb09 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期五, 03 一月 2025 14:00:17 +0800
Subject: [PATCH] 调度方案批量启禁

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java
index 3461fc6..b395057 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java
@@ -1,18 +1,23 @@
 package com.iailab.module.model.mcs.sche.service.impl;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.AlarmConfigRespDTO;
+import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO;
+import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity;
 import com.iailab.module.model.mcs.sche.dao.StScheduleSchemeDao;
 import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity;
 import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService;
 import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO;
 import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeSaveReqVO;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.Date;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * @author PanZhibao
@@ -35,8 +40,8 @@
     }
 
     @Override
-    public void update(StScheduleSchemeSaveReqVO createReqVO) {
-        StScheduleSchemeEntity entity = BeanUtils.toBean(createReqVO, StScheduleSchemeEntity.class);
+    public void update(StScheduleSchemeSaveReqVO updateReqVO) {
+        StScheduleSchemeEntity entity = BeanUtils.toBean(updateReqVO, StScheduleSchemeEntity.class);
         baseDao.updateById(entity);
     }
 
@@ -58,10 +63,48 @@
     }
 
     @Override
-    public void updateTime(String id, Date scheduleTime) {
+    public List<StScheduleSchemeDTO> list(Map<String, Object> params) {
+        QueryWrapper<StScheduleSchemeEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("trigger_method", params.get("triggerMethod"));
+        queryWrapper.eq("trigger_condition", params.get("triggerCondition"));
+        List<StScheduleSchemeEntity> list = baseDao.selectList(queryWrapper);
+        return ConvertUtils.sourceToTarget(list, StScheduleSchemeDTO.class);
+    }
+
+    @Override
+    public void updateTime(String id, Date scheduleTime, String statusCode) {
         StScheduleSchemeEntity entity = new StScheduleSchemeEntity();
         entity.setId(id);
+        entity.setRunStatus(statusCode);
         entity.setScheduleTime(scheduleTime);
         baseDao.updateById(entity);
     }
+
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
+    public void enableByIds(String[] ids) {
+        if (CollectionUtils.isEmpty(Arrays.asList(ids))) {
+            return;
+        }
+        Arrays.asList(ids).forEach(item -> {
+            StScheduleSchemeEntity entity = new StScheduleSchemeEntity();
+            entity.setId(item);
+            entity.setStatus(0);
+            baseDao.updateById(entity);
+        });
+    }
+
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
+    public void disableByIds(String[] ids) {
+        if (CollectionUtils.isEmpty(Arrays.asList(ids))) {
+            return;
+        }
+        Arrays.asList(ids).forEach(item -> {
+            StScheduleSchemeEntity entity = new StScheduleSchemeEntity();
+            entity.setId(item);
+            entity.setStatus(1);
+            baseDao.updateById(entity);
+        });
+    }
 }

--
Gitblit v1.9.3