feat: 增加国家库的阿里药品信息

v3
chenhc 4 months ago
parent b0911dada0
commit 3e28fbccf8

@ -0,0 +1,75 @@
package com.glxp.udidl.admin.controller.collect;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.glxp.udidl.admin.entity.collect.ThirdAliDrug;
import com.glxp.udidl.admin.enums.ResultEnum;
import com.glxp.udidl.admin.req.collect.ThirdAliDrugAddRequest;
import com.glxp.udidl.admin.req.collect.ThirdAliDrugRequest;
import com.glxp.udidl.admin.res.BaseResponse;
import com.glxp.udidl.admin.res.PageSimpleResponse;
import com.glxp.udidl.admin.service.collect.ThirdAliDrugService;
import com.glxp.udidl.admin.util.ResultVOUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController
public class ThirdAliDrugController {
@Resource
private ThirdAliDrugService thirdAliDrugService;
@PostMapping("/udiwms/aliDrug/addThirdAliDrug")
public BaseResponse addThirdAliDrug(@RequestBody @Valid ThirdAliDrugAddRequest relCodeBatchRequest, BindingResult bindingResult) {
thirdAliDrugService.addThirdAliDrug(relCodeBatchRequest);
return ResultVOUtils.success("添加成功!");
}
@GetMapping("/udiwms/aliDrug/getDrugLevelList")
public BaseResponse getDrugLevelList(ThirdAliDrugRequest thirdAliDrug, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.DATA_REPEAT, bindingResult.getFieldError().getDefaultMessage());
}
if (StrUtil.isEmpty(thirdAliDrug.getApprovalNum()) && StrUtil.isEmpty(thirdAliDrug.getNameCode()) &&
StrUtil.isEmpty(thirdAliDrug.getCpmctymc())
) {
return ResultVOUtils.success("查询参数不能为空");
}
List<ThirdAliDrug> list = thirdAliDrugService.filterList(thirdAliDrug);
PageInfo<ThirdAliDrug> pageInfo = new PageInfo<>(list);
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/aliDrug/getDrugLevelListBycode")
public BaseResponse getDrugLevelListBycode(ThirdAliDrugRequest thirdAliDrug, BindingResult bindingResult) {
String nameCode = thirdAliDrug.getNameCode();
if (StrUtil.isEmpty(nameCode)) {
return ResultVOUtils.error(ResultEnum.DATA_REPEAT,"标识参数不能为空");
}
ThirdAliDrug one = thirdAliDrugService.getOne(new LambdaQueryWrapper<ThirdAliDrug>().eq(ThirdAliDrug::getNameCode, nameCode));
if (one == null) {
return ResultVOUtils.error(ResultEnum.DATA_REPEAT,"标识参数错误");
}
List<ThirdAliDrug> list = thirdAliDrugService.list(new LambdaQueryWrapper<ThirdAliDrug>()
.eq(ThirdAliDrug::getApprovalNum, one.getApprovalNum())
.eq(ThirdAliDrug::getCpmctymc, one.getCpmctymc())
.eq(ThirdAliDrug::getForm, one.getForm())
.eq(ThirdAliDrug::getBzgg, one.getBzgg())
.eq(ThirdAliDrug::getPackRatio, one.getPackRatio()));
return ResultVOUtils.success(list);
}
}

@ -0,0 +1,19 @@
package com.glxp.udidl.admin.dao.collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.udidl.admin.entity.collect.ThirdAliDrug;
import com.glxp.udidl.admin.req.collect.ThirdAliDrugRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThirdAliDrugMapper extends BaseMapper<ThirdAliDrug> {
int selectDrugsByNameCodes(@Param("nameCode") String nameCode);
int saveOrUpdateBatch(@Param("list") List<ThirdAliDrug> list);
List<ThirdAliDrug> filterList(ThirdAliDrugRequest thirdAliDrug);
}

@ -0,0 +1,167 @@
package com.glxp.udidl.admin.entity.collect;
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.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@ApiModel(description = "third_ali_drug")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "third_ali_drug")
public class ThirdAliDrug implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value = "")
private Integer id;
/**
*
*/
@TableField(value = "`type`")
@ApiModelProperty(value = "药品类型")
private String type;
/**
*
*/
@TableField(value = "manufacturer")
@ApiModelProperty(value = "生产企业")
private String manufacturer;
/**
*
*/
@TableField(value = "cpmctymc")
@ApiModelProperty(value = "产品名称通用名称")
private String cpmctymc;
/**
*
*/
@TableField(value = "form")
@ApiModelProperty(value = "剂型")
private String form;
/**
*
*/
@TableField(value = "formSpec")
@ApiModelProperty(value = "剂型规格")
private String formSpec;
/**
*
*/
@TableField(value = "bzgg")
@ApiModelProperty(value = "包装规格")
private String bzgg;
/**
*
*/
@TableField(value = "spmc")
@ApiModelProperty(value = "商品名称")
private String spmc;
/**
*
*/
@TableField(value = "nameCode")
@ApiModelProperty(value = "层级标识")
private String nameCode;
/**
*
*/
@TableField(value = "packRatio")
@ApiModelProperty(value = "包装比例")
private String packRatio;
/**
*
*/
@TableField(value = "packLevel")
@ApiModelProperty(value = "包装级别")
private String packLevel;
/**
*
*/
@TableField(value = "erpId")
@ApiModelProperty(value = "包装级别")
private String erpId;
/**
*
*/
@TableField(value = "approvalNum")
@ApiModelProperty(value = "批准文号")
private String approvalNum;
/**
*
*/
@TableField(value = "createTime")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
*
*/
@TableField(value = "updateTime")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
private static final long serialVersionUID = 1L;
public ThirdAliDrug(String type, String manufacturer, String cpmctymc, String form, String formSpec, String bzgg, String approvalNum, String spmc, String nameCode, String packRatio, String packLevel, Date createTime, Date updateTime) {
this.type = type;
this.manufacturer = manufacturer;
this.cpmctymc = cpmctymc;
this.form = form;
this.formSpec = formSpec;
this.bzgg = bzgg;
this.spmc = spmc;
this.nameCode = nameCode;
this.packRatio = packRatio;
this.packLevel = packLevel;
this.createTime = createTime;
this.updateTime = updateTime;
this.approvalNum = approvalNum;
}
@Override
public String toString() {
return "ThirdAliDrug{" +
"id=" + id +
", type='" + type + '\'' +
", manufacturer='" + manufacturer + '\'' +
", cpmctymc='" + cpmctymc + '\'' +
", form='" + form + '\'' +
", formSpec='" + formSpec + '\'' +
", bzgg='" + bzgg + '\'' +
", spmc='" + spmc + '\'' +
", nameCode='" + nameCode + '\'' +
", packRatio='" + packRatio + '\'' +
", packLevel='" + packLevel + '\'' +
", erpId='" + erpId + '\'' +
", approvalNum='" + approvalNum + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}

@ -0,0 +1,11 @@
package com.glxp.udidl.admin.req.collect;
import com.glxp.udidl.admin.entity.collect.ThirdAliDrug;
import lombok.Data;
import java.util.List;
@Data
public class ThirdAliDrugAddRequest {
private List<ThirdAliDrug> list;
}

@ -0,0 +1,112 @@
package com.glxp.udidl.admin.req.collect;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.glxp.udidl.admin.req.ListPageRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class ThirdAliDrugRequest extends ListPageRequest {
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value = "")
private Integer id;
/**
*
*/
@TableField(value = "`type`")
@ApiModelProperty(value = "药品类型")
private String type;
/**
*
*/
@TableField(value = "manufacturer")
@ApiModelProperty(value = "生产企业")
private String manufacturer;
/**
*
*/
@TableField(value = "cpmctymc")
@ApiModelProperty(value = "产品名称通用名称")
private String cpmctymc;
/**
*
*/
@TableField(value = "form")
@ApiModelProperty(value = "剂型")
private String form;
/**
*
*/
@TableField(value = "formSpec")
@ApiModelProperty(value = "剂型规格")
private String formSpec;
/**
*
*/
@TableField(value = "bzgg")
@ApiModelProperty(value = "包装规格")
private String bzgg;
/**
*
*/
@TableField(value = "spmc")
@ApiModelProperty(value = "商品名称")
private String spmc;
/**
*
*/
@TableField(value = "nameCode")
@ApiModelProperty(value = "层级标识")
private String nameCode;
/**
*
*/
@TableField(value = "packRatio")
@ApiModelProperty(value = "包装比例")
private String packRatio;
/**
*
*/
@TableField(value = "packLevel")
@ApiModelProperty(value = "包装级别")
private String packLevel;
/**
*
*/
@TableField(value = "erpId")
@ApiModelProperty(value = "包装级别")
private String erpId;
/**
*
*/
@TableField(value = "createTime")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
*
*/
@TableField(value = "updateTime")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
private String approvalNum;
}

@ -0,0 +1,69 @@
package com.glxp.udidl.admin.service.collect;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.glxp.udidl.admin.dao.collect.ThirdAliDrugMapper;
import com.glxp.udidl.admin.entity.collect.ThirdAliDrug;
import com.glxp.udidl.admin.req.collect.ThirdAliDrugAddRequest;
import com.glxp.udidl.admin.req.collect.ThirdAliDrugRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
public class ThirdAliDrugService extends ServiceImpl<ThirdAliDrugMapper, ThirdAliDrug> {
public List<ThirdAliDrug> filterList(ThirdAliDrugRequest thirdAliDrug) {
if (thirdAliDrug == null) {
return Collections.emptyList();
}
if (thirdAliDrug.getPage() != null) {
int offset = (thirdAliDrug.getPage() - 1) * thirdAliDrug.getLimit();
PageHelper.offsetPage(offset, thirdAliDrug.getLimit());
}
return this.baseMapper.filterList(thirdAliDrug);
}
public List<ThirdAliDrug> findByByApproved(String approvalNum) {
return this.baseMapper.selectList(new LambdaQueryWrapper<ThirdAliDrug>().eq(ThirdAliDrug::getApprovalNum, approvalNum));
}
public void addThirdAliDrug(ThirdAliDrugAddRequest relCodeBatchRequest) {
List<ThirdAliDrug> list = relCodeBatchRequest.getList();
if (CollUtil.isNotEmpty(list)){
List<String> nameCodes = list.stream().map(ThirdAliDrug::getNameCode).collect(Collectors.toList());
List<String> updateNameCodes = new ArrayList<>();
List<ThirdAliDrug> drugs = this.list(new LambdaQueryWrapper<ThirdAliDrug>().in(ThirdAliDrug::getNameCode, nameCodes));
if (CollUtil.isNotEmpty(drugs)){
updateNameCodes = drugs.stream().map(ThirdAliDrug::getNameCode).collect(Collectors.toList());
}
List<ThirdAliDrug> addList = new ArrayList<>();
List<String> finalUpdateNameCodes = updateNameCodes;
list.forEach(item -> {
if (finalUpdateNameCodes.size() > 0 ){
if (!finalUpdateNameCodes.contains(item.getNameCode())){
item.setId(null);
addList.add(item);
}
}else {
item.setId(null);
addList.add(item);
}
});
if (CollUtil.isNotEmpty(addList)){
this.baseMapper.saveOrUpdateBatch(addList);
}
}
}
}

@ -0,0 +1,90 @@
<?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.collect.ThirdAliDrugMapper">
<resultMap id="BaseResultMap" type="com.glxp.udidl.admin.entity.collect.ThirdAliDrug">
<!--@mbg.generated-->
<!--@Table third_ali_drug-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="manufacturer" jdbcType="VARCHAR" property="manufacturer"/>
<result column="cpmctymc" jdbcType="VARCHAR" property="cpmctymc"/>
<result column="form" jdbcType="VARCHAR" property="form"/>
<result column="formSpec" jdbcType="VARCHAR" property="formSpec"/>
<result column="bzgg" jdbcType="VARCHAR" property="bzgg"/>
<result column="spmc" jdbcType="VARCHAR" property="spmc"/>
<result column="nameCode" jdbcType="VARCHAR" property="nameCode"/>
<result column="packRatio" jdbcType="VARCHAR" property="packRatio"/>
<result column="packLevel" jdbcType="VARCHAR" property="packLevel"/>
<result column="erpId" jdbcType="VARCHAR" property="packLevel"/>
<result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
<result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id,
`type`,
manufacturer,
cpmctymc,
form,
formSpec,
bzgg,
spmc,
nameCode,
packRatio,
packLevel,
createTime,
erpId,
updateTime
</sql>
<select id="selectDrugsByNameCodes" resultType="int">
SELECT count(1)
FROM third_ali_drug
WHERE nameCode = #{nameCode}
</select>
<!-- 自定义saveOrUpdateBatch方法 -->
<insert id="saveOrUpdateBatch" parameterType="com.glxp.udidl.admin.entity.collect.ThirdAliDrug">
replace INTO third_ali_drug (`type`, manufacturer, cpmctymc, form, formSpec, bzgg, spmc, nameCode, packRatio,
packLevel, createTime, updateTime, erpId, approvalNum)
VALUES
<foreach collection="list" item="item" separator="," index="index">
(#{item.type}, #{item.manufacturer}, #{item.cpmctymc}, #{item.form}, #{item.formSpec}, #{item.bzgg},
#{item.spmc}, #{item.nameCode},
#{item.packRatio}, #{item.packLevel}, #{item.createTime}, #{item.updateTime}, #{item.erpId},
#{item.approvalNum})
</foreach>
</insert>
<select id="filterList" parameterType="com.glxp.udidl.admin.req.collect.ThirdAliDrugRequest"
resultType="com.glxp.udidl.admin.entity.collect.ThirdAliDrug">
select id,
`type`,
manufacturer,
cpmctymc,
form,
formSpec,
bzgg,
spmc,
nameCode,
packRatio,
packLevel,
createTime,
erpId,
updateTime,
approvalNum
from third_ali_drug
<where>
<if test="cpmctymc != '' and cpmctymc != null">
AND cpmctymc LIKE concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != '' and nameCode != null">
AND nameCode LIKE concat('%', #{nameCode}, '%')
</if>
<if test="approvalNum != '' and approvalNum != null">
AND approvalNum = #{approvalNum}
</if>
</where>
</select>
</mapper>

@ -264,4 +264,27 @@ CREATE TABLE IF NOT EXISTS `code_rel` (
`fromType` tinyint DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `unique_idx_diNameCode_ybbm` (`diNameCode`,`ybbm`)
) ENGINE=InnoDB AUTO_INCREMENT=110586 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=110586 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `third_ali_drug` (
`id` int NOT NULL AUTO_INCREMENT,
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '药品类型',
`manufacturer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '生产企业',
`cpmctymc` varchar(255) DEFAULT NULL COMMENT '产品名称通用名称',
`form` varchar(255) DEFAULT NULL COMMENT '剂型',
`formSpec` varchar(255) DEFAULT NULL COMMENT '剂型规格',
`bzgg` varchar(255) DEFAULT NULL COMMENT '包装规格',
`spmc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '商品名称',
`nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '层级标识',
`packRatio` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '包装比例',
`packLevel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '包装级别',
`createTime` datetime DEFAULT NULL COMMENT '创建时间',
`updateTime` datetime DEFAULT NULL COMMENT '更新时间',
`erpId` varchar(255) DEFAULT NULL,
`approvalNum` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '批准文号',
PRIMARY KEY (`id`),
UNIQUE KEY `nameCode` (`nameCode`),
KEY `approvalNum` (`approvalNum`) USING BTREE,
KEY `cpmctymc` (`cpmctymc`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Loading…
Cancel
Save