| | |
| | | package cn.gistack.nky.service.impl; |
| | | |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.nky.resultpojo.DataBigResultPojo; |
| | | import cn.gistack.nky.resultpojo.DataResChildrenPo; |
| | | import cn.gistack.nky.resultpojo.DataResPo; |
| | | import cn.gistack.nky.resultpojo.ZtResultPo; |
| | | import cn.gistack.nky.resultpojo.*; |
| | | import cn.gistack.nky.service.IZtApiService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | |
| | | * 渗流监测 |
| | | */ |
| | | private static final String SL_API ="/services/1234567890ABCDEFGHIJKLMN/monitor/sl/api?res_nm=&cd=&city_cd=&county_cd=&pageNo=1&pageSize=9999"; |
| | | |
| | | private static final String RES_DAM_MONITOR ="/services/1234567890ABCDEFGHIJKLMN/res_dam_monitor/api?province_cd=420000000000&res_nm="; |
| | | private static final String BASE_CD ="/services/1234567890ABCDEFGHIJKLMN/base/cd/api"; |
| | | |
| | | |
| | | int getSyCount = 0; |
| | |
| | | public List<DataResChildrenPo> getSl() { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | return getData(SL_API, "get", params); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResDamMonitorResult> getResDamMonitor() { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | return getResDamMonitorResult(RES_DAM_MONITOR, "get", params); |
| | | } |
| | | |
| | | @Override |
| | | public List<BaseCd> getBaseCd(String resGuid, String type) { |
| | | Map<String, Object> params = new LinkedHashMap<>(); |
| | | String url = BASE_CD + StringUtil.format("?res_cd={}&type={}",resGuid,type); |
| | | // 获取环境 |
| | | 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; |
| | | } |
| | | |
| | | HttpMethod method; |
| | | method = HttpMethod.GET; |
| | | // 声明一个header变量 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 设置apikey |
| | | headers.set("apikey",API_KEY); |
| | | |
| | | HttpEntity<String> httpEntity = new HttpEntity(null, headers); |
| | | log.info("中台请求地址:{}", url); |
| | | RestTemplate template = new RestTemplate(); |
| | | ResponseEntity<ZtResultPo2> ztResultPojoResponseEntity = template.exchange(url, method,httpEntity, ZtResultPo2.class,params); |
| | | List<BaseCd> returnResult = new ArrayList<>(); |
| | | if (ztResultPojoResponseEntity.getStatusCodeValue() == 200) { |
| | | returnResult = ztResultPojoResponseEntity.getBody().getData(); |
| | | } |
| | | return returnResult; |
| | | } |
| | | |
| | | private List<DataResChildrenPo> getData(String url, String type, Map<String, Object> params) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private List<ResDamMonitorResult> getResDamMonitorResult(String url, String type, Map<String, Object> params){ |
| | | |
| | | // 获取环境 |
| | | 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; |
| | | } |
| | | |
| | | |
| | | HttpMethod method; |
| | | if (type.toLowerCase().equals("get".toLowerCase())) { |
| | | method = HttpMethod.GET; |
| | | } else { |
| | | method = HttpMethod.POST; |
| | | } |
| | | // 声明一个header变量 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 设置apikey |
| | | headers.set("apikey",API_KEY); |
| | | |
| | | HttpEntity<String> httpEntity = new HttpEntity(null, headers); |
| | | log.info("中台请求地址:{}", url); |
| | | RestTemplate template = new RestTemplate(); |
| | | ResponseEntity<ZtResult> ztResultPojoResponseEntity = template.exchange(url, method,httpEntity, ZtResult.class,params); |
| | | if (ztResultPojoResponseEntity.getStatusCodeValue() == 200) { |
| | | List<ResDamMonitorResult> resDamMonitorResultList = ztResultPojoResponseEntity.getBody().getResultList(); |
| | | return resDamMonitorResultList; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |