From af003ea3cf28b5e731a7abbc2df8111999ba3444 Mon Sep 17 00:00:00 2001 From: qiuyt Date: Wed, 4 Dec 2024 16:03:42 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=80=89=E5=85=A5=E8=8D=AF=E5=93=81?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=9B=BD=E5=AE=B6=E5=BA=93=E6=88=96=E8=80=85?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E6=8E=A5=E5=8F=A3=E8=BF=9B=E8=A1=8C=E6=8B=89?= =?UTF-8?q?=E5=8F=96=E8=8D=AF=E5=93=81=E7=A0=81=E6=AE=B5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E6=88=91=E4=BB=AC=E7=9A=84=E8=A1=A8=202?= =?UTF-8?q?=E3=80=81=E5=8C=BB=E4=BF=9D=E6=8E=A5=E5=8F=A3=E4=B9=9F=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E6=97=B6=E5=80=99=E4=B9=9F=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=203=E3=80=81=E5=8C=BB=E4=BF=9D=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../glxp/api/entity/thrsys/ThirdAliDrug.java | 37 +++- .../glxp/api/http/sync/SpGetHttpClient.java | 13 ++ .../AlihealthKytCommonParametersReqeust.java | 57 ++++++ .../AlihealthKytDrugrescodeReqeust.java | 23 +++ .../AlihealthThirdAliDrugInsertReqeust.java | 11 + .../basic/BasicBackUpdateProductService.java | 3 +- .../api/service/basic/UdiContrastService.java | 193 +++++++++++++----- .../service/thrsys/ThirdAliDrugService.java | 26 +++ .../thrsys/impl/ThrProductsServiceImpl.java | 41 ++-- src/main/java/com/glxp/api/util/DimaUtil.java | 4 +- src/main/resources/schemas/schema_v2.4.sql | 36 ++++ 11 files changed, 374 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/glxp/api/req/alihealth/AlihealthKytCommonParametersReqeust.java create mode 100644 src/main/java/com/glxp/api/req/alihealth/AlihealthKytDrugrescodeReqeust.java create mode 100644 src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java diff --git a/src/main/java/com/glxp/api/entity/thrsys/ThirdAliDrug.java b/src/main/java/com/glxp/api/entity/thrsys/ThirdAliDrug.java index 7d791aa6f..afcea4eeb 100644 --- a/src/main/java/com/glxp/api/entity/thrsys/ThirdAliDrug.java +++ b/src/main/java/com/glxp/api/entity/thrsys/ThirdAliDrug.java @@ -123,7 +123,42 @@ public class ThirdAliDrug implements Serializable { private Date updateTime; - + /** + * 制剂单位描述 + */ + @TableField(value = "prepnUnit") + @ApiModelProperty(value = "制剂单位描述") + private String prepnUnit; + /** + * 制剂单位描述 + */ + @TableField(value = "prepnUnitName") + @ApiModelProperty(value = "制剂单位描述") + private String prepnUnitName; + /** + * 药品详情类型 + */ + @TableField(value = "physicDetailType") + @ApiModelProperty(value = "药品详情类型") + private String physicDetailType; + /** + * 药品类型详情描述 + */ + @TableField(value = "physicDetailTypeDesc") + @ApiModelProperty(value = "药品类型详情描述") + private String physicDetailTypeDesc; + /** + * 药品类型描述 + */ + @TableField(value = "physicTypeDesc") + @ApiModelProperty(value = "药品类型描述") + private String physicTypeDesc; + /** + * 包装单位 + */ + @TableField(value = "packUnitName") + @ApiModelProperty(value = "包装单位") + private String packUnitName; private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java index a58fc31ce..96f08f4c1 100644 --- a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java +++ b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java @@ -17,8 +17,10 @@ import com.glxp.api.entity.sync.IOOrderStatusEntity; import com.glxp.api.entity.sync.SyncEditLogEntity; import com.glxp.api.entity.sync.SyncEditTypeEntity; import com.glxp.api.entity.system.SyncDataSetEntity; +import com.glxp.api.entity.thrsys.ThirdAliDrug; import com.glxp.api.idc.service.FileService; import com.glxp.api.req.alihealth.AlihealthRelCodeInsertReqeust; +import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; import com.glxp.api.req.basic.BasicDataRequest; import com.glxp.api.req.basic.DeleteBasicDataRequest; import com.glxp.api.req.basic.ProductInfoFilterRequest; @@ -671,4 +673,15 @@ public class SpGetHttpClient { } return response; } + public BaseResponse thirdAliDrugList(AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) { + String json = JSONUtil.toJsonStr(alihealthThirdAliDrugInsertReqeust); + String result = okHttpCli.doPostJson(getIpUrl() + "/directToSpms" + "/spms/alihealth/thirdAliDrugList", json, buildHeader()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference() { + }); + if(response == null){ + return ResultVOUtils.error("访问供应商平台访问不到"); + } + return response; + } } diff --git a/src/main/java/com/glxp/api/req/alihealth/AlihealthKytCommonParametersReqeust.java b/src/main/java/com/glxp/api/req/alihealth/AlihealthKytCommonParametersReqeust.java new file mode 100644 index 000000000..1c87a222b --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/AlihealthKytCommonParametersReqeust.java @@ -0,0 +1,57 @@ +package com.glxp.api.req.alihealth; + +import lombok.Data; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 基础参数 + */ +@Data +public class AlihealthKytCommonParametersReqeust { + /** + * API接口名称 + */ + private String method; + /** + * key + */ + private String app_key; + /** + * 授权 + */ + private String session; + /** + * 时间 + */ + private String timestamp; + /** + * 版本号 + */ + private String v; + /** + * 签名的摘要算法 + */ + private String sign_method; + /** + * 签名的摘要算法 + */ + private String sign; + /** + * 响应格式 + */ + private String format; +// /** +// * 精简开关 +// */ +// private boolean simplify; + public AlihealthKytCommonParametersReqeust(){ + this.timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + this.v = "2.0"; + this.sign_method = "md5"; + this.format = "json"; + + } + +} diff --git a/src/main/java/com/glxp/api/req/alihealth/AlihealthKytDrugrescodeReqeust.java b/src/main/java/com/glxp/api/req/alihealth/AlihealthKytDrugrescodeReqeust.java new file mode 100644 index 000000000..b544fc057 --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/AlihealthKytDrugrescodeReqeust.java @@ -0,0 +1,23 @@ +package com.glxp.api.req.alihealth; + +import lombok.Data; + +@Data +public class AlihealthKytDrugrescodeReqeust extends AlihealthKytCommonParametersReqeust { + private String ref_ent_id; + private String physic_name; + private String approval_licence_no; + private String start_date; + private String end_date; + private String ent_name; + private String package_spec; + + private String prepn_spec; + private Integer page_size; + private Integer page; + + + public AlihealthKytDrugrescodeReqeust(){ + this.setMethod("alibaba.alihealth.drug.kyt.drugrescode"); + } +} 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 new file mode 100644 index 000000000..7fae9155c --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthThirdAliDrugInsertReqeust.java @@ -0,0 +1,11 @@ +package com.glxp.api.req.alihealth.local; + +import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; +import lombok.Data; + +@Data +public class AlihealthThirdAliDrugInsertReqeust { + private String erpId; + private String appSecret; + private AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust; +} diff --git a/src/main/java/com/glxp/api/service/basic/BasicBackUpdateProductService.java b/src/main/java/com/glxp/api/service/basic/BasicBackUpdateProductService.java index 7bee1d157..125c6e597 100644 --- a/src/main/java/com/glxp/api/service/basic/BasicBackUpdateProductService.java +++ b/src/main/java/com/glxp/api/service/basic/BasicBackUpdateProductService.java @@ -250,8 +250,9 @@ public class BasicBackUpdateProductService { // udiRelevanceService.insertUdiRelevanceignore(udiRelevanceEntity1); // } try { +// Thread.sleep(2000); udiContrastService.createOnlyMainId(thrProductsEntity.getCode()); - } catch (JsonException e) { + } catch (Exception e) { } } 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 62e3ee3a2..5df99dcc3 100644 --- a/src/main/java/com/glxp/api/service/basic/UdiContrastService.java +++ b/src/main/java/com/glxp/api/service/basic/UdiContrastService.java @@ -1,14 +1,25 @@ package com.glxp.api.service.basic; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.TypeReference; +import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.entity.thrsys.*; import com.glxp.api.exception.JsonException; +import com.glxp.api.http.sync.SpGetHttpClient; +import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; +import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; import com.glxp.api.req.basic.YbDrugDetailFilterRequest; import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest; import com.glxp.api.req.thrsys.ThrInsMaterialFeeRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse; import com.glxp.api.service.thrsys.*; -import com.glxp.api.util.DimaUtil; -import com.glxp.api.util.IntUtil; +import com.glxp.api.util.*; +import lombok.extern.slf4j.Slf4j; import org.apache.xmlbeans.impl.xb.xsdschema.Public; import org.aspectj.weaver.ast.Var; import org.jfree.util.Log; @@ -26,23 +37,19 @@ import com.glxp.api.req.basic.UdiCombineRequest; import com.glxp.api.req.basic.FilterUdiRelRequest; import com.glxp.api.req.thrsys.FilterThrProductsRequest; import com.glxp.api.res.basic.UdiRelevanceResponse; -import com.glxp.api.util.CustomUtil; -import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.udi.UdiInfoUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** * 耗材字典对照 */ @Service +@Slf4j public class UdiContrastService { @Resource @@ -65,6 +72,8 @@ public class UdiContrastService { BasicInsMaterialService basicInsMaterialService; @Resource YbDrugService ybDrugService; + @Resource + private SpGetHttpClient spGetHttpClient; public boolean isExit(String originUuid, String mainId, String thirdSys) { @@ -275,15 +284,24 @@ public class UdiContrastService { if (thrProductsEntity.getYbbm() != null) { //判断药品还是器械 if (thrProductsEntity.getProductType() == 2) { + String error=null; 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(); + + // 数据处理 + udiProductEntity.setId(IdUtil.getSnowflakeNextId()); +// udiProductEntity.setNameCode(thrProductsEntity.getCode()); + udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); udiProductEntity.setDiType(1); udiProductEntity.setScbssfbhph("是"); @@ -294,21 +312,22 @@ public class UdiContrastService { udiProductEntity.setRequireScanCode(1); udiProductEntity.setMajorStatus(1); udiProductEntity.setPhysicType(3); - udiProductEntity.setCpmctymc(thrProductsEntity.getName()); - udiProductEntity.setBzgg(thrProductsEntity.getSpec() + "/" + thrProductsEntity.getMeasname()); - udiProductEntity.setMeasname(thrProductsEntity.getMeasname()); - udiProductEntity.setNameCode(thrProductsEntity.getCode()); - + //设置包装级别 + udiProductEntity.setPackLevel(1 + ""); if (StrUtil.isEmpty(udiProductEntity.getPrice())) { udiProductEntity.setPrice("0.00"); } udiProductEntity.setUpdateTime(new Date()); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); - List list = ybDrugService.getList(ybHcflDetailFilterRequest); if (list != null && list.size() > 0) { - YbDrug ybDrug = list.get(0); - udiProductEntity.setId(IdUtil.getSnowflakeNextId()); + 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()); @@ -323,54 +342,131 @@ public class UdiContrastService { udiProductEntity.setPackUnit(ybDrug.getUnit()); //设置最小产品数量 udiProductEntity.setBhxjsl(ybDrug.getFactor()); - //设置包装级别 - udiProductEntity.setPackLevel(1 + ""); + //生产厂家 udiProductEntity.setManufactory(ybDrug.getCompanyNameSc()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); - List thirdAliDrugList = thirdAliDrugService.findByByApproved(ybDrug.getApprovalCode()); - if (CollUtil.isNotEmpty(thirdAliDrugList)) { - for (int i = 0; i < thirdAliDrugList.size(); i++) { - ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); - List integers = new ArrayList<>(); - if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { - integers = DimaUtil.calculateLevels(thirdAliDrug.getPackRatio()); - } - udiProductEntity.setPackLevel(thirdAliDrug.getPackLevel()); - try { - udiProductEntity.setBhxjsl(integers.get(IntUtil.value(thirdAliDrug.getPackLevel()) - 1)); - } catch (IndexOutOfBoundsException e) { - e.printStackTrace(); - Log.error("计算包装级别出错" + thirdAliDrug.getPackLevel() + "---" + integers + "-----" + thirdAliDrug.toString()); - } - - udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); - if (IntUtil.value(thirdAliDrug.getPackLevel()) == 1) { - udiProductEntity.setXjdw(ybDrug.getMinUnit()); - if (DimaUtil.trMinCount(thirdAliDrug.getBzgg()) != null) { - udiProductEntity.setBhxjsl(DimaUtil.trMinCount(thirdAliDrug.getBzgg())); - } else - udiProductEntity.setBhxjsl(ybDrug.getFactor()); - } - if (thirdAliDrug.getPackLevel() != null) { - udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4); - } - udiProductEntity.setId(IdUtil.getSnowflakeNextId()); + + } else { + + + + } + List thirdAliDrugList = thirdAliDrugService.list( + new QueryWrapper() + .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) + ); + if (CollUtil.isNotEmpty(thirdAliDrugList)) { + + } else { + AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); + alihealthThirdAliDrugInsertReqeust.setErpId("73157692795424"); + alihealthThirdAliDrugInsertReqeust.setAppSecret("5231c601505706a9d49823c3dfe2cb01"); + AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); + alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc()); + alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh()); + alihealthKytDrugrescodeReqeust.setPage_size(100); + alihealthKytDrugrescodeReqeust.setPage(1); + alihealthKytDrugrescodeReqeust.setApp_key("31721223"); + alihealthKytDrugrescodeReqeust.setRef_ent_id("ef99b78bd9c54c1284f813149c858fb0"); + alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); + BaseResponse baseResponse = spGetHttpClient.thirdAliDrugList(alihealthThirdAliDrugInsertReqeust); + if (baseResponse.getCode() == 20000) { + + try { + thirdAliDrugService.addOrUpdate((List) baseResponse.getData()); + thirdAliDrugList = thirdAliDrugService.list( + new QueryWrapper() + .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) + ); + }catch (Exception e){ + log.info("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage()); +// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage()); +// error = "供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage(); udiProductService.insertUdiInfo(udiProductEntity); + } + + } else { + log.info("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage()); +// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage()); +// error = "供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage(); + udiProductService.insertUdiInfo(udiProductEntity); + } - } else { - udiProductService.insertUdiInfo(udiProductEntity); + } + for (int i = 0; i < thirdAliDrugList.size(); i++) { + ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); + List integers = new ArrayList<>(); + if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { + integers = DimaUtil.calculateLevels(thirdAliDrug.getPackRatio()); + } + udiProductEntity.setPackLevel(thirdAliDrug.getPackLevel()); + try { + udiProductEntity.setBhxjsl(integers.get(IntUtil.value(thirdAliDrug.getPackLevel()) - 1)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + Log.error("计算包装级别出错" + thirdAliDrug.getPackLevel() + "---" + integers + "-----" + thirdAliDrug.toString()); + udiProductEntity.setBhxjsl(0); + } + + udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); + + // 数据处理 + udiProductEntity.setPrepnSpec(thirdAliDrug.getFormSpec()); + udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); + udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); + udiProductEntity.setSpmc(thirdAliDrug.getSpmc()); + + udiProductEntity.setBzgg(thirdAliDrug.getBzgg()); +// udiProductEntity.setMatrial(ybDrug.getMaterialName()); +// udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); +// udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType())); + //最小产品单位 + udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); + //设置最小产品数量 +// udiProductEntity.setBhxjsl(ybDrug.getFactor()); + //设置包装级别 + udiProductEntity.setPackLevel(1 + ""); + //生产厂家 + udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); + //商品条码 essentialDrugMarkName sptm +// udiProductEntity.setSptm(ybDrug.getBusinessLicense()); + udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); + + if (IntUtil.value(thirdAliDrug.getPackLevel()) == 1) { + udiProductEntity.setXjdw(ybDrug.getMinUnit()); + if (DimaUtil.trMinCount(thirdAliDrug.getBzgg()) != null) { + udiProductEntity.setBhxjsl(DimaUtil.trMinCount(thirdAliDrug.getBzgg())); + } else + udiProductEntity.setBhxjsl(ybDrug.getFactor()); + } + 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.setId(IdUtil.getSnowflakeNextId()); + udiProductService.insertUdiInfo(udiProductEntity); + + } // setLevel(udiRelevanceEntity.getUuid()); UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid()); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid); +// udiRelevanceEntity.setThirdId4(error); + udiRelevanceEntity.setProductsType(thrProductsEntity.getProductType()); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); udiProductService.updateLevelCount(udiRelevanceEntity); } else { @@ -410,6 +506,7 @@ public class UdiContrastService { udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); udiProductService.insertUdiInfo(udiProductEntity); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); + udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); } } else { diff --git a/src/main/java/com/glxp/api/service/thrsys/ThirdAliDrugService.java b/src/main/java/com/glxp/api/service/thrsys/ThirdAliDrugService.java index 4fb390282..23f3d87d1 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThirdAliDrugService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThirdAliDrugService.java @@ -3,7 +3,11 @@ package com.glxp.api.service.thrsys; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.dao.thrsys.ThirdAliDrugMapper; @@ -241,4 +245,26 @@ public class ThirdAliDrugService extends ServiceImpl findByByApproved(String approvalNum) { return this.baseMapper.selectList(new LambdaQueryWrapper().eq(ThirdAliDrug::getApprovalNum, approvalNum)); } + + public boolean addOrUpdate(List list) { + if(list!=null && list.size() >0){ + for (Object object : list) { + ThirdAliDrug thirdAliDrug = JSONUtil.toBean(object.toString(),ThirdAliDrug.class); + ThirdAliDrug thirdAliDrugNew = this.getOne(new QueryWrapper().eq("nameCode", thirdAliDrug.getNameCode()) + .last("limit 1") + ); + if (Objects.isNull(thirdAliDrugNew)) { + + this.save(thirdAliDrug); + + } else { + this.update(thirdAliDrug, new QueryWrapper().eq("nameCode", thirdAliDrug.getNameCode())); + } + } + return true; + + }else { + return false; + } + } } diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java index 2741bc48b..ea2a95d58 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java @@ -264,29 +264,32 @@ public class ThrProductsServiceImpl extends ServiceImpl list = baseResponse.getData().getList(); list.forEach(item -> { - ThrProductsEntity thrProductsEntity = thrProductsDao.selectByCodeAndThird(item.getCode(), item.getThirdSys()); - if (null == thrProductsEntity) { - thrProductsEntity = new ThrProductsEntity(); - BeanUtils.copyProperties(item, thrProductsEntity); - thrProductsEntity.setCreateTime(new Date()); - thrProductsEntity.setUpdateTime(new Date()); - if (StrUtil.isEmpty(item.getSpec())) { - thrProductsEntity.setSpec(item.getStandard()); - } - thrProductsEntity.setId(IdUtil.getSnowflakeNextId()); - thrProductsEntity.setThirdSysFk(filterThrProductsRequest.getThirdSys()); - thrProductsDao.insertThrProducts(thrProductsEntity); - } else { - boolean isChange = verifyDataChange(thrProductsEntity, item); - if (isChange) { - BeanUtil.copyProperties(item, thrProductsEntity, new CopyOptions().setIgnoreNullValue(true)); + if(StringUtils.isNotEmpty(item.getCode())){ + ThrProductsEntity thrProductsEntity = thrProductsDao.selectByCodeAndThird(item.getCode(), item.getThirdSys()); + if (null == thrProductsEntity) { + thrProductsEntity = new ThrProductsEntity(); + BeanUtils.copyProperties(item, thrProductsEntity); + thrProductsEntity.setCreateTime(new Date()); thrProductsEntity.setUpdateTime(new Date()); - if (StrUtil.isEmpty(thrProductsEntity.getSpec())) { - thrProductsEntity.setSpec(thrProductsEntity.getStandard()); + if (StrUtil.isEmpty(item.getSpec())) { + thrProductsEntity.setSpec(item.getStandard()); + } + thrProductsEntity.setId(IdUtil.getSnowflakeNextId()); + thrProductsEntity.setThirdSysFk(filterThrProductsRequest.getThirdSys()); + thrProductsDao.insertThrProducts(thrProductsEntity); + } else { + boolean isChange = verifyDataChange(thrProductsEntity, item); + if (isChange) { + BeanUtil.copyProperties(item, thrProductsEntity, new CopyOptions().setIgnoreNullValue(true)); + thrProductsEntity.setUpdateTime(new Date()); + if (StrUtil.isEmpty(thrProductsEntity.getSpec())) { + thrProductsEntity.setSpec(thrProductsEntity.getStandard()); + } + thrProductsDao.updateEntityById(thrProductsEntity); } - thrProductsDao.updateEntityById(thrProductsEntity); } } + }); //total = -666 表示出错,-555表示数据已经被过滤,可以进行下一页下载 if ((list.size() >= 1 && !baseResponse.getData().getTotal().equals(-666)) || IntUtil.value(baseResponse.getData().getTotal()) == -555) { diff --git a/src/main/java/com/glxp/api/util/DimaUtil.java b/src/main/java/com/glxp/api/util/DimaUtil.java index 1f1b5a2d3..95cccd2ed 100644 --- a/src/main/java/com/glxp/api/util/DimaUtil.java +++ b/src/main/java/com/glxp/api/util/DimaUtil.java @@ -22,7 +22,9 @@ public class DimaUtil { // 存储每层级的倍数关系 List calculatedLevels = new ArrayList<>(); for (int i = levels.length - 1; i > 0; i--) { - calculatedLevels.add(levels[i] / levels[i - 1]); + if(levels[i - 1] > 0){ + calculatedLevels.add(levels[i] / levels[i - 1]); + } } // 最后加上最小单位(第一层级为 1) diff --git a/src/main/resources/schemas/schema_v2.4.sql b/src/main/resources/schemas/schema_v2.4.sql index ee853f9b6..1d20bd8d4 100644 --- a/src/main/resources/schemas/schema_v2.4.sql +++ b/src/main/resources/schemas/schema_v2.4.sql @@ -4863,3 +4863,39 @@ CALL Pro_Temp_ColumnWork('sys_workplace', 'autoCollect', INSERT ignore INTO `sys_scheduled` (`id`, `cronName`, `cron`, `customerId`, `remark`) VALUES (160, 'ioCollectOrderReprocessTask', '0 */30 * * * ?', NULL, '自动重载异常第三方处方单'); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'prepnUnit', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''制剂单位描述''', + 1); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'prepnUnitName', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''制剂单位描述''', + 1); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'physicDetailType', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''药品详情类型''', + 1); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'physicDetailTypeDesc ', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''药品类型详情描述''', + 1); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'physicTypeDesc', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''药品类型描述''', + 1); +CALL Pro_Temp_ColumnWork('third_ali_drug', 'packUnitName', + ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''包装单位''', + 1); + + +CREATE TABLE IF NOT EXISTS `auth_ali_user` ( + `id` bigint NOT NULL, + `erpId` int DEFAULT NULL COMMENT '第三方ID', + `appKey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '阿里KEY', + `appSecret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '阿里密钥', + `refEntId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '厂家标识', + `type` varchar(255) DEFAULT NULL COMMENT '1 为生成企业 2为零售药店', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +INSERT IGNORE INTO auth_menu(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query_param`, + `is_frame`, + `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, + `update_by`, `update_time`, `remark`) + VALUES (5242, '医保上传统计', 5210, 999, 'inout/split/tag/stats', 'collect/CollectOrderStats', NULL, 1, 0, 'C', '0', '0', NULL, '', '超级用户', '2024-11-18 17:46:08', NULL, NULL, NULL); +