选煤厂生产管理平台后台代码
dongyukun
2024-12-10 3f07ab2e03e501ae55d1d1b0d031daf50c8e13e5
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.iailab.module.pms.coalquality.modules.analysis.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.analysis.dao.CoalAnalysisFullDao;
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalAnalysisFullDTO;
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalAnalysisFullDetDTO;
import com.iailab.module.pms.coalquality.modules.analysis.entity.CoalAnalysisFullEntity;
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalAnalysisFullDetService;
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalAnalysisFullService;
import com.iailab.module.pms.coalquality.modules.analysis.vo.FullPageReqVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.text.DecimalFormat;
import java.util.*;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2023年01月12日 17:09:00
 */
@Service
public class CoalAnalysisFullServiceImpl extends BaseServiceImpl<CoalAnalysisFullDao, CoalAnalysisFullEntity>
        implements CoalAnalysisFullService {
 
    @Autowired
    private CoalAnalysisFullDetService coalAnalysisFullDetService;
 
    private String BUSINESS_CODE = "CoalAnalysisFull";
 
    private DecimalFormat df = new DecimalFormat("00");
 
    @Override
    public PageResult<CoalAnalysisFullDTO> page(FullPageReqVO fullPageReqVO) {
        PageResult<CoalAnalysisFullEntity> page = baseDao.selectPage(fullPageReqVO);
 
        return BeanUtils.toBean(page, CoalAnalysisFullDTO.class);
    }
 
 
    @Override
    public CoalAnalysisFullDTO get(String id) {
        CoalAnalysisFullEntity entity = baseDao.selectById(id);
        CoalAnalysisFullDTO dto = ConvertUtils.sourceToTarget(entity, CoalAnalysisFullDTO.class);
        dto.setDetList(getDetList(dto.getId()));
        return dto;
    }
 
    private List<CoalAnalysisFullDetDTO> getDetList(String fullId) {
        Map<String, Object> parmas = new HashMap<>(1);
        parmas.put("fullId", fullId);
        return coalAnalysisFullDetService.queryList(parmas);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(CoalAnalysisFullDTO dto) {
        dto.setCode(dto.getNy().replace("-", ""));
        CoalAnalysisFullEntity entity = ConvertUtils.sourceToTarget(dto, CoalAnalysisFullEntity.class);
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateDate(new Date());
        insert(entity);
 
        List<CoalAnalysisFullDetDTO> detList = dto.getDetList();
//        if (!CollectionUtils.isEmpty(detList)) {
//            for (int i = 0; i < detList.size(); i++) {
//                detList.get(i).setCode(entity.getCode() + df.format(i + 1));
//                detList.get(i).setFullId(entity.getId());
//            }
//            coalAnalysisFullDetService.saveList(detList);
//        }
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(CoalAnalysisFullDTO dto) {
        CoalAnalysisFullEntity entity = ConvertUtils.sourceToTarget(dto, CoalAnalysisFullEntity.class);
        entity.setUpdateDate(new Date());
        updateById(entity);
 
        List<CoalAnalysisFullDetDTO> detList = dto.getDetList();
//        if (!CollectionUtils.isEmpty(detList)) {
//            detList.forEach(item -> {
//                item.setFullId(entity.getId());
//            });
//            coalAnalysisFullDetService.updateList(detList);
//        }
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(String[] ids) {
        baseDao.deleteByIds(Arrays.asList(ids));
//        Arrays.asList(ids).forEach(item -> {
//            coalAnalysisFullDetService.deleteByFullId(item);
//        });
    }
 
    @Override
    public Long cheack(CoalAnalysisFullDTO dto) {
        String id = dto.getId();
        String code = dto.getCode();
 
        QueryWrapper<CoalAnalysisFullEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne(StringUtils.isNotBlank(id), "id", id);
        queryWrapper.and(wrapper -> wrapper.eq("code", code));
        return baseDao.selectCount(queryWrapper);
    }
}