leutu
2024-05-08 543e4eb01ca210b20876e8139cb3d0403d7d065c
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
package com.skyline.electricity.controller;
 
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.*;
import com.skyline.electricity.service.*;
import org.springframework.beans.factory.annotation.*;
import org.apache.commons.lang3.*;
import com.alibaba.fastjson.*;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import com.skyline.electricity.pojo.*;
import java.util.*;
import com.skyline.electricity.utils.*;
import com.skyline.electricity.entity.*;
 
@RequestMapping({ "/infosynch" })
@Controller
@CrossOrigin
public class InfoSynchController
{
    @Autowired
    private InfoSynchService infoSynchService;
    
    @RequestMapping(value = { "/saveOrUpdateOrg" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新组织结构相关信息")
    @ResponseBody
    public Object saveOrUpdateOrg(final String saveOrUpdateOrg) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdateOrg)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String orgInfo = saveOrUpdateOrg.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(orgInfo);
        final SysOrg sysOrg = (SysOrg)jsonObject.toJavaObject((Class)SysOrg.class);
        final SysOrg sog = this.infoSynchService.selectOrgInfoById(sysOrg.getId());
        if (sog == null) {
            final int flag = this.infoSynchService.insertOrgInfo(sysOrg);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updateOrgInfo(sysOrg);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deleteOrgs" }, method = { RequestMethod.POST })
    @ApiOperation("删除组织机构相关信息")
    @ResponseBody
    public Object deleteOrgs(final String deleteOrgs) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deleteOrgs)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] orgs = deleteOrgs.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (orgs.length > 0) {
            for (final String id : orgs) {
                try {
                    this.infoSynchService.deleteOrgs(Integer.parseInt(id));
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/saveOrUpdatePos" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新岗位相关信息")
    @ResponseBody
    public Object saveOrUpdatePos(final String saveOrUpdatePos) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdatePos)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String posInfo = saveOrUpdatePos.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(posInfo);
        final PgPos pgPos = (PgPos)jsonObject.toJavaObject((Class)PgPos.class);
        final PgPos position = this.infoSynchService.selectPosInfoById(pgPos.getId());
        if (position == null) {
            final int flag = this.infoSynchService.insertPosInfo(pgPos);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updatePosInfo(pgPos);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deletePoss" }, method = { RequestMethod.POST })
    @ApiOperation("删除岗位相关信息")
    @ResponseBody
    public Object deletePoss(final String deletePoss) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deletePoss)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] poss = deletePoss.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (poss.length > 0) {
            for (final String id : poss) {
                try {
                    this.infoSynchService.deletePoss(id);
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/saveOrUpdateSpec" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新专业相关信息")
    @ResponseBody
    public Object saveOrUpdateSpec(final String saveOrUpdateSpec) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdateSpec)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String specInfo = saveOrUpdateSpec.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(specInfo);
        final PgSpec pgSpec = (PgSpec)jsonObject.toJavaObject((Class)PgSpec.class);
        final PgSpec spec = this.infoSynchService.selectSpecInfoById(pgSpec.getId());
        if (spec == null) {
            final int flag = this.infoSynchService.insertSpecInfo(pgSpec);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updateSpecInfo(pgSpec);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deleteSpec" }, method = { RequestMethod.POST })
    @ApiOperation("删除专业相关信息")
    @ResponseBody
    public Object deleteSpecs(final String deleteSpecs) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deleteSpecs)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] specs = deleteSpecs.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (specs.length > 0) {
            for (final String id : specs) {
                try {
                    this.infoSynchService.deleteSpec(Integer.parseInt(id));
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/saveOrUpdateUser" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新用户相关信息")
    @ResponseBody
    public Object saveOrUpdateUser(final String saveOrUpdateUser) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdateUser)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String userInfo = saveOrUpdateUser.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(userInfo);
        final SysUser sysUser = (SysUser)jsonObject.toJavaObject((Class)SysUser.class);
        final SysUser user = this.infoSynchService.selectUserInfoById(sysUser.getId());
        if (user == null) {
            final int flag = this.infoSynchService.insertUserInfo(sysUser);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updateUserInfo(sysUser);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deleteUser" }, method = { RequestMethod.POST })
    @ApiOperation("删除用户相关相关信息")
    @ResponseBody
    public Object deleteUsers(final String deleteUsers) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deleteUsers)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] users = deleteUsers.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (users.length > 0) {
            for (final String id : users) {
                try {
                    this.infoSynchService.deleteUser(id);
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/saveOrUpdateDict" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新字典管理信息")
    @ResponseBody
    public Object saveOrUpdateDict(final String saveOrUpdateDict) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdateDict)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String dictInfo = saveOrUpdateDict.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(dictInfo);
        final SysDicts sysDicts = (SysDicts)jsonObject.toJavaObject((Class)SysDicts.class);
        final SysDicts dicts = this.infoSynchService.selectDictInfoById(sysDicts.getId());
        if (dicts == null) {
            final int flag = this.infoSynchService.insertDictInfo(sysDicts);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updateDictInfo(sysDicts);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deleteDicts" }, method = { RequestMethod.POST })
    @ApiOperation("删除字典管理相关信息")
    @ResponseBody
    public Object deleteDicts(final String deleteDicts) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deleteDicts)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] dicts = deleteDicts.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (dicts.length > 0) {
            for (final String id : dicts) {
                try {
                    this.infoSynchService.deleteDicts(id);
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/saveOrUpdateUserPos" }, method = { RequestMethod.POST })
    @ApiOperation("保存或更新用户和岗位关联信息")
    @ResponseBody
    public Object saveOrUpdateUserPos(final String saveOrUpdateUserPos) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)saveOrUpdateUserPos)) {
            rtn.put("code", "-1");
            rtn.put("msg", "参数为空");
            return rtn;
        }
        final String userPosInfo = saveOrUpdateUserPos.replace("[", "").replaceAll("]", "");
        final JSONObject jsonObject = JSONObject.parseObject(userPosInfo);
        final UserPos userPos = (UserPos)jsonObject.toJavaObject((Class)UserPos.class);
        final UserPos up = this.infoSynchService.selectUserPosInfoById(userPos.getId());
        if (up == null) {
            final int flag = this.infoSynchService.insertUserPosInfo(userPos);
            if (flag > 0) {
                rtn.put("msg", "插入数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "插入数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
        else {
            final int flag = this.infoSynchService.updateUserPosInfo(userPos);
            if (flag > 0) {
                rtn.put("msg", "更新数据成功");
                rtn.put("code", "0");
                return rtn;
            }
            rtn.put("msg", "更新数据失败");
            rtn.put("code", "-1");
            return rtn;
        }
    }
    
    @RequestMapping(value = { "/deleteUserPoss" }, method = { RequestMethod.POST })
    @ApiOperation("删除用户和岗位关联信息")
    @ResponseBody
    public Object deleteUserPoss(final String deleteUserPoss) {
        final Map<String, Object> rtn = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)deleteUserPoss)) {
            rtn.put("code", "-1");
            rtn.put("msg", "输入的数据不能为空");
            return rtn;
        }
        final String[] userPoss = deleteUserPoss.split(",");
        rtn.put("code", "0");
        rtn.put("msg", "删除成功");
        if (userPoss.length > 0) {
            for (final String id : userPoss) {
                try {
                    this.infoSynchService.deleteUserPoss(id);
                }
                catch (Exception e) {
                    rtn.put("code", "-1");
                    rtn.put("msg", "删除失败");
                    e.printStackTrace();
                }
            }
            return rtn;
        }
        rtn.put("msg", "输入的数据不能为空");
        rtn.put("code", "-1");
        return rtn;
    }
    
    @RequestMapping(value = { "/addUserToFence" }, method = { RequestMethod.POST })
    @ApiOperation("添加许可人员到固定围栏")
    @ResponseBody
    public Object addUserToFence(final String username, final String org_name, final String mobile, final String workId) {
        final String userId = this.infoSynchService.selectIdByName(username);
        if (StringUtils.isEmpty((CharSequence)userId)) {
            return "人员姓名不存在 请输入正确的员工姓名";
        }
        final Fence_User fu = new Fence_User();
        final Fence_User fence_user = this.infoSynchService.selectUser(username, workId);
        if (fence_user == null) {
            fu.setUsername(username);
            fu.setWorkId(workId);
            fu.setMobile(mobile);
            fu.setOrg_name(org_name);
            fu.setUserId(userId);
            this.infoSynchService.insertFenceUser(fu);
        }
        final SysUser sysUser = this.infoSynchService.getUserInfoById(userId);
        final Map<String, Object> map = new HashMap<String, Object>();
        map.put("userInfo", sysUser);
        return map;
    }
    
    @RequestMapping(value = { "/deleteUserFromFence" }, method = { RequestMethod.POST })
    @ApiOperation("删除固定围栏中的人员")
    @ResponseBody
    public Object deleteUserFromFence(@Param("username") String username, @Param("workId") String workId) {
        String msg = null;
        try {
            this.infoSynchService.deleteFenceUser(username, workId);
            msg = "删除成功";
        }
        catch (Exception e) {
            msg = "删除失败";
            e.printStackTrace();
        }
        return msg;
    }
    
    @RequestMapping(value = { "/getUsersInFence" }, method = { RequestMethod.GET })
    @ApiOperation("获取固定围栏许可的人员")
    @ResponseBody
    public Object getUsersInFence(final String workId) {
        final List<Fence_User> list = (List<Fence_User>)this.infoSynchService.selectUserInFence(workId);
        final WhiteList whiteList = new WhiteList();
        whiteList.setMsg("查询成功");
        whiteList.setCode(0);
        whiteList.setCount(this.infoSynchService.selectWhiteListCount());
        final List<FenceUserDto> fenceUserList = new ArrayList<FenceUserDto>();
        for (final Fence_User fenceUser : list) {
            final FenceUserDto dto = new FenceUserDto();
            dto.setMobile(fenceUser.getMobile());
            dto.setOrg_name(fenceUser.getOrg_name());
            dto.setUsername(fenceUser.getUsername());
            fenceUserList.add(dto);
        }
        whiteList.setData(fenceUserList);
        return whiteList;
    }
    
    @RequestMapping(value = { "/getNameById" }, method = { RequestMethod.POST })
    @ApiOperation("通过人员ID获取人员姓名")
    @ResponseBody
    public Object getNameById(final String userId) {
        final String username = this.infoSynchService.selectNameById(userId);
        return username;
    }
    
    @RequestMapping(value = { "/getUserInfoById" }, method = { RequestMethod.POST })
    @ApiOperation("通过人员ID获取人员信息")
    @ResponseBody
    public Object getUserInfoById(final String userId) {
        final SysUser sysUser = this.infoSynchService.selectUserInfoById(userId);
        return sysUser;
    }
    
    @RequestMapping(value = { "/getAllUserName" }, method = { RequestMethod.POST })
    @ApiOperation("获取所有人员姓名")
    @ResponseBody
    public Object getAllUserName() {
        final List<String> nameList = (List<String>)this.infoSynchService.getAllUserName();
        final Map<String, Object> map = new HashMap<String, Object>();
        map.put("nameList", nameList);
        return map;
    }
    
    @RequestMapping(value = { "/addRecipients" }, method = { RequestMethod.POST })
    @ApiOperation("添加预警信息接受人员")
    @ResponseBody
    public Object addRecipients(final String username, final String org_name, final String mobile) {
        final String userId = this.infoSynchService.selectIdByName(username);
        final List<String> idList = (List<String>)this.infoSynchService.selectAllRecipientsId();
        final Recipients recipients = new Recipients();
        final RecipientsDTO recipientsDTO = new RecipientsDTO();
        final Map<String, Object> map = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)userId)) {
            map.put("msg", "人员姓名不存在 请输入正确的员工姓名");
            return map;
        }
        if (idList.contains(userId)) {
            map.put("msg", "该员工已被添加过 请勿重复添加");
        }
        else {
            recipients.setUser_id(userId);
            recipients.setUsername(username);
            recipients.setOrg_name(org_name);
            recipients.setMobile(mobile);
            this.infoSynchService.setRecipients(recipients);
            recipientsDTO.setOrg_name(org_name);
            recipientsDTO.setMobile(mobile);
            recipientsDTO.setUsername(username);
            map.put("recipient", recipientsDTO);
            map.put("msg", "添加成功");
        }
        return map;
    }
    
    @RequestMapping(value = { "/getRecipients" }, method = { RequestMethod.GET })
    @ApiOperation("获取预警信息接受人员名单")
    @ResponseBody
    public Object getRecipients() {
        RecipientsList recipientsList = null;
        try {
            final List<RecipientsDTO> list = (List<RecipientsDTO>)this.infoSynchService.getRecipientsDTO();
            recipientsList = new RecipientsList();
            recipientsList.setCode(Integer.valueOf(0));
            final Integer count = this.infoSynchService.selectRecipientsCount();
            recipientsList.setCount(count);
            recipientsList.setData((List)list);
            recipientsList.setMsg("查询成功");
        }
        catch (Exception e) {
            recipientsList = new RecipientsList();
            recipientsList.setCode(Integer.valueOf(-1));
            recipientsList.setCount(Integer.valueOf(0));
            recipientsList.setData((List)null);
            recipientsList.setMsg("查询失败");
        }
        return recipientsList;
    }
    
    @RequestMapping(value = { "/deleteRecipients" }, method = { RequestMethod.POST })
    @ApiOperation("删除预警信息接受人员")
    @ResponseBody
    public Object deleteRecipients(final String username) {
        String msg = null;
        try {
            this.infoSynchService.deleteRecipients(username);
            msg = "删除成功";
        }
        catch (Exception e) {
            msg = "删除失败";
            e.printStackTrace();
        }
        return msg;
    }
    
    @RequestMapping(value = { "/addPermissions" }, method = { RequestMethod.POST })
    @ApiOperation("添加权限人员信息")
    @ResponseBody
    public Object addPermissions(final String username, final String org_name, final String mobile) {
        final String userId = this.infoSynchService.selectIdByName(username);
        final List<String> idList = (List<String>)this.infoSynchService.selectAllPermissionsId();
        final Permissions permissions = new Permissions();
        final PermissionsDTO permissionsDTO = new PermissionsDTO();
        final Map<String, Object> map = new HashMap<String, Object>();
        if (StringUtils.isEmpty((CharSequence)userId)) {
            map.put("msg", "人员姓名不存在 请输入正确的员工姓名");
            return map;
        }
        if (idList.contains(userId)) {
            map.put("msg", "该员工已被添加过 请勿重复添加");
        }
        else {
            permissions.setUser_id(userId);
            permissions.setUsername(username);
            permissions.setOrg_name(org_name);
            permissions.setMobile(mobile);
            this.infoSynchService.setPermissions(permissions);
            permissionsDTO.setOrg_name(org_name);
            permissionsDTO.setMobile(mobile);
            permissionsDTO.setUsername(username);
            map.put("permissions", permissionsDTO);
            map.put("msg", "添加成功");
        }
        return map;
    }
    
    @RequestMapping(value = { "/getPermissions" }, method = { RequestMethod.GET })
    @ApiOperation("获取权限人员名单信息")
    @ResponseBody
    public Object getPermissions() {
        PermissionsList permissionsList = null;
        try {
            final List<PermissionsDTO> list = (List<PermissionsDTO>)this.infoSynchService.getPermissionsDTO();
            for (final PermissionsDTO permissionsDTO : list) {
                if (permissionsDTO.getPos_name() == null || permissionsDTO.getPos_name().equals("")) {
                    permissionsDTO.setPos_name("暂无数据");
                }
            }
            permissionsList = new PermissionsList();
            permissionsList.setCode(0);
            final Integer count = this.infoSynchService.selectPermissionsCount();
            permissionsList.setCount(count);
            permissionsList.setData(list);
            permissionsList.setMsg("查询成功");
        }
        catch (Exception e) {
            permissionsList = new PermissionsList();
            permissionsList.setCode(-1);
            permissionsList.setCount(0);
            permissionsList.setData(null);
            permissionsList.setMsg("查询失败");
        }
        return permissionsList;
    }
    
    @RequestMapping(value = { "/deletePermissions" }, method = { RequestMethod.POST })
    @ApiOperation("删除权限人员名单信息")
    @ResponseBody
    public Object deletePermissions(final String username) {
        String msg = null;
        try {
            this.infoSynchService.deletePermissions(username);
            msg = "删除成功";
        }
        catch (Exception e) {
            msg = "删除失败";
            e.printStackTrace();
        }
        return msg;
    }
    
    @RequestMapping(value = { "/initializePermissions" }, method = { RequestMethod.POST })
    @ApiOperation("初始化权限人员名单信息")
    @ResponseBody
    public void initializePermissions() {
        final String posIdList = PropertiesUtil.getProperty("posIdList");
        final String[] idList = posIdList.split(",");
        final List<PosInfo> totalList = new ArrayList<PosInfo>();
        final Permissions permissions = new Permissions();
        for (final String id : idList) {
            List<PosInfo> posInfoList = new ArrayList<PosInfo>();
            posInfoList = (List<PosInfo>)this.infoSynchService.selectPositionInfoById(id);
            for (final PosInfo posInfo : posInfoList) {
                totalList.add(posInfo);
            }
        }
        for (final PosInfo posInfo2 : totalList) {
            permissions.setUser_id(posInfo2.getUser_id());
            permissions.setUsername(posInfo2.getUsername());
            permissions.setPos_name(posInfo2.getPos_name());
            final String mobile = this.infoSynchService.getMobileById(posInfo2.getUser_id());
            permissions.setMobile(mobile);
            final String org_name = this.infoSynchService.getOrgNameById(posInfo2.getUser_id());
            permissions.setOrg_name(org_name);
            this.infoSynchService.setPermissions(permissions);
        }
    }
}