111
fei.wang
2025-04-18 a6686570ac48648e2bf2ec93d27272a4473cac08
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
package com.hxzkappboot.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.hxzkappboot.pojo.TbPersonAndDepartment;
import com.hxzkappboot.pojo.TbWarning;
import com.hxzkappboot.service.TbPersonService;
import com.hxzkappboot.service.TbWarningService;
import com.hxzkappboot.udp.Udp_Out;
import com.hxzkappboot.util.R;
import com.hxzkappboot.util.StatusCode;
import com.hxzkappboot.util.result;
import com.hxzkappboot.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangfei
 * @since 2024-03-08
 */
@RestController
//@RequestMapping("/")
public class TbWarningController {
 
    @Autowired
    TbWarningService tbWarningService;
 
    @GetMapping("/api/wx/findwarning")
    public R findAll(Page page,  String objectid,String company,String juese) {
        R response;
        List<TbWarning> ipage = tbWarningService.findAll(page,objectid,company,juese);
        response = new R(StatusCode.Success);
        response.setData(ipage);
        return response;
    }
 
    @GetMapping("/api/wx/findWarningNum")
    public R findWarningNum(String company ) {
        R response;
        try {
            response = new R(StatusCode.Success);
            response.setData(tbWarningService.findWarningNum(company));
        } catch (Exception e) {
            response = new R(StatusCode.Fail.getCode(), e.getMessage());
        }
        return response;
    }
 
    @PostMapping("/api/wx/processingWarn")
    public R processingWarn(@Valid @RequestBody TbWarning warning) {
//        R response ;
//        response = new R(StatusCode.Success);
 
//        return response;
        String xieyi = "BSTOCS1,DELLWARN," +warning.getTagid()+","+warning.getWarntype()+",END";
//        String xieyi = "BSTOCS1,DELETEFENCE," + name + ",END";
        Udp_Out.udp_to_cs(xieyi);
 
        try {
            Thread.sleep(1000);
 
        }catch (InterruptedException e){
            Thread.currentThread().interrupt();
//            logUtil.error("线程中断"+e.getMessage());
        }
        R response ;
        response = new R(StatusCode.Success);
        TbWarning gpsList =tbWarningService.processingWarn(warning);
        response.setData(gpsList);
//        List<TbFence> fenceList = new ArrayList();
//        System.out.println(name);
//        fenceList = tbFenceService.earlyWarning();
//        TbWarning tbWarning =  tbWarningService.findWarningid(warning.getId());
 
//        response.setData(tbWarning);
        return response;
    }
 
    @GetMapping("/api/wx/delewarn")
    public void delewarn(String warningId,String addperson,String perCompany) {
        String time = this.gettime();
//        BSTOCS1,WARNING,DELETE,warningId,delPerson,perCompany,time,END
        String xieyi = "BSTOCS1,WARNING,DELETE," + warningId +","+ addperson +","+ perCompany +","+ time+ ",END";
        Udp_Out.udp_to_cs(xieyi);
    }
 
//    @PostMapping("/api/wx/moreprocessingWarn")
//    public R moreprocessingWarn(@Valid @RequestBody TbWarning warning) {
////        R response ;
////        response = new R(StatusCode.Success);
////        TbWarning gpsList =tbWarningService.processingWarn(warning);
////        response.setData(gpsList);
////        return response;
//        for (int i = 0; i < warning.getIds().size(); i++) {
//            TbWarning tbWarning =  tbWarningService.findWarningid(warning.getIds().get(i));
//            String xieyi = "BSTOCS1,DELLWARN," +tbWarning.getTagid()+","+tbWarning.getWarntype()+",END";
////        String xieyi = "BSTOCS1,DELETEFENCE," + name + ",END";
//            Udp_Out.udp_to_cs(xieyi);
//        }
//
//        R response ;
////        List<TbFence> fenceList = new ArrayList();
////        System.out.println(name);
////        fenceList = tbFenceService.earlyWarning();
//        response = new R(StatusCode.Success);
////        response.setData(fenceList);
//        return response;
//    }
 
    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;
    }
 
}