|
@@ -1,5 +1,6 @@
|
|
package com.fdkankan.ucenter.service.impl;
|
|
package com.fdkankan.ucenter.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.exceptions.ExceptionUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -30,6 +31,7 @@ import com.fdkankan.ucenter.service.ISceneProEditService;
|
|
import com.fdkankan.ucenter.service.ISceneProService;
|
|
import com.fdkankan.ucenter.service.ISceneProService;
|
|
import com.fdkankan.ucenter.service.ISceneRepairLogService;
|
|
import com.fdkankan.ucenter.service.ISceneRepairLogService;
|
|
import com.fdkankan.ucenter.service.ISceneUpgradeToV4Service;
|
|
import com.fdkankan.ucenter.service.ISceneUpgradeToV4Service;
|
|
|
|
+import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -84,24 +86,23 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7019.code(), ErrorCode.FAILURE_CODE_7019.message());
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7019.code(), ErrorCode.FAILURE_CODE_7019.message());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ SceneRepairLog sceneRepairLog = null;
|
|
try {
|
|
try {
|
|
//查询升级日志,如果已经升级成功,不允许重复升级
|
|
//查询升级日志,如果已经升级成功,不允许重复升级
|
|
- SceneRepairLog sceneRepairLog = sceneRepairLogService.getOne(
|
|
|
|
|
|
+ sceneRepairLog = sceneRepairLogService.getOne(
|
|
new LambdaQueryWrapper<SceneRepairLog>()
|
|
new LambdaQueryWrapper<SceneRepairLog>()
|
|
- .eq(SceneRepairLog::getNum, num));
|
|
|
|
|
|
+ .eq(SceneRepairLog::getNum, num)
|
|
|
|
+ .orderByDesc(SceneRepairLog::getId)
|
|
|
|
+ .last("limit 1"));
|
|
if(Objects.nonNull(sceneRepairLog)){
|
|
if(Objects.nonNull(sceneRepairLog)){
|
|
if(sceneRepairLog.getState() == 0){
|
|
if(sceneRepairLog.getState() == 0){
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7019.code(), ErrorCode.FAILURE_CODE_7019.message());
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7019.code(), ErrorCode.FAILURE_CODE_7019.message());
|
|
}
|
|
}
|
|
-// if(!param.isReUpgrade()){
|
|
|
|
-// if(sceneRepairLog.getState() == 1){
|
|
|
|
-// redisLockUtil.unlockLua(lockKey);
|
|
|
|
-// return ResultData.error(ErrorCode.FAILURE_CODE_7020);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //写入升级日志
|
|
|
|
+ this.upgradeLog(null, num, 0, null);
|
|
|
|
+
|
|
//同步到scenePlus、scenePlus
|
|
//同步到scenePlus、scenePlus
|
|
sceneUpgradeMapper.deleteScenePlus(scenePro.getId());
|
|
sceneUpgradeMapper.deleteScenePlus(scenePro.getId());
|
|
sceneUpgradeMapper.transferScenePlus(scenePro.getId());
|
|
sceneUpgradeMapper.transferScenePlus(scenePro.getId());
|
|
@@ -109,25 +110,18 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
String sceneKind = scenePro.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
|
|
String sceneKind = scenePro.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
|
|
sceneUpgradeMapper.transferScenePlusExt(scenePro.getId(), sceneKind);
|
|
sceneUpgradeMapper.transferScenePlusExt(scenePro.getId(), sceneKind);
|
|
|
|
|
|
- //国际版需要兼容切片图
|
|
|
|
- ScenePlus scenePlus = scenePlusService.getById(scenePro.getId());
|
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
|
- if(scenePlusExt.getSceneScheme() == 3){
|
|
|
|
- scenePlusExt.setSceneResolution(SceneResolution.TILES.code());
|
|
|
|
- scenePlusExtService.updateById(scenePlusExt);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //发送mq
|
|
|
|
- rabbitMqProducer.sendByWorkQueue(upgradeToV4, scenePro.getId());
|
|
|
|
-
|
|
|
|
//写入进度条
|
|
//写入进度条
|
|
Map<String, Integer> progress = new HashMap<>();
|
|
Map<String, Integer> progress = new HashMap<>();
|
|
progress.put("status", 0);
|
|
progress.put("status", 0);
|
|
progress.put("progress", 0);
|
|
progress.put("progress", 0);
|
|
redisUtil.set(RedisKey.scene_upgrade_progress_num, JSON.toJSONString(progress));
|
|
redisUtil.set(RedisKey.scene_upgrade_progress_num, JSON.toJSONString(progress));
|
|
|
|
|
|
|
|
+ //发送mq
|
|
|
|
+ rabbitMqProducer.sendByWorkQueue(upgradeToV4, scenePro.getId());
|
|
|
|
+
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
log.error("场景升级失败", e);
|
|
log.error("场景升级失败", e);
|
|
|
|
+ this.upgradeLog(sceneRepairLog, num, 2, ExceptionUtil.stacktraceToString(e, 3000));
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7021.code(), ErrorCode.FAILURE_CODE_7021.message());
|
|
return Result.failure(ErrorCode.FAILURE_CODE_7021.code(), ErrorCode.FAILURE_CODE_7021.message());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -146,4 +140,16 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
}
|
|
}
|
|
return Result.success(progressBean);
|
|
return Result.success(progressBean);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void upgradeLog(SceneRepairLog sceneRepairLog, String num, int status, String reason){
|
|
|
|
+ //写入升级日志
|
|
|
|
+ if(Objects.isNull(sceneRepairLog)){
|
|
|
|
+ sceneRepairLog = new SceneRepairLog();
|
|
|
|
+ sceneRepairLog.setNum(num);
|
|
|
|
+ }
|
|
|
|
+ sceneRepairLog.setState(status);
|
|
|
|
+ sceneRepairLog.setReason(reason);
|
|
|
|
+ sceneRepairLog.setCreateTime(Calendar.getInstance().getTime());
|
|
|
|
+ sceneRepairLogService.saveOrUpdate(sceneRepairLog);
|
|
|
|
+ }
|
|
}
|
|
}
|