| | |
| | | select ST_AsText(geom) from bd.dlg_25w_resa limit 1; |
| | | |
| | | -- MultiLineString MultiPolygon Point |
| | | select GeometryType(geom) from bd.dlg_25w_boul; |
| | | select st_srid(geom) from bd.dlg_25w_boul limit 1; |
| | | select GeometryType(geom) from bd.dlg_25w_boul where gid=20; |
| | | select st_srid(geom) from bd.dlg_25w_boul where gid=20 limit 1; |
| | | select ST_AsText(geom) from bd.dlg_agnp where gid=20; |
| | | |
| | | select * from lf.sys_dict where ns='bd' and tab='dlg_25w_boul' and field='geom'; |
| | | select * from lf.sys_meta; -- delete from lf.sys_meta; |
| | |
| | | |
| | | select * from lf.sys_meta_file a where metaid in (99,100,101) |
| | | alter sequence bd.dlg_agnp_gid_seq restart with 4000; |
| | | select * from bd.dlg_agnp; |
| | | select max(gid) from bd.dlg_agnp; |
| | | --to_char(now(),'yyyy-mm-dd hh24:MI:SS') |
| | | select create_time,to_char(create_time,'yyyy-mm-dd hh24:mi:ss') from lf.sys_menu where id=1; |
| | | |
| | | select tab,count(*) from lf.sys_dict d where field='classes' group by tab order by tab |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | select * from bd.dlg_25w_boul where gid<11; -- delete from bd.dlg_25w_boul where gid>10; alter sequence bd.dlg_25w_boul_gid_seq restart with 20; |
| | | select * from bd.dlg_25w_resa where gid<12; -- delete from bd.dlg_25w_resa where gid>11; alter sequence bd.dlg_25w_resa_gid_seq restart with 20; |
| | | select * from bd.dlg_agnp where gid<13; -- delete from bd.dlg_agnp where gid>12; alter sequence bd.dlg_agnp_gid_seq restart with 20; |
| | | select gb,name,classes,pinyin,pac,bsm,geom,eventid,dirid,depid,verid,createtime,createuser,updateuser,updatetime from bd.dlg_agnp |
| | | |
| | | |
| | | |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询表中数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "metaid", value = "元数据ID", dataType = "Integer", paramType = "1") |
| | | @ApiImplicitParam(name = "id", value = "元数据ID", dataType = "Integer", paramType = "1") |
| | | }) |
| | | @GetMapping(value = "/selectDbData") |
| | | public ResponseMsg<Object> selectDbData(Integer metaid) { |
| | | public ResponseMsg<Object> selectDbData(Integer id) { |
| | | try { |
| | | // |
| | | if (null == id || id < 0) { |
| | | return fail("元数据ID不能为空或小于0", null); |
| | | } |
| | | |
| | | MetaEntity meta = metaService.selectById(id); |
| | | if (null == meta || null == meta.getTab() || meta.getTab().indexOf(".") < 0) { |
| | | return fail("找不到元数据信息", null); |
| | | } |
| | | |
| | | String entity = meta.getTab().split(".")[1].replace("_", "").toLowerCase(); |
| | | |
| | | return success(null); |
| | | } catch (Exception ex) { |
| | |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlSource; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 批量插入方法 |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class InsertBatchMethod extends AbstractMethod { |
| | | private static List<String> excludeFields = new ArrayList<>(Arrays.asList("gid", "objectid", "updateuser", "updatetime", "shape_leng", "shape_area")); |
| | | |
| | | /** |
| | | * insert into user(id, name, age) values (1, "a", 17), (2, "b", 18); |
| | | * <script> |
| | |
| | | // fieldSql.append(tableInfo.getKeyColumn()).append(",") |
| | | // tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(",")) |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (GdbHelper.excludeFields.contains(f.getColumn())) { |
| | | if (excludeFields.contains(f.getColumn())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | // valueSql.append("#{item.").append(tableInfo.getKeyProperty()).append("},") |
| | | // tableInfo.getFieldList().forEach(x -> valueSql.append("#{item.").append(x.getProperty()).append("},")) |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (GdbHelper.excludeFields.contains(f.getColumn())) { |
| | | if (excludeFields.contains(f.getColumn())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | public class GdbHelper { |
| | | private final static Log log = LogFactory.getLog(GdbHelper.class); |
| | | |
| | | public static List<String> excludeFields = new ArrayList<>(Arrays.asList("gid", "shape_leng")); |
| | | private static List<String> excludeFields = new ArrayList<>(Arrays.asList("gid", "objectid", "dirid", "depid", "verid","createtime", "createuser", "updateuser", "updatetime", "shape_leng", "shape_area")); |
| | | |
| | | /** |
| | | * 销毁资源 |
| | |
| | | public static <T> void readLayer(Class clazz, Layer layer, List<T> list) { |
| | | try { |
| | | Field gField = getGeomField(clazz); |
| | | Map<Integer, Field> map = getFieldMapper(clazz, layer); |
| | | if (map.size() == 0) { |
| | | return; |
| | | } |
| | | if (1 > layer.GetFeatureCount()) { |
| | | |
| | | Map<Integer, Field> map = new HashMap<>(3); |
| | | getFieldMapper(clazz, layer, map); |
| | | if (map.isEmpty() || 0 == layer.GetFeatureCount()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | /** |
| | | * 获取字段映射 |
| | | */ |
| | | private static <T> Map<Integer, Field> getFieldMapper(Class clazz, Layer layer) { |
| | | Map<Integer, Field> map = new HashMap<>(3); |
| | | |
| | | private static <T> void getFieldMapper(Class clazz, Layer layer, Map<Integer, Field> map) { |
| | | try { |
| | | FeatureDefn fd = layer.GetLayerDefn(); |
| | | for (int i = 0, count = fd.GetFieldCount(); i < count; i++) { |
| | | FieldDefn fieldDefn = fd.GetFieldDefn(i); |
| | | try { |
| | | String name = fieldDefn.GetName().toLowerCase(); |
| | | if (excludeFields.contains(name)){ |
| | | if (excludeFields.contains(name)) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | // |
| | | } |
| | | } |
| | | |
| | | if ("java.lang.Object" != clazz.getSuperclass().getName()) { |
| | | getFieldMapper(clazz.getSuperclass(), layer, map); |
| | | } |
| | | } catch (Exception ex) { |
| | | // |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | |
| | | * 设置值 |
| | | */ |
| | | private static <T> void setValue(T t, Feature f, Field field, Integer i) throws Exception { |
| | | switch (field.getType().toString()) { |
| | | case "class java.math.BigDecimal": |
| | | case "class java.lang.Double": |
| | | switch (field.getType().getName()) { |
| | | case "java.math.BigDecimal": |
| | | case "java.lang.Double": |
| | | case "double": |
| | | field.set(t, f.GetFieldAsDouble(i)); |
| | | break; |
| | | case "class java.lang.Long": |
| | | case "java.lang.Long": |
| | | case "long": |
| | | field.set(t, f.GetFieldAsInteger64(i)); |
| | | break; |
| | | case "class java.lang.Integer": |
| | | case "java.lang.Integer": |
| | | case "int": |
| | | field.set(t, f.GetFieldAsInteger(i)); |
| | | break; |
| | | case "class java.sql.Timestamp": |
| | | case "java.sql.Timestamp": |
| | | field.set(t, getTimestamp(f, i)); |
| | | break; |
| | | default: |
| | |
| | | public static boolean unzip(String filePath, String zipDir) { |
| | | ZipFile zipFile = null; |
| | | try { |
| | | File dir = new File(zipDir); |
| | | if (!dir.exists() || !dir.isDirectory()) { |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | int count; |
| | | zipFile = new ZipFile(filePath); |
| | | |
| | | Enumeration e = zipFile.entries(); |
| | | while (e.hasMoreElements()) { |
| | | ZipEntry entry = (ZipEntry) e.nextElement(); |
| | |
| | | BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); |
| | | FileOutputStream fos = new FileOutputStream(zipDir + File.separator + entry.getName()); |
| | | BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE); |
| | | |
| | | while ((count = is.read(BUFFER, 0, BUFFER_SIZE)) != -1) { |
| | | dest.write(BUFFER, 0, count); |
| | | } |
| | |
| | | case "shp": |
| | | case "gdb": |
| | | case "mdb": |
| | | insertDb(type, temp, mf, tab); |
| | | insertDb(type, temp, entity, mf, tab); |
| | | break; |
| | | // case "xls": |
| | | default: |
| | | insertXls(temp, mf, tab); |
| | | insertXls(temp, entity, mf, tab); |
| | | break; |
| | | } |
| | | if (0 == tab.getRows()) { |
| | |
| | | /** |
| | | * 插入Excel |
| | | */ |
| | | private void insertXls(String root, MetaFileEntity mf, TabMapperEntity tab) { |
| | | private void insertXls(String root, MetaEntity me, MetaFileEntity mf, TabMapperEntity tab) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(tab.getEntity()); |
| | | if (null == basicMapper) { |
| | | return; |
| | |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | | setCreateInfo(list, mf); |
| | | setCreateInfo(list, me); |
| | | |
| | | int rows = 0; |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | |
| | | /** |
| | | * 设置创建信息 |
| | | */ |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mf) { |
| | | private <T> void setCreateInfo(List<T> list, MetaEntity me) { |
| | | try { |
| | | for (T t : list) { |
| | | Field cuField = t.getClass().getDeclaredField("createuser"); |
| | | cuField.setAccessible(true); |
| | | cuField.set(t, mf.getCreateUser()); |
| | | if (!(list.get(0) instanceof BaseEntity)) { |
| | | return; |
| | | } |
| | | |
| | | Field ctField = t.getClass().getDeclaredField("createtime"); |
| | | ctField.setAccessible(true); |
| | | ctField.set(t, mf.getCreateTime()); |
| | | for (T t : list) { |
| | | BaseEntity be = (BaseEntity) t; |
| | | be.setCreateuser(me.getCreateUser()); |
| | | be.setCreatetime(me.getCreateTime()); |
| | | be.setDirid(me.getDirid()); |
| | | be.setDepid(me.getDepid()); |
| | | be.setVerid(me.getVerid()); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | /** |
| | | * 插入DB |
| | | */ |
| | | private void insertDb(String type, String root, MetaFileEntity mf, TabMapperEntity tab) { |
| | | private void insertDb(String type, String root, MetaEntity me, MetaFileEntity mf, TabMapperEntity tab) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(tab.getEntity()); |
| | | if (null == basicMapper) { |
| | | return; |
| | |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | | setCreateInfo(list, mf); |
| | | setCreateInfo(list, me); |
| | | |
| | | int rows = basicMapper.insertBatch(list); |
| | | tab.setTab(tabName); |