|
@@ -0,0 +1,695 @@
|
|
|
+package com.gis.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileTypeUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gis.common.constant.CmdConstant;
|
|
|
+import com.gis.common.constant.ConfigConstant;
|
|
|
+import com.gis.common.constant.MsgCode;
|
|
|
+import com.gis.common.constant.RabbitConfig;
|
|
|
+import com.gis.common.exception.BaseRuntimeException;
|
|
|
+import com.gis.common.task.AsyncTask;
|
|
|
+import com.gis.common.util.*;
|
|
|
+import com.gis.domain.dto.*;
|
|
|
+import com.gis.domain.entity.SceneEntity;
|
|
|
+import com.gis.domain.entity.SceneInitEntity;
|
|
|
+import com.gis.domain.entity.SecondHandEntity;
|
|
|
+import com.gis.feign.HouseFeign;
|
|
|
+import com.gis.feign.SceneProFeign;
|
|
|
+import com.gis.mapper.IBaseMapper;
|
|
|
+import com.gis.mapper.SceneInitMapper;
|
|
|
+import com.gis.mapper.SceneMapper;
|
|
|
+import com.gis.mapper.SecondHandMapper;
|
|
|
+import com.gis.service.SceneInitService;
|
|
|
+import com.gis.service.SceneService;
|
|
|
+import com.gis.service.SecondHandService;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.transaction.Transactional;
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by owen on 2021/9/8 0011 16:16
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class SecondHandServiceImpl extends IBaseServiceImpl<SecondHandEntity, String> implements SecondHandService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SecondHandMapper entityMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SceneInitMapper sceneInitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SceneInitService sceneInitService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ HouseFeign houseFeign;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SceneProFeign sceneProFeign;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ConfigConstant configConstant;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ FileUtils fileUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AliyunOssUtil aliyunOssUtil;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AsyncTask asyncTask;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IBaseMapper<SecondHandEntity, String> getBaseMapper() {
|
|
|
+ return this.entityMapper;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @param houseId 房源id
|
|
|
+ * @param groupId 小区id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result uploadPanoRabbitMq(MultipartFile file, String houseId, String hengDaId) {
|
|
|
+
|
|
|
+ // 检查非法文件上传
|
|
|
+ boolean checkFile = FileUtils.checkFile(file);
|
|
|
+ if (!checkFile) {
|
|
|
+ return Result.failure("上传文件格式有误, 请重新上传");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 文件名不能为空
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ originalFilename = StringUtils.substringBeforeLast(originalFilename, ".");
|
|
|
+ if (StringUtils.isAllBlank(originalFilename)) {
|
|
|
+ return Result.failure("文件名不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(houseId) || houseId.equals("null")) {
|
|
|
+ log.error("houseId不能为空");
|
|
|
+ return Result.failure("houseId不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String basePath = null;
|
|
|
+ String sceneCode = FileUtils.getCode();
|
|
|
+ SecondHandEntity entity = new SecondHandEntity();
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 此方法可以读取到图片内部结构
|
|
|
+ String type = FileTypeUtil.getType(file.getInputStream());
|
|
|
+ if (!FileUtils.getType(type).equals("image")) {
|
|
|
+ log.error("非图片类型");
|
|
|
+ return Result.failure(7001, "非图片类型");
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 下次发版,建议前端判断图片大小比例,后端耗性能,不处理
|
|
|
+ if (!FileUtils.checkScale(file.getInputStream())) {
|
|
|
+ log.error("图片比例非2:1");
|
|
|
+ return Result.failure(7007, "图片比例非2:1");
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("type: " + type);
|
|
|
+
|
|
|
+
|
|
|
+ // 全景图只支持jpg图片格式
|
|
|
+ if (!type.equalsIgnoreCase("jpg")) {
|
|
|
+ log.error("图片格式错误,只支持jpg图片类型, type: " + type);
|
|
|
+ return Result.failure(7002, "只支持jpg图片类型");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 写入文件
|
|
|
+ basePath = configConstant.filePath + sceneCode;
|
|
|
+ String panoPath = basePath + "/" + sceneCode + "." + type;
|
|
|
+ log.info("panoPath: {}", panoPath);
|
|
|
+ FileUtil.writeFromStream(file.getInputStream(), panoPath);
|
|
|
+ log.info("文件写入服务器完成");
|
|
|
+
|
|
|
+ if (!FileUtil.isFile(panoPath)) {
|
|
|
+ log.error("全景图不存在");
|
|
|
+ return Result.failure("全景图不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String uuid = RandomUtils.getUuid("SH");
|
|
|
+ entity.setId(uuid);
|
|
|
+ entity.setSceneCode(sceneCode);
|
|
|
+ entity.setPath(panoPath);
|
|
|
+ entity.setOssPath(configConstant.ossDomain + configConstant.projectName + "/" + sceneCode);
|
|
|
+
|
|
|
+ // 压缩图片并上传oss
|
|
|
+ // 全景图缩略图统一命名规则: http:// oss/cms_pano_fcb/image/thumb_sceneCode.jpg
|
|
|
+ String iconPath = convertAndUploadOss(
|
|
|
+ panoPath, configConstant.filePath, configConstant.ossBasePath, configConstant.ossDomain, 600, 300, "image/thumb_" + sceneCode + ".jpg");
|
|
|
+ log.info("iconPath:" + iconPath);
|
|
|
+ entity.setIcon(iconPath);
|
|
|
+ entity.setStatus(1);
|
|
|
+ entity.setHouseId(houseId);
|
|
|
+// entity.setType(sceneType);
|
|
|
+ entity.setHengdaId(hengDaId);
|
|
|
+
|
|
|
+ // 出来文件名不要后缀
|
|
|
+ entity.setFileName(originalFilename);
|
|
|
+ entity.setSceneTitle(entity.getFileName());
|
|
|
+
|
|
|
+ // todo webSite待定
|
|
|
+ // /hengda.html?m=场景码&prodId=房车宝楼盘ID&houseId=自己维护的楼盘ID
|
|
|
+ String webSite = "/hengda.html?m=" + sceneCode + "&prodId=" + hengDaId + "&houseId=" + houseId;
|
|
|
+ log.info("webSite: " + webSite);
|
|
|
+ entity.setWebSite(webSite);
|
|
|
+
|
|
|
+ this.save(entity);
|
|
|
+
|
|
|
+ //发消息到mq
|
|
|
+ rabbitTemplate.convertAndSend(RabbitConfig.SECOND_HAND_EXCHANGE, RabbitConfig.SECOND_HAND_QUEUE_ROUTING, entity.getId());
|
|
|
+ log.info("二手房全景图入队成功: 场景码:{},场景id:{} ", sceneCode, entity.getId());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("二手房全景图上传完成:{}", sceneCode);
|
|
|
+ return Result.success(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result testQueueSecondHand() {
|
|
|
+ String msg = "cms_pano_fcb/image/thumb_sceneCode.jpg_" + System.currentTimeMillis();
|
|
|
+ rabbitTemplate.convertAndSend(RabbitConfig.SECOND_HAND_EXCHANGE, RabbitConfig.SECOND_HAND_QUEUE_ROUTING, msg);
|
|
|
+ log.info("msg: " + msg);
|
|
|
+ return Result.success(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result editXml(XmlDataDto param) {
|
|
|
+ String id = param.getId();
|
|
|
+ SecondHandEntity entity = entityMapper.findByIdForUpdate(id);
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("对象不存在,id : " + id);
|
|
|
+ return Result.failure("场景码不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 检查VR项目状态
|
|
|
+ String houseId = entity.getHouseId();
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 保存初始视觉
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("hlookat", param.getHlookat());
|
|
|
+ jsonObject.put("vlookat", param.getVlookat());
|
|
|
+ entity.setInitVisual(jsonObject.toJSONString());
|
|
|
+
|
|
|
+ this.update(entity);
|
|
|
+
|
|
|
+ return Result.success(entity.getOssPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result editSomeData(EditSomeDataDto param) {
|
|
|
+ String id = param.getId();
|
|
|
+ SecondHandEntity entity = this.findById(id);
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("场景不存在, id: " + id);
|
|
|
+ return Result.failure("场景不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查VR项目状态
|
|
|
+ String houseId = entity.getHouseId();
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ this.update(entity);
|
|
|
+ log.info("更新场景完成");
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result findBySceneCode(String sceneCode) {
|
|
|
+ SecondHandEntity entity = entityMapper.findBySceneCode(sceneCode);
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("对象不存在, 场景码:{}", sceneCode);
|
|
|
+ return Result.failure("对象不存在");
|
|
|
+ }
|
|
|
+ return Result.success(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result updateInitIcon(String id, String icon) {
|
|
|
+ // forUpdate:数据一致新问题
|
|
|
+ SecondHandEntity entity = entityMapper.findByIdForUpdate(id);
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("对象不存在: {}", id);
|
|
|
+ return Result.failure("对象不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setIcon(icon);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ this.update(entity);
|
|
|
+ log.info("更新初始画面成功");
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result setSort(Map<String, String> param) {
|
|
|
+ log.info("sort size: " + param.size());
|
|
|
+ int n = 1;
|
|
|
+ for (Map.Entry<String, String> m : param.entrySet()) {
|
|
|
+ String id = m.getKey();
|
|
|
+ if (n == 1) {
|
|
|
+ SecondHandEntity entity = this.findById(id);
|
|
|
+ String houseId = entity.getHouseId();
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String sort = m.getValue();
|
|
|
+ log.info("id: " + id);
|
|
|
+ log.info("sort: " + sort);
|
|
|
+ entityMapper.setSortById(id, sort);
|
|
|
+ n++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result upload(MultipartFile file) {
|
|
|
+
|
|
|
+ // 检查非法文件上传
|
|
|
+ boolean checkFile = FileUtils.checkFile(file);
|
|
|
+ if (!checkFile) {
|
|
|
+ return Result.failure("上传文件格式有误, 请重新上传");
|
|
|
+ }
|
|
|
+ // 直接上传oss
|
|
|
+ return Result.success(fileUtils.renameUploadOssBye(file, configConstant.ossBasePath + "secondHand/", configConstant.ossDomain));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject jsonSearch(SecondHandPageDto param) {
|
|
|
+ startPage(param);
|
|
|
+ List<SecondHandEntity> search = entityMapper.search(param);
|
|
|
+ PageInfo<SecondHandEntity> page = new PageInfo<>(search);
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("code", 0);
|
|
|
+ result.put("data", page);
|
|
|
+ result.put("msg", "操作成功");
|
|
|
+ // 是否存在计算中的场景, true: 需要轮询, false:不轮询
|
|
|
+ result.put("isCheck", checkStatus(param.getHouseId(), "1"));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result remove(String id) {
|
|
|
+ SecondHandEntity entity = this.findById(id);
|
|
|
+ if (entity.getStatus() == 1) {
|
|
|
+ return Result.failure(7004, "执行中的任务不能删除");
|
|
|
+
|
|
|
+ }
|
|
|
+ String sceneCode = entity.getSceneCode();
|
|
|
+ String houseId = entity.getHouseId();
|
|
|
+
|
|
|
+ // 检查VR项目状态
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询热点关联场景
|
|
|
+ List<SecondHandEntity> list = this.searchUseHots(houseId, sceneCode);
|
|
|
+ log.info("关联热点场景数量: " + list.size());
|
|
|
+ if (list.size() > 0) {
|
|
|
+ return Result.failure(7008, "有关联热点场景使用此场景,不能删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setIsDelete(1);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ this.update(entity);
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SecondHandEntity> searchUseHots(String houseId, String sceneCode) {
|
|
|
+ sceneCode = "%" + sceneCode + "%";
|
|
|
+ return entityMapper.searchUseHots(houseId, sceneCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result saveUseHots(UseHotsDto param) {
|
|
|
+ String id = param.getId();
|
|
|
+ SecondHandEntity entity = this.findById(id);
|
|
|
+ if (entity == null) {
|
|
|
+ log.info("对象不存在:" + id);
|
|
|
+ return Result.failure("对象不存在");
|
|
|
+
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("data", param.getSceneCodes());
|
|
|
+ entity.setUseHots(jsonObject.toJSONString());
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ this.update(entity);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result houseRemove(String houseId) {
|
|
|
+
|
|
|
+ entityMapper.houseRemove(houseId);
|
|
|
+ log.info("管理后台-vr项目删除成功, id: {}", houseId);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result houseAudit(String houseId, String status) {
|
|
|
+ if ("3".equals(status)) {
|
|
|
+ log.info("vr项目下线,状态:{}, 房源id:{}", status, houseId);
|
|
|
+ } else {
|
|
|
+ log.info("vr项目上线,状态:{}, 房源id:{}", status, houseId);
|
|
|
+ }
|
|
|
+ entityMapper.houseAudit(houseId, status);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result vrFindBySceneCode(String sceneCode) {
|
|
|
+ log.info("VR模模型-根据场景码查询: " + sceneCode);
|
|
|
+ // 此方法建议把返回值改回list值会更安全
|
|
|
+ List<SecondHandEntity> list = entityMapper.listFindBySceneCode(sceneCode);
|
|
|
+ log.info("使用中的VR模型数量:" + list.size());
|
|
|
+ boolean flag = true;
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ log.info("查询结果: " + flag);
|
|
|
+ return Result.success(flag);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加VR模型
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result findVrModel(SceneRroPageDto param) {
|
|
|
+ // TODO: 2021/1/8 0008 查找4dkk场景数据,当前区域公司下的模型
|
|
|
+ @NotBlank(message = "token不能为空") String token = param.getToken();
|
|
|
+ // 只获取计算成功的, 0:计算成功
|
|
|
+ param.setStatus("0");
|
|
|
+ String searchKey = param.getSearchKey();
|
|
|
+ if (StringUtils.isNotBlank(searchKey)) {
|
|
|
+ param.setSceneName(searchKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ Result result = null;
|
|
|
+ try {
|
|
|
+ result = sceneProFeign.findByList(param, token);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤已添加的数据
|
|
|
+ if (result.getCode() == 0) {
|
|
|
+ log.info("调用四维看看查找场景列表数据成功");
|
|
|
+ Object data = result.getData();
|
|
|
+ PageInfo page = JSON.parseObject(data.toString(), PageInfo.class);
|
|
|
+
|
|
|
+ List<Object> list = page.getList();
|
|
|
+ log.info("list size: " + list.size());
|
|
|
+
|
|
|
+ List<Object> newList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Object o : list) {
|
|
|
+ JSONObject scenePro = JSON.parseObject(o.toString());
|
|
|
+ String sceneProId = scenePro.getString("id");
|
|
|
+ List<SecondHandEntity> vrModelId = entityMapper.findByVrModelId2(sceneProId);
|
|
|
+ // 0:未使用
|
|
|
+ String use = "0";
|
|
|
+ if (vrModelId.size() > 0) {
|
|
|
+ // 1: 已使用
|
|
|
+ use = "1";
|
|
|
+ }
|
|
|
+
|
|
|
+ scenePro.put("isUse", use);
|
|
|
+ newList.add(scenePro);
|
|
|
+ }
|
|
|
+
|
|
|
+ page.setList(newList);
|
|
|
+ log.info("newList size: " + newList.size());
|
|
|
+
|
|
|
+ return Result.success(page);
|
|
|
+ } else {
|
|
|
+ log.error("异常了");
|
|
|
+ return Result.failure(result.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result saveVrModel(VrModelDto param) {
|
|
|
+ String id = param.getId();
|
|
|
+ log.info("id: " + id);
|
|
|
+
|
|
|
+ // 检查VR项目状态
|
|
|
+ String houseId = param.getHouseId();
|
|
|
+ String roomId = param.getRoomId();
|
|
|
+
|
|
|
+ if (!canEdit(houseId)) {
|
|
|
+ log.error("VR项目不可编辑");
|
|
|
+ return Result.failure(7005, "VR项目不可编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+ SecondHandEntity entity = null;
|
|
|
+ @NotBlank(message = "场景码不能为空") String sceneCode = param.getSceneCode();
|
|
|
+ @NotBlank(message = "恒大id不能为空") String hengdaId = param.getHengdaId();
|
|
|
+ String webSite = "/hengda.html?m=" + sceneCode + "&prodId=" + hengdaId + "&houseId=" + houseId;
|
|
|
+
|
|
|
+
|
|
|
+ if (id == null) {
|
|
|
+
|
|
|
+ // 一个VR项目不能有相同的户型
|
|
|
+ List<SecondHandEntity> sceneEntities = entityMapper.findByHouseIdAndRoomId(houseId, roomId);
|
|
|
+ if (sceneEntities.size() > 0) {
|
|
|
+ return Result.failure(MsgCode.e3002, "户型已存在,不能重复添加");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 一个VR项目不能有相同的模型
|
|
|
+ entity = entityMapper.findByVrModelIdAndHouseId(param.getVrModelId(), houseId);
|
|
|
+ if (entity != null) {
|
|
|
+ log.error("VrModelId已存在");
|
|
|
+ return Result.failure(MsgCode.e3001, "场景码已存在, 不能重复添加");
|
|
|
+ }
|
|
|
+
|
|
|
+ entity = new SecondHandEntity();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ entity.setId(RandomUtils.getUuid());
|
|
|
+ entity.setType("house");
|
|
|
+ entity.setStatus(3);
|
|
|
+ entity.setWebSite(webSite);
|
|
|
+ this.save(entity);
|
|
|
+
|
|
|
+
|
|
|
+ log.info("保存VR模型完成");
|
|
|
+ } else {
|
|
|
+ entity = this.findById(id);
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ entity.setWebSite(webSite);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ this.update(entity);
|
|
|
+ log.info("更新VR模型完成");
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查是否有计算中的场景
|
|
|
+ *
|
|
|
+ * @param houseId
|
|
|
+ * @param status
|
|
|
+ * @return true: 有, false:没有
|
|
|
+ */
|
|
|
+ public Boolean checkStatus(String houseId, String status) {
|
|
|
+ List<SecondHandEntity> entities = entityMapper.findByHouseIdAndStatus(houseId, status);
|
|
|
+ boolean flag = false;
|
|
|
+ if (entities.size() > 0) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2021-04-27
|
|
|
+ * 使用convert 生成缩略图
|
|
|
+ *
|
|
|
+ * @param inputFilePath
|
|
|
+ * @param ossBasePath
|
|
|
+ * @param ossDomain
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String convertAndUploadOss(
|
|
|
+ String inputFilePath, String serverBasePath, String ossBasePath, String ossDomain, Integer width, Integer height, String fileName) {
|
|
|
+
|
|
|
+ // 保存图片位置
|
|
|
+ String saveCompressImgPath = serverBasePath + fileName;
|
|
|
+ log.info("saveCompressImgPath: " + saveCompressImgPath);
|
|
|
+ String ossUrl = null;
|
|
|
+ try {
|
|
|
+ // 使用convert压缩图片
|
|
|
+ String cmd = CmdConstant.CONVERT;
|
|
|
+ String size = width + "x" + height;
|
|
|
+ cmd = cmd.replace("@size", size);
|
|
|
+ cmd = cmd.replace("@input", inputFilePath);
|
|
|
+ cmd = cmd.replace("@output", saveCompressImgPath);
|
|
|
+ CmdUtils.callShell(cmd);
|
|
|
+ log.info("图片压缩成功: " + saveCompressImgPath);
|
|
|
+
|
|
|
+ if (FileUtil.isFile(saveCompressImgPath)) {
|
|
|
+ // 上传oss
|
|
|
+ String ossPath = ossBasePath + fileName;
|
|
|
+ log.info("ossPath: " + ossPath);
|
|
|
+ asyncTask.uploadOss(saveCompressImgPath, ossPath);
|
|
|
+ ossUrl = ossDomain + ossPath;
|
|
|
+ log.info("图片上传成功: " + ossUrl);
|
|
|
+ } else {
|
|
|
+ log.error("缩略图不存在: " + saveCompressImgPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("图片格式有误,不支持此图片");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return ossUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询VR项目是否可编辑
|
|
|
+ * true: 可编辑
|
|
|
+ * false: 不可编辑
|
|
|
+ *
|
|
|
+ * @param houseId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean canEdit(String houseId) {
|
|
|
+ Result result = null;
|
|
|
+ // 方便测试用, 可以删除
|
|
|
+ if ("dev".equals(configConstant.active) || "sit".equals(configConstant.active)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ result = houseFeign.canEdit(houseId);
|
|
|
+ log.info("房车宝返回数据:{}", result);
|
|
|
+ if (result.getCode() == 0) {
|
|
|
+ boolean data = (boolean) result.getData();
|
|
|
+ if (data) {
|
|
|
+ log.info("vr项目可编辑");
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ log.info("vr项目不可编辑");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.error("VR项目接口查询失败:" + result.getMsg());
|
|
|
+ throw new BaseRuntimeException(7007, "VR项目接口查询失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("调用房车宝接口失败");
|
|
|
+ throw new BaseRuntimeException("调用房车宝接口失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void startPage(PageDto param) {
|
|
|
+ super.startPage(param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|