From a28b0a7d0939020debd58550be1bb6bb8a413b7f Mon Sep 17 00:00:00 2001
From: ke <893754509@qq.com>
Date: Tue, 21 May 2024 09:02:22 +0800
Subject: [PATCH] 全景图更新切图功能kl 5-21 9
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/skPanorama/controller/SkPanoramaController.java | 99 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 80 insertions(+), 19 deletions(-)
diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/skPanorama/controller/SkPanoramaController.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/skPanorama/controller/SkPanoramaController.java
index 8733293..bba7d9f 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/skPanorama/controller/SkPanoramaController.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/skPanorama/controller/SkPanoramaController.java
@@ -45,6 +45,8 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.gistack.sm.skPanorama.entity.SkPanoramaEntity;
@@ -85,6 +87,7 @@
/**
* 对象存储构建类
*/
+ @Autowired
private final IOssClient iOssClient;
@@ -268,13 +271,43 @@
}
*/
+ /**
+ * 批量切图
+ * @param ids
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ * @throws IM4JavaException
+ * @throws IllegalAccessException
+ */
+ @PostMapping("/cutPicBatch")
+ public R cutPicBatch(@RequestParam String ids) throws IOException, InterruptedException, IM4JavaException, IllegalAccessException {
+ List<Long> idlist = Func.toLongList(ids);
+ if (idlist!= null && idlist.size()>0) {
+ for (Long id : idlist ) {
+ SkPanoramaEntity entity = skPanoramaService.getById(id);
+ Integer status = entity.getStatus();
+ String resGuname = entity.getResGuname();
+ String name = entity.getName();
+ if (PanoramaUtilDict.panorama_status_3 == status) continue;
+ R r = cutPicture2(entity);
+ boolean success = r.isSuccess();
+ if (!success) {
+ return R.fail(resGuname+"-"+name+" 切图失败!");
+ }
+
+ }
+ }
+ return R.status(true);
+ }
+
private static final String linShiBaseUrl = "/data/panorama/qietu/";
@GetMapping("/cutPicture2")
public R cutPicture2(SkPanoramaEntity skPanorama)
throws IOException, InterruptedException, IM4JavaException, IllegalAccessException {
- SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama));
+ SkPanoramaEntity entity = skPanoramaService.getById(skPanorama.getId());
String picUrl = entity.getPicUrl();
String picName = entity.getPicName();
String resGuid = entity.getResGuid();
@@ -283,7 +316,7 @@
String dirPath = linShiBaseUrl + resGuid + "/"; //临时文件夹路径
String lingshiPic = linShiBaseUrl + resGuid + "/" + picName; //临时文件
- File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity);
+ File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity.getId());
/**
* 这里开始切图
@@ -329,8 +362,6 @@
/************************************切图结束********************************************/
// 上传切片全景图
- System.err.println("切图的路径数量"+qietuHashMap.size());
- System.err.println("水库编码"+resGuid);
QieTuEntity qieTuEntity = new QieTuEntity();
qieTuEntity.setQietuHashMap(qietuHashMap);
@@ -350,17 +381,19 @@
entity.setUrlhead(urlHead);
entity.setQierow(row);
entity.setQiecol(col);
- entity.setPicwidth(width);
- entity.setPicheight(height);
+// entity.setPicwidth(width);
+// entity.setPicheight(height);
entity.setStatus(PanoramaUtilDict.panorama_status_3);
- skPanoramaService.updateById(entity);
+ boolean b = skPanoramaService.updateById(entity);
- return R.status(true);
+ return R.status(b);
}
- private File getquanjingFile (String dirPath ,String linshiUrl , SkPanoramaEntity skPanorama) throws IOException {
- SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama));
+ private File getquanjingFile (String dirPath ,String linshiUrl , Long id) throws IOException {
+
+// SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama));
+ SkPanoramaEntity entity = skPanoramaService.getById(id);
String picUrl = entity.getPicUrl();
String picName = entity.getPicName();
String resGuid = entity.getResGuid();
@@ -368,7 +401,7 @@
File dir = new File(dirPath);
if (dir.isDirectory()) {
// 清除该目录下的文件及子目录文件而不删除该目录文件夹。该目录不存在会报错
- FileUtils.cleanDirectory(dir);
+// FileUtils.cleanDirectory(dir);
} else {
dir.mkdirs();
}
@@ -401,14 +434,20 @@
ArrayList<SkPanoramaEntity> panoramalist = new ArrayList<SkPanoramaEntity>();
+ // 已上传的全景图已符合比例,仅用改变数据状态
+ ArrayList<SkPanoramaEntity> justUpdateStatusList = new ArrayList<SkPanoramaEntity>();
+
ArrayList<FormateTuEntity> list = new ArrayList<FormateTuEntity>();
+
+
if (idlist!= null && idlist.size()>0) {
for (Long id : idlist ) {
FormateTuEntity formateTuEntity = new FormateTuEntity();
- SkPanoramaEntity skPanorama = new SkPanoramaEntity();
- skPanorama.setId(id);
- SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama));
+
+ SkPanoramaEntity entity = skPanoramaService.getById(id);
+ Integer status = entity.getStatus();
+ if (PanoramaUtilDict.panorama_status_2 == status) continue;
String picUrl = entity.getPicUrl();
String picName = entity.getPicName();
String resGuid = entity.getResGuid();
@@ -420,13 +459,14 @@
String lingshigeshibilipath = linShiformateBaseUrl + resGuid + "/geshibili/" ;
String lingshigeshibiliPic = lingshigeshibilipath + picName; //格式化后的临时文件
- File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity);
+ File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,id);
// 创建文件夹
File lingshigeshibilidir = new File(lingshigeshibilipath);
if (lingshigeshibilidir.isDirectory()) {
// 清除该目录下的文件及子目录文件而不删除该目录文件夹。该目录不存在会报错
- FileUtils.cleanDirectory(lingshigeshibilidir);
+// FileUtils.cleanDirectory(lingshigeshibilidir);
+ // 批量操作不能清空文件夹下的全部文件
} else {
lingshigeshibilidir.mkdirs();
}
@@ -438,7 +478,14 @@
Integer height = imgInfoRT.get("height");
if (width == height * 2) {
// 已经符合格式化标准
-
+ SkPanoramaEntity upEntity = new SkPanoramaEntity();
+ upEntity.setId(id);
+ upEntity.setPicheight(height);
+ upEntity.setPicwidth(width);
+ upEntity.setStatus(PanoramaUtilDict.panorama_status_2);
+ justUpdateStatusList.add(upEntity);
+// boolean b = skPanoramaService.updateById(upEntity);
+// return R.status( b);
} else {
Integer newWidth = height * 2;
// 图片格式化
@@ -491,9 +538,23 @@
}
}
- boolean b = skPanoramaService.updateBatchById(panoramalist);
+ boolean b = false;
+ if (panoramalist != null && panoramalist.size()>0) {
+ b = skPanoramaService.updateBatchById(panoramalist);
+ } else {
+ b = true;
+ }
- return R.status(true);
+ boolean formatB = false;
+ // 已上传的全景图已符合比例,仅用改变数据状态
+ if (panoramalist != null && panoramalist.size()>0) {
+ formatB = skPanoramaService.updateBatchById(justUpdateStatusList);
+ } else {
+ formatB = true;
+ }
+
+
+ return R.status((formatB && b));
}
--
Gitblit v1.9.3