From c509bd8047cfd582c59bba66d148b236e45d038d Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 12 一月 2023 10:15:15 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/upload/UploadController.java | 127 ++++++++++++----------------------------- 1 files changed, 38 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/upload/UploadController.java b/src/main/java/com/lf/server/controller/data/upload/UploadController.java index 28380aa..0f8d739 100644 --- a/src/main/java/com/lf/server/controller/data/upload/UploadController.java +++ b/src/main/java/com/lf/server/controller/data/upload/UploadController.java @@ -2,15 +2,14 @@ import com.lf.server.annotation.SysLog; import com.lf.server.entity.all.ResponseMsg; -import com.lf.server.entity.ctrl.TabMapperEntity; -import com.lf.server.entity.ctrl.UploadEntity; +import com.lf.server.entity.all.StaticData; +import com.lf.server.entity.data.DirEntity; import com.lf.server.entity.data.MetaEntity; import com.lf.server.entity.data.MetaFileEntity; +import com.lf.server.entity.data.VerEntity; import com.lf.server.entity.sys.UserEntity; -import com.lf.server.helper.WebHelper; -import com.lf.server.service.all.BaseUploadService; -import com.lf.server.service.data.DataLoaderService; -import com.lf.server.service.data.DataUploadService; +import com.lf.server.helper.StringHelper; +import com.lf.server.service.data.UploadService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -20,8 +19,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -33,22 +30,14 @@ @RequestMapping("/dataUpload") public class UploadController extends QueryController { @Autowired - protected DataLoaderService dataLoaderService; - - @Autowired - protected BaseUploadService baseUploadService; - - @Autowired - protected DataUploadService dataUploadService; - - private final static List<String> EXT_LIST = new ArrayList<>(Arrays.asList(".xls", ".xlsx", ".mdb", ".zip")); + UploadService uploadService; @SysLog() @ApiOperation(value = "鏌ヨ璺緞") @GetMapping(value = "/selectPath") public ResponseMsg<String> selectPath() { try { - String pathName = baseUploadService.selectPath(); + String pathName = uploadService.selectPath(); return success(pathName); } catch (Exception ex) { @@ -65,7 +54,7 @@ @PostMapping(value = "/uploadFiles") public ResponseMsg<Object> uploadFiles(String path, HttpServletRequest req, HttpServletResponse res) { try { - List<MetaFileEntity> list = baseUploadService.uploadData(null, path, req, res); + List<MetaFileEntity> list = uploadService.uploadData(null, path, req, res); if (null == list || list.isEmpty()) { return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null); } @@ -84,7 +73,7 @@ @GetMapping(value = "/selectFiles") public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { try { - List<MetaFileEntity> list = baseUploadService.selectFiles(path, EXT_LIST); + List<MetaFileEntity> list = uploadService.selectFiles(path, StaticData.ALL_EXTENSION); return success(list); } catch (Exception ex) { @@ -109,7 +98,7 @@ return fail("娌℃湁鎵惧埌鏂囦欢", null); } - int rows = baseUploadService.deleteFiles(list); + int rows = uploadService.deleteFiles(list); return success("鎴愬姛", rows); } catch (Exception ex) { @@ -120,28 +109,31 @@ @SysLog() @ApiOperation(value = "鏌ヨ鏄犲皠") @ApiImplicitParams({ - @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query") + @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query", example = "20230110010101"), + @ApiImplicitParam(name = "dirid", value = "鐩綍ID", dataType = "Integer", paramType = "query", example = "163"), + @ApiImplicitParam(name = "verid", value = "鐗堟湰ID", dataType = "Integer", paramType = "query", example = "0"), + @ApiImplicitParam(name = "epsgCode", value = "鍧愭爣缂栫爜", dataType = "String", paramType = "query", example = "EPSG:4490") }) @GetMapping(value = "/selectMappers") - public ResponseMsg<List<TabMapperEntity>> selectMappers(String path) { + public ResponseMsg<Object> selectMappers(String path, Integer dirid, Integer verid, String epsgCode, HttpServletRequest req) { try { - List<TabMapperEntity> list = dataLoaderService.selectMappers(path); + if (StringHelper.isEmpty(path) || StringHelper.isEmpty(epsgCode) || null == dirid || null == verid) { + return fail("璺緞銆佺洰褰旾D銆佺増鏈琁D鍜屽潗鏍囩紪鐮佷笉鑳戒负绌�"); + } + if (1 > uploadService.selectCount4Coord(epsgCode)) { + return fail("鍧愭爣缂栫爜" + epsgCode + "涓嶅瓨鍦�"); + } + DirEntity dir = dirService.selectDir(dirid); + if (null == dir) { + return fail("鐩綍ID=" + dirid + "涓嶅瓨鍦�"); + } + VerEntity ver = verService.selectVersion(verid); + if (null == ver) { + return fail("鐗堟湰ID=" + verid + "涓嶅瓨鍦�"); + } - return success(list); - } catch (Exception ex) { - return fail(ex.getMessage(), null); - } - } - - @SysLog() - @ApiOperation(value = "鏌ヨ鏂囦欢") - @ApiImplicitParams({ - @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query") - }) - @GetMapping(value = "/selectFiles2") - public ResponseMsg<List<MetaFileEntity>> selectFiles2(String path) { - try { - List<MetaFileEntity> list = baseUploadService.selectFiles(path, null); + UserEntity ue = tokenService.getCurrentUser(req); + List<MetaFileEntity> list = uploadService.selectMappers(ue, path, dir, ver, epsgCode); return success(list); } catch (Exception ex) { @@ -152,66 +144,23 @@ @SysLog() @ApiOperation(value = "鎻掑叆鏂囦欢") @ApiImplicitParams({ - @ApiImplicitParam(name = "entity", value = "涓婁紶瀹炰綋绫�", dataType = "UploadEntity", paramType = "body") + @ApiImplicitParam(name = "list", value = "鍏冩暟鎹枃浠堕泦鍚�", dataType = "MetaFileEntity", paramType = "body") }) @ResponseBody @PostMapping(value = "/insertFiles") - public ResponseMsg<Object> insertFiles(@RequestBody UploadEntity entity, HttpServletRequest req) { + public ResponseMsg<Object> insertFiles(@RequestBody List<MetaFileEntity> list, HttpServletRequest req) { try { UserEntity ue = tokenService.getCurrentUser(req); - if (ue == null) { + if (null == ue) { return fail("鐢ㄦ埛鏈櫥褰�", null); } - if (null == entity || null == entity.getMetaEntity()) { - return fail("鍏冩暟鎹俊鎭负绌�", null); + if (null == list || list.isEmpty()) { + return fail("鍏冩暟鎹枃浠堕泦鍚堜负绌�", null); } - if (null == entity.getFileEntities() || entity.getFileEntities().isEmpty()) { - return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null); - } + List<MetaEntity> metas = uploadService.insertFiles(ue, list, req); - MetaEntity me = entity.getMetaEntity(); - me.setCreateTime(WebHelper.getCurrentTimestamp()); - // me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime()))) - me.setCreateUser(ue.getId()); - - int rows = dataUploadService.insertFiles(me, entity.getFileEntities()); - - return success("鎴愬姛", rows); - } catch (Exception ex) { - return fail(ex.getMessage(), null); - } - } - - @SysLog() - @ApiOperation(value = "鎻掑叆鏂囦欢") - @ApiImplicitParams({ - @ApiImplicitParam(name = "entity", value = "涓婁紶瀹炰綋绫�", dataType = "UploadEntity", paramType = "body") - }) - @ResponseBody - @PostMapping(value = "/insertFiles2") - public ResponseMsg<Object> insertFiles2(@RequestBody UploadEntity entity, HttpServletRequest req) { - try { - UserEntity ue = tokenService.getCurrentUser(req); - if (ue == null) { - return fail("鐢ㄦ埛鏈櫥褰�", null); - } - if (null == entity || null == entity.getMetaEntity()) { - return fail("鍏冩暟鎹俊鎭负绌�", null); - } - - if (null == entity.getFileEntities() || entity.getFileEntities().isEmpty()) { - return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null); - } - - MetaEntity me = entity.getMetaEntity(); - me.setCreateTime(WebHelper.getCurrentTimestamp()); - // me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime()))) - me.setCreateUser(ue.getId()); - - dataLoaderService.insertFiles(me, entity.getFileEntities(), entity.getTabEntities()); - - return success("鎴愬姛", entity.getTabEntities()); + return success("鎴愬姛", metas); } catch (Exception ex) { return fail(ex.getMessage(), null); } -- Gitblit v1.9.3