|
@@ -2,22 +2,14 @@ package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.constant.SceneResolution;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
-import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
-import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.SceneUpgradeProgressBean;
|
|
|
import com.fdkankan.scene.entity.ScenePlus;
|
|
|
-import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
-import com.fdkankan.scene.entity.ScenePro;
|
|
|
-import com.fdkankan.scene.entity.SceneRepairLog;
|
|
|
import com.fdkankan.scene.mapper.ISceneUpgradeMapper;
|
|
|
import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
@@ -25,9 +17,6 @@ import com.fdkankan.scene.service.ISceneProService;
|
|
|
import com.fdkankan.scene.service.ISceneRepairLogService;
|
|
|
import com.fdkankan.scene.service.ISceneUpgradeToV4Service;
|
|
|
import com.fdkankan.scene.vo.SceneInfoVO;
|
|
|
-import com.fdkankan.scene.vo.UpgradeToV4ParamVO;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -46,8 +35,8 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
|
|
|
- @Value("${queue.scene.upgrade-to-v4}")
|
|
|
- private String upgradeToV4;
|
|
|
+// @Value("${queue.scene.upgrade-to-v4}")
|
|
|
+// private String upgradeToV4;
|
|
|
@Value("${oss.bucket:4dkankan}")
|
|
|
private String bucket;
|
|
|
|
|
@@ -57,8 +46,8 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
private RedisLockUtil redisLockUtil;
|
|
|
@Autowired
|
|
|
private ISceneRepairLogService sceneRepairLogService;
|
|
|
- @Autowired
|
|
|
- private RabbitMqProducer rabbitMqProducer;
|
|
|
+// @Autowired
|
|
|
+// private RabbitMqProducer rabbitMqProducer;
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
@Autowired
|
|
@@ -70,68 +59,68 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
|
|
|
@Autowired
|
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
|
|
|
- @Override
|
|
|
- public ResultData upgradeToV4(UpgradeToV4ParamVO param) {
|
|
|
-
|
|
|
- String num = param.getNum();
|
|
|
- ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
-
|
|
|
- //加锁
|
|
|
- String lockKey = String.format(RedisLockKey.LOCK_SCENE_UPGRADE_V4, num);
|
|
|
- boolean lock = redisLockUtil.lock(lockKey,RedisKey.EXPIRE_TIME_2_HOUR);
|
|
|
- if(!lock){
|
|
|
- return ResultData.error(ErrorCode.FAILURE_CODE_7019);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- //查询升级日志,如果已经升级成功,不允许重复升级
|
|
|
- SceneRepairLog sceneRepairLog = sceneRepairLogService.getOne(
|
|
|
- new LambdaQueryWrapper<SceneRepairLog>()
|
|
|
- .eq(SceneRepairLog::getNum, num));
|
|
|
- if(Objects.nonNull(sceneRepairLog)){
|
|
|
- if(sceneRepairLog.getState() == 0){
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
- return ResultData.error(ErrorCode.FAILURE_CODE_7019);
|
|
|
- }
|
|
|
- if(!param.isReUpgrade()){
|
|
|
- if(sceneRepairLog.getState() == 1){
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
- return ResultData.error(ErrorCode.FAILURE_CODE_7020);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //同步到scenePlus、scenePlus
|
|
|
- sceneUpgradeMapper.deleteScenePlus(scenePro.getId());
|
|
|
- sceneUpgradeMapper.transferScenePlus(scenePro.getId());
|
|
|
- sceneUpgradeMapper.deleteScenePlusExt(scenePro.getId());
|
|
|
- sceneUpgradeMapper.transferScenePlusExt(scenePro.getId());
|
|
|
-
|
|
|
- //国际版需要兼容切片图
|
|
|
- ScenePlus scenePlus = scenePlusService.getById(scenePro.getId());
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(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<>();
|
|
|
- progress.put("status", 0);
|
|
|
- progress.put("progress", 0);
|
|
|
- redisUtil.set(RedisKey.scene_upgrade_progress_num, JSON.toJSONString(progress));
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.error("场景升级失败", e);
|
|
|
- return ResultData.error(ErrorCode.FAILURE_CODE_7021);
|
|
|
- }
|
|
|
-
|
|
|
- return ResultData.ok();
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public ResultData upgradeToV4(UpgradeToV4ParamVO param) {
|
|
|
+//
|
|
|
+// String num = param.getNum();
|
|
|
+// ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
+//
|
|
|
+// //加锁
|
|
|
+// String lockKey = String.format(RedisLockKey.LOCK_SCENE_UPGRADE_V4, num);
|
|
|
+// boolean lock = redisLockUtil.lock(lockKey,RedisKey.EXPIRE_TIME_2_HOUR);
|
|
|
+// if(!lock){
|
|
|
+// return ResultData.error(ErrorCode.FAILURE_CODE_7019);
|
|
|
+// }
|
|
|
+//
|
|
|
+// try {
|
|
|
+// //查询升级日志,如果已经升级成功,不允许重复升级
|
|
|
+// SceneRepairLog sceneRepairLog = sceneRepairLogService.getOne(
|
|
|
+// new LambdaQueryWrapper<SceneRepairLog>()
|
|
|
+// .eq(SceneRepairLog::getNum, num));
|
|
|
+// if(Objects.nonNull(sceneRepairLog)){
|
|
|
+// if(sceneRepairLog.getState() == 0){
|
|
|
+// redisLockUtil.unlockLua(lockKey);
|
|
|
+// return ResultData.error(ErrorCode.FAILURE_CODE_7019);
|
|
|
+// }
|
|
|
+// if(!param.isReUpgrade()){
|
|
|
+// if(sceneRepairLog.getState() == 1){
|
|
|
+// redisLockUtil.unlockLua(lockKey);
|
|
|
+// return ResultData.error(ErrorCode.FAILURE_CODE_7020);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //同步到scenePlus、scenePlus
|
|
|
+// sceneUpgradeMapper.deleteScenePlus(scenePro.getId());
|
|
|
+// sceneUpgradeMapper.transferScenePlus(scenePro.getId());
|
|
|
+// sceneUpgradeMapper.deleteScenePlusExt(scenePro.getId());
|
|
|
+// sceneUpgradeMapper.transferScenePlusExt(scenePro.getId());
|
|
|
+//
|
|
|
+// //国际版需要兼容切片图
|
|
|
+// ScenePlus scenePlus = scenePlusService.getById(scenePro.getId());
|
|
|
+// ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(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<>();
|
|
|
+// progress.put("status", 0);
|
|
|
+// progress.put("progress", 0);
|
|
|
+// redisUtil.set(RedisKey.scene_upgrade_progress_num, JSON.toJSONString(progress));
|
|
|
+//
|
|
|
+// }catch (Exception e){
|
|
|
+// log.error("场景升级失败", e);
|
|
|
+// return ResultData.error(ErrorCode.FAILURE_CODE_7021);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return ResultData.ok();
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public ResultData getUpgradeToV4Progress(String num) {
|