潘志宝
2024-09-05 7fd198b8ebe97cd06b10f96b9179caebe679783c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.iailab.module.model.mcs.pre.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao;
import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.*;
 
/**
 * @author PanZhibao
 * @date 2021年04月27日 9:24
 */
@Service
public class MmModelArithSettingsServiceImpl extends BaseServiceImpl<MmModelArithSettingsDao, MmModelArithSettingsEntity>
        implements MmModelArithSettingsService {
 
    @Override
    public void saveList(List<MmModelArithSettingsEntity> list) {
        QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
        queryWrapper.eq("modelid", list.get(0).getModelid());
        baseDao.delete(queryWrapper);
        list.forEach(item -> {
            item.setId(UUID.randomUUID().toString());
        });
        baseDao.insertList(list);
    }
 
    public List<MmModelArithSettingsEntity> getByModelid(String modelid) {
        Map<String, Object> params = new HashMap<>(1);
        params.put("modelid", modelid);
        List<MmModelArithSettingsEntity> list = baseDao.getMmModelArithSettings(params);
 
        if (CollectionUtils.isEmpty(list)) {
            return new ArrayList<>();
        }
        return list;
    }
 
    @Override
    public List<MmModelArithSettingsEntity> getByModelId(String modelId) {
        QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
        queryWrapper.eq("modelid", modelId);
        return baseDao.selectList(queryWrapper);
    }
}