From a83ae77a98e235cdca07a1bb167a9a43479a2c9a Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Thu, 28 Mar 2024 16:54:20 +0800
Subject: [PATCH] 新增图斑数据返回
---
src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java | 4 +++-
src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java | 8 +++++---
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java | 21 +++++++++++----------
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java b/src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java
index 689f096..97e77af 100644
--- a/src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java
+++ b/src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java
@@ -1,6 +1,7 @@
package com.dji.sample.patches.controller;
import com.dji.sample.common.model.ResponseResult;
+import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.impl.ShpToDataSourceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -8,6 +9,7 @@
import java.io.IOException;
+import java.util.List;
@RestController
@RequestMapping("${url.patches.prefix}${url.patches.version}")
@@ -15,9 +17,9 @@
@Autowired
private ShpToDataSourceServiceImpl shpToDataSourceServiceImpl;
@PostMapping("/getGeo")
- public ResponseResult getGeo (@RequestParam("file") MultipartFile file) throws IOException {
- shpToDataSourceServiceImpl.insertGeo(file);
- return ResponseResult.success();
+ public ResponseResult<List<LotInfo>> getGeo (@RequestParam("file") MultipartFile file) throws IOException {
+ List<LotInfo> list=shpToDataSourceServiceImpl.insertGeo(file);
+ return ResponseResult.success(list);
}
diff --git a/src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java b/src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java
index 42912a6..d819420 100644
--- a/src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java
+++ b/src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java
@@ -1,8 +1,10 @@
package com.dji.sample.patches.service;
+import com.dji.sample.patches.model.entity.LotInfo;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.util.List;
public interface ShpToDataSourceService {
- void insertGeo(MultipartFile file) throws IOException;
+ List<LotInfo> insertGeo(MultipartFile file) throws IOException;
}
diff --git a/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
index cfccfec..4fc7f0b 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -21,29 +22,29 @@
public class ShpToDataSourceServiceImpl implements ShpToDataSourceService {
@Autowired
private ShpToDataSourceMapper mapper;
-
- String Land = "N1C1D";
String head = POLYGON;
String json;
-
- public void insertGeo(MultipartFile file) throws IOException {
- LotInfo patches = new LotInfo();
+ public List<LotInfo> insertGeo(MultipartFile file) throws IOException {
+ List<LotInfo> list=new ArrayList<>();
MultipartFileTOFileUtil multipartFileTOFileUtil = new MultipartFileTOFileUtil();
File file1 = multipartFileTOFileUtil.multipartFile2File(file);
List<String> s = ShapeFileUtil.shpToGeoJson(file1);
String[] arr1 = FormatConversionUtil.formatConversion(s);
for (int i = 0; i < arr1.length; i++) {
- int count = mapper.selectCount(null) + 1;
+ LotInfo lotInfo = new LotInfo();
String temp = arr1[i].trim();
temp = FormatConversionUtil.modifySpacesAndCommas(temp);
json = head + temp;
String uuid = UUID.randomUUID().toString();
String bsm = uuid.replaceAll("-", "");
- patches.setBsm(bsm);
- patches.setDkfw(json);
- patches.setDkbh(Land + count);
- mapper.insert(patches);
+ lotInfo.setBsm(bsm);
+ lotInfo.setDkfw(json);
+ lotInfo.setDkbh("dkbh"+i);
+ mapper.insert(lotInfo);
+ list.add(lotInfo);
+ System.out.println(lotInfo);
}
+ return list;
}
}
--
Gitblit v1.9.3