|
|
package com.glxp.api.controller.basic;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
import com.glxp.api.constant.AsyncDiDlHelper;
|
|
|
import com.glxp.api.dto.DictDto;
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
import com.glxp.api.req.basic.*;
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 国家库产品信息相关接口
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
public class UdiSyncController {
|
|
|
|
|
|
@Resource
|
|
|
UdiRelevanceService udiRelevanceService;
|
|
|
@Resource
|
|
|
UdiProductService udiProductService;
|
|
|
@Resource
|
|
|
SyncUdiService syncUdiService;
|
|
|
@Resource
|
|
|
AsyncDiDlHelper asyncDiDlHelper;
|
|
|
@Resource
|
|
|
ProductInfoService productInfoService;
|
|
|
@Resource
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
|
|
|
|
|
|
//获取同步库UDI信息
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/filterUdi")
|
|
|
public BaseResponse filterUdi(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
String nameCode;
|
|
|
if (StrUtil.isNotEmpty(filterUdiRelRequest.getUdiCode())) {
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiRelRequest.getUdiCode());
|
|
|
if (udiEntity != null) {
|
|
|
nameCode = udiEntity.getUdi();
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, "无效UDI码!");
|
|
|
}
|
|
|
} else
|
|
|
nameCode = filterUdiRelRequest.getNameCode();
|
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
BeanUtil.copyProperties(filterUdiRelRequest, productInfoFilterRequest);
|
|
|
if (StrUtil.isNotEmpty(nameCode)) {
|
|
|
productInfoFilterRequest.setNameCode(nameCode);
|
|
|
} else {
|
|
|
productInfoFilterRequest.setDiType("1");
|
|
|
}
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
if (udiDlDeviceResponse.getCode() == 20000) {
|
|
|
if (filterUdiRelRequest.getIsCheck() != null && filterUdiRelRequest.getIsCheck()) {
|
|
|
List<ProductInfoEntity> productInfoEntities = udiDlDeviceResponse.getData().getList();
|
|
|
if (productInfoEntities != null && productInfoEntities.size() > 0) {
|
|
|
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
|
|
|
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceService.selectByUuid(productInfoEntity.getUuid());
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 0) {
|
|
|
for (UdiRelevanceEntity udiRelevanceEntity : udiRelevanceEntities) {
|
|
|
if (udiRelevanceEntity.getThirdId() == null &&
|
|
|
udiRelevanceEntity.getThirdId2() == null && udiRelevanceEntity.getThirdId1() == null &&
|
|
|
udiRelevanceEntity.getThirdId3() == null && udiRelevanceEntity.getThirdId4() == null) {
|
|
|
//不能添加
|
|
|
productInfoEntity.setCheck(true);
|
|
|
break;
|
|
|
} else
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/drugs/filter")
|
|
|
public BaseResponse getDurgs(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
String nameCode;
|
|
|
if (StrUtil.isNotEmpty(filterUdiRelRequest.getUdiCode())) {
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiRelRequest.getUdiCode());
|
|
|
if (udiEntity != null) {
|
|
|
nameCode = udiEntity.getUdi();
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, "无效UDI码!");
|
|
|
}
|
|
|
} else
|
|
|
nameCode = filterUdiRelRequest.getNameCode();
|
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
BeanUtil.copyProperties(filterUdiRelRequest, productInfoFilterRequest);
|
|
|
if (StrUtil.isNotEmpty(nameCode)) {
|
|
|
productInfoFilterRequest.setNameCode(nameCode);
|
|
|
} else {
|
|
|
productInfoFilterRequest.setDiType("1");
|
|
|
}
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.getDrugs(productInfoFilterRequest);
|
|
|
if (udiDlDeviceResponse.getCode() == 20000) {
|
|
|
if (filterUdiRelRequest.getIsCheck() != null && filterUdiRelRequest.getIsCheck()) {
|
|
|
List<ProductInfoEntity> productInfoEntities = udiDlDeviceResponse.getData().getList();
|
|
|
if (productInfoEntities != null && productInfoEntities.size() > 0) {
|
|
|
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
|
|
|
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceService.selectByUuid(productInfoEntity.getUuid());
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 0) {
|
|
|
for (UdiRelevanceEntity udiRelevanceEntity : udiRelevanceEntities) {
|
|
|
if (udiRelevanceEntity.getThirdId() == null &&
|
|
|
udiRelevanceEntity.getThirdId2() == null && udiRelevanceEntity.getThirdId1() == null &&
|
|
|
udiRelevanceEntity.getThirdId3() == null && udiRelevanceEntity.getThirdId4() == null) {
|
|
|
//不能添加
|
|
|
productInfoEntity.setCheck(true);
|
|
|
break;
|
|
|
} else
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取同步库医疗器械注册人信息
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/filterCompany")
|
|
|
public BaseResponse filterCompany(UdiCompanyRequest udiCompanyRequest) {
|
|
|
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<UdiCompanyEntity>> udiDlDeviceResponse = syncUdiService.filterCompany(udiCompanyRequest);
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取同步库医疗器械注册人信息
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/filterCompanyOptimize")
|
|
|
public BaseResponse filterCompanyOptimize(UdiCompanyRequest udiCompanyRequest) {
|
|
|
|
|
|
try {
|
|
|
BaseResponse<Page<UdiCompanyEntity>> udiDlDeviceResponse = syncUdiService.filterCompany(udiCompanyRequest);
|
|
|
List<DictDto> reList = udiDlDeviceResponse.getData().getResult().stream().map(s-> {
|
|
|
DictDto dictDto = new DictDto(s.getYlqxzcrbarmc(),s.getYlqxzcrbarmc());
|
|
|
return dictDto;
|
|
|
}).collect(Collectors.toList());
|
|
|
PageSimpleResponse<DictDto> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(udiDlDeviceResponse.getData().getTotal());
|
|
|
pageSimpleResponse.setList(reList);
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/superSearch")
|
|
|
public BaseResponse superSearch(FilterUdiInfoRequest filterUdiInfoRequest) {
|
|
|
|
|
|
if (StrUtil.isEmpty(filterUdiInfoRequest.getNameCode()) && StrUtil.isEmpty(filterUdiInfoRequest.getUdiCode())) {
|
|
|
return ResultVOUtils.error(500, "DI不能为空!");
|
|
|
}
|
|
|
|
|
|
if (StrUtil.isNotEmpty(filterUdiInfoRequest.getUdiCode())) {
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiInfoRequest.getUdiCode());
|
|
|
if (udiEntity == null)
|
|
|
return ResultVOUtils.error(500, "UDI码格式错误!");
|
|
|
filterUdiInfoRequest.setNameCode(udiEntity.getUdi());
|
|
|
}
|
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
productInfoFilterRequest.setNameCode(filterUdiInfoRequest.getNameCode());
|
|
|
productInfoFilterRequest.setPage(filterUdiInfoRequest.getPage());
|
|
|
productInfoFilterRequest.setLimit(filterUdiInfoRequest.getLimit());
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
if (udiDlDeviceResponse.getCode() != 20000) {
|
|
|
return udiDlDeviceResponse;
|
|
|
}
|
|
|
if (CollUtil.isEmpty(udiDlDeviceResponse.getData().getList())) {
|
|
|
BaseResponse<List<ProductInfoEntity>> listBaseResponse = asyncDiDlHelper.dlByDiRes(filterUdiInfoRequest.getNameCode());
|
|
|
|
|
|
if (listBaseResponse.getCode() == 20000) {
|
|
|
List<ProductInfoEntity> productInfoEntityList = listBaseResponse.getData();
|
|
|
if (CollUtil.isNotEmpty(productInfoEntityList)) {
|
|
|
productInfoService.insertProductInfos(productInfoEntityList);
|
|
|
udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
} else {
|
|
|
ResultVOUtils.error(500, "未查询到该产品DI");
|
|
|
}
|
|
|
} else {
|
|
|
return listBaseResponse;
|
|
|
}
|
|
|
}
|
|
|
if (filterUdiInfoRequest.getIsCheck() != null && filterUdiInfoRequest.getIsCheck()) {
|
|
|
List<ProductInfoEntity> productInfoEntities = udiDlDeviceResponse.getData().getList();
|
|
|
List<UdiInfoRequest> udiInfoEntities = new ArrayList<>();
|
|
|
if (productInfoEntities != null && productInfoEntities.size() > 0) {
|
|
|
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
|
|
|
UdiInfoRequest udiInfoEntity = new UdiInfoRequest();
|
|
|
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceService.selectByUuid(productInfoEntity.getUuid());
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 0) {
|
|
|
BeanUtils.copyProperties(productInfoEntity, udiInfoEntity);
|
|
|
for (UdiRelevanceEntity udiRelevanceEntity : udiRelevanceEntities) {
|
|
|
if (udiRelevanceEntity.getThirdId() == null &&
|
|
|
udiRelevanceEntity.getThirdId2() == null && udiRelevanceEntity.getThirdId1() == null &&
|
|
|
udiRelevanceEntity.getThirdId3() == null && udiRelevanceEntity.getThirdId4() == null) {
|
|
|
//不能添加
|
|
|
udiInfoEntity.setCheck(true);
|
|
|
break;
|
|
|
} else
|
|
|
udiInfoEntity.setCheck(false);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
udiInfoEntity.setCheck(false);
|
|
|
}
|
|
|
udiInfoEntities.add(udiInfoEntity);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/basic/instrument/maintain/filterProduct")
|
|
|
public BaseResponse filterProduct(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
List<UdiProductEntity> udiInfoEntities
|
|
|
= udiProductService.filterAllUdiInfo(filterUdiRelRequest);
|
|
|
PageInfo<UdiProductEntity> pageInfo;
|
|
|
pageInfo = new PageInfo<>(udiInfoEntities);
|
|
|
PageSimpleResponse<UdiProductEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
pageSimpleResponse.setList(udiInfoEntities);
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/basic/findByCode")
|
|
|
public BaseResponse findByCode(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiRelRequest.getUdiCode());
|
|
|
UdiProductEntity udiProductEntity
|
|
|
= udiProductService.findByNameCode(udiEntity.getUdi());
|
|
|
return ResultVOUtils.success(udiProductEntity);
|
|
|
}
|
|
|
|
|
|
|
|
|
//出入库同步下载
|
|
|
@GetMapping("udidl/udiwms/syncUdi")
|
|
|
public BaseResponse syncUdi(ProductInfoFilterRequest productInfoFilterRequest) {
|
|
|
|
|
|
List<ProductInfoEntity> productInfoEntityList = productInfoService.syncDlUdi(productInfoFilterRequest);
|
|
|
return ResultVOUtils.success(productInfoEntityList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//出入库同步下载
|
|
|
@GetMapping("udidl/udiwms/syncCompany")
|
|
|
public BaseResponse syncCompany(UdiCompanyRequest udiCompanyRequest) {
|
|
|
|
|
|
List<UdiCompanyEntity> udiCompanyEntities = udiCompanyService.syncDlCompany(udiCompanyRequest);
|
|
|
return ResultVOUtils.success(udiCompanyEntities);
|
|
|
|
|
|
}
|
|
|
}
|