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