|
@@ -1,18 +1,33 @@
|
|
|
package com.fdkankan.contro.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.common.constant.CommonStatus;
|
|
|
-import com.fdkankan.common.constant.PayStatus;
|
|
|
-import com.fdkankan.common.constant.SceneStatus;
|
|
|
-import com.fdkankan.common.constant.SpaceType;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.contro.common.Result;
|
|
|
+import com.fdkankan.contro.entity.ScenePlus;
|
|
|
+import com.fdkankan.contro.entity.ScenePlusExt;
|
|
|
import com.fdkankan.contro.entity.ScenePro;
|
|
|
+import com.fdkankan.contro.httpclient.LaserClient;
|
|
|
import com.fdkankan.contro.mapper.ISceneProMapper;
|
|
|
+import com.fdkankan.contro.mapper.ISceneUpgradeMapper;
|
|
|
+import com.fdkankan.contro.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.contro.service.IScenePlusService;
|
|
|
import com.fdkankan.contro.service.ISceneProService;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
@@ -28,6 +43,21 @@ import java.util.Objects;
|
|
|
@Service
|
|
|
public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
|
|
|
|
|
|
+ @Value("${queue.modeling.obj.modeling-pre}")
|
|
|
+ private String queueObjModelingPre;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Resource
|
|
|
+ private LaserClient laserClient;
|
|
|
+ @Autowired
|
|
|
+ private ISceneUpgradeMapper sceneUpgradeMapper;
|
|
|
+ @Resource
|
|
|
+ private RabbitMqProducer mqProducer;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+
|
|
|
@Override
|
|
|
public ScenePro getByNum(String num) {
|
|
|
return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
@@ -58,4 +88,119 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
return 0L;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void generateObjFile(String num) {
|
|
|
+ ScenePro sceneProEntity = this.getByNum(num);
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(sceneProEntity) && sceneProEntity.getIsUpgrade() == 1){
|
|
|
+ generatePlusObjFile(num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(sceneProEntity.getSceneSource() != 4 && sceneProEntity.getSceneSource() != 5){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3003, "只能操作激光场景");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拷贝文件
|
|
|
+ String path = sceneProEntity.getDataSource();
|
|
|
+ String ossPath = path.replace("/mnt/data","home")+"/data.fdage";
|
|
|
+ if(!fYunFileService.fileExist(ossPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3037);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取最新的场景名称
|
|
|
+ Result laserSceneByNum = laserClient.getSceneByNum(num);
|
|
|
+ if(laserSceneByNum.getCode() != HttpStatus.OK.value()){
|
|
|
+ throw new RuntimeException("获取激光转台场景失败!");
|
|
|
+ }
|
|
|
+ JSONObject sceneInfo = JSONObject.parseObject(JSONObject.toJSONString(laserSceneByNum.getData()));
|
|
|
+ LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper
|
|
|
+ .set(ScenePro::getStatus, 0)
|
|
|
+ .set(ScenePro::getIsObj, 1)
|
|
|
+ .set(ScenePro::getIsUpgrade, 2) // 升级中
|
|
|
+ .set(ScenePro::getSceneName, sceneInfo.getString("title"))
|
|
|
+ .eq(ScenePro::getNum, sceneProEntity.getNum());
|
|
|
+ this.update(updateWrapper);
|
|
|
+
|
|
|
+ //同步到scenePlus、scenePlus
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ if(Objects.nonNull(scenePlus)){
|
|
|
+ sceneUpgradeMapper.deleteScenePlus(num);
|
|
|
+ sceneUpgradeMapper.deleteScenePlusExt(scenePlus.getId());
|
|
|
+ }
|
|
|
+ sceneUpgradeMapper.transferScenePlus(num);
|
|
|
+ scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ String sceneKind = sceneProEntity.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
|
|
|
+ sceneUpgradeMapper.transferScenePlusExt(num, scenePlus.getId(), sceneKind);
|
|
|
+
|
|
|
+ log.info("开始发送激光场景生成obj mq消息");
|
|
|
+
|
|
|
+ // 发送MQ
|
|
|
+ BuildSceneCallMessage mqMsg = new BuildSceneCallMessage();
|
|
|
+ mqMsg.setSceneNum(sceneProEntity.getNum());
|
|
|
+ mqMsg.setAlgorithm(sceneProEntity.getAlgorithm());
|
|
|
+ mqMsg.setBuildType(sceneProEntity.getBuildType());
|
|
|
+ mqMsg.setPath(sceneProEntity.getDataSource());
|
|
|
+ mqProducer.sendByWorkQueue(queueObjModelingPre,mqMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void generatePlusObjFile(String num) {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(scenePlus)){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(scenePlus.getSceneSource() != 4 && scenePlus.getSceneSource() !=5){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3003, "只能操作激光场景");
|
|
|
+ }
|
|
|
+
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+
|
|
|
+ String ossPath = scenePlusExt.getDataSource().replace("/mnt/data","home")+"/data.fdage";
|
|
|
+ if(!fYunFileService.fileExist(ossPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3037);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取最新的场景名称
|
|
|
+ Result laserSceneByNum = laserClient.getSceneByNum(num);
|
|
|
+ if(laserSceneByNum.getCode() != HttpStatus.OK.value()){
|
|
|
+ throw new RuntimeException("获取激光转台场景失败!");
|
|
|
+ }
|
|
|
+ JSONObject sceneInfo = JSONObject.parseObject(JSONObject.toJSONString(laserSceneByNum.getData()));
|
|
|
+ LambdaUpdateWrapper<ScenePlus> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper
|
|
|
+ .set(ScenePlus::getSceneStatus, 0)
|
|
|
+ .set(ScenePlus::getTitle, sceneInfo.getString("title"))
|
|
|
+ .eq(ScenePlus::getNum, num);
|
|
|
+ scenePlusService.update(updateWrapper);
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<ScenePlusExt> plusExtUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ plusExtUpdateWrapper
|
|
|
+ .set(ScenePlusExt::getIsObj, 1)
|
|
|
+ .eq(ScenePlusExt::getPlusId, scenePlus.getId());
|
|
|
+ scenePlusExtService.update(plusExtUpdateWrapper);
|
|
|
+
|
|
|
+ log.info("开始发送激光场景生成obj mq消息");
|
|
|
+
|
|
|
+ // 发送MQ
|
|
|
+ BuildSceneCallMessage mqMsg = new BuildSceneCallMessage();
|
|
|
+ mqMsg.setSceneNum(num);
|
|
|
+ mqMsg.setAlgorithm(scenePlusExt.getAlgorithm());
|
|
|
+ mqMsg.setBuildType(scenePlusExt.getBuildType());
|
|
|
+ mqMsg.setPath(scenePlusExt.getDataSource());
|
|
|
+ mqProducer.sendByWorkQueue(queueObjModelingPre,mqMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public JSONObject getSceneByNum(String num) {
|
|
|
+ Result result = laserClient.getSceneByNum(num);
|
|
|
+ if(result.getCode() != HttpStatus.OK.value()){
|
|
|
+ log.error("获取激光转台场景失败!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return JSONObject.parseObject(JSONObject.toJSONString(result.getData()));
|
|
|
+ }
|
|
|
}
|