提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.sche.service.impl; |
潘 |
2 |
|
a23e66
|
3 |
import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
bbc1ee
|
4 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
潘 |
5 |
import com.iailab.framework.common.pojo.PageResult; |
7fd198
|
6 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
bbc1ee
|
7 |
import com.iailab.framework.common.util.object.BeanUtils; |
4072bc
|
8 |
import com.iailab.framework.common.util.object.ConvertUtils; |
L |
9 |
import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; |
|
10 |
import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
|
11 |
import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; |
7fd198
|
12 |
import com.iailab.module.model.mcs.sche.dao.StScheduleSchemeDao; |
潘 |
13 |
import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; |
|
14 |
import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService; |
bbc1ee
|
15 |
import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO; |
潘 |
16 |
import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeSaveReqVO; |
7fd198
|
17 |
import org.springframework.stereotype.Service; |
a23e66
|
18 |
import org.springframework.util.CollectionUtils; |
bbc1ee
|
19 |
|
4072bc
|
20 |
import java.util.*; |
7fd198
|
21 |
|
潘 |
22 |
/** |
|
23 |
* @author PanZhibao |
|
24 |
* @date 2021年08月11日 12:06 |
|
25 |
*/ |
bbc1ee
|
26 |
@Service |
7fd198
|
27 |
public class StScheduleSchemeServiceImpl extends BaseServiceImpl<StScheduleSchemeDao, StScheduleSchemeEntity> |
潘 |
28 |
implements StScheduleSchemeService { |
bbc1ee
|
29 |
|
潘 |
30 |
@Override |
|
31 |
public PageResult<StScheduleSchemeEntity> page(StScheduleSchemePageReqVO reqVO) { |
|
32 |
return baseDao.selectPage(reqVO); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public void create(StScheduleSchemeSaveReqVO createReqVO) { |
|
37 |
StScheduleSchemeEntity entity = BeanUtils.toBean(createReqVO, StScheduleSchemeEntity.class); |
|
38 |
entity.setId(UUID.randomUUID().toString()); |
|
39 |
baseDao.insert(entity); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
51c1c2
|
43 |
public void update(StScheduleSchemeSaveReqVO updateReqVO) { |
潘 |
44 |
StScheduleSchemeEntity entity = BeanUtils.toBean(updateReqVO, StScheduleSchemeEntity.class); |
bbc1ee
|
45 |
baseDao.updateById(entity); |
潘 |
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void delete(String id) { |
|
50 |
baseDao.deleteById(id); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public StScheduleSchemeEntity getInfo(String id) { |
|
55 |
return baseDao.selectById(id); |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public StScheduleSchemeEntity getByCode(String code) { |
|
60 |
QueryWrapper<StScheduleSchemeEntity> queryWrapper = new QueryWrapper<>(); |
|
61 |
queryWrapper.eq("code", code); |
|
62 |
return baseDao.selectOne(queryWrapper); |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
4072bc
|
66 |
public List<StScheduleSchemeDTO> list(Map<String, Object> params) { |
L |
67 |
QueryWrapper<StScheduleSchemeEntity> queryWrapper = new QueryWrapper<>(); |
ed4107
|
68 |
queryWrapper.eq("trigger_method", params.get("triggerMethod")); |
潘 |
69 |
queryWrapper.eq("trigger_condition", params.get("triggerCondition")); |
4072bc
|
70 |
List<StScheduleSchemeEntity> list = baseDao.selectList(queryWrapper); |
L |
71 |
return ConvertUtils.sourceToTarget(list, StScheduleSchemeDTO.class); |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
b2bb7d
|
75 |
public void updateTime(String id, Date scheduleTime, String statusCode) { |
bbc1ee
|
76 |
StScheduleSchemeEntity entity = new StScheduleSchemeEntity(); |
潘 |
77 |
entity.setId(id); |
b2bb7d
|
78 |
entity.setRunStatus(statusCode); |
bbc1ee
|
79 |
entity.setScheduleTime(scheduleTime); |
潘 |
80 |
baseDao.updateById(entity); |
|
81 |
} |
a23e66
|
82 |
|
D |
83 |
@Override |
|
84 |
@DSTransactional(rollbackFor = Exception.class) |
|
85 |
public void enableByIds(String[] ids) { |
|
86 |
if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
|
87 |
return; |
|
88 |
} |
|
89 |
Arrays.asList(ids).forEach(item -> { |
|
90 |
StScheduleSchemeEntity entity = new StScheduleSchemeEntity(); |
|
91 |
entity.setId(item); |
|
92 |
entity.setStatus(0); |
|
93 |
baseDao.updateById(entity); |
|
94 |
}); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
@DSTransactional(rollbackFor = Exception.class) |
|
99 |
public void disableByIds(String[] ids) { |
|
100 |
if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
|
101 |
return; |
|
102 |
} |
|
103 |
Arrays.asList(ids).forEach(item -> { |
|
104 |
StScheduleSchemeEntity entity = new StScheduleSchemeEntity(); |
|
105 |
entity.setId(item); |
|
106 |
entity.setStatus(1); |
|
107 |
baseDao.updateById(entity); |
|
108 |
}); |
|
109 |
} |
7fd198
|
110 |
} |