From 6c6f679beb22b6d760cd2232af817c528c5d70ce Mon Sep 17 00:00:00 2001 From: chenhc <2369838784@qq.com> Date: Tue, 15 Oct 2024 15:02:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=93=E5=A4=96=E8=AF=8A=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../udchs/UdchsThirdApiController.java | 9 + .../udidl/admin/res/chs/YbTwzdResponse.java | 195 ++++++++++++++++++ .../service/chsapi/ChsYbChsHttpClient.java | 31 ++- .../service/chsapi/ChsYbHcflService.java | 72 +++++++ .../service/udchs/impl/YbDrugServiceImpl.java | 4 +- 5 files changed, 306 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/glxp/udidl/admin/res/chs/YbTwzdResponse.java diff --git a/src/main/java/com/glxp/udidl/admin/controller/udchs/UdchsThirdApiController.java b/src/main/java/com/glxp/udidl/admin/controller/udchs/UdchsThirdApiController.java index 11f9253..37e3a5a 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/udchs/UdchsThirdApiController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/udchs/UdchsThirdApiController.java @@ -79,4 +79,13 @@ public class UdchsThirdApiController { ybDrugService.updateDrugList(); return ResultVOUtils.success("手动触发ybDrug数据更新!"); } + + + @ApiOperation("手动触发ybTwzd数据全量更新") +// @AuthRuleAnnotation("udiwms/erp/manual/trig/ybHcfl") + @PostMapping("/udiwms/erp/manual/trig/ybTwzd") + public BaseResponse manualTrigYbTwzdl() { + ybHcflService.updateYbTwzdList(); + return ResultVOUtils.success("手动触发ybTwzd数据全量更新!"); + } } diff --git a/src/main/java/com/glxp/udidl/admin/res/chs/YbTwzdResponse.java b/src/main/java/com/glxp/udidl/admin/res/chs/YbTwzdResponse.java new file mode 100644 index 0000000..97069fd --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/res/chs/YbTwzdResponse.java @@ -0,0 +1,195 @@ +package com.glxp.udidl.admin.res.chs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@NoArgsConstructor +@Data +public class YbTwzdResponse { + + @JsonProperty("records") + private Integer records; + @JsonProperty("total") + private Integer total; + @JsonProperty("rows") + private List rows; + @JsonProperty("page") + private Integer page; + @JsonProperty("count") + private Integer count; + @JsonProperty("firstResult") + private Integer firstResult; + @JsonProperty("maxResults") + private Integer maxResults; + @JsonProperty("success") + private Boolean success; + @JsonProperty("result") + private String result; + @JsonProperty("conditions") + private ConditionsDTO conditions; + @JsonProperty("msg") + private String msg; + @JsonProperty("form") + private String form; + @JsonProperty("code") + private Integer code; + @JsonProperty("operCount") + private Integer operCount; + @JsonProperty("sord") + private String sord; + @JsonProperty("sidx") + private String sidx; + @JsonProperty("orderby") + private String orderby; + + @NoArgsConstructor + @Data + public static class ConditionsDTO { + @JsonProperty("orderColumn") + private Integer orderColumn; + } + + @NoArgsConstructor + @Data + public static class RowsDTO { + + @JsonProperty("id") + private String id; + + @JsonProperty("goodsId") + private String goodsId; + + @JsonProperty("code") + private String code; + + @JsonProperty("specificationCode") + private String specificationCode; + + @JsonProperty("catalogFullName") + private String catalogFullName; + + @JsonProperty("catalogName1") + private String catalogName1; + + @JsonProperty("catalogName2") + private String catalogName2; + + @JsonProperty("catalogName3") + private String catalogName3; + + @JsonProperty("reagentTestingCode") + private String reagentTestingCode; + + @JsonProperty("testingFullDesc") + private String testingFullDesc; + + @JsonProperty("testingCategoryName1") + private String testingCategoryName1; + + @JsonProperty("testingCategoryName2") + private String testingCategoryName2; + + @JsonProperty("reagentUseType") + private int reagentUseType; + + @JsonProperty("reagentCheckType") + private int reagentCheckType; + + @JsonProperty("reagentCheckNum") + private int reagentCheckNum; + + @JsonProperty("reagentCheckItem") + private String reagentCheckItem; + + @JsonProperty("reagentFixedType") + private int reagentFixedType; + + @JsonProperty("specification") + private String specification; + + @JsonProperty("hcybCode") + private String hcybCode; + + @JsonProperty("ggxhCode") + private String ggxhCode; + + @JsonProperty("marketStatus") + private String marketStatus; + + @JsonProperty("udiCode") + private String udiCode; + + @JsonProperty("unit") + private String unit; + + @JsonProperty("volume") + private String volume; + + @JsonProperty("serve") + private int serve; + + @JsonProperty("other") + private String other; + + @JsonProperty("applicableInstruments") + private String applicableInstruments; + + @JsonProperty("productId") + private String productId; + + @JsonProperty("productName") + private String productName; + + @JsonProperty("isImport") + private String isImport; + + @JsonProperty("regcardId") + private String regcardId; + + @JsonProperty("regcardNm") + private String regcardNm; + + @JsonProperty("regcardProductName") + private String regcardProductName; + + @JsonProperty("registrant") + private String registrant; + + @JsonProperty("managerLevel") + private String managerLevel; + + @JsonProperty("companyId") + private String companyId; + + @JsonProperty("companyName") + private String companyName; + + @JsonProperty("businessLicense") + private String businessLicense; + + @JsonProperty("companyCode") + private String companyCode; + + @JsonProperty("dataTime") + private String dataTime; + + @JsonProperty("releaseVersion") + private String releaseVersion; + + @JsonProperty("productCode") + private String productCode; + + @JsonProperty("originCode") + private String originCode; + + @JsonProperty("originCodeStatus") + private String originCodeStatus; + + @JsonProperty("modifyType") + private String modifyType; + + } +} diff --git a/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbChsHttpClient.java b/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbChsHttpClient.java index 4cce2d1..e71fafd 100644 --- a/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbChsHttpClient.java +++ b/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbChsHttpClient.java @@ -4,10 +4,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import com.glxp.udidl.admin.res.chs.YbDrugResponse; -import com.glxp.udidl.admin.res.chs.YbHcflResponse; -import com.glxp.udidl.admin.res.chs.YbHcxxGgResponse; -import com.glxp.udidl.admin.res.chs.YbHcxxResponse; +import com.glxp.udidl.admin.res.chs.*; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -26,6 +23,10 @@ public class ChsYbChsHttpClient { * 获取耗材分类目录 */ String getHcflUrl = "https://code.nhsa.gov.cn/hc/stdSpecification/getStdSpecificationListDataCompanyReport.html"; + /** + * 体外诊断试剂信息 + */ + String getTwzdUrl = "https://code.nhsa.gov.cn/sj/publish/cms_sj/product.html"; /** * 获取医用耗材信息 */ @@ -54,6 +55,28 @@ public class ChsYbChsHttpClient { }); return baseResponse; } + + //获取HCF列表 + public YbTwzdResponse getYbTwzdList(Integer pageNum, Integer pageSize) { + Map params = new HashMap<>(); + params.put("_search",false); + params.put("nd",System.currentTimeMillis()); + params.put("rows", pageSize); + params.put("page", pageNum); + params.put("sord", "asc"); + params.put("code", "C"); + + try { + Thread.sleep(15000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + String response = sendPost(getTwzdUrl+getParams(params), "",Charset.forName("utf-8")); + YbTwzdResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { + }); + return baseResponse; + } //获取HCF列表 public YbDrugResponse getYbDrugList(Integer pageNum, Integer pageSize,String goodsCode) { Map params = new HashMap<>(); diff --git a/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbHcflService.java b/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbHcflService.java index 98c5baa..ea4e7a8 100644 --- a/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbHcflService.java +++ b/src/main/java/com/glxp/udidl/admin/service/chsapi/ChsYbHcflService.java @@ -1,13 +1,16 @@ package com.glxp.udidl.admin.service.chsapi; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.glxp.udidl.admin.res.chs.YbHcflResponse; +import com.glxp.udidl.admin.res.chs.YbTwzdResponse; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.glxp.udidl.admin.dao.chs.YbHcflMapper; import com.glxp.udidl.admin.entity.chs.YbHcflEntity; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; @Service @@ -51,4 +54,73 @@ public class ChsYbHcflService extends ServiceImpl { } + + + /** + * 更新数据库的YbHcf列表数据 + * 以一定大小页面 分批对比数据库 医用耗材分类代码 是否存在 不存在进行新增 + */ + public void updateYbTwzdList(){ + Integer pageNum = 1; + Integer pageSize = 200; + + //1、获取数据 + YbTwzdResponse ybTwzdResponse = ybChsHttpClient.getYbTwzdList(pageNum, pageSize); + Integer total = ybTwzdResponse.getTotal(); + //处理第一批数据 + processUpdatesYbTwzd(ybTwzdResponse); + //处理后续数据 + if (total>pageNum){ + for (int i = 2; i <= total ; i++) { + System.out.println("更新数据库的YbTwzd列表数据"+ i); + processUpdatesYbTwzd(ybChsHttpClient.getYbTwzdList(i, pageSize)); + } + } + } + + /** + * 处理比对更新 + * @param ybTwzdResponse + */ + private void processUpdatesYbTwzd(YbTwzdResponse ybTwzdResponse) { + List list = ybTwzdResponse.getRows(); + if (CollUtil.isNotEmpty(list)){ + List ybHcflEntities = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + YbTwzdResponse.RowsDTO rowsDTO = list.get(i); + YbHcflEntity ybHcflEntity = new YbHcflEntity(); + ybHcflEntity.setSpecificationCode(rowsDTO.getCode()); + ybHcflEntity.setSpecificationId(null); + ybHcflEntity.setCatalogcode(rowsDTO.getSpecificationCode()); + ybHcflEntity.setCatalogname1(rowsDTO.getCatalogName1()); + ybHcflEntity.setCatalogname2(rowsDTO.getCatalogName2()); + ybHcflEntity.setCatalogname3(rowsDTO.getCatalogName3()); + ybHcflEntity.setCommonnamecode(null); + ybHcflEntity.setCommonname(null); + ybHcflEntity.setMatrialcode(null); + ybHcflEntity.setMatrial(rowsDTO.getTestingFullDesc()); + ybHcflEntity.setCharacteristiccode(null); + ybHcflEntity.setCharacteristic(rowsDTO.getProductName()); + ybHcflEntity.setSeparateCharges(null); + ybHcflEntity.setPaymentType(null); + ybHcflEntity.setPaymentStandard(null); + ybHcflEntity.setIsusing("1"); + ybHcflEntity.setSpecificationType(null); + ybHcflEntity.setProductStatusS(null); + ybHcflEntity.setProductCount(null); + ybHcflEntity.setCompCount(null); + ybHcflEntity.setRegCount(null); + ybHcflEntity.setGoodsCount(null); + + ybHcflEntities.add(ybHcflEntity); + } + + if (CollUtil.isNotEmpty(ybHcflEntities)){ + ybHcflMapper.batchSaveOrUpdateBySpecificationCode(ybHcflEntities); + } + } + + } + + } diff --git a/src/main/java/com/glxp/udidl/admin/service/udchs/impl/YbDrugServiceImpl.java b/src/main/java/com/glxp/udidl/admin/service/udchs/impl/YbDrugServiceImpl.java index 07b8bc4..2863859 100644 --- a/src/main/java/com/glxp/udidl/admin/service/udchs/impl/YbDrugServiceImpl.java +++ b/src/main/java/com/glxp/udidl/admin/service/udchs/impl/YbDrugServiceImpl.java @@ -46,7 +46,9 @@ public class YbDrugServiceImpl implements YbDrugService { YbDrugResponse ybDrugResponse = ybChsHttpClient.getYbDrugList(1, 1,goodsCode); List lists = ybDrugResponse.getRows(); List ybHcflEntities = BeanUtil.copyToList(lists, YbDrug.class); - ybDrugMapper.batchSaveOrUpdateByGoodsCode(ybHcflEntities); + if (CollUtil.isNotEmpty(ybHcflEntities)){ + ybDrugMapper.batchSaveOrUpdateByGoodsCode(ybHcflEntities); + } pageSimpleResponse.setTotal(Long.valueOf(lists.size())); pageSimpleResponse.setList(ybHcflEntities); }else {