| | |
| | | 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.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | public class ShpToDataSourceServiceImpl implements ShpToDataSourceService { |
| | | @Autowired |
| | | private ShpToDataSourceMapper mapper; |
| | | |
| | | private int createTime = 0; |
| | | private int updateTime = 0; |
| | | |
| | | 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 ,String workspaceId) 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; |
| | | patches.setBsm(UUID.randomUUID().toString()); |
| | | patches.setCreateTime(createTime); |
| | | patches.setUpdateTime(updateTime); |
| | | patches.setDkfw(json); |
| | | patches.setDkbh(Land+count); |
| | | mapper.insert(patches); |
| | | String uuid = UUID.randomUUID().toString(); |
| | | String bsm = uuid.replaceAll("-", ""); |
| | | lotInfo.setBsm(bsm); |
| | | lotInfo.setWorkspaceId(workspaceId); |
| | | lotInfo.setDkfw(json); |
| | | lotInfo.setDkbh("dkbh"+i); |
| | | mapper.insert(lotInfo); |
| | | list.add(lotInfo); |
| | | System.out.println(lotInfo); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |