From 6eeac9efdb16f92d19536bf23a2d1471705fe752 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期二, 31 十二月 2024 18:34:38 +0800
Subject: [PATCH] 调度模型下发

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java |  150 ++++++++++++++++++-------------------------------
 1 files changed, 55 insertions(+), 95 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java
index 277bd7e..2932e85 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java
@@ -1,145 +1,105 @@
 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.baomidou.mybatisplus.core.metadata.IPage;
 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.module.model.mcs.sche.dao.StScheduleModelDao;
-import com.iailab.module.model.mcs.sche.dto.StScheduleModelDto;
 import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
-import com.iailab.module.model.mcs.sche.entity.StScheduleModelUserParamEntity;
-import com.iailab.module.model.mcs.sche.entity.StScheduleParamEntity;
-import com.iailab.module.model.mcs.sche.entity.StScheduleParamSettingEntity;
+import com.iailab.module.model.mcs.sche.service.StScheduleModelOutService;
+import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
 import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
-import com.iailab.module.model.mcs.sche.vo.StScheduleModelRespVO;
+import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
+import com.iailab.module.model.mcs.sche.vo.StScheduleModelPageReqVO;
+import com.iailab.module.model.mcs.sche.vo.StScheduleModelSaveReqVO;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Arrays;
+import javax.annotation.Resource;
 import java.util.List;
-import java.util.Map;
 import java.util.UUID;
 
 /**
  * @author PanZhibao
  * @date 2021年07月20日 14:23
  */
-@Service("stScheduleModelService")
-public class StScheduleModelServiceImpl extends BaseServiceImpl<StScheduleModelDao, StScheduleModelEntity> implements StScheduleModelService {
-    @Autowired
-    private StScheduleParamSettingServiceImpl stScheduleParamSettingServiceImpl;
+@Service
+public class StScheduleModelServiceImpl implements StScheduleModelService {
+
+    @Resource
+    private StScheduleModelDao stScheduleModelDao;
 
     @Autowired
-    private StScheduleParamServiceImpl stScheduleParamServiceImpl;
+    private StScheduleModelParamService stScheduleModelParamService;
 
     @Autowired
-    private StScheduleModelUserParamServiceImpl stScheduleModelUserParamServiceImpl;
+    private StScheduleModelSettingService stScheduleModelSettingService;
+
+    @Autowired
+    private StScheduleModelOutService stScheduleModelOutService;
 
     @Override
-    public PageResult<StScheduleModelRespVO> getPageList(Map<String, Object> params) {
-        PageResult<StScheduleModelRespVO> result = new PageResult();
-        IPage<StScheduleModelRespVO> page = baseDao.getPageList(
-                getPage(params, null, false),
-                params
-        );
-        result.setTotal(page.getTotal());
-        result.setList(page.getRecords());
-        return result;
-    }
-
-    private QueryWrapper<StScheduleModelEntity> getWrapper(Map<String, Object> params) {
-        QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>();
-        return wrapper;
+    public PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO) {
+        return stScheduleModelDao.selectPage(reqVO);
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void saveStScheduleModel(StScheduleModelDto scheduleModel) {
-        StScheduleModelEntity stScheduleModelEntity = new StScheduleModelEntity();
-        BeanUtils.copyProperties(scheduleModel, stScheduleModelEntity);
-        stScheduleModelEntity.setId(UUID.randomUUID().toString());
-        baseDao.insert(stScheduleModelEntity);
+    public List<StScheduleModelEntity> list() {
 
-        scheduleModel.getStScheduleParamSettingList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleParamSettingServiceImpl.saveList(scheduleModel.getStScheduleParamSettingList());
-
-        scheduleModel.getStScheduleParamList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleParamServiceImpl.saveList(scheduleModel.getStScheduleParamList());
-
-        scheduleModel.getStScheduleModelUserParamList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleModelUserParamServiceImpl.saveList(scheduleModel.getStScheduleModelUserParamList());
+        return stScheduleModelDao.selectList(null);
     }
 
     @Override
-    public StScheduleModelDto getDetailById(String id) {
-        StScheduleModelDto scheduleMode = new StScheduleModelDto();
-        StScheduleModelEntity stScheduleModelEntity = baseDao.selectById(id);
-        BeanUtils.copyProperties(stScheduleModelEntity, scheduleMode);
-        List<StScheduleParamSettingEntity> stScheduleParamSettingList = stScheduleParamSettingServiceImpl.getByModelid(stScheduleModelEntity.getId());
-        scheduleMode.setStScheduleParamSettingList(stScheduleParamSettingList);
-        List<StScheduleParamEntity> stScheduleParamList = stScheduleParamServiceImpl.getByModelid(stScheduleModelEntity.getId());
-        scheduleMode.setStScheduleParamList(stScheduleParamList);
-        List<StScheduleModelUserParamEntity> stScheduleModelUserParamList = stScheduleModelUserParamServiceImpl.getByModelid(stScheduleModelEntity.getId());
-        scheduleMode.setStScheduleModelUserParamList(stScheduleModelUserParamList);
-        return scheduleMode;
+    @DSTransactional(rollbackFor = Exception.class)
+    public void create(StScheduleModelSaveReqVO reqVO) {
+        StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
+        entity.setId(UUID.randomUUID().toString());
+        stScheduleModelDao.insert(entity);
+        stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
+        stScheduleModelOutService.insertList(reqVO.getModelOut(), entity.getId());
+        stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void update(StScheduleModelDto scheduleModel) {
-        StScheduleModelEntity stScheduleModelEntity = new StScheduleModelEntity();
-        BeanUtils.copyProperties(scheduleModel, stScheduleModelEntity);
-        baseDao.updateById(stScheduleModelEntity);
-
-        scheduleModel.getStScheduleParamSettingList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleParamSettingServiceImpl.saveList(scheduleModel.getStScheduleParamSettingList());
-
-        scheduleModel.getStScheduleParamList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleParamServiceImpl.saveList(scheduleModel.getStScheduleParamList());
-
-        scheduleModel.getStScheduleModelUserParamList().forEach(item -> {
-            item.setModelid(stScheduleModelEntity.getId());
-        });
-        stScheduleModelUserParamServiceImpl.saveList(scheduleModel.getStScheduleModelUserParamList());
+    @DSTransactional(rollbackFor = Exception.class)
+    public void update(StScheduleModelSaveReqVO reqVO) {
+        StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
+        stScheduleModelDao.updateById(entity);
+        stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
+        stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
+        stScheduleModelOutService.deleteScheduleModelOut(entity.getId());
+        stScheduleModelOutService.insertList(reqVO.getModelOut(), entity.getId());
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void deleteBatch(String[] scheduleModelIds) {
-        baseDao.deleteBatchIds(Arrays.asList(scheduleModelIds));
-        stScheduleParamSettingServiceImpl.deleteBatch(scheduleModelIds);
-        stScheduleParamServiceImpl.deleteBatch(scheduleModelIds);
-        stScheduleModelUserParamServiceImpl.deleteBatch(scheduleModelIds);
+    public StScheduleModelEntity get(String id) {
+        return stScheduleModelDao.selectById(id);
     }
 
     @Override
-    public int check(StScheduleModelEntity scheduleModel) {
-        String id = scheduleModel.getId();
-        String modelname = scheduleModel.getModelname();
+    @DSTransactional(rollbackFor = Exception.class)
+    public void delete(String id) {
+        stScheduleModelDao.deleteById(id);
+        stScheduleModelParamService.deleteByModelId(id);
+        stScheduleModelSettingService.deleteByModelId(id);
+        stScheduleModelOutService.deleteScheduleModelOut(id);
+    }
+
+    @Override
+    public Long check(StScheduleModelSaveReqVO reqVO) {
+        String id = reqVO.getId();
+        String modelname = reqVO.getModelName();
         QueryWrapper<StScheduleModelEntity> scheduleModelWrapper = new QueryWrapper<>();
         scheduleModelWrapper.ne(StringUtils.isNotBlank(id), "id", id);
-        scheduleModelWrapper.and(wrapper -> wrapper.eq("modelname", modelname));
-
-        List<StScheduleModelEntity> list = baseDao.selectList(scheduleModelWrapper);
-        return list.size();
+        scheduleModelWrapper.and(wrapper -> wrapper.eq("model_name", modelname));
+        return stScheduleModelDao.selectCount(scheduleModelWrapper);
     }
 
     @Override
     public Long count() {
         QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>();
-        return baseDao.selectCount(wrapper);
+        return stScheduleModelDao.selectCount(wrapper);
     }
 }

--
Gitblit v1.9.3