From 7d64716cb0d406f21cde03976fd273bd07fdc06f Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期二, 28 九月 2021 11:44:28 +0800
Subject: [PATCH] 更新用户-角色-菜单-权限

---
 src/main/java/com/whyc/controller/ProjectManageController.java |  228 ++++++++++++++++++++-------------------------------------
 1 files changed, 80 insertions(+), 148 deletions(-)

diff --git a/src/main/java/com/whyc/controller/ProjectManageController.java b/src/main/java/com/whyc/controller/ProjectManageController.java
index 3553049..90deccf 100644
--- a/src/main/java/com/whyc/controller/ProjectManageController.java
+++ b/src/main/java/com/whyc/controller/ProjectManageController.java
@@ -1,6 +1,8 @@
 package com.whyc.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.whyc.config.MyProps;
+import com.whyc.config.ServerConfig;
 import com.whyc.dto.Response;
 import com.whyc.pojo.ProjectArchiveManage;
 import com.whyc.pojo.ProjectManage;
@@ -17,7 +19,9 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
 import java.io.*;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 
@@ -33,6 +37,9 @@
     private MyProps myProps;
 
     @Autowired
+    private ServerConfig serverConfig;
+
+    @Autowired
     private ProjectProcessManageService service;
 
 
@@ -40,36 +47,23 @@
     private ProjectArchiveManageService archiveManageService;
 
 
-    @GetMapping("all")
-    @ApiOperation(value = "椤圭洰杩囩▼绠$悊-鏌ヨ鎵�鏈�")
-    public Response<List<ProjectManage>> searchAll() {
-
-        return service.searchAll();
-    }
-
-
-    @GetMapping("byCondition")
-    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊",value = "椤圭洰杩囩▼绠$悊-鏉′欢鏌ヨ")
-    public Response<List<ProjectManage>> searchByCondition(@ApiParam(value = "鐢虫姤鏃ユ湡 鏍煎紡 2021/01/28",required = true) @RequestParam Date proCreatedate,
-                                                           @ApiParam(value = "椤圭洰绫诲瀷",required = true)@RequestParam String proSort,
-                                                           @ApiParam(value = "椤圭洰鐘舵��",required = true)@RequestParam int proState,
-                                                           @ApiParam(value = "椤圭洰缂栧彿",required = true)@RequestParam String proNum) {
-        ProjectManage projectManage = new ProjectManage();
-        projectManage.setProCreatedate(proCreatedate);
-        projectManage.setProSort(proSort);
-        projectManage.setProState(proState);
-        projectManage.setProNum(proNum);
-        return service.searchByCondition(projectManage);
+    @PostMapping("progressByCondition")
+    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊", value = "椤圭洰杩囩▼绠$悊-鏌ヨ鍒嗛〉-鏍规嵁绛涢�夋潯浠�")
+    public Response<PageInfo<ProjectManage>> searchByCondition(@RequestParam int pageNum, @RequestParam int pageSize, @RequestBody ProjectManage projectManage) {
+        return service.searchByCondition(pageNum, pageSize, projectManage);
     }
 
     @PostMapping("add")
-    @ApiOperation(value = "鏂板缓椤圭洰",notes = "notes涓瓨鏂囦欢鍦板潃鐢� ; 鍒嗛殧 {\n" +
-            "  \"proNum\": S0900033,\n" +
-            "  \"proName\": \"\",\n" +
-            "  \"proNameCode\": \"yyyyMMddHHmmss鏍煎紡瀛楃涓瞈",\n" +
+    @ApiOperation(value = "椤圭洰杩囩▼绠$悊-鏂板缓椤圭洰",notes = "fileList 瀛樻枃浠跺湴鍧� {\n" +
+            "  \"fileList\": [\n" +
+            "    \n" +
+            "  ],\n" +
+            "  \"proNum\": \"S0900033\",\n" +
+            "  \"proName\": \"鑸拌埞鐢垫皵鍔ㄥ姏璇曢獙\",\n" +
             "  \"proSort\": 0,\n" +
             "  \"proAdmin\": \"寮犱笁\",\n" +
-            "  \"proTel\": 13800003131,\n" +
+            "  \"proDepartment\": \"xxxx\",\n" +
+            "  \"proTel\": \"13800003131\",\n" +
             "  \"proCreatedate\": \"2021-03-27 08:18:27\",\n" +
             "  \"proExecutionDate\": \"2021-03-27 08:18:27\",\n" +
             "  \"proExecutionDate1\": \"2021-03-27 08:18:27\",\n" +
@@ -78,13 +72,13 @@
             "  \"proFundingSource\": \"缁忚垂鏉ユ簮\",\n" +
             "  \"proContent\": \" \",\n" +
             "  \"proState\": 0,\n" +
-            "  \"note\": \"鎷兼帴澶氫釜鏂囦欢鍦板潃\"\n" +
+            "  \"proProgress\": 0\n" +
             "}")
-    public Response add(@RequestBody ProjectManage projectManage) {
-
+    public Response add(@RequestBody @Valid ProjectManage projectManage) {
         Response response = service.add(projectManage);
         return response;
     }
+
 
     /**
      * 鏂囦欢瀛樺偍鍚庡湴鍧�鏇存柊鍒板搴旈」鐩紪鍙风殑鍦板潃锛屼竴涓」鐩搴斿涓枃浠� db_experiment.tb_project_archive_manage
@@ -93,75 +87,38 @@
      * @param file
      * @return
      */
-    @PostMapping("upload")
-    @ApiOperation(notes = "杩斿洖鏂囦欢鍦板潃锛岀‘璁ゆ椂鎻愪氦淇濆瓨鍒板瓧娈�", value = "鏂囨。鏉愭枡娣诲姞(閫夋嫨鏂囦欢)")
-    public Response upload(@RequestParam("file") MultipartFile file) {
-        // 鑾峰彇鍘熷鍚嶅瓧
-        String originalFilename = file.getOriginalFilename();
-        // 鑾峰彇鍚庣紑鍚�
-        // String suffixName = fileName.substring(fileName.lastIndexOf("."));
-        // 鏂囦欢淇濆瓨璺緞銆佸悗鏈熻�冭檻鎸夋棩鏈熸垨鑰呮湀浠藉缓dir
-        String filePath = myProps.getFilePath();
-        // 鏂囦欢閲嶅懡鍚嶏紝闃叉閲嶅,棰勮鏃堕渶瑕佹樉绀哄師鏂囦欢鍚� _ 鍒囧壊
-        String fileName = filePath + UUID.randomUUID() + "_" + originalFilename;
-        // 鏂囦欢瀵硅薄
-        File dest = new File(fileName);
-        // 鍒ゆ柇璺緞鏄惁瀛樺湪锛屽鏋滀笉瀛樺湪鍒欏垱寤�
-        if (!dest.getParentFile().exists()) {
-            dest.getParentFile().mkdirs();
-        }
-        Response<Object> response = new Response<>();
-        HashMap<Object, Object> map = new HashMap<>();
-        try {
-            // 淇濆瓨鍒版湇鍔″櫒涓�
-            file.transferTo(dest);
-            map.put("鏂囦欢绫诲瀷锛�", file.getContentType());
-            map.put("鍘熸枃浠跺悕锛�", originalFilename);
-            map.put("鏄惁涓虹┖锛�", file.isEmpty());
-            Double size = file.getSize() * 0.01 / 1024 / 1024 * 100;
-            String douStr = String.format("%.2f", size);
-            map.put("鏂囦欢澶у皬锛�", douStr+" M");
-            map.put("鏂囦欢鍦板潃锛�",fileName);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return response.setMsg(0, "涓婁紶澶辫触");
-        }
-        response.setCode(1);
-        response.setData(map);
-        return response;
-    }
-
-
-
     @PostMapping("/uploads")
-    @ApiOperation(notes = "杩斿洖鏂囦欢鍦板潃锛岀‘璁ゆ椂鎻愪氦淇濆瓨鍒板瓧娈�", value = "鏂囨。鏉愭枡娣诲姞(澶氶��)")
-    public Response uploads(MultipartFile[] files) throws IOException {
+    @ApiOperation(notes = "杩斿洖鏂囦欢鍦板潃锛岀‘璁ゆ椂鎻愪氦淇濆瓨鍒板瓧娈�", value = "椤圭洰杩囩▼绠$悊-鏂囨。鏉愭枡娣诲姞(澶氶��)")
+    public Response uploads(MultipartFile[] file) throws IOException {
         Response<Object> response = new Response<>();
-        if (files.length == 0) {
+        if (file.length == 0) {
             return response.setMsg(0, "璇烽�夋嫨瑕佷笂浼犵殑鏂囦欢");
         }
 
         ArrayList<Object> list = new ArrayList<>();
-        for (MultipartFile multipartFile : files) {
+//            String filePath = myProps.getFilePath();
+        String uploadPath = FileUtils.getProjectPath();
+//        System.out.println("uploadPath = " + uploadPath);
+        for (MultipartFile multipartFile : file) {
             if (multipartFile.isEmpty()) {
                 return response.setMsg(0, "璇烽�夋嫨瑕佷笂浼犵殑鏂囦欢");
             }
             byte[] fileBytes = multipartFile.getBytes();
-            String filePath = myProps.getFilePath();
             //鍙栧緱褰撳墠涓婁紶鏂囦欢鐨勬枃浠跺悕绉�
             String originalFilename = multipartFile.getOriginalFilename();
             //鐢熸垚鏂囦欢鍚�
             String fileName = UUID.randomUUID() + "_" + originalFilename;
 
             HashMap<Object, Object> map = new HashMap<>();
+            map.put("name", originalFilename);
+            String url = serverConfig.getUrl();
+            map.put("url", url + "/uploadFile/" + fileName);
             try {
-                FileUtils.uploadFile(fileBytes, filePath, fileName);
+                FileUtils.uploadFile(fileBytes, uploadPath, fileName);
             } catch (IOException e) {
                 e.printStackTrace();
                 return response.setMsg(0, "涓婁紶澶辫触");
             }
-            map.put("鍘熸枃浠跺悕锛�", originalFilename);
-            map.put("鏂囦欢鍦板潃锛�", filePath + fileName);
             list.add(map);
 
         }
@@ -171,10 +128,18 @@
 
 
     @GetMapping("/download")
-    @ApiOperation(notes = "闇�瑕佸湪鍦板潃鏍忔祴璇�",value = "鏂囨。鏉愭枡涓嬭浇")
-    public Object download(HttpServletResponse response, @RequestParam String filePath,@RequestParam String fileName) {
-        Response<Object> result = new Response<>();
-        File file = new File( filePath);
+    @ApiOperation(notes = "闇�瑕佸湪鍦板潃鏍忔祴璇� http://localhost:8090/projectManage/download?fileName=鐢宠涔�.pdf",value = "椤圭洰杩囩▼绠$悊-鏂囨。鏉愭枡涓嬭浇")
+    public String download(HttpServletResponse response, @ApiParam(value = "鏂囦欢璺緞",required = true)@RequestParam String filePath) {
+        String fileName = "";
+        if (filePath.length() > 10&&filePath.contains("/")) {   //IP鍦板潃+鏂囦欢鍚�
+            int lastIndexOf = filePath.lastIndexOf("/");
+            fileName = filePath.substring(lastIndexOf);
+        } else {
+            return "filePath is Error";
+        }
+
+        String projectPath = FileUtils.getProjectPath();
+        File file = new File( projectPath+fileName);
         if (file.exists()) {
             try {
                 fileName= new String(fileName.getBytes("gbk"), "ISO8859-1");
@@ -196,10 +161,12 @@
                     outputStream.write(buffer, 0, i);
                     i = bis.read(buffer);
                 }
-                return result.setMsg(1,"涓嬭浇鎴愬姛");
+//               return result.setMsg(1,"涓嬭浇鎴愬姛");
+               return "downloadSuccessful";
             } catch (Exception e) {
                 e.printStackTrace();
-                return result.setMsg(0,"涓嬭浇澶辫触");
+//                return result.setMsg(0,"涓嬭浇澶辫触");
+                return "downloadFailed";
             } finally {
                 if (bis != null) {
                     try {
@@ -216,38 +183,15 @@
                     }
                 }
             }
+        }else{
+            return "fileDoesNotExist";
         }
-        return result.setMsg(0,"鏂囦欢涓嶅瓨鍦�");
     }
 
-    @DeleteMapping("/delDoc")
-    @ApiOperation(notes = "", value = "鏂囨。鏉愭枡鍒犻櫎")
-    public Response delDocment(@RequestParam String filePath) {
-        Response<Object> response = new Response<>();
-        File file = new File(filePath);
-        try {
-            if (file.exists()) {
-                File absoluteFile = file.getAbsoluteFile();
-                String name = absoluteFile.getName();
-                file.delete();
-                HashMap<Object, Object> map = new HashMap<>();
-                map.put("鍒犻櫎鐨勬枃浠跺悕", name);
-                map.put("鍒犻櫎鐨勬枃浠惰矾寰�", filePath);
-                response.setData(map);
-                response.setMsg(1, "鍒犻櫎鎴愬姛");
-            } else {
-                response.setMsg(0, "鏂囦欢涓嶅瓨鍦�");
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            return response.setMsg(0, "鍒犻櫎澶辫触");
-        }
-        return response;
-    }
 
 
     @GetMapping("managesState")
-    @ApiOperation(notes = "", value = "椤圭洰绠$悊-宸辩‘璁�/鏈‘璁ら樁娈垫煡璇�")
+    @ApiOperation(notes = "", value = "椤圭洰杩囩▼绠$悊-宸辩‘璁�/鏈‘璁ら樁娈垫煡璇�")
     public Response<Object> searchManageStateByCondition(@ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum,
                                                          @ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode) {
         ProjectManage projectManage = new ProjectManage();
@@ -262,22 +206,28 @@
      * @return
      */
     @PutMapping("updateManageState")
-    @ApiOperation(notes = "椤圭洰杩涘害纭1-6 瀵瑰簲 绔嬮」-瀹℃壒-鐮旂┒-缁撻-楠屾敹-褰掓。",value = "椤圭洰绠$悊-鏈‘璁ら樁娈垫洿鏂�")
-    public Response updateManageState(@ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum,
-                                      @ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode,
-                                      @ApiParam(value = "椤圭洰杩涘害纭1-6",required = true)@RequestParam int proProgress,
-                                      @ApiParam(value = "鏂囨。涓婁紶淇濆瓨鍦板潃(濡傛灉鏃犱紶绌哄瓧绗︿覆)",required = true)@RequestParam String proFilePath) {
-        ProjectManage projectManage = new ProjectManage();
-        projectManage.setProNum(proNum);
-        projectManage.setProNameCode(proNameCode);
-        projectManage.setProProgress(proProgress);
-        projectManage.setNote(proFilePath);
+    @ApiOperation(notes = "椤圭洰杩涘害纭1-6 瀵瑰簲 绔嬮」-瀹℃壒-鐮旂┒-缁撻-楠屾敹-褰掓。",value = "椤圭洰杩囩▼绠$悊-鏈‘璁ら樁娈垫洿鏂�")
+    public Response updateManageState(@RequestBody ProjectManage projectManage) {
+
         return service.updateManageState(projectManage);
     }
 
+    @PutMapping("updateArchive")
+    @ApiOperation(notes = "",value = "椤圭洰杩囩▼绠$悊-褰掓。")
+    public Response updateArchive(@ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum,
+                                  @ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode) {
+        ProjectManage projectManage = new ProjectManage();
+        projectManage.setProNum(proNum);
+        projectManage.setProNameCode(proNameCode);
+        projectManage.setProProgress(6);
+        return service.updateProjectProgress(projectManage);
+    }
+
+
+
 
     @GetMapping("searchDoc")
-    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊-椤圭洰绠$悊",value = "鏂囨。鏉愭枡鏌ヨ")
+    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊-椤圭洰绠$悊",value = "椤圭洰杩囩▼绠$悊-鏂囨。鏉愭枡鏌ヨ")
     public  Response searchDocumentation(@ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum,
                                          @ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode){
         ProjectArchiveManage projectArchiveManage = new ProjectArchiveManage();
@@ -287,8 +237,8 @@
 
     }
 
-    @Delete("delDoc")
-    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊-椤圭洰绠$悊-宸辩‘璁ら樁娈�",value = "鏂囨。鏉愭枡鍒犻櫎")
+    @DeleteMapping("delDoc")
+    @ApiOperation(notes = "椤圭洰杩囩▼绠$悊-椤圭洰绠$悊",value = "椤圭洰杩囩▼绠$悊-鏂囨。鏉愭枡鍒犻櫎")
     public  Response delDocumentation(@ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum,
                                       @ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode,
                                       @ApiParam(value = "鏂囨。璺緞", required = true) @RequestParam String proFilePath){
@@ -299,26 +249,12 @@
         return  archiveManageService.delDocumentation(projectArchiveManage);
     }
 
-    @GetMapping("archiveAll")
-    @ApiOperation(value = "椤圭洰褰掓。绠$悊-鏌ヨ鎵�鏈�")
-    public Response<List<ProjectManage>> searchArchiveAll() {
 
-        return archiveManageService.searchArchiveAll();
-    }
-    @GetMapping("archiveByCondition")
-    @ApiOperation(value = "椤圭洰褰掓。绠$悊-鏉′欢鏌ヨ")
-    public Response searchArchiveByCondition(@ApiParam(value = "寮�濮嬫棩鏈� 鏍煎紡 2021/03/27",required = true) @RequestParam Date proExecutionDate,
-                                             @ApiParam(value = "褰掓。鏃ユ湡 鏍煎紡 2021/03/27",required = true)@RequestParam Date proArchiveDate,
-                                             @ApiParam(value = "椤圭洰绫诲瀷",required = true)@RequestParam String proSort,
-                                             @ApiParam(value = "椤圭洰缂栧彿",required = true)@RequestParam String proNum) {
+    @PostMapping("archiveByCondition")
+    @ApiOperation(value = "椤圭洰褰掓。绠$悊-鏌ヨ鍒嗛〉-鏍规嵁绛涢�夋潯浠�")
+    public Response<PageInfo<ProjectManage>> searchArchiveByCondition(@RequestParam int pageNum, @RequestParam int pageSize, @RequestBody ProjectManage projectManage) {
 
-        ProjectManage pm = new ProjectManage();
-        pm.setProExecutionDate(proExecutionDate);
-        pm.setProArchiveDate(proArchiveDate);
-        pm.setProSort(proSort);
-        pm.setProNum(proNum);
-
-        return archiveManageService.searchArchiveByCondition(pm);
+        return archiveManageService.searchArchiveByCondition(pageNum,pageSize,projectManage);
     }
 
     @GetMapping("archiveProjectInfo")
@@ -351,17 +287,13 @@
 
     /**
      * @param proNameCode
-     * @param proNum
-     * @return  瀹為獙鍚嶇О銆佷笂浼犳棩鏈熴�佸綊妗f棩鏈� (鎿嶄綔TODO)
+     * @return 瀹為獙鍚嶇О銆佽瘯楠屾棩鏈熴�佺粨璁哄瓧娈� etc
      */
     @GetMapping("archiveExperimentData")
-    @ApiOperation(notes = "(鎿嶄綔TODO)",value = "椤圭洰褰掓。绠$悊-璇曢獙鏁版嵁")
-    public Response searchArchiveExperimentData(@ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode,
-                                                                 @ApiParam(value = "椤圭洰缂栧彿", required = true) @RequestParam String proNum) {
-        ProjectArchiveManage pam = new ProjectArchiveManage();
-        pam.setProNum(proNum);
-        pam.setProNameCode(proNameCode);
-        return archiveManageService.searchArchiveExperimentData(pam);
+    @ApiOperation(notes = "TODO 鏂囦欢鏍煎紡鍜屼笅杞藉湴鍧�", value = "椤圭洰褰掓。绠$悊-璇曢獙鏁版嵁")
+    public Response searchArchiveExperimentData(@ApiParam(value = "椤圭洰鍚嶇О浠g爜", required = true) @RequestParam String proNameCode) {
+    //TODO fileName file
+        return archiveManageService.searchArchiveExperimentData(proNameCode);
     }
 
     @GetMapping("archiveTechnologicalAchievements")

--
Gitblit v1.9.1