4
hao
2025-04-16 c5fb1fbcbb2bf4d511773d348f9ef625855c61fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.web.pda.lyt.lytPda.controller;
 
 
import com.app.base.data.ApiResponseResult;
import com.web.pda.lyt.lytPda.service.FileCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
 
 
@Api(description = "附件管理")
@CrossOrigin
@ControllerAdvice
@RestController
@RequestMapping(value = "/rk_file")
public class FileCheckController {
 
    @Autowired
    private FileCheckService fileCheckService;
 
    
    @ApiOperation(value = "获取ftp的基础数据", notes = "获取ftp的基础数据")
    @RequestMapping(value = "/uploadFilepqc", method = RequestMethod.POST)
    public ApiResponseResult uploadFilepqc(
            @RequestParam(value = "mid") String mid,
            @RequestParam(value = "username") String username,
            @RequestParam("file0") MultipartFile[] files0,
            @RequestParam("file1") MultipartFile[] files1,@RequestParam("file2") MultipartFile[] files2,
            @RequestParam("file3") MultipartFile[] files3,@RequestParam("file4") MultipartFile[] files4,
            @RequestParam("file5") MultipartFile[] files5,@RequestParam("file6") MultipartFile[] files6,
            @RequestParam("file7") MultipartFile[] files7,@RequestParam("file8") MultipartFile[] files8) {        
      try {
          //11是IQC检验,71是IQC定期检验
          MultipartFile[]  files =  new MultipartFile[9];
          if(files0.length > 0){
              files[0] = files0[0];
          }
          if(files1.length > 0){
              files[1] = files1[0];
          }
          if(files2.length > 0){
              files[2] = files2[0];
          }
          if(files3.length > 0){
              files[3] = files3[0];
          }
          if(files4.length > 0){
              files[4] = files4[0];
          }
          if(files5.length > 0){
              files[5] = files5[0];
          }
          if(files6.length > 0){
              files[6] = files6[0];
          }
          if(files7.length > 0){
              files[7] = files7[0];
          }
          if(files8.length > 0){
              files[8] = files8[0];
          }
          return fileCheckService.uploadFilepqc(username,mid,files);
        } catch (Exception e) {
            System.out.println(e.toString());
            return ApiResponseResult.failure("获取ftp的基础数据失败!");
        }
    }
    
    @ApiOperation(value = "查询该检验项目的所有照片", notes = "查询该检验项目的所有照片")
    @RequestMapping(value = "/getFilesList", method = RequestMethod.POST, produces = "application/json")
    public ApiResponseResult getFilesList(@RequestParam(value = "mid") String mid) {        
      try {
          System.out.println(mid);
          return fileCheckService.getFilesList(mid);
        } catch (Exception e) {
            System.out.println(e.toString());
            return ApiResponseResult.failure("查询文件列表失败!");
        }
    }
    
    @ApiOperation(value="下载文件", notes="下载文件")
    @RequestMapping(value = "/getFile", method = RequestMethod.GET)
    public void get(@RequestParam(value = "fsFileId", required = true) Long fsFileId) {
        try {
            //fileCheckService.getFile(fsFileId, getResponse());
        } catch (Exception e) {
            System.out.println(e.toString());
           // return ApiResponseResult.failure("查询批次号失败!");
        }
    }
 
    @ApiOperation(value="图片在线预览", notes="图片在线预览")
    @RequestMapping(value = "/view", method = RequestMethod.GET)
    public void view(@RequestParam(value = "url", required = true) String url,
            @RequestParam(value = "fname", required = true) String fname) {
        try {
            fileCheckService.onlineView(url, fname,getResponse());
        } catch (Exception e) {
            System.out.println(e.toString());
           // return ApiResponseResult.failure("查询批次号失败!");
        }
    }
    
    /**
     * 获取response
     * @return
     */
    protected HttpServletResponse getResponse() {
        return getServletRequestAttributes().getResponse();
    }
    /**
     * 获取servlet属性
     * @return
     */
    protected final ServletRequestAttributes getServletRequestAttributes() {
        return (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    }
    
    
}