diff --git a/src/main/java/com/glxp/api/httpClient/serviceClient/AlihealthClient.java b/src/main/java/com/glxp/api/httpClient/serviceClient/AlihealthClient.java new file mode 100644 index 00000000..65809bed --- /dev/null +++ b/src/main/java/com/glxp/api/httpClient/serviceClient/AlihealthClient.java @@ -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); + +} diff --git a/src/main/java/com/glxp/api/httpClient/serviceClient/impl/AlihealthImpl.java b/src/main/java/com/glxp/api/httpClient/serviceClient/impl/AlihealthImpl.java new file mode 100644 index 00000000..a6cc9527 --- /dev/null +++ b/src/main/java/com/glxp/api/httpClient/serviceClient/impl/AlihealthImpl.java @@ -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; + } +} diff --git a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java index 7d518df0..f4a13a45 100644 --- a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java @@ -8,6 +8,7 @@ import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.constant.AliConstants; import com.glxp.api.entity.thrsys.ThirdAliDrug; 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.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.AlihealthKytSearchbillReqeust; @@ -44,29 +45,11 @@ import java.util.*; @Slf4j @Component public class AlihealthUtils { - @Resource - private CustomerInfoService customerInfoService; @Resource private AlihealthUtils alihealthUtils; - @Resource - private RelCodeDetailService relCodeDetailService; - @Resource - private RelCodeBatchService relCodeBatchService; @Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}") private String alihealthUrl; - - // 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 -// -// } - + private AlihealthClient alihealthClient; /** * 通过时间段批量查询入出库单信息 * @@ -84,9 +67,7 @@ public class AlihealthUtils { && org.apache.commons.lang3.StringUtils.isNotEmpty(alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret()) ) { try { - - Map map = alihealthUtils.disposeSign(alihealthKytSearchbillReqeust, alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret()); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(alihealthKytSearchbillReqeust, alihealthKytThirdAliSearchbillInsertReqeust.getAppSecret()); alihealthKytDrugrescodeResponse = new AlihealthKytSearchbillResponse(json); } catch (Exception e) { @@ -205,8 +186,8 @@ public class AlihealthUtils { Thread.sleep(600); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeustNew = new AlihealthKytDrugrescodeReqeust(); BeanUtils.copyProperties(alihealthKytDrugrescodeReqeust,alihealthKytDrugrescodeReqeustNew); - Map map = alihealthUtils.disposeSign(alihealthKytDrugrescodeReqeustNew, alihealthThirdAliDrugInsertReqeust.getAppSecret()); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(alihealthKytDrugrescodeReqeustNew, alihealthThirdAliDrugInsertReqeust.getAppSecret()); + log.error("阿里健康接口调用结果===" + json); alihealthKytDrugrescodeResponse = new AlihealthKytDrugrescodeResponse(json); @@ -242,8 +223,7 @@ public class AlihealthUtils { alihealthKytSinglerelationReqeust.setDes_ref_ent_id(alihealthRelCodeInsertReqeust.getRefEntId()); alihealthKytSinglerelationReqeust.setCode(alihealthRelCodeInsertReqeust.getCode()); alihealthKytSinglerelationReqeust.setApp_key(alihealthRelCodeInsertReqeust.getAppKey()); - Map map = alihealthUtils.disposeSign(alihealthKytSinglerelationReqeust, alihealthRelCodeInsertReqeust.getAppSecret()); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(alihealthKytSinglerelationReqeust, alihealthRelCodeInsertReqeust.getAppSecret()); alihealthKytSinglerelationResponse = new AlihealthKytSinglerelationResponse(json); } catch (Exception e) { diff --git a/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java b/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java index bcfb6125..32d0fa7d 100644 --- a/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java @@ -14,6 +14,7 @@ import com.glxp.api.entity.auth.CustomerInfoEntity; import com.glxp.api.entity.basic.BasicCorpEntity; import com.glxp.api.entity.collect.RelCodeBatch; 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.local.*; import com.glxp.api.res.alihealth.*; @@ -47,6 +48,8 @@ public class AlihealthYljgUtils { private AuthCompanyMapper authCompanyMapper; @Resource private BasicCorpDao basicCorpDao; + @Resource + private AlihealthClient alihealthClient; /** * 出入库单据上传 @@ -77,8 +80,7 @@ public class AlihealthYljgUtils { alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); - Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); - String json = HttpUtil.get(alihealthUrl,map); + String json = alihealthClient.accessAliInterface(alihealthKytGetentinfoReqeust, authCompany.getAppSecret()); alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); }catch (Exception e){ @@ -144,10 +146,7 @@ public class AlihealthYljgUtils { && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) ) { try { - - Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret()); - log.error("阿里啦关联关系入参==="+map); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret()); log.error("阿里啦关联关系结果==="+json); alihealthYljgSinglerelationResponse = new AlihealthYljgSinglerelationResponse(json); @@ -184,9 +183,7 @@ public class AlihealthYljgUtils { && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) ) { try { - - Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret()); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret()); alihealthYljgCodedetailResponse = new AlihealthYljgCodedetailResponse(json); } catch (Exception e) { @@ -225,8 +222,7 @@ public class AlihealthYljgUtils { alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); - Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); - String json = HttpUtil.get(alihealthUrl,map); + String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret()); alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); }catch (Exception e){ @@ -245,15 +241,9 @@ public class AlihealthYljgUtils { } } - - - - reqeust.setApp_key(authCompany.getAppId()); reqeust.setRef_ent_id(authCompany.getRefEntId()); - AlihealthYljgListupoutResponse alihealthYljgListupoutResponse = null; - if (reqeust != null && org.apache.commons.lang3.StringUtils.isNotEmpty(reqeust.getApp_key()) && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) @@ -299,9 +289,7 @@ public class AlihealthYljgUtils { && org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret()) ) { try { - - Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret()); - String json = HttpUtil.get(alihealthUrl, map); + String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret()); alihealthYljgListupoutDetailResponse = new AlihealthYljgListupoutDetailResponse(json); } catch (Exception e) {