fxl
2023-05-04 e150655a785de36a65a26a0dc4d3d6d65fe7e9d0
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package com.hxzkoa.controller;
 
import com.hxzkoa.json.R;
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.services.BasicInfoService;
import com.hxzkoa.services.HelmetService;
import com.hxzkoa.services.LabelService;
import com.hxzkoa.services.SysSettingService;
import com.hxzkoa.tools.SocketUtil;
import com.hxzkoa.util.Config;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
 
@Controller
public class HelmetController {
    @Autowired
    HelmetService helmetService;
    @Autowired
    SysSettingService sysSettingService;
    @Autowired
    LabelService labelservice;
    @Autowired
    BasicInfoService basicInfoService;
 
    public HelmetController() {
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"warning.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public R warning(HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        switch (request.getParameter("type")) {
            case "offhat":
                this.helmetService.offhat(tagid, "1");
                break;
            case "smash":
                this.helmetService.smash(tagid, "1");
                break;
            case "stopmoving":
                this.helmetService.stopmoving(tagid, "1");
                break;
            case "high":
                this.helmetService.high(tagid, "1");
                break;
            case "nearele":
                this.helmetService.nearele(tagid, "1");
        }
 
        return R.ok();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"video.do"},
            method = {RequestMethod.POST}
    )
    public R video(MultipartFile file, HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        File filen = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\video\\" + tagid + "." + file.getContentType().split("/")[1]);
        if (!file.isEmpty()) {
            try {
                file.transferTo(filen);
                this.helmetService.video(tagid, tagid + "." + file.getContentType().split("/")[1]);
                return R.ok();
            } catch (IOException var6) {
                throw new RuntimeException(var6);
            }
        } else {
            return R.error("文件不能为空");
        }
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"audio.do"},
            method = {RequestMethod.POST}
    )
    public R audio(MultipartFile file, HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        File filen = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\audio\\" + tagid + "." + file.getContentType().split("/")[1]);
        if (!file.isEmpty()) {
            try {
                file.transferTo(filen);
                this.helmetService.audio(tagid, tagid + "." + file.getContentType().split("/")[1]);
                return R.ok();
            } catch (IOException var6) {
                throw new RuntimeException(var6);
            }
        } else {
            return R.error("文件不能为空");
        }
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"image.do"},
            method = {RequestMethod.POST}
    )
    public R image(MultipartFile file, HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        File filen = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\image\\" + tagid + "." + file.getContentType().split("/")[1]);
        if (!file.isEmpty()) {
            try {
                file.transferTo(filen);
                this.helmetService.image(tagid, tagid + "." + file.getContentType().split("/")[1]);
                return R.ok();
            } catch (IOException var6) {
                throw new RuntimeException(var6);
            }
        } else {
            return R.error("文件不能为空");
        }
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"setgps.do"},
            method = {RequestMethod.POST}
    )
    public R setgps(HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        String lon = request.getParameter("lon");
        String lat = request.getParameter("lat");
        this.helmetService.setgps(tagid, lon, lat);
        return R.ok();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"sendmsg.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public R sendmsg(HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        String message = request.getParameter("message");
        message = tagid + ":" + message;
        (new SocketUtil()).sendmsg(message);
        return R.ok();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"addtagid.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public R addtagid(HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        List<tb_tag> tag = this.labelservice.searchLabelManagement(tagid);
        if (tag.size() == 0) {
            tb_tag taga = new tb_tag();
            taga.setTag_id(tagid);
            taga.setState(request.getParameter("name"));
            taga.setGaodu("150");
            taga.setSudu("1000");
            taga.setPinglv("1");
            taga.setVersion(Config.getVersion());
            this.labelservice.labelManagement_add(taga);
            tb_person person = new tb_person();
            person.setP_tagid(taga.getTag_id());
            person.setP_name(taga.getState());
            person.setP_power("100");
            person.setP_sex("男");
            person.setP_minzu("汉");
            person.setP_phone("131******88");
            person.setP_department("系统默认");
            person.setP_x("0");
            person.setP_y("0");
            person.setP_floor("0");
            person.setP_sos("0");
            person.setP_online("0");
            person.setP_kaoqing("0");
            person.setP_fence("0");
            person.setP_image("image/targeticon/default.png");
            this.basicInfoService.personManagement_add(person);
        }
 
        return R.ok();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"playstop.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public R playstop(HttpServletRequest request) {
        String tagid = request.getParameter("tagid");
        String type = request.getParameter("type");
        String filename = this.helmetService.removefile(tagid, type);
        File file;
        if (type.equals("baoliu30")) {
            file = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\video\\" + filename);
            file.delete();
        } else {
            file = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\audio\\" + filename);
            file.delete();
        }
 
        this.helmetService.guanbi(tagid, type);
        return R.ok();
    }
}