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

259 lines
11 KiB
Java

2 years ago
package com.glxp.api.controller.basic;
import java.util.ArrayList;
import java.util.Date;
2 years ago
import java.util.List;
import javax.annotation.Resource;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.DeptUserEntity;
import com.glxp.api.entity.basic.*;
import com.glxp.api.req.auth.FilterDeptUserReqeust;
import com.glxp.api.req.basic.*;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.auth.AuthAdminResponse;
import com.glxp.api.res.basic.BasicUdiRelResponse;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.service.auth.CustomerService;
2 years ago
import com.glxp.api.service.basic.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
2 years ago
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
2 years ago
import org.springframework.web.bind.annotation.RestController;
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.res.PageSimpleResponse;
import com.glxp.api.util.udi.FilterUdiUtils;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.annotations.ApiIgnore;
2 years ago
/**
*
*/
@Api(tags = "注册企业医疗器械信息绑定接口")
2 years ago
@Slf4j
@RestController
public class UdiSyncController extends BaseController {
2 years ago
@Resource
SyncUdiService syncUdiService;
@Resource
ProductInfoService productInfoService;
@Resource
UdiCompanyService udiCompanyService;
@Resource
BasicUdiRelService basicUdiRelService;
@Resource
CustomerService customerService;
2 years ago
@Resource
BasicUdiProductService basicUdiProductService;
2 years ago
//获取同步库UDI信息
@ApiIgnore
2 years ago
@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();
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);
2 years ago
}
}
}
}
return udiDlDeviceResponse;
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultVOUtils.error(500, "连接UDI数据下载服务出错");
}
}
//获取同步库医疗器械注册人信息
@ApiIgnore
2 years ago
@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数据下载服务出错");
}
}
//获取同步库UDI信息
@AuthRuleAnnotation("")
@ApiIgnore
@GetMapping("udi/basic/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();
if (StrUtil.isNotEmpty(nameCode)) {
filterUdiRelRequest.setNameCode(nameCode);
} else {
filterUdiRelRequest.setDiType(1);
}
List<BasicUdiRelResponse> udiDlDeviceResponse = basicUdiRelService.filterList(filterUdiRelRequest);
PageInfo<BasicUdiRelResponse> basicUdiRelResponsePageInfo = new PageInfo<>(udiDlDeviceResponse);
PageSimpleResponse<BasicUdiRelResponse> basicUdiRelResponsePageSimpleResponse = new PageSimpleResponse<>();
basicUdiRelResponsePageSimpleResponse.setTotal(basicUdiRelResponsePageInfo.getTotal());
basicUdiRelResponsePageSimpleResponse.setList(udiDlDeviceResponse);
return ResultVOUtils.success(basicUdiRelResponsePageSimpleResponse);
}
//产品信息关联新增
2 years ago
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "注册企业新增医疗器械信息", response = BaseResponse.class)
@PostMapping("udi/basic/rel/save")
public BaseResponse saveRel(@RequestBody BasicUdiReRequest basicUdiReRequest) {
BasicUdiRelEntity basicUdiRelEntity = new BasicUdiRelEntity();
BeanUtils.copyProperties(basicUdiReRequest, basicUdiRelEntity);
basicUdiRelEntity.setUpdateTime(new Date());
basicUdiRelEntity.setUpdateUser(customerService.getUserId() + "");
basicUdiRelEntity.setId(IdUtil.getSnowflakeNextId());
basicUdiRelService.save(basicUdiRelEntity);
return ResultVOUtils.success("添加成功!");
}
//产品信息关联新增
@AuthRuleAnnotation("")
@ApiOperation(value = "注册企业批量新增医疗器械信息", response = BaseResponse.class)
@PostMapping("udi/basic/rel/batch/save")
public BaseResponse batchSaveRel(@RequestBody UdiSelectRequest udiSelectRequest) {
String userId = customerService.getUserId() + "";
2 years ago
if (CollUtil.isNotEmpty(udiSelectRequest.getProducts())) {
for (BasicUdiRelRequest basicUdiRelRequest : udiSelectRequest.getProducts()) {
if (!basicUdiRelService.isExit(basicUdiRelRequest.getUuid(), udiSelectRequest.getCompanyId())) {
BasicUdiRelEntity basicUdiRelEntity = new BasicUdiRelEntity();
basicUdiRelEntity.setUuid(basicUdiRelRequest.getUuid());
basicUdiRelEntity.setCompanyIdFk(udiSelectRequest.getCompanyId());
basicUdiRelEntity.setUpdateTime(new Date());
basicUdiRelEntity.setUpdateUser(userId);
basicUdiRelEntity.setId(IdUtil.getSnowflakeNextId());
basicUdiRelService.save(basicUdiRelEntity);
List<ProductInfoEntity> productInfoEntities = productInfoService.selectByUuid(basicUdiRelRequest.getUuid());
if (CollUtil.isNotEmpty(productInfoEntities)) {
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
// basicUdiProductService
BasicUdiProductEntity basicUdiProductEntity = new BasicUdiProductEntity();
BeanUtils.copyProperties(productInfoEntity, basicUdiProductEntity);
basicUdiProductEntity.setId(IdUtil.getSnowflakeNextId());
basicUdiProductService.save(basicUdiProductEntity);
}
}
}
}
}
return ResultVOUtils.success("添加成功!");
}
@AuthRuleAnnotation("")
@PostMapping("udi/basic/rel/delete")
public BaseResponse deletRel(@RequestBody DeleteRequest deleteRequest) {
basicUdiRelService.removeById(deleteRequest.getId());
return ResultVOUtils.success("删除成功!");
}
//产品信息关联修改
@AuthRuleAnnotation("")
@PostMapping("udi/basic/rel/update")
2 years ago
public BaseResponse updateRel(@RequestBody BasicUdiRelRequest basicUdiRelRequest) {
BasicUdiRelEntity basicUdiRelEntity = new BasicUdiRelEntity();
BeanUtils.copyProperties(basicUdiRelRequest, basicUdiRelEntity);
basicUdiRelEntity.setUpdateTime(new Date());
basicUdiRelEntity.setUpdateUser(customerService.getUserId() + "");
basicUdiRelService.updateById(basicUdiRelEntity);
return ResultVOUtils.success("添加成功!");
}
2 years ago
//出入库同步下载
@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);
}
/**
* DI
*/
@ApiIgnore
@AuthRuleAnnotation("")
@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);
2 years ago
}
}