lxw
2022-09-02 2de83db7de28efd4777938624095c0b206115812
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
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.pojo.Product;
import com.whyc.service.*;
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;
 
@Api(tags = "产品管理")
@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private ProductService service;
 
    @Autowired
    private ProductHistoryService historyService;
 
    @Autowired
    private ProductBomService bomService;
 
    @Autowired
    private ProductBomHistoryService bomHistoryService;
 
    @Autowired
    private MaterialService meterService;
 
    @ApiOperation(value = "建立关联时查询所有的物料(不分页)",notes = "8.17修改后使用")
    @GetMapping("getAllMaterialNoLimit")
    public Response getAllMaterialNoLimit(){
        return meterService.getAllMaterialNoLimit();
    }
 
    @ApiOperation(value = "查询出所有的产品信息(分页加模糊查询<产品的编码,型号,名字,定制表编号>)",notes = "8.17修改后使用")
    @GetMapping("getAllProduct")
    public Response getAllProduct(@RequestParam(required = false) String parentCode,@RequestParam(required = false) String parentName, @RequestParam(required = false) String parentModel
            ,  @RequestParam(required = false) String customCode, @RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getAllProduct(parentCode,parentName,parentModel,customCode,pageCurr,pageSize);
    }
    @ApiOperation(value = "产品详情查看版本信息",notes = "8.17修改后使用")
    @GetMapping("getProductVersion")
    public Response getProductVersion( @RequestParam String parentCode, String customCode){
        return historyService.getProductVersion(parentCode,customCode);
    }
    @ApiOperation(value = "根据产品id和版本查询子件及其关联的物料信息",notes = "8.17修改后使用")
    @GetMapping("getBomAndMaterial")
    public Response getBomAndMaterial( @RequestParam int productId, @RequestParam int version){
        return bomService.getBomAndMaterial(productId,version);
    }
    @ApiOperation(value = "产品下载(产品id和版本<当前最新版本>)",notes = "8.17修改后使用")
    @GetMapping("downloadProduct")
    public void downloadProduct(HttpServletRequest req, HttpServletResponse resp, @RequestParam int productId, @RequestParam int version){
         bomService.downloadProduct(req,resp,productId,version);
    }
 
    @ApiOperation(value = "历史产品信息查看(根据历史产品产品id和版本查询子件及其关联的物料信息)",notes = "8.17修改后使用")
    @GetMapping("getBomHistoryAndMaterial")
    public Response getBomHistoryAndMaterial( @RequestParam int productId, @RequestParam int version){
        return bomHistoryService.getBomHistoryAndMaterial(productId,version);
    }
    @ApiOperation(value = "历史产品下载(产品id和版本<下载的版本>)",notes = "8.17修改后使用")
    @GetMapping("downloadProductHistory")
    public void downloadProductHistory(HttpServletRequest req, HttpServletResponse resp, @RequestParam int productId, @RequestParam int version){
        bomHistoryService.downloadProductHistory(req,resp,productId,version);
    }
 
    @ApiOperation(value = "历史版本可用性设定",notes = "8.31修改后使用")
    @GetMapping("setpHistoryEnable")
    public Response setpHistoryEnable( @RequestParam String parentCode, @RequestParam String customCode, @RequestParam int version,@RequestParam int enabled) {
        return historyService.setpHistoryEnable(parentCode, customCode, version, enabled);
    }
    @PostMapping("zipParse")
    @ApiOperation("zip解析")
    public Response zipParse(@RequestParam("file") MultipartFile file) throws IOException, InvalidFormatException {
        return service.zipParse(file);
    }
 
    @PostMapping
    @ApiOperation(value = "新增",notes = "解析时返回的绝对路径,需要回传到字段fileUrl")
    public Response add(@RequestBody Product product){
        return service.add(product);
    }
}