From 44b0556018a547c254016a235b259d68b5acdbdd Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Tue, 23 Aug 2022 16:37:50 +0800 Subject: [PATCH] =?UTF-8?q?UDI=E6=9C=AC=E4=BD=93=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=94=99=E8=AF=AF=EF=BC=8C=E4=B8=8B=E7=BA=A7?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=A0=87=E8=AF=86=E8=BD=AC=E6=8D=A2=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=A0=87=E8=AF=86=EF=BC=8CPC=E7=AB=AF=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=AB=AF=E4=B8=8B=E8=BD=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/ProductInfoController.java | 45 +++++++-- .../admin/dao/udi/ProductInfoMapper.java | 4 + .../admin/req/ProductInfoFilterRequest.java | 5 + .../service/inout/ProductInfoService.java | 5 + .../inout/impl/ProductInfoServiceImpl.java | 32 ++++++ .../udidl/admin/thread/UdiTransferUtils.java | 4 +- .../com/glxp/udidl/admin/util/RedisUtil.java | 15 +++ src/main/resources/application.yml | 2 +- .../mybatis/mapper/udi/ProductInfoMapper.xml | 98 ++++++++++++++++++- 9 files changed, 198 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java b/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java index c256b8b..a405b0d 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java @@ -17,6 +17,7 @@ import com.glxp.udidl.admin.service.inout.ProductInfoService; import com.glxp.udidl.admin.service.udi.UdiCompanyService; import com.glxp.udidl.admin.util.BeanUtils; import com.glxp.udidl.admin.util.FilterUdiUtils; +import com.glxp.udidl.admin.util.RedisUtil; import com.glxp.udidl.admin.util.ResultVOUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -39,12 +40,15 @@ public class ProductInfoController { ProductInfoService productInfoService; @Resource UdiCompanyService udiCompanyService; + @Resource + RedisUtil redisUtil; //手持枪扫码查询 @ApiOperation(value = "手持枪扫码查询", response = ProductInfoEntity.class) @AuthRuleAnnotation("udidl/device/findBydi") @ApiImplicitParams({@ApiImplicitParam(name = "nameCode", value = "UDI码", required = true)}) @GetMapping("udidl/device/findBydi") + public BaseResponse findProductInfo(String nameCode) { ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest(); String key = nameCode; @@ -200,6 +204,8 @@ public class ProductInfoController { @AuthRuleAnnotation("udidl/device/filterAllUdi") @GetMapping("udidl/device/filterAllUdi") public BaseResponse filterAllUdi(ProductInfoFilterRequest productInfoFilterRequest) { + + //过滤--1.参数不能全未空 if ((productInfoFilterRequest.getYlqxzcrbarmc() == null || productInfoFilterRequest.getYlqxzcrbarmc().equals("")) && (productInfoFilterRequest.getCpmctymc() == null || productInfoFilterRequest.getCpmctymc().equals("")) && @@ -238,11 +244,23 @@ public class ProductInfoController { return ResultVOUtils.error(500, "请输入完整的产品通用名称!"); } productInfoFilterRequest.setIsNewest(1); - List productInfoEntityList = productInfoService.filterUdi(productInfoFilterRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(productInfoEntityList); + + 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 productInfoEntityList = productInfoService.filterUdiNoPage(productInfoFilterRequest); PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setTotal(total); pageSimpleResponse.setList(productInfoEntityList); return ResultVOUtils.success(pageSimpleResponse); } @@ -287,11 +305,22 @@ public class ProductInfoController { return ResultVOUtils.error(500, "请输入完整的产品通用名称!"); } productInfoFilterRequest.setIsNewest(1); - List productInfoEntityList = productInfoService.filterUdi(productInfoFilterRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(productInfoEntityList); + + 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 productInfoEntityList = productInfoService.filterUdiNoPage(productInfoFilterRequest); PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setTotal(total); pageSimpleResponse.setList(productInfoEntityList); return ResultVOUtils.success(pageSimpleResponse); } diff --git a/src/main/java/com/glxp/udidl/admin/dao/udi/ProductInfoMapper.java b/src/main/java/com/glxp/udidl/admin/dao/udi/ProductInfoMapper.java index c5db4b0..dce3bf8 100644 --- a/src/main/java/com/glxp/udidl/admin/dao/udi/ProductInfoMapper.java +++ b/src/main/java/com/glxp/udidl/admin/dao/udi/ProductInfoMapper.java @@ -39,6 +39,10 @@ public interface ProductInfoMapper extends BaseMapper { List filterUdi(ProductInfoFilterRequest productInfoFilterRequest); + List filterUdiNoPage(ProductInfoFilterRequest productInfoFilterRequest); + + Long filterUdiNoPageCount(ProductInfoFilterRequest productInfoFilterRequest); + List syncDlUdi(ProductInfoFilterRequest productInfoFilterRequest); List filterUuidByCreditNo(ProductInfoFilterRequest productInfoFilterRequest); diff --git a/src/main/java/com/glxp/udidl/admin/req/ProductInfoFilterRequest.java b/src/main/java/com/glxp/udidl/admin/req/ProductInfoFilterRequest.java index 47c2aff..1bf693d 100644 --- a/src/main/java/com/glxp/udidl/admin/req/ProductInfoFilterRequest.java +++ b/src/main/java/com/glxp/udidl/admin/req/ProductInfoFilterRequest.java @@ -43,4 +43,9 @@ public class ProductInfoFilterRequest extends ListPageRequest { @ApiModelProperty(value = "更新时间") private String updateTime; + + + public String toCacheKey() { + return nameCode + deviceRecordKey + uuid + cpmctymc + ylqxzcrbarmc + ggxh + tyshxydm + showHis + diType + zczbhhzbapzbh + updateTime; + } } diff --git a/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java b/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java index 997d694..bb06627 100644 --- a/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java +++ b/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java @@ -24,6 +24,11 @@ public interface ProductInfoService { List filterUdi(ProductInfoFilterRequest productInfoFilterRequest); + + List filterUdiNoPage(ProductInfoFilterRequest productInfoFilterRequest); + + Long filterUdiNoPageCount(ProductInfoFilterRequest productInfoFilterRequest); + List selectByUuid(String uuid); List syncDlUdi(ProductInfoFilterRequest productInfoFilterRequest); diff --git a/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java b/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java index 83224f3..307785d 100644 --- a/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java +++ b/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java @@ -6,6 +6,7 @@ import com.glxp.udidl.admin.dao.udi.ProductInfoMapper; import com.glxp.udidl.admin.entity.udi.ProductInfoEntity; import com.glxp.udidl.admin.req.ProductInfoFilterRequest; import com.glxp.udidl.admin.service.inout.ProductInfoService; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -100,6 +101,37 @@ public class ProductInfoServiceImpl implements ProductInfoService { return data; } + @Override + public List filterUdiNoPage(ProductInfoFilterRequest productInfoFilterRequest) { + if (productInfoFilterRequest == null) { + return Collections.emptyList(); + } + if (productInfoFilterRequest.getPage() != null) { + int offset = (productInfoFilterRequest.getPage() - 1) * productInfoFilterRequest.getLimit(); + productInfoFilterRequest.setPage(offset); + productInfoFilterRequest.setLimit(productInfoFilterRequest.getLimit()); + } + + List data = productInfoDao.filterUdiNoPage(productInfoFilterRequest); + return data; + } + + @Override + public Long filterUdiNoPageCount(ProductInfoFilterRequest request) { + + + ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest(); + BeanUtils.copyProperties(request, productInfoFilterRequest); + + if (productInfoFilterRequest.getPage() != null) { + int offset = (productInfoFilterRequest.getPage() - 1) * productInfoFilterRequest.getLimit(); + productInfoFilterRequest.setPage(offset); + productInfoFilterRequest.setLimit(productInfoFilterRequest.getLimit()); + + } + return productInfoDao.filterUdiNoPageCount(productInfoFilterRequest); + } + @Override public List selectByUuid(String uuid) { List data = productInfoDao.selectByUuid(uuid); diff --git a/src/main/java/com/glxp/udidl/admin/thread/UdiTransferUtils.java b/src/main/java/com/glxp/udidl/admin/thread/UdiTransferUtils.java index 4e24721..e754119 100644 --- a/src/main/java/com/glxp/udidl/admin/thread/UdiTransferUtils.java +++ b/src/main/java/com/glxp/udidl/admin/thread/UdiTransferUtils.java @@ -128,10 +128,10 @@ public class UdiTransferUtils { productInfoEntity.setZxxsbzbhsydysl(0); productInfoEntity.setDiType(3); productInfoEntity.setSjcpbm(deviceEntity.getZxxsdycpbs()); - productInfoEntity.setNameCode(deviceEntity.getSydycpbs()); + productInfoEntity.setNameCode(deviceEntity.getBtcpbs()); productInfoEntity.setUpdateTime(new Date()); productInfoService.insertProductInfo(productInfoEntity); - productInfoEntity.setBhxjcpbm(deviceEntity.getSydycpbs()); + productInfoEntity.setBhxjcpbm(deviceEntity.getBtcpbs()); productInfoEntity.setBhxjsl(1); productInfoEntity.setPackLevel(2 + ""); productInfoEntity.setZxxsbzbhsydysl(1); diff --git a/src/main/java/com/glxp/udidl/admin/util/RedisUtil.java b/src/main/java/com/glxp/udidl/admin/util/RedisUtil.java index fc3d70f..58a60cd 100644 --- a/src/main/java/com/glxp/udidl/admin/util/RedisUtil.java +++ b/src/main/java/com/glxp/udidl/admin/util/RedisUtil.java @@ -1,10 +1,13 @@ package com.glxp.udidl.admin.util; +import cn.hutool.core.collection.CollUtil; import cn.hutool.db.nosql.redis.RedisDS; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import redis.clients.jedis.Jedis; +import java.util.Set; + /** * redis工具类 */ @@ -46,4 +49,16 @@ public class RedisUtil { return true; } + + //模糊匹配删除 + public void deleteByPrex(String prex) { + Set keys = jedis.keys(prex); + if (CollUtil.isNotEmpty(keys)) { + for (String str : keys) { + jedis.del(str); + } + } + } + + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 122d21b..44d07c6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,7 +2,7 @@ server: port: 9994 spring: profiles: - active: dev + active: pro jmx: enabled: false diff --git a/src/main/resources/mybatis/mapper/udi/ProductInfoMapper.xml b/src/main/resources/mybatis/mapper/udi/ProductInfoMapper.xml index 44f15fc..efa4700 100644 --- a/src/main/resources/mybatis/mapper/udi/ProductInfoMapper.xml +++ b/src/main/resources/mybatis/mapper/udi/ProductInfoMapper.xml @@ -230,6 +230,101 @@ + + + + + +