阿里访问代码移动到统一访问包里

dev_drug_dm
qiuyt 4 months ago
parent 9817cc5d8a
commit abe6c3e635

@ -0,0 +1,14 @@
package com.glxp.api.httpClient.serviceClient;
import cn.hutool.http.HttpUtil;
import com.glxp.api.req.alihealth.AlihealthKytCommonParametersReqeust;
import com.glxp.api.util.alihealth.AlihealthUtils;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import java.util.Map;
public interface AlihealthClient {
String accessAliInterface(AlihealthKytCommonParametersReqeust alihealthKytCommonParametersReqeust, String appSecret);
}

@ -0,0 +1,25 @@
package com.glxp.api.httpClient.serviceClient.impl;
import cn.hutool.http.HttpUtil;
import com.glxp.api.httpClient.serviceClient.AlihealthClient;
import com.glxp.api.req.alihealth.AlihealthKytCommonParametersReqeust;
import com.glxp.api.util.alihealth.AlihealthUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;
@Service
public class AlihealthImpl implements AlihealthClient {
@Resource
private AlihealthUtils alihealthUtils;
@Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}")
private String alihealthUrl;
@Override
public String accessAliInterface(AlihealthKytCommonParametersReqeust alihealthKytCommonParametersReqeust, String appSecret) {
Map map = alihealthUtils.disposeSign(alihealthKytCommonParametersReqeust, appSecret);
String json = HttpUtil.get(alihealthUrl, map);
return json;
}
}

@ -8,6 +8,7 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.AliConstants; import com.glxp.api.constant.AliConstants;
import com.glxp.api.entity.thrsys.ThirdAliDrug; import com.glxp.api.entity.thrsys.ThirdAliDrug;
import com.glxp.api.entity.alihealth.AliKytSearchbill; import com.glxp.api.entity.alihealth.AliKytSearchbill;
import com.glxp.api.httpClient.serviceClient.AlihealthClient;
import com.glxp.api.req.alihealth.AlihealthKytCommonParametersReqeust; import com.glxp.api.req.alihealth.AlihealthKytCommonParametersReqeust;
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.AlihealthKytSearchbillReqeust; import com.glxp.api.req.alihealth.AlihealthKytSearchbillReqeust;
@ -44,29 +45,11 @@ import java.util.*;
@Slf4j @Slf4j
@Component @Component
public class AlihealthUtils { public class AlihealthUtils {
@Resource
private CustomerInfoService customerInfoService;
@Resource @Resource
private AlihealthUtils alihealthUtils; private AlihealthUtils alihealthUtils;
@Resource
private RelCodeDetailService relCodeDetailService;
@Resource
private RelCodeBatchService relCodeBatchService;
@Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}") @Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}")
private String alihealthUrl; private String alihealthUrl;
private AlihealthClient alihealthClient;
// public static void main(String[] args) {
//
// alihealthKytSinglerelationReqeust.setSign(sign);
// String ss = HttpUtil.get("http://gw.api.taobao.com/router/rest",BeanUtil.beanToMap(alihealthKytSinglerelationReqeust));
// AlihealthKytSinglerelationResponse alihealthKytSinglerelationResponse = new AlihealthKytSinglerelationResponse(ss);
// System.out.println(ss);
// System.out.println(alihealthKytSinglerelationResponse);
//
//// AlibabaAlihealthDrugtraceTopLsydQueryRelationResponse alibabaAlihealthDrugtraceTopLsydQueryRelationResponse
//
// }
/** /**
* *
* *
@ -84,9 +67,7 @@ public class AlihealthUtils {
&& org.apache.commons.lang3.StringUtils.isNotEmpty(alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret()) && org.apache.commons.lang3.StringUtils.isNotEmpty(alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret())
) { ) {
try { try {
String json = alihealthClient.accessAliInterface(alihealthKytSearchbillReqeust, alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret());
Map map = alihealthUtils.disposeSign(alihealthKytSearchbillReqeust, alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
alihealthKytDrugrescodeResponse = new AlihealthKytSearchbillResponse(json); alihealthKytDrugrescodeResponse = new AlihealthKytSearchbillResponse(json);
} catch (Exception e) { } catch (Exception e) {
@ -205,8 +186,8 @@ public class AlihealthUtils {
Thread.sleep(600); Thread.sleep(600);
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeustNew = new AlihealthKytDrugrescodeReqeust(); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeustNew = new AlihealthKytDrugrescodeReqeust();
BeanUtils.copyProperties(alihealthKytDrugrescodeReqeust,alihealthKytDrugrescodeReqeustNew); BeanUtils.copyProperties(alihealthKytDrugrescodeReqeust,alihealthKytDrugrescodeReqeustNew);
Map map = alihealthUtils.disposeSign(alihealthKytDrugrescodeReqeustNew, alihealthThirdAliDrugInsertReqeust.getAppSecret()); String json = alihealthClient.accessAliInterface(alihealthKytDrugrescodeReqeustNew, alihealthThirdAliDrugInsertReqeust.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
log.error("阿里健康接口调用结果===" + json); log.error("阿里健康接口调用结果===" + json);
alihealthKytDrugrescodeResponse = new AlihealthKytDrugrescodeResponse(json); alihealthKytDrugrescodeResponse = new AlihealthKytDrugrescodeResponse(json);
@ -242,8 +223,7 @@ public class AlihealthUtils {
alihealthKytSinglerelationReqeust.setDes_ref_ent_id(alihealthRelCodeInsertReqeust.getRefEntId()); alihealthKytSinglerelationReqeust.setDes_ref_ent_id(alihealthRelCodeInsertReqeust.getRefEntId());
alihealthKytSinglerelationReqeust.setCode(alihealthRelCodeInsertReqeust.getCode()); alihealthKytSinglerelationReqeust.setCode(alihealthRelCodeInsertReqeust.getCode());
alihealthKytSinglerelationReqeust.setApp_key(alihealthRelCodeInsertReqeust.getAppKey()); alihealthKytSinglerelationReqeust.setApp_key(alihealthRelCodeInsertReqeust.getAppKey());
Map map = alihealthUtils.disposeSign(alihealthKytSinglerelationReqeust, alihealthRelCodeInsertReqeust.getAppSecret()); String json = alihealthClient.accessAliInterface(alihealthKytSinglerelationReqeust, alihealthRelCodeInsertReqeust.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
alihealthKytSinglerelationResponse = new AlihealthKytSinglerelationResponse(json); alihealthKytSinglerelationResponse = new AlihealthKytSinglerelationResponse(json);
} catch (Exception e) { } catch (Exception e) {

@ -14,6 +14,7 @@ import com.glxp.api.entity.auth.CustomerInfoEntity;
import com.glxp.api.entity.basic.BasicCorpEntity; import com.glxp.api.entity.basic.BasicCorpEntity;
import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.inout.IoCodeLostEntity; import com.glxp.api.entity.inout.IoCodeLostEntity;
import com.glxp.api.httpClient.serviceClient.AlihealthClient;
import com.glxp.api.req.alihealth.*; import com.glxp.api.req.alihealth.*;
import com.glxp.api.req.alihealth.local.*; import com.glxp.api.req.alihealth.local.*;
import com.glxp.api.res.alihealth.*; import com.glxp.api.res.alihealth.*;
@ -47,6 +48,8 @@ public class AlihealthYljgUtils {
private AuthCompanyMapper authCompanyMapper; private AuthCompanyMapper authCompanyMapper;
@Resource @Resource
private BasicCorpDao basicCorpDao; private BasicCorpDao basicCorpDao;
@Resource
private AlihealthClient alihealthClient;
/** /**
* *
@ -77,8 +80,7 @@ public class AlihealthYljgUtils {
alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo");
alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId());
alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName());
Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); String json = alihealthClient.accessAliInterface(alihealthKytGetentinfoReqeust, authCompany.getAppSecret());
String json = HttpUtil.get(alihealthUrl,map);
alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json);
}catch (Exception e){ }catch (Exception e){
@ -144,10 +146,7 @@ public class AlihealthYljgUtils {
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret())
) { ) {
try { try {
String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
log.error("阿里啦关联关系入参==="+map);
String json = HttpUtil.get(alihealthUrl, map);
log.error("阿里啦关联关系结果==="+json); log.error("阿里啦关联关系结果==="+json);
alihealthYljgSinglerelationResponse = new AlihealthYljgSinglerelationResponse(json); alihealthYljgSinglerelationResponse = new AlihealthYljgSinglerelationResponse(json);
@ -184,9 +183,7 @@ public class AlihealthYljgUtils {
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret())
) { ) {
try { try {
String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
alihealthYljgCodedetailResponse = new AlihealthYljgCodedetailResponse(json); alihealthYljgCodedetailResponse = new AlihealthYljgCodedetailResponse(json);
} catch (Exception e) { } catch (Exception e) {
@ -225,8 +222,7 @@ public class AlihealthYljgUtils {
alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo");
alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId());
alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName());
Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
String json = HttpUtil.get(alihealthUrl,map);
alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json);
}catch (Exception e){ }catch (Exception e){
@ -245,15 +241,9 @@ public class AlihealthYljgUtils {
} }
} }
reqeust.setApp_key(authCompany.getAppId()); reqeust.setApp_key(authCompany.getAppId());
reqeust.setRef_ent_id(authCompany.getRefEntId()); reqeust.setRef_ent_id(authCompany.getRefEntId());
AlihealthYljgListupoutResponse alihealthYljgListupoutResponse = null; AlihealthYljgListupoutResponse alihealthYljgListupoutResponse = null;
if (reqeust != null if (reqeust != null
&& org.apache.commons.lang3.StringUtils.isNotEmpty(reqeust.getApp_key()) && org.apache.commons.lang3.StringUtils.isNotEmpty(reqeust.getApp_key())
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret())
@ -299,9 +289,7 @@ public class AlihealthYljgUtils {
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret())
) { ) {
try { try {
String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
alihealthYljgListupoutDetailResponse = new AlihealthYljgListupoutDetailResponse(json); alihealthYljgListupoutDetailResponse = new AlihealthYljgListupoutDetailResponse(json);
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save