| | |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SerialNumber").value(SerialNumber).build()); |
| | | } |
| | | //9L发动机涂胶轨迹下发 |
| | | else if(Constants.OP080.equals(device) && Constants.PLC_4.equals(thoroughfare)){ |
| | | // 1. 初始化工单对象并查询工单信息 |
| | | String workOrderNo = resultList.get(0).getWorkOrderNo(); |
| | | OmProductionOrderInfo queryOrder = new OmProductionOrderInfo(); |
| | | queryOrder.setWorkOrderNo(workOrderNo); |
| | | List<OmProductionOrderInfo> orderList = omProductionOrderInfoService.selectOmProductionOrderInfoList(queryOrder); |
| | | // 2. 判断类型分支逻辑 |
| | | String engineName = orderList.get(0).getEngineName(); |
| | | if (!"9L".equals(engineName)) { |
| | | // 非9L直接写0 |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(0).build()); |
| | | } else { |
| | | // 3. 查询产线配置的两条预置数据 |
| | | BsLineInfo lineQuery = new BsLineInfo(); |
| | | lineQuery.setLineCode(engineName); // 假设通过lineCode=9L获取两条数据 |
| | | List<BsLineInfo> configuredLines = bsLineInfoService.selectBsLineInfoList(lineQuery); |
| | | // 第一条配置数据的校验 |
| | | BsLineInfo firstLine = configuredLines.get(0); |
| | | BsBomChildInfo checkFirst = new BsBomChildInfo(); |
| | | checkFirst.setMaterialCode(firstLine.getLineName()); |
| | | checkFirst.setBomCode(workOrderNo); |
| | | List<BsBomChildInfo> firstCheckList = bsBomChildInfoService.selectBsBomChildInfoList(checkFirst); |
| | | if (firstCheckList.size() == 1) { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(1).build()); |
| | | } else { |
| | | // 第二条配置数据的校验 |
| | | BsLineInfo secondLine = configuredLines.get(1); |
| | | BsBomChildInfo checkSecond = new BsBomChildInfo(); |
| | | checkSecond.setMaterialCode(secondLine.getLineName()); |
| | | checkSecond.setBomCode(workOrderNo); |
| | | List<BsBomChildInfo> secondCheckList = bsBomChildInfoService.selectBsBomChildInfoList(checkSecond); |
| | | if (secondCheckList.size() == 1) { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(2).build()); |
| | | } |
| | | } |
| | | } |
| | | if(Constants.OP080.equals(device) ){ |
| | | if(Constants.PLC_4.equals(thoroughfare)){ |
| | | // 1. 初始化工单对象并查询工单信息 |
| | | String workOrderNo = resultList.get(0).getWorkOrderNo(); |
| | | OmProductionOrderInfo queryOrder = new OmProductionOrderInfo(); |
| | | queryOrder.setWorkOrderNo(workOrderNo); |
| | | List<OmProductionOrderInfo> orderList = omProductionOrderInfoService.selectOmProductionOrderInfoList(queryOrder); |
| | | // 2. 判断类型分支逻辑 |
| | | String engineName = orderList.get(0).getEngineName(); |
| | | if (!"9L".equals(engineName)) { |
| | | // 非9L直接写0 |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(0).build()); |
| | | } else { |
| | | // 3. 查询产线配置的两条预置数据 |
| | | BsLineInfo lineQuery = new BsLineInfo(); |
| | | lineQuery.setLineCode(engineName); // 假设通过lineCode=9L获取两条数据 |
| | | List<BsLineInfo> configuredLines = bsLineInfoService.selectBsLineInfoList(lineQuery); |
| | | // 第一条配置数据的校验 |
| | | BsLineInfo firstLine = configuredLines.get(0); |
| | | BsBomChildInfo checkFirst = new BsBomChildInfo(); |
| | | checkFirst.setMaterialCode(firstLine.getLineName()); |
| | | checkFirst.setBomCode(workOrderNo); |
| | | List<BsBomChildInfo> firstCheckList = bsBomChildInfoService.selectBsBomChildInfoList(checkFirst); |
| | | if (firstCheckList.size() == 1) { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(1).build()); |
| | | } else { |
| | | // 第二条配置数据的校验 |
| | | BsLineInfo secondLine = configuredLines.get(1); |
| | | BsBomChildInfo checkSecond = new BsBomChildInfo(); |
| | | checkSecond.setMaterialCode(secondLine.getLineName()); |
| | | checkSecond.setBomCode(workOrderNo); |
| | | List<BsBomChildInfo> secondCheckList = bsBomChildInfoService.selectBsBomChildInfoList(checkSecond); |
| | | if (secondCheckList.size() == 1) { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".GlueType").value(2).build()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | String getWorkOrderNo = resultList.get(0).getWorkOrderNo(); |
| | | BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); |
| | |
| | | if (Objects.equals(nowQty, getPreOrder2.getPlanQty().toString())){ |
| | | omProductionOrderInfoService.updatePreStatus2(); |
| | | } |
| | | // }else if (Constants.OP020.equals(device)){ |
| | | // final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // // 遍历 MaterialCode35 到 MaterialCode40 共6组数据 |
| | | // for (int i = 35; i <= 40; i++) { // 修改循环范围 |
| | | // // 构建OPC UA节点地址(例如:PLC1.OP020.MaterialCode35) |
| | | // String nodeId = "PLC2." + device + ".MaterialCode" + i; |
| | | // // 创建采集对象 |
| | | // DaMaterialCollection materialCollection = new DaMaterialCollection(); |
| | | // materialCollection.setSfcCode(SFCCode.toString()); |
| | | // materialCollection.setLocationCode(device); |
| | | // // 设置参数名称(活塞1到活塞6) |
| | | // int pistonNumber = i - 34; // 35→1, 36→2...40→6 |
| | | // materialCollection.setParamName("活塞" + pistonNumber); |
| | | // // 通过OPC UA读取参数值 |
| | | // ReadWriteEntity dataRead = miloService.readFromOpcUa(nodeId); |
| | | // if (dataRead != null && dataRead.getValue() != null && !Objects.equals(dataRead.getValue(), " ")) { |
| | | // materialCollection.setParamValue(dataRead.getValue().toString()); |
| | | // Date collectTime = new Date(); |
| | | // ReadWriteEntity collectTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");//进站时间 |
| | | // collectTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(collectTimeRead.getValue().toString()))); |
| | | // materialCollection.setCollectTime( collectTime); |
| | | // // 插入数据库 |
| | | // daMaterialCollectionService.insertDaMaterialCollection(materialCollection); |
| | | // } else { |
| | | // log.info("活塞号为空: {}",materialCollection.getParamName() ); |
| | | // } |
| | | // } |
| | | // }else if (Constants.OP130.equals(device)){ |
| | | // final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // // 遍历 MaterialCode35 到 MaterialCode40 共6组数据 |
| | | // String nodeId = "PLC3." + device + ".MaterialCode35" ; |
| | | // // 创建采集对象 |
| | | // DaMaterialCollection materialCollection = new DaMaterialCollection(); |
| | | // materialCollection.setSfcCode(SFCCode.toString()); |
| | | // materialCollection.setLocationCode(device); |
| | | // materialCollection.setParamName("缸盖码"); |
| | | // // 通过OPC UA读取参数值 |
| | | // ReadWriteEntity dataRead = miloService.readFromOpcUa(nodeId); |
| | | // if (dataRead != null && dataRead.getValue() != null && !Objects.equals(dataRead.getValue(), " ")) { |
| | | // materialCollection.setParamValue(dataRead.getValue().toString()); |
| | | // Date collectTime = new Date(); |
| | | // ReadWriteEntity collectTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");//进站时间 |
| | | // collectTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(collectTimeRead.getValue().toString()))); |
| | | // materialCollection.setCollectTime( collectTime); |
| | | // // 插入数据库 |
| | | // daMaterialCollectionService.insertDaMaterialCollection(materialCollection); |
| | | // } else { |
| | | // log.info("缸盖码为空: {}",materialCollection.getParamName() ); |
| | | // } |
| | | |
| | | } |
| | | else if (Constants.OP020.equals(device)){ |
| | | final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 遍历 MaterialCode35 到 MaterialCode40 共6组数据 |
| | | for (int i = 35; i <= 40; i++) { // 修改循环范围 |
| | | // 构建OPC UA节点地址(例如:PLC1.OP020.MaterialCode35) |
| | | String nodeId = "PLC2." + device + ".MaterialCode" + i; |
| | | // 创建采集对象 |
| | | DaMaterialCollection materialCollection = new DaMaterialCollection(); |
| | | materialCollection.setSfcCode(SFCCode.toString()); |
| | | materialCollection.setLocationCode(device); |
| | | // 设置参数名称(活塞1到活塞6) |
| | | int pistonNumber = i - 34; // 35→1, 36→2...40→6 |
| | | materialCollection.setParamName("活塞" + pistonNumber); |
| | | // 通过OPC UA读取参数值 |
| | | ReadWriteEntity dataRead = miloService.readFromOpcUa(nodeId); |
| | | if (dataRead != null && dataRead.getValue() != null && !Objects.equals(dataRead.getValue(), " ")) { |
| | | materialCollection.setParamValue(dataRead.getValue().toString()); |
| | | Date collectTime = new Date(); |
| | | ReadWriteEntity collectTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");//进站时间 |
| | | collectTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(collectTimeRead.getValue().toString()))); |
| | | materialCollection.setCollectTime( collectTime); |
| | | // 插入数据库 |
| | | daMaterialCollectionService.plusSave(materialCollection); |
| | | } else { |
| | | log.info("活塞号为空: {}",materialCollection.getParamName() ); |
| | | } |
| | | } |
| | | }else if (Constants.OP130.equals(device)){ |
| | | final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 遍历 MaterialCode35 到 MaterialCode40 共6组数据 |
| | | String nodeId = "PLC3." + device + ".MaterialCode35" ; |
| | | // 创建采集对象 |
| | | DaMaterialCollection materialCollection = new DaMaterialCollection(); |
| | | materialCollection.setSfcCode(SFCCode.toString()); |
| | | materialCollection.setLocationCode(device); |
| | | materialCollection.setParamName("缸盖码"); |
| | | // 通过OPC UA读取参数值 |
| | | ReadWriteEntity dataRead = miloService.readFromOpcUa(nodeId); |
| | | if (dataRead != null && dataRead.getValue() != null && !Objects.equals(dataRead.getValue(), " ")) { |
| | | materialCollection.setParamValue(dataRead.getValue().toString()); |
| | | Date collectTime = new Date(); |
| | | ReadWriteEntity collectTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");//进站时间 |
| | | collectTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(collectTimeRead.getValue().toString()))); |
| | | materialCollection.setCollectTime( collectTime); |
| | | // 插入数据库 |
| | | daMaterialCollectionService.plusSave(materialCollection); |
| | | } else { |
| | | log.info("缸盖码为空: {}",materialCollection.getParamName() ); |
| | | } |
| | | } |
| | | //出站保存 |
| | | DaStationCollection daStationCollection = new DaStationCollection(); |
| | |
| | | daCollectionParamConf1.setDescriptive("1"); |
| | | List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1); |
| | | for (DaCollectionParamConf conf : daCollectionParamConfList1) { |
| | | String index = String.valueOf(daCollectionParamConfList1.indexOf(conf)); |
| | | String gatherAddress = conf.getGatherAddress(); |
| | | String valueObj = null; |
| | | ReadWriteEntity entity = miloService.readFromOpcUa(gatherAddress); |
| | |
| | | valueObj = value.toString(); // 最终赋值 |
| | | if (!Objects.equals(valueObj, " ")) { |
| | | DaMaterialCollection materialCollection = new DaMaterialCollection(); |
| | | materialCollection.setRemark(index); |
| | | |
| | | materialCollection.setSfcCode(SFCCode.toString()); |
| | | materialCollection.setLocationCode(device); |
| | | materialCollection.setParamName(conf.getParameterSetName()); |