diff --git a/src/main/java/com/glxp/udidl/admin/controller/udchs/CodeRelController.java b/src/main/java/com/glxp/udidl/admin/controller/udchs/CodeRelController.java index 07b2a65..ff78b36 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/udchs/CodeRelController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/udchs/CodeRelController.java @@ -1,19 +1,26 @@ package com.glxp.udidl.admin.controller.udchs; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.glxp.udidl.admin.dto.udchs.BaseParam; import com.glxp.udidl.admin.entity.chs.CodeRel; import com.glxp.udidl.admin.entity.chs.YbDrug; +import com.glxp.udidl.admin.entity.collect.ThirdAliDrug; import com.glxp.udidl.admin.enums.ResultEnum; import com.glxp.udidl.admin.res.BaseResponse; +import com.glxp.udidl.admin.res.chs.CodeRelVo; +import com.glxp.udidl.admin.service.collect.ThirdAliDrugService; import com.glxp.udidl.admin.service.udchs.impl.CodeRelServiceImpl; +import com.glxp.udidl.admin.util.BeanUtils; import com.glxp.udidl.admin.util.ResultVOUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; @@ -27,6 +34,8 @@ public class CodeRelController { @Autowired private CodeRelServiceImpl codeRelService; + @Resource + private ThirdAliDrugService thirdAliDrugService; @ApiOperation(value = "获取指定信息", response = CodeRel.class) @PostMapping("/list") @@ -58,5 +67,47 @@ public class CodeRelController { } + @ApiOperation(value = "更新指定信息", response = CodeRel.class) + @PostMapping("/updateBatch") + public BaseResponse updateBatchByCodeRel(@RequestBody List paramList) { + if (CollUtil.isEmpty(paramList)){ + return ResultVOUtils.error(500,"更新失败,数据为空"); + } + codeRelService.updateBatchByCodeRel(paramList); + return ResultVOUtils.success("更新成功"); + } + + + @ApiOperation(value = "获取指定信息", response = CodeRel.class) + @PostMapping("/listAndAliDrug") + public BaseResponse getListAndAliDrug(@RequestBody CodeRel param) { + if ( param == null || + (StrUtil.isBlank(param.getDiNameCode()) && StrUtil.isBlank(param.getDrugCode())) + ){ + return ResultVOUtils.error(ResultEnum.DATA_ERROR,"参数错误"); + } + + List respList = new ArrayList<>(); + List list = codeRelService.list(new LambdaQueryWrapper() + .eq(CodeRel::getDiNameCode,param.getDiNameCode()).or().eq(CodeRel::getDrugCode,param.getDrugCode())); + + if (CollUtil.isNotEmpty(list)){ + for (int i = 0; i < list.size(); i++) { + CodeRel codeRel = list.get(i); + CodeRelVo codeRelVo = new CodeRelVo(); + BeanUtils.copyProperties(codeRel,codeRelVo); + + String drugCode = codeRelVo.getDrugCode(); + if (StrUtil.isNotEmpty(drugCode)){ + //本地查找 未找到再到阿里查找 + ThirdAliDrug thirdAliDrug = thirdAliDrugService.getThirdAliDrug(drugCode); + codeRelVo.setThirdAliDrug(thirdAliDrug); + } + respList.add(codeRelVo); + } + } + + return ResultVOUtils.success(respList); + } } diff --git a/src/main/java/com/glxp/udidl/admin/res/chs/CodeRelVo.java b/src/main/java/com/glxp/udidl/admin/res/chs/CodeRelVo.java new file mode 100644 index 0000000..e14c8d4 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/res/chs/CodeRelVo.java @@ -0,0 +1,82 @@ +package com.glxp.udidl.admin.res.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 com.glxp.udidl.admin.entity.collect.ThirdAliDrug; +import lombok.Data; + +import java.util.Date; + +@Data +@TableName(value = "code_rel") +public class CodeRelVo { + + + @TableId(type = IdType.AUTO) + public Integer id; + + /** + * 器械最小销售产品标识 + */ + @TableField(value = "diNameCode") + public String diNameCode; + + /** + * 阿里药品标识码 + */ + @TableField(value = "drugCode") + public String drugCode; + + /** + * 医保编码 + */ + @TableField(value = "ybbm") + public String ybbm; + + /** + * 阳光采购平台编码 + */ + @TableField(value = "ycCode") + public String ycCode; + + /** + * 商品条码 + */ + @TableField(value = "sptm") + public String sptm; + + /** + * 药品本位码 + */ + @TableField(value = "ypbwm") + public String ypbwm; + + /** + * 统一社会信用号 + */ + @TableField(value = "tyshxyh") + public String tyshxyh; + + /** + * 国家编码9码 + */ + @TableField(value = "gjbm") + public String gjbm; + + @TableField(value = "status") + public String status; + + @TableField(value = "updateTime") + public Date updateTime; + + @TableField(value = "createTime") + public Date createTime; + + @TableField(value = "fromType") + public Integer fromType; + + private ThirdAliDrug thirdAliDrug; + +} \ No newline at end of file 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 index 7dd5826..97209cc 100644 --- a/src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java +++ b/src/main/java/com/glxp/udidl/admin/service/collect/ThirdAliDrugService.java @@ -108,5 +108,16 @@ public class ThirdAliDrugService extends ServiceImpl thirdAliDrugs = this.baseMapper.filterList(thirdAliDrug); + if (CollUtil.isNotEmpty(thirdAliDrugs)){ + return thirdAliDrugs.get(0); + }else { + // TODO: 2025/1/6 前往阿里查找 未找到的话 直接返回 new ThirdAliDrug() + } + return new ThirdAliDrug(); + } } diff --git a/src/main/java/com/glxp/udidl/admin/service/udchs/impl/CodeRelServiceImpl.java b/src/main/java/com/glxp/udidl/admin/service/udchs/impl/CodeRelServiceImpl.java index cb51cee..5968659 100644 --- a/src/main/java/com/glxp/udidl/admin/service/udchs/impl/CodeRelServiceImpl.java +++ b/src/main/java/com/glxp/udidl/admin/service/udchs/impl/CodeRelServiceImpl.java @@ -1,12 +1,21 @@ package com.glxp.udidl.admin.service.udchs.impl; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.glxp.udidl.admin.dao.chs.CodeRelMapper; import com.glxp.udidl.admin.entity.chs.CodeRel; +import com.glxp.udidl.admin.enums.ResultEnum; +import com.glxp.udidl.admin.exception.JsonException; +import com.glxp.udidl.admin.util.ResultVOUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; @Service +@Transactional(rollbackFor = Exception.class) public class CodeRelServiceImpl extends ServiceImpl { //存在就更新 不存在就新增 @@ -19,4 +28,20 @@ public class CodeRelServiceImpl extends ServiceImpl { return b; } + public void updateBatchByCodeRel(List paramList) { + for (int i = 0; i < paramList.size(); i++) { + CodeRel param = paramList.get(i); + + if ( param == null || + (StrUtil.isBlank(param.getDiNameCode()) && StrUtil.isBlank(param.getDrugCode())) + ){ + throw new JsonException(ResultEnum.DATA_ERROR,"参数错误"); + } + boolean b = this.updateByCodeRel(param); + if (!b){ + throw new JsonException(500,"更新失败"); + } + } + + } }