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-spms-java/src/main/java/com/glxp/api/service/basic/SyncUdiService.java

162 lines
8.6 KiB
Java

package com.glxp.api.service.basic;
import cn.hutool.core.util.StrUtil;
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.req.basic.ProductInfoFilterRequest;
import com.glxp.api.req.basic.UdiCompanyRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.util.RedisUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@Service
public class SyncUdiService {
@Resource
ProductInfoService productInfoService;
@Resource
UdiCompanyService udiCompanyService;
@Resource
RedisUtil redisUtil;
public BaseResponse filterUdi(ProductInfoFilterRequest productInfoFilterRequest) {
//过滤--1.参数不能全未空
if ((productInfoFilterRequest.getYlqxzcrbarmc() == null || productInfoFilterRequest.getYlqxzcrbarmc().equals("")) &&
(productInfoFilterRequest.getCpmctymc() == null || productInfoFilterRequest.getCpmctymc().equals("")) &&
(productInfoFilterRequest.getNameCode() == null || productInfoFilterRequest.getNameCode().equals("")) &&
(productInfoFilterRequest.getGgxh() == null || productInfoFilterRequest.getGgxh().equals("")) &&
(productInfoFilterRequest.getUuid() == null || productInfoFilterRequest.getUuid().equals("")) &&
(productInfoFilterRequest.getZczbhhzbapzbh() == null || productInfoFilterRequest.getZczbhhzbapzbh().equals("")) &&
(productInfoFilterRequest.getDeviceRecordKey() == null || productInfoFilterRequest.getDeviceRecordKey().equals(""))
) {
return ResultVOUtils.error(500, "查询条件不能为空!");
}
if (StrUtil.isEmpty(productInfoFilterRequest.getYlqxzcrbarmc()) &&
StrUtil.isEmpty(productInfoFilterRequest.getCpmctymc())
&& StrUtil.isEmpty(productInfoFilterRequest.getNameCode())
&& StrUtil.isEmpty(productInfoFilterRequest.getGgxh())
&& StrUtil.isEmpty(productInfoFilterRequest.getUuid())
&& StrUtil.isEmpty(productInfoFilterRequest.getZczbhhzbapzbh())) {
if (productInfoFilterRequest.getNameCode() != null && !productInfoFilterRequest.getNameCode().equals("") && productInfoFilterRequest.getNameCode().length() < 10) {
return ResultVOUtils.error(500, "请输入完整的最小销售单元标识!");
}
}
if (StrUtil.isEmpty(productInfoFilterRequest.getYlqxzcrbarmc()) && StrUtil.isEmpty(productInfoFilterRequest.getNameCode())) {
if (StrUtil.isNotEmpty(productInfoFilterRequest.getCpmctymc())) {
return ResultVOUtils.error(500, "请输入医疗器械注册备案人名称");
}
if (productInfoFilterRequest.getGgxh() != null && !productInfoFilterRequest.getGgxh().equals("")) {
return ResultVOUtils.error(500, "请输入医疗器械注册备案人名称");
}
if (productInfoFilterRequest.getZczbhhzbapzbh() != null && !productInfoFilterRequest.getZczbhhzbapzbh().equals("")) {
return ResultVOUtils.error(500, "请输入医疗器械注册备案人名称");
}
}
if ((productInfoFilterRequest.getYlqxzcrbarmc() == null || productInfoFilterRequest.getYlqxzcrbarmc().equals(""))
&& (productInfoFilterRequest.getNameCode() == null || productInfoFilterRequest.getNameCode().equals(""))
&& (productInfoFilterRequest.getCpmctymc() == null || productInfoFilterRequest.getCpmctymc().equals(""))
) {
if (productInfoFilterRequest.getGgxh() != null && !productInfoFilterRequest.getGgxh().equals("")) {
return ResultVOUtils.error(500, "请输入医疗器械注册备案人名称");
}
if (productInfoFilterRequest.getZczbhhzbapzbh() != null && !productInfoFilterRequest.getZczbhhzbapzbh().equals("")) {
return ResultVOUtils.error(500, "请输入医疗器械注册备案人名称");
}
}
if (productInfoFilterRequest.getCpmctymc() != null && !productInfoFilterRequest.getCpmctymc().equals("") && productInfoFilterRequest.getCpmctymc().length() < 4) {
return ResultVOUtils.error(500, "请输入完整的产品通用名称!");
}
productInfoFilterRequest.setIsNewest(1);
// productInfoFilterRequest.setDiType("1");
String keyCache = productInfoFilterRequest.toCacheKey();
if (StrUtil.isEmpty(keyCache)) {
return ResultVOUtils.error(500, "查询条件不能为空!");
}
String totalStr = (String) redisUtil.get(keyCache);
long total = 0;
if (StrUtil.isEmpty(totalStr)) {
total = productInfoService.filterUdiNoPageCount(productInfoFilterRequest);
redisUtil.set(keyCache, total + "");
} else {
total = Long.parseLong(totalStr);
}
List<ProductInfoEntity> productInfoEntityList = productInfoService.filterUdiNoPage(productInfoFilterRequest);
PageSimpleResponse<ProductInfoEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(total);
pageSimpleResponse.setList(productInfoEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
public BaseResponse getDrugs(ProductInfoFilterRequest productInfoFilterRequest) {
//过滤--1.参数不能全未空
if ((productInfoFilterRequest.getYlqxzcrbarmc() == null || productInfoFilterRequest.getYlqxzcrbarmc().equals("")) &&
(productInfoFilterRequest.getCpmctymc() == null || productInfoFilterRequest.getCpmctymc().equals("")) &&
(productInfoFilterRequest.getNameCode() == null || productInfoFilterRequest.getNameCode().equals("")) &&
(productInfoFilterRequest.getGgxh() == null || productInfoFilterRequest.getGgxh().equals("")) &&
(productInfoFilterRequest.getUuid() == null || productInfoFilterRequest.getUuid().equals("")) &&
(productInfoFilterRequest.getZczbhhzbapzbh() == null || productInfoFilterRequest.getZczbhhzbapzbh().equals("")) &&
(productInfoFilterRequest.getDeviceRecordKey() == null || productInfoFilterRequest.getDeviceRecordKey().equals(""))
) {
return ResultVOUtils.error(500, "查询条件不能为空!");
}
if (StrUtil.isEmpty(productInfoFilterRequest.getYlqxzcrbarmc()) &&
StrUtil.isEmpty(productInfoFilterRequest.getCpmctymc())
&& StrUtil.isEmpty(productInfoFilterRequest.getNameCode())
&& StrUtil.isEmpty(productInfoFilterRequest.getGgxh())
&& StrUtil.isEmpty(productInfoFilterRequest.getUuid())
&& StrUtil.isEmpty(productInfoFilterRequest.getZczbhhzbapzbh())) {
if (productInfoFilterRequest.getNameCode() != null && !productInfoFilterRequest.getNameCode().equals("") && productInfoFilterRequest.getNameCode().length() < 10) {
return ResultVOUtils.error(500, "请输入完整的最小销售单元标识!");
}
}
if (productInfoFilterRequest.getCpmctymc() != null && !productInfoFilterRequest.getCpmctymc().equals("") && productInfoFilterRequest.getCpmctymc().length() < 4) {
return ResultVOUtils.error(500, "请输入完整的产品通用名称!");
}
productInfoFilterRequest.setIsNewest(1);
String keyCache = productInfoFilterRequest.toCacheKey();
if (StrUtil.isEmpty(keyCache)) {
return ResultVOUtils.error(500, "查询条件不能为空!");
}
String totalStr = (String) redisUtil.get(keyCache);
long total = 0;
if (StrUtil.isEmpty(totalStr)) {
total = productInfoService.filterUdiNoPageCount(productInfoFilterRequest);
redisUtil.set(keyCache, total + "");
} else {
total = Long.parseLong(totalStr);
}
List<ProductInfoEntity> productInfoEntityList = productInfoService.filterUdiNoPage(productInfoFilterRequest);
PageSimpleResponse<ProductInfoEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(total);
pageSimpleResponse.setList(productInfoEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
public BaseResponse filterCompany(@Valid UdiCompanyRequest udiCompanyRequest) {
List<UdiCompanyEntity> udiCompanyEntities = udiCompanyService.filterUdiCompany(udiCompanyRequest);
return ResultVOUtils.success(udiCompanyEntities);
}
}