|
|
|
@ -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());
|
|
|
|
|
|
|
|
|
|