| | |
| | | import com.se.simu.domain.dto.GeField; |
| | | import com.se.simu.domain.dto.GeFile; |
| | | import com.se.simu.domain.dto.GeLayer; |
| | | import com.se.simu.domain.po.DataPo; |
| | | import com.se.simu.helper.RsaHelper; |
| | | import com.se.simu.helper.ShpHelper; |
| | | import com.se.simu.helper.StringHelper; |
| | |
| | | return true; |
| | | } |
| | | |
| | | private void createPath(String basePath) { |
| | | File f = new File(basePath); |
| | | if (f.exists() && f.isDirectory()) { |
| | | FileUtil.del(f); |
| | | } |
| | | f.mkdirs(); |
| | | } |
| | | |
| | | public String getToken() throws Exception { |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("userid", user); |
| | |
| | | return data.getStr("token"); |
| | | } |
| | | |
| | | public String getPassword() throws Exception { |
| | | private String getPassword() throws Exception { |
| | | if (StringHelper.isEmpty(password)) { |
| | | String key = getPublicKey(); |
| | | RsaHelper.setPublicKey(key); |
| | |
| | | return password; |
| | | } |
| | | |
| | | public String getPublicKey() { |
| | | private String getPublicKey() { |
| | | //{"datetime":"2024-09-12 17:24:38","code":200,"data":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtFwJCh2taVTEi05C8qT2oG7Y+rDmJhlO4zicpSeRtiro9LsytePeWI7BXM6sfDU0WeKun1izawcfgGkZgnoJuMBluAOKI1tL0uCrR+DreNLqMVtnXHwoWEIk/hGJedDWaf3q22aGDyEB5h9qCq0JklSShP1Ih4ppap4LmgxdTPQIDAQAB"} |
| | | JSONObject obj = restTemplate.getForObject(host + "account-service/security/publickey", JSONObject.class); |
| | | |
| | |
| | | return data.getJSONArray("features"); |
| | | } |
| | | |
| | | public void createShps(String basePath, List<GeLayer> layers) throws Exception { |
| | | public void copeVectors(DataPo data, List<GeLayer> layers) throws Exception { |
| | | String basePath = inPath + File.separator + data.getInPath(); |
| | | createShps(basePath, layers); |
| | | } |
| | | |
| | | private void createShps(String basePath, List<GeLayer> layers) throws Exception { |
| | | for (GeLayer layer : layers) { |
| | | String path = String.format("%s\\%s.shp", basePath, layer.getShpName()); |
| | | if (!ShpHelper.createShp(path, layer)) { |
| | |
| | | } |
| | | } |
| | | |
| | | public GeDb getFileDb(String token) { |
| | | public void copeDem(String token, DataPo data) throws Exception { |
| | | GeDb fileDb = getFileDb(token); |
| | | String fileId = getFileId(token, fileDb.getDbid()); |
| | | List<GeFile> files = getFileNames(token, fileDb.getDbid(), fileId); |
| | | |
| | | String basePath = inPath + File.separator + data.getInPath(); |
| | | String filePath = inPath + File.separator + fileDb.getDbid(); |
| | | downloadFiles(token, filePath, files, fileDb.getDbid(), fileId); |
| | | clipDemFile(filePath, files, basePath, data.getBbox(), 0); |
| | | } |
| | | |
| | | private GeDb getFileDb(String token) { |
| | | String uri = String.format("%sfile-service/docdb/query/canview?token=%s", host, token); |
| | | JSONObject obj = restTemplate.getForObject(uri, JSONObject.class); |
| | | JSONArray data = obj.getJSONArray("data"); |
| | |
| | | return list.stream().filter(db -> null != db.getName() && db.getName().contains(dbName)).findFirst().orElse(null); |
| | | } |
| | | |
| | | public String getFileId(String token, String dbid) { |
| | | private String getFileId(String token, String dbid) { |
| | | String uri = String.format("%sfile-service/doc/catagory/file/query?token=%s&dbid=%s&catagory=%s&count=%d&start=%d&like=", |
| | | host, token, dbid, "image", 9999, 1); |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | public List<GeFile> getFileNames(String token, String dbid, String fileId) { |
| | | private List<GeFile> getFileNames(String token, String dbid, String fileId) { |
| | | String uri = String.format("%sfile-service/doc/cluster/struct/list?token=%s&dbid=%s&cluster_fileid=%s&onlychild=true&folder_stairs=", |
| | | host, token, dbid, fileId); |
| | | |
| | |
| | | return JSONUtil.toList(data, GeFile.class); |
| | | } |
| | | |
| | | public void downloadFiles(String token, String path, List<GeFile> files, String dbid, String fileId) throws IOException { |
| | | private void downloadFiles(String token, String path, List<GeFile> files, String dbid, String fileId) throws IOException { |
| | | File f = new File(path); |
| | | if (!f.exists() || !f.isDirectory()) { |
| | | f.mkdirs(); |