| | |
| | | package cn.gistack.nky.service.impl; |
| | | |
| | | import cn.gistack.common.utils.CommonUtil; |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.nky.resultpojo.HsybGetFuturePo; |
| | | import cn.gistack.nky.service.IHsybService; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | @Slf4j |
| | | public class HsybServiceImpl implements IHsybService { |
| | | |
| | | private static String ONLINE = "http://10.42.7.148:50001"; |
| | | private static String LOCAL = "https://sk.hubeishuiyi.cn"; |
| | | private static String GET_FUTURE = ONLINE + "/hsybApi/api/fh-admin/skkr/getFuture"; |
| | | private static String GET_FUTURE = "/hsybApi/api/fh-admin/skkr/getFuture"; |
| | | |
| | | private static String AUTHORIZATION = "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJBRE1JTiIsIlVzZXJJZCI6IjEiLCJzY29wZSI6WyJhbGwiXSwiVXNlclJlYWxOYW1lIjoi6LaF57qn566h55CG5ZGYIiwiVXNlclh6cWhkbSI6IjQyMDUiLCJleHAiOjI1MTk3NzIwMTAsImp0aSI6ImExNTcxYzk1LTBkNjMtNDkyYi1iOWEyLTE2ZTIzNTQ5ZTY1ZiIsImNsaWVudF9pZCI6InVzZXItc2VydmljZSJ9.ebNVZrw9LbhKaj2w6RR8b2wccQiDkhvBeq79SxxCK-yWiOlIFqBkotTN4TNJg8umcpyYvLILwvqXWRJhffEtgi25sX2y6MqLIWM4kMZ9d8ptdnSmTpBPhltSiQOM0KFa1kl5nSDCBwYOLn-pESJglam76cjpgZNoC88x3iNHacdiXDItY0rtY85HrQ26uyJu9UovKtmYmZRHsIbGMpDta5Q1p4vfaCIr-YUayDrCweZJiQDEEcOSpWJ7O7RMk3pRkX_4UmPHFzrOI2lMp1jQIhxnSTE7EVAz_4z8h8r46muSkpF54Ic4XSawHKqdSLHx8T05LB0MpvOzWMPS6c1uHA"; |
| | | |
| | |
| | | |
| | | public HsybGetFuturePo apiRequest(String url, String jsonparams) { |
| | | |
| | | // Long param = Long.parseLong(jsonparams); |
| | | System.out.println("请求参数:" + jsonparams); |
| | | // 获取环境 |
| | | String activeProfile = SpringContextUtil.getActiveProfile(); |
| | | if (activeProfile.equals("dev")) { |
| | | url = LOCAL+ url ; |
| | | } |
| | | if (activeProfile.equals("prod")) { |
| | | url = ONLINE+ url ; |
| | | } |
| | | if (activeProfile.equals("test")) { |
| | | url = ONLINE + url; |
| | | } |
| | | |
| | | |
| | | log.info("预测水位请求参数:" + jsonparams); |
| | | // 声明一个header变量 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 设置为json格式 |
| | |
| | | RestTemplate template = new RestTemplate(); |
| | | try { |
| | | HsybGetFuturePo hsybGetFuturePo = template.postForObject(url, httpEntity, HsybGetFuturePo.class); |
| | | System.out.println(hsybGetFuturePo.toString()); |
| | | log.info("预测水位返回结果:" + hsybGetFuturePo.toString()); |
| | | return hsybGetFuturePo; |
| | | } catch (Exception e) { |
| | | System.out.println(e); |