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.
udi-cpt-java/src/main/java/com/glxp/api/controller/basic/UdiSyncController.java

228 lines
9.6 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.glxp.api.controller.basic;
import cn.hutool.core.util.StrUtil;
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.entity.basic.ProductInfoEntity;
import com.glxp.api.entity.basic.UdiCompanyEntity;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.req.basic.FilterUdiRelRequest;
import com.glxp.api.req.basic.ProductInfoFilterRequest;
import com.glxp.api.req.basic.UdiCompanyRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicUdiRelResponse;
import com.glxp.api.service.basic.*;
import com.glxp.api.util.udi.FilterUdiUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "UDI同步相关接口")
@Slf4j
@RestController
public class UdiSyncController {
@Resource
SyncUdiService syncUdiService;
@Resource
ProductInfoService productInfoService;
@Resource
UdiCompanyService udiCompanyService;
@Resource
BasicUdiRelService basicUdiRelService;
@Resource
BasicUdiProductService basicUdiProductService;
//获取同步库UDI信息
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "获取同步库UDI信息",response = ProductInfoEntity.class)
@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();
BeanUtils.copyProperties(filterUdiRelRequest, productInfoFilterRequest);
if (StrUtil.isNotEmpty(nameCode)) {
productInfoFilterRequest.setNameCode(nameCode);
} else {
productInfoFilterRequest.setDiType("1");
}
try {
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
return udiDlDeviceResponse;
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultVOUtils.error(500, "连接UDI数据下载服务出错");
}
}
//获取同步库UDI信息
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "获取同步库UDI字典信息",response = ProductInfoEntity.class)
@GetMapping("udiwms/udiinfo/dict/filter")
public BaseResponse filterDict(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();
BeanUtils.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) {
Boolean isExit = basicUdiProductService.isExit(productInfoEntity.getUuid());
if (isExit) {
productInfoEntity.setCheck(true);
} else
productInfoEntity.setCheck(false);
}
}
}
}
return udiDlDeviceResponse;
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultVOUtils.error(500, "连接UDI数据下载服务出错");
}
}
//获取同步库UDI信息
@ApiIgnore
@AuthRuleAnnotation("获取同步库UDI关联信息")
@ApiOperation(value = "",response = ProductInfoEntity.class)
@GetMapping("udiwms/udiinfo/rel/filter")
public BaseResponse filterRel(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();
BeanUtils.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) {
Boolean isExit = basicUdiRelService.isExit(productInfoEntity.getUuid(), filterUdiRelRequest.getCompanyId());
if (isExit) {
productInfoEntity.setCheck(true);
} else
productInfoEntity.setCheck(false);
}
}
}
}
return udiDlDeviceResponse;
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultVOUtils.error(500, "连接UDI数据下载服务出错");
}
}
//获取同步库医疗器械注册人信息
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "获取同步库医疗器械注册人信息",response = UdiCompanyEntity.class)
@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数据下载服务出错");
}
}
//出入库同步下载
@ApiOperation(value = "出入库同步下载(同步UDI)",response = ProductInfoEntity.class)
@GetMapping("udidl/udiwms/syncUdi")
public BaseResponse syncUdi(ProductInfoFilterRequest productInfoFilterRequest) {
List<ProductInfoEntity> productInfoEntityList = productInfoService.syncDlUdi(productInfoFilterRequest);
return ResultVOUtils.success(productInfoEntityList);
}
//出入库同步下载
@ApiOperation(value = "出入库同步下载(同步企业)",response = UdiCompanyEntity.class)
@GetMapping("udidl/udiwms/syncCompany")
public BaseResponse syncCompany(UdiCompanyRequest udiCompanyRequest) {
List<UdiCompanyEntity> udiCompanyEntities = udiCompanyService.syncDlCompany(udiCompanyRequest);
return ResultVOUtils.success(udiCompanyEntities);
}
/**
* 耗材字典信息获取同一产品对应DI信息
*/
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "耗材字典信息获取同一产品对应DI信息",response = ProductInfoEntity.class)
@GetMapping("udiwms/udiinfo/local/filterByUuid")
public BaseResponse filterLocalByUuid(FilterUdiRelRequest filterUdiRelRequest) {
if (StrUtil.isEmpty(filterUdiRelRequest.getUuid())) {
return ResultVOUtils.error(500, "产品ID主键不能为空");
}
List<ProductInfoEntity> udiInfoEntities = productInfoService.selectByUuid(filterUdiRelRequest.getUuid());
return ResultVOUtils.success(udiInfoEntities);
}
}