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/UdiRelController.java

205 lines
9.5 KiB
Java

package com.glxp.api.controller.basic;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
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.controller.BaseController;
import com.glxp.api.entity.basic.*;
import com.glxp.api.req.basic.*;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicUdiRelResponse;
import com.glxp.api.service.auth.CustomerService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
*/
@Api(tags = "注册企业医疗器械信息绑定接口")
@Slf4j
@RestController
public class UdiRelController extends BaseController {
@Resource
BasicUdiRelService basicUdiRelService;
@Resource
CustomerService customerService;
@Resource
BasicUdiProductService basicUdiProductService;
@Resource
ProductInfoService productInfoService;
//获取同步库UDI信息
@AuthRuleAnnotation("")
@ApiIgnore
2 years ago
@ApiOperation(value = "获取同步库UDI信息", response = BasicUdiRelResponse.class)
@GetMapping("udi/basic/rel/filter")
public BaseResponse filterRel(FilterUdiRelRequest filterUdiRelRequest) {
System.out.println(filterUdiRelRequest.toString());
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.filtersList(filterUdiRelRequest);
PageInfo<BasicUdiRelResponse> basicUdiRelResponsePageInfo = new PageInfo<>(udiDlDeviceResponse);
PageSimpleResponse<BasicUdiRelResponse> basicUdiRelResponsePageSimpleResponse = new PageSimpleResponse<>();
basicUdiRelResponsePageSimpleResponse.setTotal(basicUdiRelResponsePageInfo.getTotal());
basicUdiRelResponsePageSimpleResponse.setList(udiDlDeviceResponse);
return ResultVOUtils.success(basicUdiRelResponsePageSimpleResponse);
}
//获取同步库UDI信息
@AuthRuleAnnotation("")
@ApiIgnore
@ApiOperation(value = "获取企业产品信息", response = BasicUdiRelResponse.class)
@GetMapping("udi/basic/rel/company/filter")
public BaseResponse filterRelByCompany(FilterUdiRelRequest filterUdiRelRequest) {
System.out.println(filterUdiRelRequest.toString());
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);
}
2 years ago
List<BasicUdiRelResponse> udiDlDeviceResponse = basicUdiRelService.filtersList(filterUdiRelRequest);
PageInfo<BasicUdiRelResponse> basicUdiRelResponsePageInfo = new PageInfo<>(udiDlDeviceResponse);
PageSimpleResponse<BasicUdiRelResponse> basicUdiRelResponsePageSimpleResponse = new PageSimpleResponse<>();
basicUdiRelResponsePageSimpleResponse.setTotal(basicUdiRelResponsePageInfo.getTotal());
basicUdiRelResponsePageSimpleResponse.setList(udiDlDeviceResponse);
return ResultVOUtils.success(basicUdiRelResponsePageSimpleResponse);
}
//产品信息关联新增
@ApiIgnore
@AuthRuleAnnotation("")
@ApiOperation(value = "注册企业新增医疗器械信息", response = BaseResponse.class)
@PostMapping("udi/basic/rel/save")
public BaseResponse saveRel(@RequestBody BasicUdiBatchRelRequest basicUdiBatchRelRequest) {
BasicUdiRelEntity basicUdiRelEntity = new BasicUdiRelEntity();
BeanUtils.copyProperties(basicUdiBatchRelRequest, 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() + "";
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.setCompanyType(basicUdiRelRequest.getCompanyType());
basicUdiRelEntity.setId(IdUtil.getSnowflakeNextId());
basicUdiRelService.save(basicUdiRelEntity);
List<ProductInfoEntity> productInfoEntities = productInfoService.selectByUuid(basicUdiRelRequest.getUuid());
if (CollUtil.isNotEmpty(productInfoEntities)) {
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
BasicUdiProductEntity basicUdiProductEntity = new BasicUdiProductEntity();
BeanUtils.copyProperties(productInfoEntity, basicUdiProductEntity);
basicUdiProductEntity.setId(IdUtil.getSnowflakeNextId());
2 years ago
if (!basicUdiProductService.isExit(basicUdiProductEntity.getUuid())) {
basicUdiProductService.save(basicUdiProductEntity);
}
}
}
}
}
}
return ResultVOUtils.success("添加成功!");
}
@AuthRuleAnnotation("")
2 years ago
@ApiOperation(value = "注册企业删除医疗器械信息", response = BaseResponse.class)
@PostMapping("udi/basic/rel/delete")
public BaseResponse deletRel(@RequestBody DeleteRequest deleteRequest) {
basicUdiRelService.removeById(deleteRequest.getId());
return ResultVOUtils.success("删除成功!");
}
//产品信息关联修改
@AuthRuleAnnotation("")
2 years ago
@ApiOperation(value = "注册企更新除医疗器械信息", response = BaseResponse.class)
@PostMapping("udi/basic/rel/update")
public BaseResponse updateRel(@RequestBody BasicUdiRelRequest basicUdiRelRequest) {
2 years ago
if (basicUdiRelRequest.getAgengtStartDate() != null && basicUdiRelRequest.getAgengtEndDate() != null) {
if (basicUdiRelRequest.getAgengtStartDate().getTime() > basicUdiRelRequest.getAgengtEndDate().getTime()) {
return ResultVOUtils.error(999, "代理起始时间不能小于代理截止时间!");
}
}
BasicUdiRelEntity basicUdiRelEntity = new BasicUdiRelEntity();
BeanUtils.copyProperties(basicUdiRelRequest, basicUdiRelEntity);
basicUdiRelEntity.setUpdateTime(new Date());
basicUdiRelEntity.setUpdateUser(customerService.getUserId() + "");
basicUdiRelService.updateById(basicUdiRelEntity);
BasicUdiProductEntity basicUdiProductEntity = new BasicUdiProductEntity();
basicUdiProductEntity.setUuid(basicUdiRelRequest.getUuid());
basicUdiProductEntity.setManufactory(basicUdiRelRequest.getManufactory());
basicUdiProductEntity.setMeasname(basicUdiRelRequest.getMeasname());
basicUdiProductEntity.setSpmc(basicUdiRelRequest.getSpmc());
2 years ago
basicUdiProductEntity.setMeasname(basicUdiRelRequest.getMeasname());
basicUdiProductEntity.setManufactory(basicUdiRelRequest.getManufactory());
basicUdiProductService.updateByUuid(basicUdiProductEntity);
return ResultVOUtils.success("添加成功!");
}
}