| | |
| | | package com.dji.sample.patches.service.impl; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.dji.sample.patches.dao.DemoMapper; |
| | | import com.dji.sample.patches.service.DemoService; |
| | | import com.dji.sample.patches.utils.MultipartFileTOFile; |
| | | import com.dji.sample.patches.utils.ShapeFileUtil; |
| | | import com.dji.sample.patches.utils.ZipUtil; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @Service |
| | | public class DemoServiceImpl implements DemoService { |
| | | @Autowired |
| | | private DemoMapper mapper; |
| | | private ShapeFileUtil shapeFileUtil; |
| | | @Override |
| | | |
| | | public void insertGeo(File file) throws IOException { |
| | | System.out.println(shapeFileUtil.shpToGeoJson(file)); |
| | | private int createTime=0; |
| | | private int updateTime=0; |
| | | |
| | | private String bsm; |
| | | public void insertGeo(MultipartFile file) throws IOException { |
| | | ShapeFileUtil shapeFileUtil=new ShapeFileUtil(); |
| | | MultipartFileTOFile multipartFileTOFile= new MultipartFileTOFile(); |
| | | File file1= multipartFileTOFile.multipartFile2File(file); |
| | | List<String> s=shapeFileUtil.shpToGeoJson(file1); |
| | | String[] arr=new String[10]; |
| | | String str=s.toString(); |
| | | String ses=str.substring(0, str.length()-3); |
| | | String[] arr1=ses.split("]],"); |
| | | for (int i = 0; i < arr1.length; i++) { |
| | | bsm=UUID.randomUUID().toString()+1; |
| | | String json= arr1[i].substring(3); |
| | | arr[i]=json; |
| | | mapper.insertJson(json,bsm,createTime,updateTime); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |