From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 02 七月 2025 16:43:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service

---
 src/main/java/com/lf/server/controller/show/PipelineController.java |  262 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 258 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/show/PipelineController.java b/src/main/java/com/lf/server/controller/show/PipelineController.java
index b4c3ffe..c57fc39 100644
--- a/src/main/java/com/lf/server/controller/show/PipelineController.java
+++ b/src/main/java/com/lf/server/controller/show/PipelineController.java
@@ -1,9 +1,263 @@
 package com.lf.server.controller.show;
 
+import com.lf.server.annotation.SysLog;
+import com.lf.server.controller.all.BaseController;
+import com.lf.server.entity.all.HttpStatus;
+import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.all.StaticData;
+import com.lf.server.entity.data.DownloadEntity;
+import com.lf.server.entity.show.PipelineEntity;
+import com.lf.server.entity.sys.UserEntity;
+import com.lf.server.helper.Md5Helper;
+import com.lf.server.helper.StringHelper;
+import com.lf.server.helper.WebHelper;
+import com.lf.server.service.data.DownloadService;
+import com.lf.server.service.show.PipelineService;
+import com.lf.server.service.sys.DownlogService;
+import com.lf.server.service.sys.TokenService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
 /**
- * 绠¢亾璧勬枡
- * @author sws
- * @date   2022-09-22
+ * 绠¢亾鍒嗘瀽
+ * @author WWW
  */
-public class PipelineController {
+@Api(tags = "缁煎悎灞曠ず\\绠¢亾鍒嗘瀽")
+@RestController
+@RequestMapping("/pipeline")
+public class PipelineController extends BaseController {
+    @Autowired
+    TokenService tokenService;
+
+    @Autowired
+    DownlogService downlogService;
+
+    @Autowired
+    DownloadService downloadService;
+
+    @Autowired
+    PipelineService pipelineService;
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ绠℃")
+    @GetMapping(value = "/selectSegNames")
+    public ResponseMsg<Object> selectSegNames() {
+        try {
+            List<PipelineEntity> rs = pipelineService.selectSegNames();
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ绠$嚎鍒嗘瀽")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pe", value = "绠¢亾鍒嗘瀽瀹炰綋绫�", dataType = "PipelineEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/selectPipeAnalysis")
+    public ResponseMsg<Object> selectPipeAnalysis(@RequestBody PipelineEntity pe) {
+        try {
+            if (null == pe.getGid() || pe.getGid() < 1) {
+                return fail("璇疯緭鍏ョ娈礗D");
+            }
+            if (null == pe.getTabs() || 0 == pe.getTabs().size()) {
+                return fail("璇疯緭鍏ヨ〃鍚�");
+            }
+            if (!checkTabs(pe.getTabs())) {
+                return fail("瀛樺湪闈炴硶琛ㄥ悕");
+            }
+
+            Map<String, Object> map = new HashMap<>(4);
+            for (String tab : pe.getTabs()) {
+                List<PipelineEntity> rs = pipelineService.selectPipeAnalysis(tab, pe.getGid());
+                map.put(tab, rs);
+            }
+
+            return success(map);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "璇锋眰绠¢亾鍒嗘瀽缁撴灉涓嬭浇")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pe", value = "绠¢亾鍒嗘瀽瀹炰綋绫�", dataType = "PipelineEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/downloadReq")
+    public ResponseMsg<Object> downloadReq(@RequestBody PipelineEntity pe, HttpServletRequest req) {
+        try {
+            if (null == pe || StringHelper.isEmpty(pe.getPwd())) {
+                return fail("瀵嗙爜涓嶈兘涓虹┖");
+            }
+            if (null == pe.getTabs() || 0 == pe.getTabs().size()) {
+                return fail("璇疯緭鍏ヨ〃鍚�");
+            }
+            if (!checkTabs(pe.getTabs())) {
+                return fail("瀛樺湪闈炴硶琛ㄥ悕");
+            }
+            if (!DownloadService.decryptPwd(pe)) {
+                return fail("瀵嗙爜瑙e瘑澶辫触", null);
+            }
+            if (StringHelper.isPwdInvalid(pe.getPwd())) {
+                return fail("瀵嗙爜涓嶇鍚堣姹�");
+            }
+
+            Map<String, List<PipelineEntity>> map = new HashMap<>(4);
+            for (String tab : pe.getTabs()) {
+                List<PipelineEntity> rs = pipelineService.selectPipeAnalysis(tab, pe.getGid());
+                if (null != rs && rs.size() > 0) {
+                    map.put(tab, rs);
+                }
+            }
+            if (map.size() == 0) {
+                return fail("鏌ユ棤鏁版嵁");
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            String guid = pipelineService.createZipFile(ue, map, pe.getPwd());
+
+            return success(guid);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鍒嗛〉鏌ヨ涓嬭浇鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = ""),
+            @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"),
+            @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1")
+    })
+    @GetMapping(value = "/selectPageCountForDownload")
+    public ResponseMsg<List<DownloadEntity>> selectPageCountForDownload(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) {
+        try {
+            if (pageSize < 1 || pageIndex < 1) {
+                return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null);
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue == null) {
+                return fail("鐢ㄦ埛鏈櫥褰�", null);
+            }
+
+            int count = downloadService.selectCountForUser(ue.getId(), "5", name);
+            if (count == 0) {
+                return success(0, null);
+            }
+            List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), "5", name, pageSize, pageSize * (pageIndex - 1));
+
+            return success(count, rs);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ涓嬭浇鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "pwd", value = "瀵嗙爜", dataType = "String", paramType = "query")
+    })
+    @GetMapping(value = "/selectDownloadFile")
+    public ResponseMsg<Boolean> selectDownloadFile(String guid, String pwd) {
+        try {
+            if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) {
+                return fail("鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", null);
+            }
+            if (!pwd.endsWith(StaticData.EQ)) {
+                pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name());
+            }
+
+            String password = DownloadService.decryptPwd(pwd);
+            if (null == password) {
+                return fail("瀵嗙爜瑙e瘑澶辫触", null);
+            }
+
+            DownloadEntity de = downloadService.selectByGuid(guid);
+            if (null == de) {
+                return fail("鏂囦欢涓嶅瓨鍦�", null);
+            }
+            if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) {
+                return fail("瀵嗙爜涓嶆纭�", null);
+            }
+
+            String filePath = downloadService.getDownloadFilePath(de);
+            File file = new File(filePath);
+
+            return success(file.exists());
+        } catch (Exception ex) {
+            return fail(ex, false);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "涓嬭浇鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "pwd", value = "瀵嗙爜", dataType = "String", paramType = "query")
+    })
+    @ResponseBody
+    @GetMapping(value = "/downloadFile")
+    public void downloadFile(String guid, String pwd, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) {
+                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", res);
+            }
+            if (!pwd.endsWith(StaticData.EQ)) {
+                pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name());
+            }
+
+            String password = DownloadService.decryptPwd(pwd);
+            if (null == password) {
+                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "瀵嗙爜瑙e瘑澶辫触", res);
+            }
+
+            DownloadEntity de = downloadService.selectByGuid(guid);
+            if (null == de) {
+                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "鏂囦欢涓嶅瓨鍦�", res);
+                return;
+            }
+            if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) {
+                WebHelper.writeInfo(HttpStatus.UNAUTHORIZED, "瀵嗙爜涓嶆纭�", res);
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            downlogService.updateInfos(ue, de, req);
+
+            String filePath = downloadService.getDownloadFilePath(de);
+            WebHelper.download(filePath, de.getName(), res);
+        } catch (Exception ex) {
+            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
+        }
+    }
+
+    /**
+     * 妫�鏌ヨ〃鍚�
+     */
+    private boolean checkTabs(List<String> tabs) {
+        for (String tab : tabs) {
+            if (!StaticData.PIPE_ANALYSIS_TABS.contains(tab)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
 }

--
Gitblit v1.9.3