admin
2024-06-15 8cfe20288690f2ba46c804f41f39e8aa48c2dea0
提交 | 用户 | 时间
e57a89 1 package com.jcdm.main.bs.formulaChild.controller;
2
3 import java.util.List;
6a462f 4 import java.util.stream.Collectors;
e57a89 5 import javax.servlet.http.HttpServletResponse;
0caf87 6
6a462f 7 import cn.hutool.core.collection.CollUtil;
0caf87 8 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
6a462f 9 import com.jcdm.main.constant.Constants;
a320dc 10 import com.kangaroohy.milo.model.ReadWriteEntity;
A 11 import com.kangaroohy.milo.service.MiloService;
e57a89 12 import org.springframework.security.access.prepost.PreAuthorize;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.web.bind.annotation.GetMapping;
15 import org.springframework.web.bind.annotation.PostMapping;
16 import org.springframework.web.bind.annotation.PutMapping;
17 import org.springframework.web.bind.annotation.DeleteMapping;
18 import org.springframework.web.bind.annotation.PathVariable;
19 import org.springframework.web.bind.annotation.RequestBody;
20 import org.springframework.web.bind.annotation.RequestMapping;
21 import org.springframework.web.bind.annotation.RestController;
22 import com.jcdm.common.annotation.Log;
23 import com.jcdm.common.core.controller.BaseController;
24 import com.jcdm.common.core.domain.AjaxResult;
25 import com.jcdm.common.enums.BusinessType;
26 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
27 import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
28 import com.jcdm.common.utils.poi.ExcelUtil;
29 import com.jcdm.common.core.page.TableDataInfo;
30
31 /**
32  * 配方配置子信息Controller
33  * 
34  * @author ruimin
35  * @date 2023-12-26
36  */
37 @RestController
38 @RequestMapping("/bs/formulaChild")
39 public class BsFormulaChildInfoController extends BaseController
40 {
41     @Autowired
42     private IBsFormulaChildInfoService bsFormulaChildInfoService;
43
a320dc 44     @Autowired
A 45     private MiloService miloService;
46
47     /**
48      * 扫码确认
49      */
50     @GetMapping("/fistSetpNumber")
51     public void fistSetpNumber(BsFormulaChildInfo bsFormulaChildInfo)
52     {
53         try {
54             String str = "PACK."+bsFormulaChildInfo.getProcessesCode()+".MStepNumber";
55             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(1).build());
56         } catch (Exception e) {
57             throw new RuntimeException(e);
58         }
59     }
60
e57a89 61     /**
62      * 查询配方配置子信息列表
63      */
0caf87 64     @GetMapping("/noPageListFormulaChild")
65     public TableDataInfo noPageListFormulaChild(BsFormulaChildInfo bsFormulaChildInfo)
66     {
a320dc 67
0caf87 68         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
69                 .eq(BsFormulaChildInfo::getProductCode,bsFormulaChildInfo.getProductCode())
70                 .eq(BsFormulaChildInfo::getProcessesCode,bsFormulaChildInfo.getProcessesCode()));
6a462f 71         if (CollUtil.isNotEmpty(list)){
W 72             List<BsFormulaChildInfo> collect1 = list.stream().filter(x -> Constants.OK.equals(x.getResults())).collect(Collectors.toList());
73             List<BsFormulaChildInfo> collect2 = list.stream().filter(x -> !Constants.OK.equals(x.getResults())).collect(Collectors.toList());
74             list = collect1;
75             list.addAll(collect2);
76         }
0caf87 77         for (BsFormulaChildInfo formulaChildInfo : list) {
78 //            formulaChildInfo.setSort(formulaChildInfo.getStepSort());
79 //            formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
80 //            formulaChildInfo.setImg(formulaChildInfo.getOperationSteps());
81             if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){
82                 if(formulaChildInfo.getCollectData().contains("[")){
83                     String data = formulaChildInfo.getCollectData();
84                     data = data.replace("[", "").replace("]", "").replace(" ", "");
85                     String[] tightenDataParts = data.split(",");
86                     formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]);
87                 }
88             }
89         }
90         return getDataTable(list);
91     }
92
93     /**
94      * 查询配方配置子信息列表
95      */
e57a89 96     @PreAuthorize("@ss.hasPermi('bs:formulaChild:list')")
97     @GetMapping("/list")
98     public TableDataInfo list(BsFormulaChildInfo bsFormulaChildInfo)
99     {
100         startPage();
101         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
102         for (BsFormulaChildInfo formulaChildInfo : list) {
103             formulaChildInfo.setSort(formulaChildInfo.getStepSort());
104             formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
105             formulaChildInfo.setImg(formulaChildInfo.getOperationSteps());
b77303 106             if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){
107                 if(formulaChildInfo.getCollectData().contains("[")){
108                     String data = formulaChildInfo.getCollectData();
109                     data = data.replace("[", "").replace("]", "").replace(" ", "");
110                     String[] tightenDataParts = data.split(",");
111                     formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]);
112                 }
113             }
e57a89 114         }
115         return getDataTable(list);
116     }
117
b77303 118 //    /**
119 //     * 检查是否可以放行
120 //     */
121 //    @GetMapping("/releaseCheck")
122 //    public AjaxResult releaseCheck(BsFormulaChildInfo bsFormulaChildInfo)
123 //    {
124 //        List<BsFormulaChildInfo> i = bsFormulaChildInfoService.releaseCheck(bsFormulaChildInfo);
125 //        return AjaxResult.success(i.size());
126 //    }
e57a89 127
128     /**
129      * 扫码确认
130      */
131     @GetMapping("/updateResults")
132     public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo)
133     {
134         return bsFormulaChildInfoService.updateResults(bsFormulaChildInfo);
135     }
136
137     /**
2c7661 138      * 扫码确认
A 139      */
06713a 140     @GetMapping("/jrmUpdateResults")
A 141     public AjaxResult jrmUpdateResults(BsFormulaChildInfo bsFormulaChildInfo)
142     {
143         return bsFormulaChildInfoService.jrmUpdateResults(bsFormulaChildInfo);
144     }
145
146     /**
147      * 扫码确认
148      */
2c7661 149     @GetMapping("/yzUpdateResults")
A 150     public AjaxResult yzUpdateResults(BsFormulaChildInfo bsFormulaChildInfo)
151     {
152         return bsFormulaChildInfoService.yzUpdateResults(bsFormulaChildInfo);
153     }
154
155     /**
e57a89 156      * 放行请空状态
157      */
158     @GetMapping("/workpieceRelease")
159     public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
160     {
161         return bsFormulaChildInfoService.workpieceRelease(bsFormulaChildInfo);
162     }
163
164     /**
8cfe20 165      * 放行请空状态
A 166      */
167     @GetMapping("/clearWorkpieceRelease")
168     public AjaxResult clearWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
169     {
170         return bsFormulaChildInfoService.clearWorkpieceRelease(bsFormulaChildInfo);
171     }
172
173     /**
174      * 放行请空状态
175      */
176     @GetMapping("/jrmWorkpieceRelease")
177     public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
178     {
179         return bsFormulaChildInfoService.jrmWorkpieceRelease(bsFormulaChildInfo);
180     }
181
182     /**
b77303 183      * 拧紧后更新对应数据
184      */
185     @GetMapping("/updateTighteningFormula")
186     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
187     {
188         return bsFormulaChildInfoService.updateTighteningFormula(bsFormulaChildInfo);
189     }
190
191     /**
2c7661 192      * 拧紧后更新对应数据
A 193      */
194     @GetMapping("/yzUpdateTighteningFormula")
195     public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
196     {
197         return bsFormulaChildInfoService.yzUpdateTighteningFormula(bsFormulaChildInfo);
198     }
199
200     /**
e57a89 201      * 导出配方配置子信息列表
202      */
203     @PreAuthorize("@ss.hasPermi('bs:formulaChild:export')")
204     @Log(title = "配方配置子信息", businessType = BusinessType.EXPORT)
205     @PostMapping("/export")
206     public void export(HttpServletResponse response, BsFormulaChildInfo bsFormulaChildInfo)
207     {
208         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
209         ExcelUtil<BsFormulaChildInfo> util = new ExcelUtil<BsFormulaChildInfo>(BsFormulaChildInfo.class);
210         util.exportExcel(response, list, "配方配置子信息数据");
211     }
212
213     /**
214      * 获取配方配置子信息详细信息
215      */
216     @PreAuthorize("@ss.hasPermi('bs:formulaChild:query')")
217     @GetMapping(value = "/{id}")
218     public AjaxResult getInfo(@PathVariable("id") Long id)
219     {
220         return success(bsFormulaChildInfoService.selectBsFormulaChildInfoById(id));
221     }
222
223     /**
224      * 新增配方配置子信息
225      */
226     @PreAuthorize("@ss.hasPermi('bs:formulaChild:add')")
227     @Log(title = "配方配置子信息", businessType = BusinessType.INSERT)
228     @PostMapping
229     public AjaxResult add(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
230     {
231         return toAjax(bsFormulaChildInfoService.insertBsFormulaChildInfo(bsFormulaChildInfo));
232     }
233
234     /**
235      * 修改配方配置子信息
236      */
237     @PreAuthorize("@ss.hasPermi('bs:formulaChild:edit')")
238     @Log(title = "配方配置子信息", businessType = BusinessType.UPDATE)
239     @PutMapping
240     public AjaxResult edit(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
241     {
242         return toAjax(bsFormulaChildInfoService.updateBsFormulaChildInfo(bsFormulaChildInfo));
243     }
244
245     /**
246      * 删除配方配置子信息
247      */
248     @PreAuthorize("@ss.hasPermi('bs:formulaChild:remove')")
249     @Log(title = "配方配置子信息", businessType = BusinessType.DELETE)
250     @DeleteMapping("/{ids}")
251     public AjaxResult remove(@PathVariable Long[] ids)
252     {
253         return toAjax(bsFormulaChildInfoService.deleteBsFormulaChildInfoByIds(ids));
254     }
255 }