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