dengzedong
9 天以前 67f59ab45824874e8adb0f07b2912f4a3a185b3c
提交 | 用户 | 时间
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
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
6eeac9 39     @Autowired
D 40     private StScheduleModelOutService stScheduleModelOutService;
41
7fd198 42     @Override
bbc1ee 43     public PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO) {
b425df 44         return stScheduleModelDao.selectPage(reqVO);
7fd198 45     }
46
47     @Override
056470 48     public List<StScheduleModelEntity> list() {
49
b425df 50         return stScheduleModelDao.selectList(null);
056470 51     }
52
53     @Override
b425df 54     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 55     public void create(StScheduleModelSaveReqVO reqVO) {
56         StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
57         entity.setId(UUID.randomUUID().toString());
b425df 58         stScheduleModelDao.insert(entity);
bbc1ee 59         stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
6eeac9 60         stScheduleModelOutService.insertList(reqVO.getModelOut(), entity.getId());
bbc1ee 61         stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
7fd198 62     }
63
64     @Override
b425df 65     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 66     public void update(StScheduleModelSaveReqVO reqVO) {
67         StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
b425df 68         stScheduleModelDao.updateById(entity);
bbc1ee 69         stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
70         stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
6eeac9 71         stScheduleModelOutService.deleteScheduleModelOut(entity.getId());
D 72         stScheduleModelOutService.insertList(reqVO.getModelOut(), entity.getId());
bbc1ee 73     }
7fd198 74
bbc1ee 75     @Override
76     public StScheduleModelEntity get(String id) {
b425df 77         return stScheduleModelDao.selectById(id);
7fd198 78     }
79
80     @Override
b425df 81     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 82     public void delete(String id) {
b425df 83         stScheduleModelDao.deleteById(id);
bbc1ee 84         stScheduleModelParamService.deleteByModelId(id);
85         stScheduleModelSettingService.deleteByModelId(id);
6eeac9 86         stScheduleModelOutService.deleteScheduleModelOut(id);
7fd198 87     }
88
89     @Override
bbc1ee 90     public Long check(StScheduleModelSaveReqVO reqVO) {
91         String id = reqVO.getId();
92         String modelname = reqVO.getModelName();
7fd198 93         QueryWrapper<StScheduleModelEntity> scheduleModelWrapper = new QueryWrapper<>();
94         scheduleModelWrapper.ne(StringUtils.isNotBlank(id), "id", id);
bbc1ee 95         scheduleModelWrapper.and(wrapper -> wrapper.eq("model_name", modelname));
b425df 96         return stScheduleModelDao.selectCount(scheduleModelWrapper);
7fd198 97     }
98
99     @Override
100     public Long count() {
101         QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>();
b425df 102         return stScheduleModelDao.selectCount(wrapper);
7fd198 103     }
e9506a 104
J 105     @Override
106     public StScheduleModelEntity getByModelCode(String modelCode) {
107         return stScheduleModelDao.selectOne("model_code", modelCode);
108     }
7fd198 109 }