Browse Source

数据 测试

guoqiang 7 months ago
parent
commit
733d9dc20b

+ 21 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/controller/DevicePointController.java

@@ -15,6 +15,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.dataRepository.entity.PointData;
 import org.jeecg.modules.deviceConn.modbus.service.ModbusTcp;
 import org.jeecg.modules.deviceConn.opc.utils.OpcConn;
 import org.jeecg.modules.deviceConn.opc.utils.OpcUaServerUtils;
@@ -28,6 +29,10 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -58,9 +63,11 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 	 String[] s7Fileds = {"pointName","pointCode","pointAddr","dateType","dateLength"};
 
 	 String[] modbisFileds = {"pointName","pointCode","pointAddr","registerType","pointBit","pointScale","dateType","dateLength"};
+    @Autowired
+    private MongoTemplate mongoTemplate;
 
 
-	 /**
+	/**
 	 * 分页列表查询
 	 *
 	 * @param devicePoint
@@ -333,6 +340,19 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 		 return Result.OK(null);
 	 }
 
+	@ApiOperation(value="s7采集点-testAllS7", notes="s7采集点-testAllS7")
+	@GetMapping(value = "/testAllS7")
+	public Result<?> testAll(@RequestParam(name="id") String id) {
+		List<DevicePoint> devicePointList = devicePointService.list(new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId, id));
+		for (DevicePoint devicePoint : devicePointList) {
+			Query query = Query.query(Criteria.where("pointId").is(devicePoint.getId()))
+					.with(Sort.by(Sort.Order.desc("time"))).limit(1);
+			PointData pointData = mongoTemplate.findOne(query, PointData.class, devicePoint.getId() + "_500");
+			if(pointData!=null) devicePoint.setRemarks(pointData.getDataText());
+		}
+		return Result.OK(devicePointList);
+	}
+
 	private String testReadData(OpcConnPageParam opcConnPage) throws Exception {
 		OpcUaClient opcUaClient = null;
 		OpcConnParam opcConnParam = new OpcConnParam(opcConnPage);

+ 4 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/entity/DevicePoint.java

@@ -90,6 +90,10 @@ public class DevicePoint implements Serializable {
 	@Excel(name = "寄存器偏移位", width = 15)
     @ApiModelProperty(value = "寄存器偏移位-modbus")
     private Integer pointScale;
+    /**测试结果*/
+    @Excel(name = "测试结果", width = 15)
+    @ApiModelProperty(value = "测试结果")
+    private java.lang.String remarks;
 	/**数据类型*/
 	@Excel(name = "数据类型", width = 15)
     @ApiModelProperty(value = "数据类型")