选煤厂生产管理平台后台代码
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.iailab.module.pms.coalquality.modules.detection.service.impl;
 
 
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.pms.coalquality.modules.detection.dao.QualityQuickDao;
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityQuickDTO;
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityQuickItemDTO;
import com.iailab.module.pms.coalquality.modules.detection.entity.QualityQuickEntity;
import com.iailab.module.pms.coalquality.modules.detection.service.QualityQuickItemService;
import com.iailab.module.pms.coalquality.modules.detection.service.QualityQuickService;
import com.iailab.module.pms.coalquality.modules.detection.vo.QuickPageReqVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author DongYukun
 * @Description
 * @createTime 2023年12月27日 9:53:00
 */
@Slf4j
@Service
public class QualityQuickServiceImpl extends BaseServiceImpl<QualityQuickDao, QualityQuickEntity>
        implements QualityQuickService {
 
    private String BUSINESS_CODE = "QualityQuick";
 
    @Autowired
    private QualityQuickItemService qualityQuickItemService;
 
    @Override
    public PageResult<QualityQuickDTO> page(QuickPageReqVO reqVO) {
        PageResult<QualityQuickEntity> page = baseDao.selectPage(reqVO);
 
        return BeanUtils.toBean(page, QualityQuickDTO.class);
    }
 
    @Override
    public QualityQuickDTO get(String id) {
        QualityQuickEntity entity = baseDao.selectById(id);
        QualityQuickDTO dto = ConvertUtils.sourceToTarget(entity, QualityQuickDTO.class);
        Map<String, Object> parmas = new HashMap<>(1);
        parmas.put("lsh", dto.getLsh());
        List<QualityQuickItemDTO> itemList = qualityQuickItemService.queryList(parmas);
        dto.setItemList(itemList);
        return dto;
    }
 
    @Override
    public void save(QualityQuickDTO dto) {
        //dto.setLsh(serialNumUtils.getByBusinessDate(BUSINESS_CODE, dto.getDatetime(), 4));
        QualityQuickEntity entity = ConvertUtils.sourceToTarget(dto, QualityQuickEntity.class);
        insert(entity);
        dto.getItemList().stream().forEach(
                item->{
                    item.setLsh(dto.getLsh());
                    qualityQuickItemService.save(item);
                }
        );
    }
 
    @Override
    public void update(QualityQuickDTO dto) {
        QualityQuickEntity entity = ConvertUtils.sourceToTarget(dto, QualityQuickEntity.class);
        updateById(entity);
        qualityQuickItemService.deleteByLsh(dto.getLsh());
 
        dto.getItemList().forEach(
                item->{
                    item.setLsh(dto.getLsh());
                    qualityQuickItemService.save(item);
                    }
        );
 
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(String[] ids) {
        QualityQuickEntity dto = baseDao.selectById(ids[0]);
        baseDao.deleteByIds(Arrays.asList(ids));
        qualityQuickItemService.deleteByLsh(dto.getLsh());
    }
 
 
}