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 | 268 ++++++++++++++++++++++------------------------------- 1 files changed, 113 insertions(+), 155 deletions(-) diff --git a/src/main/java/com/whyc/controller/ProjectManageController.java b/src/main/java/com/whyc/controller/ProjectManageController.java index 5937621..90deccf 100644 --- a/src/main/java/com/whyc/controller/ProjectManageController.java +++ b/src/main/java/com/whyc/controller/ProjectManageController.java @@ -1,24 +1,28 @@ 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; import com.whyc.service.ProjectArchiveManageService; import com.whyc.service.ProjectProcessManageService; +import com.whyc.util.FileUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.*; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; +import java.text.SimpleDateFormat; +import java.util.*; /** @@ -30,6 +34,12 @@ public class ProjectManageController { @Autowired + private MyProps myProps; + + @Autowired + private ServerConfig serverConfig; + + @Autowired private ProjectProcessManageService service; @@ -37,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" + @@ -75,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 @@ -90,49 +87,59 @@ * @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 = "c:/upload/"; - // 鏂囦欢閲嶅懡鍚嶏紝闃叉閲嶅,棰勮鏃堕渶瑕佹樉绀哄師鏂囦欢鍚� _ 鍒囧壊 - String fileName = filePath + UUID.randomUUID() + "_" + originalFilename; - // 鏂囦欢瀵硅薄 - File dest = new File(fileName); - // 鍒ゆ柇璺緞鏄惁瀛樺湪锛屽鏋滀笉瀛樺湪鍒欏垱寤� - if (!dest.getParentFile().exists()) { - dest.getParentFile().mkdirs(); - } + @PostMapping("/uploads") + @ApiOperation(notes = "杩斿洖鏂囦欢鍦板潃锛岀‘璁ゆ椂鎻愪氦淇濆瓨鍒板瓧娈�", value = "椤圭洰杩囩▼绠$悊-鏂囨。鏉愭枡娣诲姞(澶氶��)") + public Response uploads(MultipartFile[] file) throws IOException { 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, "涓婁紶澶辫触"); + if (file.length == 0) { + return response.setMsg(0, "璇烽�夋嫨瑕佷笂浼犵殑鏂囦欢"); } - response.setCode(1); - response.setData(map); - return response; + + ArrayList<Object> list = new ArrayList<>(); +// 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 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, uploadPath, fileName); + } catch (IOException e) { + e.printStackTrace(); + return response.setMsg(0, "涓婁紶澶辫触"); + } + list.add(map); + + } + response.setData(list); + return response.setMsg(1, "涓婁紶鎴愬姛"); } + @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"); @@ -154,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 { @@ -174,13 +183,15 @@ } } } + }else{ + return "fileDoesNotExist"; } - return result.setMsg(0,"鏂囦欢涓嶅瓨鍦�"); } + @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(); @@ -195,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(); @@ -220,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){ @@ -232,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") @@ -284,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") @@ -310,48 +309,7 @@ - /** - * 鏂囦欢涓婁紶 - * achievement_name 鎴愭灉绫诲瀷 - */ -/* - @RequestMapping("/upload") - public Response upload(MultipartFile file) { - try { - if (file != null) { - File parentFile = createParentFile(); - String fileName = file.getOriginalFilename(); - String suffix = fileName.substring(fileName.lastIndexOf(".")); - String uuid = IdUtil.simpleUUID(); - fileName = uuid + suffix; - File imageFile = new File(parentFile, fileName); - FileUtil.writeFromStream(file.getInputStream(), imageFile); - */ -/** - * 骞存湀鏃ョ洰褰� - *//* - String fileDay = DateUtil.thisYear() + "/" + (DateUtil.thisMonth() + 1) + "/" - + DateUtil.thisDayOfMonth(); - String imagePath = SystemConstant.FILE + "/document/" + fileDay + "/" + fileName; - */ -/** - * 瀹炴椂杞崲 - *//* - - File toFile = new File(parentFile, uuid + ".pdf"); - documentConverter.convert(imageFile).to(toFile).execute(); - return Result.ok(imagePath); - } else { - return Result.error(); - } - } catch (Exception e) { - LOGGER.error("杞崲寮傚父{}",e); - return Result.error(); - } - } - -*/ } -- Gitblit v1.9.1