admin
2 天以前 4e91ae3c1ff41d0bf9f65d444c90c2583e69cdb7
提交 | 用户 | 时间
b78728 1 package com.jcdm.main.bs.formulaChild.controller;
A 2
4cba4a 3 import java.text.SimpleDateFormat;
C 4 import java.util.Date;
b78728 5 import java.util.List;
A 6 import java.util.stream.Collectors;
7 import javax.servlet.http.HttpServletResponse;
8
9 import cn.hutool.core.collection.CollUtil;
10 import cn.hutool.core.util.ObjectUtil;
11 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
12 import com.jcdm.main.constant.Constants;
616068 13 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
A 14 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
b78728 15 import com.kangaroohy.milo.model.ReadWriteEntity;
A 16 import com.kangaroohy.milo.service.MiloService;
17 import org.springframework.security.access.prepost.PreAuthorize;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.web.bind.annotation.GetMapping;
20 import org.springframework.web.bind.annotation.PostMapping;
21 import org.springframework.web.bind.annotation.PutMapping;
22 import org.springframework.web.bind.annotation.DeleteMapping;
23 import org.springframework.web.bind.annotation.PathVariable;
24 import org.springframework.web.bind.annotation.RequestBody;
25 import org.springframework.web.bind.annotation.RequestMapping;
26 import org.springframework.web.bind.annotation.RestController;
27 import com.jcdm.common.annotation.Log;
28 import com.jcdm.common.core.controller.BaseController;
29 import com.jcdm.common.core.domain.AjaxResult;
30 import com.jcdm.common.enums.BusinessType;
31 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
32 import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
33 import com.jcdm.common.utils.poi.ExcelUtil;
34 import com.jcdm.common.core.page.TableDataInfo;
35
36 /**
37  * 配方配置子信息Controller
38  * 
39  * @author ruimin
40  * @date 2023-12-26
41  */
42 @RestController
43 @RequestMapping("/bs/formulaChild")
44 public class BsFormulaChildInfoController extends BaseController
45 {
46     @Autowired
47     private IBsFormulaChildInfoService bsFormulaChildInfoService;
616068 48
A 49     @Autowired
50     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
b78728 51
A 52     @Autowired
53     private MiloService miloService;
54
55     /**
ac3856 56      * 返修信息写入plc
A 57      */
58     @GetMapping("/writeRepairInformationIntoPlc")
59     public AjaxResult writeRepairInformationIntoPlc(BsFormulaChildInfo bsFormulaChildInfo)
60     {
61         String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//获取通道
62         try {
63             String prefix = thoroughfare+".OP165.";
64             miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(prefix+"SNCode").value(bsFormulaChildInfo.getSfcCode()).build());
65             miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(prefix+"WorkOrderNumber").value(bsFormulaChildInfo.getWorkOrderNo()).build());
66             miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(prefix+"ProcessesCode").value(bsFormulaChildInfo.getProcessesCode()).build());
67             miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(prefix+"EngravingStatus").value(bsFormulaChildInfo.getEngravingStatus()).build());
68         } catch (Exception e) {
69             throw new RuntimeException(e);
70         }
71         return AjaxResult.success();
72     }
73
74     public static void main(String[] args) {
75         String str = "TZ180XSDSZX012409120000001";
76         System.out.println(str.length());
77     }
78
79     /**
b78728 80      * 未做完工序回复plc信号
A 81      */
82     @GetMapping("/unfinishedProcess")
83     public AjaxResult unfinishedProcess(BsFormulaChildInfo bsFormulaChildInfo)
84     {
989363 85         String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//获取通道
b78728 86         try {
989363 87 //            String str = "MOZU1."+bsFormulaChildInfo.getProcessesCode()+".RecordDataDone";
A 88 //            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(bsFormulaChildInfo.getRecordDataDone()).build());
89             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getProcessesCode()+".RecordDataDone").value(bsFormulaChildInfo.getRecordDataDone()).build());
b78728 90         } catch (Exception e) {
A 91             throw new RuntimeException(e);
92         }
93         return AjaxResult.success();
94     }
95
96     /**
97      * 扫码确认
98      */
99     @GetMapping("/initializedData")
100     public AjaxResult initializedData(BsFormulaChildInfo bsFormulaChildInfo)
101     {
102         String productNum = "";
103         try {
8c09d8 104             String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());
C 105             String str = thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".SNCode";
b78728 106             Object productNumObject = miloService.readFromOpcUa(str).getValue();
A 107             if(ObjectUtil.isNotNull(productNumObject)){
108                 productNum = productNumObject.toString();
109             }
110         } catch (Exception e) {
111             throw new RuntimeException(e);
112         }
113         return AjaxResult.success(productNum);
114     }
115
116     /**
117      * 扫码确认
118      */
119     @GetMapping("/fistSetpNumber")
120     public AjaxResult fistSetpNumber(BsFormulaChildInfo bsFormulaChildInfo)
121     {
122 //        try {
123 //            String str = "PACK."+bsFormulaChildInfo.getProcessesCode()+".MStepNumber";
124 //            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(1).build());
125 //        } catch (Exception e) {
126 //            throw new RuntimeException(e);
127 //        }
128         Integer stepNumber = 1;
129         try {
4280d7 130 //            List<BsFormulaChildInfo> op260 = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
A 131 //                    .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getProcessesCode())
132 //                    .eq(BsFormulaChildInfo::getOperationType, "1")
133 //            );
134 //            List<BsFormulaChildInfo> filteredList = op260.stream()
135 //                    .filter(obj -> obj.getResults() != null && !obj.getResults().isEmpty())
136 //                    .collect(Collectors.toList());
137 //            if(filteredList.size() > 0){
138 //                stepNumber = Integer.valueOf(filteredList.get(filteredList.size()-1).getStepSort())+1;
139 //            }
b78728 140
039f89 141             String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//获取通道
fd4ea6 142             String str = thoroughfare+"."+bsFormulaChildInfo.getProcessesCode()+".MESScrew";
b82de6 143             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(stepNumber).build());//拧紧步骤
252f60 144             if("OP230".equals(bsFormulaChildInfo.getProcessesCode())){
616068 145                 List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().like(OmProductionOrdeInfo::getProductNum, bsFormulaChildInfo.getSfcBarcode()));
A 146                 String sfcCode = list.get(0).getProductNum();
4cba4a 147                 //所有进站将进站时间写给PLC
C 148                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
149                 String currentDate = dateFormat.format(new Date());
150                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".StartTime").value(currentDate).build());
616068 151                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".SNCode").value(sfcCode).build());
f2a963 152                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build());
252f60 153             }else if("OP220".equals(bsFormulaChildInfo.getProcessesCode())){
f2a963 154                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build());
4cba4a 155             }
b82de6 156
b78728 157         } catch (Exception e) {
A 158             throw new RuntimeException(e);
159         }
160         return AjaxResult.success(stepNumber);
161     }
162
163     /**
164      * 查询配方配置子信息列表
165      */
166     @GetMapping("/noPageListFormulaChild")
167     public TableDataInfo noPageListFormulaChild(BsFormulaChildInfo bsFormulaChildInfo)
168     {
169
170         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
171                 .eq(BsFormulaChildInfo::getProductCode,bsFormulaChildInfo.getProductCode())
172                 .eq(BsFormulaChildInfo::getProcessesCode,bsFormulaChildInfo.getProcessesCode())
eec569 173 //                .orderByAsc(BsFormulaChildInfo::getStepSort)
b78728 174         );
A 175         if (CollUtil.isNotEmpty(list)){
176             List<BsFormulaChildInfo> collect1 = list.stream().filter(x -> Constants.OK.equals(x.getResults())).collect(Collectors.toList());
177             List<BsFormulaChildInfo> collect2 = list.stream().filter(x -> !Constants.OK.equals(x.getResults())).collect(Collectors.toList());
178             list = collect1;
179             list.addAll(collect2);
180         }
181         for (BsFormulaChildInfo formulaChildInfo : list) {
182 //            formulaChildInfo.setSort(formulaChildInfo.getStepSort());
183 //            formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
184 //            formulaChildInfo.setImg(formulaChildInfo.getOperationSteps());
185             if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){
186                 if(formulaChildInfo.getCollectData().contains("[")){
187                     String data = formulaChildInfo.getCollectData();
188                     data = data.replace("[", "").replace("]", "").replace(" ", "");
189                     String[] tightenDataParts = data.split(",");
190                     formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]);
191                 }
192             }
193         }
194         return getDataTable(list);
195     }
196
197     /**
198      * 查询配方配置子信息列表
199      */
200     @PreAuthorize("@ss.hasPermi('bs:formulaChild:list')")
201     @GetMapping("/list")
202     public TableDataInfo list(BsFormulaChildInfo bsFormulaChildInfo)
203     {
204         startPage();
205         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
206         for (BsFormulaChildInfo formulaChildInfo : list) {
207             formulaChildInfo.setSort(formulaChildInfo.getStepSort());
208             formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement());
209             formulaChildInfo.setImg(formulaChildInfo.getOperationSteps());
210             if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){
211                 if(formulaChildInfo.getCollectData().contains("[")){
212                     String data = formulaChildInfo.getCollectData();
213                     data = data.replace("[", "").replace("]", "").replace(" ", "");
214                     String[] tightenDataParts = data.split(",");
215                     formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]);
216                 }
217             }
218         }
219         return getDataTable(list);
220     }
221
222 //    /**
223 //     * 检查是否可以放行
224 //     */
225 //    @GetMapping("/releaseCheck")
226 //    public AjaxResult releaseCheck(BsFormulaChildInfo bsFormulaChildInfo)
227 //    {
228 //        List<BsFormulaChildInfo> i = bsFormulaChildInfoService.releaseCheck(bsFormulaChildInfo);
229 //        return AjaxResult.success(i.size());
230 //    }
231
232     /**
233      * 扫码确认
234      */
235     @GetMapping("/updateResults")
236     public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo)
237     {
238         return bsFormulaChildInfoService.updateResults(bsFormulaChildInfo);
239     }
240
241     /**
242      * 扫码确认
243      */
244     @GetMapping("/jrmUpdateResults")
245     public AjaxResult jrmUpdateResults(BsFormulaChildInfo bsFormulaChildInfo)
246     {
247         return bsFormulaChildInfoService.jrmUpdateResults(bsFormulaChildInfo);
248     }
249
250     /**
251      * 扫码确认
252      */
253     @GetMapping("/yzUpdateResults")
254     public AjaxResult yzUpdateResults(BsFormulaChildInfo bsFormulaChildInfo)
255     {
256         return bsFormulaChildInfoService.yzUpdateResults(bsFormulaChildInfo);
257     }
258
259     /**
260      * 放行请空状态
261      */
262     @GetMapping("/workpieceRelease")
263     public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
264     {
265         return bsFormulaChildInfoService.workpieceRelease(bsFormulaChildInfo);
266     }
267
268     /**
269      * 放行请空状态
270      */
271     @GetMapping("/checkMaterialCode")
272     public AjaxResult checkMaterialCode(BsFormulaChildInfo bsFormulaChildInfo)
273     {
274         return bsFormulaChildInfoService.checkMaterialCode(bsFormulaChildInfo);
275     }
276
277     /**
278      * 放行请空状态
279      */
280     @GetMapping("/clearWorkpieceRelease")
281     public AjaxResult clearWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
282     {
283         return bsFormulaChildInfoService.clearWorkpieceRelease(bsFormulaChildInfo);
284     }
285
286     /**
287      * 放行请空状态
288      */
289     @GetMapping("/jrmWorkpieceRelease")
290     public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo)
291     {
292         return bsFormulaChildInfoService.jrmWorkpieceRelease(bsFormulaChildInfo);
293     }
294
295     /**
296      * 拧紧后更新对应数据
297      */
298     @GetMapping("/updateTighteningFormula")
299     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
300     {
301         return bsFormulaChildInfoService.updateTighteningFormula(bsFormulaChildInfo);
302     }
303
304     /**
305      * 拧紧后更新对应数据
306      */
307     @GetMapping("/yzUpdateTighteningFormula")
308     public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo)
309     {
310         return bsFormulaChildInfoService.yzUpdateTighteningFormula(bsFormulaChildInfo);
311     }
312
313     /**
314      * 导出配方配置子信息列表
315      */
316     @PreAuthorize("@ss.hasPermi('bs:formulaChild:export')")
317     @Log(title = "配方配置子信息", businessType = BusinessType.EXPORT)
318     @PostMapping("/export")
319     public void export(HttpServletResponse response, BsFormulaChildInfo bsFormulaChildInfo)
320     {
321         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo);
322         ExcelUtil<BsFormulaChildInfo> util = new ExcelUtil<BsFormulaChildInfo>(BsFormulaChildInfo.class);
323         util.exportExcel(response, list, "配方配置子信息数据");
324     }
325
326     /**
327      * 获取配方配置子信息详细信息
328      */
329     @PreAuthorize("@ss.hasPermi('bs:formulaChild:query')")
330     @GetMapping(value = "/{id}")
331     public AjaxResult getInfo(@PathVariable("id") Long id)
332     {
333         return success(bsFormulaChildInfoService.selectBsFormulaChildInfoById(id));
334     }
335
336     /**
337      * 新增配方配置子信息
338      */
339     @PreAuthorize("@ss.hasPermi('bs:formulaChild:add')")
340     @Log(title = "配方配置子信息", businessType = BusinessType.INSERT)
341     @PostMapping
342     public AjaxResult add(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
343     {
344         return toAjax(bsFormulaChildInfoService.insertBsFormulaChildInfo(bsFormulaChildInfo));
345     }
346
347     /**
348      * 修改配方配置子信息
349      */
350     @PreAuthorize("@ss.hasPermi('bs:formulaChild:edit')")
351     @Log(title = "配方配置子信息", businessType = BusinessType.UPDATE)
352     @PutMapping
353     public AjaxResult edit(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
354     {
355         return toAjax(bsFormulaChildInfoService.updateBsFormulaChildInfo(bsFormulaChildInfo));
356     }
357
358     /**
359      * 删除配方配置子信息
360      */
361     @PreAuthorize("@ss.hasPermi('bs:formulaChild:remove')")
362     @Log(title = "配方配置子信息", businessType = BusinessType.DELETE)
363     @DeleteMapping("/{ids}")
364     public AjaxResult remove(@PathVariable Long[] ids)
365     {
366         return toAjax(bsFormulaChildInfoService.deleteBsFormulaChildInfoByIds(ids));
367     }
368 }