|
|
@@ -5,11 +5,15 @@ import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.base.Joiner; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.common.util.CryptUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.HttpUtil; |
|
|
|
import com.ningdatech.pmapi.common.util.RefreshKeyUtil; |
|
|
|
import com.ningdatech.pmapi.irs.manage.AppIrsManage; |
|
|
|
import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO; |
|
|
|
import com.ningdatech.pmapi.irs.model.dto.ForwardDTO; |
|
|
|
import com.ningdatech.pmapi.irs.utils.RefreshTokenUtil; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.IrsApplication; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.NdPiotTasks; |
|
|
@@ -19,6 +23,7 @@ import com.ningdatech.pmapi.projectdeclared.service.INdPiotTasksService; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IrsApplicationService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@@ -27,6 +32,7 @@ import org.springframework.web.client.RestTemplate; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@@ -102,4 +108,36 @@ public class IrsManage { |
|
|
|
log.info(forEntity.getBody()); |
|
|
|
return forEntity.getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 转发IRS请求 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String forward(ForwardDTO dto) { |
|
|
|
try{ |
|
|
|
String url = dto.getUrl(); |
|
|
|
String appkey = dto.getAppKey(); |
|
|
|
long timestamp = System.currentTimeMillis(); |
|
|
|
String requestSecret = dto.getSecret(); |
|
|
|
String sign = CryptUtils.MD5Encode(appkey + requestSecret + timestamp); |
|
|
|
url = url + "?requestTime=" + timestamp + "&sign=" + sign + asUrlParams(dto.getData()); |
|
|
|
log.info("url :{}",url); |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); |
|
|
|
log.info(forEntity.getBody()); |
|
|
|
return forEntity.getBody(); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error("e:" + e); |
|
|
|
} |
|
|
|
return BizConst.OP_FAIL; |
|
|
|
} |
|
|
|
|
|
|
|
public static String asUrlParams(Map<String, Object> source){ |
|
|
|
return Joiner.on("&") |
|
|
|
// 用指定符号代替空值,key 或者value 为null都会被替换 |
|
|
|
.useForNull("") |
|
|
|
.withKeyValueSeparator("=") |
|
|
|
.join(source); |
|
|
|
} |
|
|
|
} |