7.1
15832144755
2021-07-01 ba21fcf8482029f7634b62d60daf171538001769
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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
package com.hxzkoa.controller;
 
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.ImageIcon;
 
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
 
import com.hxzkoa.json.tb_adress_and_port;
import com.hxzkoa.json.tb_department;
import com.hxzkoa.json.tb_history_power;
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.json.tb_tagpower;
import com.hxzkoa.json.tb_wifi;
import com.hxzkoa.json.vo_tp_t_p;
import com.hxzkoa.services.AnchorService;
import com.hxzkoa.services.BasicInfoService;
import com.hxzkoa.services.LabelService;
import com.hxzkoa.udp.ControTag;
import com.hxzkoa.udp.GetNowTime;
import com.hxzkoa.udp.IDcard;
import com.hxzkoa.udp.Udp_Out;
/*import com.hxzkoa.udp.Udp_Receive;*/
import com.hxzkoa.udp.bmpToJPG;
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ExcelUtils;
import com.hxzkoa.util.HttpUtil;
import com.hxzkoa.util.LineXy;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import com.hxzkoa.util.RequestUtils;
 
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import net.sf.json.JSONObject;
 
@Controller
public class LabelController {
    @Autowired
    private LabelService labelService;
    @Autowired
    private BasicInfoService basicInfoService;
    @Autowired
    private AnchorService anchorService;
    
    @ResponseBody
    @RequestMapping(value = "/to_cs_pinlv.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void pinlv(HttpServletRequest request) {
        String tag_id = request.getParameter("tag_id");
        String hz = request.getParameter("hz");
        String xieyi = "55BB,ALERT_TAG_HZ,"+hz+","+tag_id+",END";
        Udp_Out.udp_to_cs(xieyi);
    }
    
    @ResponseBody
    @RequestMapping(value = "/to_cs_xiumian_time.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void xiumiantime(HttpServletRequest request) {
        String tag_id = request.getParameter("tag_id");
        String hz = request.getParameter("hz");
        String xieyi = "55BB,ALERT_SLEEP_TIME,"+hz+","+tag_id+",END";
        Udp_Out.udp_to_cs(xieyi);
    }
    
    @ResponseBody
    @RequestMapping(value = "/to_cs_xiumian_.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void xiumian(HttpServletRequest request) {
        String tag_id = request.getParameter("tag_id");
        String hz = request.getParameter("hz");
        String xieyi = "55BB,OPEN_OR_CLOSE_SLEEP,"+hz+","+tag_id+",END";
        Udp_Out.udp_to_cs(xieyi);
    }
    
    @ResponseBody
    @RequestMapping(value = "/to_cs_zhendong_.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void zhendong(HttpServletRequest request) {
        String tag_id = request.getParameter("tag_id");
        String hz = request.getParameter("hz");
        String xieyi = "55BB,TAG_SHAKE,"+hz+","+tag_id+",END";
        Udp_Out.udp_to_cs(xieyi);
    }
 
    @RequestMapping(value = "/labelManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement(HttpServletRequest request) {
        String toPage = "forward:/hxzk/label/labelManagement.jsp";
        List<tb_tag> labelManagementList = labelService.getLabelManagement(1);
        request.setAttribute("labelManagementList", labelManagementList);
        int curPage = 1;
        int count = labelService.getLabelManagementCount();
        int minPage = PageUtil.getMinPage(count);
        System.out.print(minPage);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
    }
 
    @RequestMapping(value = "/labelManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_add(HttpServletRequest request) throws IOException {
        tb_tag tag = new tb_tag();
        String tag_id = request.getParameter("tag_id");
        if (("").equals(tag_id) || tag_id == null) {
            // 接口处理逻辑
            String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
            tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
            tag_id = tag.getTag_id();
        } else {
            // 网页请求逻辑
            tag.setTag_id(request.getParameter("tag_id"));
            tag.setState(request.getParameter("state"));
            tag.setGaodu(request.getParameter("gaodu"));
            tag.setSudu(request.getParameter("sudu"));
            tag.setPinglv(request.getParameter("pinglv"));
            tag.setVersion(Config.getVersion());
        }
        // 如果该tag_id不存在,新增一条
        List<tb_tag> searchLabelManagement = labelService.searchLabelManagement(tag_id);
        if (searchLabelManagement.size() == 0) {
            labelService.labelManagement_add(tag);
            if(("").equals(tag.getState())){
                tag.setState("未绑定");
            }
            if(("").equals(tag.getGaodu())){
                tag.setGaodu("150");
            }
            if(("").equals(tag.getSudu())){
                tag.setSudu("1000");
            }
            String xieyi = "BSTOCS1,ADDTAG,"+tag.getTag_id()+","+tag.getState()+","+tag.getGaodu()+","+tag.getSudu()+","+tag.getPinglv()+",END";
            Udp_Out.udp_to_cs(xieyi);
            // 新增标签同时需要在tb_person中插入一条数据
            tb_person person = new tb_person();
            person.setP_tagid(tag.getTag_id());
            person.setP_name(tag.getState());
            person.setP_power(tag.getPower());
            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");
            basicInfoService.personManagement_add(person);
        }
    }
 
    @RequestMapping(value = "/labelManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_modify(HttpServletRequest request) {
        tb_tag tag = new tb_tag();
        tag.setTag_id(request.getParameter("tag_id"));
        tag.setState(request.getParameter("state"));
        tag.setGaodu(request.getParameter("gaodu"));
        tag.setSudu(request.getParameter("sudu"));
        tag.setPinglv(request.getParameter("pinglv"));
        labelService.labelManagement_modify(tag);
        String xieyi = "BSTOCS1,ALTERTAG,"+tag.getTag_id()+","+tag.getState()+","+tag.getGaodu()+","+tag.getSudu()+","+tag.getPinglv()+",END";
        Udp_Out.udp_to_cs(xieyi);
        // 修改标签同时需要修改tb_person 需要先查再改否则覆盖空
        List<tb_person> searchPersonManagement = basicInfoService.searchPersonManagement(tag.getTag_id());
        if(searchPersonManagement!=null){
            tb_person person = searchPersonManagement.get(0);
            person.setP_tagid(tag.getTag_id());
            person.setP_name(tag.getState());
            person.setP_power(tag.getPower());
            basicInfoService.personManagement_modify(person);
        }
    }
 
    @RequestMapping(value = "/labelManagement_modifyAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_modifyAll(HttpServletRequest request) {
        tb_tag tag = new tb_tag();
        tag.setGaodu(request.getParameter("gaodu"));
        tag.setSudu(request.getParameter("sudu"));
        tag.setPinglv(request.getParameter("pinglv"));
        labelService.labelManagement_modifyAll(tag);
        String xieyi = "BSTOCS1,ALTERALLTAG,"+tag.getGaodu()+","+tag.getSudu()+","+tag.getPinglv()+",END";
        Udp_Out.udp_to_cs(xieyi);
        // 需要遍历修改
        List<tb_tag> labelList = labelService.getLabelManagement();
        for (int i = 0; i < labelList.size(); i++) {
            String tag_id = labelList.get(i).getTag_id();
            // 修改标签同时需要修改tb_person 需要先查再改否则覆盖空
            List<tb_person> searchPersonManagement = basicInfoService.searchPersonManagement(tag_id);
            if(searchPersonManagement!=null){
                tb_person person = searchPersonManagement.get(0);
                person.setP_tagid(tag.getTag_id());
                person.setP_name(tag.getState());
                person.setP_power(tag.getPower());
                basicInfoService.personManagement_modify(person);
            }
        }
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_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(",");
        labelService.labelManagement_delete(checkVal);
        for (int i = 0; i < checkVal.length; i++) {
            String xieyi = "BSTOCS1,DELETETAG,"+checkVal[i]+",END";
            Udp_Out.udp_to_cs(xieyi);
        }
        // 删除标签同时需要删除tb_person
        labelService.labelperson_delete(checkVal);  
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_deleteAll(HttpServletRequest request) {
        labelService.labelManagement_deleteAll();
        String xieyi = "BSTOCS1,DELETEALLTAG,END";
        Udp_Out.udp_to_cs(xieyi);
        // 删除标签同时需要删除tb_person
        basicInfoService.personManagement_deleteAll();
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_search(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        String input = request.getParameter("input");
        if (("").equals(input) || input == null) {
            String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
            tb_tag tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
            input = tag.getTag_id();
            List<tb_tag> labelManagementList = labelService.searchLabelManagement(input);
            if (labelManagementList.size() > 0) {
                json.put("result", labelManagementList.get(0));
            } else {
                json.put("result", "null");
            }
 
        } else {
            int curPage = 1;
            List<Integer> pageList = new ArrayList<Integer>();
            List<tb_tag> labelManagementList = labelService.searchLabelManagement(input);
            pageList.add(1);
            json.put("dataList", labelManagementList);
            json.put("pageList", pageList);
            json.put("curPage", curPage);
        }
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = labelService.getLabelManagementCount();
        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_tag> labelManagementList = labelService.getLabelManagement(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 = "/labelManagement_exportTemplate.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_exportTemplate(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/label/labelManagement.jsp";
        List<tb_tag> labelTemplateList = labelService.getLabelManagement(1);
        String[] rowName = { "标签ID", "绑定对象"};
        List<Object[]> dataList = labelTemplateobjectToArray(labelTemplateList);
        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;
    }
 
    // 对象转数组
    public static List<Object[]> labelTemplateobjectToArray(List<tb_tag> labelList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < labelList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_tag tag = (tb_tag) labelList.get(i);
            words.add(tag.getTag_id());
            words.add(tag.getState());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_import.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_import(HttpServletRequest request) {
        String path = request.getParameter("path");
        if (path.indexOf("fakepath") != -1) {
            String[] fileNameArr = path.split("\\\\");
            String fileName = fileNameArr[fileNameArr.length - 1];
            path = "C:/hxzkoa/" + fileName;
        }
        ;
        int result = 0;
        // 选取Excel文件得到工作薄
        Workbook workbook;
        try {
            File file = new File(path);
            workbook = Workbook.getWorkbook(file);
            // 选择工作表,通过Workbook的getSheet方法选择第一个工作表(从0开始)
            Sheet sheet = workbook.getSheet(0);
            int rows = sheet.getRows();
            // 选择Cell,读取单元格 通过Sheet的getCell方法选择位置为C2的单元格(两个参数都从0开始)
            for (int i = 1; i < rows; i++) {
                // 读取信息,通过Cell的getContents方法读取单元格的值把单元格中的信息以字符的形式读取出来
                String status = sheet.getCell(0, i).getContents();
                String tag_id = sheet.getCell(1, i).getContents();
                String state = sheet.getCell(2, i).getContents();
                String power = sheet.getCell(3, i).getContents();
                String gaodu = sheet.getCell(4, i).getContents();
                String sudu = sheet.getCell(5, i).getContents();
                String pinglv = sheet.getCell(6, i).getContents();
                String version = sheet.getCell(7, i).getContents();
                if (!("").equals(tag_id)) {
                    tb_tag tag = new tb_tag();
                    tag.setStatus(status);
                    tag.setTag_id(tag_id);
                    tag.setState(state);
                    tag.setPower(power);
                    tag.setGaodu(gaodu);
                    tag.setSudu(sudu);
                    tag.setPinglv(pinglv);
                    tag.setVersion(version);
                    labelService.labelManagement_add(tag);
                }
            }
            // 释放资源
            workbook.close();
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONObject json = new JSONObject();
        json.put("result", result);
        return json.toString();
    }
 
    @RequestMapping(value = "/uploadLabel.do")
    public String uploadPerson(@RequestParam("file") MultipartFile[] files, HttpServletRequest request) {
        String toPage = "forward:/hxzk/label/labelManagement.jsp";
        String filePath = request.getServletContext().getRealPath("/") + "hxzk\\upload\\";
        String filename = files[0].getOriginalFilename();
        try {
            File existFile = new File(filePath);
            if (!existFile.exists()) {
                existFile.mkdir();
            }
            for (MultipartFile file : files) {
                file.transferTo(new File(filePath + file.getOriginalFilename()));
                System.out.print(file.getOriginalFilename());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        int result = 0;
        String path = filePath + filename;
        // 选取Excel文件得到工作薄
        Workbook workbook;
        try {
            File file = new File(path);
            workbook = Workbook.getWorkbook(file);
            // 选择工作表,通过Workbook的getSheet方法选择第一个工作表(从0开始)
            Sheet sheet = workbook.getSheet(0);
            int rows = sheet.getRows();
            // 选择Cell,读取单元格 通过Sheet的getCell方法选择位置为C2的单元格(两个参数都从0开始)
            for (int i = 3; i < rows; i++) {
                // 读取信息,通过Cell的getContents方法读取单元格的值把单元格中的信息以字符的形式读取出来
                // String status = sheet.getCell(0, i).getContents();
                String tag_id = sheet.getCell(0, i).getContents();
                String state = sheet.getCell(1, i).getContents();
                if (!("").equals(tag_id)) {
                    tb_tag tag = new tb_tag();
                    // tag.setStatus(status);
                    tag.setTag_id(tag_id);
                    tag.setState(state);
                    tag.setPower("100");
                    tag.setGaodu("150");
                    tag.setSudu("无");
                    tag.setPinglv("无");
                    tag.setVersion("无");
                    result = labelService.labelManagement_add(tag);
                }
            }
            // 释放资源
            workbook.close();
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        request.setAttribute("resultList", result);
        List<tb_tag> labelManagementList = labelService.getLabelManagement(1);
        request.setAttribute("labelManagementList", labelManagementList);
        int curPage = 1;
        int count = labelService.getLabelManagementCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        File file = new File(path);
        file.delete();
        return toPage;
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/label/labelManagement.jsp";
        List<tb_tag> tb_tagList = labelService.getLabelManagement();
        String[] rowName = { "标签ID", "绑定对象", "电量%", "佩戴高度/cm", "速度限制cm/s", "定位频率(HZ)", "版本", "添加时间" };
        List<Object[]> dataList = objectToArray_labelManagement(tb_tagList);
        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;
    }
 
    // tb_tag 导出表格 对象转数组
    public static List<Object[]> objectToArray_labelManagement(List<tb_tag> tb_tagList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < tb_tagList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_tag tag = (tb_tag) tb_tagList.get(i);
            words.add(tag.getTag_id());
            words.add(tag.getState());
            words.add(tag.getPower());
            words.add(tag.getGaodu());
            words.add(tag.getSudu());
            words.add(tag.getPinglv());
            words.add(tag.getVersion());
            words.add(tag.getAddtime());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_tagid.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_tagid(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        List<tb_tag> labelManagementList = labelService.getLabelManagement();
        List<String> reList = new ArrayList<String>();
        for (int i = 0; i < labelManagementList.size(); i++) {
            reList.add(labelManagementList.get(i).getTag_id());
        }
        json.put("dataList", reList);
        return json.toString();
    }
 
    @RequestMapping(value = "/labelManagement_more.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelManagement_more(HttpServletRequest request) {
        tb_tag tag = new tb_tag();
        tag.setTag_id(request.getParameter("tag_id"));
        tag.setSleep_satus(request.getParameter("sleep_satus"));
        tag.setSleep_time(request.getParameter("sleep_time"));
        tag.setGongfang(request.getParameter("gongfang"));
        tag.setPinglv(request.getParameter("pinglv"));
        tag.setImu(request.getParameter("imu"));
        tag.setDong_status(request.getParameter("dong_status"));
        labelService.labelManagement_more(tag);
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelManagement_tag.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelManagement_tag(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        String tagid = request.getParameter("tag_id");
        String tag = request.getParameter("tag");
        String hz = request.getParameter("hz");
        String result = "";
        List<tb_tag> tagList = null;
        if (("ALL").equals(tagid)) {
            tagList = labelService.getLabelManagement();
        }
        // 获取 port,wifi_mode
        tb_wifi wifiManagement = anchorService.getWifiManagement();
        String port = wifiManagement.getPort();
        String wifi_mode = wifiManagement.getModel();
        // 1.开启或者关闭标签休眠
        // 2.修改标签休眠时间
        // 3.修改标签的功率
        // 4.下发标签振动
        // 5.修改标签的频率
        // 6.修改加速度计阈值
        // 7.修改静止时间
        // 8.开启或者关闭标签振动功能
        if (("1").equals(tag)) {
            // 1.开启或者关闭标签休眠
            int sleep_open = Integer.parseInt(hz);
            ControTag.set_tag_sleep_open(sleep_open, tagid, tagList, port, wifi_mode);
            result = "休眠指令已经下发完成!";
        } else if (("2").equals(tag)) {
            // 2.修改标签休眠时间
            int sleeptime = Integer.parseInt(hz);
            ControTag.set_tag_sleep_time(sleeptime, tagid, tagList, port, wifi_mode);
            result = "休眠时间修改指令下发完成!";
        } else if (("3").equals(tag)) {
            // 3.修改标签的功率
            int gonglv = Integer.parseInt(hz);
            ControTag.set_tag_gonglv(gonglv, tagid, tagList, port, wifi_mode);
            result = "功率修改指令下发完成!";
        } else if (("4").equals(tag)) {
            // 4.下发标签振动
            if (hz == null || ("").equals(hz)) {
                result = "振动时间不能为空!";
            } else {
                int time = Integer.parseInt(hz);
                if (time > 255) {
                    result = "振动时间为0~255秒!";
                } else {
                    ControTag.set_tag_zhendong(time, tagid, tagList, port, wifi_mode);
                    result = "振动指令已下发完毕!";
                }
            }
        } else if (("5").equals(tag)) {
            // 5.修改标签的频率
            ControTag.set_tag_hz(hz, tagid, tagList, port, wifi_mode);
            result = "修改频率指令已下发完毕!";
        } else if (("6").equals(tag)) {
            // 6.修改加速度计阈值
            int yuzhi = Integer.parseInt(hz);
            ControTag.set_tag_jiasu(yuzhi, tagid, tagList, port, wifi_mode);
            result = "修改加速度计阈值指令下发完成!";
        } else if (("7").equals(tag)) {
            // 7.修改静止时间
            int time = Integer.parseInt(hz);
            ControTag.set_tag_jingzhi(time, tagid, tagList, port, wifi_mode);
            result = "静止时间修改指令下发完成!";
        } else if (("8").equals(tag)) {
            // 8.开启或者关闭标签振动功能
            int jck_move = Integer.parseInt(hz);
            ControTag.set_tag_move(jck_move, tagid, tagList, port, wifi_mode);
            if (jck_move == 1) {
                result = "开启振动改指令下发完成!";
            } else {
                result = "关闭振动指令下发完成!";
            }
        }
        json.put("result", result);
        return json.toString();
    }
 
    @RequestMapping(value = "/labelDeliver.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelDeliver(HttpServletRequest request) {
        String toPage = "forward:/hxzk/label/labelDeliver.jsp";
        List<tb_department> department = basicInfoService.getAllDepartmentManagement();
        request.setAttribute("department", department);
        return toPage;
    }
 
    @RequestMapping(value = "/labelDeliver_add.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelDeliver_add(HttpServletRequest request) {
        String p_tagid = request.getParameter("p_tagid");
        String p_name = request.getParameter("p_name");
        tb_person person = new tb_person();
        String p_sos = "0";
        String p_online = "0";
        String p_power = "100";
        person.setP_tagid(p_tagid);
        person.setP_name(p_name);
        person.setP_sex(request.getParameter("p_sex"));
        person.setP_minzu(request.getParameter("p_minzu"));
        person.setP_phone(request.getParameter("p_phone"));
        person.setP_department(request.getParameter("p_department"));
        person.setP_idcardnum(request.getParameter("p_idcardnum"));
        person.setP_adress(request.getParameter("p_adress"));
        person.setP_sos(p_sos);
        person.setP_online(p_online);
        person.setP_power(p_power);
        int exist = labelService.labelDeliver_exist(p_tagid);
        if (exist > 0) {
            labelService.labelDeliver_modify(person);
        } else {
            labelService.labelDeliver_add(person);
        }
        labelService.labelManagement_state(p_name, p_tagid);
    }
 
    @RequestMapping(value = "/labelDeliver_remove.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelDeliver_remove(HttpServletRequest request) {
        String p_tagid = request.getParameter("p_tagid");
        String p_name = "未绑定";
        tb_person person = new tb_person();
        person.setP_tagid(p_tagid);
        person.setP_name(p_name);
        person.setP_sex(request.getParameter("p_sex"));
        person.setP_minzu(request.getParameter("p_minzu"));
        person.setP_phone(request.getParameter("p_phone"));
        person.setP_department(request.getParameter("p_department"));
        person.setP_idcardnum(request.getParameter("p_idcardnum"));
        person.setP_adress(request.getParameter("p_adress"));
        int exist = labelService.labelDeliver_exist(p_tagid);
        if (exist > 0) {
            labelService.labelDeliver_modify(person);
            labelService.labelManagement_state(p_name, p_tagid);
        }
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelDeliver_conn.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelDeliver_conn(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        List<tb_adress_and_port> adress_and_port = labelService.getAdress_and_port();
        String result = "0";
        String state = IDcard.chushi(adress_and_port);
        if (("发卡设备准备就绪...").equals(state)) {
            result = "1";
        }
        json.put("result", result);
        json.put("port", adress_and_port.get(0).getPort());
        json.put("btl", adress_and_port.get(0).getBaoliu());
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/labelDeliver_readIDcard.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelDeliver_readIDcard(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        List<tb_adress_and_port> adress_and_port = labelService.getAdress_and_port();
        String result;
        String state = IDcard.chushi(adress_and_port);
        String idcard = "";
        String imageStr = "";
        if (("发卡设备准备就绪...").equals(state)) {
            int i = 0;
            // 卡认证
            while (i < 3) {
                boolean rz = IDcard.CVR_Authenticate();
                if (rz) {
                    i = 8;
                    System.out.println("卡认证成功...");
                    break;
                } else {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                    System.out.println(i + "请放身份证...");
                    result = i + "请放身份证...";
                    i++;
                }
            }
 
            if (i == 8) {
                result = "卡认证成功...";
                if (IDcard.RedaCard() == 1) {
                    idcard = IDcard.name + "_";
                    idcard = IDcard.sex + "_";
                    idcard = IDcard.minzu + "_";
                    idcard = IDcard.chushengdate + "_";
                    idcard = IDcard.startdate + "-" + IDcard.jizhidate + "_";
                    idcard = IDcard.idnum + "_";
                    idcard = IDcard.address + "_";
                    idcard = IDcard.fazhengjiguan;
                }
                try {
                    bmpToJPG.bmp2jpg();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                // 身份证照片
                // image.setIcon(bmpToJPG.getImages());
                ImageIcon images = bmpToJPG.getImages();
                Image image = images.getImage();
                imageStr = image.toString();
            } else {
                result = "卡认证失败...";
            }
        } else {
            result = "发卡设备状态不正常!请先连接设备...";
        }
        json.put("idcard", idcard);
        json.put("result", result);
        json.put("image", imageStr);
        return json.toString();
    }
    
    @ResponseBody
    @RequestMapping(value = "/labelDeliver_readPoscard.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String labelDeliver_readPoscard(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        List<tb_adress_and_port> adress_and_port = labelService.getAdress_and_port();
        String rfidnum = "";
        if(IDcard.M1_MF_HL_Request(adress_and_port)==144) {
             rfidnum=String.valueOf(IDcard.kaohao); 
        };                  
        json.put("rfidnum", rfidnum);
        return json.toString();
    }
 
    @RequestMapping(value = "/labelDeliver_savePort.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void labelDeliver_savePort(HttpServletRequest request) throws IOException {
        String p_port = request.getParameter("p_port");
        String p_btl = request.getParameter("p_btl");
        tb_adress_and_port port = new tb_adress_and_port();
        port.setBaoliu(p_port);
        port.setBaoliu2(p_btl);
        port.setName("faka ");
        labelService.updateAdress_and_port(port);
    }
 
    @RequestMapping(value = "/realTimePower.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String realTimePower(HttpServletRequest request) {
        String toPage = "forward:/hxzk/label/realTimePower.jsp";
        List<tb_tagpower> realTimePowerList = labelService.getRealTimePower(1);
        request.setAttribute("realTimePowerList", realTimePowerList);
        int curPage = 1;
        int count = labelService.getRealTimePowerCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
    }
 
    @ResponseBody
    @RequestMapping(value = "/realTimePower_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String realTimePower_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<vo_tp_t_p> realTimePowerList = labelService.searchRealTimePower(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", realTimePowerList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/realTimePower_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String realTimePower_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = labelService.getRealTimePowerCount();
        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_tagpower> realTimePowerList = labelService.getRealTimePower(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", realTimePowerList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/realTimePower_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String realTimePower_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/label/realTimePower.jsp";
        List<vo_tp_t_p> realTimePowerList = labelService.getRealTimePower();
        String[] rowName = { "姓名", "标签ID", "标签频率(HZ)", "电量%", "更新时间" };
        List<Object[]> dataList = objectToArray_realTimePower(realTimePowerList);
        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;
    }
 
    // vo_tp_t_p 导出表格 对象转数组
    public static List<Object[]> objectToArray_realTimePower(List<vo_tp_t_p> vo_tp_t_pList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < vo_tp_t_pList.size(); i++) {
            List<String> words = new ArrayList<String>();
            vo_tp_t_p tp_t_p = (vo_tp_t_p) vo_tp_t_pList.get(i);
            words.add(tp_t_p.getP_name());
            words.add(tp_t_p.getTagid());
            words.add(tp_t_p.getPinglv());
            words.add(tp_t_p.getPower());
            words.add(tp_t_p.getTime());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
 
    @RequestMapping(value = "/historicalPower.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalPower(HttpServletRequest request) {
        String toPage = "forward:/hxzk/label/historicalPower.jsp";
        List<tb_history_power> historicalPowerList = labelService.getHistoricalPower(1);
        request.setAttribute("historicalPowerList", historicalPowerList);
        int curPage = 1;
        int count = labelService.getHistoricalPowerCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", curPage);
        return toPage;
 
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalPower_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<tb_history_power> historicalPowerList = labelService.searchHistoricalPower(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", historicalPowerList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_powerAnalysis.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalPower_powerAnalysis(HttpServletRequest request) throws Exception {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList<Integer>();
        List<tb_history_power> historicalPowerList = labelService.searchPowerAnalysis(input);
        String sysPath = request.getServletContext().getRealPath("/");
        LineXy.getJFreeChart_hp(input, historicalPowerList,sysPath);
        pageList.add(1);
        JSONObject json = new JSONObject();
        String filePath = "hxzk/image/powerAnalysis/" + input + "电量分析.jpeg";
        json.put("dataList", historicalPowerList);
        json.put("pageList", pageList);
        json.put("curPage", curPage);
        json.put("path", filePath);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_page.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalPower_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = labelService.getHistoricalPowerCount();
        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_history_power> historicalPowerList = labelService.getHistoricalPower(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", historicalPowerList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void historicalPower_delete(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        labelService.historicalPower_delete(checkVal);
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void historicalPower_deleteAll(HttpServletRequest request) {
        labelService.historicalPower_deleteAll();
    }
 
    @ResponseBody
    @RequestMapping(value = "/historicalPower_export.do", method = { RequestMethod.POST, RequestMethod.GET })
    public String historicalPower_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/label/historicalPower.jsp";
        List<tb_history_power> historicalPowerList = labelService.getHistoricalPower();
        String[] rowName = { "序号", "标签ID", "电量%", "时间" };
        List<Object[]> dataList = objectToArray_historicalPower(historicalPowerList);
        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;
    }
 
    // tb_history_power 导出表格 对象转数组
    public static List<Object[]> objectToArray_historicalPower(List<tb_history_power> history_powerList) {
        List<Object[]> reList = new ArrayList<>();
        for (int i = 0; i < history_powerList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_history_power history_power = (tb_history_power) history_powerList.get(i);
            words.add(history_power.getId() + "");
            words.add(history_power.getTagid());
            words.add(history_power.getPower());
            words.add(history_power.getTime());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
        }
        return reList;
    }
 
    // 报文收取 改标签的状态和电量信息
    @RequestMapping(value = "/label_bw_power.do", method = { RequestMethod.POST, RequestMethod.GET })
    public void label_bw_power(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_tag tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
        // 显示sql
        String sqlString = "UPDATE tb_tag SET power=" + tag.getPower() + " WHERE tag_id=" + tag.getTag_id();
        String messageJson =  GetNowTime.timestamp2()+ " 收:"+ sqlString ;
        String BaowenPath = Config.getBaowenConfig();
        String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
        if (baowenStatus.equals("1")){
            /* Udp_Receive.mysqlMessage.add(messageJson); */
        }
        //
        labelService.label_bw_power(tag);
    }
    
    @ResponseBody
    @RequestMapping(value = "/labeltag_id_search.do", method = { RequestMethod.POST, RequestMethod.GET })
    public int labeltag_id_search(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        String tag_id = request.getParameter("tag_id");
        List<tb_tag> labelManagementList = null;
        int nn;
        if (("").equals(tag_id) || tag_id == null) {
            String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
            tb_tag tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
            tag_id = tag.getTag_id();
            labelManagementList = labelService.searchLabelManagement(tag_id);
            if (labelManagementList.size() > 0) {
                json.put("result", labelManagementList.get(0));
            } else {
                json.put("result", "null");
            }
 
        } else {
            int curPage = 1;
            List<Integer> pageList = new ArrayList<Integer>();
            labelManagementList = labelService.searchLabelManagement(tag_id);
            pageList.add(1);
            json.put("dataList", labelManagementList);
            json.put("pageList", pageList);
            json.put("curPage", curPage);
        }
        if(null == labelManagementList || labelManagementList.size() ==0 ) {
            nn=0;
        }else {
            nn=1;
        }
        return nn;
    }
}