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