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

3
import java.util.ArrayList;
4
import java.util.List;
5 6 7

import com.zehong.common.core.domain.entity.SysDictData;
import com.zehong.common.utils.StringUtils;
8 9 10
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.vo.PipeVo;
import com.zehong.system.mapper.TDeviceInfoMapper;
11
import com.zehong.system.service.ISysDictTypeService;
12
import org.springframework.beans.BeanUtils;
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TPipeMapper;
import com.zehong.system.domain.TPipe;
import com.zehong.system.service.ITPipeService;

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

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

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

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

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

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

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

76
                list.add(pipeVo);
77 78
            }
        }
79
        return list;
80 81
    }

82 83 84 85 86
    /**
     * 统计管道总长度
     * @return
     */
    @Override
87
    public double countPipeLength() {
88 89 90
        return tPipeMapper.countPipeLength();
    };

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    /**
     * 新增管道信息
     * 
     * @param tPipe 管道信息
     * @return 结果
     */
    @Override
    public int insertTPipe(TPipe tPipe)
    {
        return tPipeMapper.insertTPipe(tPipe);
    }

    /**
     * 修改管道信息
     * 
     * @param tPipe 管道信息
     * @return 结果
     */
    @Override
    public int updateTPipe(TPipe tPipe)
    {
112 113 114 115 116 117 118 119 120 121
        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);
                }
            }
        }
122 123 124 125 126 127 128 129 130 131
        return tPipeMapper.updateTPipe(tPipe);
    }

    /**
     * 批量删除管道信息
     * 
     * @param pipeIds 需要删除的管道信息ID
     * @return 结果
     */
    @Override
132
    public int deleteTPipeByIds(int[] pipeIds)
133 134 135 136 137 138 139 140 141 142 143
    {
        return tPipeMapper.deleteTPipeByIds(pipeIds);
    }

    /**
     * 删除管道信息信息
     * 
     * @param pipeId 管道信息ID
     * @return 结果
     */
    @Override
144
    public int deleteTPipeById(int pipeId)
145 146 147 148
    {
        return tPipeMapper.deleteTPipeById(pipeId);
    }
}