选煤厂生产管理平台后台代码
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.iailab.module.pms.coalquality.modules.analysis.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.constant.Constant;
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.framework.tenant.core.aop.TenantIgnore;
import com.iailab.module.pms.coalquality.modules.analysis.dao.CoalWashCurvesDao;
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDTO;
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDetDTO;
import com.iailab.module.pms.coalquality.modules.analysis.entity.CoalWashCurvesEntity;
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesDetService;
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesService;
import com.iailab.module.pms.coalquality.modules.analysis.vo.WashCurvesPageReqVO;
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 org.springframework.util.CollectionUtils;
 
import java.text.DecimalFormat;
import java.util.*;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2023年01月16日 15:58:00
 */
@Service
public class CoalWashCurvesServiceImpl extends BaseServiceImpl<CoalWashCurvesDao, CoalWashCurvesEntity>
        implements CoalWashCurvesService {
    @Autowired
    private CoalWashCurvesDetService coalWashCurvesDetService;
 
    private DecimalFormat df = new DecimalFormat("00");
 
    private String BUSINESS_CODE = "CoalWashCurves";
 
    @Override
    @TenantIgnore
    public PageResult<CoalWashCurvesDTO> page(WashCurvesPageReqVO washCurvesPageReqVO) {
        PageResult<CoalWashCurvesEntity> page = baseDao.selectPage(washCurvesPageReqVO);
 
        return BeanUtils.toBean(page, CoalWashCurvesDTO.class);
    }
 
    @Override
    public CoalWashCurvesDTO get(String id) {
        CoalWashCurvesEntity entity = baseDao.selectById(id);
        CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
        Map<String, Object> parmas = new HashMap<>(1);
        parmas.put("curvesId", dto.getId());
        List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
        dto.setDetList(detList);
        return dto;
    }
 
    @Override
    public CoalWashCurvesDTO getLastByMz(String mz) {
//        if (StringUtils.isBlank(mz)) {
//            return new CoalWashCurvesDTO();
//        }
        QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz).orderByDesc(Constant.CREATE_DATE).last("limit 0, 1");
        List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper);
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
 
        CoalWashCurvesEntity entity = list.get(0);
        CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
        Map<String, Object> parmas = new HashMap<>(1);
        parmas.put("curvesId", dto.getId());
        List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
        dto.setDetList(detList);
        return dto;
    }
 
    @Override
    public CoalWashCurvesDTO getByMzAndRq(String mz, String syrq) {
//        if (StringUtils.isBlank(mz)) {
//            return new CoalWashCurvesDTO();
//        }
        QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz)
                .eq(StringUtils.isNotBlank(syrq),"syrq",syrq);
        List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper);
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
 
        CoalWashCurvesEntity entity = list.get(0);
        CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
        Map<String, Object> parmas = new HashMap<>(1);
        parmas.put("curvesId", dto.getId());
        List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
        dto.setDetList(detList);
        return dto;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(CoalWashCurvesDTO dto) {
//        String a = serialNumUtils.getByBusiness( BUSINESS_CODE,4);
        dto.setCode(dto.getNy().replace("-", "") );
        CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class);
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateDate(new Date());
//        entity.setCreator(SecurityUser.getUserId().toString());
        insert(entity);
 
        List<CoalWashCurvesDetDTO> 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).setCurvesId(entity.getId());
//            }
//            coalWashCurvesDetService.saveList(detList);
//        }
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(CoalWashCurvesDTO dto) {
        CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class);
        entity.setUpdateDate(new Date());
//        entity.setUpdater(SecurityUser.getUserId().toString());
        updateById(entity);
 
        List<CoalWashCurvesDetDTO> detList = dto.getDetList();
//        if (!CollectionUtils.isEmpty(detList)) {
//            detList.forEach(item -> {
//                item.setCurvesId(entity.getId());
//            });
//            coalWashCurvesDetService.updateList(detList);
//        }
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(String[] ids) {
        baseDao.deleteByIds(Arrays.asList(ids));
//        coalWashCurvesDetService.deleteByCurvesIds(Arrays.asList(ids));
    }
 
}