Commit b45e2685 by HlQ

[feat] 客流平台专用接口——巡检报告下载

1 parent 0b0788a4
...@@ -12,15 +12,24 @@ import lombok.RequiredArgsConstructor; ...@@ -12,15 +12,24 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.dromara.hutool.core.date.TimeUtil; import org.dromara.hutool.core.date.TimeUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.core.io.FileSystemResource;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.config.excel.FaultTypeConverter; import vion.config.excel.FaultTypeConverter;
import vion.config.excel.UserNameConverter; import vion.config.excel.UserNameConverter;
import vion.dto.TaskDTO; import vion.dto.TaskDTO;
import vion.model.FaultLog; import vion.model.FaultLog;
import vion.model.FileInfo;
import vion.model.Task; import vion.model.Task;
import vion.service.IFaultLogService; import vion.service.IFaultLogService;
import vion.service.IFileService;
import vion.service.ITaskService; import vion.service.ITaskService;
import vion.vo.TaskVO; import vion.vo.TaskVO;
import vion.vo.UserVO; import vion.vo.UserVO;
...@@ -40,6 +49,7 @@ public class TaskController { ...@@ -40,6 +49,7 @@ public class TaskController {
private final ITaskService taskService; private final ITaskService taskService;
private final IFaultLogService faultLogService; private final IFaultLogService faultLogService;
private final IFileService fileService;
private final UserNameConverter userNameConverter; private final UserNameConverter userNameConverter;
private final FaultTypeConverter faultTypeConverter; private final FaultTypeConverter faultTypeConverter;
...@@ -183,4 +193,36 @@ public class TaskController { ...@@ -183,4 +193,36 @@ public class TaskController {
public String urgeTask(Long taskId) { public String urgeTask(Long taskId) {
return taskService.urgeTask(taskId, "客户催办"); return taskService.urgeTask(taskId, "客户催办");
} }
/**
* 客流平台单独使用接口
* 巡检报告下载
* @param taskId taskId
* @return org.springframework.http.ResponseEntity<org.springframework.core.io.FileSystemResource>
*/
@GetMapping("/keliu/inspection/download")
public ResponseEntity<FileSystemResource> download(Long taskId) {
var fileInfo = fileService.lambdaQuery()
.eq(FileInfo::getSourceType, 35)
.eq(FileInfo::getSourceId, taskId)
.one();
if (ObjUtil.isNotNull(fileInfo)) {
return ResponseEntity.notFound().build();
}
var file = FileUtil.file(fileInfo.getUrl());
if (!FileUtil.exists(file)) {
return ResponseEntity.notFound().build();
}
FileSystemResource resource = new FileSystemResource(file);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.valueOf(MediaType.APPLICATION_OCTET_STREAM_VALUE));
headers.setContentDisposition(ContentDisposition.attachment().filename(file.getName()).build());
return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.body(resource);
}
} }
...@@ -34,6 +34,6 @@ public class InterceptorConfig implements WebMvcConfigurer { ...@@ -34,6 +34,6 @@ public class InterceptorConfig implements WebMvcConfigurer {
.excludePathPatterns("/api/point/upd/{uuid}", "/api/point/get/{uuid}", "/api/point/install/submit/{uuid}", "/api/point/client/reject", "/api/point/reject/uuid/{uuid}") .excludePathPatterns("/api/point/upd/{uuid}", "/api/point/get/{uuid}", "/api/point/install/submit/{uuid}", "/api/point/client/reject", "/api/point/reject/uuid/{uuid}")
.excludePathPatterns("/api/sparePart/frontSubmit", "/api/repairRec/frontSubmit") .excludePathPatterns("/api/sparePart/frontSubmit", "/api/repairRec/frontSubmit")
.excludePathPatterns("/api/mqtt/**", "/api/monitor/**") .excludePathPatterns("/api/mqtt/**", "/api/monitor/**")
.excludePathPatterns("/api/keliu/taskTemp/{uuid}", "/api/keliu/task/urge"); .excludePathPatterns("/api/keliu/taskTemp/{uuid}", "/api/keliu/task/urge", "/api/keliu/inspection/download");
} }
} }
...@@ -41,6 +41,7 @@ public class FileInfo { ...@@ -41,6 +41,7 @@ public class FileInfo {
* <br>22备件,23返修</br> * <br>22备件,23返修</br>
* <br>24验收报告,25竣工图纸,26点位表,27项目总结,28前期勘察,29巡检报告,30结算资料,31启动会</br> * <br>24验收报告,25竣工图纸,26点位表,27项目总结,28前期勘察,29巡检报告,30结算资料,31启动会</br>
* <br>32运维监测项目监控里富文本编辑器传图用这个类型</br> * <br>32运维监测项目监控里富文本编辑器传图用这个类型</br>
* <br>35客流平台创建的巡检工单对应的巡检报告</br>
*/ */
private Integer sourceType; private Integer sourceType;
/** /**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!