| | |
| | | public TabMapperEntity() { |
| | | } |
| | | |
| | | public TabMapperEntity(String fileName, String type, String tab) { |
| | | this.fileName = fileName; |
| | | this.type = type; |
| | | this.tab = tab; |
| | | } |
| | | |
| | | public TabMapperEntity(String fileName, String type, String tab, String subPath) { |
| | | this.fileName = fileName; |
| | | this.type = type; |
| | |
| | | |
| | | private double sizes; |
| | | |
| | | private String tab; |
| | | |
| | | private int rows; |
| | | |
| | | private String cs; |
| | | |
| | | private String scale; |
| | |
| | | this.sizes = sizes; |
| | | } |
| | | |
| | | public String getTab() { |
| | | return tab; |
| | | } |
| | | |
| | | public void setTab(String tab) { |
| | | this.tab = tab; |
| | | } |
| | | |
| | | public int getRows() { |
| | | return rows; |
| | | } |
| | | |
| | | public void setRows(int rows) { |
| | | this.rows = rows; |
| | | } |
| | | |
| | | public String getCs() { |
| | | return cs; |
| | | } |
| | |
| | | package com.lf.server.extend; |
| | | |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.lf.server.helper.GdbHelper; |
| | | import org.apache.ibatis.executor.keygen.NoKeyGenerator; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlSource; |
| | |
| | | |
| | | private String prepareFieldSql(TableInfo tableInfo) { |
| | | StringBuilder fieldSql = new StringBuilder(); |
| | | fieldSql.append(tableInfo.getKeyColumn()).append(","); |
| | | tableInfo.getFieldList().forEach(x -> { |
| | | fieldSql.append(x.getColumn()).append(","); |
| | | }); |
| | | // 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())) { |
| | | continue; |
| | | } |
| | | |
| | | fieldSql.append(f.getColumn()).append(","); |
| | | } |
| | | |
| | | fieldSql.delete(fieldSql.length() - 1, fieldSql.length()); |
| | | fieldSql.insert(0, "("); |
| | |
| | | private String prepareValuesSql(TableInfo tableInfo) { |
| | | final StringBuilder valueSql = new StringBuilder(); |
| | | valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">"); |
| | | valueSql.append("#{item.").append(tableInfo.getKeyProperty()).append("},"); |
| | | tableInfo.getFieldList().forEach(x -> valueSql.append("#{item.").append(x.getProperty()).append("},")); |
| | | // 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())) { |
| | | continue; |
| | | } |
| | | |
| | | valueSql.append("geom".equals(f.getColumn()) ? "${item." : "#{item.").append(f.getProperty()).append("},"); |
| | | } |
| | | |
| | | valueSql.delete(valueSql.length() - 1, valueSql.length()); |
| | | valueSql.append("</foreach>"); |
| | | |
| | |
| | | |
| | | reader.read(sheet); |
| | | } |
| | | |
| | | reader.finish(); |
| | | |
| | | return list; |
| | | } |
| | |
| | | public class GdbHelper { |
| | | private final static Log log = LogFactory.getLog(GdbHelper.class); |
| | | |
| | | public static List<String> excludeFields = new ArrayList<String>(); |
| | | |
| | | static { |
| | | excludeFields.add("gid"); |
| | | excludeFields.add("shape_leng"); |
| | | } |
| | | |
| | | /** |
| | | * 获取表名 |
| | | */ |
| | |
| | | layer.delete(); |
| | | } |
| | | |
| | | dataSource.delete(); |
| | | driver.delete(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | layer.delete(); |
| | | } |
| | | |
| | | dataSource.delete(); |
| | | driver.delete(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | Field gField = getGeomField(clazz); |
| | | Map<Integer, Field> map = getFieldMapper(clazz, layer); |
| | | if (map.size() == 0) { |
| | | return; |
| | | } |
| | | if (1 > layer.GetFeatureCount()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | for (int i = 0, count = fd.GetFieldCount(); i < count; i++) { |
| | | FieldDefn fieldDefn = fd.GetFieldDefn(i); |
| | | try { |
| | | Field field = clazz.getDeclaredField(fieldDefn.GetName().toLowerCase()); |
| | | String name = fieldDefn.GetName().toLowerCase(); |
| | | if (excludeFields.contains(name)){ |
| | | continue; |
| | | } |
| | | |
| | | Field field = clazz.getDeclaredField(name); |
| | | field.setAccessible(true); |
| | | |
| | | map.put(i, field); |
| | |
| | | |
| | | /** |
| | | * 设置 geom 字段值 |
| | | * <p> |
| | | * wkbUnknown = 0, |
| | | * wkbPoint = 1, |
| | | * wkbLineString = 2, |
| | | * wkbPolygon = 3, |
| | | * wkbMultiPoint = 4, |
| | | * wkbMultiLineString = 5, |
| | | * wkbMultiPolygon = 6, |
| | | * wkbGeometryCollection = 7, |
| | | * wkbNone = 100, |
| | | * wkbLinearRing = 101 |
| | | */ |
| | | private static <T> void setGeom(T t, Feature f, Field gField) throws Exception { |
| | | Geometry geometry = f.GetGeometryRef(); |
| | | if (null != geometry) { |
| | | gField.set(t, geometry.ExportToWkt()); |
| | | String wkt = geometry.ExportToWkt(); |
| | | switch (geometry.GetGeometryType()) { |
| | | case 2: |
| | | wkt = wkt.replace("LINESTRING (", "MULTILINESTRING ((") + ")"; |
| | | break; |
| | | case 3: |
| | | wkt = wkt.replace("POLYGON (", "MULTIPOLYGON ((") + ")"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | gField.set(t, String.format("ST_GeomFromText('%s')", wkt)); |
| | | } |
| | | } |
| | | |
| | |
| | | layer.delete(); |
| | | } |
| | | |
| | | dataSource.delete(); |
| | | driver.delete(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | layer.delete(); |
| | | } |
| | | |
| | | dataSource.delete(); |
| | | driver.delete(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | |
| | | private static int sharePath = 1; |
| | | |
| | | private final static double D90 = 90; |
| | | private final static double D85 = 85; |
| | | |
| | | private final static Log log = LogFactory.getLog(PathHelper.class); |
| | | |
| | |
| | | public void deleteOldPath(String tempPath) { |
| | | try { |
| | | double ran = Math.random() * 99; |
| | | if (ran < D90) { |
| | | if (ran < D85) { |
| | | return; |
| | | } |
| | | |
| | | File file = new File(tempPath); |
| | | String str = StringHelper.YMD__FORMAT.format(new Date()); |
| | | String str = StringHelper.YMD2_FORMAT.format(new Date()); |
| | | |
| | | File[] files = file.listFiles(); |
| | | for (File f : files) { |
| | |
| | | |
| | | GdbHelper.readLayer(clazz, layer, list); |
| | | |
| | | dataSource.delete(); |
| | | driver.delete(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | /** |
| | | * 格式化当前系统日期 3 |
| | | */ |
| | | public static final SimpleDateFormat YMD__FORMAT = new SimpleDateFormat("yyyyMMdd_"); |
| | | public static final SimpleDateFormat YMD2_FORMAT = new SimpleDateFormat("yyyyMMdd"); |
| | | |
| | | /** |
| | | * 格式化当前系统日期 4 |
| | |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import org.apache.commons.text.StringEscapeUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * 获取映射 |
| | | */ |
| | | private List<TabMapperEntity> getMappers(String zipPath, File[] files) { |
| | | String temp = pathHelper.getConfig().getTempPath(); |
| | | |
| | | List<TabMapperEntity> list = new ArrayList<>(); |
| | | for (File f : files) { |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | if (fileName.contains(XLS)) { |
| | | list.add(new TabMapperEntity(fileName, "xls", fileName)); |
| | | String path = f.getPath().replace(temp + File.separator, ""); |
| | | list.add(new TabMapperEntity(fileName, "xls", null, path)); |
| | | continue; |
| | | } |
| | | if (fileName.contains(MDB)) { |
| | | String path = f.getPath().replace(temp + File.separator, ""); |
| | | List<String> tabs = MdbHelper.getTabNames(f.getPath()); |
| | | for (String tab : tabs) { |
| | | list.add(new TabMapperEntity(fileName, "mdb", tab, fileName)); |
| | | list.add(new TabMapperEntity(fileName, "mdb", tab, path)); |
| | | } |
| | | continue; |
| | | } |
| | |
| | | List<String> files = new ArrayList<>(); |
| | | getShpFiles(subPath, files); |
| | | |
| | | String root = subPath.substring(0, subPath.lastIndexOf(File.separator) + 1); |
| | | String root = pathHelper.getConfig().getTempPath() + File.separator; |
| | | for (String file : files) { |
| | | String name = FileHelper.getFileName(file); |
| | | String path = file.replace(root, ""); |
| | |
| | | List<String> files = new ArrayList<>(); |
| | | getGdbFiles(subPath, files); |
| | | |
| | | String root = subPath.substring(0, subPath.lastIndexOf(File.separator) + 1); |
| | | String root = pathHelper.getConfig().getTempPath() + File.separator; |
| | | for (String file : files) { |
| | | String path = file.replace(root, ""); |
| | | List<String> tabs = GdbHelper.getTabNames(file); |
| | |
| | | /** |
| | | * 插入文件 |
| | | */ |
| | | public void insertFiles(MetaEntity entity, List<MetaFileEntity> list, List<TabMapperEntity> tabs) { |
| | | public void insertFiles(MetaEntity entity, List<MetaFileEntity> list, List<TabMapperEntity> tabList) { |
| | | try { |
| | | String temp = pathHelper.getConfig().getTempPath(); |
| | | String full = pathHelper.getUploadFullPath(); |
| | | String root = pathHelper.getConfig().getUploadPath(); |
| | | String upload = pathHelper.getUploadFullPath(); |
| | | |
| | | for (MetaFileEntity mf : list) { |
| | | String filePath = getFilePath(temp, full, mf); |
| | | if (null == filePath) { |
| | | File file = new File(temp + File.separator + mf.getPath()); |
| | | File newFile = new File(upload + File.separator + mf.getGuid()); |
| | | |
| | | String type = getType(mf.getName().toLowerCase()); |
| | | if (null == type) { |
| | | file.delete(); |
| | | continue; |
| | | } |
| | | |
| | | // 元数据 |
| | | MetaEntity me = createMetaEntity(entity, mf); |
| | | if (metaService.insert(me) < 1) { |
| | | // 获取表映射 |
| | | List<TabMapperEntity> tabs = getTabs(mf, tabList); |
| | | if (tabs.isEmpty()) { |
| | | file.delete(); |
| | | continue; |
| | | } |
| | | |
| | | // 元数据文件 |
| | | MetaFileEntity mfe = createMetaFileEntity(me, mf, filePath); |
| | | if (metaFileService.insert(mfe) < 1) { |
| | | continue; |
| | | MetaFileEntity old = metaFileService.selectByGuid(mf.getGuid()); |
| | | String filePath = null == old ? newFile.getPath() : old.getPath(); |
| | | |
| | | int count = 0; |
| | | for (TabMapperEntity tab : tabs) { |
| | | if (null == tab || StringHelper.isEmpty(tab.getEntity())) { |
| | | return; |
| | | } |
| | | switch (type) { |
| | | case "shp": |
| | | case "gdb": |
| | | case "mdb": |
| | | insertDb(type, temp, mf, tab); |
| | | break; |
| | | // case "xls": |
| | | default: |
| | | insertXls(temp, mf, tab); |
| | | break; |
| | | } |
| | | if (0 == tab.getRows()) { |
| | | continue; |
| | | } |
| | | |
| | | MetaEntity me = createMetaEntity(entity, mf, tab.getTab(), tab.getRows()); |
| | | if (metaService.insert(me) == 0) { |
| | | continue; |
| | | } |
| | | |
| | | MetaFileEntity mfe = createMetaFileEntity(me, mf, filePath); |
| | | if (metaFileService.insert(mfe) == 0) { |
| | | metaService.delete(me.getId()); |
| | | continue; |
| | | } |
| | | count += tab.getRows(); |
| | | } |
| | | |
| | | // 入库 |
| | | switch (me.getType()) { |
| | | case "xls": |
| | | insertXls(root, mfe, tabs); |
| | | break; |
| | | case "shp": |
| | | case "gdb": |
| | | case "mdb": |
| | | String zipPath = FileHelper.getPath(temp + File.separator + mf.getPath()) + "_zip"; |
| | | insertDb(me.getType(), zipPath, mfe, tabs); |
| | | break; |
| | | default: |
| | | break; |
| | | if (count == 0 || null != old) { |
| | | file.delete(); |
| | | } else { |
| | | file.renameTo(newFile); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取文件路径 |
| | | * 获取 Tabs |
| | | */ |
| | | private String getFilePath(String temp, String root, MetaFileEntity mf) { |
| | | // 移动文件 |
| | | File file = new File(temp + File.separator + mf.getPath()); |
| | | File newFile = new File(root + File.separator + mf.getGuid()); |
| | | private List<TabMapperEntity> getTabs(MetaFileEntity mfe, List<TabMapperEntity> tabs) { |
| | | List<TabMapperEntity> list = new ArrayList<>(); |
| | | for (TabMapperEntity tab : tabs) { |
| | | if (!tab.getFileName().equals(mfe.getName()) || StringHelper.isEmpty(tab.getEntity())) { |
| | | continue; |
| | | } |
| | | |
| | | // 文件类型 |
| | | String metaType = getType(mf.getName().toLowerCase()); |
| | | if (null == metaType) { |
| | | file.delete(); |
| | | return null; |
| | | list.add(tab); |
| | | } |
| | | |
| | | MetaFileEntity old = metaFileService.selectByGuid(mf.getGuid()); |
| | | |
| | | String filePath = null; |
| | | if (null == old) { |
| | | filePath = newFile.getPath(); |
| | | file.renameTo(newFile); |
| | | } else { |
| | | filePath = old.getPath(); |
| | | file.delete(); |
| | | } |
| | | |
| | | return filePath; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据实体 |
| | | */ |
| | | private MetaEntity createMetaEntity(MetaEntity entity, MetaFileEntity mf) { |
| | | MetaEntity me = new MetaEntity(); |
| | | me.setDepid(entity.getDepid()); |
| | | me.setDirid(entity.getDirid()); |
| | | me.setVerid(entity.getVerid()); |
| | | me.setType(getType(mf.getName().toLowerCase())); |
| | | me.setGather(entity.getGather()); |
| | | me.setBatch(entity.getBatch()); |
| | | me.setDescr(entity.getDescr()); |
| | | me.setName(mf.getName()); |
| | | me.setSizes(mf.getSizes()); |
| | | me.setCreateTime(entity.getCreateTime()); |
| | | me.setCreateUser(entity.getCreateUser()); |
| | | |
| | | return me; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaEntity me, MetaFileEntity entity, String filePath) { |
| | | MetaFileEntity mfe = new MetaFileEntity(); |
| | | mfe.setName(entity.getName()); |
| | | mfe.setMetaid(me.getId()); |
| | | mfe.setGuid(entity.getGuid()); |
| | | mfe.setSizes(entity.getSizes()); |
| | | mfe.setPath(FileHelper.getRelativePath(filePath)); |
| | | mfe.setCreateUser(me.getCreateUser()); |
| | | mfe.setCreateTime(me.getCreateTime()); |
| | | |
| | | return mfe; |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据实体 |
| | | */ |
| | | private MetaEntity createMetaEntity(MetaEntity entity, MetaFileEntity mf, String tab, int rows) { |
| | | MetaEntity me = new MetaEntity(); |
| | | me.setDepid(entity.getDepid()); |
| | | me.setDirid(entity.getDirid()); |
| | | me.setVerid(entity.getVerid()); |
| | | me.setType(getType(mf.getName().toLowerCase())); |
| | | me.setGather(entity.getGather()); |
| | | me.setBatch(entity.getBatch()); |
| | | me.setDescr(entity.getDescr()); |
| | | me.setName(mf.getName()); |
| | | me.setSizes(mf.getSizes()); |
| | | me.setTab(tab); |
| | | me.setRows(rows); |
| | | me.setCreateTime(entity.getCreateTime()); |
| | | me.setCreateUser(entity.getCreateUser()); |
| | | |
| | | return me; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaEntity me, MetaFileEntity entity, String filePath) { |
| | | MetaFileEntity mfe = new MetaFileEntity(); |
| | | mfe.setName(entity.getName()); |
| | | mfe.setMetaid(me.getId()); |
| | | mfe.setGuid(entity.getGuid()); |
| | | mfe.setSizes(entity.getSizes()); |
| | | mfe.setPath(FileHelper.getRelativePath(filePath)); |
| | | mfe.setCreateUser(me.getCreateUser()); |
| | | mfe.setCreateTime(me.getCreateTime()); |
| | | |
| | | return mfe; |
| | | } |
| | | |
| | | /** |
| | | * 插入Excel |
| | | */ |
| | | private void insertXls(String root, MetaFileEntity mfe, List<TabMapperEntity> tabs) { |
| | | TabMapperEntity tab = getTabEntity(mfe, tabs); |
| | | if (null == tab || StringHelper.isEmpty(tab.getEntity())) { |
| | | return; |
| | | } |
| | | |
| | | private void insertXls(String root, MetaFileEntity mf, TabMapperEntity tab) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(tab.getEntity()); |
| | | if (null == basicMapper) { |
| | | return; |
| | | } |
| | | |
| | | String tabName = BaseQueryService.getTabName(basicMapper); |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (null == clazz) { |
| | | if (null == clazz || null == tabName) { |
| | | return; |
| | | } |
| | | |
| | | List<?> list = ExcelHelper.readExcel(clazz, root + File.separator + mfe.getPath()); |
| | | List<?> list = ExcelHelper.readExcel(clazz, root + File.separator + mf.getPath()); |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | | setCreateInfo(list, mfe); |
| | | setCreateInfo(list, mf); |
| | | |
| | | int rows = 0; |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | |
| | | updateXlsGeom((GeomBaseMapper) basicMapper, list); |
| | | } |
| | | |
| | | tab.setTab(tabName); |
| | | tab.setRows(rows); |
| | | } |
| | | |
| | | /** |
| | | * 获取表映射实体类 |
| | | */ |
| | | private TabMapperEntity getTabEntity(MetaFileEntity mfe, List<TabMapperEntity> tabs) { |
| | | for (TabMapperEntity tab : tabs) { |
| | | if (tab.getFileName().equals(mfe.getName())) { |
| | | return tab; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 设置创建信息 |
| | | */ |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mfe) { |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mf) { |
| | | try { |
| | | for (T t : list) { |
| | | Field cuField = t.getClass().getDeclaredField("createuser"); |
| | | cuField.setAccessible(true); |
| | | cuField.set(t, mfe.getCreateUser()); |
| | | cuField.set(t, mf.getCreateUser()); |
| | | |
| | | Field ctField = t.getClass().getDeclaredField("createtime"); |
| | | ctField.setAccessible(true); |
| | | ctField.set(t, mfe.getCreateTime()); |
| | | ctField.set(t, mf.getCreateTime()); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | /** |
| | | * 插入DB |
| | | */ |
| | | private void insertDb(String type, String root, MetaFileEntity mfe, List<TabMapperEntity> tabs) { |
| | | for (TabMapperEntity tab : tabs) { |
| | | if (!tab.getFileName().equals(mfe.getName()) || StringHelper.isEmpty(tab.getEntity())) { |
| | | continue; |
| | | } |
| | | |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(tab.getEntity()); |
| | | if (null == basicMapper) { |
| | | continue; |
| | | } |
| | | |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (null == clazz) { |
| | | continue; |
| | | } |
| | | |
| | | List<?> list = null; |
| | | switch (type) { |
| | | case "shp": |
| | | list = ShpHelper.readData(clazz, root + File.separator + tab.getSubPath()); |
| | | break; |
| | | case "gdb": |
| | | list = GdbHelper.readData(clazz, root + File.separator + tab.getSubPath(), tab.getTab()); |
| | | break; |
| | | case "mdb": |
| | | list = MdbHelper.readData(clazz, root + File.separator + tab.getSubPath(), tab.getTab()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (null == list || list.isEmpty()) { |
| | | continue; |
| | | } |
| | | setCreateInfo(list, mfe); |
| | | |
| | | Integer rows = basicMapper.insertBatch(list); |
| | | if (basicMapper instanceof GeomBaseMapper) { |
| | | updateDbGeom((GeomBaseMapper) basicMapper, list); |
| | | } |
| | | |
| | | tab.setRows(rows); |
| | | private void insertDb(String type, String root, MetaFileEntity mf, TabMapperEntity tab) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(tab.getEntity()); |
| | | if (null == basicMapper) { |
| | | return; |
| | | } |
| | | |
| | | String tabName = BaseQueryService.getTabName(basicMapper); |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (null == clazz || null == tabName) { |
| | | return; |
| | | } |
| | | |
| | | String filePath = StringEscapeUtils.escapeJava(root + File.separator + tab.getSubPath()); |
| | | List<?> list = null; |
| | | switch (type) { |
| | | case "shp": |
| | | list = ShpHelper.readData(clazz, filePath); |
| | | break; |
| | | case "gdb": |
| | | list = GdbHelper.readData(clazz, filePath, tab.getTab()); |
| | | break; |
| | | case "mdb": |
| | | list = MdbHelper.readData(clazz, filePath, tab.getTab()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | | setCreateInfo(list, mf); |
| | | |
| | | int rows = basicMapper.insertBatch(list); |
| | | tab.setTab(tabName); |
| | | tab.setRows(rows); |
| | | } |
| | | |
| | | /** |
| | |
| | | </selectKey> |
| | | |
| | | insert into lf.sys_meta |
| | | (name,dirid,depid,verid,type,sizes,cs,scale,resolution,gather,batch,descr,create_user,create_time,geom) |
| | | (name,dirid,depid,verid,type,sizes,tab,rows,cs,scale,resolution,gather,batch,descr,create_user,create_time,geom) |
| | | values |
| | | (#{name},#{dirid},#{depid},#{verid},#{type},#{sizes},#{cs},#{scale},#{resolution},#{createTime},#{batch},#{descr},#{createUser},now(),#{geom}) |
| | | (#{name},#{dirid},#{depid},#{verid},#{type},#{sizes},#{tab},#{rows},#{cs},#{scale},#{resolution},#{createTime},#{batch},#{descr},#{createUser},now(),#{geom}) |
| | | </insert> |
| | | |
| | | <insert id="inserts"> |
| | | insert into lf.sys_meta |
| | | (name,dirid,depid,verid,type,sizes,cs,scale,resolution,gather,batch,descr,create_user,create_time,geom) |
| | | (name,dirid,depid,verid,type,sizes,tab,rows,cs,scale,resolution,gather,batch,descr,create_user,create_time,geom) |
| | | values |
| | | <foreach collection="list" item="item" index="index" separator=","> |
| | | (#{item.name},#{item.dirid},#{item.depid},#{item.verid},#{item.type},#{item.sizes},#{item.cs},#{item.scale},#{item.resolution},now(),#{item.batch},#{item.descr},#{item.createUser},now(),#{item.geom}) |
| | | (#{item.name},#{item.dirid},#{item.depid},#{item.verid},#{item.type},#{item.sizes},#{item.tab},#{item.rows},#{item.cs},#{item.scale},#{item.resolution},now(),#{item.batch},#{item.descr},#{item.createUser},now(),#{item.geom}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | |
| | | |
| | | <update id="update"> |
| | | update lf.sys_meta |
| | | set name=#{name},dirid=#{dirid},depid=#{depid},verid=#{verid},type=#{type},sizes=#{sizes},cs=#{cs},scale=#{scale},resolution=#{resolution},gather=now(),batch=#{batch},descr=#{descr},update_user=#{updateUser},update_time=now(),geom=#{geom} |
| | | set name=#{name},dirid=#{dirid},depid=#{depid},verid=#{verid},type=#{type},sizes=#{sizes},tab=#{tab},rows=#{rows},cs=#{cs},scale=#{scale},resolution=#{resolution},gather=now(),batch=#{batch},descr=#{descr},update_user=#{updateUser},update_time=now(),geom=#{geom} |
| | | where id=#{id} |
| | | </update> |
| | | |
| | |
| | | <foreach collection="list" item="item" index="index" separator=";"> |
| | | update lf.sys_meta |
| | | <set> |
| | | name=#{item.name},dirid=#{item.dirid},depid=#{item.depid},verid=#{item.verid},type=#{item.type},sizes=#{item.sizes},cs=#{item.cs},scale=#{item.scale},resolution=#{item.resolution},gather=now(),batch=#{item.batch},descr=#{item.descr},update_user=#{item.updateUser},update_time=now(),geom=#{item.geom} |
| | | name=#{item.name},dirid=#{item.dirid},depid=#{item.depid},verid=#{item.verid},type=#{item.type},sizes=#{item.sizes},tab=#{item.tab},rows=#{item.rows},cs=#{item.cs},scale=#{item.scale},resolution=#{item.resolution},gather=now(),batch=#{item.batch},descr=#{item.descr},update_user=#{item.updateUser},update_time=now(),geom=#{item.geom} |
| | | </set> |
| | | where id = #{item.id} |
| | | </foreach> |