From bc16d0f0fc46ca6cb7d9bfb8496ad8f20ffba677 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Mon, 06 May 2024 14:53:52 +0800
Subject: [PATCH] 修改DB库相关问题
---
src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java b/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
index a5be0c5..9adf2ed 100644
--- a/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
+++ b/src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
@@ -14,6 +14,7 @@
import com.dji.sample.territory.dao.ITbFjMapper;
import com.dji.sample.territory.model.entity.TbDkjbxxEntity;
import com.dji.sample.territory.model.entity.TbFjEntity;
+import com.dji.sample.territory.model.entity.param.UploadUrlParam;
import com.dji.sample.territory.pojo.TerritoryConfigPojo;
import com.dji.sample.territory.service.ITbDkjbxxService;
import org.locationtech.jts.geom.Coordinate;
@@ -27,6 +28,7 @@
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -47,6 +49,8 @@
public class TbDkjbxxServiceImpl extends ServiceImpl<ITbDkjbxxMapper, TbDkjbxxEntity> implements ITbDkjbxxService {
@Autowired
private ITbDkjbxxMapper iTbDkjbxxMapper;
+ @Autowired
+ private TbFjServiceImpl tbFjService;
@Autowired
private PatchesConfigPojo patchesConfigPojo;
@Autowired
@@ -111,6 +115,37 @@
return convert(new File(destKMZFile));
}
+ @Override
+ public ResponseResult uploadUrl(String url) {
+ if (url.isEmpty()) {
+ throw new IllegalArgumentException("上传文件为空");
+ }
+ downloadFile(url);
+ return ResponseResult.success();
+ }
+ public File downloadFile(String fileUrl) {
+ File downloadedFile = null;
+ try {
+ URL url = new URL(fileUrl);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ InputStream inputStream = connection.getInputStream();
+ downloadedFile = new File(territoryConfigPojo.getPath());
+ OutputStream outputStream = new FileOutputStream(downloadedFile);
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ inputStream.close();
+ outputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return downloadedFile;
+ }
+
/**
* 将TbDkjbxxEntity类型的列表转换为LotInfo类型的列表。
*
@@ -120,25 +155,14 @@
private List<LotInfo> dbConvertToEntity(List<TbDkjbxxEntity> list) {
List<LotInfo> infos = new ArrayList<>();
for (TbDkjbxxEntity file : list) {
- double[] coordinates = extractCoordinates(pointCGCStoWGS(file.getXzb(), file.getYzb()));
// 使用Builder模式构建LotInfo对象
LotInfo.LotInfoBuilder builder = LotInfo.builder();
if (file != null) {
// 从TbDkjbxxEntity实体中提取信息,构建LotInfo对象
- builder.bsm(file.getBsm())
- .bz(file.getBz())
- .dkmj(file.getDkmj())
- .dkmc(file.getDkmc())
- .dkbh(file.getDkbh())
- .xmc(file.getXmc())
- .xzb(coordinates[0])
- .sfbhzdk(file.getSfbhzdk())
- .sjlx(file.getSjlx())
- .dkfw(poylonCGCStoWGS(file.getDkfw()))
- .xzqdm(file.getXzqdm())
- .yzb(coordinates[1])
- .kzxx(file.getKzxx())
- .dklx(file.getDklx())
+ builder.bsm(file.getFId())
+ .dkbh(file.getFTbbh())
+ .dkfw(file.getFShape())
+ .xzqdm(file.getFXzqdmsys())
.build();
// 将构建好的LotInfo对象添加到infos列表中
infos.add(builder.build());
--
Gitblit v1.9.3