From 3bbfe1ea3af3ad62389b83dc8d2bdaab46c010cb Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期五, 19 七月 2024 13:39:00 +0800 Subject: [PATCH] 修改30工位获取ocv数据,根据时间倒叙获取第一条 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java index 9377594..1fd42d9 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java @@ -802,9 +802,11 @@ List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() .eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") - .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); + .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) + .orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) + ); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ flag = true; }else { @@ -857,9 +859,11 @@ String cellCode = value2.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") - .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); + .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) + .orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) + ); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); }else { @@ -883,9 +887,11 @@ String cellCode = value3.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") - .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); + .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) + .orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) + ); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); }else { @@ -909,9 +915,11 @@ String cellCode = value4.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") - .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); + .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) + .orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) + ); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); }else { -- Gitblit v1.9.3