提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
5 |
import com.iailab.framework.common.page.PageData; |
|
6 |
import com.iailab.framework.common.pojo.PageResult; |
|
7 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
8 |
import com.iailab.module.model.mcs.pre.dao.DmModuleDao; |
|
9 |
import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; |
|
10 |
import com.iailab.module.model.mcs.pre.service.DmModuleService; |
|
11 |
import com.iailab.module.model.mcs.pre.vo.DmModulePageReqVO; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.springframework.stereotype.Service; |
|
14 |
import org.springframework.transaction.annotation.Transactional; |
|
15 |
|
|
16 |
import java.util.*; |
|
17 |
|
|
18 |
/** |
|
19 |
* @author PanZhibao |
|
20 |
* @date 2021年04月23日 8:36 |
|
21 |
*/ |
|
22 |
@Service("dmModuleService") |
|
23 |
public class DmModuleServiceImpl extends BaseServiceImpl<DmModuleDao, DmModuleEntity> implements DmModuleService { |
|
24 |
|
|
25 |
@Override |
|
26 |
public PageResult<DmModuleEntity> queryPage(DmModulePageReqVO reqVO) { |
|
27 |
return baseDao.selectPage(reqVO); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public List<DmModuleEntity> list(Map<String, Object> params) { |
|
32 |
QueryWrapper<DmModuleEntity> wrapper = getWrapper(params); |
|
33 |
wrapper.orderByDesc("CREATE_TIME"); |
|
34 |
return baseDao.selectList(wrapper); |
|
35 |
} |
|
36 |
|
bbc1ee
|
37 |
@Override |
潘 |
38 |
public DmModuleEntity get(String id) { |
|
39 |
return baseDao.selectById(id); |
|
40 |
} |
|
41 |
|
7fd198
|
42 |
private QueryWrapper<DmModuleEntity> getWrapper(Map<String, Object> params) { |
潘 |
43 |
String modulename = (String) params.get("modulename"); |
|
44 |
String moduletype = (String) params.get("moduletype"); |
|
45 |
|
|
46 |
QueryWrapper<DmModuleEntity> wrapper = new QueryWrapper<>(); |
|
47 |
wrapper.like(StringUtils.isNotBlank(modulename), "modulename", modulename) |
|
48 |
.eq(StringUtils.isNotBlank(moduletype), "moduletype", moduletype); |
|
49 |
|
|
50 |
return wrapper; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
@Transactional(rollbackFor = Exception.class) |
|
55 |
public void saveModule(DmModuleEntity module) { |
|
56 |
module.setId(UUID.randomUUID().toString()); |
|
57 |
Calendar calendar = Calendar.getInstance(); |
|
58 |
calendar.set(Calendar.SECOND, 0); |
|
59 |
calendar.set(Calendar.MILLISECOND, 0); |
|
60 |
module.setPredicttime(calendar.getTime()); |
|
61 |
module.setCollecttime(calendar.getTime()); |
|
62 |
module.setUpdateTime(new Date()); |
|
63 |
baseDao.insert(module); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
@Transactional(rollbackFor = Exception.class) |
|
68 |
public void update(DmModuleEntity module) { |
|
69 |
module.setUpdateTime(new Date()); |
|
70 |
baseDao.updateById(module); |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
@Transactional(rollbackFor = Exception.class) |
|
75 |
public void deleteBatch(String[] moduleIds) { |
|
76 |
baseDao.deleteBatchIds(Arrays.asList(moduleIds)); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public List<DmModuleEntity> getModuleByModuleType(String moduletype) { |
|
81 |
Map<String, Object> params = new HashMap<>(1); |
|
82 |
params.put("moduletype", moduletype); |
|
83 |
QueryWrapper<DmModuleEntity> wrapper = getWrapper(params); |
|
84 |
return baseDao.selectList(wrapper); |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public int check(DmModuleEntity module) { |
|
90 |
String id = module.getId(); |
|
91 |
String modulename = module.getModulename(); |
|
92 |
QueryWrapper<DmModuleEntity> moduleWrapper = new QueryWrapper<>(); |
|
93 |
moduleWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
|
94 |
moduleWrapper.and(wrapper -> wrapper.eq("modulename", modulename)); |
|
95 |
|
|
96 |
List<DmModuleEntity> list = baseDao.selectList(moduleWrapper); |
|
97 |
return list.size(); |
|
98 |
} |
|
99 |
|
|
100 |
} |