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