| | |
| | | return; |
| | | } |
| | | |
| | | String stage = getPipeStage(tabName); |
| | | String name = FileHelper.getName(mf.getPath()); |
| | | List<?> list = createKmlEntity(clazz, wkt, name); |
| | | List<?> list = createKmlEntity(clazz, wkt, name, mf, stage); |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | /** |
| | | * 创建KML实体类 |
| | | */ |
| | | private <T> List<T> createKmlEntity(Class clazz, String wkt, String name) { |
| | | private <T> List<T> createKmlEntity(Class clazz, String wkt, String name, MetaFileEntity mf, String stage) { |
| | | try { |
| | | T t = (T) clazz.newInstance(); |
| | | |
| | | Field gField = clazz.getSuperclass().getDeclaredField("geom"); |
| | | gField.setAccessible(true); |
| | | gField.set(t, null == wkt ? "null" : String.format("ST_GeomFromText('%s')", wkt)); |
| | | |
| | | Field pField = clazz.getDeclaredField("pipename"); |
| | | pField.setAccessible(true); |
| | | pField.set(t, name); |
| | | setEntityVal(clazz.getSuperclass(), t, "geom", null == wkt ? "null" : String.format("ST_GeomFromText('%s')", wkt)); |
| | | setEntityVal(clazz, t, "pipename", name); |
| | | setEntityVal(clazz, t, "projname", name); |
| | | setEntityVal(clazz, t, "medium", mf.getMedium()); |
| | | setEntityVal(clazz, t, "pipestage", stage); |
| | | |
| | | List<T> list = new ArrayList<>(); |
| | | list.add(t); |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置实体值 |
| | | */ |
| | | private <T> void setEntityVal(Class clazz, T t, String field, String val) throws Exception { |
| | | Field pField = clazz.getDeclaredField(field); |
| | | pField.setAccessible(true); |
| | | pField.set(t, val); |
| | | } |
| | | |
| | | /** |
| | | * 获取管道阶段 |
| | | */ |
| | | private String getPipeStage(String tab) { |
| | | switch (tab) { |
| | | case "si.pl_pipeline_f": |
| | | return "可研阶段"; |
| | | case "si.pl_pipeline_b": |
| | | return "初设阶段"; |
| | | case "si.pl_pipeline_d": |
| | | return "施工图阶段"; |
| | | case "si.pl_pipeline_a": |
| | | return "竣工图阶段"; |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | } |