代码备份

dev_unify
yewj 7 months ago
parent 16c86f330a
commit baa11d9504

@ -53,6 +53,7 @@ public class AlihealthKytDrugrescodeResponse extends AlihealthKytCommonParameter
jsonObjectResult = jsonObject.getJSONObject(s).getJSONObject("result"); jsonObjectResult = jsonObject.getJSONObject(s).getJSONObject("result");
} }
AlihealthKytCommonParametersResponse alihealthKytCommonParametersResponse = JSONUtil.toBean(jsonObjectResult.toString(), AlihealthKytCommonParametersResponse alihealthKytCommonParametersResponse = JSONUtil.toBean(jsonObjectResult.toString(),
AlihealthKytCommonParametersResponse.class); AlihealthKytCommonParametersResponse.class);
BeanUtils.copyProperties(alihealthKytCommonParametersResponse, this); BeanUtils.copyProperties(alihealthKytCommonParametersResponse, this);

@ -22,6 +22,8 @@ import com.glxp.api.service.collect.RelCodeBatchService;
import com.glxp.api.service.collect.RelCodeDetailService; import com.glxp.api.service.collect.RelCodeDetailService;
import com.taobao.api.Constants; import com.taobao.api.Constants;
import com.taobao.api.internal.util.StringUtils; import com.taobao.api.internal.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -39,6 +41,7 @@ import java.util.*;
import static com.taobao.api.internal.util.TaobaoUtils.byte2hex; import static com.taobao.api.internal.util.TaobaoUtils.byte2hex;
@Slf4j
@Component @Component
public class AlihealthUtils { public class AlihealthUtils {
@Resource @Resource
@ -102,6 +105,7 @@ public class AlihealthUtils {
} }
} }
public BaseResponse<List<ThirdAliDrug>> thirdAliDrugInsertAll(AlihealthThirdAliDrugInsertReqeust request) { public BaseResponse<List<ThirdAliDrug>> thirdAliDrugInsertAll(AlihealthThirdAliDrugInsertReqeust request) {
// 初始化变量 // 初始化变量
List<ThirdAliDrug> resultList = new ArrayList<>(); List<ThirdAliDrug> resultList = new ArrayList<>();
@ -116,14 +120,20 @@ public class AlihealthUtils {
if (containsBrackets(originalName)) { if (containsBrackets(originalName)) {
String convertedName = convertBrackets(originalName); String convertedName = convertBrackets(originalName);
drugRequest.setPhysic_name(convertedName); drugRequest.setPhysic_name(convertedName);
tryInsertAndCollect(request, resultList); AlihealthThirdAliDrugInsertReqeust tempRequest = new AlihealthThirdAliDrugInsertReqeust();
BeanUtils.copyProperties(request, tempRequest);
tempRequest.getAlihealthKytDrugrescodeReqeust().setPhysic_name(convertedName);
tryInsertAndCollect(tempRequest, resultList);
} }
// 处理罗马数字转换 // 处理罗马数字转换
if (containsRomanNumerals(originalName)) { if (containsRomanNumerals(originalName)) {
String convertedName = convertRomanNumerals(originalName); String convertedName = convertRomanNumerals(originalName);
drugRequest.setPhysic_name(convertedName); drugRequest.setPhysic_name(convertedName);
tryInsertAndCollect(request, resultList); AlihealthThirdAliDrugInsertReqeust tempRequest = new AlihealthThirdAliDrugInsertReqeust();
BeanUtils.copyProperties(request, tempRequest);
tempRequest.getAlihealthKytDrugrescodeReqeust().setPhysic_name(convertedName);
tryInsertAndCollect(tempRequest, resultList);
} }
// 设置结果 // 设置结果
@ -167,12 +177,15 @@ public class AlihealthUtils {
private BaseResponse<List<ThirdAliDrug>> tryInsertAndCollect( private BaseResponse<List<ThirdAliDrug>> tryInsertAndCollect(
AlihealthThirdAliDrugInsertReqeust request, AlihealthThirdAliDrugInsertReqeust request,
List<ThirdAliDrug> resultList) { List<ThirdAliDrug> resultList) {
BaseResponse<List<ThirdAliDrug>> response = thirdAliDrugInsert(request); AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust();
BeanUtil.copyProperties(request, alihealthThirdAliDrugInsertReqeust);
BaseResponse<List<ThirdAliDrug>> response = thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust);
if (response.getCode() == 20000 && response.getData() != null) { if (response.getCode() == 20000 && response.getData() != null) {
resultList.addAll(response.getData()); resultList.addAll(response.getData());
} }
return response; return response;
} }
/** /**
* *
* *
@ -193,6 +206,7 @@ public class AlihealthUtils {
Map map = alihealthUtils.disposeSign(alihealthKytDrugrescodeReqeust, alihealthThirdAliDrugInsertReqeust.getAppSecret()); Map map = alihealthUtils.disposeSign(alihealthKytDrugrescodeReqeust, alihealthThirdAliDrugInsertReqeust.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map); String json = HttpUtil.get(alihealthUrl, map);
log.error("阿里健康接口调用成功===" + json);
alihealthKytDrugrescodeResponse = new AlihealthKytDrugrescodeResponse(json); alihealthKytDrugrescodeResponse = new AlihealthKytDrugrescodeResponse(json);
} catch (Exception e) { } catch (Exception e) {
@ -206,7 +220,7 @@ public class AlihealthUtils {
String physicName = alihealthKytDrugrescodeReqeust.getPhysic_name(); String physicName = alihealthKytDrugrescodeReqeust.getPhysic_name();
if (alihealthKytDrugrescodeResponse.judgeCall() ) { if (alihealthKytDrugrescodeResponse.judgeCall()) {
List<ThirdAliDrug> listNew = alihealthKytDrugrescodeResponse.disposeThirdAliDrugList(alihealthThirdAliDrugInsertReqeust.getErpId()); List<ThirdAliDrug> listNew = alihealthKytDrugrescodeResponse.disposeThirdAliDrugList(alihealthThirdAliDrugInsertReqeust.getErpId());
return ResultVOUtils.success(listNew); return ResultVOUtils.success(listNew);
} else { } else {
@ -280,12 +294,12 @@ public class AlihealthUtils {
String sign; String sign;
try { try {
sign = new AlihealthUtils().signTopRequest(map, secret, "md5"); sign = new AlihealthUtils().signTopRequest(map, secret, "md5");
log.info("sign====" + sign);
alihealthKytCommonParametersReqeust.setSign(sign); alihealthKytCommonParametersReqeust.setSign(sign);
return BeanUtil.beanToMap(alihealthKytCommonParametersReqeust);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
return null; return BeanUtil.beanToMap(alihealthKytCommonParametersReqeust);
} }
@ -357,5 +371,4 @@ public class AlihealthUtils {
} }
} }

Loading…
Cancel
Save