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