管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-22 1abeb69a19d26ee0be425770d0544244e81ee822
1
已修改2个文件
60 ■■■■■ 文件已修改
data/db_fn.sql 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/GdbHelper.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_fn.sql
@@ -341,6 +341,22 @@
select * from lf.sys_dict where ns='bd' and tab='dlg_agnp';
select count(distinct tab) from lf.sys_dict where tab like '%b_b%';
select * from bd.b_borehole where endholtime <= '1978-06-29' limit 10;
select c.relname tab, cast(obj_description(c.oid) as varchar) desc, a.attnum num, a.attname col, t.typname type, d.description bak
from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join
pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and
relnamespace in (29258) order by c.relname;
select t.typname type
from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join
pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and
relnamespace in (29258) group by type;
src/main/java/com/lf/server/helper/GdbHelper.java
@@ -243,6 +243,9 @@
    private static <T> void setValue(T t, Feature f, Field field, Integer i) throws Exception {
        switch (field.getType().getName()) {
            case "java.math.BigDecimal":
                double dd = f.GetFieldAsDouble(i);
                field.set(t, new BigDecimal(dd));
                break;
            case "java.lang.Double":
            case "double":
                field.set(t, f.GetFieldAsDouble(i));
@@ -257,6 +260,9 @@
                break;
            case "java.sql.Timestamp":
                field.set(t, getTimestamp(f, i));
                break;
            case "java.time.LocalDate":
                field.set(t, getLocalDate(f, i));
                break;
            default:
                field.set(t, f.GetFieldAsString(i));
@@ -322,6 +328,23 @@
        );
        return Timestamp.valueOf(localDateTime);
    }
    /**
     * 获取 LocalDate
     */
    private static LocalDate getLocalDate(Feature f, int index) {
        int[] pnYear = new int[1];
        int[] pnMonth = new int[1];
        int[] pnDay = new int[1];
        int[] pnHour = new int[1];
        int[] pnMinute = new int[1];
        float[] pfSecond = new float[1];
        int[] pnTzFlag = new int[1];
        f.GetFieldAsDateTime(index, pnYear, pnMonth, pnDay, pnHour, pnMinute, pfSecond, pnTzFlag);
        return LocalDate.of(pnYear[0], pnMonth[0], pnDay[0]);
    }
    /**
@@ -482,6 +505,8 @@
                return ogr.OFTInteger;
            case "java.sql.Timestamp":
                return ogr.OFTDateTime;
            case "java.time.LocalDate":
                return ogr.OFTDate;
            default:
                return ogr.OFTString;
        }
@@ -526,8 +551,12 @@
                        f.SetField(i, n);
                        break;
                    case "java.sql.Timestamp":
                        Timestamp time = (Timestamp) field.get(t);
                        setTimestamp(f, i, time);
                        Timestamp timestamp = (Timestamp) field.get(t);
                        setTimestamp(f, i, timestamp);
                        break;
                    case "java.time.LocalDate":
                        LocalDate localDate = (LocalDate) field.get(t);
                        setLocalDate(f, i, localDate);
                        break;
                    default:
                        String str = (String) val;
@@ -550,4 +579,15 @@
        LocalDateTime local = time.toLocalDateTime();
        f.SetField(i, local.getYear(), local.getMonthValue(), local.getDayOfMonth(), local.getHour(), local.getMinute(), local.getSecond(), 8);
    }
    /**
     * 设置LocalDate
     */
    private static void setLocalDate(Feature f, int i, LocalDate local) {
        if (null == local) {
            return;
        }
        f.SetField(i, local.getYear(), local.getMonthValue(), local.getDayOfMonth(), 0, 0, 0, 8);
    }
}