| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢æä»¶") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "è·¯å¾", dataType = "String", paramType = "query") |
| | | }) |
| | | @GetMapping(value = "/selectFiles") |
| | | public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { |
| | | try { |
| | | List<MetaFileEntity> list = baseUploadService.selectFiles(path); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "ä¸ä¼ æä»¶") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "è·¯å¾", dataType = "String", paramType = "query") |
| | |
| | | import com.lf.server.entity.ctrl.TabMapperEntity; |
| | | import com.lf.server.entity.ctrl.UploadEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.data.DataLoaderService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @RequestMapping("/dataLoader") |
| | | public class DataLoaderController extends BaseUploadController { |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | BaseQueryService baseQueryService; |
| | | |
| | | @Autowired |
| | | DataLoaderService dataLoaderService; |
| | | |
| | | private final static String FILE_TYPES = "'xls','shp','gdb','mdb'"; |
| | | |
| | | public static List<String> extList = new ArrayList<>(Arrays.asList(".xls", ".xlsx", ".mdb", ".zip")); |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å页æ¥è¯¢ä¸ä¼ æ°æ®å¹¶è¿åè®°å½æ°") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯é¡µæ¡æ°", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageForUpload") |
| | | public ResponseMsg<Object> selectByPageForUpload(Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | |
| | | int count = metaService.selectCountForUpload(ue.getId(), FILE_TYPES); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectByPageForUpload(ue.getId(), FILE_TYPES, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢æä»¶") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "è·¯å¾", dataType = "String", paramType = "query") |
| | | }) |
| | | @GetMapping(value = "/selectFiles") |
| | | public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { |
| | | try { |
| | | List<MetaFileEntity> list = baseUploadService.selectFiles(path, extList); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢ææè¡¨") |
| | | @GetMapping(value = "/selectTabs") |
| | |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.ctrl.UploadEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.DataUploadService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æ°æ®ä¸ä¼ |
| | |
| | | @RequestMapping("/dataUpload") |
| | | public class DataUploadController extends BaseUploadController { |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | DataUploadService dataUploadService; |
| | | |
| | | private final static String FILE_TYPES = "'file'"; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å页æ¥è¯¢ä¸ä¼ æ°æ®å¹¶è¿åè®°å½æ°") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯é¡µæ¡æ°", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageForUpload") |
| | | public ResponseMsg<Object> selectByPageForUpload(Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | |
| | | int count = metaService.selectCountForUpload(ue.getId(), FILE_TYPES); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectByPageForUpload(ue.getId(), FILE_TYPES, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢æä»¶") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "è·¯å¾", dataType = "String", paramType = "query") |
| | | }) |
| | | @GetMapping(value = "/selectFiles") |
| | | public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { |
| | | try { |
| | | List<MetaFileEntity> list = baseUploadService.selectFiles(path, null); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥æä»¶") |
| | | @ApiImplicitParams({ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.helper; |
| | | |
| | | /** |
| | | * Access帮å©ç±» |
| | | * @author WWW |
| | | */ |
| | | public class AccessHelper { |
| | | // |
| | | } |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * GDB帮å©ç±» |
| | |
| | | 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"); |
| | | } |
| | | public static List<String> excludeFields = new ArrayList<>(Arrays.asList("gid", "shape_leng")); |
| | | |
| | | /** |
| | | * è·å表å |
| | |
| | | List<String> list = new ArrayList<>(); |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("OpenFileGDB"); |
| | | if (driver == null) { |
| | | if (null == driver) { |
| | | return list; |
| | | } |
| | | |
| | | DataSource dataSource = driver.Open(filePath, 0); |
| | | if (null == dataSource) { |
| | | return list; |
| | | } |
| | | |
| | | for (int i = 0, count = dataSource.GetLayerCount(); i < count; i++) { |
| | | Layer layer = dataSource.GetLayer(i); |
| | | list.add(layer.GetName()); |
| | |
| | | List<T> list = new ArrayList<>(); |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("OpenFileGDB"); |
| | | if (driver == null) { |
| | | if (null == driver) { |
| | | return list; |
| | | } |
| | | |
| | | DataSource dataSource = driver.Open(filePath, 0); |
| | | if (null == dataSource) { |
| | | return list; |
| | | } |
| | | |
| | | for (int i = 0, count = dataSource.GetLayerCount(); i < count; i++) { |
| | | Layer layer = dataSource.GetLayer(i); |
| | | |
| | |
| | | List<String> list = new ArrayList<>(); |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("PGeo"); |
| | | if (driver == null) { |
| | | if (null == driver) { |
| | | return list; |
| | | } |
| | | |
| | | DataSource dataSource = driver.Open(filePath, 0); |
| | | if (null == dataSource) { |
| | | return list; |
| | | } |
| | | |
| | | for (int i = 0, count = dataSource.GetLayerCount(); i < count; i++) { |
| | | Layer layer = dataSource.GetLayer(i); |
| | | list.add(layer.GetName()); |
| | |
| | | List<T> list = new ArrayList<>(); |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("PGeo"); |
| | | if (driver == null) { |
| | | if (null == driver) { |
| | | return list; |
| | | } |
| | | |
| | | DataSource dataSource = driver.Open(filePath, 0); |
| | | if (null == dataSource) { |
| | | return list; |
| | | } |
| | | |
| | | for (int i = 0, count = dataSource.GetLayerCount(); i < count; i++) { |
| | | Layer layer = dataSource.GetLayer(i); |
| | | |
| | |
| | | List<T> list = new ArrayList<>(); |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("ESRI shapefile"); |
| | | if (driver == null) { |
| | | if (null == driver) { |
| | | return list; |
| | | } |
| | | |
| | | DataSource dataSource = driver.Open(filePath); |
| | | if (null == dataSource) { |
| | | return list; |
| | | } |
| | | |
| | | Layer layer = dataSource.GetLayer(0); |
| | | |
| | | GdbHelper.readLayer(clazz, layer, list); |
| | |
| | | public List<MetaEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸ä¼ è®°å½æ° |
| | | * |
| | | * @param createUser ç¨æ·ID |
| | | * @param types æä»¶ç±»å |
| | | * @return è®°å½æ° |
| | | */ |
| | | public Integer selectCountForUpload(Integer createUser, String types); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ä¸ä¼ è®°å½ |
| | | * |
| | | * @param createUser ç¨æ·ID |
| | | * @param types æä»¶ç±»å |
| | | * @param limit è®°å½è¡¨ |
| | | * @param offset åç§»é |
| | | * @return å表 |
| | | */ |
| | | public List<MetaEntity> selectByPageForUpload(Integer createUser, String types, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ |
| | | * |
| | | * @return |
| | |
| | | /** |
| | | * æ¥è¯¢æä»¶ |
| | | */ |
| | | public List<MetaFileEntity> selectFiles(String subPath) throws IOException { |
| | | public List<MetaFileEntity> selectFiles(String subPath, List<String> extList) throws IOException { |
| | | String root = pathHelper.getConfig().getTempPath() + File.separator + subPath; |
| | | |
| | | File file = new File(root); |
| | |
| | | List<MetaFileEntity> list = new ArrayList<MetaFileEntity>(); |
| | | for (File f : files) { |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | if (null != extList) { |
| | | String extName = FileHelper.getExtension(fileName); |
| | | if (!extList.contains(extName)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | double sizes = FileHelper.sizeToMb(f.length()); |
| | | String filePath = subPath + File.separator + fileName; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCountForUpload(Integer createUser, String types) { |
| | | return metaMapper.selectCountForUpload(createUser, types); |
| | | } |
| | | |
| | | @Override |
| | | public List<MetaEntity> selectByPageForUpload(Integer createUser, String types, Integer limit, Integer offset) { |
| | | return metaMapper.selectByPageForUpload(createUser, types, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public List<MetaEntity> selectAll() { |
| | | return metaMapper.selectAll(); |
| | | } |