sfd
2025-05-23 b60b39fc30384a1fa75765e8e10f9ad3bffe9480
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
package com.aps.core.service.impl;
 
import cn.hutool.core.util.IdUtil;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.poi.ExcelUtil;
import com.aps.common.security.utils.DictUtils;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.ApsGasPipelineMo;
import com.aps.core.mapper.ApsGasPipelineMoMapper;
import com.aps.core.service.IApsGasPipelineMoService;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
/**
 * 管路手工气体工单数据Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-19
 */
@Service
public class ApsGasPipelineMoServiceImpl implements IApsGasPipelineMoService {
    @Autowired
    private ApsGasPipelineMoMapper apsGasPipelineMoMapper;
 
    /**
     * 查询管路手工气体工单数据
     *
     * @param id 管路手工气体工单数据主键
     * @return 管路手工气体工单数据
     */
    @Override
    public ApsGasPipelineMo selectApsGasPipelineMoById(Long id) {
        return apsGasPipelineMoMapper.selectApsGasPipelineMoById(id);
    }
 
    /**
     * 查询管路手工气体工单数据列表
     *
     * @param apsGasPipelineMo 管路手工气体工单数据
     * @return 管路手工气体工单数据
     */
    @Override
    public List<ApsGasPipelineMo> selectApsGasPipelineMoList(ApsGasPipelineMo apsGasPipelineMo) {
        return apsGasPipelineMoMapper.selectApsGasPipelineMoList(apsGasPipelineMo);
    }
 
    /**
     * 新增管路手工气体工单数据
     *
     * @param apsGasPipelineMo 管路手工气体工单数据
     * @return 结果
     */
    @Override
    public int insertApsGasPipelineMo(ApsGasPipelineMo apsGasPipelineMo) {
        apsGasPipelineMo.setCreateTime(DateUtils.getNowDate());
        apsGasPipelineMo.setId(IdUtil.getSnowflakeNextId());
        apsGasPipelineMo.setCreateBy(SecurityUtils.getUsername());
        return apsGasPipelineMoMapper.insertApsGasPipelineMo(apsGasPipelineMo);
    }
 
    /**
     * 修改管路手工气体工单数据
     *
     * @param apsGasPipelineMo 管路手工气体工单数据
     * @return 结果
     */
    @Override
    public int updateApsGasPipelineMo(ApsGasPipelineMo apsGasPipelineMo) {
        apsGasPipelineMo.setUpdateTime(DateUtils.getNowDate());
        return apsGasPipelineMoMapper.updateApsGasPipelineMo(apsGasPipelineMo);
    }
 
    /**
     * 批量删除管路手工气体工单数据
     *
     * @param ids 需要删除的管路手工气体工单数据主键
     * @return 结果
     */
    @Override
    public int deleteApsGasPipelineMoByIds(Long[] ids) {
        return apsGasPipelineMoMapper.deleteApsGasPipelineMoByIds(ids);
    }
 
    /**
     * 删除管路手工气体工单数据信息
     *
     * @param id 管路手工气体工单数据主键
     * @return 结果
     */
    @Override
    public int deleteApsGasPipelineMoById(Long id) {
        return apsGasPipelineMoMapper.deleteApsGasPipelineMoById(id);
    }
 
    @SneakyThrows
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int batchInsertGasPipelineMo(MultipartFile file) {
 
        ExcelUtil<ApsGasPipelineMo> util = new ExcelUtil<>(ApsGasPipelineMo.class);
        List<ApsGasPipelineMo> tempList = util.importExcel(file.getInputStream());
        DictUtils.CacheValue cacheValue = DictUtils.getCacheValue("aps_factory");
        tempList.forEach(apsGasPipelineMo -> {
            apsGasPipelineMo.setId(IdUtil.getSnowflakeNextId());
            apsGasPipelineMo.setFactory(cacheValue.get(apsGasPipelineMo.getFactory()));
            apsGasPipelineMo.setCreateBy(SecurityUtils.getUsername());
            apsGasPipelineMo.setCreateTime(DateUtils.getNowDate());
        });
 
        if (!tempList.isEmpty()) {
            apsGasPipelineMoMapper.deleteAll();
            apsGasPipelineMoMapper.insert(tempList);
        }
        return tempList.size();
    }
}