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/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/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(); //判断是否过期 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(); }