hdy
2025-03-14 0994009a6d6184839359505d99fdf7be68ee1b19
billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java
@@ -134,6 +134,7 @@
                    OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
                    Object SFCCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".SFCCode").getValue();
                    //上线工位
//                    if(Constants.ONLINE.contains(device) || Constants.TEST.equals(device) ){
                    if(Constants.ONLINE.contains(device)){
                        Object workOrderNumber = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue();
                        Object nowQty = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue();
@@ -158,7 +159,6 @@
                        ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
                        Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
                        omOrderScheduling.setOfflineTime(Time);
                        omOrderScheduling.setStatus("2");
                        if(Constants.C060.equals(device)){
                            omOrderScheduling.setRemarks("Head");
                            omOrderScheduling.setSfcCode(SFCCode.toString());
@@ -171,7 +171,7 @@
                            if (nowQty == headQty){
                                UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                                updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
                                updateWrapper.set("head_status", "3");
                                updateWrapper.set("head_status", "2");
                                omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                            }
                        } else if (Constants.OP310.equals(device)) {
@@ -186,7 +186,7 @@
                            if (nowQty == bodyQty){
                                UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                                updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
                                updateWrapper.set("body_status", "3");
                                updateWrapper.set("body_status", "2");
                                omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                            }
                        }
@@ -206,7 +206,7 @@
                        if (nowQty == preQty){
                            UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                            updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
                            updateWrapper.set("pre_status", "3");
                            updateWrapper.set("pre_status", "2");
                            omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                        }
                    }
@@ -217,21 +217,29 @@
                    List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1);
                    for (DaCollectionParamConf conf : daCollectionParamConfList1) {
                        String gatherAddress = conf.getGatherAddress();
                        String valueObj = miloService.readFromOpcUa(gatherAddress).getValue().toString(); // 获取原始值对象‌:ml-citation{ref="4" data="citationList"}
                        if (!Objects.equals(valueObj, "                                                  ")) {
                            DaMaterialCollection materialCollection = new DaMaterialCollection();
                            materialCollection.setSfcCode(SFCCode.toString());
                            materialCollection.setLocationCode(device);
                            materialCollection.setParamName(conf.getParameterSetName());
                            materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString());
                            Date Time = new Date();
                            ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
                            Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
                            materialCollection.setCollectTime(Time);
                            daMaterialCollectionService.insertDaMaterialCollection(materialCollection);
                        }
                        else {
                            log.debug("采集项为空: {}", gatherAddress);
                        String valueObj = null;
                        ReadWriteEntity entity = miloService.readFromOpcUa(gatherAddress);
                        if (entity != null) {
                            Object value = entity.getValue();
                            if (value != null) {
                                valueObj = value.toString();  // 最终赋值
                                if (!Objects.equals(valueObj, "                                                  ")) {
                                    DaMaterialCollection materialCollection = new DaMaterialCollection();
                                    materialCollection.setSfcCode(SFCCode.toString());
                                    materialCollection.setLocationCode(device);
                                    materialCollection.setParamName(conf.getParameterSetName());
                                    materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString());
                                    Date Time = new Date();
                                    ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
                                    Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
                                    materialCollection.setCollectTime(Time);
                                    daMaterialCollectionService.insertDaMaterialCollection(materialCollection);
                                }
                                else {
                                    log.debug("采集项为空: {}", gatherAddress);
                                }
                            }
                        }
                    }
//                    查询descriptive字段等于2的采集项保存到扫码保存到da_param_collection表里
@@ -280,6 +288,7 @@
            log.error(e.getMessage());
        }
}
    //首工站下发工单,并生成SN码
    private static final String[] MONTH = {"A","B","C","D","E","F","G","H","I","J","K","L"};
    public void plackWorkOrder(String thoroughfare, String device, String tab, String valueString) {
@@ -334,7 +343,8 @@
                            if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){
                                omProductionOrderInfoService.updateBodyStatus2();
                            }
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getBodyOrder2.getBodyQty()).build());
                            String PalletID = getBodyOrder2.getBodyQty().toString();
                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                    }
                    else{
@@ -386,7 +396,8 @@
                        if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){
                            omProductionOrderInfoService.updateHeadStatus2();
                        }
                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getHeadOrder2.getHeadQty()).build());
                        String PalletID = getHeadOrder2.getHeadQty().toString();
                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                    }
                    else{
@@ -437,7 +448,8 @@
                        if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){
                            omProductionOrderInfoService.updatePreStatus2();
                        }
                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getPreOrder2.getPreQty()).build());
                        String PalletID = getPreOrder2.getPreQty().toString();
                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                    }
                    else{