yyt
2024-06-26 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.main.bs.formulaChild.controller;
Y 2
3 import com.jcdm.common.annotation.Log;
4 import com.jcdm.common.core.controller.BaseController;
5 import com.jcdm.common.core.domain.AjaxResult;
6 import com.jcdm.common.core.page.TableDataInfo;
7 import com.jcdm.common.enums.BusinessType;
8 import com.jcdm.common.utils.poi.ExcelUtil;
9 import com.jcdm.main.bs.formulaChild.Query.ProductProcessQuery;
10 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
11 import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
12 import com.jcdm.main.bs.formulaChild.service.impl.ProductProcessService;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.security.access.prepost.PreAuthorize;
15 import org.springframework.web.bind.annotation.*;
16
17 import javax.servlet.http.HttpServletResponse;
18 import java.util.Comparator;
19 import java.util.List;
20 import java.util.stream.Collectors;
21
22 /**
23  * 配方配置子信息Controller
24  * 
25  * @author ruimin
26  * @date 2023-12-26
27  */
28 @RestController
29 @RequestMapping("/bs/formulaChild")
30 public class BsFormulaChildInfoController extends BaseController
31 {
32     @Autowired
33     private IBsFormulaChildInfoService bsFormulaChildInfoService;
34
35     @Autowired
36     private ProductProcessService productProcessService;
37
38     private static final String ZERO = "0";
39
40     /**
41      * 查询配方配置子信息列表
42      */
43     @PreAuthorize("@ss.hasPermi('bs:formulaChild:list')")
44     @GetMapping("/list")
45     public TableDataInfo list(BsFormulaChildInfo bsFormulaChildInfo)
46     {
47         startPage();
48         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
49         for (BsFormulaChildInfo formulaChildInfo : list) {
50             formulaChildInfo.setSort(formulaChildInfo.getStepSort());
51             formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
52             formulaChildInfo.setImg(formulaChildInfo.getPicture());
53         }
54
55         return getDataTable(list);
56     }
57
58     /**
59      * 查询工艺流程
60      * @param bsFormulaChildInfo query
61      * @return list
62      */
63     @PostMapping("/getProductProcess")
64     public TableDataInfo getProductProcess(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
65     {
66         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
67         for (BsFormulaChildInfo formulaChildInfo : list) {
68             formulaChildInfo.setSort(formulaChildInfo.getStepSort());
69             formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
70             formulaChildInfo.setImg(formulaChildInfo.getPicture());
71         }
72         list = list.stream()
73                 .filter(x -> !ZERO.equals(x.getSort())).sorted(Comparator.comparing(BsFormulaChildInfo::getSort)).collect(Collectors.toList());
74         return getDataTable(list);
75     }
76
77     /**
78      * 查询工艺文件
79      * @param bsFormulaChildInfo query
80      * @return list
81      */
82     @PostMapping("/getMainProductProcess")
83     public TableDataInfo getMainProductProcess(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
84     {
85         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
86         for (BsFormulaChildInfo formulaChildInfo : list) {
87             formulaChildInfo.setSort(formulaChildInfo.getStepSort());
88             formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
89             formulaChildInfo.setImg(formulaChildInfo.getPicture());
90         }
91         list = list.stream()
92                 .filter(x -> ZERO.equals(x.getSort())).sorted(Comparator.comparing(BsFormulaChildInfo::getSort)).collect(Collectors.toList());
93         return getDataTable(list);
94     }
95
96     /**
97      * 导出配方配置子信息列表
98      */
99     @PreAuthorize("@ss.hasPermi('bs:formulaChild:export')")
100     @Log(title = "配方配置子信息", businessType = BusinessType.EXPORT)
101     @PostMapping("/export")
102     public void export(HttpServletResponse response, BsFormulaChildInfo bsFormulaChildInfo)
103     {
104         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
105         ExcelUtil<BsFormulaChildInfo> util = new ExcelUtil<BsFormulaChildInfo>(BsFormulaChildInfo.class);
106         util.exportExcel(response, list, "配方配置子信息数据");
107     }
108
109     /**
110      * 获取配方配置子信息详细信息
111      */
112     @PreAuthorize("@ss.hasPermi('bs:formulaChild:query')")
113     @GetMapping(value = "/{id}")
114     public AjaxResult getInfo(@PathVariable("id") Long id)
115     {
116         return success(bsFormulaChildInfoService.selectBsFormulaChildInfoById(id));
117     }
118
119     /**
120      * 新增配方配置子信息
121      */
122     @PreAuthorize("@ss.hasPermi('bs:formulaChild:add')")
123     @Log(title = "配方配置子信息", businessType = BusinessType.INSERT)
124     @PostMapping
125     public AjaxResult add(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
126     {
127         return toAjax(bsFormulaChildInfoService.insertBsFormulaChildInfo(bsFormulaChildInfo));
128     }
129
130     /**
131      * 修改配方配置子信息
132      */
133     @PreAuthorize("@ss.hasPermi('bs:formulaChild:edit')")
134     @Log(title = "配方配置子信息", businessType = BusinessType.UPDATE)
135     @PutMapping
136     public AjaxResult edit(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
137     {
138         return toAjax(bsFormulaChildInfoService.updateBsFormulaChildInfo(bsFormulaChildInfo));
139     }
140
141     /**
142      * 删除配方配置子信息
143      */
144     @PreAuthorize("@ss.hasPermi('bs:formulaChild:remove')")
145     @Log(title = "配方配置子信息", businessType = BusinessType.DELETE)
146     @DeleteMapping("/{ids}")
147     public AjaxResult remove(@PathVariable Long[] ids)
148     {
149         return toAjax(bsFormulaChildInfoService.deleteBsFormulaChildInfoByIds(ids));
150     }
151 }