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