| | |
| | | package com.dji.sample.patches.service.impl; |
| | | |
| | | import com.dji.sample.patches.dao.ShpToDataSourceMapper; |
| | | import com.dji.sample.patches.model.entity.PatchesEntity; |
| | | import com.dji.sample.patches.service.ShpToDataSourceService; |
| | | import com.dji.sample.patches.utils.FormatConversionUtil; |
| | | import com.dji.sample.patches.utils.MultipartFileTOFileUtil; |
| | | import com.dji.sample.patches.utils.ShapeFileUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import static org.locationtech.jts.io.WKTConstants.POLYGON; |
| | | |
| | | @Service |
| | | public class ShpToDataSourceServiceImpl implements ShpToDataSourceService { |
| | | @Autowired |
| | |
| | | |
| | | private int createTime=0; |
| | | private int updateTime=0; |
| | | String head = POLYGON; |
| | | String json; |
| | | |
| | | private String bsm; |
| | | public void insertGeo(MultipartFile file) throws IOException { |
| | | ShapeFileUtil shapeFileUtil=new ShapeFileUtil(); |
| | | PatchesEntity patches = new PatchesEntity(); |
| | | MultipartFileTOFileUtil multipartFileTOFileUtil = new MultipartFileTOFileUtil(); |
| | | File file1= multipartFileTOFileUtil.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("]],"); |
| | | List<String> s = ShapeFileUtil.shpToGeoJson(file1); |
| | | String[] arr1 = FormatConversionUtil.formatConversion(s); |
| | | 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); |
| | | String temp = arr1[i].trim(); |
| | | temp = FormatConversionUtil.modifySpacesAndCommas(temp); |
| | | json = head + temp; |
| | | patches.setBsm(UUID.randomUUID().toString()); |
| | | patches.setCreateTime(createTime); |
| | | patches.setUpdateTime(updateTime); |
| | | patches.setDkfw(json); |
| | | mapper.insert(patches); |
| | | } |
| | | } |
| | | |