|
@@ -0,0 +1,120 @@
|
|
|
+package com.fdkankan.contro.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneConstant;
|
|
|
+import com.fdkankan.common.constant.SceneKind;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.contro.entity.ScenePlus;
|
|
|
+import com.fdkankan.contro.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.contro.entity.ScenePro;
|
|
|
+import com.fdkankan.contro.mapper.ISceneUpgradeMapper;
|
|
|
+import com.fdkankan.contro.service.*;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class GenerateObjFileServiceImpl implements IGenerateObjFileService {
|
|
|
+
|
|
|
+ @Value("${queue.modeling.obj.modeling-pre}")
|
|
|
+ private String queueObjModelingPre;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Resource
|
|
|
+ private RabbitMqProducer mqProducer;
|
|
|
+ @Autowired
|
|
|
+ private ISceneUpgradeMapper sceneUpgradeMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void generateObjFile(String num) {
|
|
|
+ ScenePro sceneProEntity = sceneProService.getByNum(num);
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(sceneProEntity) || sceneProEntity.getIsUpgrade() == CommonStatus.YES.code().intValue()){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取最新的场景名称
|
|
|
+ //同步到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);
|
|
|
+
|
|
|
+
|
|
|
+ // 发送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.code(), "只能操作激光场景");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<ScenePlusExt> plusExtUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ plusExtUpdateWrapper
|
|
|
+ .set(ScenePlusExt::getIsObj, 1)
|
|
|
+ .eq(ScenePlusExt::getPlusId, scenePlus.getId());
|
|
|
+ scenePlusExtService.update(plusExtUpdateWrapper);
|
|
|
+
|
|
|
+ // 发送MQ
|
|
|
+ BuildSceneCallMessage mqMsg = new BuildSceneCallMessage();
|
|
|
+ mqMsg.setSceneNum(num);
|
|
|
+ mqMsg.setAlgorithm(scenePlusExt.getAlgorithm());
|
|
|
+ mqMsg.setBuildType(scenePlusExt.getBuildType());
|
|
|
+ mqMsg.setPath(scenePlusExt.getDataSource());
|
|
|
+ mqProducer.sendByWorkQueue(queueObjModelingPre,mqMsg);
|
|
|
+ }
|
|
|
+}
|