From 05b7f36c1fdb1dae4fd2131f63e10f72f85ee42c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 03 四月 2023 16:49:14 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/upload/CheckController.java | 156 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 135 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/upload/CheckController.java b/src/main/java/com/lf/server/controller/data/upload/CheckController.java index ac4dd64..7fd9de0 100644 --- a/src/main/java/com/lf/server/controller/data/upload/CheckController.java +++ b/src/main/java/com/lf/server/controller/data/upload/CheckController.java @@ -5,6 +5,9 @@ import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.all.StaticData; import com.lf.server.entity.ctrl.FmeReqEntity; +import com.lf.server.entity.ctrl.RegisterEntity; +import com.lf.server.helper.HttpHelper; +import com.lf.server.helper.PathHelper; import com.lf.server.helper.StringHelper; import com.lf.server.service.data.FmeService; import io.swagger.annotations.ApiImplicitParam; @@ -12,9 +15,13 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -24,6 +31,9 @@ * @author WWW */ public class CheckController extends BaseController { + @Autowired + protected PathHelper pathHelper; + @Autowired protected FmeService fmeService; @@ -39,16 +49,14 @@ return fail("id涓嶈兘涓虹┖"); } - Object obj = fmeService.getTaskStatus(id, req); - - return obj; + return fmeService.getTaskStatus(id, req); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @SysLog() - @ApiOperation(value = "涓嬭浇璐ㄦ閿欒缁撴灉") + @ApiOperation(value = "涓嬭浇璐ㄦ缁撴灉") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "浠诲姟ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4") }) @@ -57,7 +65,10 @@ try { if (!StringHelper.isEmpty(id)) { String url = fmeService.getDownloadUrl(id, req); - res.sendRedirect(url); + + HttpHelper httpHelper = new HttpHelper(); + // res.sendRedirect(url) + httpHelper.service(req, res, url, null); } } catch (Exception ex) { log.error(ex.getMessage(), ex); @@ -66,11 +77,29 @@ @SysLog() @ApiOperation(value = "鎻愪氦鏁版嵁璐ㄦ") - @GetMapping(value = "/uploadChecks") - public ResponseMsg<Object> uploadChecks(FmeReqEntity entity, HttpServletRequest req) { + @ApiImplicitParams({ + @ApiImplicitParam(name = "entity", value = "FME璇锋眰瀹炰綋绫�", dataType = "FmeReqEntity", paramType = "body") + }) + @ResponseBody + @PostMapping(value = "/uploadChecks") + public ResponseMsg<Object> uploadChecks(@RequestBody FmeReqEntity entity, HttpServletRequest req) { try { if (StringHelper.isEmpty(entity.names)) { return fail("浠诲姟鍚嶇О涓嶈兘涓虹┖"); + } + if (StringHelper.isEmpty(entity.zipPath)) { + return fail("璇烽�夋嫨寰呰川妫�鐨剒ip鏂囦欢"); + } + + entity.zipPath = getFullPath(entity.zipPath); + if (!isZipFile(entity.zipPath)) { + return fail("寰呰川妫�鐨剒ip鏂囦欢涓嶅瓨鍦�"); + } + if (entity.names.contains(StaticData.CHECK_MAIN)) { + entity.wbsPath = getFullPath(entity.wbsPath); + if (!isXlsFile(entity.wbsPath)) { + return fail("寰呰川妫�鐨刉BS鏂囦欢涓嶅瓨鍦�"); + } } List<String> list = new ArrayList<>(); @@ -81,8 +110,44 @@ return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } + } + + /** + * 鑾峰彇鏂囦欢璺緞 + */ + private String getFullPath(String filePath) { + return null == filePath ? null : pathHelper.getConfig().getTempPath() + File.separator + filePath; + } + + /** + * 鏄�/鍚︿负Zip鏂囦欢 + */ + private boolean isZipFile(String filePath) { + if (null == filePath || !filePath.toLowerCase().endsWith(StaticData.ZIP)) { + return false; + } + + File zipFile = new File(filePath); + + return zipFile.exists() && !zipFile.isDirectory(); + } + + /** + * 鏄�/鍚︿负Excel鏂囦欢 + */ + private boolean isXlsFile(String filePath) { + if (null == filePath) { + return false; + } + if (!(filePath.toLowerCase().endsWith(StaticData.XLS) || filePath.toLowerCase().endsWith(StaticData.XLSX))) { + return false; + } + + File zipFile = new File(filePath); + + return zipFile.exists() && !zipFile.isDirectory(); } /** @@ -119,7 +184,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -141,7 +206,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -163,7 +228,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -186,7 +251,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -208,7 +273,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -236,7 +301,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -258,7 +323,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -279,7 +344,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -303,7 +368,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -325,7 +390,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -347,7 +412,7 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -372,7 +437,56 @@ return success(rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } }*/ + + @SysLog() + @ApiOperation(value = "鏈嶅姟娉ㄥ唽") + @GetMapping(value = "/selectServerRegister") + public ResponseMsg<Object> selectServerRegister(HttpServletRequest req) { + try { + RegisterEntity rs = fmeService.serverRegister("瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116DT02锛�", "http://127.0.0.1/LFData/2d/tiles/01/{z}/{x}/{y}.png", "DOM", req); + if (null == rs || StringHelper.isEmpty(rs.getSerialnum())) { + return fail("澶辫触"); + } + + return success(rs); + } catch (Exception ex) { + return fail(ex, null); + } + } + + @SysLog() + @ApiOperation(value = "鏈嶅姟鐢宠") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "鏈嶅姟ID", dataType = "String", paramType = "query", example = "195f77eb-19dd-4e34-afc1-fcff8f758f7b"), + @ApiImplicitParam(name = "pubid", value = "鍙戝竷ID", dataType = "Integer", paramType = "query", example = "1"), + }) + @GetMapping(value = "/selectServerApply") + public ResponseMsg<Object> selectServerApply(String id, Integer pubid, HttpServletRequest req) { + try { + fmeService.serverApply(id, pubid, req); + + return success("OK"); + } catch (Exception ex) { + return fail(ex, null); + } + } + + @SysLog() + @ApiOperation(value = "鍒犻櫎璧勬簮") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "鏈嶅姟ID", dataType = "String", paramType = "query", example = "6f4b6783-4b98-4d46-a0d9-43cdb5f339dc") + }) + @GetMapping(value = "/selectDeleteRes") + public ResponseMsg<Object> selectDeleteRes(String id, HttpServletRequest req) { + try { + fmeService.deleteRes(id, req); + + return success("OK"); + } catch (Exception ex) { + return fail(ex, null); + } + } } -- Gitblit v1.9.3