From f7819b4bc08d3ee2fc391b79da8480e7c85d64fd Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期五, 28 三月 2025 13:57:25 +0800
Subject: [PATCH] ASDC

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StAdjustConfigServiceImpl.java |   83 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StAdjustConfigServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StAdjustConfigServiceImpl.java
index dd5b57e..d9cf83a 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StAdjustConfigServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StAdjustConfigServiceImpl.java
@@ -1,16 +1,30 @@
 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.fhs.core.trans.anno.Trans;
+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.StAdjustConfigDTO;
+import com.iailab.module.model.common.enums.AdjustConfigStatusEnum;
+import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
 import com.iailab.module.model.mcs.sche.dao.StAdjustConfigDao;
 import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity;
 import com.iailab.module.model.mcs.sche.entity.StAdjustConfigEntity;
 import com.iailab.module.model.mcs.sche.service.StAdjustConfigDetService;
 import com.iailab.module.model.mcs.sche.service.StAdjustConfigService;
+import com.iailab.module.model.mcs.sche.vo.StAdjustConfigPageReqVO;
+import com.iailab.module.model.mcs.sche.vo.StAdjustConfigRespVO;
+import com.iailab.module.model.mcs.sche.vo.StAdjustConfigSaveReqVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.List;
+import java.util.*;
 
 /**
  * @author PanZhibao
@@ -24,13 +38,70 @@
     @Autowired
     private StAdjustConfigDetService stAdjustConfigDetService;
 
-    public StAdjustConfigEntity getByModelId(String modelId) {
-        return baseDao.selectOne("schedule_model_id", modelId);
+    @Override
+    public PageResult<StAdjustConfigRespVO> page(StAdjustConfigPageReqVO reqVO) {
+        IPage<StAdjustConfigRespVO> page = baseDao.selectPage(reqVO);
+        return new PageResult<>(page.getRecords(), page.getTotal());
     }
 
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
+    public void create(StAdjustConfigSaveReqVO createReqVO) {
+        StAdjustConfigEntity entity = BeanUtils.toBean(createReqVO, StAdjustConfigEntity.class);
+        entity.setId(UUID.randomUUID().toString());
+        baseDao.insert(entity);
 
-    public List<StAdjustConfigDetEntity> getDetByModelId(String modelId) {
-        StAdjustConfigEntity configEntity = getByModelId(modelId);
-        return stAdjustConfigDetService.getListByConfigId(configEntity.getId());
+        List<StAdjustConfigDetEntity> detList = createReqVO.getAdjustConfigDetList();
+        stAdjustConfigDetService.insertList(detList, entity.getId());
+    }
+
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
+    public void update(StAdjustConfigSaveReqVO updateReqVO) {
+        StAdjustConfigEntity entity = BeanUtils.toBean(updateReqVO, StAdjustConfigEntity.class);
+        baseDao.updateById(entity);
+
+        stAdjustConfigDetService.deleteByConfigId(entity.getId());
+        List<StAdjustConfigDetEntity> detList = updateReqVO.getAdjustConfigDetList();
+        stAdjustConfigDetService.insertList(detList, entity.getId());
+    }
+
+    @Override
+    @DSTransactional(rollbackFor = Exception.class)
+    public void delete(String id) {
+        baseDao.deleteById(id);
+        stAdjustConfigDetService.deleteByConfigId(id);
+    }
+
+    @Override
+    public StAdjustConfigEntity getInfo(String id) {
+        return baseDao.selectById(id);
+    }
+
+    @Override
+    public List<StAdjustConfigDTO> list(Map<String, Object> params) {
+        QueryWrapper<StAdjustConfigEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("trigger_method", params.get("triggerMethod"));
+        queryWrapper.eq("trigger_condition", params.get("triggerCondition"));
+        List<StAdjustConfigEntity> list = baseDao.selectList(queryWrapper);
+        return ConvertUtils.sourceToTarget(list, StAdjustConfigDTO.class);
+    }
+
+    @Override
+    public Map<StAdjustConfigEntity, List<StAdjustConfigDetEntity>> getAdjustConfigMap(String modelId) {
+        Map<StAdjustConfigEntity, List<StAdjustConfigDetEntity>> result = new HashMap<>();
+        QueryWrapper<StAdjustConfigEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("schedule_model_id", modelId)
+                .eq("status", AdjustConfigStatusEnum.ENABLE.getCode());
+        List<StAdjustConfigEntity> configList =  baseDao.selectList(queryWrapper);
+        if (CollectionUtils.isEmpty(configList)) {
+            return result;
+        }
+        for (StAdjustConfigEntity entity : configList) {
+            List<StAdjustConfigDetEntity> detList = stAdjustConfigDetService.getListByConfigId(entity.getId());
+            result.put(entity, detList);
+        }
+
+        return result;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3