diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
deleted file mode 100644
index 93c271f..0000000
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.newfiber.termite.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class TermiteMqttData {
-
- /**
- * 设备编码
- */
- @ApiModelProperty(value = "设备编码")
- private String sn;
-
- /**
- * 设备地址
- */
- @ApiModelProperty(value = "设备地址")
- private String location;
-
- /**
- * 数据日期
- */
- @ApiModelProperty(value = "数据日期")
- private String date;
-
- /**
- * 有无白蚁 1有 2无
- */
- @ApiModelProperty(value = "有无白蚁 1有 2无")
- private String yesnoant;
-
-}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
deleted file mode 100644
index 93c271f..0000000
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.newfiber.termite.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class TermiteMqttData {
-
- /**
- * 设备编码
- */
- @ApiModelProperty(value = "设备编码")
- private String sn;
-
- /**
- * 设备地址
- */
- @ApiModelProperty(value = "设备地址")
- private String location;
-
- /**
- * 数据日期
- */
- @ApiModelProperty(value = "数据日期")
- private String date;
-
- /**
- * 有无白蚁 1有 2无
- */
- @ApiModelProperty(value = "有无白蚁 1有 2无")
- private String yesnoant;
-
-}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
new file mode 100644
index 0000000..3bda36b
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
@@ -0,0 +1,17 @@
+package com.newfiber.termite.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.newfiber.termite.domain.TermiteData;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Mapper接口
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Mapper
+public interface TermiteDataMapper extends BaseMapper{
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
deleted file mode 100644
index 93c271f..0000000
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.newfiber.termite.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class TermiteMqttData {
-
- /**
- * 设备编码
- */
- @ApiModelProperty(value = "设备编码")
- private String sn;
-
- /**
- * 设备地址
- */
- @ApiModelProperty(value = "设备地址")
- private String location;
-
- /**
- * 数据日期
- */
- @ApiModelProperty(value = "数据日期")
- private String date;
-
- /**
- * 有无白蚁 1有 2无
- */
- @ApiModelProperty(value = "有无白蚁 1有 2无")
- private String yesnoant;
-
-}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
new file mode 100644
index 0000000..3bda36b
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
@@ -0,0 +1,17 @@
+package com.newfiber.termite.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.newfiber.termite.domain.TermiteData;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Mapper接口
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Mapper
+public interface TermiteDataMapper extends BaseMapper{
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
index c2f15aa..6ed8586 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
@@ -1,26 +1,40 @@
package com.newfiber.termite.service;
import com.alibaba.fastjson2.JSONObject;
-import com.newfiber.termite.domain.TermiteMqttData;
+import com.newfiber.termite.domain.TermiteData;
import com.newfiber.termite.util.MqttUtils;
import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataReceiveService {
- String url = "139.155.49.237";
- Integer port = 8383;
- String userName = "termite_huangpi";
- String userPassword = "Huangpi@2024";
- String subscribeTopic = "wulinshuiku/+/antResult";
+ @Value("${mqtt.url}")
+ String url;
+
+ @Value("${mqtt.port}")
+ Integer port;
+
+ @Value("${mqtt.userName}")
+ String userName;
+
+ @Value("${mqtt.userPassword}")
+ String userPassword;
+
+ @Value("${mqtt.subscribeTopic}")
+ String subscribeTopic;
+
+ @Resource
+ private TermiteDataService termiteDataService;
@PostConstruct
public void initMqttConnect(){
@@ -47,7 +61,7 @@
return "tcp://".concat(url).concat(":").concat(port.toString());
}
- static class TermiteDataReceiveCallback implements MqttCallback {
+ class TermiteDataReceiveCallback implements MqttCallback {
@Override
public void connectionLost(Throwable cause) {
@@ -64,8 +78,8 @@
}
log.info("【数据接收】主题[{}]接收到数据:{}", topic, message);
- TermiteMqttData termiteMqttData = JSONObject.parseObject(message, TermiteMqttData.class);
-
+ TermiteData termiteData = JSONObject.parseObject(message, TermiteData.class);
+ termiteDataService.save(termiteData);
}
@Override
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
deleted file mode 100644
index 93c271f..0000000
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.newfiber.termite.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class TermiteMqttData {
-
- /**
- * 设备编码
- */
- @ApiModelProperty(value = "设备编码")
- private String sn;
-
- /**
- * 设备地址
- */
- @ApiModelProperty(value = "设备地址")
- private String location;
-
- /**
- * 数据日期
- */
- @ApiModelProperty(value = "数据日期")
- private String date;
-
- /**
- * 有无白蚁 1有 2无
- */
- @ApiModelProperty(value = "有无白蚁 1有 2无")
- private String yesnoant;
-
-}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
new file mode 100644
index 0000000..3bda36b
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
@@ -0,0 +1,17 @@
+package com.newfiber.termite.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.newfiber.termite.domain.TermiteData;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Mapper接口
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Mapper
+public interface TermiteDataMapper extends BaseMapper{
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
index c2f15aa..6ed8586 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
@@ -1,26 +1,40 @@
package com.newfiber.termite.service;
import com.alibaba.fastjson2.JSONObject;
-import com.newfiber.termite.domain.TermiteMqttData;
+import com.newfiber.termite.domain.TermiteData;
import com.newfiber.termite.util.MqttUtils;
import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataReceiveService {
- String url = "139.155.49.237";
- Integer port = 8383;
- String userName = "termite_huangpi";
- String userPassword = "Huangpi@2024";
- String subscribeTopic = "wulinshuiku/+/antResult";
+ @Value("${mqtt.url}")
+ String url;
+
+ @Value("${mqtt.port}")
+ Integer port;
+
+ @Value("${mqtt.userName}")
+ String userName;
+
+ @Value("${mqtt.userPassword}")
+ String userPassword;
+
+ @Value("${mqtt.subscribeTopic}")
+ String subscribeTopic;
+
+ @Resource
+ private TermiteDataService termiteDataService;
@PostConstruct
public void initMqttConnect(){
@@ -47,7 +61,7 @@
return "tcp://".concat(url).concat(":").concat(port.toString());
}
- static class TermiteDataReceiveCallback implements MqttCallback {
+ class TermiteDataReceiveCallback implements MqttCallback {
@Override
public void connectionLost(Throwable cause) {
@@ -64,8 +78,8 @@
}
log.info("【数据接收】主题[{}]接收到数据:{}", topic, message);
- TermiteMqttData termiteMqttData = JSONObject.parseObject(message, TermiteMqttData.class);
-
+ TermiteData termiteData = JSONObject.parseObject(message, TermiteData.class);
+ termiteDataService.save(termiteData);
}
@Override
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java
new file mode 100644
index 0000000..4230a76
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java
@@ -0,0 +1,21 @@
+package com.newfiber.termite.service;
+
+import com.newfiber.common.core.web.service.BaseServiceImpl;
+import com.newfiber.termite.domain.TermiteData;
+import com.newfiber.termite.mapper.TermiteDataMapper;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Service;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Service业务层处理
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Service
+public class TermiteDataService extends BaseServiceImpl {
+
+ @Resource
+ private TermiteDataMapper termiteDataMapper;
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/pom.xml b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
index f7d7514..bb6e1eb 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/pom.xml
+++ b/newfiber-data-connect/newfiber-data-connect-main/pom.xml
@@ -23,10 +23,21 @@
spring-integration-mqtt
-
+
+
+
+
+
+
+
- com.newfiber
- newfiber-common-datasource
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ com.dameng
+ DmJdbcDriver18
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
new file mode 100644
index 0000000..5d22c5f
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteData.java
@@ -0,0 +1,50 @@
+package com.newfiber.termite.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.newfiber.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 白蚁数据(第三方部署接收数据)对象 ter_termite_data
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Data
+@TableName("ter_termite_data")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "白蚁数据(第三方部署接收数据)", description = "白蚁数据(第三方部署接收数据)")
+public class TermiteData extends BaseEntity{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 设备编码
+ */
+ @ApiModelProperty(value = "设备编码")
+ private String sn;
+
+ /**
+ * 数据日期
+ */
+ @ApiModelProperty(value = "数据日期")
+ private String date;
+
+ /**
+ * 有无白蚁 1有 2无
+ */
+ @ApiModelProperty(value = "有无白蚁 1有 2无")
+ private String yesnoant;
+
+ /**
+ * 设备地址
+ */
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
deleted file mode 100644
index 93c271f..0000000
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/domain/TermiteMqttData.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.newfiber.termite.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class TermiteMqttData {
-
- /**
- * 设备编码
- */
- @ApiModelProperty(value = "设备编码")
- private String sn;
-
- /**
- * 设备地址
- */
- @ApiModelProperty(value = "设备地址")
- private String location;
-
- /**
- * 数据日期
- */
- @ApiModelProperty(value = "数据日期")
- private String date;
-
- /**
- * 有无白蚁 1有 2无
- */
- @ApiModelProperty(value = "有无白蚁 1有 2无")
- private String yesnoant;
-
-}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
new file mode 100644
index 0000000..3bda36b
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/mapper/TermiteDataMapper.java
@@ -0,0 +1,17 @@
+package com.newfiber.termite.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.newfiber.termite.domain.TermiteData;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Mapper接口
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Mapper
+public interface TermiteDataMapper extends BaseMapper{
+
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
index c2f15aa..6ed8586 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/DataReceiveService.java
@@ -1,26 +1,40 @@
package com.newfiber.termite.service;
import com.alibaba.fastjson2.JSONObject;
-import com.newfiber.termite.domain.TermiteMqttData;
+import com.newfiber.termite.domain.TermiteData;
import com.newfiber.termite.util.MqttUtils;
import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataReceiveService {
- String url = "139.155.49.237";
- Integer port = 8383;
- String userName = "termite_huangpi";
- String userPassword = "Huangpi@2024";
- String subscribeTopic = "wulinshuiku/+/antResult";
+ @Value("${mqtt.url}")
+ String url;
+
+ @Value("${mqtt.port}")
+ Integer port;
+
+ @Value("${mqtt.userName}")
+ String userName;
+
+ @Value("${mqtt.userPassword}")
+ String userPassword;
+
+ @Value("${mqtt.subscribeTopic}")
+ String subscribeTopic;
+
+ @Resource
+ private TermiteDataService termiteDataService;
@PostConstruct
public void initMqttConnect(){
@@ -47,7 +61,7 @@
return "tcp://".concat(url).concat(":").concat(port.toString());
}
- static class TermiteDataReceiveCallback implements MqttCallback {
+ class TermiteDataReceiveCallback implements MqttCallback {
@Override
public void connectionLost(Throwable cause) {
@@ -64,8 +78,8 @@
}
log.info("【数据接收】主题[{}]接收到数据:{}", topic, message);
- TermiteMqttData termiteMqttData = JSONObject.parseObject(message, TermiteMqttData.class);
-
+ TermiteData termiteData = JSONObject.parseObject(message, TermiteData.class);
+ termiteDataService.save(termiteData);
}
@Override
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java
new file mode 100644
index 0000000..4230a76
--- /dev/null
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/java/com/newfiber/termite/service/TermiteDataService.java
@@ -0,0 +1,21 @@
+package com.newfiber.termite.service;
+
+import com.newfiber.common.core.web.service.BaseServiceImpl;
+import com.newfiber.termite.domain.TermiteData;
+import com.newfiber.termite.mapper.TermiteDataMapper;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Service;
+
+/**
+ * 白蚁数据(第三方部署接收数据)Service业务层处理
+ *
+ * @author X.K
+ * @date 2024-11-20
+ */
+@Service
+public class TermiteDataService extends BaseServiceImpl {
+
+ @Resource
+ private TermiteDataMapper termiteDataMapper;
+
+}
diff --git a/newfiber-data-connect/newfiber-data-connect-main/src/main/resources/bootstrap.yml b/newfiber-data-connect/newfiber-data-connect-main/src/main/resources/bootstrap.yml
index 953358e..d2375f0 100644
--- a/newfiber-data-connect/newfiber-data-connect-main/src/main/resources/bootstrap.yml
+++ b/newfiber-data-connect/newfiber-data-connect-main/src/main/resources/bootstrap.yml
@@ -15,11 +15,16 @@
port: 8024
password: xfgd2019redis
database: 9
+# datasource:
+# driver-class-name: com.mysql.cj.jdbc.Driver
+# url: jdbc:mysql://119.27.160.75:62674/newfiber_standard_termite?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true
+# username: root
+# password: xfgdgfA20202328
datasource:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://119.27.160.75:62674/newfiber_standard_termite?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true
- username: root
- password: xfgdgfA20202328
+ driver-class-name: dm.jdbc.driver.DmDriver
+ url: jdbc:dm://1.14.15.129:5237/newfiber_standard?schema=newfiber_standard
+ username: SYSDBA
+ password: SYSDBA
mybatis:
typeAliasesPackage: com.newfiber.termite
@@ -29,3 +34,9 @@
level:
com.newfiber.termite.mapper: DEBUG
+mqtt:
+ url: 139.155.49.237
+ port: 8383
+ userName: termite_huangpi
+ userPassword: Huangpi@2024
+ subscribeTopic: wulinshuiku/+/antResult
\ No newline at end of file