选煤厂生产管理平台后台代码
Jay
6 天以前 8d3ff63ab144ad6b48015b01196bc901944a48f9
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.iailab.module.pms.coalquality.modules.plan.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.pms.coalquality.modules.plan.dao.QualityPlanDetDao;
import com.iailab.module.pms.coalquality.modules.plan.dto.QualityPlanDetDTO;
import com.iailab.module.pms.coalquality.modules.plan.entity.QualityPlanDetEntity;
import com.iailab.module.pms.coalquality.modules.plan.service.QualityPlanDetService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2023年02月04日 14:45:00
 */
@Service
public class QualityPlanDetServiceImpl extends BaseServiceImpl<QualityPlanDetDao, QualityPlanDetEntity>
        implements QualityPlanDetService {
 
    @Override
    public QualityPlanDetDTO get(String id) {
        QualityPlanDetEntity entity = baseDao.selectById(id);
 
        return ConvertUtils.sourceToTarget(entity, QualityPlanDetDTO.class);
    }
 
    @Override
    public void save(QualityPlanDetDTO dto) {
        QualityPlanDetEntity entity = ConvertUtils.sourceToTarget(dto, QualityPlanDetEntity.class);
 
        insert(entity);
    }
 
    @Override
    public void update(QualityPlanDetDTO dto) {
        QualityPlanDetEntity entity = ConvertUtils.sourceToTarget(dto, QualityPlanDetEntity.class);
 
        updateById(entity);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(String[] ids) {
        baseDao.deleteByIds(Arrays.asList(ids));
    }
 
    @Override
    public List<QualityPlanDetDTO> getListByPlanId(String planId) {
        List<QualityPlanDetEntity> list = baseDao.selectList(
                new QueryWrapper<QualityPlanDetEntity>().eq("plan_id", planId)
                .orderByAsc("sort"));
        return ConvertUtils.sourceToTarget(list, QualityPlanDetDTO.class);
    }
 
    @Override
    public void saveList(List<QualityPlanDetDTO> dtoList, String planId) {
        for(int i = 0; i < dtoList.size(); i++) {
            QualityPlanDetDTO item = dtoList.get(i);
            item.setPlanId(planId);
            item.setSort(i);
        }
        dtoList.forEach(this::save);
    }
 
    @Override
    public void deleteByPlanId(String planId) {
        baseDao.delete(new QueryWrapper<QualityPlanDetEntity>().eq("plan_id", planId));
    }
 
    @Override
    public void deleteByPlanIds(String[] planIds) {
        baseDao.delete(new QueryWrapper<QualityPlanDetEntity>().in("plan_id", Arrays.asList(planIds)));
    }
}