소스 검색

Merge branch 'master' into dev

# Conflicts:
#	jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java
guoqiang 9 달 전
부모
커밋
5945f7ef2c

+ 13 - 14
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/controller/DevicePointController.java

@@ -294,20 +294,6 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 		return Result.OK("文件导入失败!");
     }
 
-
-	@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);
-	}
-
 	@ApiOperation(value="设备采集点测试", notes="设备采集点-test")
 	@RequestMapping(value = "/device/test", method = RequestMethod.POST)
 	public Result<?> deviceTest(@RequestParam Map<String,Object> params) throws Exception {
@@ -353,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);

+ 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");

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

@@ -1,166 +0,0 @@
-package org.jeecg.modules.watch;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import io.netty.util.internal.StringUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.dataRepository.entity.PointData;
-import org.jeecg.modules.device.entity.DeviceInformation;
-import org.jeecg.modules.device.service.IDeviceInformationService;
-import org.jeecg.modules.deviceConn.s7.service.S7PLC;
-import org.jeecg.modules.devicePoint.entity.DevicePoint;
-import org.jeecg.modules.devicePoint.service.IDevicePointService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-
-//@EnableScheduling
-@EnableAsync
-@Component
-@Slf4j
-public class s7gatherWatch {
-
-    @Autowired
-    IDeviceInformationService deviceInformationService;
-
-    @Autowired
-    IDevicePointService devicePointService;
-
-    @Autowired
-    MongoTemplate mongoTemplate;
-
-    HashMap<String, S7PLC> s7PLCmap = new HashMap<>();
-
-    @Scheduled(fixedDelay = 500)
-    public void t1(){
-        s7("500");
-    }
-
-    @Scheduled(fixedDelay = 1000)
-    public void t2(){
-        s7("1000");
-    }
-
-    @Scheduled(fixedDelay = 2000)
-    public void t3(){
-        s7("2000");
-    }
-
-    @Scheduled(fixedDelay = 5000)
-    public void t4(){
-        s7("5000");
-    }
-
-    @Scheduled(fixedDelay = 10000)
-    public void t5(){
-        s7("10000");
-    }
-
-    @Scheduled(fixedDelay = 30000)
-    public void t6(){
-        s7("30000");
-    }
-
-    @Scheduled(fixedDelay = 60000)
-    public void t7(){
-        s7("60000");
-    }
-
-
-    //s7数据采集
-    public void s7(String freq){
-        //获取当前时间
-        Date curentDate = new Date();
-        //获取所有运行中设备
-        LambdaQueryWrapper<DeviceInformation> s7Query = new LambdaQueryWrapper<DeviceInformation>().ne(DeviceInformation::getStatus, "1").eq(DeviceInformation::getFreq, freq);
-        List<DeviceInformation> s7List = deviceInformationService.list(s7Query);
-        //遍历设备集合
-        s7List.forEach(s7 -> {
-            List<DevicePoint> s7Infos = null;
-            //未处理数据
-            String read = "";
-            //处理过的数据
-            String readText = "";
-            //从连接池中拿取连接
-            S7PLC s7PLC = s7PLCmap.get(s7.getId());
-            //连接对象为空则创建
-            if(oConvertUtils.isEmpty(s7PLC)){
-                //与设备建立连接
-                s7PLC = new S7PLC(s7.getS7Model(), s7.getDeviceIp(), Integer.valueOf(s7.getDevicePort()), s7.getS7Rack(), Integer.valueOf(s7.getS7Slot()), Integer.valueOf(s7.getS7LongestWidth()));
-                //将连接放入连接池中
-                s7PLCmap.put(s7.getId(),s7PLC);
-            }
-            try {
-                //获取设备下所有点位
-                s7Infos = devicePointService.list( new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId,s7.getId()));
-                //遍历点位集合
-                for (DevicePoint s7Info : s7Infos) {
-                    try {
-                        //读取点位数据
-                        String pointAddr = s7Info.getPointAddr()+"";
-                        if (s7Info.getDateType().equals("STRING")){
-                            read = "" + s7PLC.readString(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("REAL")){
-                            read = "" + s7PLC.readFloat32(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("DINT")){
-                            read = "" + s7PLC.readInt32(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("INT")){
-                            read = "" + s7PLC.readInt16(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("DWORD")){
-                            read = "" + s7PLC.readInt32(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("WORD")){
-                            read = "" + s7PLC.readInt16(pointAddr);
-                            readText = read;
-                        }else if (s7Info.getDateType().equals("BOOL")){
-                            read = "" + s7PLC.readBoolean(pointAddr);
-                            if(!StringUtil.isNullOrEmpty(read))readText = read.equals("true")?"1":"0";
-                        }
-                        if (oConvertUtils.isEmpty(read)) {
-                            read = "";
-                        }
-                        //将点位数据存入点位信息对象中
-                        s7Info.setTestResult(read);
-                        //如果点位状态异常则恢复为正常
-                        if(s7Info.getGatherStatus().equals("1")){
-                            s7Info.setGatherStatus("0");
-                        }
-                    } catch (Exception e) {
-                        //打印点位异常日志
-                        log.error(e.getMessage());
-                        //设置点位状态为异常
-                        s7Info.setGatherStatus("1");
-                    }finally {
-                        //将点位数据存入mongo中
-                        mongoTemplate.insert(new PointData(s7Info, freq, readText, curentDate), s7Info.getId());
-                        //更新数据库点位信息
-                        devicePointService.updateById(s7Info);
-                        readText = "";
-                    }
-                }
-            } catch (Exception e) {
-            }
-        });
-    }
-
-    //关闭连接并从连接池中移除
-    public void closeS7(String id){
-        S7PLC s7PLC = s7PLCmap.get(id);
-        if(!oConvertUtils.isEmpty(s7PLC)){
-            s7PLC.close();
-            s7PLCmap.remove(id);
-        }
-    }
-
-}

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

@@ -169,9 +169,9 @@ 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://127.0.0.1:3306/lg?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
           username: root
-          password: 1qaz2wsx@..
+          password: '@qwe@123'
           driver-class-name: com.mysql.cj.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

+ 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

@@ -126,6 +126,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>
@@ -534,7 +539,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配置分组名称-->
@@ -564,7 +569,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配置分组名称-->
@@ -582,7 +587,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配置分组名称-->