feat: 代码提交

zhairh
chenhc 6 months ago
parent 00a048406e
commit eac98ace7f

@ -1,6 +1,7 @@
package com.glxp.udidl.admin.controller.udchs;
import com.glxp.udidl.admin.res.BaseResponse;
import com.glxp.udidl.admin.service.chsapi.ChsYbDrugService;
import com.glxp.udidl.admin.service.chsapi.ChsYbHcflService;
import com.glxp.udidl.admin.service.chsapi.ChsYbHcxxGgService;
import com.glxp.udidl.admin.service.chsapi.ChsYbHcxxService;
@ -23,6 +24,8 @@ public class UdchsThirdApiController {
ChsYbHcxxService ybHcxxService;
@Autowired
ChsYbHcxxGgService ybHcxxGgService;
@Autowired
ChsYbDrugService ybDrugService;
@ApiOperation("手动触发ybHcfl数据全量更新")
// @AuthRuleAnnotation("udiwms/erp/manual/trig/ybHcfl")
@ -67,4 +70,13 @@ public class UdchsThirdApiController {
ybHcxxGgService.updateYbHcxxGgList(specificationCode);
return ResultVOUtils.success("手动触发ybHcxxGg数据更新通过父code");
}
@ApiOperation("手动触发ybDrug数据更新")
@PostMapping("/udiwms/erp/manual/trig/ybDrugByCode")
public BaseResponse<?> ybDrugByCode() {
ybDrugService.updateDrugList();
return ResultVOUtils.success("手动触发ybDrug数据更新");
}
}

@ -0,0 +1,36 @@
package com.glxp.udidl.admin.controller.udchs;
import com.glxp.udidl.admin.annotation.AuthRuleAnnotation;
import com.glxp.udidl.admin.dto.udchs.BaseParam;
import com.glxp.udidl.admin.entity.chs.YbDrug;
import com.glxp.udidl.admin.entity.chs.YbHcflEntity;
import com.glxp.udidl.admin.res.BaseResponse;
import com.glxp.udidl.admin.service.udchs.YbDrugService;
import com.glxp.udidl.admin.service.udchs.YbHcflService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*/
@Api(tags = "国家医保药品信息接口")
@RestController
@RequestMapping("/udchs/ybDrug")
public class UdchsYbDrugController {
@Autowired
private YbDrugService ybDrugService;
@ApiOperation(value = "国家医保耗材分类目录信息", response = YbDrug.class)
@PostMapping("/list")
public BaseResponse getList(@RequestBody BaseParam param) {
return ybDrugService.getList(param);
}
}

@ -0,0 +1,18 @@
package com.glxp.udidl.admin.dao.chs;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.udidl.admin.dto.udchs.BaseParam;
import com.glxp.udidl.admin.entity.chs.YbDrug;
import com.glxp.udidl.admin.entity.chs.YbHcflEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface YbDrugMapper extends BaseMapper<YbDrug> {
void batchSaveOrUpdateByGoodsCode(@Param("list")List<YbDrug> ybHcflEntities);
List<YbDrug> list(BaseParam param);
}

@ -13,6 +13,9 @@ public class BaseParam extends ListPageRequest {
@ApiModelProperty(name = "specificationCode", value = "名称,支持模糊查询")
private String specificationCode;//名称,支持模糊查询
@ApiModelProperty(name = "goodsCode", value = "名称,支持模糊查询")
private String goodsCode;//名称,支持模糊查询
@ApiModelProperty(name = "codeShow", value = "名称,支持模糊查询")
private String codeShow;//名称,支持模糊查询

@ -0,0 +1,153 @@
package com.glxp.udidl.admin.entity.chs;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
*
*/
@Data
@TableName(value = "yb_drug")
public class YbDrug implements Serializable {
/**
*
*/
@TableField(value = "businessLicense")
private String businessLicense;
/**
*
*/
@TableField(value = "companyNameSc")
private String companyNameSc;
/**
*
*/
@TableField(value = "approvalCode")
private String approvalCode;
/**
*
*/
@TableField(value = "goodsStandardCode")
private String goodsStandardCode;
/**
* baseId
*/
@TableField(value = "baseId")
private String baseId;
/**
*
*/
@TableField(value = "productName")
private String productName;
/**
*
*/
@TableField(value = "productMedicinemodel")
private String productMedicinemodel;
/**
*
*/
@TableField(value = "registeredProductName")
private String registeredProductName;
/**
*
*/
@TableField(value = "listingHolder")
private String listingHolder;
/**
*
*/
@TableField(value = "registeredMedicinemodel")
private String registeredMedicinemodel;
/**
*
*/
@TableField(value = "minUnit")
private String minUnit;
/**
*
*/
@TableField(value = "factor")
private Integer factor;
@TableField(value = "goodsName")
private String goodsName;
@TableField(value = "dataSouce")
private String dataSouce;
/**
*
*/
@TableField(value = "realityOutlook")
private String realityOutlook;
@TableField(value = "productRemark")
private String productRemark;
@TableField(value = "subpackager")
private String subpackager;
@TableField(value = "version")
private String version;
@TableField(value = "productInsuranceType")
private String productInsuranceType;
/**
*
*/
@TableField(value = "realityMedicinemodel")
private String realityMedicinemodel;
@TableField(value = "marketState")
private String marketState;
/**
*
*/
@TableField(value = "materialName")
private String materialName;
/**
*
*/
@TableField(value = "unit")
private String unit;
/**
*
*/
@TableField(value = "registeredOutlook")
private String registeredOutlook;
@TableField(value = "productCode")
private String productCode;
/**
*
*/
@TableField(value = "goodsCode")
private String goodsCode;
}

@ -0,0 +1,112 @@
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 YbDrugResponse {
@JsonProperty("records")
private Integer records;
@JsonProperty("total")
private Integer total;
@JsonProperty("rows")
private List<RowsDTO> 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("businessLicense")
private String businessLicense;
@JsonProperty("companyNameSc")
private String companyNameSc;
@JsonProperty("approvalCode")
private String approvalCode;
@JsonProperty("goodsStandardCode")
private String goodsStandardCode;
@JsonProperty("baseId")
private String baseId;
@JsonProperty("productName")
private String productName;
@JsonProperty("productMedicinemodel")
private String productMedicinemodel;
@JsonProperty("registeredProductName")
private String registeredProductName;
@JsonProperty("listingHolder")
private String listingHolder;
@JsonProperty("registeredMedicinemodel")
private String registeredMedicinemodel;
@JsonProperty("minUnit")
private String minUnit;
@JsonProperty("factor")
private Integer factor;
@JsonProperty("goodsName")
private String goodsName;
@JsonProperty("dataSouce")
private String dataSouce;
@JsonProperty("realityOutlook")
private String realityOutlook;
@JsonProperty("productRemark")
private String productRemark;
@JsonProperty("subpackager")
private String subpackager;
@JsonProperty("version")
private String version;
@JsonProperty("productInsuranceType")
private String productInsuranceType;
@JsonProperty("realityMedicinemodel")
private String realityMedicinemodel;
@JsonProperty("marketState")
private String marketState;
@JsonProperty("materialName")
private String materialName;
@JsonProperty("unit")
private String unit;
@JsonProperty("registeredOutlook")
private String registeredOutlook;
@JsonProperty("productCode")
private String productCode;
@JsonProperty("goodsCode")
private String goodsCode;
}
}

@ -1,7 +1,10 @@
package com.glxp.udidl.admin.service.chsapi;
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;
@ -31,6 +34,10 @@ public class ChsYbChsHttpClient {
*
*/
String getHcxxGgUrl = "https://code.nhsa.gov.cn/hc/stdYgbData/getPublicHcDataList.html";
/**
*
*/
String getDrugUrl = "https://code.nhsa.gov.cn/yp/stdGoodsPublic/getStdGoodsPublicData.html";
//获取HCF列表
@ -47,6 +54,27 @@ public class ChsYbChsHttpClient {
});
return baseResponse;
}
//获取HCF列表
public YbDrugResponse getYbDrugList(Integer pageNum, Integer pageSize,String goodsCode) {
Map<String, Object> params = new HashMap<>();
params.put("_search",false);
params.put("nd",System.currentTimeMillis());
params.put("rows", pageSize);
params.put("page", pageNum);
if (StrUtil.isNotBlank(goodsCode)) params.put("goodsCode", goodsCode);
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String response = sendPost(getDrugUrl+getParams(params), "",Charset.forName("utf-8"));
response = response.replace("”", "").replace("“", "").replace("\\\"" , "").replace("\\\"" , "").replace("\\", "");
System.out.println(response);
YbDrugResponse baseResponse = JSONObject.parseObject(response, new TypeReference<YbDrugResponse>() {
});
return baseResponse;
}
//获取Hcxx列表
public YbHcxxResponse getYbHcxxList(Integer pageNum, Integer pageSize) {

@ -0,0 +1,54 @@
package com.glxp.udidl.admin.service.chsapi;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.udidl.admin.dao.chs.YbDrugMapper;
import com.glxp.udidl.admin.dao.chs.YbHcflMapper;
import com.glxp.udidl.admin.entity.chs.YbDrug;
import com.glxp.udidl.admin.entity.chs.YbHcflEntity;
import com.glxp.udidl.admin.res.chs.YbDrugResponse;
import com.glxp.udidl.admin.res.chs.YbHcflResponse;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ChsYbDrugService extends ServiceImpl<YbDrugMapper, YbDrug> {
@Resource
ChsYbChsHttpClient ybChsHttpClient;
@Resource
YbDrugMapper ybDrugMapper;
public void updateDrugList(){
Integer pageNum = 148;
Integer pageSize = 200;
//1、获取数据
YbDrugResponse ybDrugResponse = ybChsHttpClient.getYbDrugList(pageNum, pageSize,null);
Integer total = ybDrugResponse.getTotal();
//处理第一批数据
processUpdates(ybDrugResponse);
//处理后续数据
if (total>pageNum){
for (int i = 149; i <= total ; i++) {
System.out.println("更新数据库的YbDrug列表数据"+ i);
processUpdates(ybChsHttpClient.getYbDrugList(i, pageSize,null));
}
}
}
/**
*
* @param ybDrugResponse
*/
private void processUpdates(YbDrugResponse ybDrugResponse) {
List<YbDrugResponse.RowsDTO> list = ybDrugResponse.getRows();
List<YbDrug> ybHcflEntities = BeanUtil.copyToList(list, YbDrug.class);
ybDrugMapper.batchSaveOrUpdateByGoodsCode(ybHcflEntities);
}
}

@ -0,0 +1,8 @@
package com.glxp.udidl.admin.service.udchs;
import com.glxp.udidl.admin.dto.udchs.BaseParam;
import com.glxp.udidl.admin.res.BaseResponse;
public interface YbDrugService {
BaseResponse getList(BaseParam param);
}

@ -0,0 +1,62 @@
package com.glxp.udidl.admin.service.udchs.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glxp.udidl.admin.dao.chs.YbDrugMapper;
import com.glxp.udidl.admin.dao.chs.YbHcflMapper;
import com.glxp.udidl.admin.dto.udchs.BaseParam;
import com.glxp.udidl.admin.entity.chs.YbDrug;
import com.glxp.udidl.admin.entity.chs.YbHcflEntity;
import com.glxp.udidl.admin.res.BaseResponse;
import com.glxp.udidl.admin.res.PageSimpleResponse;
import com.glxp.udidl.admin.res.chs.YbDrugResponse;
import com.glxp.udidl.admin.service.chsapi.ChsYbChsHttpClient;
import com.glxp.udidl.admin.service.udchs.YbDrugService;
import com.glxp.udidl.admin.service.udchs.YbHcflService;
import com.glxp.udidl.admin.util.ResultVOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class YbDrugServiceImpl implements YbDrugService {
@Autowired
private YbDrugMapper mapper;
@Resource
ChsYbChsHttpClient ybChsHttpClient;
@Resource
YbDrugMapper ybDrugMapper;
@Override
public BaseResponse getList(BaseParam param) {
PageHelper.startPage(param.getPage(), param.getLimit());
List<YbDrug> list = mapper.list(param);
PageInfo<YbDrug> pageInfo = new PageInfo<>(list);
PageSimpleResponse<YbDrug> pageSimpleResponse = new PageSimpleResponse<>();
if (CollUtil.isEmpty(list)){
String goodsCode = param.getGoodsCode();
if (StrUtil.isNotBlank(goodsCode)){
YbDrugResponse ybDrugResponse = ybChsHttpClient.getYbDrugList(1, 1,goodsCode);
List<YbDrugResponse.RowsDTO> lists = ybDrugResponse.getRows();
List<YbDrug> ybHcflEntities = BeanUtil.copyToList(lists, YbDrug.class);
ybDrugMapper.batchSaveOrUpdateByGoodsCode(ybHcflEntities);
pageSimpleResponse.setTotal(Long.valueOf(lists.size()));
pageSimpleResponse.setList(ybHcflEntities);
}else {
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
}
}else {
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
}
return ResultVOUtils.success(pageSimpleResponse);
}
}

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.udidl.admin.dao.chs.YbDrugMapper">
<!-- 自定义批量保存数据-->
<insert id="batchSaveOrUpdateByGoodsCode" parameterType="int">
INSERT INTO
yb_drug
(
businessLicense,
companyNameSc,
approvalCode,
goodsStandardCode,
baseId,
productName,
productMedicinemodel,
registeredProductName,
listingHolder,
registeredMedicinemodel,
minUnit,
factor,
goodsName,
dataSouce,
realityOutlook,
productRemark,
subpackager,
version,
productInsuranceType,
realityMedicinemodel,
marketState,
materialName,
unit,
registeredOutlook,
productCode,
goodsCode
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.businessLicense},
#{item.companyNameSc},
#{item.approvalCode},
#{item.goodsStandardCode},
#{item.baseId},
#{item.productName},
#{item.productMedicinemodel},
#{item.registeredProductName},
#{item.listingHolder},
#{item.registeredMedicinemodel},
#{item.minUnit},
#{item.factor},
#{item.goodsName},
#{item.dataSouce},
#{item.realityOutlook},
#{item.productRemark},
#{item.subpackager},
#{item.version},
#{item.productInsuranceType},
#{item.realityMedicinemodel},
#{item.marketState},
#{item.materialName},
#{item.unit},
#{item.registeredOutlook},
#{item.productCode},
#{item.goodsCode}
)
</foreach>
ON DUPLICATE KEY UPDATE
businessLicense = VALUES(businessLicense),
companyNameSc = VALUES(companyNameSc),
approvalCode = VALUES(approvalCode),
goodsStandardCode = VALUES(goodsStandardCode),
baseId = VALUES(baseId),
productName = VALUES(productName),
productMedicinemodel = VALUES(productMedicinemodel),
registeredProductName = VALUES(registeredProductName),
listingHolder= VALUES(listingHolder),
registeredMedicinemodel = VALUES(registeredMedicinemodel),
minUnit = VALUES(minUnit),
factor = VALUES(factor),
goodsName = VALUES(goodsName),
dataSouce = VALUES(dataSouce),
realityOutlook = VALUES(realityOutlook),
productRemark = VALUES(productRemark),
subpackager = VALUES(subpackager),
version = VALUES(version),
productInsuranceType = VALUES(productInsuranceType),
realityMedicinemodel = VALUES(realityMedicinemodel),
marketState = VALUES(marketState),
materialName = VALUES(materialName),
unit = VALUES(unit),
registeredOutlook = VALUES(registeredOutlook),
productCode = VALUES(productCode),
goodsCode = VALUES(goodsCode)
</insert>
<select id="list" resultType="com.glxp.udidl.admin.entity.chs.YbDrug" parameterType="com.glxp.udidl.admin.dto.udchs.BaseParam">
select id,
businessLicense,
companyNameSc,
approvalCode,
goodsStandardCode,
baseId,
productName,
productMedicinemodel,
registeredProductName,
listingHolder,
registeredMedicinemodel,
minUnit,
factor,
goodsName,
dataSouce,
realityOutlook,
productRemark,
subpackager,
version,
productInsuranceType,
realityMedicinemodel,
marketState,
materialName,
unit,
registeredOutlook,
productCode,
goodsCode
from yb_drug
<where>
<if test="goodsCode != '' and goodsCode != null">
and goodsCode like concat(#{goodsCode},'%')
</if>
</where>
order by goodsCode DESC
</select>
</mapper>
Loading…
Cancel
Save