对比新文件 |
| | |
| | | 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; |
| | | // } |
| | | // } |
| | | } |