diff --git a/src/main/java/com/glxp/api/controller/thrsys/ThirdAliDrugController.java b/src/main/java/com/glxp/api/controller/thrsys/ThirdAliDrugController.java index 285b0ab3..46b0f0ee 100644 --- a/src/main/java/com/glxp/api/controller/thrsys/ThirdAliDrugController.java +++ b/src/main/java/com/glxp/api/controller/thrsys/ThirdAliDrugController.java @@ -76,7 +76,7 @@ public class ThirdAliDrugController extends BaseController { if (StrUtil.isEmpty(thirdAliDrug.getApprovalNum()) && StrUtil.isEmpty(thirdAliDrug.getNameCode()) && - StrUtil.isEmpty(thirdAliDrug.getCpmctymc()) + StrUtil.isEmpty(thirdAliDrug.getCpmctymc()) && StrUtil.isEmpty(thirdAliDrug.getManufacturer()) ) { return ResultVOUtils.success("查询参数不能为空"); } @@ -97,6 +97,7 @@ public class ThirdAliDrugController extends BaseController { AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid()); alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret()); + alihealthThirdAliDrugInsertReqeust.setManufactory(thirdAliDrug.getManufacturer()); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); alihealthKytDrugrescodeReqeust.setPhysic_name(thirdAliDrug.getCpmctymc()); alihealthKytDrugrescodeReqeust.setApproval_licence_no(thirdAliDrug.getApprovalNum()); diff --git a/src/main/java/com/glxp/api/req/thrsys/ThirdAliDrugRequest.java b/src/main/java/com/glxp/api/req/thrsys/ThirdAliDrugRequest.java index 316a96f6..c08b3e2e 100644 --- a/src/main/java/com/glxp/api/req/thrsys/ThirdAliDrugRequest.java +++ b/src/main/java/com/glxp/api/req/thrsys/ThirdAliDrugRequest.java @@ -155,6 +155,6 @@ public class ThirdAliDrugRequest extends ListPageRequest { private String uuid; private String ybbm; private List nameCodeIn; - + private String nameCodeRow; } diff --git a/src/main/java/com/glxp/api/service/basic/UdiContrastService.java b/src/main/java/com/glxp/api/service/basic/UdiContrastService.java index 10033192..c97146d8 100644 --- a/src/main/java/com/glxp/api/service/basic/UdiContrastService.java +++ b/src/main/java/com/glxp/api/service/basic/UdiContrastService.java @@ -36,6 +36,7 @@ import com.glxp.api.service.thrsys.ThrProductsService; import com.glxp.api.service.thrsys.YbDrugService; import com.glxp.api.util.*; import com.glxp.api.util.alihealth.AlihealthUtils; +import com.glxp.api.util.alihealth.CopyUtils; import com.glxp.api.util.udi.UdiInfoUtil; import lombok.extern.slf4j.Slf4j; import org.jfree.util.Log; @@ -247,7 +248,6 @@ public class UdiContrastService { udiRelevanceEntity.setSplitEnable(true); udiRelevanceEntity.setAutoCode(true); udiRelevanceEntity.setIsDisable(false); - udiRelevanceEntity.setProductsType(thrProductsEntity.getProductType()); BasicInsMaterialEntity basicInsMaterialEntity = null; if (thrProductsEntity.getYbbm() != null) { @@ -433,25 +433,25 @@ public class UdiContrastService { udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); // 数据处理 - udiProductEntity.setPrepnSpec(thirdAliDrug.getFormSpec()); - udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); - udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); - udiProductEntity.setSpmc(thirdAliDrug.getSpmc()); + udiProductEntity.setPrepnSpec(CopyUtils.copyNullStr(udiProductEntity.getPrepnSpec(),thirdAliDrug.getFormSpec())); + udiProductEntity.setZczbhhzbapzbh(CopyUtils.copyNullStr(udiProductEntity.getZczbhhzbapzbh(),thirdAliDrug.getApprovalNum())); + udiProductEntity.setCpmctymc(CopyUtils.copyNullStr(udiProductEntity.getCpmctymc(),thirdAliDrug.getCpmctymc())); + udiProductEntity.setSpmc(CopyUtils.copyNullStr(udiProductEntity.getSpmc(),thirdAliDrug.getSpmc())); - udiProductEntity.setBzgg(thirdAliDrug.getBzgg()); - udiProductEntity.setPackRatio(thirdAliDrug.getPackRatio()); + udiProductEntity.setBzgg(CopyUtils.copyNullStr(udiProductEntity.getBzgg(),thirdAliDrug.getBzgg())); + udiProductEntity.setPackRatio(CopyUtils.copyNullStr(udiProductEntity.getPackRatio(),thirdAliDrug.getPackRatio())); // udiProductEntity.setMatrial(ybDrug.getMaterialName()); // udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); // udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType())); //最小产品单位 - udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); + udiProductEntity.setPackUnit(CopyUtils.copyNullStr(udiProductEntity.getPackUnit(),thirdAliDrug.getPackUnitName())); //设置最小产品数量 // udiProductEntity.setBhxjsl(ybDrug.getFactor()); //生产厂家 // udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); - udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); + udiProductEntity.setPrepnUnit(CopyUtils.copyNullStr(udiProductEntity.getPrepnUnit(),thirdAliDrug.getPrepnUnitName())); List integers = new ArrayList<>(); if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { diff --git a/src/main/java/com/glxp/api/service/basic/impl/UdiProductServiceImpl.java b/src/main/java/com/glxp/api/service/basic/impl/UdiProductServiceImpl.java index 6e01c3fd..c43f05a5 100644 --- a/src/main/java/com/glxp/api/service/basic/impl/UdiProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/basic/impl/UdiProductServiceImpl.java @@ -14,20 +14,21 @@ import com.glxp.api.entity.thrsys.ThirdAliDrug; import com.glxp.api.entity.thrsys.ThrProductsEntity; import com.glxp.api.entity.thrsys.YbDrug; import com.glxp.api.exception.JsonException; -import com.glxp.api.req.basic.AddProductRequest; -import com.glxp.api.req.basic.FilterUdiRelRequest; -import com.glxp.api.req.basic.UdiInfoRequest; -import com.glxp.api.req.basic.UpdateLevelDrugRequest; +import com.glxp.api.req.basic.*; import com.glxp.api.req.thrsys.ThirdAliDrugRequest; +import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest; import com.glxp.api.res.DiLevelResponse; import com.glxp.api.res.basic.UdiRelevanceResponse; import com.glxp.api.service.auth.CustomerService; +import com.glxp.api.service.basic.UdiContrastService; import com.glxp.api.service.basic.UdiProductService; import com.glxp.api.service.thrsys.ThirdAliDrugService; import com.glxp.api.service.thrsys.ThrProductsService; +import com.glxp.api.service.thrsys.YbDrugService; import com.glxp.api.util.DimaUtil; import com.glxp.api.util.IntUtil; import com.glxp.api.util.PinyinUtils; +import com.glxp.api.util.alihealth.CopyUtils; import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.UdiInfoUtil; import org.apache.commons.lang3.StringUtils; @@ -613,22 +614,39 @@ public class UdiProductServiceImpl implements UdiProductService { private UdiProductService udiProductService; @Resource private ThirdAliDrugService thirdAliDrugService; + @Resource + private YbDrugService ybDrugService; + @Resource + private UdiContrastService udiContrastService; @Override public void saveOrUpadateLevelDrugAli(ThirdAliDrugRequest thirdAliDrugRequest) { - ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(thirdAliDrugRequest.getYbbm()); ThirdAliDrug thirdAliDrugServiceOne = thirdAliDrugService.getOne( - new QueryWrapper().eq("nameCode", thirdAliDrugRequest.getNameCode()).last("limit 1") + new QueryWrapper().eq("nameCode", thirdAliDrugRequest.getNameCodeRow()).last("limit 1") ); if (thirdAliDrugServiceOne != null) { List thirdAliDrugList = thirdAliDrugService.list( - new QueryWrapper().eq("bzgg", thirdAliDrugServiceOne.getBzgg()).eq("packRatio", thirdAliDrugServiceOne.getPackRatio()) + new QueryWrapper().eq(StringUtils.isNotBlank( thirdAliDrugServiceOne.getBzgg()),"bzgg", thirdAliDrugServiceOne.getBzgg()) + .eq(StringUtils.isNotBlank( thirdAliDrugServiceOne.getPackRatio()),"packRatio", thirdAliDrugServiceOne.getPackRatio()) + .eq(StringUtils.isNotBlank( thirdAliDrugRequest.getCpmctymc()),"cpmctymc", thirdAliDrugRequest.getCpmctymc()) + .eq(StringUtils.isNotBlank( thirdAliDrugRequest.getManufacturer()),"manufacturer", thirdAliDrugRequest.getManufacturer()) + .eq(StringUtils.isNotBlank( thirdAliDrugRequest.getApprovalNum()),"approvalNum", thirdAliDrugRequest.getApprovalNum()) + ); if (thirdAliDrugList != null && thirdAliDrugList.size() > 0) { + ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(thirdAliDrugRequest.getYbbm()); for (ThirdAliDrug thirdAliDrug : thirdAliDrugList) { - UdiProductEntity udiProductEntity = new UdiProductEntity(); + ThrInsDrugFeeRequest thrInsDrugFeeRequest = new ThrInsDrugFeeRequest(); + thrInsDrugFeeRequest.setMedCatalogCode(thrProductsEntity.getYbbm()); + YbDrugDetailFilterRequest ybHcflDetailFilterRequest = new YbDrugDetailFilterRequest(); + ybHcflDetailFilterRequest.setLimit(1); + ybHcflDetailFilterRequest.setPage(1); + ybHcflDetailFilterRequest.setGoodsCode(thrProductsEntity.getYbbm()); + List list = ybDrugService.getList(ybHcflDetailFilterRequest); + + UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); YbDrug ybDrug = new YbDrug(); @@ -653,30 +671,62 @@ public class UdiProductServiceImpl implements UdiProductService { } udiProductEntity.setUpdateTime(new Date()); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); -// for (int i = 0; i < thirdAliDrugList.size(); i++) { -// ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); - udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); + if (list != null && list.size() > 0) { + ybDrug = list.get(0); + // 数据做处理好查询阿里接口 + if (ybDrug.getApprovalCode().contains("(")) { + String[] charArr = ybDrug.getRegisteredProductName().split("\\("); + ybDrug.setApprovalCode(charArr[0]); + } + +// udiProductEntity.setNameCode(thrProductsEntity.getCode()); + udiProductEntity.setPrepnSpec(ybDrug.getRealityOutlook()); + udiProductEntity.setZczbhhzbapzbh(ybDrug.getApprovalCode()); + udiProductEntity.setCpmctymc(ybDrug.getRegisteredProductName()); + udiProductEntity.setSpmc(ybDrug.getGoodsName()); + + udiProductEntity.setBzgg(String.valueOf(ybDrug.getFactor()) + ybDrug.getMinUnit() + "/" + ybDrug.getUnit()); + udiProductEntity.setMatrial(ybDrug.getMaterialName()); + udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); + udiProductEntity.setMedicareType(udiContrastService.setMedicareType(ybDrug.getProductInsuranceType())); + //最小产品单位 + udiProductEntity.setPackUnit(ybDrug.getUnit()); + //设置最小产品数量 + udiProductEntity.setBhxjsl(ybDrug.getFactor()); + + //生产厂家 + udiProductEntity.setManufactory(ybDrug.getCompanyNameSc()); + //商品条码 essentialDrugMarkName sptm +// udiProductEntity.setSptm(ybDrug.getBusinessLicense()); + udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); + } else { + udiProductEntity.setCpmctymc(thrProductsEntity.getName()); + } + + + udiProductEntity.setNameCode(CopyUtils.copyNullStr(udiProductEntity.getNameCode(), thirdAliDrug.getNameCode())); // 数据处理 - udiProductEntity.setPrepnSpec(thirdAliDrug.getFormSpec()); - udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); - udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); - udiProductEntity.setSpmc(thirdAliDrug.getSpmc()); + udiProductEntity.setPrepnSpec(CopyUtils.copyNullStr(udiProductEntity.getPrepnSpec(), thirdAliDrug.getFormSpec())); + udiProductEntity.setZczbhhzbapzbh(CopyUtils.copyNullStr(udiProductEntity.getZczbhhzbapzbh(), thirdAliDrug.getApprovalNum())); + udiProductEntity.setCpmctymc(CopyUtils.copyNullStr(udiProductEntity.getCpmctymc(), thirdAliDrug.getCpmctymc())); + udiProductEntity.setSpmc(CopyUtils.copyNullStr(udiProductEntity.getSpmc(), thirdAliDrug.getSpmc())); - udiProductEntity.setBzgg(thirdAliDrug.getBzgg()); + udiProductEntity.setBzgg(CopyUtils.copyNullStr(udiProductEntity.getBzgg(), thirdAliDrug.getBzgg())); + udiProductEntity.setPackRatio(CopyUtils.copyNullStr(udiProductEntity.getPackRatio(), thirdAliDrug.getPackRatio())); // udiProductEntity.setMatrial(ybDrug.getMaterialName()); // udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); // udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType())); //最小产品单位 - udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); + udiProductEntity.setPackUnit(CopyUtils.copyNullStr(udiProductEntity.getPackUnit(), thirdAliDrug.getPackUnitName())); //设置最小产品数量 // udiProductEntity.setBhxjsl(ybDrug.getFactor()); //生产厂家 - udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); +// udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); - udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); + udiProductEntity.setPrepnUnit(CopyUtils.copyNullStr(udiProductEntity.getPrepnUnit(), thirdAliDrug.getPrepnUnitName())); List integers = new ArrayList<>(); if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { @@ -707,9 +757,6 @@ public class UdiProductServiceImpl implements UdiProductService { udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); udiProductEntity.setId(IdUtil.getSnowflakeNextId()); - udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); - udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); - udiProductService.insertUdiInfo(udiProductEntity); } } diff --git a/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java index fe2b93b7..3df76754 100644 --- a/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java @@ -1,6 +1,7 @@ package com.glxp.api.util.alihealth; import cn.hutool.core.bean.BeanUtil; +import com.glxp.api.util.StringUtils; import java.lang.reflect.Field; import java.util.Map; @@ -8,6 +9,10 @@ import java.util.Objects; import java.util.Set; public class CopyUtils { + // 第一个参数为空才复制 + public static String copyNullStr(String str,String strNew){ + return StringUtils.isNotEmpty(str) ? str : strNew; + } public static void compatibleCopy(Map map, Object target) { try { diff --git a/src/main/resources/mybatis/mapper/thrsys/ThirdAliDrugMapper.xml b/src/main/resources/mybatis/mapper/thrsys/ThirdAliDrugMapper.xml index bca2f63c..86dab9f1 100644 --- a/src/main/resources/mybatis/mapper/thrsys/ThirdAliDrugMapper.xml +++ b/src/main/resources/mybatis/mapper/thrsys/ThirdAliDrugMapper.xml @@ -91,7 +91,9 @@ #{id} - + + AND manufacturer LIKE concat('%', #{manufacturer}, '%') + order by cpmctymc,approvalNum,packRatio,packLevel