1
hao
2025-05-20 8e24c6fea30d9b179375ee2893710cdec2443b13
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package com.web.pda.lyt.ftp.controller;
 
 
import com.app.base.data.ApiResponseResult;
import com.web.pda.lyt.ftp.service.FileCheckLytService;
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 = "lyt附件管理")
@CrossOrigin
@ControllerAdvice
@RestController
@RequestMapping(value = "/lyt_file")
public class FileCheckLytController {
 
    @Autowired
    private FileCheckLytService fileCheckLytService;
 
    
    @ApiOperation(value = "获取ftp的基础数据", notes = "获取ftp的基础数据")
    @RequestMapping(value = "/uploadFilepqc", method = RequestMethod.POST)
    public ApiResponseResult uploadFilepqc(@RequestParam(value = "type1") String type,
            @RequestParam(value = "company") String company,@RequestParam(value = "factory") String factory,
            @RequestParam(value = "mid") String mid,@RequestParam(value = "username") String username,
            @RequestParam(value = "note") String note,
            @RequestParam("pid") String pid, // ✅ 新增
            @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 fileCheckLytService.uploadFilepqc(factory,company,username,Integer.parseInt(mid),Integer.parseInt(type),note,files,pid);
        } catch (Exception e) {
            System.out.println(e.toString());
            return ApiResponseResult.failure("获取ftp的基础数据失败!");
        }
    }
    
    @ApiOperation(value = "获取ftp的基础数据", notes = "获取ftp的基础数据")
    @RequestMapping(value = "/uploadFileIpqc", method = RequestMethod.POST)
    public ApiResponseResult uploadFileIpqc(@RequestParam(value = "type1") String type,
            @RequestParam(value = "company") String company,@RequestParam(value = "factory") String factory,
            @RequestParam(value = "mid") String mid,@RequestParam(value = "username") String username,
            @RequestParam(value = "note") String note, @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 fileCheckLytService.uploadFileIpqc(factory,company,username,Integer.parseInt(mid),Integer.parseInt(type),note,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 {
          return fileCheckLytService.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 {
            fileCheckLytService.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();
    }
    
    
}