From 3e28fbccf8a6e225ece5d398f73abec62a019e44 Mon Sep 17 00:00:00 2001 From: chenhc <2369838784@qq.com> Date: Thu, 28 Nov 2024 15:28:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=9B=BD=E5=AE=B6?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E9=98=BF=E9=87=8C=E8=8D=AF=E5=93=81=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collect/ThirdAliDrugController.java | 75 ++++++++ .../admin/dao/collect/ThirdAliDrugMapper.java | 19 ++ .../admin/entity/collect/ThirdAliDrug.java | 167 ++++++++++++++++++ .../req/collect/ThirdAliDrugAddRequest.java | 11 ++ .../req/collect/ThirdAliDrugRequest.java | 112 ++++++++++++ .../service/collect/ThirdAliDrugService.java | 69 ++++++++ .../mapper/collect/ThirdAliDrugMapper.xml | 90 ++++++++++ src/main/resources/schemas/schema_v2.1.sql | 25 ++- 8 files changed, 567 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/glxp/udidl/admin/controller/collect/ThirdAliDrugController.java create mode 100644 src/main/java/com/glxp/udidl/admin/dao/collect/ThirdAliDrugMapper.java create mode 100644 src/main/java/com/glxp/udidl/admin/entity/collect/ThirdAliDrug.java create mode 100644 src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugAddRequest.java create mode 100644 src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugRequest.java create mode 100644 src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java create mode 100644 src/main/resources/mybatis/mapper/collect/ThirdAliDrugMapper.xml diff --git a/src/main/java/com/glxp/udidl/admin/controller/collect/ThirdAliDrugController.java b/src/main/java/com/glxp/udidl/admin/controller/collect/ThirdAliDrugController.java new file mode 100644 index 0000000..35adc46 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/controller/collect/ThirdAliDrugController.java @@ -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 list = thirdAliDrugService.filterList(thirdAliDrug); + PageInfo pageInfo = new PageInfo<>(list); + PageSimpleResponse 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().eq(ThirdAliDrug::getNameCode, nameCode)); + if (one == null) { + return ResultVOUtils.error(ResultEnum.DATA_REPEAT,"标识参数错误"); + } + + List list = thirdAliDrugService.list(new LambdaQueryWrapper() + .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); + } + +} diff --git a/src/main/java/com/glxp/udidl/admin/dao/collect/ThirdAliDrugMapper.java b/src/main/java/com/glxp/udidl/admin/dao/collect/ThirdAliDrugMapper.java new file mode 100644 index 0000000..1c95f08 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/dao/collect/ThirdAliDrugMapper.java @@ -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 { + + int selectDrugsByNameCodes(@Param("nameCode") String nameCode); + + int saveOrUpdateBatch(@Param("list") List list); + + List filterList(ThirdAliDrugRequest thirdAliDrug); +} \ No newline at end of file diff --git a/src/main/java/com/glxp/udidl/admin/entity/collect/ThirdAliDrug.java b/src/main/java/com/glxp/udidl/admin/entity/collect/ThirdAliDrug.java new file mode 100644 index 0000000..12d4e69 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/entity/collect/ThirdAliDrug.java @@ -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 + + '}'; + } +} diff --git a/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugAddRequest.java b/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugAddRequest.java new file mode 100644 index 0000000..d7915fa --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugAddRequest.java @@ -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 list; +} diff --git a/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugRequest.java b/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugRequest.java new file mode 100644 index 0000000..c73a904 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/req/collect/ThirdAliDrugRequest.java @@ -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; + +} diff --git a/src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java b/src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java new file mode 100644 index 0000000..35a1acc --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java @@ -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 { + + + public List 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 findByByApproved(String approvalNum) { + return this.baseMapper.selectList(new LambdaQueryWrapper().eq(ThirdAliDrug::getApprovalNum, approvalNum)); + } + + public void addThirdAliDrug(ThirdAliDrugAddRequest relCodeBatchRequest) { + List list = relCodeBatchRequest.getList(); + if (CollUtil.isNotEmpty(list)){ + List nameCodes = list.stream().map(ThirdAliDrug::getNameCode).collect(Collectors.toList()); + List updateNameCodes = new ArrayList<>(); + List drugs = this.list(new LambdaQueryWrapper().in(ThirdAliDrug::getNameCode, nameCodes)); + if (CollUtil.isNotEmpty(drugs)){ + updateNameCodes = drugs.stream().map(ThirdAliDrug::getNameCode).collect(Collectors.toList()); + } + List addList = new ArrayList<>(); + List 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); + } + + } + } +} diff --git a/src/main/resources/mybatis/mapper/collect/ThirdAliDrugMapper.xml b/src/main/resources/mybatis/mapper/collect/ThirdAliDrugMapper.xml new file mode 100644 index 0000000..568df3c --- /dev/null +++ b/src/main/resources/mybatis/mapper/collect/ThirdAliDrugMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, + `type`, + manufacturer, + cpmctymc, + form, + formSpec, + bzgg, + spmc, + nameCode, + packRatio, + packLevel, + createTime, + erpId, + updateTime + + + + + + + replace INTO third_ali_drug (`type`, manufacturer, cpmctymc, form, formSpec, bzgg, spmc, nameCode, packRatio, + packLevel, createTime, updateTime, erpId, approvalNum) + VALUES + + (#{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}) + + + + + + diff --git a/src/main/resources/schemas/schema_v2.1.sql b/src/main/resources/schemas/schema_v2.1.sql index 0e05dab..d3d1099 100644 --- a/src/main/resources/schemas/schema_v2.1.sql +++ b/src/main/resources/schemas/schema_v2.1.sql @@ -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; \ No newline at end of file +) 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; \ No newline at end of file