zss
2023-08-31 fa40e09b66af9d17b6d2dda1a3d4687ad72bf668
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
package com.yuanchu.mom.controller;
 
import com.yuanchu.mom.pojo.dto.MaterialDto;
import com.yuanchu.mom.service.*;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
@Api(tags = "技术管理-->标准BOM")
@RestController
@RequestMapping("/material")
public class MaterialController {
 
    @Autowired
    private MaterialService materialService;
 
    @Resource
    TechnologyService technologyService;
 
    @Resource
    ProductService productService;
 
    @Resource
    MbomService mbomService;
 
    @Resource
    TechniqueService techniqueService;
 
    @ApiOperation(value = "左侧五级树展示")
    @GetMapping("/selectTreeByMaterial")
    public Result selectTreeByMaterial() {
        return Result.success(materialService.selectTreeByMaterial());
    }
 
    @ApiOperation("(1,2级)新增-->物料,标准,型号")
    @PostMapping("/add")
    public Result<?> addMaterial(@Validated @RequestBody MaterialDto materialDto) {
        materialService.addMaterial(materialDto);
        return Result.success("添加物料【" + materialDto.getName() + "】成功");
    }
 
    @ApiOperation(value = "右侧数据展示-->选择版本")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "specificationsId", value = "型号id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "type", value = "类型(0:工艺路线;1:技术指标;2:物料清单;3:生产工艺)", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectVersion")
    public Result selectVersion(Integer type, Integer specificationsId) {
        switch (type) {
            case 0:
                //工艺路线
                return Result.success(technologyService.selectVerByTec(specificationsId));
            case 1:
                //技术指标
                return Result.success(productService.selectVerByPro(specificationsId));
            case 2:
                //物料清单
                return Result.success(mbomService.selectVerByMbom(specificationsId));
            case 3:
                //生产工艺
                return Result.success(techniqueService.selectVerByTeq(specificationsId));
        }
        return Result.fail("没有该类型!");
    }
 
    @ApiOperation(value = "右侧数据展示")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "specificationsId", value = "型号id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "type", value = "类型(0:工艺路线;1:技术指标;2:物料清单;3:生产工艺)", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "version", value = "版本(默认最新)", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "message", value = "搜索内容", dataTypeClass = String.class)
    })
    @GetMapping("/selectAll")
    public Result selectAll(Integer specificationsId, Integer type, Integer version,String message) {
        switch (type) {
            case 0:
                //工艺路线
                return Result.success(technologyService.selectAllTec(specificationsId, version,message));
            case 1:
                //技术指标
                return Result.success(productService.selectAllPro(specificationsId, version,message));
            case 2:
                //物料清单
                return Result.success(mbomService.selectAllMbom(specificationsId, version,message));
            case 3:
                //生产工艺
                return Result.success(techniqueService.selectAllTeq(specificationsId, version,message));
        }
        return Result.fail("没有该类型!");
    }
}