| | |
| | | package com.se.simu.service; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | |
| | | import com.se.simu.domain.SeField; |
| | | import com.se.simu.domain.SeLayer; |
| | | import com.se.simu.helper.RsaHelper; |
| | | import com.se.simu.helper.ShpHelper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class SedbService { |
| | | @Value("${sys.path.in}") |
| | | String inPath; |
| | | |
| | | @Value("${sedb.host}") |
| | | String host; |
| | | |
| | |
| | | |
| | | String password; |
| | | |
| | | |
| | | @Resource |
| | | RestTemplate restTemplate; |
| | | |
| | | public String test() throws Exception { |
| | | public boolean test() throws Exception { |
| | | // 469538.6536261877,4416744.922022615,469853.14714664617,4417049.378602433 |
| | | String bbox = "116.64388473935195,39.884315914604464,116.64754729082588,39.887069143903496"; |
| | | |
| | | String token = getToken(); |
| | |
| | | List<SeLayer> layers = getLayers(token, db.getDbid()); |
| | | queryData(token, db, layers); |
| | | |
| | | return db.getDbid(); |
| | | createShps(inPath + "\\20240913", layers); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | public String getToken() throws Exception { |
| | |
| | | } |
| | | } |
| | | |
| | | public int getCount(String token, SeDb db, SeLayer layer) { |
| | | private int getCount(String token, SeDb db, SeLayer layer) { |
| | | Map<String, Object> map = new HashMap<>(6); |
| | | map.put("token", token); |
| | | map.put("dbid", db.getDbid()); |
| | |
| | | return obj.getInt("data"); |
| | | } |
| | | |
| | | public JSONArray query(String token, SeDb db, SeLayer layer, int start, int count) { |
| | | private JSONArray query(String token, SeDb db, SeLayer layer, int start, int count) { |
| | | Map<String, Object> map = new HashMap<>(9); |
| | | map.put("token", token); |
| | | map.put("start", start); |
| | |
| | | |
| | | return data.getJSONArray("features"); |
| | | } |
| | | |
| | | public void createShps(String basePath, List<SeLayer> layers) throws Exception { |
| | | File f = new File(basePath); |
| | | if (f.exists() && f.isDirectory()) { |
| | | FileUtil.del(f); |
| | | } |
| | | f.mkdirs(); |
| | | |
| | | for (SeLayer layer : layers) { |
| | | String path = String.format("%s\\%s.shp", basePath, layer.getShpName()); |
| | | if (!ShpHelper.createShp(path, layer)) { |
| | | throw new Exception(layer.getName() + ",创建ShapeFile文件失败!"); |
| | | } |
| | | } |
| | | } |
| | | } |