Scene3dFamilyController.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.fdkankan.scene.controller;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.dtflys.forest.annotation.Get;
  4. import com.fdkankan.common.constant.ErrorCode;
  5. import com.fdkankan.common.exception.BusinessException;
  6. import com.fdkankan.scene.entity.Scene3dfamily;
  7. import com.fdkankan.scene.entity.ScenePro;
  8. import com.fdkankan.scene.service.IScene3dfamilyService;
  9. import com.fdkankan.scene.service.ISceneProService;
  10. import com.fdkankan.scene.service.IUserService;
  11. import com.fdkankan.web.controller.BaseController;
  12. import com.fdkankan.web.response.Result;
  13. import com.fdkankan.web.user.SSOUser;
  14. import java.util.Arrays;
  15. import java.util.Date;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.apache.commons.lang3.StringUtils;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.cloud.context.config.annotation.RefreshScope;
  21. import org.springframework.util.ObjectUtils;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestMethod;
  25. import org.springframework.web.bind.annotation.RestController;
  26. /**
  27. * 三维家
  28. */
  29. @RefreshScope
  30. @Slf4j
  31. @RestController
  32. @RequestMapping("/service/scenev3/threefamily")
  33. public class Scene3dFamilyController extends BaseController {
  34. @Autowired
  35. private IScene3dfamilyService scene3dFamilyService;
  36. @Autowired
  37. private ISceneProService sceneProService;
  38. @Autowired
  39. private IUserService userService;
  40. @Value("${3d.family.keys:#{null}}")
  41. private String[] secrets;
  42. /**
  43. *
  44. * 三维家 拉取场景数据,压缩zip包
  45. */
  46. @GetMapping(value = "/scenecpzip")
  47. public Result scenecpzip(String sceneNum) throws Exception{
  48. String token = getToken();
  49. if(StringUtils.isEmpty(token)){
  50. throw new BusinessException(ErrorCode.FAILURE_CODE_3004);
  51. }
  52. SSOUser ssoUser = this.getSsoUserV3();
  53. if(ssoUser == null || ssoUser.getId() == null){
  54. throw new BusinessException(ErrorCode.FAILURE_CODE_3004);
  55. }
  56. if(StrUtil.isEmpty(sceneNum)){
  57. throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
  58. }
  59. ScenePro sceneProEntity = sceneProService.findBySceneNum(sceneNum);
  60. if(sceneProEntity == null){
  61. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  62. }
  63. //验证是否在打包
  64. Scene3dfamily scene3dFamilyEntity = scene3dFamilyService.findSceneNumByNum(sceneProEntity.getNum(),0);
  65. if(scene3dFamilyEntity != null){
  66. throw new BusinessException(ErrorCode.FAILURE_CODE_5031);
  67. }
  68. scene3dFamilyService.updateSceneNumByNum(sceneProEntity);
  69. //信息入库
  70. scene3dFamilyEntity = new Scene3dfamily();
  71. scene3dFamilyEntity.setSceneNum(sceneNum);
  72. scene3dFamilyEntity.setStatus(0);
  73. scene3dFamilyEntity.setZipStartTime(new Date());
  74. scene3dFamilyEntity.setCreateUesr(ssoUser.getId());
  75. scene3dFamilyEntity.setUpdateUesr(ssoUser.getId());
  76. scene3dFamilyService.save(scene3dFamilyEntity);
  77. scene3dFamilyService.createZip(sceneProEntity, ssoUser.getId());
  78. return Result.success();
  79. }
  80. /**
  81. *
  82. * 三维家 拉取场景数据,压缩zip包
  83. */
  84. @GetMapping(value = "/detail")
  85. public Result detail(String sceneNum,String keys) throws Exception{
  86. if (!ObjectUtils.isEmpty(secrets) && Arrays.asList(secrets).contains(keys)){
  87. if(StrUtil.isEmpty(sceneNum)){
  88. throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
  89. }
  90. ScenePro sceneProEntity = sceneProService.findBySceneNum(sceneNum);
  91. if(sceneProEntity == null){
  92. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  93. }
  94. return Result.success(scene3dFamilyService.findSceneNumByNum2(sceneProEntity));
  95. }else{
  96. return Result.failure("身份验证失败!");
  97. }
  98. }
  99. }