Browse Source

解决多实例bug问题

dev_shibei_match
jianjun 4 years ago
parent
commit
f244d64d78
  1. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

10
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -40,6 +40,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.IpUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.IcResiUserDTO;
@ -355,9 +356,10 @@ public class IcResiUserController {
String fileType = ".xlsx";
String fileName = customerId + fileType;
File file = new File(IC_RESI_DOWNLOAD_DIR.resolve(fileName).toString());
String isChanged = redisUtils.getString(RedisKeys.getResiTempChangedKey(customerId));
//如果 本地文件不存在 或者已经变动 则重新下载
if (!file.exists() || NumConstant.ONE_STR.equals(isChanged)) {
String serverIp = IpUtils.getServerIp();
Object isChanged = redisUtils.hGet(RedisKeys.getResiTempChangedKey(customerId), serverIp);
//如果 redis 不存在这个机器的key 或者值为1 则重新下载
if (isChanged == null || NumConstant.ONE_STR.equals(isChanged.toString())) {
if (file.exists()) {
file.delete();
}
@ -375,7 +377,7 @@ public class IcResiUserController {
log.warn("getExportTemplateFile reload file form oss default file to template,customerId:{}",customerId);
FileUtils.writeByteArrayToFile(file,result.getData());
}
redisUtils.setString(RedisKeys.getResiTempChangedKey(customerId), NumConstant.ZERO_STR);
redisUtils.hSet(RedisKeys.getResiTempChangedKey(customerId), serverIp, NumConstant.ZERO_STR);
return file;
}
return file;

Loading…
Cancel
Save