From 038cc239a4853bfb93249ff235bf516a93308fef Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" <123456> Date: Tue, 24 Oct 2023 17:32:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=AF=B9=E6=A2=A6=E5=A4=A9=E7=9A=84token?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=BF=9B=E8=A1=8C=E4=BC=98=E5=8C=96=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FactoryAuthServiceImpl.java | 8 ++++++ .../service/impl/FactoryTokenServiceImpl.java | 26 +++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryAuthServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryAuthServiceImpl.java index 48e03a48d..9d5d9af7a 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryAuthServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryAuthServiceImpl.java @@ -13,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.TokenUtil; +import org.springblade.core.redis.cache.BladeRedis; import org.springframework.stereotype.Service; import java.nio.charset.StandardCharsets; @@ -31,6 +32,8 @@ public class FactoryAuthServiceImpl implements IFactoryAuthService { private final IFactoryAccountService factoryAccountService; private final IFactoryTokenService factoryTokenService; + private final BladeRedis bladeRedis; + @Override public FactoryTokenVO getToken(String corpId, String appKey, String appSecret) throws NoSuchAlgorithmException { @@ -71,6 +74,11 @@ public class FactoryAuthServiceImpl implements IFactoryAuthService { factoryTokenVO.setToken(token); factoryTokenVO.setExpireTime(date); factoryTokenVO.setExpireTimeLong(date.getTime()); + + + // 增加redis缓存 疑似梦天请求太快 无法出现数据 + bladeRedis.setEx("corpId:"+corpId, factoryToken, 60*60*24*30L); + return factoryTokenVO; } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryTokenServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryTokenServiceImpl.java index 672b9984e..714e3c73a 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryTokenServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryTokenServiceImpl.java @@ -8,6 +8,7 @@ import lombok.AllArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.redis.cache.BladeRedis; import org.springframework.stereotype.Service; import java.security.NoSuchAlgorithmException; @@ -20,6 +21,8 @@ public class FactoryTokenServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("token",token) - .eq("corpid",corpId); - FactoryToken factoryToken = baseMapper.selectOne(queryWrapper); + String key ="corpId:"+corpId; + FactoryToken factoryToken = bladeRedis.get(key); + + if(Objects.isNull(factoryToken)){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("token",token); + factoryToken = baseMapper.selectOne(queryWrapper); + } + + if(Objects.isNull(factoryToken)){ - logger.error("#########verifyToken: token验证不通过 token={},corpid={}",token,corpId); + logger.error("#########verifyToken: token1验证不通过 token={},corpid={}",token,corpId); + return false; + } + logger.info("#########verifyToken: 验证token 传入token {} 验证token {}",token,factoryToken.getToken()); + if(!factoryToken.getToken().equals(token)){ + logger.error("#########verifyToken: toke2n验证不通过 token={},corpid={}",token,corpId); return false; } + + Long expireTimeLong = factoryToken.getExpireTime().getTime(); Long now = new Date().getTime(); //判断是否过期 From 108a0abec81baa5ee5577375e22f5a0062b98606 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 24 Oct 2023 17:43:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.=E8=80=81=E7=B3=BB=E7=BB=9F=E5=8D=B8?= =?UTF-8?q?=E5=88=86=E4=B8=80=E4=BD=93=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FactoryCommonServiceImpl.java | 1 + .../factory/receiver/DealWithDataHandler.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java index 42554dad7..28ba1b8e6 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java @@ -34,6 +34,7 @@ public class FactoryCommonServiceImpl implements IFactoryCommonService { @Override public void syncTrayTypeData(String unitNo, Integer trayId, String oldWarehouseId) { + log.info("###############syncTrayTypeData: 包件打托开始 unitNo={} trayId={} oldWarehouseId={}",unitNo,trayId,oldWarehouseId); //先判断新系统仓库信息是否存在 BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getWarehouseByOldId(Integer.parseInt(oldWarehouseId)); if(Objects.isNull(warehouseEntity)){ diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java index a27e7e498..b6ad1446c 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java @@ -17,7 +17,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.util.Map; -import java.util.Objects; /** @@ -48,7 +47,7 @@ public class DealWithDataHandler { String unitNo = orderStatusDTO.getUnitNo(); String operationTime = orderStatusDTO.getOperationTime(); Integer trayId = orderStatusDTO.getTrayId(); - if ("4".equals(status)) { + if ("4".equals(status) || "2".equals(status)) { //继续判断是否到达目的仓 String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id //查询destinationWarehouse logiBillNo plantId数据 @@ -68,11 +67,16 @@ public class DealWithDataHandler { } else { //真正的处理需要的数据 try { - panFactoryDataService.handleDataToPlatform(unitNo, operationTime); - //同步打托数据 - if(!Objects.isNull(trayId)){ - factoryCommonService.syncTrayTypeData(unitNo,trayId,currentWarehouseId); + if ("4".equals(status)) { + panFactoryDataService.handleDataToPlatform(unitNo, operationTime); + }else if("2".equals(status)){ +// //同步打托数据 +// if(!Objects.isNull(trayId)){ +// factoryCommonService.syncTrayTypeData(unitNo,trayId,currentWarehouseId); +// } } + + } catch (Exception e) { e.printStackTrace(); }