From fc8c8356f5e95cb8317069c9986120b1ecb88851 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 29 一月 2026 14:27:21 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/smart_screen
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ProjectController.java | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ProjectController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ProjectController.java
index 42e796b..9174fd2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ProjectController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ProjectController.java
@@ -16,16 +16,28 @@
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.*;
import io.swagger.annotations.*;
+import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.parsing.Problem;
+import org.springframework.core.io.InputStreamResource;
import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import javax.validation.Valid;
+import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
@@ -67,6 +79,9 @@
@Autowired
private ScreenAccountService screenAccountService;
+ @Autowired
+ private ProjectProgressService projectProgressService;
+
@ApiOperation(value = "获取项目/委托方列表",response = LoginNameVo.class)
@GetMapping("/getLoginNameVoList")
@@ -86,6 +101,38 @@
}
+
+ @ApiOperation(value = "获取项目最新进度",response = ProjectProgress.class)
+ @GetMapping("/getProjectProgress/{projectId}")
+ public R<ProjectProgress> getProjectProgress(@PathVariable Integer projectId) {
+ ProjectProgress projectProgress = projectProgressService.getOne(new LambdaQueryWrapper<ProjectProgress>().eq(ProjectProgress::getProjectId, projectId).eq(ProjectProgress::getDeleted,0).orderByDesc(ProjectProgress::getTime).last("limit 1"));
+ return R.ok(projectProgress);
+ }
+
+
+ @ApiOperation(value = "获取项目进度历史列表",response = ProjectProgress.class)
+ @PostMapping("/getProjectProgressList")
+ public R<Page<ProjectProgress>> getProjectProgressList(@Valid @RequestBody ProjectProgressQuery query) {
+ LambdaQueryWrapper<ProjectProgress> wrapper = new LambdaQueryWrapper<ProjectProgress>().eq(ProjectProgress::getProjectId, query.getProjectId()).eq(ProjectProgress::getDeleted, 0);
+ if(query.getContent()!=null && !query.getContent().isEmpty()){
+ wrapper.like(ProjectProgress::getDetail, query.getContent());
+ }
+ if(query.getStartTime()!=null && !query.getStartTime().isEmpty()){
+ wrapper.ge(ProjectProgress::getTime, query.getStartTime());
+ }
+ if(query.getEndTime()!=null && !query.getEndTime().isEmpty()){
+ wrapper.le(ProjectProgress::getTime, query.getEndTime());
+ }
+
+ wrapper.orderByDesc(ProjectProgress::getTime);
+ Page<ProjectProgress> page = projectProgressService.page(new Page<>(query.getPageNum(), query.getPageSize()),wrapper);
+ return R.ok(page);
+ }
+ @ApiOperation(value = "获取项目进度详情",response = ProjectProgress.class)
+ @GetMapping("/getProjectProgressDetail/{id}")
+ public R<ProjectProgress> getProjectProgressDetail(@PathVariable Integer id) {
+ return R.ok(projectProgressService.getById(id));
+ }
@ApiOperation(value = "获取项目详情",response = Project.class)
@@ -405,4 +452,60 @@
return R.ok(list);
}
+
+
+ @Resource
+ UserFileService userFileService;
+
+ @SneakyThrows
+ @ApiOperation(value = "下载文件(名称)")
+ @GetMapping("/download/{name}")
+ public ResponseEntity<org.springframework.core.io.Resource> downloadFileByName(@PathVariable String name) {
+ var userFile = userFileService.getOne(new LambdaQueryWrapper<UserFile>().eq(UserFile::getName, name));
+ return downloadFile(userFile);
+ }
+
+ private ResponseEntity<org.springframework.core.io.Resource> downloadFile(UserFile userFile) throws IOException {
+ InputStreamResource resource =resolveResource(userFile);
+ var fileSize = userFile.getSize();
+// if(resource == null) {
+// resource = new InputStreamResource(getClass().getClassLoader().getResourceAsStream("images/wukong.png"));
+// fileSize = 6215360L;// resource.contentLength();
+// }
+
+ String encodedFileName = URLEncoder.encode(userFile.getOriginFileName(), "UTF-8");
+ String headerValue = String.format("attachment; filename=\"%s\"", encodedFileName);
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType(userFile.getContentType()))
+ .contentLength(fileSize)
+ .header(HttpHeaders.CONTENT_DISPOSITION, headerValue)
+ .body(resource);
+ }
+
+ public InputStreamResource resolveResource(UserFile userFile) throws IOException {
+ var filePath = fileLocation.resolve(userFile.getName() + "." + userFile.getExtension()).normalize();
+ if(!Files.exists(filePath)){
+ return null;
+ }
+ return new InputStreamResource(Files.newInputStream(filePath));
+ }
+
+ private Path fileLocation;
+
+
+
+ @Value("${file.upload.dir}/files")
+ private String UPLOAD_DIR;
+
+
+ @PostConstruct
+ void init(){
+ fileLocation = Path.of(UPLOAD_DIR).toAbsolutePath().normalize();
+ try {
+ Files.createDirectories(this.fileLocation);
+ } catch (Exception ex) {
+ throw new RuntimeException("Could not create the directory where the uploaded files will be stored.", ex);
+ }
+ }
+
}
--
Gitblit v1.7.1