-
admin
2024-05-15 a320dcc8a480436f2f6b3ef81fe6b607f080a64a
提交 | 用户 | 时间
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     /**
b77303 165      * 拧紧后更新对应数据
166      */
167     @GetMapping("/updateTighteningFormula")
168     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
169     {
170         return bsFormulaChildInfoService.updateTighteningFormula(bsFormulaChildInfo);
171     }
172
173     /**
2c7661 174      * 拧紧后更新对应数据
A 175      */
176     @GetMapping("/yzUpdateTighteningFormula")
177     public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
178     {
179         return bsFormulaChildInfoService.yzUpdateTighteningFormula(bsFormulaChildInfo);
180     }
181
182     /**
e57a89 183      * 导出配方配置子信息列表
184      */
185     @PreAuthorize("@ss.hasPermi('bs:formulaChild:export')")
186     @Log(title = "配方配置子信息", businessType = BusinessType.EXPORT)
187     @PostMapping("/export")
188     public void export(HttpServletResponse response, BsFormulaChildInfo bsFormulaChildInfo)
189     {
190         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
191         ExcelUtil<BsFormulaChildInfo> util = new ExcelUtil<BsFormulaChildInfo>(BsFormulaChildInfo.class);
192         util.exportExcel(response, list, "配方配置子信息数据");
193     }
194
195     /**
196      * 获取配方配置子信息详细信息
197      */
198     @PreAuthorize("@ss.hasPermi('bs:formulaChild:query')")
199     @GetMapping(value = "/{id}")
200     public AjaxResult getInfo(@PathVariable("id") Long id)
201     {
202         return success(bsFormulaChildInfoService.selectBsFormulaChildInfoById(id));
203     }
204
205     /**
206      * 新增配方配置子信息
207      */
208     @PreAuthorize("@ss.hasPermi('bs:formulaChild:add')")
209     @Log(title = "配方配置子信息", businessType = BusinessType.INSERT)
210     @PostMapping
211     public AjaxResult add(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
212     {
213         return toAjax(bsFormulaChildInfoService.insertBsFormulaChildInfo(bsFormulaChildInfo));
214     }
215
216     /**
217      * 修改配方配置子信息
218      */
219     @PreAuthorize("@ss.hasPermi('bs:formulaChild:edit')")
220     @Log(title = "配方配置子信息", businessType = BusinessType.UPDATE)
221     @PutMapping
222     public AjaxResult edit(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
223     {
224         return toAjax(bsFormulaChildInfoService.updateBsFormulaChildInfo(bsFormulaChildInfo));
225     }
226
227     /**
228      * 删除配方配置子信息
229      */
230     @PreAuthorize("@ss.hasPermi('bs:formulaChild:remove')")
231     @Log(title = "配方配置子信息", businessType = BusinessType.DELETE)
232     @DeleteMapping("/{ids}")
233     public AjaxResult remove(@PathVariable Long[] ids)
234     {
235         return toAjax(bsFormulaChildInfoService.deleteBsFormulaChildInfoByIds(ids));
236     }
237 }