春风项目四线(合箱线、总装线)
wujian
2024-09-10 51b05b093fa15dd477981372f67ae7b3b2747733
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
package com.jcdm.main.bs.orderScheduling.controller;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.github.pagehelper.PageInfo;
import com.jcdm.common.annotation.Log;
import com.jcdm.common.core.controller.BaseController;
import com.jcdm.common.core.domain.AjaxResult;
import com.jcdm.common.core.domain.R;
import com.jcdm.common.core.domain.entity.SysDictData;
import com.jcdm.common.core.page.TableDataInfo;
import com.jcdm.common.enums.BusinessType;
import com.jcdm.common.exception.ServiceException;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.common.utils.poi.ExcelUtil;
import com.jcdm.main.bs.orderScheduling.common.Constants;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO;
import com.jcdm.main.bs.orderScheduling.vo.LineChartVO;
import com.jcdm.main.bs.orderScheduling.vo.SumDataVO;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation;
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService;
import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection;
import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.impl.OmProductionOrdeInfoServiceImpl;
import com.jcdm.main.plcserver.conf.OPCElement;
import com.jcdm.main.plcserver.sub.OPCUaSubscription;
import com.jcdm.system.service.ISysDictDataService;
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.kangaroohy.milo.service.MiloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 订单排产Controller
 * 
 * @author jiang
 * @date 2024-01-13
 */
@RestController
@RequestMapping("/bs/orderScheduling")
public class BsOrderSchedulingController extends BaseController
{
    @Autowired
    private IBsOrderSchedulingService bsOrderSchedulingService;
 
 
    @Resource
    private ISysDictDataService iSysDictDataService;
 
    @Resource
    private OmProductionOrdeInfoServiceImpl productionOrdeInfoService;
    @Resource
    private DaParamCollectionMapper daParamCollectionService;
    @Resource
    private IDaTileMatchCollectionService daTileMatchCollectionService;
    @Resource
    private ProductNewPassStationService productNewPassStationService;
 
    @Resource
    private IDaPassingStationCollectionService daPassingStationCollectionService;
 
    @Autowired
    MiloService miloService;
 
    @Value("${websocketUrl}")
    private String websocketUrl;
 
    @GetMapping("/forceUpload")
    public void forceUpload() throws Exception {
        ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP121_ZZ_CODE_CHECK, 1);
        miloService.writeToOpcByte(entity);
    }
 
    @GetMapping("/websocketUrl")
    public String websocketName() {
        return websocketUrl;
    }
 
 
    /**
     * 查询订单排产列表
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsOrderScheduling bsOrderScheduling)
    {
        startPage();
        List<BsOrderScheduling> list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        return getDataTable(list);
    }
 
    /**
     * 查询追溯列表
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')")
    @GetMapping("/getFollowReportList")
    public R getFollowReportList(BsOrderScheduling bsOrderScheduling)
    {
        FollowReportVO followReportList = bsOrderSchedulingService.getFollowReportList(bsOrderScheduling);
        return R.ok(followReportList);
    }
 
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:export')")
    @Log(title = "追溯报表导出", businessType = BusinessType.EXPORT)
    @PostMapping("/exportFollow")
    public void exportFollow(HttpServletResponse response, BsOrderScheduling bsOrderScheduling)
    {
        FollowReportVO followReportList = bsOrderSchedulingService.getFollowReportList(bsOrderScheduling);
        List<SysDictData> allDict = iSysDictDataService.selectDictDataList(null);
        if (CollUtil.isNotEmpty(followReportList.getMainList())){
            List<SysDictData> dict1 = allDict.stream().filter(x -> "material_type".equals(x.getDictType())).collect(Collectors.toList());
            List<SysDictData> dict2 = allDict.stream().filter(x -> "order_scheduling_produce_status".equals(x.getDictType())).collect(Collectors.toList());
            for (BsOrderScheduling orderScheduling : followReportList.getMainList()) {
                if (CollUtil.isNotEmpty(dict1)){
                    List<SysDictData> collect = dict1.stream().filter(x -> x.getDictValue().equals(orderScheduling.getProductType())).collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(collect)){
                        SysDictData sysDictData1 = collect.get(0);
                        orderScheduling.setProductTypeString(sysDictData1.getDictLabel());
                    }
                }
                if (CollUtil.isNotEmpty(dict2)){
                    List<SysDictData> collect = dict2.stream().filter(x -> x.getDictValue().equals(orderScheduling.getProductionStatus())).collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(collect)){
                        SysDictData sysDictData1 = collect.get(0);
                        orderScheduling.setProductionStatusString(sysDictData1.getDictLabel());
                    }
                }
            }
        }
        String fileName = "追溯报表";
        try {
            ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
            WriteSheet mainSheet = EasyExcel.writerSheet(0, "订单排产")
                    .head(BsOrderScheduling.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet1 = EasyExcel.writerSheet(1, "拧紧数据")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet2 = EasyExcel.writerSheet(2, "相机检测")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet3 = EasyExcel.writerSheet(3, "外漏检测")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet4 = EasyExcel.writerSheet(4, "机油加注")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet5 = EasyExcel.writerSheet(5, "工位结果")
                    .head(DaPassingStationCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            excelWriter.write(followReportList.getMainList(),mainSheet);
            excelWriter.write(followReportList.getList1(),sheet1);
            excelWriter.write(followReportList.getList2(),sheet2);
            excelWriter.write(followReportList.getList3(),sheet3);
            excelWriter.write(followReportList.getList4(),sheet4);
            excelWriter.write(followReportList.getList5(),sheet5);
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition","attachment;filename="+fileName+".xlsx");
            excelWriter.finish();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
 
    /**
     * 查询下线数量
     */
    @GetMapping("/getOffLineNum")
    public TableDataInfo getOffLineNum(BsOrderScheduling bsOrderScheduling)
    {
 
        List<LineChartVO> vo = bsOrderSchedulingService.getOffLineNum();
        return getDataTable(vo);
    }
 
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(BsOrderScheduling bsOrderScheduling)
    {
//        startPage();
        List<BsOrderScheduling> list = new ArrayList<>();
        if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){
            list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        }
        return getDataTable(list);
    }
 
    @GetMapping("/list3")
    public TableDataInfo list3(BsOrderScheduling bsOrderScheduling)
    {
        startPage();
        List<BsOrderScheduling> list = new ArrayList<>();
        long total = 0;
        if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){
            list = bsOrderSchedulingService.selectBsOrderSchedulingPage(bsOrderScheduling);
            if (CollUtil.isNotEmpty(list)){
                total = new PageInfo(list).getTotal();
                List<String> allEngineNoList = list.stream().map(BsOrderScheduling::getEngineNo).collect(Collectors.toList());
                List<ProductNewPassStation> productPassStationListByEngineList = productNewPassStationService.getProductPassStationListByEngineList(allEngineNoList);
                list.forEach(x -> {
                    if (StrUtil.isNotBlank(x.getWorkingHours())){
                        x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
                    } else {
                        x.setWorkingHoursInt(0);
                    }
                    if (CollUtil.isNotEmpty(productPassStationListByEngineList)){
                        List<ProductNewPassStation> collect = productPassStationListByEngineList.stream().filter(y -> x.getEngineNo().equals(y.getSfcCode())).collect(Collectors.toList());
                        if (CollUtil.isNotEmpty(collect)){
                            ProductNewPassStation productNewPassStation = collect.get(0);
                            x.setBoxCode(productNewPassStation.getBoxCode());
                        }
                    }
                });
                list = list.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
            }
        }
//        List<BsOrderScheduling> collect = list.stream().filter(x -> Constants.UN_QUALIFIED.equals(x.getQualityStatus())).collect(Collectors.toList());
//        if (CollUtil.isNotEmpty(collect)){
//            String.valueOf(collect.size());
//        }
        TableDataInfo dataTable = getDataTable(list);
        dataTable.setTotal(total);
        return dataTable;
 
    }
 
    /**
     * 导出订单排产列表
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:export')")
    @Log(title = "订单排产", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsOrderScheduling bsOrderScheduling)
    {
        List<BsOrderScheduling> list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        ExcelUtil<BsOrderScheduling> util = new ExcelUtil<BsOrderScheduling>(BsOrderScheduling.class);
        util.exportExcel(response, list, "订单排产数据");
    }
 
    /**
     * 获取订单排产详细信息
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bsOrderSchedulingService.selectBsOrderSchedulingById(id));
    }
 
    /**
     * 新增订单排产
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:add')")
    @Log(title = "订单排产", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsOrderScheduling bsOrderScheduling)
    {
        return toAjax(bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling));
    }
 
    /**
     * 修改订单排产
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:edit')")
    @Log(title = "订单排产", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsOrderScheduling bsOrderScheduling)
    {
        return toAjax(bsOrderSchedulingService.updateBsOrderScheduling(bsOrderScheduling));
    }
 
    /**
     * 删除订单排产
     */
    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:remove')")
    @Log(title = "订单排产", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bsOrderSchedulingService.deleteBsOrderSchedulingByIds(ids));
    }
    @GetMapping("/getSumData")
    public R getSumData(BsOrderScheduling bsOrderScheduling){
        List<BsOrderScheduling> list = new ArrayList<>();
        int onlineNum = 0;
        int finishNum = 0;
        if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){
 
            list = bsOrderSchedulingService.selectBsOrderSchedulingPage(bsOrderScheduling);
            List<BsOrderScheduling> onlineNumList = list.stream().filter(x -> Constants.ORDER_STATUS_ING.equals(x.getProductionStatus())).collect(Collectors.toList());
            if (CollUtil.isNotEmpty(onlineNumList)){
                onlineNum = onlineNumList.size();
            }
            List<BsOrderScheduling> finishNumList = list.stream().filter(x -> Constants.FINISH_PRODUCTION.equals(x.getProductionStatus())).collect(Collectors.toList());
            if (CollUtil.isNotEmpty(finishNumList)){
                finishNum = finishNumList.size();
            }
        }
        List<BsOrderScheduling> collect = list.stream().filter(x -> Constants.UN_QUALIFIED.equals(x.getQualityStatus())).collect(Collectors.toList());
        String unqualified = "0";
        if (CollUtil.isNotEmpty(collect)){
            unqualified = String.valueOf(collect.size());
        }
        SumDataVO vo = new SumDataVO();
        vo.setFinishNum(finishNum);
        vo.setOnlineNum(onlineNum);
        vo.setUnqualified(unqualified);
        return R.ok(vo);
    }
 
    /**
     * 校验发动机号是否和机型匹配、是否重复扫描、是否超出计划数量
     * @param engineNo 箱体码
     * @param model 机型
     * @return boolean
     */
    @Transactional(rollbackFor = Exception.class)
    @GetMapping("/engineNoIsInModel")
    public R engineNoIsInModel(String engineNo,String model,String orderNo,Boolean repairFlag) throws Exception {
 
        if (StringUtils.isEmpty(engineNo)){
            return R.fail(500,"箱体码不能为空,请重试");
        }
        if (!engineNo.contains(",")){
            return R.fail(500,"箱体码格式有误,请重试");
        }
        ProductNewPassStation checkStation = new ProductNewPassStation();
        checkStation.setBoxCode(engineNo);
        List<ProductNewPassStation> checkList = productNewPassStationService.getProductPassStationList(checkStation);
        if (!repairFlag){
            if (CollUtil.isNotEmpty(checkList)){
                return R.fail(500,"请勿重复扫描箱体码");
            }
        }
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setOrderNo(orderNo);
        List<BsOrderScheduling> allList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        if (CollUtil.isNotEmpty(allList)){
            allList.forEach(x -> {
                if (StrUtil.isNotBlank(x.getWorkingHours())){
                    x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
                } else {
                    x.setWorkingHoursInt(0);
                }
            });
            allList = allList.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
        }
        List<BsOrderScheduling> dlist = allList.stream().filter(x->x.getProductionStatus().equals(Constants.WAIT_PRODUCTION)).collect(Collectors.toList());
        List<BsOrderScheduling> collect = allList.stream().filter(x -> x.getProductionStatus().equals(Constants.ORDER_STATUS_ING)
                ||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(checkList)){
            //重复扫码
            ProductNewPassStation productNewPassStation = checkList.get(0);
            String sfcCode = productNewPassStation.getSfcCode();
            DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
            passingStationCollection.setSfcCode(sfcCode);
            List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionService.selectDaPassingStationCollectionList(passingStationCollection);
            if (CollUtil.isNotEmpty(daPassingStationCollections)){
                //过站后重新上线
                //OPC操作
                logger.info("过站后重新上线,{}",sfcCode);
                ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode);
                OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN
                return R.ok();
            } else {
                //OPC操作
                logger.info("当前站重新扫码,{}",sfcCode);
//                ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP010.ProductTypeSN",sfcCode);
//                OPCUaSubscription.miloService.writeToOpcUa(entity3);//写产品SN号反馈
                ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode);
                OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN
                return R.ok();
            }
        }else {
 
            if (CollUtil.isNotEmpty(dlist)){
                BsOrderScheduling OrderScheduling=dlist.get(0);
 
                OmProductionOrdeInfo info = new OmProductionOrdeInfo();
                info.setWorkOrderNo(orderNo);
                List<OmProductionOrdeInfo> omProductionOrdeInfos = productionOrdeInfoService.selectOmProductionOrdeInfoList(info);
                if (CollUtil.isNotEmpty(omProductionOrdeInfos)){
                    OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfos.get(0);
                    Long planQty = omProductionOrdeInfo.getPlanQty();
                    if (planQty<collect.size()){
                        return R.fail(500,"超出计划数量,请检查后重试");
                    }
                }
                //插入数据
                DaParamCollection saveData = new DaParamCollection();
                saveData.setSfcCode(OrderScheduling.getEngineNo());
                saveData.setParamValue(engineNo);
                saveData.setLocationCode("OP010");
                saveData.setParamCode("XTM");
                saveData.setParamName("箱体");
                daParamCollectionService.insertDaParamCollection(saveData);
 
                DaTileMatchCollection MatchCollection = new DaTileMatchCollection();
                MatchCollection.setSfcCode(OrderScheduling.getEngineNo());
                MatchCollection.setParamValue(engineNo);
                MatchCollection.setLocationCode("OP010");
                MatchCollection.setParamCode("XTM");
                MatchCollection.setParamName("箱体");
                daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection);
 
                if (StrUtil.isNotBlank(OrderScheduling.getEngineNo())){
                    String snCode = OrderScheduling.getEngineNo();
                    if (snCode.startsWith("280") || snCode.startsWith("380")){
                        ProductNewPassStation productNewPassStation = new ProductNewPassStation();
                        UUID uuid = UUID.randomUUID();
                        productNewPassStation.setId(uuid.getMostSignificantBits());
                        productNewPassStation.setFinishFlag("0");
                        productNewPassStation.setSfcCode(OrderScheduling.getEngineNo());
                        productNewPassStation.setCreateTime(new Date());
                        productNewPassStation.setBoxCode(engineNo);
                        if (snCode.startsWith("280")){
                            productNewPassStation.setProductType("280");
                        } else {
                            productNewPassStation.setProductType("380");
                        }
                        productNewPassStationService.insertPassStation(productNewPassStation);
                    }
                }
 
                //更新上线数量
                int onlineNum = 0;
                List<BsOrderScheduling> onlineNumList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling)
                        .stream().filter(x -> Constants.ORDER_STATUS_ING.equals(x.getProductionStatus())||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(onlineNumList)){
                    onlineNum = onlineNumList.size();
                }
                OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
                omProductionOrdeInfo.setWorkOrderNo(orderNo);
                List<OmProductionOrdeInfo> omList = productionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
                if (CollUtil.isNotEmpty(omList)){
                    OmProductionOrdeInfo omInfo = omList.get(0);
                    String s = String.valueOf(onlineNum);
                    long l = Long.parseLong(s);
                    omInfo.setActualOnlineQty(l);
                    productionOrdeInfoService.updateOmProductionOrdeInfo(omInfo);
                }
 
                //OPC操作
                ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", OrderScheduling.getEngineNo());
                OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN
 
 
                OrderScheduling.setProductionStatus("2");
                bsOrderSchedulingService.updateBsOrderScheduling(OrderScheduling);
                return R.ok();
            } else {
                return R.fail(500,"超出计划数量,请检查后重试");
            }
 
        }
 
    }
 
 
    @GetMapping("/changeBoxCode")
    public R changeBoxCode(String sfcCode,String newBoxCode){
        if (StringUtils.isEmpty(newBoxCode)){
            return R.fail(500,"箱体码不能为空,请重试");
        }
        if (StringUtils.isEmpty(sfcCode)){
            return R.fail(500,"发动机号不能为空,请重试");
        }
        if (!newBoxCode.contains(",")){
            return R.fail(500,"箱体码格式有误,请重试");
        }
        ProductNewPassStation checkStation = new ProductNewPassStation();
        checkStation.setSfcCode(sfcCode);
        List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(checkStation);
        if (CollUtil.isNotEmpty(productPassStationList)){
            productNewPassStationService.updateBoxCodeBySfcCode(sfcCode, newBoxCode);
            return R.ok();
        } else {
            return R.fail("未查找到该发动机号对应的箱体");
        }
    }
}