fuliqi
2024-08-01 82137fdbb4fc7d990b6f4d91f33ca80becad4545
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
package com.ycl.platform.service.impl;
 
import annotation.DataScope;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.platform.domain.entity.TMonitor;
import com.ycl.platform.domain.vo.TMonitorVO;
import com.ycl.platform.mapper.TMonitorMapper;
import com.ycl.platform.service.ITMonitorService;
import com.ycl.system.service.ISysConfigService;
import com.ycl.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
import java.util.Objects;
 
/**
 * 设备资产Service业务层处理
 *
 * @author ruoyi
 * @date 2024-03-04
 */
@Service
public class TMonitorServiceImpl extends ServiceImpl<TMonitorMapper, TMonitor> implements ITMonitorService
{
    @Autowired
    private TMonitorMapper tMonitorMapper;
    @Autowired
    private ISysConfigService configService;
 
    /**
     * 查询设备资产
     *
     * @param id 设备资产主键
     * @return 设备资产
     */
    @Override
    public TMonitor selectTMonitorById(Long id)
    {
        return tMonitorMapper.selectTMonitorById(id);
    }
 
    /**
     * 查询设备资产列表
     *
     * @param tMonitor 设备资产
     * @return 设备资产
     */
    @Override
    @DataScope(deptAlias = "d",userAlias = "u")
    public List<TMonitorVO> selectTMonitorList(TMonitor tMonitor)
    {
        List<TMonitorVO> monitors = tMonitorMapper.selectTMonitorList(tMonitor);
        if (Objects.equals(tMonitor.getRecovery(), 1)) {
            String time = configService.selectConfigByKey("abnormal.equipment.continuous.attention.time");
            if (StringUtils.isBlank(time)) {
                throw new RuntimeException("请配置异常设备连续关注时间");
            }
            List<TMonitorVO> recoveryMonitors = tMonitorMapper.selectRecoveryMonitor(time);
            monitors.addAll(recoveryMonitors);
        }
        return monitors;
    }
 
    /**
     * 新增设备资产
     *
     * @param tMonitor 设备资产
     * @return 结果
     */
    @Override
    public int insertTMonitor(TMonitor tMonitor)
    {
        return tMonitorMapper.insertTMonitor(tMonitor);
    }
 
    /**
     * 修改设备资产
     *
     * @param tMonitor 设备资产
     * @return 结果
     */
    @Override
    public int updateTMonitor(TMonitor tMonitor)
    {
        return tMonitorMapper.updateTMonitor(tMonitor);
    }
 
    /**
     * 批量删除设备资产
     *
     * @param ids 需要删除的设备资产主键
     * @return 结果
     */
    @Override
    public int deleteTMonitorByIds(Long[] ids)
    {
        return tMonitorMapper.deleteTMonitorByIds(ids);
    }
 
    /**
     * 删除设备资产信息
     *
     * @param id 设备资产主键
     * @return 结果
     */
    @Override
    public int deleteTMonitorById(Long id)
    {
        return tMonitorMapper.deleteTMonitorById(id);
    }
 
    @Override
    @DataScope(deptAlias = "d",userAlias = "u")
    public Map<String, String> getVideoCount(TMonitor tMonitor) {
        return tMonitorMapper.getVideoCount(tMonitor);
    }
 
    @Override
    public Map<String, String> recoveryException() {
        String time = configService.selectConfigByKey("abnormal.equipment.continuous.attention.time");
        return tMonitorMapper.recoveryException(time);
    }
}