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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.web.jhsop.websocket.controller;
 
import com.alibaba.fastjson.JSON;
import com.app.base.control.WebController;
import com.app.base.data.ApiResponseResult;
 
import com.web.jhsop.websocket.entity.SopFile;
import com.web.jhsop.websocket.service.SopSendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import java.util.Map;
 
@Api(description = "SOP公共接口")
@CrossOrigin
@ControllerAdvice
// @RestController
@Controller
@RequestMapping(value = "/sop")
public class SopController extends WebController {
 
    @Autowired
    private SopSendService sopSendService;
 
    @ApiOperation(value = "sop分发", notes = "sop分发")
    @RequestMapping(value = "/sendSop", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult sendSop(@RequestParam(value = "deviceId", required = false) String deviceCode,
                                     @RequestParam(value = "url", required = false) String url,
                                     @RequestParam(value = "account", required = false) String account,
                                     @RequestParam(value = "password", required = false) String password,
                                     @RequestParam(value = "path", required = false) String path,
                                     @RequestParam(value = "root", required = false) String root,
                                     @RequestParam(value = "fileName", required = false) String fileName,
                                     @RequestParam(value = "workOrder", required = false) String workOrder,
                                     @RequestParam(value = "processLine",required = false)String processLine,
                                     @RequestParam(value = "page",required = false)Integer page) throws Exception{
        try{
            return sopSendService.sendSop(deviceCode,url,account,password,path,root,fileName,workOrder,processLine,page);
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("sop分发失败");
        }
    }
 
    @ApiOperation(value = "sop分发", notes = "sop分发")
    @RequestMapping(value = "/sendAllSop", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult sendAllSop(
                                     @RequestParam(value = "url", required = false) String url,
                                     @RequestParam(value = "account", required = false) String account,
                                     @RequestParam(value = "password", required = false) String password,
                                     @RequestParam(value = "path", required = false) String path,
                                     @RequestParam(value = "root", required = false) String root,
                                     @RequestParam(value = "fileName", required = false) String fileName,
                                     @RequestParam(value = "workOrder", required = false) String workOrder,
                                     @RequestParam(value = "processLine",required = false)String processLine,
                                     @RequestParam(value = "page",required = false)Integer page) throws Exception{
        try{
            return sopSendService.sendAllSop(url,account,password,path,root,fileName,workOrder,processLine,page);
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("sop分发失败");
        }
    }
 
    @ApiOperation(value = "获取ftp文件 返回文件流", notes = "获取ftp文件 返回文件流")
    @RequestMapping(value = "/getFtpFile", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult getFtpFile(@RequestParam(value = "deviceId", required = false) String deviceCode,
                                        @RequestParam(value = "url", required = false) String url,
                                        @RequestParam(value = "account", required = false) String account,
                                        @RequestParam(value = "password", required = false) String password,
                                        @RequestParam(value = "path", required = false) String path,
                                        @RequestParam(value = "root", required = false) String root,
                                        @RequestParam(value = "fileName", required = false) String fileName) throws Exception{
        try{
            return sopSendService.getFtpFile(deviceCode,url,account,password,path,root,fileName,getResponse());
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("获取ftp文件 返回文件流失败");
        }
    }
 
    @ApiOperation(value = "跳转到对应sheet", notes = "跳转到对应sheet")
    @RequestMapping(value = "/toSheetByPage", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult toSheetByPage(@RequestParam(value = "deviceId", required = false) String deviceId,
                                           @RequestParam(value = "page", required = false) String page) throws Exception{
        try{
            return sopSendService.toSheetByPage(deviceId,page);
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("跳转到对应sheet失败");
        }
    }
 
    @ApiOperation(value = "获取所有的设备", notes = "获取所有的设备")
    @RequestMapping(value = "/getAllDevice", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult getAllDevice() throws Exception{
        try{
            return sopSendService.getAllDevice();
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("获取所有的设备失败");
        }
    }
 
    @ApiOperation(value = "获取sop文件", notes = "获取sop文件")
    @RequestMapping(value = "/getSopFile", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult getSopFile() throws Exception{
        try{
            return sopSendService.getSopFile();
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("获取sop文件失败");
        }
    }
 
    @ApiOperation(value = "sop文件分发", notes = "sop文件分发")
    @RequestMapping(value = "/distributeFile", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponseResult distributeFile(@RequestBody Map<String,Object> map
                                            ) throws Exception{
        try{
            String deviceId = map.get("deviceId").toString();
            SopFile sopFile = JSON.parseObject(JSON.toJSONString(map.get("file")), SopFile.class);
            String order = map.get("order").toString();
            return sopSendService.distributeFile(deviceId,sopFile,order);
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponseResult.failure("sop文件分发失败");
        }
    }
 
}