|
@@ -2,6 +2,7 @@ package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import com.fdkankan.indoor.base.constant.CmdConstant;
|
|
|
+import com.fdkankan.indoor.base.constant.MsgCode;
|
|
|
import com.fdkankan.indoor.base.convert.ImageClipUtil;
|
|
|
import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
|
import com.fdkankan.indoor.base.util.CmdUtils;
|
|
@@ -36,15 +37,15 @@ public class MapServiceImpl extends IBaseServiceImpl implements MapService {
|
|
|
|
|
|
private MapEntity findById(String sceneCode){
|
|
|
Optional<MapEntity> optional = entityMapper.findById(sceneCode);
|
|
|
- // 处理是否登录
|
|
|
- MapEntity entity = optional.get();
|
|
|
- return entity;
|
|
|
+ if (!optional.isPresent()) {
|
|
|
+ throw new BaseRuntimeException(MsgCode.e3001, "对象不存在");
|
|
|
+ }
|
|
|
+ return optional.get();
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Result upload(String sceneCode, MapDto param) {
|
|
|
- MultipartFile file = param.getFile();
|
|
|
+ public Result upload(String sceneCode, MultipartFile file) {
|
|
|
if (file == null) {
|
|
|
throw new BaseRuntimeException(5003, "文件不能为空");
|
|
|
}
|
|
@@ -70,33 +71,41 @@ public class MapServiceImpl extends IBaseServiceImpl implements MapService {
|
|
|
String tilePath = basePath + "tile";
|
|
|
clipImage(savePath, tilePath);
|
|
|
|
|
|
- // step3: 初始化小地图数据
|
|
|
- initMap(sceneCode, tilePath, param);
|
|
|
-
|
|
|
// step4: 切图上传oss
|
|
|
ossUploadDir(sceneCode, tilePath);
|
|
|
|
|
|
-
|
|
|
- return Result.success();
|
|
|
+ Object ossPath = sceneCode + "/data/tile/0/0/0.png";
|
|
|
+ log.info("返回前端小地图oss地址:{}", ossPath);
|
|
|
+ return Result.success(ossPath);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Result getTiledMap(String sceneCode) {
|
|
|
MapEntity entity = findById(sceneCode);
|
|
|
return Result.success(entity.getData());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result init(String sceneCode, MapDto param) {
|
|
|
+ // step3: 初始化小地图数据
|
|
|
+ String tilePath = configConstant.serverBasePath + "/" + sceneCode +"/map/tile";
|
|
|
+ initMap(sceneCode, tilePath, param);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化小地图数据
|
|
|
* @param sceneCode
|
|
|
- * @param basePath
|
|
|
+ * @param tilePath
|
|
|
*/
|
|
|
- private void initMap(String sceneCode, String basePath, MapDto param){
|
|
|
+ private void initMap(String sceneCode, String tilePath, MapDto param){
|
|
|
|
|
|
MapPo po = new MapPo();
|
|
|
po.setId(1);
|
|
|
po.setBundle_id(3);
|
|
|
- po.setFile_path(basePath);
|
|
|
+ po.setFile_path(tilePath);
|
|
|
po.setFile_name("$DEPTH/$X/$Y.png");
|
|
|
po.setFloor_id(11);
|
|
|
po.setMap_size_m(61.44);
|