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

dev_drug_dm
qiuyt 4 months ago
parent 13af418d79
commit 6b4fe9cc36

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

@ -63,14 +63,6 @@ public class ThrUnitImportService {
filterThrCorpRequest.setThirdSysFk(unitMaintainFilterRequest.getThirdSys()); filterThrCorpRequest.setThirdSysFk(unitMaintainFilterRequest.getThirdSys());
filterThrCorpRequest.setPage(null); filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpEntities = thrCorpService.filterThrCorps(filterThrCorpRequest); 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); imports.addAll(thrCorpEntities);
} }
if (imports != null && imports.size() > 0) { if (imports != null && imports.size() > 0) {

@ -1,5 +1,6 @@
package com.glxp.api.util.alihealth; package com.glxp.api.util.alihealth;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -36,8 +37,6 @@ import java.util.Map;
public class AlihealthYljgUtils { public class AlihealthYljgUtils {
@Resource @Resource
private AuthCompanyMapper authCompanyMapper; private AuthCompanyMapper authCompanyMapper;
@Resource @Resource
@ -46,27 +45,22 @@ public class AlihealthYljgUtils {
private AlihealthClient alihealthClient; private AlihealthClient alihealthClient;
/** /**
* * ID
* @param reqeust *
* @param authCompany
* @param erpId
* @return * @return
*/ */
public BaseResponse<AlihealthKytSinglerelationResponse> yljgUploadinoutbill(AlihealthYljgUploadinoutbillReqeust reqeust,String erpId) { public String getEntId(AuthCompany authCompany, 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)) { if (StringUtils.isNotEmpty(erpId)) {
BasicCorpEntity basicCorpEntity = basicCorpDao.selectOne( BasicCorpEntity basicCorpEntity = basicCorpDao.selectOne(
new QueryWrapper<BasicCorpEntity>().eq("erpId", erpId) new QueryWrapper<BasicCorpEntity>().eq("erpId", erpId)
); );
if(basicCorpEntity!=null){ if (ObjectUtil.isNotEmpty(basicCorpEntity) && StringUtils.isNotEmpty(basicCorpEntity.getAliEntId())) {
return basicCorpEntity.getAliEntId();
}else { }
basicCorpEntity = new BasicCorpEntity(); if (ObjectUtil.isNull(basicCorpEntity)) {
basicCorpEntity.setName(erpId); return null;
} }
AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse = null; AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse = null;
try { try {
@ -78,18 +72,47 @@ public class AlihealthYljgUtils {
alihealthKytGetentinfoResponse = new AlihealthKytGetentinfoResponse(json); alihealthKytGetentinfoResponse = new AlihealthKytGetentinfoResponse(json);
} catch (Exception e) { } catch (Exception e) {
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查"); log.error("阿里健康接口调用失败===往来单位名称请检查");
return null;
} }
if (StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info()) if (StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info())
&& alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功") && alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功")
) { ) {
reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id()); // 写入往来单位表
BasicCorpEntity basicCorpEntityNew = new BasicCorpEntity();
basicCorpEntityNew.setId(basicCorpEntity.getId());
basicCorpEntityNew.setAliEntId(alihealthKytGetentinfoResponse.getEnt_id());
basicCorpDao.updateById(basicCorpEntityNew);
return alihealthKytGetentinfoResponse.getEnt_id();
} else { } else {
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info()); 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 if (reqeust != null
@ -121,6 +144,7 @@ public class AlihealthYljgUtils {
/** /**
* *
*
* @param reqeust * @param reqeust
* @return * @return
*/ */
@ -161,6 +185,7 @@ public class AlihealthYljgUtils {
/** /**
* *
*
* @param reqeust * @param reqeust
* @return * @return
*/ */
@ -194,8 +219,10 @@ public class AlihealthYljgUtils {
} }
} }
/** /**
* *
*
* @param reqeust * @param reqeust
* @return * @return
*/ */
@ -204,35 +231,10 @@ public class AlihealthYljgUtils {
new QueryWrapper<AuthCompany>().last("limit 1") new QueryWrapper<AuthCompany>().last("limit 1")
); );
if(StringUtils.isNotEmpty(erpId)){ // 获取阿里往来单位ID
BasicCorpEntity basicCorpEntity = basicCorpDao.selectOne( reqeust.setFrom_user_id(getEntId(authCompany, erpId));
new QueryWrapper<BasicCorpEntity>().eq("erpId",erpId) if (StringUtils.isEmpty(reqeust.getFrom_user_id())) {
); log.error("阿里往来单位ID获取失败去检查");
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());
}
}
} }
reqeust.setApp_key(authCompany.getAppId()); reqeust.setApp_key(authCompany.getAppId());
reqeust.setRef_ent_id(authCompany.getRefEntId()); reqeust.setRef_ent_id(authCompany.getRefEntId());
@ -261,8 +263,10 @@ public class AlihealthYljgUtils {
} }
} }
/** /**
* *
*
* @param reqeust * @param reqeust
* @return * @return
*/ */

@ -1297,3 +1297,8 @@ CREATE TABLE IF NOT EXISTS `basic_products_registration_cert` (
CALL Pro_Temp_ColumnWork('basic_products', 'zczbhhzbapzbhSys', CALL Pro_Temp_ColumnWork('basic_products', 'zczbhhzbapzbhSys',
'varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''注册/备案证号系统使用''', '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