13693261870
2024-09-23 a9935306b55b60b24dd2a4c6aadd8f8ee433aecf
添加数据处理流程
已修改3个文件
100 ■■■■■ 文件已修改
src/main/java/com/se/simu/domain/po/DataPo.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/GedbService.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/SimuService.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/domain/po/DataPo.java
@@ -63,7 +63,20 @@
    @ApiModelProperty("防汛最大Y")
    private Double floodMaxy;
    @ApiModelProperty("坐标系ID")
    private Integer epsg;
    public DataPo() {
    }
    public void setPath(String inPath, String outPath) {
        this.inPath = inPath;
        this.outPath = outPath;
    }
    public String getBbox() {
        // "116.64388473935195,39.884315914604464,116.64754729082588,39.887069143903496";
        return minx + "," + miny + "," + maxx + "," + maxy;
    }
    public DataPo(String name, String inPath, String outPath, Double total, Integer duration, Integer isFlood) {
@@ -85,11 +98,6 @@
        this.maxy = maxy;
        this.total = total;
        this.duration = duration;
    }
    public void setPath(String inPath, String outPath) {
        this.inPath = inPath;
        this.outPath = outPath;
    }
    public boolean setExtent(Double minx, Double miny, Double maxx, Double maxy) {
@@ -264,4 +272,12 @@
    public void setFloodMaxy(Double floodMaxy) {
        this.floodMaxy = floodMaxy;
    }
    public Integer getEpsg() {
        return epsg;
    }
    public void setEpsg(Integer epsg) {
        this.epsg = epsg;
    }
}
src/main/java/com/se/simu/service/GedbService.java
@@ -8,6 +8,7 @@
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;
@@ -105,14 +106,6 @@
        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);
@@ -125,7 +118,7 @@
        return data.getStr("token");
    }
    public String getPassword() throws Exception {
    private String getPassword() throws Exception {
        if (StringHelper.isEmpty(password)) {
            String key = getPublicKey();
            RsaHelper.setPublicKey(key);
@@ -135,7 +128,7 @@
        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);
@@ -245,7 +238,12 @@
        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)) {
@@ -254,7 +252,18 @@
        }
    }
    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");
@@ -265,7 +274,7 @@
        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);
@@ -282,7 +291,7 @@
        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);
@@ -292,7 +301,7 @@
        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();
src/main/java/com/se/simu/service/SimuService.java
@@ -8,6 +8,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.se.simu.domain.dto.GeDb;
import com.se.simu.domain.dto.GeLayer;
import com.se.simu.domain.po.DataPo;
import com.se.simu.domain.po.SimuPo;
import com.se.simu.domain.vo.CreateSimuVo;
@@ -142,10 +144,11 @@
    }
    private void createDir(String path) {
        File dir = new File(path);
        if (!dir.exists() || !dir.isDirectory()) {
            dir.mkdirs();
        File f = new File(path);
        if (f.exists() && f.isDirectory()) {
            FileUtil.del(f);
        }
        f.mkdirs();
    }
    private void asyncCall(SimuPo simu) {
@@ -166,18 +169,28 @@
    private void scope(SimuPo simu) {
        try {
            DataPo data = JSONUtil.toBean(simu.getData(), DataPo.class);
            update(simu, 1, null);
            String token = gedbService.getToken();
            GeDb db = gedbService.getSeDb(token);
            db.setBbox(data.getBbox());
            data.setEpsg(db.getEpsg());
            //boolean flag = tifService.splitTif(dsd);
            //update(simu, flag ? 2 : 20, flag ? null : "切分数据出错");
            //if (!flag) return;
            update(simu, 2, null);
            List<GeLayer> layers = gedbService.getLayers(token, db);
            gedbService.queryData(token, db, layers);
            gedbService.copeVectors(data, layers);
            //flag = aiService.sendRequest(task.getDataType(), dsd.getDataTime());
            //update(simu, flag ? 3 : 20, flag ? null : "识别数据出错");
            //if (!flag) return;
            update(simu, 3, null);
            gedbService.copeDem(token, data);
            //flag = geoJsonService.processResults(task, dsd);
            //update(simu, flag ? 10 : 20, flag ? "执行完成" : "处理结果出错");
            update(simu, 4, null);
            // 模拟内涝仿真
            //update(simu, 5, null);
            // 处理仿真数据
            //update(simu, 10, "完成");
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            update(simu, -10, ex.getMessage());