whyclxw
3 天以前 bfa320956f20988fe671b0c4d25aa82fe766a98d
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
package com.whyc.controller;
 
import com.google.gson.reflect.TypeToken;
import com.whyc.dto.Response;
import com.whyc.pojo.Software;
import com.whyc.service.SoftwareService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
 
@Api(tags = "软件管理-新版")
@RestController
@RequestMapping("software")
public class SoftwareController {
 
    @Autowired
    private SoftwareService service;
 
    @ApiOperation("excel解析")
    @PostMapping("excelParse")
    public Response excelParse(@RequestParam MultipartFile multipartFile) throws IOException, InvalidFormatException, ParseException {
        Response<Object> response = new Response<>();
        String name=multipartFile.getOriginalFilename();
        assert name != null;
        if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){
            response.set(1,false,"文件解析错误:上传格式非excel格式");
        }else{
            response =  service.excelParse(multipartFile.getInputStream());
        }
        return response;
    }
 
    @ApiOperation("软件上传")
    @PostMapping("upload")
    public Response upload(@RequestParam MultipartFile file1,@RequestParam MultipartFile file2,@RequestParam String fontUpdateTime,@RequestParam String softwareStr) throws IOException {
        List<Software> softwareList = ActionUtil.getGson().fromJson(softwareStr,new TypeToken<List<Software>>(){}.getType());
        return service.upload(file1,file2,fontUpdateTime,softwareList);
    }
 
    @ApiOperation("更新软件版本对应的适用机型")
    @PutMapping("applyModel")
    public Response updateApplyModel(@RequestParam MultipartFile multipartFile,@RequestParam String softwareStr) throws IOException {
        List<Software> softwareList = ActionUtil.getGson().fromJson(softwareStr,new TypeToken<List<Software>>(){}.getType());
        return service.updateApplyModel(multipartFile,softwareList);
    }
 
    /**
     *lockFlag :
     * 全部 11
     * 可用 0
     * 不可用 12
     * 待测试 -1
     */
    @ApiOperation(value = "查询软件列表的信息")
    @GetMapping("getAllSoftware")
    public Response getAllSoftware(
                                   @RequestParam(required = false) Integer lockFlag,
                                   @RequestParam(required = false) String fileName,
                                   @RequestParam(required = false) String applyMaterialCode,
                                   @RequestParam(required = false) String applyModel,
                                   @RequestParam(required = false) String owner,
                                   @RequestParam(required = false) String boardNumber,
                                   @RequestParam(required = false) String version,
                                   @RequestParam int pageCurr,@RequestParam int pageSize ){
        return service.getAllSoftware(lockFlag,fileName,applyMaterialCode,applyModel,owner,boardNumber,version,pageCurr,pageSize);
    }
 
    @ApiOperation(value = "根据subcode查询软件列表")
    @GetMapping("getSoftBySubCode")
    public Response getSoftBySubCode(@RequestParam String subCode ){
        return service.getSoftBySubCode(subCode);
    }
 
    @ApiOperation(value = "根据软件id实现软件下载")
    @GetMapping("downLoadSoftware")
    public void downLoadSoftware(HttpServletRequest req, HttpServletResponse resp, @RequestParam int id){
        service.downLoadSoftware(req,resp,id);
    }
 
    @ApiOperation(value = "根据软件id修改软件锁定状态")
    @GetMapping("updateSoftwareLock")
    public Response updateSoftwareLock(@RequestParam String fileUrl,@RequestParam int lockFlag,@RequestParam int lockFlagNow,@RequestParam String localReason){
        return service.updateSoftwareLock(fileUrl,lockFlagNow,lockFlag,localReason);
    }
 
    @ApiOperation(value = "根据软件软件名实现软件删除")
    @GetMapping("deleteSoftware")
    public Response deleteSoftware( @RequestParam String fileName,@RequestParam String version){
        return service.deleteSoftware(fileName,version);
    }
}