管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-20 dd5ae83a6e574322e6fc5b851134fa4c40c99627
1
已修改2个文件
32 ■■■■■ 文件已修改
src/main/java/com/lf/server/helper/GdbHelper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/DataLibService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/GdbHelper.java
@@ -326,7 +326,7 @@
    /**
     * 创建GDB
     */
    public static void createGdb(String filePath,  Map<String, List<?>> map) {
    public static void createGdb(String filePath,  Map<String, List<?>> map) throws Exception {
        Driver driver = null;
        DataSource dataSource = null;
        try {
@@ -358,13 +358,11 @@
                    }
                    List<Field> fields = new ArrayList<>();
                    fields.add(getGeomField(clazz));
                    // fields.add(getGeomField(clazz))
                    getFields(clazz, fields);
                    addLayerField(layer, fields);
                    setLayerData(layer, fields, map.get(key));
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                } finally {
                    if (null != layer) {
                        layer.delete();
@@ -376,6 +374,7 @@
            dataSource.FlushCache();
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw ex;
        } finally {
            GdbHelper.delete(dataSource, driver);
        }
@@ -453,13 +452,13 @@
     * 添加图层字段
     */
    private static void addLayerField(Layer layer, List<Field> list) {
        for (int i = 1, c = list.size(); i < c; i++) {
        for (int i = 0, c = list.size(); i < c; i++) {
            Field f = list.get(i);
            int fieldType = getFieldType(f);
            FieldDefn fd = new FieldDefn(f.getName(), fieldType);
            layer.CreateField(fd, i);
            layer.CreateField(fd, i + 1);
        }
    }
@@ -496,7 +495,7 @@
            Geometry geom = Geometry.CreateFromWkt(geoEntity.getGeom());
            f.SetGeometry(geom);
            for (int i = 1, c = fields.size(); i < c; i++) {
            for (int i = 0, c = fields.size(); i < c; i++) {
                Field field = fields.get(i);
                Object val = field.get(t);
                if (null == val) {
@@ -537,15 +536,10 @@
    /**
     * 设置Timestamp
     */
    @SuppressWarnings("AlibabaRemoveCommentedCode")
    private static void setTimestamp(Feature f, int i, Timestamp time) {
        if (null == time) {
            return;
        }
        //Calendar now = Calendar.getInstance();
        //now.setTimeInMillis(time.getTime());
        // f.SetField(i, now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, now.get(Calendar.DATE), now.get(Calendar.HOUR), now.get(Calendar.MINUTE), now.get(Calendar.SECOND), 8);
        LocalDateTime local = time.toLocalDateTime();
        f.SetField(i, local.getYear(), local.getMonthValue(), local.getDayOfMonth(), local.getHour(), local.getMinute(), local.getSecond(), 8);
src/main/java/com/lf/server/service/show/DataLibService.java
@@ -33,23 +33,17 @@
    /**
     * 创建Zip包
     */
    public String createZipFile(UserEntity ue, List<String> entities, String wkt, String pwd) {
    public String createZipFile(UserEntity ue, List<String> entities, String wkt, String pwd) throws Exception {
        Map<String, List<?>> map = queryData(entities, wkt);
        if (map.size() == 0) {
            return null;
        }
        //String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
        //String tempPath = pathHelper.getTempPath(tempName);
        //String filePath = tempPath + File.separator + tempName + ".gdb";
        String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
        String tempPath = pathHelper.getTempPath(tempName);
        String filePath = tempPath + File.separator + tempName + ".gdb";
        String filePath = "D:\\LF\\temp\\20221219202706\\20221219202705.gdb";
        File file = new File(filePath);
        if (!file.exists() || !file.isDirectory()) {
            file.mkdirs();
        }
        filePath = "D:\\LF\\temp\\20221219202706\\2022.gdb";
        if (file.exists() && file.isDirectory()) {
            FileHelper.deleteDir(filePath);
        }