fei.wang
2025-04-18 321a74059773cfecc01d6313f7c2e2d45545d6d3
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
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.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) {
        R response;
        List<TbWarning> ipage = tbWarningService.findAll(page,objectid,company);
        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.getObjectid()+","+warning.getType()+",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;
    }
 
    @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.getObjectid()+","+tbWarning.getType()+",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;
    }
 
 
}