feat: 代码提交
parent
00a048406e
commit
eac98ace7f
@ -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);
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
@ -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…
Reference in New Issue