whyclxw
2025-03-13 935e439797c17c9f2d2c9ce8f4ffb39dc7e1b1f4
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
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.pojo.Material;
import com.whyc.service.MaterialService;
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.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
 
@Api(tags = "物料管理")
@RestController
@RequestMapping("material")
public class MaterialController {
    @Autowired
    private MaterialService service;
 
    /*@ApiOperation(value = "查询所有的散装件信息分页(带上关联的子件信息,status状态不做处理))")
    @GetMapping("getAllMaterial")
    public Response getAllMaterial(@RequestParam(required = false) String category,@RequestParam(required = false) String subCode,@RequestParam(required = false) String subName, @RequestParam(required = false) String subModel,@RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getAllMaterial(category,subCode,subName,subModel,pageCurr,pageSize);
    }*/
   /* @ApiOperation(tags = "产品管理",value = "查询所有的散装件信息不分页(不包含被最新版本关联的散装件,status=1可用)")
    @GetMapping("getMaterialWithoutSub")
    public Response getMaterialWithoutSub(@RequestParam String parentModel, @RequestParam String subName, @RequestParam int version){
        return service.getMaterialWithoutSub(parentModel,subName,version);
    }*/
    /*@ApiOperation(value = "删除散装件(将散装件标识为不可用)")
    @GetMapping("deleteMaterial")
    public Response deleteMaterial(@RequestParam int id){
        return service.deleteMaterial(id);
    }*/
 
    @ApiOperation(value = "查询所有物料(分页,模糊查询)",notes = "8.17修改后使用")
    @GetMapping("getMaterialLimit")
    public Response getMaterialLimit(@RequestParam(required = false) String subCode,@RequestParam(required = false) String subName, @RequestParam(required = false) String subModel,@RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getMaterialLimit(subCode,subName,subModel,pageCurr,pageSize);
    }
 
    @PostMapping
    @ApiOperation(value = "新增",notes = "解析返回的绝对路径,需要回传到字段fileUrl")
    public Response add(@RequestBody List<Material> materialList){
        return service.add(materialList);
    }
 
    @PostMapping("zipParse")
    @ApiOperation("zip解析")
    public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException {
        return service.zipParse(file);
    }
 
    @ApiOperation(value = "根据物料id查询返回附件文件夹下所有的文件列表",notes = "9.3修改后使用")
    @GetMapping("getAttachByMaterialId")
    public Response getAttachByMaterialId(@RequestParam int materialId){
        return service.getAttachByMaterialId(materialId);
    }
 
 
    @ApiOperation(value = "根据物料型号('-','_'之前的部分)查询物料的历史版本",notes = "9.3修改后使用")
    @GetMapping("getMaterialVersion")
    public Response getMaterialVersion(@RequestParam String subModel){
        return service.getMaterialVersion(subModel);
    }
 
    @ApiOperation(value = "根据物料id查询物料信息",notes = "9.3修改后使用")
    @GetMapping("getMaterialById")
    public Response getMaterialById(@RequestParam int materialId){
        return service.getMaterialById(materialId);
    }
 
    /**物料id-物料编码-物料型号*/
    @ApiOperation(value = "追加附件",notes = "materialStr为json字符串,包含id,subCode,subModel")
    @PostMapping("attachment")
    public Response addAttachment(@RequestParam String materialStr, @RequestParam MultipartFile... file) throws IOException {
        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
        List<MultipartFile> multipartFileList = Arrays.asList(file);
        return service.addAttachment(multipartFileList,material);
    }
 
    @ApiOperation("物料图纸对比")
    @GetMapping("dwgCompare")
    public Response dwgCompare(@RequestParam int materialId,@RequestParam int materialId2) throws IOException {
        return service.dwgCompare(materialId,materialId2);
    }
 
    /**物料id-物料编码-物料型号*/
    @ApiOperation(value = "更新图片或者图纸",notes = "materialStr为json字符串,包含id,subCode,subModel")
    @PutMapping("picOrDwg")
    public Response updatePicOrDwg(@RequestParam String materialStr, @RequestPart MultipartFile file) throws IOException {
        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
        return service.updatePicOrDwg(file,material);
    }
 
    @PostMapping("checkNaming")
    @ApiOperation("命名规范校验")
    public void checkNaming( HttpServletResponse response,@RequestParam MultipartFile file) throws IOException, InvalidFormatException {
        service.checkNaming(file.getInputStream(),response);
    }
 
    @ApiOperation("物料推送弹窗使用")
    @GetMapping("getMaterialDialog")
    public Response getMaterialDialog(@RequestParam String subCode,@RequestParam String subName,@RequestParam String subModel)  {
        return service.getMaterialDialog(subCode,subName,subModel);
    }
}