feat: 暴露多码融合的关系接口给自助调用

v3
chenhc 3 months ago
parent ac1ce57da9
commit 67d174f381

@ -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<CodeRel> 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<CodeRelVo> respList = new ArrayList<>();
List<CodeRel> list = codeRelService.list(new LambdaQueryWrapper<CodeRel>()
.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);
}
}

@ -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;
}

@ -108,5 +108,16 @@ public class ThirdAliDrugService extends ServiceImpl<ThirdAliDrugMapper, ThirdAl
}
public ThirdAliDrug getThirdAliDrug(String drugCode) {
ThirdAliDrugRequest thirdAliDrug = new ThirdAliDrugRequest();
thirdAliDrug.setNameCode(drugCode);
List<ThirdAliDrug> thirdAliDrugs = this.baseMapper.filterList(thirdAliDrug);
if (CollUtil.isNotEmpty(thirdAliDrugs)){
return thirdAliDrugs.get(0);
}else {
// TODO: 2025/1/6 前往阿里查找 未找到的话 直接返回 new ThirdAliDrug()
}
return new ThirdAliDrug();
}
}

@ -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<CodeRelMapper, CodeRel> {
//存在就更新 不存在就新增
@ -19,4 +28,20 @@ public class CodeRelServiceImpl extends ServiceImpl<CodeRelMapper, CodeRel> {
return b;
}
public void updateBatchByCodeRel(List<CodeRel> 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,"更新失败");
}
}
}
}

Loading…
Cancel
Save