Browse Source

Merge remote-tracking branch 'origin/dev' into dev

training
caoyizhong 1 year ago
parent
commit
b01040e307
  1. 8
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryAuthServiceImpl.java
  2. 1
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryCommonServiceImpl.java
  3. 26
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/FactoryTokenServiceImpl.java
  4. 16
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java

8
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;
}

1
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)){

26
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<FactoryTokenMapper,
private static final Logger logger = LoggerFactory.getLogger(FactoryTokenServiceImpl.class);
private final BladeRedis bladeRedis;
@Override
public boolean verifyToken(String token, String corpId) throws NoSuchAlgorithmException {
logger.info("#########verifyToken: 验证token开始");
@ -27,14 +30,27 @@ public class FactoryTokenServiceImpl extends BaseServiceImpl<FactoryTokenMapper,
// String tokenAbst = MD5Utils.md5Hex(token.getBytes(StandardCharsets.UTF_8));
//编写查询条件
QueryWrapper<FactoryToken> 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<FactoryToken> 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();
//判断是否过期

16
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();
}

Loading…
Cancel
Save