智慧保安后台管理-验收版本
tangzy
2021-07-20 5cdadbb29f95f35b5eabdc733ce60b16d0338037
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
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.information.controller;
 
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
 
import javax.validation.Valid;
 
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.desk.wrapper.NoticeWrapper;
import org.springblade.modules.jurisdiction.service.JurisdictionService;
import org.springblade.modules.jurisdiction.vo.JurisdictionVO;
import org.springblade.modules.member.service.IMemberService;
import org.springblade.modules.shareholder.service.IShareholderService;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserDeptService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.vo.InformationVO;
import org.springblade.modules.information.service.IInformationService;
import org.springblade.core.boot.ctrl.BladeController;
import springfox.documentation.annotations.ApiIgnore;
 
import java.util.*;
 
/**
 * 控制器
 *
 * @author BladeX
 * @since 2021-07-07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/information")
@Api(value = "", tags = "接口")
public class InformationController extends BladeController {
 
    private final IInformationService informationService;
    private final IDeptService iDeptService;
    private final JurisdictionService jurisdictionService;
 
 
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入information")
    public R<Information> detail(Information information) {
        Information detail = informationService.getOne(Condition.getQueryWrapper(information));
        return R.data(detail);
    }
 
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入information")
    public R<IPage<Information>> list(@ApiIgnore @RequestParam Map<String, Object> information, Query query) {
        IPage<Information> pages = informationService.page(Condition.getPage(query), Condition.getQueryWrapper(information, Information.class));
        return R.data(pages);
    }
 
    /**
     * 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入information")
    public R<IPage<Information>> page(Information information, Query query) {
        IPage<Information> pages = informationService.selectInformationPage(Condition.getPage(query), information);
        return R.data(pages);
    }
 
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入information")
    public R save(@Valid @RequestBody Information information) {
        return R.status(informationService.save(information));
    }
 
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入information")
    public R update(@Valid @RequestBody Information information) {
        return R.status(informationService.updateById(information));
    }
 
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入information")
    public R submit(@Valid @RequestBody Information information) {
        return R.status(informationService.saveOrUpdate(information));
    }
 
 
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(String creditcode) {
        informationService.deleteIn(creditcode);
        informationService.deleteSh(creditcode);
        informationService.deleteMe(creditcode);
        return R.success("删除成功");
    }
 
    /**
     * 首页保安公司统计接口
     *
     * @return
     */
    @PostMapping("/SelectCount")
    public R SelectCount() {
        List<Map<Object, String>> list = iDeptService.selectCount();
        List<Map<String, Object>> lists = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            String title = list.get(i).get("title");//部门名称
            String departmentid = String.valueOf(list.get(i).get("jurisdiction"));//部门id
            Map<String, Object> map = new HashMap<String, Object>();
            Map maps = informationService.selectCount(departmentid);
            map.put("name", title);
            map.put("server", maps);
            lists.add(map);
        }
        return R.data(lists);
    }
 
    /**
     * 首页保安持证统计接口
     *
     * @return
     */
    @PostMapping("/SelectCounthold")
    public R SelectCounthold() {
        List<Map<Object, String>> list = iDeptService.selectCount();
        List<Map<String, Object>> lists = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            int cznumber = 0;//总的持证数量
            int wcznumber = 0;//总的未持证数量
            String title = list.get(i).get("title");//部门名称
            Map<String, Object> map = new HashMap<String, Object>();
            Map<Object, Integer> objectStringMap = iDeptService.selectHold(String.valueOf(list.get(i).get("jurisdiction")));
            if (objectStringMap==null) {
                map.put("name", title);
                map.put("cz", cznumber);
                map.put("wcz", wcznumber);
                lists.add(map);
            }
            else {
                cznumber = objectStringMap.get("cz");
                wcznumber = objectStringMap.get("wcz");
                map.put("name", title);
                map.put("cz", cznumber);
                map.put("wcz", wcznumber);
                lists.add(map);
            }
        }
        return R.data(lists);
    }
 
 
    /**
     * 统计保安公司未持证的保安的公司数量
     */
    @PostMapping("/selectInCount")
    public R selectInCount(String jurisdiction,String deptid) {
        List<Map<Object, String>> maps = informationService.selectInCount(jurisdiction,deptid);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("Count",maps.size());
        map.put("List",maps);
        List<Map<String, Object>> lists = new ArrayList<>();
        lists.add(map);
        return R.data(lists);
    }
 
 
    /**
     * 通过辖区查询机构id,然后通过机构id查询当前机构交社保的人数(numj单位已交社保数量;numz单位人员总数)
     */
    @PostMapping("/selectCs")
    public R selectCs(String jurisdiction,String deptid) {
        List<Map<String, Object>> maps = informationService.selectCs(jurisdiction,deptid);
        List<Map<String, Object>> lists = new ArrayList<>();
        List<Map<String, Object>> lists1 = new ArrayList<>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        Integer count=0;
        for (int i=0;i<maps.size();i++){
            Map<String, Object> map = new HashMap<String, Object>();
            //交社保数
            String numjs = maps.get(i).get("numj").toString();
            Integer numj = Integer.parseInt(numjs);
            //单位总人数
            String numzs = maps.get(i).get("numz").toString();
            Integer numz = Integer.parseInt(numzs);
            String deptname = maps.get(i).get("deptname").toString();
            //统计未交社保人数
            int i1 = numz - numj;
            count+=i1;
            map.put("count",i1);
            map.put("name",deptname);
            lists1.add(map);
        }
        map1.put("Count",count);
        map1.put("List",lists1);
        lists.add(map1);
        return R.data(lists);
    }
 
 
    /**
     * 管辖区域下拉
     */
    @PostMapping("/selecttree")
    public R selecttree() {
        List<Map<Object, String>> maps = iDeptService.selectCount();
        return R.data(maps);
    }
 
    /**
     * 管辖区域下拉
     */
    @PostMapping("/lazyTreeJu")
    public R lazyTreeJu() {
        List<JurisdictionVO> jurisdictionVOS = jurisdictionService.lazyTreeJu();
        return R.data(jurisdictionVOS);
    }
 
 
    /**
     * 统计这个月和上个月交社保的人数,以及金额
     * @return
     */
    @PostMapping("/selectTo")
    public R selectTo(String jurisdiction,String deptid) {
        //上个月人数数量
        Integer lnum=0;
        //这个月人数数量
        Integer tnum=0;
        //上个月金额
        Double lmount=0.0;
        //这个月金额
        Double tmount=0.0;
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> lists = new ArrayList<>();
        List<Map<String, Object>> list = informationService.selectTo(jurisdiction,deptid);
        for (int i=0;i<list.size();i++){
            String lastmonths = list.get(i).get("lastmonth").toString();
            Integer lastmonth=Integer.parseInt(lastmonths);
            lnum+=lastmonth;
            String thismouths = list.get(i).get("thismouth").toString();
            Integer thismouth=Integer.parseInt(thismouths);
            tnum+=thismouth;
            String lastamounts = list.get(i).get("lastamount").toString();
            Double lastamount =Double.parseDouble(lastamounts);
            lmount+=lastamount;
            String thisamounts = list.get(i).get("thisamount").toString();
            Double thisamount =Double.parseDouble(thisamounts);
            tmount+=thisamount;
        }
        map.put("lastmonth",lnum);
        map.put("thismouth",tnum);
        map.put("lastamount",lmount);
        map.put("thisamount",tmount);
        lists.add(map);
        return R.data(lists);
    }
 
 
    /**
     * 查询本年所有月份交社保人数
     * @return
     */
    @GetMapping("/queryYearSoil")
    public R queryYearSoil(String jurisdiction,String deptid) {
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        Map<String, String> map = informationService.queryYearSoil(year,jurisdiction,deptid);
        map = (HashMap<String, String>) sortMapBykeyAsc(map) ;//key升序
        return R.data(map);
    }
 
    /**
     * 查询本年所有月份社保金额
     * @return
     */
    @GetMapping("/queryYearAn")
    public R queryYearAn(String jurisdiction,String deptid) {
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        Map<String, String> map = informationService.queryYearAn(year,jurisdiction,deptid);
        map = (HashMap<String, String>) sortMapBykeyAsc(map) ;//key升序
        return R.data(map);
    }
 
 
    /**
     * 公司运营智能统计
     * @return
     */
    @GetMapping("/queryCounts")
    public R queryCounts(String jurisdiction,String deptid) {
        List<Map<String, Object>> lists = new ArrayList<>();
        Integer a=0;
        Integer b=0;
        Integer zca=0;
        Integer zcb=0;
        Integer cza=0;
        Integer czb=0;
        Integer sba=0;
        Integer sbb=0;
        Integer kha=0;
        Integer khb=0;
        Integer pqa=0;
        Integer pqb=0;
        //保安员数量
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> mapzc = new HashMap<String, Object>();
        Map<String, Object> mapcz = new HashMap<String, Object>();
        Map<String, Object> mapsb = new HashMap<String, Object>();
        Map<String, Object> mapkh = new HashMap<String, Object>();
        Map<String, Object> mappq = new HashMap<String, Object>();
        Map<String, Object> mapC = new HashMap<String, Object>();
        List<Map<Object, Integer>> maps = informationService.queryCountB(jurisdiction, deptid);
        for (int i=0;i<maps.size();i++){
            //这个月数量
            a+=maps.get(i).get("thisnum");
            //上个月数量
            b+=  maps.get(i).get("lastnum");
 
        }
        map.put("thisnum",a);
        map.put("lastnum",b);
        mapC.put("baoan",map);
        //正常保安员数量
        List<Map<Object, Integer>> maps1 = informationService.queryCountZc(jurisdiction, deptid);
        for (int i=0;i<maps1.size();i++){
            //这个月数量
            zca+= maps1.get(i).get("thisnum");
            //上个月数量
            zcb+= maps1.get(i).get("lastnum");
        }
        mapzc.put("thisnum",zca);
        mapzc.put("lastnum",zcb);
        mapC.put("zcbaoan",mapzc);
        //持证保安数量
        List<Map<Object, Integer>> maps2 = informationService.queryCountCz(jurisdiction, deptid);
        for (int i=0;i<maps2.size();i++){
            //这个月数量
            cza+=maps2.get(i).get("thisnum");
            //上个月数量
            czb+=  maps2.get(i).get("lastnum");
        }
        mapcz.put("thisnum",cza);
        mapcz.put("lastnum",czb);
        mapC.put("czbaoan",mapcz);
        //缴纳社保数量
        List<Map<Object, Integer>> maps3 = informationService.queryCountSb(jurisdiction, deptid);
        for (int i=0;i<maps3.size();i++){
            //这个月数量
            sba+=maps3.get(i).get("thisnum");
            //上个月数量
            sbb+=maps3.get(i).get("lastnum");
        }
        mapsb.put("thisnum",sba);
        mapsb.put("lastnum",sbb);
        mapC.put("sbbaoan",mapsb);
        //服务客户数量
        List<Map<Object, Integer>> maps4 = informationService.queryCountKh(jurisdiction, deptid);
        for (int i=0;i<maps4.size();i++){
            //这个月数量
            kha+=maps4.get(i).get("thisnum");
            //上个月数量
            khb+=maps4.get(i).get("lastnum");
        }
        mapkh.put("thisnum",kha);
        mapkh.put("lastnum",khb);
        mapC.put("kh",mapkh);
        //保安派遣数量
        List<Map<Object, Integer>> maps5 = informationService.queryCountPq(jurisdiction, deptid);
        for (int i=0;i<maps5.size();i++){
            //这个月数量
            pqa+=maps5.get(i).get("thisnum");
            //上个月数量
            pqb+=maps5.get(i).get("lastnum");
        }
        mappq.put("thisnum",pqa);
        mappq.put("lastnum",pqb);
        mapC.put("paiq",mappq);
        lists.add(mapC);
        return R.data(lists);
    }
 
 
 
    /**
     * 查询本年公司运营智能统计
     * @return
     */
    @GetMapping("/queryYearG")
    public R queryYearG(String jurisdiction,String deptid) {
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        Map<String, Object> mapz = new HashMap<String, Object>();
        Map<String, Object> mapzc1= new HashMap<String, Object>();
        Map<String, Object> mapcz1= new HashMap<String, Object>();
        Map<String, Object> mapsb1= new HashMap<String, Object>();
        List<Map<String, Object>> lists = new ArrayList<>();
        Map<String, String> map = informationService.queryYearZ(year,jurisdiction,deptid);
        map = (HashMap<String, String>) sortMapBykeyAsc(map) ;//key升序
        mapz.put("baoan",map);
        lists.add(mapz);
        //正常保安数量
        Map<String, String> mapzc = informationService.queryYearZc(year,jurisdiction,deptid);
        mapzc = (HashMap<String, String>) sortMapBykeyAsc(mapzc) ;//key升序
        mapzc1.put("zc",mapzc);
        lists.add(mapzc1);
        //保安持证数量
        Map<String, String> mapcz = informationService.queryYearZc(year,jurisdiction,deptid);
        mapcz = (HashMap<String, String>) sortMapBykeyAsc(mapcz) ;//key升序
        mapcz1.put("cz",mapcz);
        lists.add(mapcz1);
        //缴纳社保数
        Map<String, String> mapsb = informationService.queryYearSoil(year,jurisdiction,deptid);
        mapsb = (HashMap<String, String>) sortMapBykeyAsc(mapsb) ;//key升序
        mapsb1.put("sb",mapsb);
        lists.add(mapsb1);
        return R.data(lists);
    }
 
 
    /**
     * 查询本年所有月份的客户数量
     * @return
     */
    @GetMapping("/queryYearKh")
    public R queryYearKh(String jurisdiction,String deptid) {
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        Map<String, String> map = informationService.queryYearKh(year,jurisdiction,deptid);
        map = (HashMap<String, String>) sortMapBykeyAsc(map) ;//key升序
        return R.data(map);
    }
    //升序
    public  static Map<String, String> sortMapBykeyAsc(Map<String, String> oriMap) {
        Map<String, String> sortedMap = new LinkedHashMap<String, String>();
        try {
            if (oriMap != null && !oriMap.isEmpty()) {
                List<Map.Entry<String, String>> entryList = new ArrayList<Map.Entry<String, String>>(oriMap.entrySet());
                Collections.sort(entryList,
                    new Comparator<Map.Entry<String, String>>() {
                        public int compare(Map.Entry<String, String> entry2,
                                           Map.Entry<String, String> entry1) {
                            int value2 = 0, value1 = 0;
                            try {
                                value2 = Integer.parseInt(entry1.getKey());
                                value1 = Integer.parseInt(entry2.getKey());
                            } catch (NumberFormatException e) {
                                value2 = 0;
                                value1 = 0;
                            }
                            return value1 - value2;
                        }
                    });
                Iterator<Map.Entry<String, String>> iter = entryList.iterator();
                Map.Entry<String, String> tmpEntry = null;
                while (iter.hasNext()) {
                    tmpEntry = iter.next();
                    sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
                }
            }
        } catch (Exception e) {
        }
        return sortedMap;
    }
 
}