|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.fzzy.api.entity.ApiConfs; | 
|---|
|  |  |  | import com.fzzy.api.utils.AESUtils; | 
|---|
|  |  |  | import com.fzzy.push.gd2022.dto.GD2022ResponseDto; | 
|---|
|  |  |  | import com.fzzy.push.shjdjw2023.dto.ShjdjwRespDto; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang.StringUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | String rs = ""; | 
|---|
|  |  |  | ShjdjwRespDto responseDto = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String md = AESUtils.encrypt(data, apiConfs.getPublicKey()); | 
|---|
|  |  |  | log.info("---------接口请求地址:" +url+ "----------密文参数:" + md +"---------"); | 
|---|
|  |  |  | connection = (HttpURLConnection) urls.openConnection(); | 
|---|
|  |  |  | connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); | 
|---|
|  |  |  | connection.setDoOutput(true); | 
|---|
|  |  |  | 
|---|
|  |  |  | connection.setConnectTimeout(20000); | 
|---|
|  |  |  | connection.setReadTimeout(30000); | 
|---|
|  |  |  | connection.setRequestMethod("POST"); | 
|---|
|  |  |  | StringBuffer buffer = new StringBuffer(); | 
|---|
|  |  |  | buffer.append(md); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | outputStream = connection.getOutputStream(); | 
|---|
|  |  |  | outputStream.write(buffer.toString().getBytes("UTF-8")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | outputStream.write(data.getBytes("UTF-8")); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | connection.connect(); | 
|---|
|  |  |  | if (connection.getResponseCode() == 200) { | 
|---|
|  |  |  | 
|---|
|  |  |  | log.info("---------接口返回,解析后:" + rs +"---------"); | 
|---|
|  |  |  | responseDto = JSON.parseObject(rs, ShjdjwRespDto.class); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(responseDto == null )   return new ShjdjwRespDto(99,"接口请求发生未知错误"); | 
|---|
|  |  |  | if(responseDto == null )  { | 
|---|
|  |  |  | return new ShjdjwRespDto(99,"接口请求发生未知错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseDto; | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | try { | 
|---|