You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
8.1 KiB
Java
177 lines
8.1 KiB
Java
package com.glxp.api.controller.thrsys;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.glxp.api.annotation.CusRedissonAnnotation;
|
|
import com.glxp.api.annotation.RepeatSubmit;
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.constant.RedissonCacheKey;
|
|
import com.glxp.api.controller.BaseController;
|
|
import com.glxp.api.controller.alihealth.AlihealthBusController;
|
|
import com.glxp.api.entity.auth.AuthAliUser;
|
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
|
import com.glxp.api.entity.thrsys.ThirdAliDrug;
|
|
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
|
|
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
|
|
import com.glxp.api.req.basic.FilterUdiRelRequest;
|
|
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
|
|
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.collect.RelCodeDetailResponse;
|
|
import com.glxp.api.res.thrsys.ThrCorpsResponse;
|
|
import com.glxp.api.service.auth.AuthAliUserService;
|
|
import com.glxp.api.service.basic.UdiProductService;
|
|
import com.glxp.api.service.thrsys.ThirdAliDrugService;
|
|
import com.glxp.api.util.StringUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@Slf4j
|
|
public class ThirdAliDrugController extends BaseController {
|
|
|
|
@Resource
|
|
private ThirdAliDrugService thirdAliDrugService;
|
|
@Resource
|
|
private AlihealthBusController alihealthBusController;
|
|
@Resource
|
|
private AuthAliUserService authAliUserService;
|
|
@Resource
|
|
private UdiProductService udiProductService;
|
|
|
|
/**
|
|
* 上传文件保存
|
|
*
|
|
* @param uuid
|
|
* @param file
|
|
* @return
|
|
*/
|
|
@RepeatSubmit()
|
|
@CusRedissonAnnotation(cacheName = RedissonCacheKey.XML_UPLOAD_ALI, key = {"#uuid"}, timeOutMsg = "系统正在处理,请勿重复上传")
|
|
@PostMapping("/udiwms/aliDrug/txtUpload")
|
|
public BaseResponse txtUpload(@RequestParam("uuid") String uuid, @RequestParam("file") MultipartFile file) {
|
|
thirdAliDrugService.txtUpload(file);
|
|
return ResultVOUtils.successMsg("上传成功!");
|
|
}
|
|
|
|
|
|
@GetMapping("/udiwms/aliDrug/getDrugLevelList")
|
|
public BaseResponse getDrugLevelList(ThirdAliDrugRequest thirdAliDrug, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
|
|
if (StrUtil.isEmpty(thirdAliDrug.getApprovalNum()) && StrUtil.isEmpty(thirdAliDrug.getNameCode()) &&
|
|
StrUtil.isEmpty(thirdAliDrug.getCpmctymc()) && StrUtil.isEmpty(thirdAliDrug.getManufacturer())
|
|
) {
|
|
return ResultVOUtils.success("查询参数不能为空");
|
|
}
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setUuid(thirdAliDrug.getUuid());
|
|
List<UdiProductEntity> udiInfoEntities = udiProductService.filterAllUdiInfo(filterUdiRelRequest);
|
|
List<String> nameCodeIn = new ArrayList<>();
|
|
if (udiInfoEntities != null && udiInfoEntities.size() > 0) {
|
|
for (UdiProductEntity udiInfoEntity : udiInfoEntities) {
|
|
if (StringUtils.isNotEmpty(udiInfoEntity.getNameCode())) {
|
|
nameCodeIn.add(udiInfoEntity.getNameCode());
|
|
}
|
|
}
|
|
|
|
}
|
|
thirdAliDrug.setNameCodeIn(nameCodeIn);
|
|
// 不查本地库全查阿里的库
|
|
List<ThirdAliDrug> list = thirdAliDrugService.filterList(thirdAliDrug);
|
|
if(list == null || list.size() == 0){
|
|
|
|
AuthAliUser authAliUser = authAliUserService.getOne();
|
|
AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust();
|
|
alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid());
|
|
alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret());
|
|
alihealthThirdAliDrugInsertReqeust.setManufactory(thirdAliDrug.getManufacturer());
|
|
alihealthThirdAliDrugInsertReqeust.setBzgg(thirdAliDrug.getBzgg());
|
|
alihealthThirdAliDrugInsertReqeust.setFormSpec(thirdAliDrug.getFormSpec());
|
|
|
|
alihealthThirdAliDrugInsertReqeust.setGjkSwitch(true);
|
|
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust();
|
|
alihealthKytDrugrescodeReqeust.setPhysic_name(thirdAliDrug.getCpmctymc());
|
|
alihealthKytDrugrescodeReqeust.setApproval_licence_no(thirdAliDrug.getApprovalNum());
|
|
// alihealthKytDrugrescodeReqeust.setEnt_name(thirdAliDrug.getManufacturer());
|
|
// alihealthKytDrugrescodeReqeust.setPackage_spec(thirdAliDrug.getBzgg());
|
|
// alihealthKytDrugrescodeReqeust.setPrepn_spec(thirdAliDrug.getFormSpec());
|
|
|
|
alihealthKytDrugrescodeReqeust.setPage_size(200);
|
|
alihealthKytDrugrescodeReqeust.setPage(1);
|
|
alihealthKytDrugrescodeReqeust.setApp_key(authAliUser.getAppkey());
|
|
alihealthKytDrugrescodeReqeust.setRef_ent_id(authAliUser.getRefentid());
|
|
alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust);
|
|
try {
|
|
BaseResponse baseResponse = alihealthBusController.thirdAliDrugList(alihealthThirdAliDrugInsertReqeust);
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
|
if (thirdAliDrugService.addOrUpdate((List) baseResponse.getData())) {
|
|
list = thirdAliDrugService.filterList(thirdAliDrug);
|
|
|
|
} else {
|
|
log.error("获取阿里和国家库码段信息===未查到产品信息");
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
log.error("获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
|
|
// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
|
|
// error = "供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage();
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
log.error("获取阿里和国家库码段信息出现错误===" + e.getMessage());
|
|
|
|
}
|
|
}
|
|
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("标识参数不能为空");
|
|
}
|
|
ThirdAliDrug one = thirdAliDrugService.getOne(new LambdaQueryWrapper<ThirdAliDrug>().eq(ThirdAliDrug::getNameCode, nameCode));
|
|
if (one == null) {
|
|
return ResultVOUtils.error("标识参数错误");
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
}
|