From 5c04226f7879df60f9ede9912410a7eadadf6657 Mon Sep 17 00:00:00 2001 From: qiuyt Date: Mon, 23 Dec 2024 19:51:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E4=BB=8E=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E9=80=89=E5=85=A5=E8=8D=AF=E5=93=81=E6=90=AC=E5=88=B0?= =?UTF-8?q?=E5=86=85=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AlihealthThirdAliDrugInsertReqeust.java | 2 + .../api/service/basic/UdiContrastService.java | 29 ++++---- .../glxp/api/util/alihealth/CopyUtils.java | 66 +++++++++++++++++++ 3 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/glxp/api/util/alihealth/CopyUtils.java diff --git a/src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java index 7fae9155c..3e0f00a54 100644 --- a/src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java +++ b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java @@ -7,5 +7,7 @@ import lombok.Data; public class AlihealthThirdAliDrugInsertReqeust { private String erpId; private String appSecret; + private String manufactory; + private AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust; } 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 61fed888b..940d17fc2 100644 --- a/src/main/java/com/glxp/api/service/basic/UdiContrastService.java +++ b/src/main/java/com/glxp/api/service/basic/UdiContrastService.java @@ -21,6 +21,7 @@ import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse; import com.glxp.api.service.auth.AuthAliUserService; import com.glxp.api.service.thrsys.*; import com.glxp.api.util.*; +import com.glxp.api.util.alihealth.CopyUtils; import lombok.extern.slf4j.Slf4j; import org.apache.xmlbeans.impl.xb.xsdschema.Public; import org.aspectj.weaver.ast.Var; @@ -354,6 +355,8 @@ public class UdiContrastService { udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); + }else { + udiProductEntity.setCpmctymc(thrProductsEntity.getName()); } if (StrUtil.isEmpty(udiProductEntity.getZczbhhzbapzbh()) || StrUtil.isEmpty(udiProductEntity.getCpmctymc())) { return; @@ -362,6 +365,8 @@ public class UdiContrastService { new QueryWrapper() .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getManufactory()), "manufacturer", udiProductEntity.getManufactory()) + ); if (CollUtil.isNotEmpty(thirdAliDrugList)) { @@ -370,6 +375,7 @@ public class UdiContrastService { AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid()); alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret()); + alihealthThirdAliDrugInsertReqeust.setManufactory(udiProductEntity.getManufactory()); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc()); alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh()); @@ -388,6 +394,8 @@ public class UdiContrastService { new QueryWrapper() .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getManufactory()), "manufacturer", udiProductEntity.getManufactory()) + ); } else { log.info("供应商平台获取阿里和国家库码段信息===未查到产品信息"); @@ -423,27 +431,26 @@ 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.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.setPackLevel(1 + ""); //生产厂家 - udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); +// udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); - udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); - udiProductEntity.setPackRatio(thirdAliDrug.getPackRatio()); + 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/util/alihealth/CopyUtils.java b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java new file mode 100644 index 000000000..0ca947927 --- /dev/null +++ b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java @@ -0,0 +1,66 @@ +package com.glxp.api.util.alihealth; + +import com.glxp.api.util.StringUtils; + +import java.lang.reflect.Field; +import java.util.Map; +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 { + + Class targetClass = target.getClass();//得到对象的Class + Field[] targetFields = targetClass.getDeclaredFields();//得到Class对象的所有属性 + Set keySet =map.keySet(); //获取到所有值 + for(Object key : keySet ) { + Object value = map.get(key); + + + for (Field targetField : targetFields) { + targetField.setAccessible(true); + + String targetName = targetField.getName();//目标对象的属性名 + + + if (targetName.equals(snakeToCamel((String) key)) && !Objects.isNull(value)) { + targetField.set(target, value); + } + } + } + + + } catch (Exception e) { + System.out.println("错误==="+e); + + e.printStackTrace(); +// BeanUtil.copyProperties(source, target); + + } + + } + public static String snakeToCamel(String snakeCase) { + // 将字符串按下划线分割 + String[] parts = snakeCase.split("_"); + + StringBuilder camelCase = new StringBuilder(); + + for (String part : parts) { + if (camelCase.length() == 0) { + // 第一个单词首字母小写 + camelCase.append(part.toLowerCase()); + } else { + // 其他单词首字母大写 + camelCase.append(part.substring(0, 1).toUpperCase()) + .append(part.substring(1).toLowerCase()); + } + } + + return camelCase.toString(); + } +} From 1f791a88e74b06c0b2fb7da207b2e50ec4754cb1 Mon Sep 17 00:00:00 2001 From: wangwei <1610949092@qq.com> Date: Mon, 23 Dec 2024 20:56:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?12/23=20=E5=90=8C=E6=AD=A5=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E6=95=B0=E6=8D=AE=E4=BE=9B=E5=BA=94=E5=95=86=E5=85=B3?= =?UTF-8?q?=E8=81=94=E4=BA=A7=E5=93=81=E5=91=A2=E5=9F=BA=E7=A1=80=E6=95=B0?= =?UTF-8?q?=E6=8D=AE1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/glxp/api/service/sync/HeartService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/glxp/api/service/sync/HeartService.java b/src/main/java/com/glxp/api/service/sync/HeartService.java index 7038fb763..cfc7503c0 100644 --- a/src/main/java/com/glxp/api/service/sync/HeartService.java +++ b/src/main/java/com/glxp/api/service/sync/HeartService.java @@ -1882,6 +1882,7 @@ public class HeartService { // basicProductsDao.replaceBatchs(productsList, 1000); } if (CollectionUtil.isNotEmpty(relevanceList)) { + relevanceDao.replaceBatch(relevanceList); } if (CollectionUtil.isNotEmpty(corpList)) { corpDao.replaceBatch(corpList);