提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.sche.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.service.impl.BaseServiceImpl; |
|
7 |
import com.iailab.module.model.mcs.sche.dao.StScheduleModelUserParamDao; |
|
8 |
import com.iailab.module.model.mcs.sche.entity.StScheduleModelUserParamEntity; |
|
9 |
import com.iailab.module.model.mcs.sche.service.StScheduleModelUserParamService; |
|
10 |
import com.iailab.module.model.mcs.sche.vo.ScheduleModelUserParamVo; |
|
11 |
import org.springframework.stereotype.Service; |
|
12 |
import org.springframework.util.CollectionUtils; |
|
13 |
|
|
14 |
import java.util.ArrayList; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Map; |
|
17 |
import java.util.UUID; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author PanZhibao |
|
21 |
* @date 2021年07月22日 10:40 |
|
22 |
*/ |
|
23 |
@Service("stScheduleModelUserParamService") |
|
24 |
public class StScheduleModelUserParamServiceImpl extends BaseServiceImpl<StScheduleModelUserParamDao, StScheduleModelUserParamEntity> implements StScheduleModelUserParamService { |
|
25 |
@Override |
|
26 |
public PageData<ScheduleModelUserParamVo> page(Map<String, Object> params) { |
|
27 |
IPage<StScheduleModelUserParamEntity> page = baseDao.selectPage( |
|
28 |
getPage(params, null, false), |
|
29 |
getWrapper(params) |
|
30 |
); |
|
31 |
return getPageData(page, ScheduleModelUserParamVo.class); |
|
32 |
} |
|
33 |
|
|
34 |
private QueryWrapper<StScheduleModelUserParamEntity> getWrapper(Map<String, Object> params) { |
|
35 |
QueryWrapper<StScheduleModelUserParamEntity> wrapper = new QueryWrapper<>(); |
|
36 |
return wrapper; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public List<StScheduleModelUserParamEntity> getByModelid(String modelid) { |
|
41 |
QueryWrapper<StScheduleModelUserParamEntity> queryWrapper = new QueryWrapper(); |
|
42 |
queryWrapper.eq("modelid", modelid); |
|
43 |
queryWrapper.orderByAsc("USERID"); |
|
44 |
queryWrapper.orderByAsc("ENERGYTYPEID"); |
|
45 |
List<StScheduleModelUserParamEntity> list = baseDao.selectList(queryWrapper); |
|
46 |
if (CollectionUtils.isEmpty(list)) { |
|
47 |
return new ArrayList<>(); |
|
48 |
} |
|
49 |
return list; |
|
50 |
} |
|
51 |
|
|
52 |
public void saveList(List<StScheduleModelUserParamEntity> list) { |
|
53 |
QueryWrapper<StScheduleModelUserParamEntity> queryWrapper = new QueryWrapper(); |
|
54 |
queryWrapper.eq("modelid", list.get(0).getModelid()); |
|
55 |
baseDao.delete(queryWrapper); |
|
56 |
list.forEach(item -> { |
|
57 |
item.setId(UUID.randomUUID().toString()); |
|
58 |
baseDao.insert(item); |
|
59 |
}); |
|
60 |
} |
|
61 |
|
|
62 |
public void deleteBatch(String[] modelIds) { |
|
63 |
QueryWrapper queryWrapper = new QueryWrapper<StScheduleModelUserParamEntity>(); |
|
64 |
queryWrapper.in("modelid", modelIds); |
|
65 |
baseDao.delete(queryWrapper); |
|
66 |
} |
|
67 |
} |