潘志宝
2024-12-03 51c1c2c9fa28fb1765dd6e81c70b78566792aebe
提交 | 用户 | 时间
7fd198 1 package com.iailab.module.model.mcs.sche.service.impl;
2
b425df 3 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
7fd198 4 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 import com.iailab.framework.common.pojo.PageResult;
bbc1ee 6 import com.iailab.framework.common.util.object.BeanUtils;
7fd198 7 import com.iailab.module.model.mcs.sche.dao.StScheduleModelDao;
8 import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
bbc1ee 9 import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
7fd198 10 import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
bbc1ee 11 import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
12 import com.iailab.module.model.mcs.sche.vo.StScheduleModelPageReqVO;
13 import com.iailab.module.model.mcs.sche.vo.StScheduleModelSaveReqVO;
7fd198 14 import org.apache.commons.lang3.StringUtils;
15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service;
17 import org.springframework.transaction.annotation.Transactional;
18
b425df 19 import javax.annotation.Resource;
056470 20 import java.util.List;
7fd198 21 import java.util.UUID;
22
23 /**
24  * @author PanZhibao
25  * @date 2021年07月20日 14:23
26  */
bbc1ee 27 @Service
b425df 28 public class StScheduleModelServiceImpl implements StScheduleModelService {
29
30     @Resource
31     private StScheduleModelDao stScheduleModelDao;
7fd198 32
33     @Autowired
bbc1ee 34     private StScheduleModelParamService stScheduleModelParamService;
7fd198 35
36     @Autowired
bbc1ee 37     private StScheduleModelSettingService stScheduleModelSettingService;
7fd198 38
39     @Override
bbc1ee 40     public PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO) {
b425df 41         return stScheduleModelDao.selectPage(reqVO);
7fd198 42     }
43
44     @Override
056470 45     public List<StScheduleModelEntity> list() {
46
b425df 47         return stScheduleModelDao.selectList(null);
056470 48     }
49
50     @Override
b425df 51     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 52     public void create(StScheduleModelSaveReqVO reqVO) {
53         StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
54         entity.setId(UUID.randomUUID().toString());
b425df 55         stScheduleModelDao.insert(entity);
bbc1ee 56         stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
57         stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
7fd198 58     }
59
60     @Override
b425df 61     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 62     public void update(StScheduleModelSaveReqVO reqVO) {
63         StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
b425df 64         stScheduleModelDao.updateById(entity);
bbc1ee 65         stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
66         stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
67     }
7fd198 68
bbc1ee 69     @Override
70     public StScheduleModelEntity get(String id) {
b425df 71         return stScheduleModelDao.selectById(id);
7fd198 72     }
73
74     @Override
b425df 75     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 76     public void delete(String id) {
b425df 77         stScheduleModelDao.deleteById(id);
bbc1ee 78         stScheduleModelParamService.deleteByModelId(id);
79         stScheduleModelSettingService.deleteByModelId(id);
7fd198 80     }
81
82     @Override
bbc1ee 83     public Long check(StScheduleModelSaveReqVO reqVO) {
84         String id = reqVO.getId();
85         String modelname = reqVO.getModelName();
7fd198 86         QueryWrapper<StScheduleModelEntity> scheduleModelWrapper = new QueryWrapper<>();
87         scheduleModelWrapper.ne(StringUtils.isNotBlank(id), "id", id);
bbc1ee 88         scheduleModelWrapper.and(wrapper -> wrapper.eq("model_name", modelname));
b425df 89         return stScheduleModelDao.selectCount(scheduleModelWrapper);
7fd198 90     }
91
92     @Override
93     public Long count() {
94         QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>();
b425df 95         return stScheduleModelDao.selectCount(wrapper);
7fd198 96     }
97 }