Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
package com.gk.firework.Api;
 
 
import com.gk.firework.Scheduls.WarningTask.MessageSendTask;
import io.swagger.annotations.Api;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
@Api(tags = "Api接口数据接口")
@RestController
@RequestMapping("/api")
public class ApiController {
    @Value("${filePath}")
    private String filePath; //配置文件配置的物理保存地址
    @Value("${fileurl}")
    private String fileurl;
    private Logger logger = LogManager.getLogger(MessageSendTask.class);
 
//    @Autowired
//    private SmsLogService smsLogService;
 
 
//    //在android上传图片后返回url
//    @ApiOperation(value = "公众号上保存插座监测数据",notes = "传入实验室以及电源极性数据")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query",name = "operator",value = "操作人"),
//            @ApiImplicitParam(paramType="query",name = "number",value = "场所条码",required = true),
//            @ApiImplicitParam(paramType="query",name = "name",value = "场所名称"),
//            @ApiImplicitParam(paramType="query",name = "location",value = "具体地点"),
//            @ApiImplicitParam(paramType="query",name = "houseType",value = "实验室类型"),
//            @ApiImplicitParam(paramType="query",name = "manager",value = "实验室负责人" ),
//            @ApiImplicitParam(paramType="query",name = "safer",value = "实验室安全员"),
//            @ApiImplicitParam(paramType="query",name = "polarity",value = "电源极性数组"),
//            @ApiImplicitParam(paramType="query",name = "list",value = "插座个数"),
//            @ApiImplicitParam(paramType="query",name = "picpath",value = "首张图片"),
//            @ApiImplicitParam(paramType="query",name = "signature",value = "签名",required = true),
//    })
//    @PostMapping("/mobile/putpolarityUrl")
//    @ResponseBody
//    public Msg PutPolarityUrl(
//            String operator, String number, String name, String location,
//            String  houseType, String manager, String safer, String polarity,
//            String list,String signature,String picpath,String picList){
//        Msg msg = new Msg();
//        msg.setCode("404");
//        if (StringUtils.isNotBlank(signature) && signature.equals("7DAD4D03150E978F88F9F66F6F01EB68")){
//            PolarityInfo polarityInfo = new PolarityInfo();
//            if (StringUtils.isBlank(number)){
//                msg.setMessage("场所条码不能为空");
//                return msg;
//            }else {
//                polarityInfo.setNumber(number);
//            }
//            polarityInfo.setName(name);
//            polarityInfo.setLocation(location);
//            polarityInfo.setHousetype(houseType);
//            polarityInfo.setManager(manager);
//            polarityInfo.setSafer(safer);
//            polarityInfo.setOperator(operator);
//            polarityInfo.setUpdatetime(new Date());
//
//            int n = 1;
//            List<String> polarityList = new ArrayList<>();
//            if (StringUtils.isNotBlank(polarity)){
//                polarityList = StringUtils.toList(polarity);
//            }
//            if (StringUtils.isNotBlank(list)) {
//                String[] str = list.split(",");
//                n += str.length;
//            }
//
//            List<PolarityDetailInfo> polarityDetailInfoList = new ArrayList<>();
//            String advice = "";
//            //判断火地零的灯分别显示了哪个,根据不同的灯给出不同的建议
//            //n为插座个数,polarityList存入1-1,2-3,表示那盏灯亮,前缀表示第几排,后缀表示第几个灯亮
//            for (int i = 1; i <= n; i++){
//                PolarityDetailInfo polarityDetailInfo = new PolarityDetailInfo();
//                polarityDetailInfo.setLinea((byte)0);
//                polarityDetailInfo.setLineb((byte)0);
//                polarityDetailInfo.setLinec((byte)0);
//
//                if (i == 1){
//                    polarityDetailInfo.setPicname(picpath);
//                }else {
//                    String pic = "pic-"+i;
//                    String[] picListstr = picList.split(",");
//                    for (String picstr : picListstr){
//                        String[] picArray = picstr.split(";");
//                        if (picArray[0].equals(pic)){
//                            polarityDetailInfo.setPicname(picArray[1]);
//                        }
//                    }
//                }
//
//                List<String> tempList = new ArrayList<> ();
//                for (String str : polarityList){
//                    if (str.startsWith(i+"-")){
//                        tempList.add(str.substring(str.length() - 1));
//                    }
//                }
//
//                //极性只有0灯、1灯、2灯,截取最后一位数 表示第几盏灯亮
//                if (tempList.size() > 0){
//                    if (tempList.size() == 1){
//                        if (tempList.get(0).equals("1")){
//                            advice += PolarityStatus.a;
//                            polarityDetailInfo.setLinea((byte)1);
//                        }else if (tempList.get(0).equals("3")){
//                            advice += PolarityStatus.c;
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                    }else if (tempList.size() == 2) {
//                        if ((tempList.get(0).equals("1") && tempList.get(1).equals("2"))
//                                || (tempList.get(0).equals("2") && tempList.get(1).equals("1"))){
//                            advice += PolarityStatus.ab;
//                            polarityDetailInfo.setLinea((byte)1);
//                            polarityDetailInfo.setLineb((byte)1);
//                        }
//                        if ((tempList.get(0).equals("1") && tempList.get(1).equals("3"))
//                                || (tempList.get(0).equals("3") && tempList.get(1).equals("1"))){
//                            advice += PolarityStatus.ac;
//                            polarityDetailInfo.setLinea((byte)1);
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                        if ((tempList.get(0).equals("2") && tempList.get(1).equals("3"))
//                                || (tempList.get(0).equals("3") && tempList.get(1).equals("2"))){
//                            advice += PolarityStatus.bc;
//                            polarityDetailInfo.setLineb((byte)1);
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                    }
//                }else {
//                    advice += PolarityStatus.none;
//                }
//
//                polarityDetailInfoList.add(polarityDetailInfo);
//            }
//            if (advice.length()> 255){
//                advice = advice.substring(0, 255);
//            }
//            polarityInfo.setAdvice(advice);
//            //查找是否存在该场所的信息,如果存在则更新,否则删除
//            PolarityInfo polarityInfoExist = polarityService.selectByNumber(number);
//            if (null != polarityInfoExist){
//                polarityInfo.setId(polarityInfoExist.getId());
//                polarityService.updateById(polarityInfo);
//            }else {
//                polarityService.save(polarityInfo);
//            }
//            //删除该场所历史的电源极性明细,重新插入数据
//            polarityDetailService.deleteByPid(polarityInfo.getId());
//            for (PolarityDetailInfo detailInfo : polarityDetailInfoList){
//                detailInfo.setPid(polarityInfo.getId());
//                detailInfo.setOperator(operator);
//                detailInfo.setUpdatetime(new Date());
//                polarityDetailService.save(detailInfo);
//            }
//        }
//        else {
//            msg.setMessage("签名错误");
//            return msg;
//        }
//        msg.setCode("200");
//        msg.setMessage("success");
//        return msg;
//    }
//
////   在vant上传图片
//    @ApiOperation(value = "公众号上保存插座监测数据",notes = "传入实验室以及电源极性数据")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query",name = "operator",value = "操作人"),
//            @ApiImplicitParam(paramType="query",name = "number",value = "场所条码",required = true),
//            @ApiImplicitParam(paramType="query",name = "name",value = "场所名称"),
//            @ApiImplicitParam(paramType="query",name = "location",value = "具体地点"),
//            @ApiImplicitParam(paramType="query",name = "houseType",value = "实验室类型"),
//            @ApiImplicitParam(paramType="query",name = "manager",value = "实验室负责人" ),
//            @ApiImplicitParam(paramType="query",name = "safer",value = "实验室安全员"),
//            @ApiImplicitParam(paramType="query",name = "polarity",value = "电源极性数组"),
//            @ApiImplicitParam(paramType="query",name = "list",value = "插座个数"),
//            @ApiImplicitParam(paramType="query",name = "picpath",value = "首张图片"),
//            @ApiImplicitParam(paramType="query",name = "signature",value = "签名",required = true),
//    })
//    @PostMapping("/mobile/putpolarity")
//    @ResponseBody
//    public Msg PutPolarity(
//            String operator, String number, String name, String location,
//            String  houseType, String manager, String safer, String polarity,
//            String list,String signature,MultipartFile picpath,StandardMultipartHttpServletRequest req)throws Exception{
//        Msg msg = new Msg();
//        msg.setCode("404");
//        if (StringUtils.isNotBlank(signature) && signature.equals("7DAD4D03150E978F88F9F66F6F01EB68")){
//            PolarityInfo polarityInfo = new PolarityInfo();
//            if (StringUtils.isBlank(number)){
//                msg.setMessage("场所条码不能为空");
//                return msg;
//            }else {
//                polarityInfo.setNumber(number);
//            }
//            polarityInfo.setName(name);
//            polarityInfo.setLocation(location);
//            polarityInfo.setHousetype(houseType);
//            polarityInfo.setManager(manager);
//            polarityInfo.setSafer(safer);
//            polarityInfo.setOperator(operator);
//            polarityInfo.setUpdatetime(new Date());
//
//            int n = 1;
//            List<String> polarityList = new ArrayList<>();
//            if (StringUtils.isNotBlank(polarity)){
//                polarityList = StringUtils.toList(polarity);
//            }
//            if (StringUtils.isNotBlank(list)) {
//                String[] str = list.split(",");
//                n += str.length;
//            }
//
//            List<PolarityDetailInfo> polarityDetailInfoList = new ArrayList<>();
//            String advice = "";
//            //判断火地零的灯分别显示了哪个,根据不同的灯给出不同的建议
//            //n为插座个数,polarityList存入1-1,2-3,表示那盏灯亮,前缀表示第几排,后缀表示第几个灯亮
//            for (int i = 1; i <= n; i++){
//                PolarityDetailInfo polarityDetailInfo = new PolarityDetailInfo();
//                polarityDetailInfo.setLinea((byte)0);
//                polarityDetailInfo.setLineb((byte)0);
//                polarityDetailInfo.setLinec((byte)0);
//
//                if (i == 1){
//                    String picmame = UploadUtil.uploadFile(picpath,filePath);
//                    polarityDetailInfo.setPicname(fileurl+picmame);
//                }else {
//                    String pic = "pic-"+i;
//                    MultiValueMap<String, MultipartFile> multipartFiles = req.getMultiFileMap();
//                    MultipartFile  picFile = multipartFiles.get(pic).get(0);
//                    String picmame = UploadUtil.uploadFile(picFile,filePath);
//                    polarityDetailInfo.setPicname(fileurl+picmame);
//                }
//
//                List<String> tempList = new ArrayList<> ();
//                for (String str : polarityList){
//                    if (str.startsWith(i+"-")){
//                        tempList.add(str.substring(str.length() - 1));
//                    }
//                }
//
//                //极性只有0灯、1灯、2灯,截取最后一位数 表示第几盏灯亮
//                if (tempList.size() > 0){
//                    if (tempList.size() == 1){
//                        if (tempList.get(0).equals("1")){
//                            advice += PolarityStatus.a;
//                            polarityDetailInfo.setLinea((byte)1);
//                        }else if (tempList.get(0).equals("3")){
//                            advice += PolarityStatus.c;
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                    }else if (tempList.size() == 2) {
//                        if ((tempList.get(0).equals("1") && tempList.get(1).equals("2"))
//                                || (tempList.get(0).equals("2") && tempList.get(1).equals("1"))){
//                            advice += PolarityStatus.ab;
//                            polarityDetailInfo.setLinea((byte)1);
//                            polarityDetailInfo.setLineb((byte)1);
//                        }
//                        if ((tempList.get(0).equals("1") && tempList.get(1).equals("3"))
//                                || (tempList.get(0).equals("3") && tempList.get(1).equals("1"))){
//                            advice += PolarityStatus.ac;
//                            polarityDetailInfo.setLinea((byte)1);
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                        if ((tempList.get(0).equals("2") && tempList.get(1).equals("3"))
//                                || (tempList.get(0).equals("3") && tempList.get(1).equals("2"))){
//                            advice += PolarityStatus.bc;
//                            polarityDetailInfo.setLineb((byte)1);
//                            polarityDetailInfo.setLinec((byte)1);
//                        }
//                    }
//                }else {
//                    advice += PolarityStatus.none;
//                }
//
//                polarityDetailInfoList.add(polarityDetailInfo);
//            }
//            if (advice.length()> 255){
//                advice = advice.substring(0, 255);
//            }
//            polarityInfo.setAdvice(advice);
//            //查找是否存在该场所的信息,如果存在则更新,否则删除
//            PolarityInfo polarityInfoExist = polarityService.selectByNumber(number);
//            if (null != polarityInfoExist){
//                polarityInfo.setId(polarityInfoExist.getId());
//                polarityService.updateById(polarityInfo);
//            }else {
//                polarityService.save(polarityInfo);
//            }
//            //删除该场所历史的电源极性明细,重新插入数据
//            polarityDetailService.deleteByPid(polarityInfo.getId());
//            for (PolarityDetailInfo detailInfo : polarityDetailInfoList){
//                detailInfo.setPid(polarityInfo.getId());
//                detailInfo.setOperator(operator);
//                detailInfo.setUpdatetime(new Date());
//                polarityDetailService.save(detailInfo);
//            }
//        }
//        else {
//            msg.setMessage("签名错误");
//            return msg;
//        }
//        msg.setCode("200");
//        msg.setMessage("success");
//        return msg;
//    }
//
//
//    @ApiOperation(value = "上传图片",notes = "上传图片")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query",name = "picpath",value = "文件"),
//    })
//    @PostMapping("/mobile/uploadPic")
//    @ResponseBody
//    public Msg uploadPic(StandardMultipartHttpServletRequest req){
//        Msg msg = new Msg();
//        msg.setCode("200");
//        msg.setMessage("success");
//
//        MultiValueMap<String, MultipartFile> multipartFiles = req.getMultiFileMap();
//        MultipartFile  picFile = multipartFiles.get("files").get(0);
//        if (null == picFile){
//            msg.setCode("404");
//            msg.setMessage("上传文件为空");
//        }else {
//            try {
//                String picmame = UploadUtil.uploadFile(picFile,filePath);
//                msg.setResult(fileurl+picmame);
//            }catch (Exception e){
//                e.printStackTrace();
//                msg.setCode("500");
//                msg.setMessage("上传失败");
//            }
//        }
//        return msg;
//    }
//
//
//    @ApiOperation(value = "发送报警短信",notes = "每天每个手机号只能发20个")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query",name = "head",value = "系统名称",required = true),
//            @ApiImplicitParam(paramType="query",name = "telnumber",value = "手机号码以英文,分隔",required = true),
//            @ApiImplicitParam(paramType="query",name = "content",value = "报警内容",required = true),
//            @ApiImplicitParam(paramType="query",name = "signature",value = "签名",required = true),
//    })
//    @PostMapping("/sendmessage")
//    @ResponseBody
//    public Msg SendMessage(
//            String head,String telnumber,String content,String signature)throws Exception{
//        Msg msg = new Msg();
//        if (StringUtils.isNotBlank(signature) && signature.equals("4E85FE3F203915AC358A92205814D043")){
//            boolean issend = sendMessage(head,telnumber,content);
//            if (!issend){
//                msg.setCode("400");
//                msg.setMessage("发送短信失败,超出日发送条数");
//                return msg;
//            }
//        }
//        else {
//            msg.setCode("500");
//            msg.setMessage("签名错误");
//            return msg;
//        }
//        msg.setCode("200");
//        msg.setMessage("success");
//        return msg;
//    }
//
//    public Boolean sendMessage(String head,String telnumber,String content) throws UnsupportedEncodingException {
//        String url ="http://v.juhe.cn/sms/send";//请求接口地址
//        String tpl_id = "222840";
//        String dtype = "json";
//        String key = "f89279278b739f972ed922fa708eafa0";
//        String tpl_value = URLEncoder.encode("#name#=" + head + "&#code#=" + content,"utf-8");
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        SimpleDateFormat sdfstart = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
//        SimpleDateFormat sdfend = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
//        Date now = new Date();
//        String starttime  = sdfstart.format(now);
//        String endtime = sdfend.format(now);
//
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(now);
//        calendar.add(Calendar.HOUR_OF_DAY, -1);
//        Date onehour = calendar.getTime();
//        String onehourstart = sdf.format(onehour);
//        String onehourend = sdf.format(now);
//
//        boolean issend = false;
//        List<String> mobiles = StringUtils.toList(telnumber);
//        for (String mobile : mobiles) {
//            /**运营商限制同1个号码同1个签名的内容1分钟内只能接收1条,10分钟3条,1小时内4条,一天20条,否则可能会被运营商屏蔽**/
//            SmsLogInfo smsLogInfo = smsLogService.selectByTel(mobile,starttime,endtime,(byte)2);
//            if (null != smsLogInfo && smsLogInfo.getTimes()>=20){
//                logger.error("手机号:" + mobile + ",在时间为" + sdf.format(now) + ",当天已发出20条,无法继续发送");
//                continue;
//            }
//            SmsLogInfo smsLogInfoHour = smsLogService.selectByTel(mobile,onehourstart,onehourend,(byte)1);
//            if (null != smsLogInfoHour && smsLogInfoHour.getTimes()>=4){
//                logger.error("手机号:" + mobile + ",在时间为" + sdf.format(now) + ",本小时已发出4条,无法继续发送");
//                continue;
//            }
//            String respnse = null;
//            Map params = new HashMap();//请求参数
//            params.put("mobile", mobile);//接收短信的手机号码
//            params.put("tpl_id", tpl_id);//短信模板ID,请参考个人中心短信模板设置
//            params.put("tpl_value", tpl_value);
//            params.put("key", key);//应用APPKEY(应用详细页查询)
//            params.put("dtype", dtype);//返回数据的格式,xml或json,默认json
//            try {
//                respnse = HttpUtils.net(url, params, "GET");
//                JSONObject jsonResult = JSONObject.parseObject(respnse);
//                String errorcode = jsonResult.getString("error_code");
//                String reason = jsonResult.getString("reason");
//                if (errorcode.equals("0")) {
//                    //增加发送次数
//                    JSONObject result = jsonResult.getJSONObject("result");
//                    Integer count = result.getInteger("count");
//                    if (null !=  smsLogInfo){
//                        smsLogInfo.setTimes(smsLogInfo.getTimes()+count);
//                        smsLogService.updateById(smsLogInfo);
//                    }else {
//                        SmsLogInfo smsLogInfo1 = new SmsLogInfo();
//                        smsLogInfo1.setMobile(mobile);
//                        smsLogInfo1.setSendtime(now);
//                        smsLogInfo1.setTimes(count);
//                        smsLogInfo1.setType((byte)2);
//                        smsLogService.save(smsLogInfo1);
//                    }
//                    issend = true;
//                    if (null !=  smsLogInfoHour){
//                        smsLogInfoHour.setTimes(smsLogInfoHour.getTimes()+count);
//                        smsLogService.updateById(smsLogInfoHour);
//                    }else {
//                        SmsLogInfo smsLogInfo1 = new SmsLogInfo();
//                        smsLogInfo1.setMobile(mobile);
//                        smsLogInfo1.setSendtime(now);
//                        smsLogInfo1.setTimes(count);
//                        smsLogInfo1.setType((byte)1);
//                        smsLogService.save(smsLogInfo1);
//                    }
//                } else {
//                    logger.error("手机号:" + mobile + ",在时间为" + sdf.format(now) + "发送短信失败,原因为:" + reason);
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//        return issend;
//    }
 
 
//    //根据研究所id显示设备报警和故障个数 get请求
//    @ApiOperation(value = "根据研究所id显示设备报警和故障个数")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query",name = "instituteid",value = "研究所id",required = true),
//            @ApiImplicitParam(paramType="query",name = "appkey",value = "appkey",required = true),
//            @ApiImplicitParam(paramType="query",name = "timestamp",value = "时间戳",required = true),
//            @ApiImplicitParam(paramType="query",name = "signature",value = "签名",required = true),
//    })
//    @GetMapping("/getElectricalWarn")
//    @ResponseBody
//    public Msg getElectricalWarn(@RequestParam String instituteid,@RequestParam String appkey,
//                                 @RequestParam String timestamp,@RequestParam String signature){
//        Msg msg = new Msg();
//        msg.setCode("200");
//        msg.setMessage("success");
//
//        String errorMsg =  validSign(appkey,signature,timestamp);
//        if (StringUtils.isNotBlank(errorMsg)){
//            msg.setCode("500");
//            msg.setMessage(errorMsg);
//            return msg;
//        }
//
//       int yujing = 0;
//       int guzhang = 0;
//
//       SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//       Date now = new Date();
//       Calendar calendar = Calendar.getInstance();
//       calendar.setTime(now);
//       calendar.add(Calendar.MINUTE, -2);
//       Date starttime = calendar.getTime();
//       String starttimeStr = sdf.format(starttime);
//       String endttimeStr = sdf.format(now);
//
//       InstituteInfo instituteInfo = instituteService.getById(instituteid);
//
//       List<String> numberList = electricalHistoryService.getElectricalWarn(starttimeStr,endttimeStr);
//       if (numberList.size() > 0){
//           List<ResearchHouseVo> researchHouseVoList = researchHouseService.selectByNumbers(numberList);
//           for (ResearchHouseVo researchHouseVo : researchHouseVoList){
//               if (researchHouseVo.getInstituteName().equals(instituteInfo.getName())){
//                   yujing ++;
//               }
//           }
//       }
//
//       List<DeviceInfo> deviceInfoList = deviceService.selectByStatusAndInstitute((byte)1);
//       if (deviceInfoList.size() > 0){
//           for (DeviceInfo deviceInfo : deviceInfoList) {
//               if (deviceInfo.getInstitute().equals(instituteInfo.getName())){
//                   guzhang ++;
//               }
//           }
//       }
//
//       Map<String,Object> map = new HashMap<> ();
//       map.put("yujing",yujing);
//       map.put("guzhang",guzhang);
//
//       msg.setResult(map);
//       return msg;
//    }
//
//
//    private String validSign(String appkey,String signature,String timestamp) {
//        String appsecret = "5E84FE3F20N915AC357A92206817D023";
//        if (StringUtils.isBlank(signature)||StringUtils.isBlank(appkey)
//                || StringUtils.isBlank(timestamp)){
//            return "签名不能为空";
//        }
//        if (!appkey.equals("sznms")){
//            return "appkey有误";
//        }
//
//        Long nowtimestamp = System.currentTimeMillis()/1000;
//
//        Integer signtimestamp = Integer.parseInt(timestamp);
//
//        if(Math.abs(nowtimestamp - signtimestamp) > 120)
//        {
//            return "超出时间范围";
//        }
//
//        String sign = MD5Encoder(appkey+appsecret+timestamp,"UTF-8");
//        if (!sign.equals(signature)){
//            return "签名验证失败";
//        }
//        return null;
//    }
//
//    public String MD5Encoder(String s,String charset){
//        try{
//            byte[] btInput = s.getBytes(charset);
//            MessageDigest mdInst = MessageDigest.getInstance("MD5");
//            mdInst.update(btInput);
//
//            byte[] md = mdInst.digest();
//            StringBuffer sb = new StringBuffer();
//            for(int i =0 ;i<md.length;i++)
//            {
//                int val = ((int)md[i]) & 0xff;
//                if(val<16){
//                    sb.append("0");
//                }
//                sb.append(Integer.toHexString(val));
//            }
//            return sb.toString();
//        }
//        catch (Exception e)
//        {
//            return  null;
//        }
//    }
}