Browse Source

Merge remote-tracking branch 'origin/dev' into dev

fenze 7 months ago
parent
commit
194864962f

+ 24 - 5
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
@@ -287,10 +294,9 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 		return Result.OK("文件导入失败!");
     }
 
-
-	 @ApiOperation(value="设备采集点测试", notes="设备采集点-test")
-	 @RequestMapping(value = "/device/test", method = RequestMethod.POST)
-	 public Result<?> deviceTest(@RequestParam Map<String,Object> params) throws Exception {
+	@ApiOperation(value="设备采集点测试", notes="设备采集点-test")
+	@RequestMapping(value = "/device/test", method = RequestMethod.POST)
+	public Result<?> deviceTest(@RequestParam Map<String,Object> params) throws Exception {
 		 // 获取所有的key
 		 Set<String> keys = params.keySet();
 		 // 遍历key并根据key执行不同的业务逻辑
@@ -333,6 +339,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 = "数据类型")

+ 3 - 3
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -35,15 +35,16 @@ public class OpcGatherWatch {
     @Autowired
     MongoTemplate mongoTemplate;
 
+    // 采集频率设置值(数据库字典匹配,否则不执行查询不到设备)
     @Scheduled(fixedDelay = 500)
     public void t1(){
         opc("500");
-    }
+    } // 0.5ms
 
     @Scheduled(fixedDelay = 1000)
     public void t2(){
         opc("1000");
-    }
+    } // 1ms
 
     @Scheduled(fixedDelay = 2000)
     public void t3(){
@@ -60,7 +61,6 @@ public class OpcGatherWatch {
         opc("10000");
     }
 
-
     @Scheduled(fixedDelay = 30000)
     public void t6(){
         opc("30000");

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

@@ -21,7 +21,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-//@EnableScheduling
+@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j

+ 1 - 1
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -169,7 +169,7 @@ spring:
           slow-sql-millis: 5000
       datasource:
         master:
-          url: jdbc:mysql://123.57.213.14:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          url: jdbc:mysql://123.57.213.14/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
           username: root
           password: 1qaz2wsx@..
           driver-class-name: com.mysql.cj.jdbc.Driver

+ 1 - 1
jeecg-server-cloud/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java

@@ -32,7 +32,7 @@ public class JeecgNacosApplication {
 //        System.setProperty("nacos.core.auth.default.password", "nacos");
         System.setProperty("server.tomcat.basedir","logs");
         //自定义启动端口号
-        System.setProperty("server.port","8848");
+        System.setProperty("server.port","8849");
         SpringApplication.run(JeecgNacosApplication.class, args);
     }
 

+ 2 - 2
jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application-mysql.yml

@@ -13,9 +13,9 @@ spring:
 db:
   num: 1
   password:
-    '0': ${MYSQL-PWD:root}
+    '0': ${MYSQL-PWD:1qaz2wsx@..}
   url:
-    '0': jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
+    '0': jdbc:mysql://${MYSQL-HOST:123.57.213.14}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
   user:
     '0': ${MYSQL-USER:root}
 management:

+ 8 - 3
pom.xml

@@ -125,6 +125,11 @@
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+		<!--集成springmvc框架并实现自动配置 -->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
@@ -533,7 +538,7 @@
                 <!--当前环境-->
                 <profile.name>dev</profile.name>
                 <!--Nacos服务地址-->
-                <config.server-addr>jeecg-boot-nacos:8848</config.server-addr>
+                <config.server-addr>jeecg-boot-nacos:8849</config.server-addr>
 				<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空-->
 				<config.namespace></config.namespace>
 				<!--Nacos配置分组名称-->
@@ -563,7 +568,7 @@
                 <!--当前环境-->
                 <profile.name>test</profile.name>
                 <!--Nacos服务地址-->
-                <config.server-addr>jeecg-boot-nacos:8848</config.server-addr>
+                <config.server-addr>jeecg-boot-nacos:8849</config.server-addr>
 				<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空-->
 				<config.namespace></config.namespace>
 				<!--Nacos配置分组名称-->
@@ -581,7 +586,7 @@
                 <!--当前环境-->
                 <profile.name>prod</profile.name>
                 <!--Nacos服务地址-->
-                <config.server-addr>jeecg-boot-nacos:8848</config.server-addr>
+                <config.server-addr>jeecg-boot-nacos:8849</config.server-addr>
 				<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空-->
 				<config.namespace></config.namespace>
 				<!--Nacos配置分组名称-->