阿里接口关于往来单位ID获取优化,减少重复访问阿里接口

dev_drug_dm
qiuyt 1 month ago
parent 13af418d79
commit 6b4fe9cc36

@ -140,5 +140,10 @@ public class BasicCorpEntity {
@TableField(value = "remark")
private String remark;
/**
* ID
*/
@TableField(value = "aliEntId")
private String aliEntId;
}

@ -63,14 +63,6 @@ public class ThrUnitImportService {
filterThrCorpRequest.setThirdSysFk(unitMaintainFilterRequest.getThirdSys());
filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpEntities = thrCorpService.filterThrCorps(filterThrCorpRequest);
// List<ThrCorpsResponse> lists = thrCorpEntities.stream().map(
// item -> {
// ThrCorpsResponse thrProductsEntity = new ThrCorpsResponse();
// BeanUtils.copyProperties(item, thrProductsEntity);
// thrProductsEntity.setId(item.getUnitId());
// return thrProductsEntity;
// }
// ).collect(Collectors.toList());
imports.addAll(thrCorpEntities);
}
if (imports != null && imports.size() > 0) {

@ -1,5 +1,6 @@
package com.glxp.api.util.alihealth;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -36,8 +37,6 @@ import java.util.Map;
public class AlihealthYljgUtils {
@Resource
private AuthCompanyMapper authCompanyMapper;
@Resource
@ -46,51 +45,75 @@ public class AlihealthYljgUtils {
private AlihealthClient alihealthClient;
/**
*
* @param reqeust
* ID
*
* @param authCompany
* @param erpId
* @return
*/
public BaseResponse<AlihealthKytSinglerelationResponse> yljgUploadinoutbill(AlihealthYljgUploadinoutbillReqeust reqeust,String erpId) {
AuthCompany authCompany = authCompanyMapper.selectOne(
new QueryWrapper<AuthCompany>().last("limit 1")
);
reqeust.setApp_key(authCompany.getAppId());
reqeust.setRef_user_id(authCompany.getRefEntId());
reqeust.setTo_user_id(authCompany.getRefEntId());
AlihealthYljgUploadinoutbillResponse alihealthYljgUploadinoutbillResponse = null;
if(StringUtils.isNotEmpty(erpId)){
public String getEntId(AuthCompany authCompany, String erpId) {
if (StringUtils.isNotEmpty(erpId)) {
BasicCorpEntity basicCorpEntity = basicCorpDao.selectOne(
new QueryWrapper<BasicCorpEntity>().eq("erpId",erpId)
new QueryWrapper<BasicCorpEntity>().eq("erpId", erpId)
);
if(basicCorpEntity!=null){
}else {
basicCorpEntity = new BasicCorpEntity();
basicCorpEntity.setName(erpId);
if (ObjectUtil.isNotEmpty(basicCorpEntity) && StringUtils.isNotEmpty(basicCorpEntity.getAliEntId())) {
return basicCorpEntity.getAliEntId();
}
if (ObjectUtil.isNull(basicCorpEntity)) {
return null;
}
AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse =null;
AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse = null;
try {
AlihealthKytGetentinfoReqeust alihealthKytGetentinfoReqeust = new AlihealthKytGetentinfoReqeust();
alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo");
alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId());
alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName());
String json = alihealthClient.accessAliInterface(alihealthKytGetentinfoReqeust, authCompany.getAppSecret());
alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json);
alihealthKytGetentinfoResponse = new AlihealthKytGetentinfoResponse(json);
}catch (Exception e){
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查");
} catch (Exception e) {
log.error("阿里健康接口调用失败===往来单位名称请检查");
return null;
}
if(StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info())
if (StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info())
&& alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功")
){
reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id());
}else {
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info());
) {
// 写入往来单位表
BasicCorpEntity basicCorpEntityNew = new BasicCorpEntity();
basicCorpEntityNew.setId(basicCorpEntity.getId());
basicCorpEntityNew.setAliEntId(alihealthKytGetentinfoResponse.getEnt_id());
basicCorpDao.updateById(basicCorpEntityNew);
return alihealthKytGetentinfoResponse.getEnt_id();
} else {
log.error("阿里健康接口调用失败===往来单位名称请检查===" + alihealthKytGetentinfoResponse.getMsg_info());
return null;
}
}
return null;
}
/**
*
*
* @param reqeust
* @return
*/
public BaseResponse<AlihealthKytSinglerelationResponse> yljgUploadinoutbill(AlihealthYljgUploadinoutbillReqeust reqeust, String erpId) {
AuthCompany authCompany = authCompanyMapper.selectOne(
new QueryWrapper<AuthCompany>().last("limit 1")
);
reqeust.setApp_key(authCompany.getAppId());
reqeust.setRef_user_id(authCompany.getRefEntId());
reqeust.setTo_user_id(authCompany.getRefEntId());
AlihealthYljgUploadinoutbillResponse alihealthYljgUploadinoutbillResponse = null;
// 获取阿里往来单位ID
reqeust.setFrom_user_id(getEntId(authCompany, erpId));
if (StringUtils.isEmpty(reqeust.getFrom_user_id())) {
log.error("阿里往来单位ID获取失败去检查");
}
if (reqeust != null
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppId())
@ -121,6 +144,7 @@ public class AlihealthYljgUtils {
/**
*
*
* @param reqeust
* @return
*/
@ -140,7 +164,7 @@ public class AlihealthYljgUtils {
) {
try {
String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
log.error("阿里啦关联关系结果==="+json);
log.error("阿里啦关联关系结果===" + json);
alihealthYljgSinglerelationResponse = new AlihealthYljgSinglerelationResponse(json);
} catch (Exception e) {
@ -161,6 +185,7 @@ public class AlihealthYljgUtils {
/**
*
*
* @param reqeust
* @return
*/
@ -187,52 +212,29 @@ public class AlihealthYljgUtils {
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
}
if (alihealthYljgCodedetailResponse.judgeCall()) {
return ResultVOUtils.success( alihealthYljgCodedetailResponse.disposeRelCodeBatch());
return ResultVOUtils.success(alihealthYljgCodedetailResponse.disposeRelCodeBatch());
} else {
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthYljgCodedetailResponse.getMsg_info());
}
}
/**
*
*
* @param reqeust
* @return
*/
public BaseResponse<List<AliYljgSearchbill>> listupout(AlihealthYljgListupoutReqeust reqeust,String erpId) {
public BaseResponse<List<AliYljgSearchbill>> listupout(AlihealthYljgListupoutReqeust reqeust, String erpId) {
AuthCompany authCompany = authCompanyMapper.selectOne(
new QueryWrapper<AuthCompany>().last("limit 1")
);
if(StringUtils.isNotEmpty(erpId)){
BasicCorpEntity basicCorpEntity = basicCorpDao.selectOne(
new QueryWrapper<BasicCorpEntity>().eq("erpId",erpId)
);
if(basicCorpEntity!=null){
AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse =null;
try {
AlihealthKytGetentinfoReqeust alihealthKytGetentinfoReqeust = new AlihealthKytGetentinfoReqeust();
alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo");
alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId());
alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName());
String json = alihealthClient.accessAliInterface(reqeust, authCompany.getAppSecret());
alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json);
}catch (Exception e){
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查");
}
if(StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info())
&& alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功")
){
reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id());
}else {
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info());
}
}
// 获取阿里往来单位ID
reqeust.setFrom_user_id(getEntId(authCompany, erpId));
if (StringUtils.isEmpty(reqeust.getFrom_user_id())) {
log.error("阿里往来单位ID获取失败去检查");
}
reqeust.setApp_key(authCompany.getAppId());
reqeust.setRef_ent_id(authCompany.getRefEntId());
@ -254,15 +256,17 @@ public class AlihealthYljgUtils {
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
}
if (alihealthYljgListupoutResponse.judgeCall()) {
return ResultVOUtils.success( alihealthYljgListupoutResponse.disposeAliYljgSearchbill());
return ResultVOUtils.success(alihealthYljgListupoutResponse.disposeAliYljgSearchbill());
} else {
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthYljgListupoutResponse.getMsg_info());
}
}
/**
*
*
* @param reqeust
* @return
*/
@ -291,7 +295,7 @@ public class AlihealthYljgUtils {
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
}
if (alihealthYljgListupoutDetailResponse.judgeCall()) {
return ResultVOUtils.success( alihealthYljgListupoutDetailResponse.disposeAliYljgBillDetail());
return ResultVOUtils.success(alihealthYljgListupoutDetailResponse.disposeAliYljgBillDetail());
} else {
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthYljgListupoutDetailResponse.getMsg_info());

@ -1296,4 +1296,9 @@ CREATE TABLE IF NOT EXISTS `basic_products_registration_cert` (
CALL Pro_Temp_ColumnWork('basic_products', 'zczbhhzbapzbhSys',
'varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''注册/备案证号系统使用''',
1);
1);
CALL Pro_Temp_ColumnWork('basic_corp', 'aliEntId',
'varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''阿里供应商ID''',
1);

Loading…
Cancel
Save