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