yuan
2026-04-24 b4a9e12e00b78e1aef8acda070434de9ffd0d66a
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
package com.ruoyi.technology.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.technology.bean.dto.BomImportDto;
import com.ruoyi.technology.bean.dto.TechnologyBomDto;
import com.ruoyi.technology.bean.vo.TechnologyBomVo;
import com.ruoyi.technology.pojo.TechnologyBom;
import com.ruoyi.technology.service.TechnologyBomService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
@RestController
@RequestMapping("/technologyBom")
@RequiredArgsConstructor
@Tag(name = "基础BOM")
public class TechnologyBomController {
 
    private final TechnologyBomService technologyBomService;
 
    @GetMapping("/listPage")
    @Log(title = "Technology BOM page", businessType = BusinessType.OTHER)
    @Operation(summary = "BOM分页查询")
    public R<IPage<TechnologyBomVo>> listPage(Page<TechnologyBomDto> page, TechnologyBomDto technologyBomDto) {
        return R.ok(technologyBomService.listPage(page, technologyBomDto));
    }
 
    @PostMapping("/add")
    @Log(title = "Add technology BOM", businessType = BusinessType.INSERT)
    @Operation(summary = "新增BOM")
    public R add(@RequestBody TechnologyBom technologyBom) {
        return technologyBomService.add(technologyBom);
    }
 
    @PutMapping("/update")
    @Log(title = "Update technology BOM", businessType = BusinessType.UPDATE)
    @Operation(summary = "修改BOM")
    public R update(@RequestBody TechnologyBom technologyBom) {
        return technologyBomService.update(technologyBom);
    }
 
    @DeleteMapping("/batchDelete")
    @Log(title = "Delete technology BOM", businessType = BusinessType.DELETE)
    @Operation(summary = "批量删除BOM")
    public R batchDelete(@RequestBody List<Long> ids) {
        return R.ok(technologyBomService.batchDelete(ids));
    }
 
    @GetMapping("/getByModel")
    @Log(title = "List BOM by model", businessType = BusinessType.OTHER)
    @Operation(summary = "根据规格查询BOM")
    public R<List<TechnologyBomVo>> getByModel(Long productModelId) {
        return R.ok(technologyBomService.listByModel(productModelId));
    }
 
    @PostMapping("/uploadBom")
    @PreAuthorize("@ss.hasPermi('product:bom:import')")
    @Log(title = "根据Excel导入BOM", businessType = BusinessType.IMPORT)
    @Operation(summary = "根据Excel导入BOM")
    public R uploadBom(@RequestParam("file") MultipartFile file) {
        return technologyBomService.uploadBom(file);
    }
 
    @PostMapping("/exportBom")
    @PreAuthorize("@ss.hasPermi('product:bom:export')")
    @Operation(summary = "导出BOM文件")
    @Log(title = "导出BOM文件", businessType = BusinessType.EXPORT)
    public void exportBom(HttpServletResponse response, @RequestParam Integer bomId) {
        technologyBomService.exportBom(response, bomId);
    }
 
    @GetMapping("/downloadTemplate")
    @Log(title = "下载BOM导入模板", businessType = BusinessType.EXPORT)
    @Operation(summary = "下载BOM导入模板")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<BomImportDto> excelUtil = new ExcelUtil<>(BomImportDto.class);
        excelUtil.importTemplateExcel(response, "BOM导入模板");
    }
 
    @PostMapping("/copy")
    @Log(title = "Copy technology BOM", businessType = BusinessType.INSERT)
    @Operation(summary = "复制BOM")
    public R copy(@RequestBody TechnologyBom technologyBom) {
        return technologyBomService.copy(technologyBom);
    }
}