|
@@ -19,13 +19,11 @@ import com.fdkanfang.domain.response.UserResponse;
|
|
|
import com.fdkanfang.service.backend.*;
|
|
|
import com.fdkanfang.web.backend.utils.UserUtils;
|
|
|
import com.fdkanfang.web.mq.config.RabbitConfig;
|
|
|
-import com.fdkanfang.web.shiro.JWTUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -35,13 +33,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@@ -62,6 +61,9 @@ public class HouseController extends BaseController {
|
|
|
@Value("${server.domain}")
|
|
|
private String domain;
|
|
|
|
|
|
+ @Value("${4dkankan.host}")
|
|
|
+ private String KankanHost;
|
|
|
+
|
|
|
@Autowired
|
|
|
private HouseService2 houseService2;
|
|
|
|
|
@@ -626,8 +628,7 @@ public class HouseController extends BaseController {
|
|
|
try {
|
|
|
|
|
|
FileUtils.createDir(sourcePath);
|
|
|
-/*
|
|
|
- /***
|
|
|
+ /**
|
|
|
* 以下字段为给算法部传递的参数(data.json),用于生成模型和
|
|
|
* 照片,提供前端使用,完整的参数如下:
|
|
|
* {
|
|
@@ -677,28 +678,19 @@ public class HouseController extends BaseController {
|
|
|
log.error("vision不能为空");
|
|
|
return new R(50002, "vision不能为空");
|
|
|
}
|
|
|
-
|
|
|
// json写入服务器
|
|
|
FileUtils.fileWriter(floorPlan, sourcePath + "floorplan.json");
|
|
|
FileUtils.fileWriter(vision, sourcePath + "vision.txt");
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
log.info("floorplan.json生成完成");
|
|
|
log.info("vision.txt生成完成");
|
|
|
-
|
|
|
// 复制垂直校验图片到指定目录
|
|
|
String verticalImagePath = OUTPATH + sceneCode+"/output_img";
|
|
|
String panoImagePath = sourcePath + "images/";
|
|
|
-
|
|
|
// srcPath: /data/kanfang/10002/output_img
|
|
|
log.info("srcPath: {}", verticalImagePath);
|
|
|
-
|
|
|
// target: /data/kanfang/10002/pano/extras/images/
|
|
|
log.info("target: {}", panoImagePath);
|
|
|
-
|
|
|
FileUtil.copyFilesFromDir(new File(verticalImagePath), new File(panoImagePath), true);
|
|
|
-
|
|
|
flagQ = true;
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -708,52 +700,69 @@ public class HouseController extends BaseController {
|
|
|
}
|
|
|
|
|
|
if (flagQ) {
|
|
|
- HashMap<Object, Object> mqMap = new HashMap<>();
|
|
|
- mqMap.put("id", house.getId());
|
|
|
- mqMap.put("basePath", savePath);
|
|
|
+ /* mqMap.put("id", house.getId());
|
|
|
+ mqMap.put("basePath", savePath);*/
|
|
|
|
|
|
// 上传floorplan.json到oss, 并命名为floor.json
|
|
|
HashMap<String, String> uploadJson = new HashMap<>();
|
|
|
-
|
|
|
// osspath : images/images+sceneCode/floor.json
|
|
|
uploadJson.put(sourcePath + "floorplan.json", ConstantFilePath.OSS_FLOOR_PATH+sceneCode+"/floor.json");
|
|
|
AliyunOssUtil.uploadMulFiles(uploadJson);
|
|
|
-
|
|
|
// savePath:/data/kanfang/房源编号/
|
|
|
// basePath: /data/kanfang/10002/pano
|
|
|
log.info("basePath: {}", savePath);
|
|
|
log.info("houseId: {}", house.getId());
|
|
|
|
|
|
- //发消息到mq
|
|
|
- rabbitTemplate.convertAndSend(RabbitConfig.PANO_EXCHANGE, RabbitConfig.PANO_QUEUE_ROUTING, mqMap);
|
|
|
-
|
|
|
- // 修改房源状态, 3:模型计算中
|
|
|
- house.setStatus(3);
|
|
|
- house.setUpdateTime(new Date());
|
|
|
- houseService2.update(house);
|
|
|
-
|
|
|
-
|
|
|
// 每点击生成模型一次,就修改SceneProEditEntity的部分值
|
|
|
SceneProEntity sceneProEntity = sceneProService.findBySceneNum(house.getSceneCode());
|
|
|
if (sceneProEntity == null) {
|
|
|
log.error("sceneProEntity对象不存在:{}", house.getSceneCode());
|
|
|
return new R(MsgCode.ERROR_CODE, "sceneProEntity对象不存在");
|
|
|
}
|
|
|
+
|
|
|
+ // 修改房源状态, 3:模型计算中
|
|
|
+ house.setStatus(3);
|
|
|
+ house.setUpdateTime(new Date());
|
|
|
+ int updateHouse = houseService2.update(house);
|
|
|
+ if(updateHouse != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新房源状态失败");
|
|
|
+ }
|
|
|
+
|
|
|
SceneProEditEntity proEditEntity = sceneProEditService.findByProId(sceneProEntity.getId());
|
|
|
proEditEntity.setVersion(proEditEntity.getVersion() + 1);
|
|
|
proEditEntity.setFloorEditVer(proEditEntity.getFloorEditVer() + 1);
|
|
|
proEditEntity.setFloorPublishVer(proEditEntity.getFloorPublishVer() + 1);
|
|
|
proEditEntity.setUpdateTime(new Date());
|
|
|
|
|
|
- sceneProEditService.update(proEditEntity);
|
|
|
+ int updateSceneProEdit = sceneProEditService.update(proEditEntity);
|
|
|
+ if(updateSceneProEdit != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新sceneProEdit状态失败");
|
|
|
+ }
|
|
|
log.info("更新SceneProEditEntity数据完成");
|
|
|
|
|
|
+ //发消息到mq
|
|
|
+ Map<String, Object> mqMap = formatMqReq(house , sceneProEntity , savePath);
|
|
|
+ rabbitTemplate.convertAndSend(RabbitConfig.PANO_EXCHANGE, RabbitConfig.PANO_QUEUE_ROUTING, mqMap);
|
|
|
log.info("入队成功");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return new R(MsgCode.SUCCESS_CODE, house);
|
|
|
}
|
|
|
|
|
|
+ private Map<String, Object> formatMqReq(HouseEntity house , SceneProEntity sceneProEntity , String path){
|
|
|
+ Map<String ,Object> result = new HashMap<>();
|
|
|
+ if(null == house){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.put("sceneName" , house.getDistrictName());
|
|
|
+ result.put("sceneNum" , house.getSceneCode());
|
|
|
+ result.put("sceneScheme" , sceneProEntity.getSceneScheme());
|
|
|
+ result.put("userId" , house.getUserId());
|
|
|
+ result.put("dataSource" , path);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private String checkImageResolutionRate(HouseEntity houseEntity){
|
|
|
if(null == houseEntity || null == houseEntity.getId()){
|
|
|
return null;
|
|
@@ -784,24 +793,23 @@ public class HouseController extends BaseController {
|
|
|
|
|
|
|
|
|
/***
|
|
|
- * 获取唯一场景码
|
|
|
+ * 从四维看看获取唯一场景码
|
|
|
*/
|
|
|
private String getSceneCode(){
|
|
|
- String randowString = null;
|
|
|
- Condition condition = new Condition(HouseEntity.class);
|
|
|
-
|
|
|
- List<HouseEntity> all = null;
|
|
|
-
|
|
|
- boolean flag = true;
|
|
|
- while (flag) {
|
|
|
- randowString = RandomUtils.randowString(9);
|
|
|
- condition.and().andEqualTo("sceneCode", randowString);
|
|
|
- all = houseService2.findAll(condition);
|
|
|
- log.info(all.size());
|
|
|
- flag = all.size() > 0;
|
|
|
- }
|
|
|
- log.info("code: {}", randowString);
|
|
|
- return "d_" + randowString;
|
|
|
+ String url = KankanHost + "api/scene/finSkSceneNum";
|
|
|
+ String kankanResult = HttpClientUtil.doPost(url);
|
|
|
+ //解析返回结果
|
|
|
+ JSONObject res = JSONObject.parseObject(kankanResult);
|
|
|
+ log.info("四维看看返回登录数据:{}" , null != res ? res.toJSONString() : "返回结果为null");
|
|
|
+ Integer code = DataUtils.getInteger(res.get("code"));
|
|
|
+ if(null == code || code.compareTo(0) != 0){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "从四维看看获取场景码失败");
|
|
|
+ }
|
|
|
+ String sceneCode = res.getString("msg");
|
|
|
+ if(StringUtils.isBlank(sceneCode)){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "四维看看返回的场景码为空");
|
|
|
+ }
|
|
|
+ return sceneCode;
|
|
|
}
|
|
|
|
|
|
|