15832144755
2021-08-27 3516f02277035cdc7ff137422709b16efe97ca4a
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
package com.hxzkoa.controller;
 
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 com.hxzkoa.json.tb_collector;
import com.hxzkoa.json.tb_gas;
import com.hxzkoa.json.tb_gas_history;
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.services.GasService;
import com.hxzkoa.udp.GetNowTime;
/*import com.hxzkoa.udp.Udp_Receive;*/
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ExcelUtils;
import com.hxzkoa.util.HttpUtil;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import com.hxzkoa.util.RequestUtils;
 
import net.sf.json.JSONObject;
 
@Controller
public class GasController {
    @Autowired
    private GasService gasService;
    
    @RequestMapping(value = "/sensorManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String sensorManagement(HttpServletRequest request) {
        String toPage = "forward:/hxzk/gas/sensorManagement.jsp";
        List<tb_gas> sensorManagementList = gasService.getSensorManagement(1);
        request.setAttribute("sensorManagementList", sensorManagementList);
        List<tb_collector> collectorList = gasService.getcollectorList();
        request.setAttribute("collectorList", collectorList);
        int curPage = 1;
        int count = gasService.getSensorManagementCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
    }
    
    @ResponseBody
    @RequestMapping(value = "/sensorManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String sensorManagement_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = gasService.getSensorManagementCount();
        int minPage = PageUtil.getMinPage(count);
        int curPage = Integer.parseInt(curPageStr);
        int page = 1;
        if ("pre".equals(pageStr)) {
            if (curPage > 1) {
                page = curPage - 1;
            }
        } else if ("next".equals(pageStr)) {
            if (curPage < minPage) {
                page = curPage + 1;
            }
        } else {
            page = Integer.parseInt(pageStr);
        }
        List<tb_gas> sensorManagementList = gasService.getSensorManagement(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", sensorManagementList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/sensorManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String sensorManagement_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<tb_gas> sensorManagementList = gasService.searchSensorManagement(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", sensorManagementList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/sensorManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_delete(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        gasService.sensorManagement_delete(checkVal);
    }
 
    @ResponseBody
    @RequestMapping(value = "/sensorManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_deleteAll(HttpServletRequest request) {
        gasService.sensorManagement_deleteAll();
    }
    
    @RequestMapping(value = "/sensorManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void sensorManagement_add(HttpServletRequest request) {
        List<tb_collector> macNameList = gasService.getmacName(request.getParameter("gasMacid"));
        String macName = macNameList.get(0).getMacname();
        String id = request.getParameter("gasId");
        tb_gas gas = new tb_gas();
        gas.setTong_dao(request.getParameter("gasTd"));
        gas.setGas_type(request.getParameter("gasType"));
        gas.setWaring_zhi(request.getParameter("gasThres"));
        gas.setCollect_ip(request.getParameter("gasMacid"));
        gas.setIp(request.getParameter("gasIp"));
        gas.setX(request.getParameter("gasX"));
        gas.setY(request.getParameter("gasY"));
        gas.setWei_zhi(macName);
        gas.setId(Integer.parseInt(request.getParameter("gasId")));
        int exist = gasService.sensor_exist(id);
        if (exist > 0) {
            gasService.sensorManagement_modify(gas);
        } else {
            gasService.sensorManagement_add(gas);
        }       
    }
    
    @RequestMapping(value = "/sensorManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void sensorManagement_modify(HttpServletRequest request) {
        List<tb_collector> macNameList = gasService.getmacName(request.getParameter("gasMacid"));
        String macName = macNameList.get(0).getMacname();
        String id = request.getParameter("gasId");
        tb_gas gas = new tb_gas();
        gas.setTong_dao(request.getParameter("gasTd"));
        gas.setGas_type(request.getParameter("gasType"));
        gas.setWaring_zhi(request.getParameter("gasThres"));
        gas.setCollect_ip(request.getParameter("gasMacid"));
        gas.setIp(request.getParameter("gasIp"));
        gas.setX(request.getParameter("gasX"));
        gas.setY(request.getParameter("gasY"));
        gas.setWei_zhi(macName);
        gas.setId(Integer.parseInt(request.getParameter("gasId"))); 
        gasService.sensorManagement_modify(gas);
    }
    
    // 对象转数组
    public static List<Object[]> objectToArray(List<tb_gas> sensorManagementList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < sensorManagementList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_gas gas = (tb_gas) sensorManagementList.get(i);
            words.add(String.valueOf(gas.getId()));
            words.add(gas.getWei_zhi());
            words.add(gas.getGas_type());
            words.add(gas.getNong_du());
            words.add(gas.getStatus());
            words.add(gas.getCollect_ip());
            words.add(gas.getTong_dao());
            words.add(gas.getWaring_zhi());
            words.add(gas.getIp());
            words.add(gas.getX());
            words.add(gas.getY());
            words.add(gas.getAddtime());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
    
    @ResponseBody
    @RequestMapping(value = "/sensorManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String sensorManagement_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/gas/sensorManagement.jsp";
        List<tb_gas> sensorManagementList = gasService.getSensorManagement();
        String[] rowName = { "设备编号","安装位置","气体类型","浓度值","告警情况","采集仪地址","所在通道","告警阈值","IP地址","   X坐标 ","Y坐标","更新时间"};
        List<Object[]> dataList = objectToArray(sensorManagementList);
        ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList);
        OutputStream out;
        try {
            String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
            String headStr = "attachment; filename=\"" + fileName + "\"";
            response.setContentType("APPLICATION/OCTET-STREAM");
            response.setHeader("Content-Disposition", headStr);
            out = response.getOutputStream();
            excel.export(out);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return toPage;
    }
 
    @RequestMapping(value = "/historicalDetection.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalDetection(HttpServletRequest request) {
        String toPage = "forward:/hxzk/gas/historicalDetection.jsp";
        List<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection(1);
        request.setAttribute("historicalDetectionList", historicalDetectionList);
        int curPage = 1;
        int count = gasService.getHistoricalDetectionCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
    }
    
    @ResponseBody
    @RequestMapping(value = "/historicalDetection_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalDetection_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<tb_gas_history> historicalDetectionList = gasService.searchHistoricalDetection(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", historicalDetectionList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalDetection_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalDetection_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = gasService.getHistoricalDetectionCount();
        int minPage = PageUtil.getMinPage(count);
        int curPage = Integer.parseInt(curPageStr);
        int page = 1;
        if ("pre".equals(pageStr)) {
            if (curPage > 1) {
                page = curPage - 1;
            }
        } else if ("next".equals(pageStr)) {
            if (curPage < minPage) {
                page = curPage + 1;
            }
        } else {
            page = Integer.parseInt(pageStr);
        }
        List<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", historicalDetectionList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/historicalDetection_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void historicalDetection_delete(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        gasService.historicalDetection_delete(checkVal);
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalDetection_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void historicalDetection_deleteAll(HttpServletRequest request) {
        gasService.historicalDetection_deleteAll();
    }
    
    // 对象转数组
    public static List<Object[]> hisobjectToArray(List<tb_gas_history> historicalDetectionList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < historicalDetectionList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_gas_history gas_history = (tb_gas_history) historicalDetectionList.get(i);
            words.add(String.valueOf(gas_history.getId()));
            words.add(gas_history.getMacid());
            words.add(gas_history.getName());
            words.add(gas_history.getType());
            words.add(gas_history.getWaring());
            words.add(String.valueOf(gas_history.getX()));
            words.add(String.valueOf(gas_history.getY()));
            words.add(gas_history.getDeep());
            words.add(gas_history.getAddtime());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
    
    @ResponseBody
    @RequestMapping(value = "/historicalDetection_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalDetection_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/gas/historicalDetection.jsp";
        List<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection();
        String[] rowName = {"序号","设备通道  ","安装位置","气体类型","告警状态","X坐标","Y坐标","浓度值","添加时间"};
        List<Object[]> dataList = hisobjectToArray(historicalDetectionList);
        ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList);
        OutputStream out;
        try {
            String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
            String headStr = "attachment; filename=\"" + fileName + "\"";
            response.setContentType("APPLICATION/OCTET-STREAM");
            response.setHeader("Content-Disposition", headStr);
            out = response.getOutputStream();
            excel.export(out);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return toPage;
    }
 
    
 
    @RequestMapping(value = "/collectorManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String collectorManagement(HttpServletRequest request) {
        String toPage = "forward:/hxzk/gas/collectorManagement.jsp";
        List<tb_collector> collectorManagementList = gasService.getCollectorManagement(1);
        request.setAttribute("collectorManagementList", collectorManagementList);
        int curPage = 1;
        int count = gasService.getCollectorManagementCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
    }
    
    @ResponseBody
    @RequestMapping(value = "/collectorManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String collectorManagement_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<tb_collector> collectorManagementList = gasService.searchCollectorManagement(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", collectorManagementList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/collectorManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String collectorManagement_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = gasService.getCollectorManagementCount();
        int minPage = PageUtil.getMinPage(count);
        int curPage = Integer.parseInt(curPageStr);
        int page = 1;
        if ("pre".equals(pageStr)) {
            if (curPage > 1) {
                page = curPage - 1;
            }
        } else if ("next".equals(pageStr)) {
            if (curPage < minPage) {
                page = curPage + 1;
            }
        } else {
            page = Integer.parseInt(pageStr);
        }
        List<tb_collector> labelManagementList = gasService.getCollectorManagement(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", labelManagementList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/collectorManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void collectorManagement_delete(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        gasService.collectorManagement_delete(checkVal);
    }
 
    @ResponseBody
    @RequestMapping(value = "/collectorManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void collectorManagement_deleteAll(HttpServletRequest request) {
        gasService.collectorManagement_deleteAll();
    }
    
    @RequestMapping(value = "/collectorManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void collectorManagement_add(HttpServletRequest request) {
        tb_collector collector = new tb_collector();
        collector.setMacid(Integer.parseInt(request.getParameter("hostId")));
        collector.setStartip(Integer.parseInt(request.getParameter("startId")));
        collector.setDatlenth(Integer.parseInt(request.getParameter("dataLength")));
        collector.setIp(request.getParameter("intId"));
        collector.setMacname(request.getParameter("insLoc"));
        collector.setPosx(Integer.parseInt(request.getParameter("coordX")));
        collector.setPosy(Integer.parseInt(request.getParameter("coordY")));
        gasService.collectorManagement_add(collector);
    }
    
    @RequestMapping(value = "/collectorManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void collectorManagement_modify(HttpServletRequest request) {
        tb_collector collector = new tb_collector();
        collector.setId(Integer.parseInt(request.getParameter("id")));
        collector.setMacid(Integer.parseInt(request.getParameter("hostId")));
        collector.setStartip(Integer.parseInt(request.getParameter("startId")));
        collector.setDatlenth(Integer.parseInt(request.getParameter("dataLength")));
        collector.setIp(request.getParameter("intId"));
        collector.setMacname(request.getParameter("insLoc"));
        collector.setPosx(Integer.parseInt(request.getParameter("coordX")));
        collector.setPosy(Integer.parseInt(request.getParameter("coordY")));    
        gasService.collectorManagement_modify(collector);
    }
    
    // 对象转数组
    public static List<Object[]> collectorobjectToArray(List<tb_collector> collectorManagementList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < collectorManagementList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_collector collector = (tb_collector) collectorManagementList.get(i);
            words.add(String.valueOf(collector.getId()));
            words.add(String.valueOf(collector.getMacid()));
            words.add(String.valueOf(collector.getStartip()));
            words.add(String.valueOf(collector.getDatlenth()));
            words.add(collector.getIp());
            words.add(collector.getMacname());
            words.add(String.valueOf(collector.getPosx()));
            words.add(String.valueOf(collector.getPosy()));
            words.add(String.valueOf(collector.getAddtime()));
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
    
    @ResponseBody
    @RequestMapping(value = "/collectorManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String collectorManagement_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/gas/collectorManagement.jsp";
        List<tb_collector> collectorManagementList = gasService.getCollectorManagement();
        String[] rowName = {"序号","主机地址","起始地址","数据长度","IP地址","安装位置","X坐标","Y坐标","添加时间"};
        List<Object[]> dataList = collectorobjectToArray(collectorManagementList);
        ExcelUtils excel = new ExcelUtils("采集仪管理", rowName, dataList);
        OutputStream out;
        try {
            String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
            String headStr = "attachment; filename=\"" + fileName + "\"";
            response.setContentType("APPLICATION/OCTET-STREAM");
            response.setHeader("Content-Disposition", headStr);
            out = response.getOutputStream();
            excel.export(out);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return toPage;
    }
    
    final Logger logger = LoggerFactory.getLogger(getClass());
 
    @RequestMapping(value = "/collectorManagement_bw.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void collectorManagement_bw(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        logger.info("传入数据IData:" + jsonString);
        tb_collector collector = (tb_collector) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_collector.class);
        gasService.collectorManagement_add(collector);
    }
    
    @RequestMapping(value = "/sensorManagement_bw.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void sensorManagement_bw(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_gas gas = (tb_gas) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
        int exist = gasService.sensor_exist(String.valueOf(gas.getId()));
        if (exist == 0) {
            gasService.sensorManagement_add(gas);
        }   
    }
    
    @RequestMapping(value = "/modifyWarning.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void modifyWarning(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_gas gas = (tb_gas) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
        //显示sql
        String sqlString = "UPDATE tb_gas SET status = "+gas.getStatus()+",nong_du="+gas.getNong_du()+",addtime="+GetNowTime.timestamp2()+" WHERE id=" + gas.getId();
        String messageJson =  GetNowTime.timestamp2()+ " 收:"+ sqlString ;
        String BaowenPath = Config.getBaowenConfig();
        String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
        if (baowenStatus.equals("1")){
            /* Udp_Receive.mysqlMessage.add(messageJson); */
        }
        //
        gasService.modifyWarning(gas);
    }
    
    @ResponseBody
    @RequestMapping(value = "/getGasLength.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String getGasLength(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_gas gas = (tb_gas) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
        String ip = gas.getCollect_ip();
        Integer length = gasService.getGasNumber(ip);
        json.put("length", length);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/getGas.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String getGas(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_gas gas = (tb_gas) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
        String tongdao = gas.getTong_dao();
        String ip = gas.getCollect_ip();
        List<tb_gas> gasList = gasService.getGas(tongdao,ip);
        if (gasList.size() > 0) {
            json.put("result", gasList.get(0));
        } else {
            json.put("result", "null");
        }
        return json.toString();
    }
        
    
}