TPipeServiceImpl.java 4.46 KB
Newer Older
1 2
package com.zehong.system.service.impl;

3 4
import com.github.pagehelper.PageInfo;
import com.zehong.common.utils.PageInfoUtil;
5
import com.zehong.system.domain.TDeviceInfo;
6
import com.zehong.system.domain.TPipe;
7 8
import com.zehong.system.domain.vo.PipeVo;
import com.zehong.system.mapper.TDeviceInfoMapper;
9 10
import com.zehong.system.mapper.TPipeMapper;
import com.zehong.system.service.ITPipeService;
11
import org.springframework.beans.BeanUtils;
12 13
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
14 15 16

import java.util.ArrayList;
import java.util.List;
17 18 19 20 21 22 23 24 25 26 27 28

/**
 * 管道信息Service业务层处理
 * 
 * @author zehong
 * @date 2021-07-08
 */
@Service
public class TPipeServiceImpl implements ITPipeService 
{
    @Autowired
    private TPipeMapper tPipeMapper;
29
    @Autowired
30
    private TDeviceInfoMapper tDeviceInfoMapper;
31 32 33 34 35 36 37
    /**
     * 查询管道信息
     * 
     * @param pipeId 管道信息ID
     * @return 管道信息
     */
    @Override
38
    public PipeVo selectTPipeById(int pipeId)
39
    {
40
        PipeVo pipeVo = new PipeVo();
41
        TPipe tPipe = tPipeMapper.selectTPipeById(pipeId);
42 43 44 45 46
        BeanUtils.copyProperties(tPipe, pipeVo);

        List<TDeviceInfo> deviceInfoList = tDeviceInfoMapper.selectTDeviceInfoByPipeId(tPipe.getPipeId());
        if(deviceInfoList.size() != 0) {
            pipeVo.setDeviceInfoList(deviceInfoList);
47
        }
48 49

        return pipeVo;
50 51 52 53 54 55 56 57 58
    }

    /**
     * 查询管道信息列表
     * 
     * @param tPipe 管道信息
     * @return 管道信息
     */
    @Override
59
    public List<PipeVo> selectTPipeList(TPipe tPipe)
60
    {
61
        List<PipeVo> list = new ArrayList<>();
62 63 64 65 66
        List<TPipe> tPipeList = tPipeMapper.selectTPipeList(tPipe);

        if(tPipeList.size() != 0){

            for(TPipe pipe : tPipeList){
67 68
                PipeVo pipeVo = new PipeVo();
                BeanUtils.copyProperties(pipe, pipeVo);
69

70 71 72
                List<TDeviceInfo> deviceInfoList = tDeviceInfoMapper.selectTDeviceInfoByPipeId(pipe.getPipeId());
                if(deviceInfoList.size() != 0) {
                    pipeVo.setDeviceInfoList(deviceInfoList);
73 74
                }

75
                list.add(pipeVo);
76 77
            }
        }
78
        return list;
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
    /**
     * 查询管道信息列表
     *
     * @param tPipe 管道信息
     * @return 管道信息
     */
    @Override
    public PageInfo<PipeVo> selectTPipePage(TPipe tPipe)
    {
        List<PipeVo> list = new ArrayList<>();
        List<TPipe> tPipeList = tPipeMapper.selectTPipeList(tPipe);
        PageInfo<PipeVo> pageVo = PageInfoUtil.pageInfo2PageInfoDTO(new PageInfo(tPipeList),PipeVo.class);
        if(pageVo.getList().size() != 0){
            for(PipeVo pipe : pageVo.getList()){
                List<TDeviceInfo> deviceInfoList = tDeviceInfoMapper.selectTDeviceInfoByPipeId(pipe.getPipeId());
                if(deviceInfoList.size() != 0) {
                    pipe.setDeviceInfoList(deviceInfoList);
                }
            }
        }
        return pageVo;
    }

104 105 106 107 108
    /**
     * 统计管道总长度
     * @return
     */
    @Override
109
    public double countPipeLength() {
110 111 112
        return tPipeMapper.countPipeLength();
    };

113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    /**
     * 新增管道信息
     * 
     * @param tPipe 管道信息
     * @return 结果
     */
    @Override
    public int insertTPipe(TPipe tPipe)
    {
        return tPipeMapper.insertTPipe(tPipe);
    }

    /**
     * 修改管道信息
     * 
     * @param tPipe 管道信息
     * @return 结果
     */
    @Override
    public int updateTPipe(TPipe tPipe)
    {
134 135 136 137 138 139 140 141 142 143
        if("1".equals(tPipe.getIsDel())){
            List<TDeviceInfo> tDeviceInfoList = tDeviceInfoMapper.selectTDeviceInfoByPipeId(tPipe.getPipeId());

            if(tDeviceInfoList.size() != 0) {
                for (TDeviceInfo device : tDeviceInfoList) {
                    device.setIsDel("1");
                    tDeviceInfoMapper.updateTDeviceInfo(device);
                }
            }
        }
144 145 146 147 148 149 150 151 152 153
        return tPipeMapper.updateTPipe(tPipe);
    }

    /**
     * 批量删除管道信息
     * 
     * @param pipeIds 需要删除的管道信息ID
     * @return 结果
     */
    @Override
154
    public int deleteTPipeByIds(int[] pipeIds)
155 156 157 158 159 160 161 162 163 164 165
    {
        return tPipeMapper.deleteTPipeByIds(pipeIds);
    }

    /**
     * 删除管道信息信息
     * 
     * @param pipeId 管道信息ID
     * @return 结果
     */
    @Override
166
    public int deleteTPipeById(int pipeId)
167 168 169 170
    {
        return tPipeMapper.deleteTPipeById(pipeId);
    }
}