|
|
|
@ -12,6 +12,7 @@ import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.controller.alihealth.AlihealthBusController;
|
|
|
|
|
import com.glxp.api.dao.basic.UdiRelevanceDao;
|
|
|
|
|
import com.glxp.api.dto.BasicProductsCreateDto;
|
|
|
|
|
import com.glxp.api.entity.auth.AuthAliUser;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
|
|
@ -47,6 +48,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 耗材字典对照
|
|
|
|
@ -234,8 +237,10 @@ public class UdiContrastService {
|
|
|
|
|
ThirdAliDrugService thirdAliDrugService;
|
|
|
|
|
@Resource
|
|
|
|
|
private AlihealthBusController alihealthBusController;
|
|
|
|
|
|
|
|
|
|
// @Transactional
|
|
|
|
|
public void createOnlyMainId(String mainId) {
|
|
|
|
|
public void createOnlyMainId(BasicProductsCreateDto basicProductsCreateDto) {
|
|
|
|
|
String mainId = basicProductsCreateDto.getMainId();
|
|
|
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
filterThrProductsRequest.setCode(mainId);
|
|
|
|
|
ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(mainId);
|
|
|
|
@ -340,8 +345,10 @@ public class UdiContrastService {
|
|
|
|
|
|
|
|
|
|
AuthAliUser authAliUser = authAliUserService.getOne();
|
|
|
|
|
AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust();
|
|
|
|
|
basicProductsCreateDto.setDrugCheckMark(basicProductsCreateDto.isDrugCheckMark());
|
|
|
|
|
alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid());
|
|
|
|
|
alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret());
|
|
|
|
|
alihealthThirdAliDrugInsertReqeust.setDrugCheckMark(basicProductsCreateDto.isDrugCheckMark());
|
|
|
|
|
// alihealthThirdAliDrugInsertReqeust.setManufactory(udiProductEntity.getManufactory());
|
|
|
|
|
alihealthThirdAliDrugInsertReqeust.setYbDrug(ybDrug);
|
|
|
|
|
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust();
|
|
|
|
@ -398,6 +405,7 @@ public class UdiContrastService {
|
|
|
|
|
// udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
|
// }
|
|
|
|
|
if (thirdAliDrugList != null && thirdAliDrugList.size() > 0) {
|
|
|
|
|
List<CodeRel> codeRelArrayList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < thirdAliDrugList.size(); i++) {
|
|
|
|
|
ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i);
|
|
|
|
@ -447,16 +455,37 @@ public class UdiContrastService {
|
|
|
|
|
udiProductEntity.setBhxjsl(DimaUtil.trMinCount(thirdAliDrug.getBzgg()));
|
|
|
|
|
} else
|
|
|
|
|
udiProductEntity.setBhxjsl(ybDrug.getFactor());
|
|
|
|
|
} else {
|
|
|
|
|
udiProductEntity.setXjdw(thirdAliDrug.getPrepnUnitName());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (thirdAliDrug.getPackLevel() != null && !thirdAliDrug.getPackLevel().equals("0")) {
|
|
|
|
|
udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4);
|
|
|
|
|
} else {
|
|
|
|
|
udiProductEntity.setDiType(1);
|
|
|
|
|
}
|
|
|
|
|
udiProductEntity.setXjdw(thirdAliDrug.getPrepnUnitName());
|
|
|
|
|
udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName());
|
|
|
|
|
// udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName());
|
|
|
|
|
|
|
|
|
|
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
|
|
|
|
|
// 多码融合表拼接参数
|
|
|
|
|
if (basicProductsCreateDto.isDrugCheckMark() && !thirdAliDrug.isDmcx()) {
|
|
|
|
|
CodeRel codeRel = new CodeRel();
|
|
|
|
|
codeRel.setDrugCode(thirdAliDrug.getNameCode());
|
|
|
|
|
codeRel.setUpdateTime(new Date());
|
|
|
|
|
codeRel.setYbbm(ybDrug.getGoodsCode());
|
|
|
|
|
codeRel.setPackUnit(udiProductEntity.getPackUnit());
|
|
|
|
|
codeRel.setBhxjsl(udiProductEntity.getBhxjsl());
|
|
|
|
|
codeRel.setXjdw(udiProductEntity.getXjdw());
|
|
|
|
|
codeRel.setYbBzgg(udiProductEntity.getBzgg());
|
|
|
|
|
codeRelArrayList.add(codeRel);
|
|
|
|
|
}
|
|
|
|
|
// 多码融合存在就以多码融合为准
|
|
|
|
|
udiProductEntity.setPackUnit(CopyUtils.copyNullStr(thirdAliDrug.getPackUnit(), udiProductEntity.getPackUnit()));
|
|
|
|
|
udiProductEntity.setBhxjsl(CopyUtils.copyNullNum(thirdAliDrug.getBhxjsl(), udiProductEntity.getBhxjsl()));
|
|
|
|
|
udiProductEntity.setXjdw(CopyUtils.copyNullStr(thirdAliDrug.getXjdw(), udiProductEntity.getXjdw()));
|
|
|
|
|
udiProductEntity.setBzgg(CopyUtils.copyNullStr(thirdAliDrug.getBzgg(), udiProductEntity.getBzgg()));
|
|
|
|
|
|
|
|
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -466,6 +495,12 @@ public class UdiContrastService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("明细分类转换出现错误" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
// 上传到多码融合表
|
|
|
|
|
if (basicProductsCreateDto.isDrugCheckMark()
|
|
|
|
|
&& CollUtil.isNotEmpty(codeRelArrayList)) {
|
|
|
|
|
this.codeRelUpdateBatch(codeRelArrayList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
|
|
|
|
|
@ -568,6 +603,38 @@ public class UdiContrastService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上传国家库多码融合库
|
|
|
|
|
*
|
|
|
|
|
* @param list
|
|
|
|
|
*/
|
|
|
|
|
public void codeRelUpdateBatch(List<CodeRel> list) {
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String response = HttpUtil.post(udiUrl + "/udchs/codeRel/updateBatch", JSONUtil.toJsonStr(list));
|
|
|
|
|
BaseResponse<String> baseResponse = JSONUtil.toBean(response, BaseResponse.class);
|
|
|
|
|
|
|
|
|
|
if (baseResponse.getCode() == 2000) {
|
|
|
|
|
log.error("国家库===上传多码关系===" + list.get(0).getYbbm() + "成功===");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
log.error("国家库===上传多码关系===出现错误===" + baseResponse.getMessage());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("国家库===上传多码关系===出现错误===" + e.getMessage());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.error("国家库===上传多码关系===出现错误===数据为空");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ThirdAliDrug> disposeYbDrugList(List<ThirdAliDrug> thirdAliDrugList, YbDrug ybDrug, List<String> codeIn) {
|
|
|
|
|
List<ThirdAliDrug> list1 = new ArrayList<>();
|
|
|
|
|
String result = null;
|
|
|
|
@ -580,7 +647,7 @@ public class UdiContrastService {
|
|
|
|
|
for (ThirdAliDrug thirdAliDrug : thirdAliDrugList) {
|
|
|
|
|
String str = drugRulesVerify(ybDrug, thirdAliDrug);
|
|
|
|
|
if (StringUtils.isNotEmpty(str)) {
|
|
|
|
|
if(str.equals("1") || str.equals("2")){
|
|
|
|
|
if (str.equals("1")) {
|
|
|
|
|
if (StringUtils.isNotEmpty(result)) {
|
|
|
|
|
if (!result.contains(thirdAliDrug.getNameCode())) {
|
|
|
|
|
list1.add(thirdAliDrug);
|
|
|
|
@ -601,22 +668,21 @@ public class UdiContrastService {
|
|
|
|
|
|
|
|
|
|
return list1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String drugRulesVerify(YbDrug ybDrug, ThirdAliDrug thirdAliDrug) {
|
|
|
|
|
try {
|
|
|
|
|
Integer bzggInt = DimaUtil.trMinCount(thirdAliDrug.getBzgg());
|
|
|
|
|
|
|
|
|
|
// 医保规格和阿里制剂规格双方都去除特殊符号和空格之后进行精准匹配
|
|
|
|
|
String realityOutlook = DimaUtil.specialCharactersRemover(ybDrug.getRealityOutlook());
|
|
|
|
|
String formSpec = DimaUtil.specialCharactersRemover(thirdAliDrug.getFormSpec());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 按照医保数量与阿里包装规格对比
|
|
|
|
|
if((bzggInt == ybDrug.getFactor())){
|
|
|
|
|
if ((bzggInt == ybDrug.getFactor()) && realityOutlook.equals(formSpec)) {
|
|
|
|
|
return "1";
|
|
|
|
|
}
|
|
|
|
|
// 医保规格拆分与阿里规格拆分做匹配
|
|
|
|
|
List<String> list = DimaUtil.extractNumbers(ybDrug.getRealityOutlook());
|
|
|
|
|
if(list!=null && list.size() >0){
|
|
|
|
|
for (String str : list) {
|
|
|
|
|
if(str.equals(String.valueOf(bzggInt))){
|
|
|
|
|
return "2";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // 医保的规格与阿里制剂规格完全匹配
|
|
|
|
|
// if(thirdAliDrug.getFormSpec().equals(ybDrug.getRealityOutlook())){
|
|
|
|
|
// return "3";
|
|
|
|
|