From a240f24839a9158dcdcfdff88a43bb7b6e2e3bd1 Mon Sep 17 00:00:00 2001 From: qiuyt Date: Mon, 2 Dec 2024 19:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E5=85=A5=E8=8D=AF=E5=93=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alihealth/AlihealthBusController.java | 72 +++++ .../controller/test/TestCodeController.java | 4 +- .../AlihealthThirdAliDrugInsertReqeust.java | 1 + .../api/service/basic/UdiContrastService.java | 255 ++++++++++-------- .../api/util/alihealth/AlihealthUtils.java | 29 +- 5 files changed, 247 insertions(+), 114 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java b/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java index 3bf1f0a6..48ddc83f 100644 --- a/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java +++ b/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java @@ -1,12 +1,22 @@ package com.glxp.api.controller.alihealth; +import cn.hutool.core.collection.CollUtil; import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.glxp.api.annotation.Log; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.constant.BusinessType; +import com.glxp.api.entity.auth.CustomerInfoEntity; +import com.glxp.api.entity.thrsys.ThirdAliDrug; +import com.glxp.api.exception.JsonException; +import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust; import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust; +import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; +import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.alihealth.AlihealthKytGetentinfoResponse; import com.glxp.api.util.alihealth.AlihealthUtils; import lombok.extern.slf4j.Slf4j; @@ -17,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; import java.util.Map; @Slf4j @@ -26,6 +38,8 @@ public class AlihealthBusController { private AlihealthUtils alihealthUtils; @Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}") private String alihealthUrl; + @Value("${UDI_SERVER_URL}") + private String udiUrl; @PostMapping("/spms/alihealth/relCodeInsert") @Log(title = "阿里健康自动赋码关联关系", businessType = BusinessType.OTHER) public BaseResponse relCodeInsert(@RequestBody AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust) { @@ -67,4 +81,62 @@ public class AlihealthBusController { } } + @PostMapping("/spms/alihealth/thirdAliDrugList") + @Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER) + public BaseResponse> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) { + AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust(); + + Map map = new HashMap(); + if(com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())){ + map.put("cpmctymc",alihealthKytDrugrescodeReqeust.getPhysic_name()); + + } + if(com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())){ + map.put("approvalNum",alihealthKytDrugrescodeReqeust.getApproval_licence_no()); + + } + List thirdAliDrugsListGjk = null; + + try { + String response = HttpUtil.get(udiUrl+"/udiwms/aliDrug/getDrugLevelList",map); + BaseResponse> udiDlDeviceResponse = + JSONObject.parseObject(response, new TypeReference>>() { + + }); + if (udiDlDeviceResponse != null + ) { + // 查询国家库是否有值 有值直接返回没值查询阿里接口 + thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); + } + } catch (Exception e) { + log.error("国家库查询阿里产品访问出现错误==="+e.getMessage()); + } + + if(thirdAliDrugsListGjk!= null && thirdAliDrugsListGjk.size() >0){ + return ResultVOUtils.success(thirdAliDrugsListGjk); + }else { + List thirdAliDrugListNew; + BaseResponse> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust,true); + if(baseResponse.getCode() == 20000){ + thirdAliDrugListNew = baseResponse.getData(); + }else { + log.error("阿里接口未查到产品信息==="+baseResponse.getMessage()); + throw new JsonException(500, "阿里接口未查到产品信息"); + + } + // 上传到国家库 + try { + Map mapNew = new HashMap(); + mapNew.put("list",thirdAliDrugListNew); + String response = HttpUtil.post(udiUrl+"/udiwms/aliDrug/addThirdAliDrug", JSONUtil.toJsonStr(mapNew)); + BaseResponse baseResponseAdd = JSONUtil.toBean(response,BaseResponse.class); + log.info("成功上传国家库阿里产品数据"); + } catch (Exception e) { + log.error("国家库上传阿里产品访问出现错误==="+e.getMessage()); + } + return ResultVOUtils.success(thirdAliDrugListNew); + + } +// udiProductService.insertUdiInfo(udiProductEntity); + } } diff --git a/src/main/java/com/glxp/api/controller/test/TestCodeController.java b/src/main/java/com/glxp/api/controller/test/TestCodeController.java index f5156e13..b3a0d4da 100644 --- a/src/main/java/com/glxp/api/controller/test/TestCodeController.java +++ b/src/main/java/com/glxp/api/controller/test/TestCodeController.java @@ -93,7 +93,7 @@ public class TestCodeController { alihealthKytDrugrescodeReqeust.setApp_key("31721223"); alihealthKytDrugrescodeReqeust.setRef_ent_id("ef99b78bd9c54c1284f813149c858fb0"); alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); - BaseResponse> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust); + BaseResponse> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust,true); if(baseResponse.getCode() == 20000){ List list = baseResponse.getData(); if(list!=null && list.size() >0){ @@ -113,7 +113,7 @@ public class TestCodeController { } - return alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust); + return alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust,true); } @PostMapping("/test2") public BaseResponse test2() { 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 7fae9155..79c1bea8 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,6 @@ import lombok.Data; public class AlihealthThirdAliDrugInsertReqeust { private String erpId; private String appSecret; + 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 22ff8fdc..af9cfe58 100644 --- a/src/main/java/com/glxp/api/service/basic/UdiContrastService.java +++ b/src/main/java/com/glxp/api/service/basic/UdiContrastService.java @@ -227,7 +227,6 @@ public class UdiContrastService { @Resource ThirdAliDrugService thirdAliDrugService; - // @Transactional public void createOnlyMainId(String mainId) { FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest(); @@ -260,15 +259,15 @@ public class UdiContrastService { UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); + YbDrug ybDrug=new YbDrug(); if (list != null && list.size() > 0) { - YbDrug ybDrug = list.get(0); + ybDrug = list.get(0); // 数据做处理好查询阿里接口 - ybDrug.setRegisteredProductName(ybDrug.getRegisteredProductName().replace("(", "(").replace(")", ")")); - if (ybDrug.getApprovalCode().contains("(")) { - String[] charArr = ybDrug.getRegisteredProductName().split("\\("); - ybDrug.setRegisteredProductName(charArr[0]); + if(ybDrug.getApprovalCode().contains("(")){ + String[] charArr = ybDrug.getRegisteredProductName().split("\\("); + ybDrug.setApprovalCode(charArr[0]); } - ybDrug.setApprovalCode(ybDrug.getApprovalCode().replace("(", "(").replace(")", ")")); + udiProductEntity.setId(IdUtil.getSnowflakeNextId()); @@ -309,127 +308,171 @@ public class UdiContrastService { udiProductEntity.setUpdateTime(new Date()); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); - List thirdAliDrugList = thirdAliDrugService.list( - new QueryWrapper() - .eq(StringUtils.isNotEmpty(ybDrug.getRegisteredProductName()), "cpmctymc", ybDrug.getRegisteredProductName()) - .eq(StringUtils.isNotEmpty(ybDrug.getApprovalCode()), "approvalNum", ybDrug.getApprovalCode()) - ); - if (CollUtil.isNotEmpty(thirdAliDrugList)) { - } else { - Map map = new HashMap(); - if (StringUtils.isNotEmpty(ybDrug.getRegisteredProductName())) { - map.put("cpmctymc", ybDrug.getRegisteredProductName()); + } else { - } - if (StringUtils.isNotEmpty(ybDrug.getApprovalCode())) { - map.put("approvalNum", ybDrug.getApprovalCode()); + // 数据处理 + udiProductEntity.setId(IdUtil.getSnowflakeNextId()); +// udiProductEntity.setNameCode(thrProductsEntity.getCode()); - } - List thirdAliDrugsListGjk = null; + udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); + udiProductEntity.setDiType(1); + udiProductEntity.setScbssfbhph("是"); + udiProductEntity.setScbssfbhscrq("是"); + udiProductEntity.setScbssfbhsxrq("是"); + udiProductEntity.setScbssfbhxlh("否"); + udiProductEntity.setProductsType(thrProductsEntity.getProductType()); + udiProductEntity.setRequireScanCode(1); + udiProductEntity.setMajorStatus(1); + udiProductEntity.setPhysicType(3); + if (StrUtil.isEmpty(udiProductEntity.getPrice())) { + udiProductEntity.setPrice("0.00"); + } + udiProductEntity.setUpdateTime(new Date()); + udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); + + } + 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 { + Map map = new HashMap(); + if(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc())){ + map.put("cpmctymc",udiProductEntity.getCpmctymc()); - try { - String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", map); - BaseResponse> udiDlDeviceResponse = - JSONObject.parseObject(response, new TypeReference>>() { + } + if(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh())){ + map.put("approvalNum",udiProductEntity.getZczbhhzbapzbh()); - }); - if (udiDlDeviceResponse != null) { - // 查询国家库是否有值 有值直接返回没值查询阿里接口 - thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); + } + List thirdAliDrugsListGjk = null; + + try { + String response = HttpUtil.get(udiUrl+"/udiwms/aliDrug/getDrugLevelList",map); + BaseResponse> udiDlDeviceResponse = + JSONObject.parseObject(response, new TypeReference>>() { + + }); + if (udiDlDeviceResponse != null) { + // 查询国家库是否有值 有值直接返回没值查询阿里接口 + thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); - } - } catch (Exception e) { - log.error("国家库查询阿里产品访问出现错误===" + e.getMessage()); } + } catch (Exception e) { + log.error("国家库查询阿里产品访问出现错误==="+e.getMessage()); + } - if (thirdAliDrugService.addOrUpdate(thirdAliDrugsListGjk)) { - - } else { - List thirdAliDrugListNew = null; - - AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); - alihealthThirdAliDrugInsertReqeust.setErpId("73157692795424"); - alihealthThirdAliDrugInsertReqeust.setAppSecret("5231c601505706a9d49823c3dfe2cb01"); - AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); - alihealthKytDrugrescodeReqeust.setPhysic_name(ybDrug.getRegisteredProductName()); - alihealthKytDrugrescodeReqeust.setApproval_licence_no(ybDrug.getApprovalCode()); - alihealthKytDrugrescodeReqeust.setPage_size(100); - alihealthKytDrugrescodeReqeust.setPage(1); - alihealthKytDrugrescodeReqeust.setApp_key("31721223"); - alihealthKytDrugrescodeReqeust.setRef_ent_id("ef99b78bd9c54c1284f813149c858fb0"); - alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); - BaseResponse> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust); - if (baseResponse.getCode() == 20000) { - thirdAliDrugListNew = baseResponse.getData(); - thirdAliDrugService.addOrUpdate(thirdAliDrugListNew); - - } else { - udiProductService.insertUdiInfo(udiProductEntity); - log.error("阿里接口未查到产品信息===" + baseResponse.getMessage()); + if(thirdAliDrugService.addOrUpdate(thirdAliDrugsListGjk)){ + + }else { + List thirdAliDrugListNew = null; + + 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 = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust,true); + if(baseResponse.getCode() == 20000){ + thirdAliDrugListNew = baseResponse.getData(); + thirdAliDrugService.addOrUpdate(thirdAliDrugListNew); + + }else { + udiProductService.insertUdiInfo(udiProductEntity); + log.error("阿里接口未查到产品信息==="+baseResponse.getMessage()); // throw new JsonException(500, "阿里接口未查到产品信息"); + } + if(thirdAliDrugListNew!=null && thirdAliDrugListNew.size() > 0 ){ + try { + // 上传到国家库 + Map mapNew = new HashMap(); + mapNew.put("list",thirdAliDrugListNew); + String response = HttpUtil.post(udiUrl+"/udiwms/aliDrug/addThirdAliDrug", JSONUtil.toJsonStr(mapNew)); + BaseResponse baseResponseAdd = JSONUtil.toBean(response,BaseResponse.class); + log.info("成功上传国家库阿里产品数据"); + } catch (Exception e) { + log.error("国家库上传阿里产品访问出现错误==="+e.getMessage()); } - if (thirdAliDrugListNew != null && thirdAliDrugListNew.size() > 0) { - try { - // 上传到国家库 - Map mapNew = new HashMap(); - mapNew.put("list", thirdAliDrugListNew); - String response = HttpUtil.post(udiUrl + "/udiwms/aliDrug/addThirdAliDrug", JSONUtil.toJsonStr(mapNew)); - BaseResponse baseResponseAdd = JSONUtil.toBean(response, BaseResponse.class); - log.info("成功上传国家库阿里产品数据"); - } catch (Exception e) { - log.error("国家库上传阿里产品访问出现错误===" + e.getMessage()); - } - } - } -// udiProductService.insertUdiInfo(udiProductEntity); } + thirdAliDrugList = thirdAliDrugService.list( new QueryWrapper() - .eq(StringUtils.isNotEmpty(ybDrug.getRegisteredProductName()), "cpmctymc", ybDrug.getRegisteredProductName()) - .eq(StringUtils.isNotEmpty(ybDrug.getApprovalCode()), "approvalNum", ybDrug.getApprovalCode()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()),"cpmctymc",udiProductEntity.getCpmctymc()) + .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()),"approvalNum",udiProductEntity.getZczbhhzbapzbh()) ); - 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); - } +// udiProductService.insertUdiInfo(udiProductEntity); + } - 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 || !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()); + 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.setId(IdUtil.getSnowflakeNextId()); - udiProductService.insertUdiInfo(udiProductEntity); + 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()); } - } else { + 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); diff --git a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java index 2f5c9dbd..25094042 100644 --- a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java @@ -60,6 +60,7 @@ public class AlihealthUtils { //// AlibabaAlihealthDrugtraceTopLsydQueryRelationResponse alibabaAlihealthDrugtraceTopLsydQueryRelationResponse // // } + /** * 通过时间段批量查询入出库单信息 * @@ -98,12 +99,13 @@ public class AlihealthUtils { } } + /** * 查询药品码段信息 * * @param alihealthThirdAliDrugInsertReqeust */ - public BaseResponse> thirdAliDrugInsert(AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) { + public BaseResponse> thirdAliDrugInsert(AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust, Boolean callBool) { if (alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust() == null) { return ResultVOUtils.error("入参不能为空"); } @@ -132,6 +134,21 @@ public class AlihealthUtils { List list = alihealthKytDrugrescodeResponse.disposeThirdAliDrugList(alihealthThirdAliDrugInsertReqeust.getErpId()); return ResultVOUtils.success(list); } else { + // 重新上传标识为true就改变一下 + if ("未查询到相关信息".equals(alihealthKytDrugrescodeResponse.getMsg_info()) + && callBool) { + String physicName = alihealthKytDrugrescodeReqeust.getPhysic_name(); + if (physicName.contains("(")) { + physicName = physicName.replace("(", "(").replace(")", ")"); + + } else if (physicName.contains("(")) { + physicName = physicName.replace("(", "(").replace(")", ")"); + + } + alihealthKytDrugrescodeReqeust.setPhysic_name(physicName); + alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); + thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust, false); + } return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthKytDrugrescodeResponse.getMsg_info()); } @@ -176,7 +193,7 @@ public class AlihealthUtils { public Map disposeSign(AlihealthKytCommonParametersReqeust alihealthKytCommonParametersReqeust, String secret) { - Map map = BeanUtil.beanToMap(alihealthKytCommonParametersReqeust); + Map map = BeanUtil.beanToMap(alihealthKytCommonParametersReqeust); String sign; try { sign = new AlihealthUtils().signTopRequest(map, secret, "md5"); @@ -189,7 +206,7 @@ public class AlihealthUtils { } - public String signTopRequest(Map params, String secret, String signMethod) throws IOException { + public String signTopRequest(Map params, String secret, String signMethod) throws IOException { // 第一步:检查参数是否已经排序 String[] keys = params.keySet().toArray(new String[0]); Arrays.sort(keys); @@ -201,11 +218,11 @@ public class AlihealthUtils { } for (String key : keys) { Object value = params.get(key); - if(value instanceof String){ - if ( StringUtils.areNotEmpty(key, (String) value)) { + if (value instanceof String) { + if (StringUtils.areNotEmpty(key, (String) value)) { query.append(key).append(value); } - }else { + } else { if (!Objects.isNull(value)) { query.append(key).append(value); }