zhitong.yu
7 天以前 7fc9c42987a13c1d8d2159591a5803e70518827f
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
package com.hxzk.gps.service.impl.Warning;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxzk.gps.controller.System.SystemLogUtil;
import com.hxzk.gps.controller.Warning.dto.TableSearchResult.TableSearchResult;
 
import com.hxzk.gps.entity.Warning.TbWarning;
import com.hxzk.gps.mapper.Company.TbCompanyMapper;
import com.hxzk.gps.mapper.Warning.TbWarningMapper;
import com.hxzk.gps.result.ListDataResult;
import com.hxzk.gps.result.ResultTable;
import com.hxzk.gps.result.table;
import com.hxzk.gps.service.Company.TbCompanyService;
import com.hxzk.gps.service.Warning.TbWarningService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzk.gps.util.GetUser.UserInfoUtil;
import com.hxzk.gps.util.MessageUtils.MessageUtils;
import com.hxzk.gps.util.Result.ReturnMessage;
 
 
 
import com.hxzk.gps.util.Time.TimeUtil;
import com.hxzk.gps.util.UDP.UDP_Warning;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Optional;
 
/**
 * <p>
 *  服务实现类
 *  告警管理
 * </p>
 *
 * @author YuZhiTong
 * @since 2025-05-23
 */
@Service
public class TbWarningServiceImpl extends ServiceImpl<TbWarningMapper, TbWarning> implements TbWarningService {
 
    @Autowired
    TbCompanyService companyService;
    @Autowired
    TbWarningMapper warningMapper;
 
    @Override
    public ResultTable FindWarningInfo(TableSearchResult TableSearchResult) {
        PageHelper.startPage(TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize());
        PageInfo<TbWarning> info = new PageInfo<>(warningMapper.FindWarningInfo(UserInfoUtil.getUserCompany(),TableSearchResult.getWarning().getObjectid(),TableSearchResult.getWarning().getBaoliu10(),TableSearchResult.getWarning().getType()));
        table<TbWarning> achortable = new table<>(info.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),info.getTotal());
        return ListDataResult.resultTableSuccess(achortable, MessageUtils.getMessage("Success"));
    }
 
    @Override
    public ResultTable FindWarningUntreated(TableSearchResult TableSearchResult) {
        PageHelper.startPage(TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize());
        List<Long> list = companyService.getChildCompanyIds(UserInfoUtil.getUserCompanyId());
        PageInfo<TbWarning> info = new PageInfo<>(warningMapper.FindWarningUntreated(list,MessageUtils.getMessage("UnHandle")));
        table<TbWarning> achortable = new table<>(info.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),info.getTotal());
        return ListDataResult.resultTableSuccess(achortable, MessageUtils.getMessage("Success"));
    }
 
    @Override
    public ReturnMessage AllHandle() {
        /*
        声明操作状态
        * */
        boolean isSuccess = false;
        QueryWrapper queryWrapper = new QueryWrapper<>();
        try {
             /*
            发送指令到CS
            * */
            UDP_Warning.AllHandle();
            TbWarning tbWarning = new TbWarning();
            tbWarning.setStatus(MessageUtils.getMessage("Handle"));
            baseMapper.update(tbWarning,queryWrapper);
            isSuccess = true;
        }catch (Exception e){
 
        }
        return SystemLogUtil.handleUpdateResult(isSuccess,"HandleWarning",MessageUtils.getMessage("ALL"));
    }
 
    @Override
    public ReturnMessage Handle(TbWarning warning) {
       /*
        声明操作状态
        * */
        boolean isSuccess = false;
        try {
             /*
            发送指令到CS
            * */
            UDP_Warning.Handle(warning);
            QueryWrapper queryWrapper =new QueryWrapper<>();
            queryWrapper.eq("id",warning.getId());
            warning.setStatus(MessageUtils.getMessage("Handle"));
            warning.setBaoliu6(TimeUtil.GetTime());
            warning.setBaoliu5(UserInfoUtil.getUserName());
            baseMapper.update(warning,queryWrapper);
            isSuccess = true;
        }catch (Exception e){
 
        }
        return SystemLogUtil.handleUpdateResult(isSuccess,"HandleWarning",warning.getObjectid());
    }
}