|
|
|
@ -2,8 +2,12 @@ package com.glxp.api.util.alihealth;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.dao.auth.AuthCompanyMapper;
|
|
|
|
|
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
|
|
|
|
|
import com.glxp.api.entity.auth.AuthCompany;
|
|
|
|
|
import com.glxp.api.entity.collect.RelCodeBatch;
|
|
|
|
|
import com.glxp.api.req.alihealth.*;
|
|
|
|
|
import com.glxp.api.req.alihealth.local.*;
|
|
|
|
@ -11,6 +15,7 @@ import com.glxp.api.res.alihealth.*;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerInfoService;
|
|
|
|
|
import com.glxp.api.service.collect.RelCodeBatchService;
|
|
|
|
|
import com.glxp.api.service.collect.RelCodeDetailService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
@ -30,6 +35,8 @@ public class AlihealthYljgUtils {
|
|
|
|
|
private RelCodeBatchService relCodeBatchService;
|
|
|
|
|
@Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}")
|
|
|
|
|
private String alihealthUrl;
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthCompanyMapper authCompanyMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 出入库单据上传
|
|
|
|
@ -132,4 +139,112 @@ public class AlihealthYljgUtils {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询单据
|
|
|
|
|
* @param reqeust
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public BaseResponse<List<AliYljgSearchbill>> listupout(AlihealthYljgListupoutReqeust reqeust,String erpName) {
|
|
|
|
|
AuthCompany authCompany = authCompanyMapper.selectOne(
|
|
|
|
|
new QueryWrapper<AuthCompany>().last("limit 1")
|
|
|
|
|
);
|
|
|
|
|
if(StringUtils.isNotEmpty(erpName)){
|
|
|
|
|
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(erpName);
|
|
|
|
|
Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret());
|
|
|
|
|
String json = HttpUtil.get(alihealthUrl,map);
|
|
|
|
|
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.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())
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
|
|
|
|
|
String json = HttpUtil.get(alihealthUrl, map);
|
|
|
|
|
alihealthYljgListupoutResponse = new AlihealthYljgListupoutResponse(json);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// e.getMessage();
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
|
|
|
|
|
}
|
|
|
|
|
if (alihealthYljgListupoutResponse.judgeCall()) {
|
|
|
|
|
return ResultVOUtils.success( alihealthYljgListupoutResponse.disposeAliYljgSearchbill());
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthYljgListupoutResponse.getMsg_info());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询单据详情
|
|
|
|
|
* @param reqeust
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public BaseResponse<List<AliYljgSearchbill>> listupoutDetail(AlihealthYljgListupoutDetailReqeust reqeust) {
|
|
|
|
|
AlihealthYljgListupoutDetailResponse alihealthYljgListupoutDetailResponse = null;
|
|
|
|
|
AuthCompany authCompany = authCompanyMapper.selectOne(
|
|
|
|
|
new QueryWrapper<AuthCompany>().last("limit 1")
|
|
|
|
|
);
|
|
|
|
|
reqeust.setApp_key(authCompany.getAppId());
|
|
|
|
|
reqeust.setRef_ent_id(authCompany.getRefEntId());
|
|
|
|
|
reqeust.setTo_ref_user_id(authCompany.getRefEntId());
|
|
|
|
|
|
|
|
|
|
if (reqeust != null
|
|
|
|
|
&& org.apache.commons.lang3.StringUtils.isNotEmpty(reqeust.getApp_key())
|
|
|
|
|
&& org.apache.commons.lang3.StringUtils.isNotEmpty(authCompany.getAppSecret())
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
|
|
|
|
|
String json = HttpUtil.get(alihealthUrl, map);
|
|
|
|
|
alihealthYljgListupoutDetailResponse = new AlihealthYljgListupoutDetailResponse(json);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
|
|
|
|
|
}
|
|
|
|
|
if (alihealthYljgListupoutDetailResponse.judgeCall()) {
|
|
|
|
|
return ResultVOUtils.success( alihealthYljgListupoutDetailResponse.disposeAliYljgBillDetail());
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthYljgListupoutDetailResponse.getMsg_info());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|