zhitong.yu
2024-03-15 ebd89b9ffa8980ac944a7e79ecc64c01637d4f17
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.TbAchor;
import com.hxzk.pojo.TbSystemOperationLog;
import com.hxzk.pojo.TbTag;
import com.hxzk.pojo.TbWarning;
import com.hxzk.service.TagService;
import com.hxzk.service.WarningService;
import com.hxzk.udp.Udp_Out;
import com.hxzk.util.GetTime;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping("/")
public class WarningController {
    @Autowired
    WarningService warningService;
    //查询所有标签设备信息
    @GetMapping("findwarning")
    result<List<com.hxzk.deo.TbWarning>> findwarning(Integer page, Integer limit){
        PageInfo<com.hxzk.deo.TbWarning> cz= warningService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping("findwarningHouTai")
    result<List<com.hxzk.deo.TbWarning>> findwarningHouTai(Integer page, Integer limit){
        PageInfo<com.hxzk.deo.TbWarning> cz= warningService.findAllHouTai(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping("findwarningDaPing")
    result<List<com.hxzk.deo.TbWarning>> findwarningDaPing(Integer page, Integer limit){
        PageInfo<com.hxzk.deo.TbWarning> cz= warningService.findAllStatus(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    //表格搜索
    @GetMapping("findwarningSearch")
    result<List<com.hxzk.deo.TbWarning>> findwarningSearch(Integer page, Integer limit,TbWarning warning){
        PageInfo<com.hxzk.deo.TbWarning> cz= warningService.findwarningSearch(page, limit,warning);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    //表格搜索
    @GetMapping("findwarningSearchHouTai")
    result<List<com.hxzk.deo.TbWarning>> findwarningSearchHouTai(Integer page, Integer limit,TbWarning warning){
        PageInfo<com.hxzk.deo.TbWarning> cz= warningService.findwarningSearchHouTai(page, limit,warning);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    //表格筛选
    @GetMapping("findwarningScreen")
    result<List<TbWarning>> findwarningScreen(Integer page, Integer limit, TbWarning warning, HttpServletRequest request){
        String param0 = request.getParameter("param0");
        String param1 = request.getParameter("param1");
        String param2 = request.getParameter("param2");
        String param3 = request.getParameter("param3");
        if(param3 == null){
            warning.setType(param0+param1+param2);
        }else{
            warning.setType(param0+param1+param2+param3);
        }
        PageInfo<TbWarning> cz= warningService.findwarningScreen(page, limit,warning);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    //单独处理告警
    @PostMapping("DellWarning")
    public void deletegaojing(TbWarning warning, String ids, HttpServletResponse response) throws IOException {
        warning.setBaoliu4(GetTime.getTime());
        warning.setStatus("已处理");
        String[] ids1 = ids.split(",");
        for (int i =0; i < ids1.length;i++){
            warningService.ChuliWarning(warning,ids1[i]);
            TbWarning  warning1 = warningService.findtagidWarning(ids1[i]);
            TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
            systemOperationLog.setName(UserController.username);
            systemOperationLog.setTime(gettime());
            systemOperationLog.setContent("在后台处理了一条告警数据,该数据设备ID是:"+warning.getObjectid()+",类型是:"+warning.getType());
            String xieyi = "BSTOCS1,DELLWARN," +warning1.getObjectid()+","+warning1.getType()+",END";
            Udp_Out.udp_to_cs(xieyi);
        }
        response.sendRedirect("/hxzkuwb/HouTai/GaoJingHuiZong/GaoJingHuiZong.jsp");
    }
 
    //首页大屏单独处理告警
    @PostMapping("DaPingDellWarning")
    public void deletegaojing(TbWarning warning,String username) throws IOException {
        warning.setBaoliu4(GetTime.getTime());
        warning.setBaoliu3(username);
        warning.setStatus("已处理");
        String xieyi = "BSTOCS1,DELLWARN," +warning.getId()+","+warning.getType()+",END";
        TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
        systemOperationLog.setName(UserController.username);
        systemOperationLog.setTime(gettime());
        systemOperationLog.setContent("在大屏处理了一条告警数据,该数据设备ID是:"+warning.getObjectid()+",类型是:"+warning.getType());
        Udp_Out.udp_to_cs(xieyi);
        warningService.DaPingChuliWarning(warning);
    }
    @GetMapping("WarningCaoZuo")
    public void WarningCaoZuo(TbWarning warning){
        String xieyi = "BSTOCS1,DELLWARN," + warning.getObjectid() + ","+warning.getType()+",END";
        TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
        systemOperationLog.setName(UserController.username);
        systemOperationLog.setTime(gettime());
        systemOperationLog.setContent("在后台处理了一条告警数据,该数据设备ID是:"+warning.getObjectid()+",类型是:"+warning.getType());
        Udp_Out.udp_to_cs(xieyi);
    }
    //全部处理告警
    @PostMapping("WarningChuLiAll")
    public void deleteALLgaojing(TbWarning warning,HttpServletResponse response) throws IOException {
        String xieyi = "BSTOCS1,DELLWARNALL,"+warning.getType()+",END";
        TbWarning warning1 = new TbWarning();
        warning1.setStatus("已处理");
        warning1.setType(warning.getType());
        warning1.setBaoliu3(UserController.username);
        warning1.setBaoliu4(gettime());
        warning1.setBaoliu6(warning.getBaoliu6());
        warning1.setBaoliu5(warning.getBaoliu5());
        warningService.UpAllWarning(warning1);
        TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
        systemOperationLog.setName(UserController.username);
        systemOperationLog.setTime(gettime());
        systemOperationLog.setContent("成功把"+warning.getType()+"消息全部处理");
        Udp_Out.udp_to_cs(xieyi);
        response.sendRedirect("/hxzkuwb/HouTai/GaoJingHuiZong/GaoJingHuiZong.jsp");
    }
 
    //大屏告警信息数据查询
    @GetMapping("findDaPingGaojing")
    public List<com.hxzk.deo.TbWarning> findDaPingGaoJing(){
        return warningService.findDaPingGaoJing();
    }
    //大屏今日未处理总数
    @GetMapping("findDapingWeiChuLiCount")
    public Integer findDaPingWeiChuLiCount(){
        return warningService.findDaPingWeiChuLiCount();
    }
 
    //根据ID获取详细信息
    @GetMapping("findIdXiangXi")
    public TbWarning findIdXiangXi(Integer id){
        return warningService.findIdXiangXi(id);
    }
 
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
 
    @GetMapping("findIDWarning")
    public TbWarning findIdWarning(Integer id){
        return warningService.findIdWarning(id);
    }
 
 
    @GetMapping("updateIDWarning")
    public void updateIDWarning(Integer id){
        warningService.updateIDWarning(id);
    }
}