whycxzp
2025-05-09 4dde1b58e8731fd94ec07c9e1c48566d74bb252b
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
package com.whyc.controller;
 
import com.google.gson.reflect.TypeToken;
import com.whyc.dto.Response;
import com.whyc.pojo.TechnicalSpecification;
import com.whyc.service.TechnicalSpecificationService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import java.io.IOException;
import java.text.ParseException;
 
@Api(tags = "技术规格书")
@RestController
@RequestMapping("technicalSpecification")
public class TechnicalSpecificationController {
 
    @Autowired
    private TechnicalSpecificationService 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 technicalSpecificationStr) throws IOException {
        TechnicalSpecification specification = ActionUtil.getGson().fromJson(technicalSpecificationStr,new TypeToken<TechnicalSpecification>(){}.getType());
        return service.upload(file1,file2,specification);
    }
 
    @ApiOperation("更新锁定状态")
    @PostMapping("updateLock")
    public Response updateLock(@RequestParam int id,@RequestParam int lockFlag,@RequestParam(required = false) String reason) throws IOException {
        return service.updateLock(id,lockFlag,reason);
    }
 
    @ApiOperation("查询技术规格书")
    @PostMapping("getInfo")
    public Response getInfo(@RequestParam(required = false) String applyMaterialCode ,@RequestParam(required = false) String applyModel,@RequestParam(required = false) String applyCustomCode
                           ,@RequestParam(required = false) String owner,@RequestParam(required = false) Integer lockFlag
                           ,@RequestParam int pageNum,@RequestParam int pageSize) {
        return service.getInfo(applyMaterialCode,applyModel,applyCustomCode,owner,lockFlag,pageNum,pageSize);
    }
 
    @ApiOperation("查询指定技术规格书的所有版本")
    @PostMapping("getVersionByInfo")
    public Response getVersionByInfo(@RequestParam(required = false) String applyMaterialCode ,@RequestParam(required = false) String applyModel,@RequestParam(required = false) String applyCustomCode) {
        return service.getVersionByInfo(applyMaterialCode,applyModel,applyCustomCode);
    }
}