|
@@ -0,0 +1,662 @@
|
|
|
+package com.fdkankan.scene.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fdkankan.base.constant.CameraConstant;
|
|
|
+import com.fdkankan.base.constant.ErrorCode;
|
|
|
+import com.fdkankan.base.constant.SceneConstant;
|
|
|
+import com.fdkankan.base.mq.ModelingMsgProducer;
|
|
|
+import com.fdkankan.common.api.BaseController;
|
|
|
+import com.fdkankan.common.constant.Constant;
|
|
|
+import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.controller.BaseController;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.model.Result;
|
|
|
+import com.fdkankan.common.model.SSOUser;
|
|
|
+import com.fdkankan.common.response.ResultData;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.common.util.RubberSheetingUtil;
|
|
|
+import com.fdkankan.common.vo.request.RequestBuildScene;
|
|
|
+import com.fdkankan.common.vo.request.RequestScene;
|
|
|
+import com.fdkankan.common.vo.request.UserParamVO;
|
|
|
+import com.fdkankan.common.vo.response.ResponseScene;
|
|
|
+import com.fdkankan.goods.entity.CameraDetailEntity;
|
|
|
+import com.fdkankan.goods.entity.CameraEntity;
|
|
|
+import com.fdkankan.goods.feign.GoodsFeignClient;
|
|
|
+import com.fdkankan.scene.service.ISceneCooperationService;
|
|
|
+import com.fdkankan.scene.service.ISceneProEditService;
|
|
|
+import com.fdkankan.scene.service.ISceneProService;
|
|
|
+import com.fdkankan.scene.service.ISceneService;
|
|
|
+import com.fdkankan.scene.util.ComputerUtil;
|
|
|
+import com.fdkankan.scene.vo.SceneVO;
|
|
|
+import com.fdkankan.scene.vo.UserParamVO;
|
|
|
+import com.fdkankan.user.entity.UserEntity;
|
|
|
+import com.fdkankan.user.feign.UserFeignClient;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.github.pagehelper.util.StrUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang.StrUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by Hb_zzZ on 2019/6/10.
|
|
|
+ */
|
|
|
+@Log4j2
|
|
|
+@RestController
|
|
|
+@PostMapping("/api/app/scene")
|
|
|
+@Api(tags = "场景管理-app场景模块")
|
|
|
+public class SceneAppController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsFeignClient goodsService;
|
|
|
+ @Autowired
|
|
|
+ private ObjectMapper mapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneService sceneService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneProEditService sceneProEditService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserFeignClient userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScene3dNumNewService numService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneCooperationService sceneCooperationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ModelingMsgProducer producer;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RubberSheetingUtil rubberSheetingUtil;
|
|
|
+
|
|
|
+ @Value("${main.url}")
|
|
|
+ private String mainUrl;
|
|
|
+
|
|
|
+ @Value("${scene.url}")
|
|
|
+ private String sceneUrl;
|
|
|
+
|
|
|
+ @Value("${scene.pro.url}")
|
|
|
+ private String sceneProUrl;
|
|
|
+
|
|
|
+ @Value("${ecs.type}")
|
|
|
+ private String ecsType;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SceneNumService sceneNumService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ 获取相机的所有场景(分页)
|
|
|
+ * </p>
|
|
|
+ * @author dengsixing
|
|
|
+ * @date 2022/1/13
|
|
|
+ * @param param
|
|
|
+ * <p>appUserName: 相机设备码</p>
|
|
|
+ * <p>appPassword: 相机密码</p>
|
|
|
+ * <p>phoneNum: 用户手机号</p>
|
|
|
+ * <p>cameraType: 1表示双目,4表示8目</p>
|
|
|
+ * <p>orderBy: 排序,如(create_time desc)</p>
|
|
|
+ * <p>sceneType:0表示其他,1表示文博,2表示地产,3表示电商,4表示餐饮,5表示家居</p>
|
|
|
+ * <p>sceneName: 场景名称,模糊搜索</p>
|
|
|
+ * <p>pageNum: 页码</p>
|
|
|
+ * <p>pageSize: 页大小</p>
|
|
|
+ * @return com.fdkankan.common.response.ResultData<com.fdkankan.scene.vo.SceneVO>
|
|
|
+ *
|
|
|
+ **/
|
|
|
+ @PostMapping(value = "/getAppAllSceneByPage")
|
|
|
+ public ResultData<SceneVO> getAllSceneByPage(@RequestBody UserParamVO param) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(param.getAppUserName()) && StrUtil.isEmpty(param.getPhoneNum()) ){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ Long cameraId = null;
|
|
|
+ Long userId = null;
|
|
|
+ Integer cameraType = null;
|
|
|
+ //获取相机id
|
|
|
+ if(!StrUtil.isEmpty(param.getAppUserName()) && !StrUtil.isEmpty(param.getAppPassword())){
|
|
|
+ Result result = goodsService.findByChildNameAndChildPassword(param.getAppUserName(), param.getAppPassword());
|
|
|
+ if (result.getCode() == Result.CODE_FAILURE){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ CameraEntity cameraEntity = mapper.convertValue(result.getData(), CameraEntity.class);
|
|
|
+ if(cameraEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
+ }
|
|
|
+
|
|
|
+ cameraId = cameraEntity.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder nums = new StringBuilder();
|
|
|
+ //获取该用户id协作者的场景码集合
|
|
|
+ if (StrUtil.isNotEmpty(param.getPhoneNum())) {
|
|
|
+ paramEntity paramEntity = paramService.findparamByparamName(param.getPhoneNum());
|
|
|
+
|
|
|
+ if (paramEntity == null) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3015);
|
|
|
+ }
|
|
|
+ userId = paramEntity.getId();
|
|
|
+
|
|
|
+ Condition condition = new Condition(SceneCooperationEntity.class);
|
|
|
+ condition.and().andEqualTo("userId", userId);
|
|
|
+ condition.orderBy("id").desc();
|
|
|
+ List<SceneCooperationEntity> list = sceneCooperationService.findAll(condition);
|
|
|
+
|
|
|
+ if(list == null || list.size() > 0){
|
|
|
+ SceneCooperationEntity cooperationEntity = null;
|
|
|
+ for(int i = 0, len = list.size(); i < len; i++){
|
|
|
+ cooperationEntity = list.get(i);
|
|
|
+ if(i != len - 1){
|
|
|
+ nums.append("'").append(cooperationEntity.getSceneNum()).append("'").append(",");
|
|
|
+ }else {
|
|
|
+ nums.append("'").append(cooperationEntity.getSceneNum()).append("'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(param.getCameraType() != null){
|
|
|
+ cameraType = param.getCameraType();
|
|
|
+ }
|
|
|
+
|
|
|
+ CameraEntity camera = null;
|
|
|
+ CameraDetailEntity cameraDetailEntity = null;
|
|
|
+ PageInfo<ResponseScene> pageInfo = sceneProService.getAppAllSceneByPage(cameraId, userId, cameraType, param.getPageNum(), param.getPageSize(), param.getOrderBy(), param.getSceneType(), nums.toString(), param.getSceneName());
|
|
|
+ for(ResponseScene responseScene : pageInfo.getList()){
|
|
|
+ // 当计算时,返回给前端的状态为计算中
|
|
|
+ if (!ObjectUtils.isEmpty(responseScene)) {
|
|
|
+ if (responseScene.getStatus() == -1) {
|
|
|
+ responseScene.setStatus(0);
|
|
|
+ } else if (responseScene.getStatus() == 500) {
|
|
|
+ responseScene.setStatus(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //相机id为空是123看房的场景
|
|
|
+ if(responseScene.getCameraId() == null){
|
|
|
+ //当场景用户id等于该用户id,为用户场景,其余未协作场景
|
|
|
+ if(responseScene.getUserId().longValue() == userId.longValue()){
|
|
|
+ responseScene.setSceneSourceType(1);
|
|
|
+ }else {
|
|
|
+ responseScene.setSceneSourceType(2);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ camera = goodsService.findCameraById(responseScene.getCameraId());
|
|
|
+ if(camera != null){
|
|
|
+ responseScene.setChildName(camera.getChildName());
|
|
|
+ responseScene.setSnCode(camera.getSnCode());
|
|
|
+
|
|
|
+ cameraDetailEntity = goodsService.findCameraDetailByCameraId(camera.getId());
|
|
|
+ if(cameraDetailEntity != null){
|
|
|
+ //相机的userId为空,表示相机的场景
|
|
|
+ if(cameraDetailEntity.getUserId() == null || userId == null){
|
|
|
+ responseScene.setSceneSourceType(0);
|
|
|
+ }else if(userId != null && cameraDetailEntity.getUserId().longValue() == userId.longValue()){
|
|
|
+ //相机用户id等于该用户id,既为用户的场景
|
|
|
+ responseScene.setSceneSourceType(1);
|
|
|
+ }else if(cameraId != null && cameraDetailEntity.getCameraId() != null && cameraDetailEntity.getCameraId().longValue() == cameraId.longValue()
|
|
|
+ && cameraDetailEntity.getCooperationparam() == null){
|
|
|
+ //场景相机id等于该相机id
|
|
|
+ responseScene.setSceneSourceType(0);
|
|
|
+ }else if(cameraId != null && cameraDetailEntity.getCameraId().longValue() == cameraId.longValue()
|
|
|
+ && cameraDetailEntity.getCooperationparam() != null){
|
|
|
+ if(userId != null && cameraDetailEntity.getCooperationparam().longValue() == userId.longValue()){
|
|
|
+ responseScene.setSceneSourceType(2);
|
|
|
+ }else {
|
|
|
+ responseScene.setSceneSourceType(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //最后不等于则为协作者场景
|
|
|
+ responseScene.setSceneSourceType(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultData.ok(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取相机的所有场景
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("获取相机的所有场景")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "appUserName", value = "相机设备码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "appPassword", value = "相机密码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/getAllForCameraName")
|
|
|
+ public Result<ResponseScene> getAllForCameraName(@RequestBody UserParamVO user) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(user.getAppUserName()) || StrUtil.isEmpty(user.getAppPassword())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ Result result = goodsService.findByChildNameAndChildPassword(user.getAppUserName(), user.getAppPassword());
|
|
|
+ if (result.getCode() == Result.CODE_FAILURE){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ CameraEntity cameraEntity = mapper.convertValue(result.getData(), CameraEntity.class);
|
|
|
+ if(cameraEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderBy = " create_time desc ";
|
|
|
+ Condition condition = new Condition(SceneProEntity.class);
|
|
|
+ condition.and().andEqualTo("cameraId", cameraEntity.getId()).andNotEqualTo("sceneType", 99);
|
|
|
+ condition.and().andEqualTo("status", 1).orEqualTo("status", -2);
|
|
|
+ List<SceneProEntity> list = sceneProService.findAll(condition, orderBy);
|
|
|
+
|
|
|
+ List<ResponseScene> sceneList = sceneProService.convert(list);
|
|
|
+ for(ResponseScene responseScene : sceneList){
|
|
|
+ responseScene.setChildName(user.getAppUserName());
|
|
|
+ }
|
|
|
+ return Result.success(sceneList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取相机的场景数量
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("获取相机的场景数量")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "appUserName", value = "相机设备码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "appPassword", value = "相机密码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/getSceneCount")
|
|
|
+ public Result getSceneCount(@RequestBody UserParamVO user) throws Exception {
|
|
|
+
|
|
|
+ if(StrUtil.isEmpty(user.getAppUserName()) || StrUtil.isEmpty(user.getAppPassword())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ Result result = goodsService.findByChildNameAndChildPassword(user.getAppUserName(), user.getAppPassword());
|
|
|
+ if (result.getCode() == Result.CODE_FAILURE){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ CameraEntity cameraEntity = mapper.convertValue(result.getData(), CameraEntity.class);
|
|
|
+ if(cameraEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(sceneProService.getSceneCount(cameraEntity.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取场景的状态
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("获取场景的状态")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "appUserName", value = "相机设备码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "appPassword", value = "相机密码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneNum", value = "场景码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/getSceneStatus")
|
|
|
+ public Result getSceneStatus(@RequestBody UserParamVO user) throws Exception {
|
|
|
+
|
|
|
+ if(StrUtil.isEmpty(user.getAppUserName()) || StrUtil.isEmpty(user.getAppPassword())
|
|
|
+ || StrUtil.isEmpty(user.getSceneNum())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ Result result = goodsService.findByChildNameAndChildPassword(user.getAppUserName(), user.getAppPassword());
|
|
|
+ if (result.getCode() == Result.CODE_FAILURE){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ CameraEntity cameraEntity = mapper.convertValue(result.getData(), CameraEntity.class);
|
|
|
+ if(cameraEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneProEntity scene = sceneProService.findBySceneNum(user.getSceneNum());
|
|
|
+ if(scene == null){
|
|
|
+ scene = sceneProService.findDeleteSceneBySceneNum(user.getSceneNum());
|
|
|
+ if(scene == null){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5006, SceneConstant.FAILURE_MSG_5006);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(scene.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取8目场景的状态
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("获取8目场景的状态")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "appUserName", value = "相机设备码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "appPassword", value = "相机密码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "unicode", value = "unicode码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/getSceneStatusByUnicode")
|
|
|
+ public Result getSceneStatusByUnicode(@RequestBody UserParamVO user) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(user.getAppUserName()) || StrUtil.isEmpty(user.getAppPassword())
|
|
|
+ || StrUtil.isEmpty(user.getUnicode())){
|
|
|
+ log.info("appUserName:" + user.getAppUserName() + ",appPassword:" + user.getAppPassword() +
|
|
|
+ ",unicode:" + user.getUnicode());
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ Result result = goodsService.findByChildNameAndChildPassword(user.getAppUserName(), user.getAppPassword());
|
|
|
+ if (result.getCode() == Result.CODE_FAILURE){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ CameraEntity cameraEntity = mapper.convertValue(result.getData(), CameraEntity.class);
|
|
|
+ if(cameraEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneProEntity scene = sceneProService.getSceneStatusByUnicode(user.getUnicode(), "A");
|
|
|
+ if(scene == null){
|
|
|
+ scene = sceneProService.getSceneStatusByUnicode(user.getUnicode(), "I");
|
|
|
+ if(scene == null){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5009, SceneConstant.FAILURE_MSG_5009);
|
|
|
+ }
|
|
|
+ if(scene.getPayStatus() == -2){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5006, SceneConstant.FAILURE_MSG_5006);
|
|
|
+ }
|
|
|
+ // 当计算时,返回给前端的状态为计算中
|
|
|
+ if (scene.getStatus() == -1) {
|
|
|
+ scene.setStatus(0);
|
|
|
+ } else if (scene.getStatus() == 500) {
|
|
|
+ scene.setStatus(-1);
|
|
|
+ }
|
|
|
+ Map map = new HashMap();
|
|
|
+ //临时将-2改成1,app还没完全更新
|
|
|
+ map.put("status", scene.getStatus() == -2? 1 : scene.getStatus());
|
|
|
+ map.put("webSite", scene.getWebSite());
|
|
|
+ map.put("sceneNum", scene.getNum());
|
|
|
+ map.put("thumb", scene.getThumb());
|
|
|
+ map.put("dataSource", scene.getDataSource());
|
|
|
+ map.put("payStatus", scene.getPayStatus());
|
|
|
+ map.put("recStatus", scene.getRecStatus());
|
|
|
+ return Result.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除某个场景
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("删除某个场景")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "cameraId", value = "相机id", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneNum", value = "场景码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/deleteForCameraName")
|
|
|
+ public Result deleteForCameraName(@RequestBody UserParamVO user) throws Exception {
|
|
|
+ if (user.getCameraId() == null || StrUtil.isEmpty(user.getSceneNum())) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ CameraDetailEntity detailEntity = goodsService.findCameraDetailByCameraId(user.getCameraId());
|
|
|
+ if (detailEntity == null) {
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneProEntity scene = sceneProService.findBySceneNum(user.getSceneNum());
|
|
|
+ if(scene == null){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(scene.getCameraId().longValue() != user.getCameraId().longValue()){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5010, SceneConstant.FAILURE_MSG_5010);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return userService.deleteScene(null, user.getSceneNum());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * app保存录屏音频文件
|
|
|
+ * @param scene
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("app保存录屏音频文件")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "screencapMusic", value = "普通录屏音频文件地址", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "originalFileName", value = "文件名称", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneNum", value = "场景码", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/getScreencapVoice")
|
|
|
+ public Result getScreencapVoice(@RequestBody RequestScene scene) throws Exception {
|
|
|
+ if (StrUtil.isEmpty(scene.getScreencapMusic()) || StrUtil.isEmpty(scene.getOriginalFileName())
|
|
|
+ || StrUtil.isEmpty(scene.getSceneNum())) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneProEntity sceneProEntity = sceneProService.findBySceneNum(scene.getSceneNum());
|
|
|
+ if(sceneProEntity == null){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneProEditEntity updateScene = sceneProEditService.findByProId(sceneProEntity.getId());
|
|
|
+
|
|
|
+ //八目存放新的录音位置
|
|
|
+ long time = System.currentTimeMillis();
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ map.put("screencapVoiceSoundsyncFileName", scene.getScreencapMusic() + ".mp3");
|
|
|
+ map.put("screencapVoiceSoundsync", scene.getOriginalFileName() + "?t=" + time);
|
|
|
+ log.info("微信上传的音频路径:" + scene.getOriginalFileName() + "?t=" + time);
|
|
|
+ map.put("screencapVoiceType", "soundsync");
|
|
|
+ map.put("version", updateScene.getVersion() + 1);
|
|
|
+
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH)
|
|
|
+ .append("data").append(File.separator)
|
|
|
+ .append("data").append(scene.getSceneNum());
|
|
|
+ FileUtils.writeJsonFile(dataBuffer.append(File.separator).append("scene.json").toString(), map);
|
|
|
+
|
|
|
+ updateScene.setScreencapVoiceSoundsync(scene.getOriginalFileName() + "?t=" + time);
|
|
|
+ updateScene.setScreencapVoiceType("soundsync");
|
|
|
+ updateScene.setVersion(updateScene.getVersion() + 1);
|
|
|
+
|
|
|
+ FileUtils.downLoadFromUrl(scene.getOriginalFileName() + "?t=" + time, scene.getScreencapMusic() + ".mp3",
|
|
|
+ ConstantFilePath.SCENE_PATH+ "voice" + File.separator + "voice" + scene.getSceneNum());
|
|
|
+ return Result.success(sceneProEditService.update(updateScene));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * app获取用户所有场景
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("app获取用户所有场景")
|
|
|
+ @PostMapping(value = "/getAllSceneByUserName")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phoneNum", value = "用户名(手机号)", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "cameraType", value = "相机类型,1双目,4八目", dataType = "String")
|
|
|
+ })
|
|
|
+ public Result<List<ResponseScene>> getAllSceneByUserName(@RequestBody UserParamVO user) throws Exception {
|
|
|
+ if (StrUtil.isEmpty(user.getPhoneNum())) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ Result userResult = userService.findByUserName(user.getPhoneNum());
|
|
|
+ if(userResult.getCode() == Result.CODE_FAILURE){
|
|
|
+ return userResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ SSOUser ssoUser = mapper.convertValue(userResult.getData(), SSOUser.class);
|
|
|
+ if (ssoUser == null) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3015);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(user.getCameraType() == null){
|
|
|
+ user.setCameraType(4);
|
|
|
+ }
|
|
|
+ List<SceneProEntity> list = sceneProService.findByUserIdAndCameraType(ssoUser.getId(), user.getCameraType());
|
|
|
+
|
|
|
+ List<ResponseScene> sceneList = sceneProService.convert(list);
|
|
|
+ CameraEntity camera = null;
|
|
|
+ for(ResponseScene responseScene : sceneList){
|
|
|
+ camera = goodsService.findCameraById(responseScene.getCameraId());
|
|
|
+ if(camera != null){
|
|
|
+ responseScene.setChildName(camera.getChildName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.success(sceneList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 场景建模
|
|
|
+ */
|
|
|
+ @ApiOperation("场景建模")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "unicode", value = "unicode码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "cameraName", value = "相机编码", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "phoneId", value = "phoneId", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneKey", value = "大场景秘钥", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "prefix", value = "zip文件下载地址前缀", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "fileName", value = "文件名zip.Zip", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneName", value = "大场景名称", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneDec", value = "大场景描述", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "sceneType", value = "大场景类型", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "shootCount", value = "拍摄点位数", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "gps", value = "gps", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "thumb", value = "场景缩略图", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "algorithm", value = "sfm或slam", dataType = "String")
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/buildScene")
|
|
|
+ public Result buildScene(@RequestBody RequestBuildScene buildScene) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(buildScene.getUnicode()) || StrUtil.isEmpty(buildScene.getCameraName()) ||
|
|
|
+ StrUtil.isEmpty(buildScene.getSceneKey()) ||
|
|
|
+ StrUtil.isEmpty(buildScene.getPrefix()) || StrUtil.isEmpty(buildScene.getFileName()) ||
|
|
|
+ StrUtil.isEmpty(buildScene.getSceneName()) || StrUtil.isEmpty(buildScene.getSceneDec()) ||
|
|
|
+ buildScene.getSceneType() == null || buildScene.getShootCount() == null ||
|
|
|
+ StrUtil.isEmpty(buildScene.getThumb()) || StrUtil.isEmpty(buildScene.getAlgorithm()) ){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+ String sceneNum = null;
|
|
|
+ try{
|
|
|
+ sceneNum = sceneNumService.generateSceneNum();
|
|
|
+ if(sceneNum == null){
|
|
|
+ log.error("大场景序号为空:" + sceneNum);
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("查询相机:" + buildScene.getCameraName());
|
|
|
+ CameraEntity cameraEntity = goodsService.findByChildName(buildScene.getCameraName());
|
|
|
+
|
|
|
+ if(cameraEntity == null){
|
|
|
+ log.error("该相机不存在:" + buildScene.getCameraName());
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
|
|
|
+ }
|
|
|
+
|
|
|
+ CameraDetailEntity detailEntity = goodsService.findCameraDetailByCameraId(cameraEntity.getId());
|
|
|
+
|
|
|
+ int balance = Integer.valueOf(detailEntity.getBalance());
|
|
|
+ if(balance - Constant.MONEY_SCENE <0){
|
|
|
+ log.error("相机点数不足:" + buildScene.getCameraName());
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6006, CameraConstant.FAILURE_MSG_6006);
|
|
|
+ }
|
|
|
+
|
|
|
+ Result result = userService.findById(detailEntity.getUserId());
|
|
|
+ SSOUser user = mapper.convertValue(result.getData(), SSOUser.class);
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户id不存在:" + detailEntity.getUserId());
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3015);
|
|
|
+ }
|
|
|
+ SceneEntity sceneProEntity = ComputerUtil.createScene(sceneNum, cameraEntity.getId(), cameraEntity.getChildName(), buildScene.getPhoneId(),
|
|
|
+ buildScene.getSceneKey(), buildScene.getUnicode(), detailEntity.getGoodsId(), "0", buildScene.getPrefix(),
|
|
|
+ buildScene.getFileName(), buildScene.getThumb(), "0", detailEntity.getUserId(), user.getUserName(),
|
|
|
+ buildScene.getAlgorithm(), buildScene.getShootCount(), buildScene.getSceneName(),
|
|
|
+ buildScene.getSceneDec(), buildScene.getSceneType(), buildScene.getGps(), sceneService, 0, producer, mainUrl + sceneUrl, ecsType, rubberSheetingUtil);
|
|
|
+
|
|
|
+ return Result.success(sceneProEntity);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("增加大场景失败:" + sceneNum);
|
|
|
+ sceneProService.updateStatus(sceneNum, -1);
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5011, SceneConstant.FAILURE_MSG_5011);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 协作的场景
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("协作的场景")
|
|
|
+ @PostMapping(value = "/cooperationSceneList")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phoneNum", value = "用户名(手机号)", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "cameraType", value = "相机类型,1双目,4八目", dataType = "String")
|
|
|
+ })
|
|
|
+ public Result cooperationSceneList(@RequestBody UserParamVO user) throws Exception{
|
|
|
+ if (StrUtil.isEmpty(user.getPhoneNum())) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001, ErrorCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ Result userResult = userService.findByUserName(user.getPhoneNum());
|
|
|
+ if(userResult.getCode() == Result.CODE_FAILURE){
|
|
|
+ return userResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ SSOUser ssoUser = mapper.convertValue(userResult.getData(), SSOUser.class);
|
|
|
+ if (ssoUser == null) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3015);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(user.getCameraType() == null){
|
|
|
+ user.setCameraType(4);
|
|
|
+ }
|
|
|
+
|
|
|
+ Condition condition = new Condition(SceneCooperationEntity.class);
|
|
|
+ condition.and().andEqualTo("userId", ssoUser.getId());
|
|
|
+ condition.orderBy("id").desc();
|
|
|
+ List<SceneCooperationEntity> list = sceneCooperationService.findAll(condition);
|
|
|
+
|
|
|
+ if(list == null || list.size() <= 0){
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder nums = new StringBuilder();
|
|
|
+ SceneCooperationEntity cooperationEntity = null;
|
|
|
+ for(int i = 0, len = list.size(); i < len; i++){
|
|
|
+ cooperationEntity = list.get(i);
|
|
|
+ if(i != len - 1){
|
|
|
+ nums.append("'").append(cooperationEntity.getSceneNum()).append("'").append(",");
|
|
|
+ }else {
|
|
|
+ nums.append("'").append(cooperationEntity.getSceneNum()).append("'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SceneProEntity> sceneProEntityList = sceneProService.findBySceneNums(nums.toString(), user.getCameraType());
|
|
|
+
|
|
|
+ List<ResponseScene> responseScenes = sceneProService.convert(sceneProEntityList);
|
|
|
+ CameraEntity cameraEntity = null;
|
|
|
+ for(ResponseScene responseScene : responseScenes){
|
|
|
+ cameraEntity = goodsService.findCameraById(responseScene.getCameraId());
|
|
|
+ if(cameraEntity != null){
|
|
|
+ responseScene.setChildName(cameraEntity.getChildName());
|
|
|
+ responseScene.setSnCode(cameraEntity.getSnCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(responseScenes);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|