leutu
2024-08-20 6c914caa1e16d709d16c39b6ae55bd8b5c8f0283
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
package com.skyline.electricity.timer;
 
import org.springframework.stereotype.*;
import org.springframework.context.annotation.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.messaging.simp.*;
 
import java.text.ParseException;
import java.util.concurrent.*;
import com.skyline.electricity.service.*;
import com.vividsolutions.jts.geom.*;
import java.text.*;
import java.nio.charset.*;
import org.springframework.http.converter.*;
import org.springframework.web.client.*;
import com.vividsolutions.jts.io.*;
import com.alibaba.fastjson.*;
import org.springframework.http.*;
import java.util.*;
import org.springframework.scheduling.annotation.*;
import org.springframework.util.*;
import com.skyline.electricity.entity.*;
import com.skyline.electricity.pojo.*;
import com.skyline.electricity.controller.*;
import java.io.*;
import java.util.stream.Collectors;
 
import org.slf4j.*;
 
@Component
@Configuration
@EnableScheduling
public class SchedulerTask
{
    private static Logger log;
    public static List<PersonPosition> personlocationentity;
    @Autowired
    private ConfigInfo configInfo;
    private static int locationEnable;
    @Autowired
    SimpMessagingTemplate simpMessagingTemplate;
    @Autowired
    private DetectService detectService;
    @Autowired
    private OutService outService;
    private ConcurrentHashMap cmap;
    @Autowired
    private RemoteController remoteController;
    @Autowired
    private InfoSynchService infoSynchService;
 
    @Autowired
    private DeviceController deviceController ;
    @Autowired
            private InformationService informationService ;
 
 
    @Autowired
    WebSocketController webSocketController ;
 
 
    GeometryFactory geometryFactory;
    WKTReader reader;
    private Point point;
    private Polygon polygon;
    private Map<Object, Object> map;
    private static final SimpleDateFormat dateFormat;
    public Integer mux;
 
    public SchedulerTask() {
        this.cmap = new ConcurrentHashMap();
        this.geometryFactory = new GeometryFactory();
        this.reader = new WKTReader(this.geometryFactory);
        this.map = new HashMap<Object, Object>();
        this.mux = 1;
    }
    // 读取information表数据,此表保留用户最后一次定位信息
    @Scheduled(fixedRate = 5000L)
    public void webSocketGetInfo( ) {
 
        List<String> list = informationService.listInformations().stream().map(r->r.getXy()).collect(Collectors.toList());
 
        List<RetInfo> rlist = new ArrayList<>();
        list.stream().forEach(r->rlist.add(JSONObject.parseObject(r,RetInfo.class))) ;
        if( list != null && list.size() > 0){
            System.out.println("scheduled....push size:"+list.size());
            webSocketController.sendAllMessage(JSONObject.toJSONString(rlist));
        }
       //     System.out.println( "websocket status ..["+JSONObject.toJSONString(rlist)+"]" );
        //推送报警信息
        //pushIM(rlist);
    }
 
    /**
     * {
     *     "type":"3",
     *     "source":"2",
     *     "vedioUrl":"",
     *     "cameraCode":"",
     *     "cameraName":"",
     *     "startDate":"1234567890",
     *     "warnName": "张三进入围栏大厂区"
     * }
     */
    @Async
    public void pushIM(List<RetInfo> rlist){
        final RestTemplate template = new RestTemplate();
        Map<String, String> map = new HashMap<>();
 
        rlist.stream().forEach((k) -> {
           // if(  k.getStatus().equals("ok")) return ;
            //System.out.println( "k====="+k.getLongitude()+"   "+k.getLatitude()) ;
            MonitorInfo monitor = informationService.queryMinDistance(k.getLongitude(),k.getLatitude());
            if( monitor == null ) return ;
 
            //严谨的处理应该有判断高度,这里暂时不处理
 
            map.put("type", "3");
            map.put("source", "2");
            map.put("vedioUrl", monitor.getHk_rtsp());
            map.put("cameraCode", monitor.getMonitor_id());
            map.put("cameraName", monitor.getMonitor_name());
            Date date = new Date();
//            try {
//                date = DateFormat.getDateInstance().parse(k.getStartTime());
//            } catch (ParseException e) {
//                e.printStackTrace();
//                date = new Date();
//            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String formattedDate = sdf.format(date);
            map.put("startDate",formattedDate);
            map.put("warnName", k.getUserName()+"进入"+k.getFence_name());
            String url = configInfo.getWarn_url();
            //System.out.println( "post url warning "+url) ;
            //System.out.println( "post url warning "+configInfo.getServer_url()) ;
            url =  "http://10.69.206.205:8080/a/ew/ewWarning/warning";
            ResponseEntity<String> result =  template.postForEntity(url, map,String.class);
            //System.out.println("【user info】:"+result);
 
        });
 
    }
 
 
    //    @Scheduled(fixedRate = 5000L)
    public void getInfo() {
        final RestTemplate template = new RestTemplate();
        final Map<String, String> configInfo = (Map<String, String>)this.remoteController.getConfigInfo();
        final String appid = configInfo.get("appid");
        final String tenantId = configInfo.get("tenantId");
        final String secret = configInfo.get("secret");
        final String coUrl = configInfo.get("coUrl");
        final String imUrl = configInfo.get("imUrl");
        final String dzzzUrl = configInfo.get("dzzzUrl");
        final String shopId = configInfo.get("shopId");
        final String modId = configInfo.get("modId");
        final String modKey = configInfo.get("modKey");
        final Integer pageNum = Integer.parseInt(configInfo.get("pageNum"));
        final Integer pageSize = Integer.parseInt(configInfo.get("pageSize"));
        final Integer value = Integer.parseInt(configInfo.get("value"));
        final String safeSystem_ip = configInfo.get("safeSystem_ip");
        final String senderName = "围栏预警";
        final String url = safeSystem_ip + "/a/in/api/woWt/savePersonAccess";
        template.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        final HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        final HttpHeaders header = new HttpHeaders();
        header.setContentType(MediaType.APPLICATION_JSON_UTF8);
        final Map<String, Object> configMap = new HashMap<String, Object>();
        configMap.put("appid", appid);
        configMap.put("secret", secret);
        configMap.put("tenantId", tenantId);
//        ResponseEntity<String> response = null;
//        try {
//            response = (ResponseEntity<String>)template.getForEntity(coUrl + "/oapi/gettoken?appid={appid}&secret={secret}&tenantId={tenantId}", (Class)String.class, (Map)configMap);
//
//        }
//        catch (RestClientException e7) {
//            for (int i = 0; i < 10; ++i) {
//                response = (ResponseEntity<String>)template.getForEntity(coUrl + "/oapi/gettoken?appid={appid}&secret={secret}&tenantId={tenantId}", (Class)String.class, (Map)configMap);
//            }
//        }
//        final String body = (String)response.getBody();
//        System.out.println("weilan resp:["+body+"]");
//        final JSONObject jsonObjectResult = JSONObject.parseObject(body);
//        final String access_token = jsonObjectResult.getString("access_token");
        final String access_token = "";
        final MultiValueMap<String, String> params = (MultiValueMap<String, String>)new LinkedMultiValueMap();
        params.add("token", access_token);
        params.add("senderName", senderName);
        params.add("sender", appid);
        final JSONObject message = new JSONObject();
        final List<String> recipientsIds = (List<String>)this.infoSynchService.getRecipientsIds();
        final StringBuffer stringBuffer = new StringBuffer();
        for (int j = 0; j < recipientsIds.size(); ++j) {
            if (j != recipientsIds.size() - 1) {
                stringBuffer.append(recipientsIds.get(j) + ",");
            }
            else {
                stringBuffer.append(recipientsIds.get(j));
            }
        }
        message.put("recipient", (Object)stringBuffer.toString().trim());
        message.put("msgId", (Object)UUID.randomUUID().toString());
        message.put("displayType", (Object)"microapp");
        message.put("handleState", (Object)"false");
        final JSONObject msg = new JSONObject();
        msg.put("type", (Object)"text");
        msg.put("url", (Object)"");
        msg.put("redirectUrl", (Object)"");
        msg.put("fun", (Object)"");
        msg.put("avatar", (Object)"");
        final Map<Object, Object> map = new HashMap<Object, Object>();
        final Map<String, Object> locations = (Map<String, Object>)this.remoteController.getMultiPersonlocations(shopId, modId, modKey, pageNum, pageSize, (int)value);
        //final List<PersonPosition> list = SchedulerTask.personlocationentity = locations.get("list");
        final List<PersonPosition> list = (List<PersonPosition>)locations.get("list");
        final List<Map<String, Object>> personlist = new ArrayList<Map<String, Object>>();
        final Iterator<PersonPosition> it = list.iterator();
        while (it.hasNext()) {
            final PersonPosition p = it.next();
            if (p.getAlitude() == null || p.getLatitude() == null || p.getLongitude() == null) {
                it.remove();
            }
        }
        final List<FencePosition> fencePositionList = (List<FencePosition>)this.detectService.getFenceInfoByStatus();
        final Information information = new Information();
        final String glpoly = this.configInfo.getGl();
        final String qjpoly = this.configInfo.getQj();
        Polygon glpolygon = null;
        Polygon qjpolygon = null;
        try {
            glpolygon = (Polygon)this.reader.read("POLYGON((" + glpoly + "))");
            qjpolygon = (Polygon)this.reader.read("POLYGON((" + qjpoly + "))");
        }
        catch (Exception e1) {
            e1.printStackTrace();
        }
        final List<Map<String, Object>> fixedPolygon = new ArrayList<Map<String, Object>>();
        double startaltitude = 0.0;
        double endaltitude = 6.3;
        for (int k = 1; k < 4; ++k) {
            final Map<String, Object> polyinfo = new HashMap<String, Object>();
            polyinfo.put("polygon", qjpolygon.toString());
            polyinfo.put("startaltitude", startaltitude);
            polyinfo.put("endaltitude", endaltitude);
            polyinfo.put("name", "qj" + k);
            startaltitude += 6.3;
            endaltitude += 6.3;
            fixedPolygon.add(polyinfo);
        }
        startaltitude = 0.0;
        endaltitude = 6.3;
        for (int k = 1; k < 3; ++k) {
            final Map<String, Object> polyinfo = new HashMap<String, Object>();
            polyinfo.put("polygon", glpolygon.toString());
            polyinfo.put("startaltitude", startaltitude);
            polyinfo.put("endaltitude", endaltitude);
            if (k == 2) {
                polyinfo.put("name", "gl3");
            }
            else {
                polyinfo.put("name", "gl" + k);
            }
            startaltitude += 12.6;
            endaltitude += 12.6;
            fixedPolygon.add(polyinfo);
        }
        int personcount = 0;
        SchedulerTask.log.warn("人员位置list" + list.toString());
        if (list.size() > 0) {
            for (int l = 0; l < fixedPolygon.size(); ++l) {
                personcount = 0;
                personlist.clear();
                for (int m = 0; m < list.size(); ++m) {
                    final String compoint = list.get(m).getLongitude() + " " + list.get(m).getLatitude();
                    final String userId = list.get(m).getUserId();
                    try {
                        this.point = (Point)this.reader.read("POINT(" + compoint + ")");
                    }
                    catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    if (this.point != null) {
                        map.put("point", this.point.toString());
                    }
                    map.put("polygon", fixedPolygon.get(l).get("polygon"));
                    final String flag = this.detectService.judge((Map)map);
                    final boolean mark = Double.parseDouble(list.get(m).getAlitude()) > Double.parseDouble(fixedPolygon.get(l).get("startaltitude").toString()) && Double.parseDouble(list.get(m).getAlitude()) < Double.parseDouble(fixedPolygon.get(l).get("endaltitude").toString());
                    if (flag.equals("t") && mark) {
                        final Map<String, Object> tempmap = new HashMap<String, Object>();
                        tempmap.put("workid", fixedPolygon.get(l).get("name"));
                        tempmap.put("userid", list.get(m).getUserId().toString());
                        personlist.add(tempmap);
                        ++personcount;
                    }
                    if (m == list.size() - 1) {
                        this.detectService.insertfixareaPersonRel((List)personlist, fixedPolygon.get(l).get("name").toString(), personcount);
                    }
                }
            }
            for (int l = 0; l < fencePositionList.size(); ++l) {
                personcount = 0;
                personlist.clear();
                final String workId = fencePositionList.get(l).getWorkId();
                final List<String> allowList = (List<String>)this.infoSynchService.selectAllowList(workId);
                try {
                    this.polygon = (Polygon)this.reader.read("POLYGON((" + fencePositionList.get(l).getFenceposition() + "))");
                }
                catch (Exception e3) {
                    e3.printStackTrace();
                }
                for (int j2 = 0; j2 < list.size(); ++j2) {
                    final String compoint2 = list.get(j2).getLongitude() + " " + list.get(j2).getLatitude();
                    final String userId2 = list.get(j2).getUserId();
                    final boolean isExist = allowList.contains(userId2);
                    final Information info = this.detectService.selectPosition(userId2, fencePositionList.get(l).getWorkId());
                    try {
                        this.point = (Point)this.reader.read("POINT(" + compoint2 + ")");
                    }
                    catch (Exception e4) {
                        e4.printStackTrace();
                    }
                    if (this.point != null) {
                        map.put("point", this.point.toString());
                    }
                    map.put("polygon", this.polygon.toString());
                    final String flag2 = this.detectService.judge((Map)map);
                    final boolean mark2 = Double.parseDouble(list.get(j2).getAlitude()) > fencePositionList.get(l).getStartaltitude() && Double.parseDouble(list.get(j2).getAlitude()) < fencePositionList.get(l).getEndaltitude();
                    if (flag2.equals("t") && mark2) {
                        final Map<String, Object> tempmap2 = new HashMap<String, Object>();
                        tempmap2.put("fname", fencePositionList.get(l).getFname());
                        tempmap2.put("workid", fencePositionList.get(l).getWorkId());
                        tempmap2.put("userid", list.get(j2).getUserId().toString());
                        personlist.add(tempmap2);
                        ++personcount;
                    }
                    if (j2 == list.size() - 1) {
                        final FencePosition fencePost = fencePositionList.get(l);
                        fencePost.setPersoncount(Integer.valueOf(personcount));
                        this.detectService.updateFenceInfo(fencePost);
                        for (final Map<String, Object> map2 : personlist) {
                            map2.put("personcount", personcount);
                        }
                        this.detectService.insertFencePersonRel((List)personlist, fencePost.getWorkId());
                    }
                    if (info == null && mark2) {
                        if (flag2.equals("t")) {
                            information.setWtId(fencePositionList.get(l).getWorkId());
                            information.setUserId(list.get(j2).getUserId());
                            information.setUserName(list.get(j2).getUserName());
                            information.setStartTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()).toString());
                            information.setName(fencePositionList.get(l).getFname());
                            information.setFence_type(fencePositionList.get(l).getType());
                            information.setStatus("in");
                            SchedulerTask.log.warn("in调用插入时间 " + information.toString());
                            this.cmap.put(list.get(j2).getUserId(), 1);
                            final String json = JSON.toJSONString((Object)information);
                            this.detectService.insertInfo(information);
                            if (fencePositionList.get(l).getType().equals("temp")) {
                                final HttpEntity<MultiValueMap<String, String>> as_request = (HttpEntity<MultiValueMap<String, String>>)new HttpEntity((Object)json, (MultiValueMap)header);
                                template.postForEntity(url, (Object)as_request, (Class)String.class, new Object[0]);
                                SchedulerTask.log.warn("临时围栏工作票:+" + fencePositionList.get(l).getWorkId());
                                final List<Map> workleader = (List<Map>)this.detectService.selectWorkLeader(fencePositionList.get(l).getWorkId());
                                SchedulerTask.log.warn("工作票负责人" + workleader.toString());
                                if (workleader.get(0).get("id").equals(list.get(j2).getUserId())) {
                                    SchedulerTask.log.warn(list.get(j2).getUserName() + "该员工是工作票负责人");
                                    final Information lastInformation = this.detectService.queryInformation(information.getWtId(), workleader.get(0).get("id").toString());
                                    SchedulerTask.log.warn("上次的出记录" + lastInformation.toString());
                                    SchedulerTask.log.warn("本次出入记录" + information.toString());
                                    if (lastInformation != null) {
                                        final String startWorkTimeAM = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString() + " 08:30";
                                        final String endWorkTimeAM = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString() + " 11:30";
                                        final String startWorkTimePM = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString() + " 13:30";
                                        final String endWorkTimePM = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString() + " 17:30";
                                        final String currentTime = information.getStartTime();
                                        final String lastTime = lastInformation.getStartTime();
                                        boolean fig = false;
                                        try {
                                            final Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(currentTime);
                                            final Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(lastTime);
                                            final long l2 = (now.getTime() - date.getTime()) / 1000L / 60L;
                                            if (l2 > 10L) {
                                                if (lastTime.compareTo(startWorkTimeAM) > 0 && lastTime.compareTo(endWorkTimeAM) < 0 && currentTime.compareTo(startWorkTimeAM) > 0 && currentTime.compareTo(endWorkTimeAM) < 0) {
                                                    fig = true;
                                                }
                                                if (currentTime.compareTo(startWorkTimePM) > 0 && currentTime.compareTo(endWorkTimePM) < 0 && lastTime.compareTo(startWorkTimePM) > 0 && lastTime.compareTo(endWorkTimePM) < 0) {
                                                    fig = true;
                                                }
                                            }
                                            if (fig) {
                                                SchedulerTask.log.warn("推送信息给工作台");
                                                msg.put("title", (Object)"离开工作票区域超时告警");
                                                final String enter_msg = "工作票负责人:" + workleader.get(0).get("name") + "离开" + fencePositionList.get(l).getFname() + "\u56f4\u680f\uff0c\u65f6\u95f4" + l2 + "\u5206\u949f";
                                                msg.put("msg", (Object)enter_msg);
                                                message.put("message", (Object)msg.toString());
                                                SchedulerTask.log.warn("gengxin");
                                                this.detectService.updateFenceAlarmCount(fencePositionList.get(l).getWorkId());
                                                SchedulerTask.log.warn("gengxinwanchen");
                                                SchedulerTask.log.warn("工作票负责人告警前");
                                                this.pushMessage(list.get(j2).getUserId(), dzzzUrl, imUrl, tenantId, params, headers, template, configMap, message);
                                                SchedulerTask.log.warn("工作票负责人告警后");
                                            }
                                        }
                                        catch (Exception e5) {
                                            e5.printStackTrace();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (info != null) {
                        SchedulerTask.log.warn("1");
                        if (flag2.equals("t") && mark2) {
                            SchedulerTask.log.warn("2");
                            if (!isExist) {
                                SchedulerTask.log.warn("3");
                                if (list.get(j2).getType().equals("UWB") && !fencePositionList.get(l).getType().equals("temp")) {
                                    final Information entryinfo = this.detectService.selectPosition(userId2, fencePositionList.get(l).getWorkId());
                                    SchedulerTask.log.warn("固定围栏进入记录" + entryinfo.toString());
                                    Date entrydata = null;
                                    try {
                                        entrydata = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(entryinfo.getStartTime());
                                    }
                                    catch (Exception e6) {
                                        SchedulerTask.log.warn(e6.toString());
                                        e6.printStackTrace();
                                    }
                                    SchedulerTask.log.warn("时间判断" + (System.currentTimeMillis() - entrydata.getTime() > 20000L) + (System.currentTimeMillis() - entrydata.getTime() < 25000L));
                                    SchedulerTask.log.warn(this.cmap.toString());
                                    if (System.currentTimeMillis() - entrydata.getTime() > 20000L) {
                                        synchronized (this.mux) {
                                            final int a = l;
                                            final int b = j2;
                                            if (this.cmap.containsKey(userId2)) {
                                                this.cmap.remove(list.get(b).getUserId());
                                                SchedulerTask.log.warn("固定围栏进入超过1分钟");
                                                msg.put("title", (Object)"异常进入告警");
                                                final String quit_msg = "未授权人" + list.get(b).getUserName() + "进入" + fencePositionList.get(a).getFname();
                                                msg.put("msg", (Object)quit_msg);
                                                message.put("message", (Object)msg.toString());
                                                SchedulerTask.log.warn("推送标签前" + msg.toString());
                                                final Object uwbBody = this.remoteController.sendMessageToUWB(list.get(b).getShopId(), list.get(b).getUserId(), Integer.valueOf(0), "BELL_VIBRATE");
                                                SchedulerTask.log.warn("推送标签后");
                                                SchedulerTask.log.warn("uwp固定围栏报警开始");
                                                SchedulerTask.log.warn("更新预警次数" + fencePositionList.get(a).getWorkId());
                                                this.detectService.updateFenceAlarmCount(fencePositionList.get(a).getWorkId());
                                                SchedulerTask.log.warn("更新预警次数完成");
                                                this.pushCommonMessage(list.get(b).getUserId(), dzzzUrl, imUrl, tenantId, params, headers, template, configMap, message);
                                                SchedulerTask.log.warn("uwp固定围栏报警结束");
                                                SchedulerTask.log.warn("cmap清除" + list.get(b).getUserId());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else {
                            if (this.cmap.contains(userId2)) {
                                this.cmap.remove(userId2);
                            }
                            SchedulerTask.log.warn(this.cmap.toString());
                            this.detectService.changeStatus(userId2, fencePositionList.get(l).getWorkId());
                            SchedulerTask.log.warn("改变状态" + userId2.toString());
                            information.setUserId(list.get(j2).getUserId());
                            information.setUserName(list.get(j2).getUserName());
                            information.setWtId(fencePositionList.get(l).getWorkId());
                            information.setStartTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()).toString());
                            information.setName(fencePositionList.get(l).getFname());
                            information.setFence_type(fencePositionList.get(l).getType());
                            information.setStatus("out");
                            final String json = JSON.toJSONString((Object)information);
                            SchedulerTask.log.warn("out\u8c03\u7528" + information.toString());
                            this.detectService.insertInfo(information);
                            if (fencePositionList.get(l).getType().equals("temp")) {
                                final HttpEntity<MultiValueMap<String, String>> request = (HttpEntity<MultiValueMap<String, String>>)new HttpEntity((Object)json, (MultiValueMap)header);
                                template.postForEntity(url, (Object)request, (Class)String.class, new Object[0]);
                            }
                        }
                    }
                }
            }
        }
        else {
            this.detectService.delAllFencePersonRel();
        }
    }
 
 
    public void pushMessage(final String userid, final String dzzzUrl, final String imUrl, final String tenantId, final MultiValueMap<String, String> params, final HttpHeaders headers, final RestTemplate template, final Map<String, Object> configMap, final JSONObject message) {
        final StringBuilder recipent = new StringBuilder(message.get((Object)"recipient").toString());
        final List<Map> zhurenlist = (List<Map>)this.detectService.selectDepartDeputyDirectorByStaffid(userid);
        if (',' != recipent.charAt(recipent.length() - 1)) {
            recipent.append(",");
        }
        for (final Map zhuren : zhurenlist) {
            recipent.append(zhuren.get("id")).append(",");
        }
        SchedulerTask.log.warn("recip" + recipent.toString());
        SchedulerTask.log.warn("当值值长");
        SchedulerTask.log.warn("configMap" + configMap.toString());
        final String dzzzresponse = (String)template.getForObject(dzzzUrl, (Class)String.class, new Object[0]);
        final JSONObject json = JSONObject.parseObject(dzzzresponse);
        SchedulerTask.log.warn(dzzzresponse.toString());
        SchedulerTask.log.warn(json.getJSONObject("data").getString("id"));
        //System.out.println(json.getJSONObject("data").getString("id"));
        if (',' == recipent.charAt(recipent.length() - 1)) {
            recipent.append(json.getJSONObject("data").getString("id"));
        }
        else {
            recipent.append(',' + json.getJSONObject("data").getString("id"));
        }
        message.put("recipient", recipent.toString());
        params.add("message", message.toString());
        final HttpEntity<MultiValueMap<String, String>> httpEntity = (HttpEntity<MultiValueMap<String, String>>)new HttpEntity((Object)params, (MultiValueMap)headers);
        SchedulerTask.log.warn("推送参数" + params.toString());
        SchedulerTask.log.warn("推送实体httpEnitty", (Object)httpEntity.toString());
        final ResponseEntity responseEntity = template.postForEntity(imUrl + "/oapi/message/sendworkmsg?tenantId=" + tenantId, (Object)httpEntity, (Class)String.class, new Object[0]);
        SchedulerTask.log.warn("推送结果" + responseEntity.toString());
    }
 
    public void pushCommonMessage(final String userid, final String dzzzUrl, final String imUrl, final String tenantId, final MultiValueMap<String, String> params, final HttpHeaders headers, final RestTemplate template, final Map<String, Object> configMap, final JSONObject message) {
        final StringBuilder recipent = new StringBuilder(message.get((Object)"recipient").toString());
        if (',' != recipent.charAt(recipent.length() - 1)) {
            recipent.append(",");
        }
        final List<Map> zhurenlist = (List<Map>)this.detectService.selectDepartDeputyDirectorByStaffid(userid);
        for (final Map zhuren : zhurenlist) {
            recipent.append(zhuren.get("id")).append(",");
        }
        SchedulerTask.log.warn("recip" + recipent.toString());
        SchedulerTask.log.warn("当值值长");
        SchedulerTask.log.warn("configMap" + configMap.toString());
        final List<Map> outlist = (List<Map>)this.outService.selectExternPeople(userid);
        for (final Map map : outlist) {
            recipent.append(map.get("PRO_LEADER").toString() + ",");
        }
        final String dzzzresponse = (String)template.getForObject(dzzzUrl, (Class)String.class, new Object[0]);
        final JSONObject json = JSONObject.parseObject(dzzzresponse);
        SchedulerTask.log.warn(dzzzresponse.toString());
        SchedulerTask.log.warn(json.getJSONObject("data").getString("id"));
        //System.out.println(json.getJSONObject("data").getString("id"));
        if (',' == recipent.charAt(recipent.length() - 1)) {
            recipent.append(json.getJSONObject("data").getString("id"));
        }
        else {
            recipent.append(',' + json.getJSONObject("data").getString("id"));
        }
        message.put("recipient", recipent.toString());
        params.add("message", message.toString());
        final HttpEntity<MultiValueMap<String, String>> httpEntity = (HttpEntity<MultiValueMap<String, String>>)new HttpEntity((Object)params, (MultiValueMap)headers);
        SchedulerTask.log.warn("推送参数" + params.toString());
        SchedulerTask.log.warn("推送实体httpEnitty", (Object)httpEntity.toString());
        final ResponseEntity responseEntity = template.postForEntity(imUrl + "/oapi/message/sendworkmsg?tenantId=" + tenantId, (Object)httpEntity, (Class)String.class, new Object[0]);
        SchedulerTask.log.warn("推送结果" + responseEntity.toString());
    }
 
//    @Scheduled(fixedRate = 5000L)
    public void changeFenceStatus() {
        final List<FencePosition> fencePositions = (List<FencePosition>)this.detectService.getTempFenceInfo();
        for (final FencePosition fencePosition : fencePositions) {
            if (!StringUtils.isEmpty((Object)fencePosition.getStarttime()) && StringUtils.isEmpty((Object)fencePosition.getDisabledtime())) {
                if (SchedulerTask.dateFormat.format(new Date()).compareTo(fencePosition.getStarttime()) >= 0) {
                    this.detectService.setFenceEnabledByStartTime(fencePosition.getWorkId());
                }
                else {
                    this.detectService.setFenceDisabled(fencePosition.getWorkId());
                }
            }
            else if (!StringUtils.isEmpty((Object)fencePosition.getStarttime()) && !StringUtils.isEmpty((Object)fencePosition.getDisabledtime())) {
                if (SchedulerTask.dateFormat.format(new Date()).compareTo(fencePosition.getDisabledtime()) <= 0 && SchedulerTask.dateFormat.format(new Date()).compareTo(fencePosition.getStarttime()) >= 0) {
                    this.detectService.setFenceEnabled(fencePosition.getWorkId());
                }
                else {
                    if (SchedulerTask.dateFormat.format(new Date()).compareTo(fencePosition.getDisabledtime()) < 0 && SchedulerTask.dateFormat.format(new Date()).compareTo(fencePosition.getStarttime()) > 0) {
                        continue;
                    }
                    this.detectService.setFenceDisabled(fencePosition.getWorkId());
                }
            }
            else {
                if (!StringUtils.isEmpty((Object)fencePosition.getStarttime())) {
                    continue;
                }
                this.detectService.setFenceDisabled(fencePosition.getWorkId());
            }
        }
    }
 
//    @Scheduled(fixedRate = 60000L)
    public void setRecipients() {
        final List<Recipients> recipients_list = (List<Recipients>)this.infoSynchService.selectRecipients();
        final List<Recipients> recipients = (List<Recipients>)this.infoSynchService.getRecipients();
        for (final Recipients recipient : recipients_list) {
            if (!recipients.contains(recipient)) {
                this.infoSynchService.setRecipients(recipient);
            }
        }
    }
 
    public void setPermissions() {
        final List<Permissions> permissions_list = (List<Permissions>)this.infoSynchService.selectPermissions();
        final List<Permissions> permissions = (List<Permissions>)this.infoSynchService.getPermissions();
        for (final Permissions permission : permissions_list) {
            if (!permissions.contains(permission)) {
                this.infoSynchService.setPermissions(permission);
            }
        }
    }
 
//    @Scheduled(fixedRate = 300000L)
    public void setWhiteList() {
        final List<Fence_User> list = (List<Fence_User>)this.infoSynchService.selectWhiteList();
        final List<FencePosition> fenceList = (List<FencePosition>)this.detectService.getFixedFenceInfo();
        for (int i = 0; i < fenceList.size(); ++i) {
            final String workId = fenceList.get(i).getWorkId();
            for (final Fence_User user : list) {
                user.setWorkId(workId);
                final Fence_User fence_user = this.infoSynchService.selectUniqueInfo(user);
                if (fence_user == null) {
                    this.infoSynchService.insertWhiteList(user);
                }
            }
        }
    }
 
   //@Scheduled(fixedRate = 5000L)
    public void test() {
        SchedulerTask.locationEnable = this.configInfo.getLocationEnable();
        if (SchedulerTask.locationEnable == 1) {
            final Map<String, Object> map = new HashMap<String, Object>();
            if (SchedulerTask.personlocationentity != null) {
                map.put("list", SchedulerTask.personlocationentity);
            }
            try {
                WebSocketServer.BroadCastInfo(JSONObject.toJSONString((Object)map));
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
    public static void main(final String[] args) {
    }
 
    static {
        SchedulerTask.log = LoggerFactory.getLogger((Class)SchedulerTask.class);
        SchedulerTask.personlocationentity = null;
        dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    }
}