diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
index 5c05f23..c3e20f7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
@@ -1,11 +1,10 @@
package com.newfiber.termite.service;
-import java.util.Date;
-import java.util.List;
import com.newfiber.termite.domain.DeviceMonitoringData;
+import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataSaveRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataUpdateRequest;
-import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
+import java.util.List;
/**
* 白蚁防治数据Service接口
@@ -79,4 +78,12 @@
*/
List selectList(String sn, String startDate, String endDate);
+ /**
+ * 列表查询白蚁防治数据
+ *
+ * @param request 列表参数
+ * @return 白蚁防治数据集合
+ */
+ List selectList(String sn);
+
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
index 5c05f23..c3e20f7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
@@ -1,11 +1,10 @@
package com.newfiber.termite.service;
-import java.util.Date;
-import java.util.List;
import com.newfiber.termite.domain.DeviceMonitoringData;
+import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataSaveRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataUpdateRequest;
-import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
+import java.util.List;
/**
* 白蚁防治数据Service接口
@@ -79,4 +78,12 @@
*/
List selectList(String sn, String startDate, String endDate);
+ /**
+ * 列表查询白蚁防治数据
+ *
+ * @param request 列表参数
+ * @return 白蚁防治数据集合
+ */
+ List selectList(String sn);
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
index b58d719..7883b4f 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
@@ -1,14 +1,20 @@
package com.newfiber.termite.service;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import org.springframework.web.multipart.MultipartFile;
-
import java.util.List;
+import org.springframework.web.multipart.MultipartFile;
public interface ITermiteService {
@@ -20,8 +26,6 @@
List querytermiteData(TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(TermiteHistoryQueryRequest request);
-
boolean updateMonitorData(TermiteInfoUpdateyRequest request);
boolean updateMonitorDevice(DeviceInfoUpdateRequest request);
@@ -36,9 +40,9 @@
UnitInfoDto queryUnitdata();
- List queryAlarmdata(String projectCode);
-
List querySnalarmStatistic(String projectCode);
Object queryNowWeather();
+
+ void transferMySql2Mongo();
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
index 5c05f23..c3e20f7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
@@ -1,11 +1,10 @@
package com.newfiber.termite.service;
-import java.util.Date;
-import java.util.List;
import com.newfiber.termite.domain.DeviceMonitoringData;
+import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataSaveRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataUpdateRequest;
-import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
+import java.util.List;
/**
* 白蚁防治数据Service接口
@@ -79,4 +78,12 @@
*/
List selectList(String sn, String startDate, String endDate);
+ /**
+ * 列表查询白蚁防治数据
+ *
+ * @param request 列表参数
+ * @return 白蚁防治数据集合
+ */
+ List selectList(String sn);
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
index b58d719..7883b4f 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
@@ -1,14 +1,20 @@
package com.newfiber.termite.service;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import org.springframework.web.multipart.MultipartFile;
-
import java.util.List;
+import org.springframework.web.multipart.MultipartFile;
public interface ITermiteService {
@@ -20,8 +26,6 @@
List querytermiteData(TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(TermiteHistoryQueryRequest request);
-
boolean updateMonitorData(TermiteInfoUpdateyRequest request);
boolean updateMonitorDevice(DeviceInfoUpdateRequest request);
@@ -36,9 +40,9 @@
UnitInfoDto queryUnitdata();
- List queryAlarmdata(String projectCode);
-
List querySnalarmStatistic(String projectCode);
Object queryNowWeather();
+
+ void transferMySql2Mongo();
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 526364b..8fc56e5 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -6,6 +6,8 @@
import com.newfiber.common.core.web.service.BaseServiceImpl;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -13,6 +15,7 @@
import com.newfiber.termite.enums.EDeviceSyncState;
import com.newfiber.termite.mapper.DeviceInfoMapper;
import com.newfiber.termite.service.IDeviceInfoService;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
@@ -43,6 +46,22 @@
}
@Override
+ public boolean insert(DeviceInfoBatchSaveRequest request) {
+ if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){
+ return true;
+ }
+ List deviceInfoList = new ArrayList<>();
+ for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){
+ DeviceInfo deviceInfo = new DeviceInfo();
+ BeanUtils.copyProperties(infoImportRequest, deviceInfo);
+ deviceInfo.setProjectCode(request.getProjectCode());
+ deviceInfo.setCategory("project");
+ deviceInfoList.add(deviceInfo);
+ }
+ return saveBatch(deviceInfoList);
+ }
+
+ @Override
public boolean update(DeviceInfoUpdateRequest request) {
DeviceInfo deviceInfo = new DeviceInfo();
BeanUtils.copyProperties(request, deviceInfo);
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
index 5c05f23..c3e20f7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
@@ -1,11 +1,10 @@
package com.newfiber.termite.service;
-import java.util.Date;
-import java.util.List;
import com.newfiber.termite.domain.DeviceMonitoringData;
+import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataSaveRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataUpdateRequest;
-import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
+import java.util.List;
/**
* 白蚁防治数据Service接口
@@ -79,4 +78,12 @@
*/
List selectList(String sn, String startDate, String endDate);
+ /**
+ * 列表查询白蚁防治数据
+ *
+ * @param request 列表参数
+ * @return 白蚁防治数据集合
+ */
+ List selectList(String sn);
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
index b58d719..7883b4f 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
@@ -1,14 +1,20 @@
package com.newfiber.termite.service;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import org.springframework.web.multipart.MultipartFile;
-
import java.util.List;
+import org.springframework.web.multipart.MultipartFile;
public interface ITermiteService {
@@ -20,8 +26,6 @@
List querytermiteData(TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(TermiteHistoryQueryRequest request);
-
boolean updateMonitorData(TermiteInfoUpdateyRequest request);
boolean updateMonitorDevice(DeviceInfoUpdateRequest request);
@@ -36,9 +40,9 @@
UnitInfoDto queryUnitdata();
- List queryAlarmdata(String projectCode);
-
List querySnalarmStatistic(String projectCode);
Object queryNowWeather();
+
+ void transferMySql2Mongo();
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 526364b..8fc56e5 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -6,6 +6,8 @@
import com.newfiber.common.core.web.service.BaseServiceImpl;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -13,6 +15,7 @@
import com.newfiber.termite.enums.EDeviceSyncState;
import com.newfiber.termite.mapper.DeviceInfoMapper;
import com.newfiber.termite.service.IDeviceInfoService;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
@@ -43,6 +46,22 @@
}
@Override
+ public boolean insert(DeviceInfoBatchSaveRequest request) {
+ if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){
+ return true;
+ }
+ List deviceInfoList = new ArrayList<>();
+ for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){
+ DeviceInfo deviceInfo = new DeviceInfo();
+ BeanUtils.copyProperties(infoImportRequest, deviceInfo);
+ deviceInfo.setProjectCode(request.getProjectCode());
+ deviceInfo.setCategory("project");
+ deviceInfoList.add(deviceInfo);
+ }
+ return saveBatch(deviceInfoList);
+ }
+
+ @Override
public boolean update(DeviceInfoUpdateRequest request) {
DeviceInfo deviceInfo = new DeviceInfo();
BeanUtils.copyProperties(request, deviceInfo);
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
index e7df1ac..85ccf9b 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
@@ -1,6 +1,5 @@
package com.newfiber.termite.service.impl;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.newfiber.common.core.exception.ServiceException;
import com.newfiber.common.core.web.domain.BaseEntity;
import com.newfiber.common.core.web.service.BaseServiceImpl;
@@ -16,6 +15,10 @@
import java.util.Optional;
import javax.annotation.Resource;
import org.springframework.beans.BeanUtils;
+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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +34,9 @@
@Resource
private DeviceMonitoringDataMapper deviceMonitoringDataMapper;
+ @Resource
+ private MongoTemplate mongoTemplate;
+
@Override
public long insert(DeviceMonitoringDataSaveRequest request) {
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
@@ -52,6 +58,14 @@
return deleteLogic(ids);
}
+ public boolean existCollect(String sn){
+ return mongoTemplate.collectionExists(sn);
+ }
+
+ public void createCollect(String sn){
+ mongoTemplate.createCollection(sn);
+ }
+
@Override
public DeviceMonitoringData selectDetail(Long id) {
DeviceMonitoringData deviceMonitoringData = deviceMonitoringDataMapper.selectOneById(id);
@@ -63,20 +77,28 @@
@Override
public DeviceMonitoringData lastDruging(String sn) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- ne("druing", EDrugFlag.False.getCode()).
- orderByDesc("druing_datetime").last("limit 1");
- return getOne(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"druing_datetime")).
+ addCriteria(Criteria.where("druing").ne(EDrugFlag.False.getCode()));
+ return mongoTemplate.findOne(query, DeviceMonitoringData.class, sn);
+//
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// ne("druing", EDrugFlag.False.getCode()).
+// orderByDesc("druing_datetime").last("limit 1");
+// return getOne(queryWrapper);
}
@Override
public DeviceMonitoringData lastHeating(String sn) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- eq("heating", EHeatingFlag.True.getCode()).
- orderByDesc("heating_datetime").last("limit 1");
- return getOne(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"heating_datetime")).
+ addCriteria(Criteria.where("heating").is(EHeatingFlag.True.getCode()));
+ return mongoTemplate.findOne(query, DeviceMonitoringData.class, sn);
+
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// eq("heating", EHeatingFlag.True.getCode()).
+// orderByDesc("heating_datetime").last("limit 1");
+// return getOne(queryWrapper);
}
@Override
@@ -91,10 +113,21 @@
@Override
public List selectList(String sn, String startDate, String endDate) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- ge("date", startDate).le("date", endDate).orderByDesc("date");
- return list(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"date")).
+ addCriteria(Criteria.where("date").gte(startDate)).addCriteria(Criteria.where("date").lte(endDate));
+ return mongoTemplate.find(query, DeviceMonitoringData.class, sn);
+
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// ge("date", startDate).le("date", endDate).orderByDesc("date");
+// return list(queryWrapper);
+ }
+
+ @Override
+ public List selectList(String sn) {
+ DeviceMonitoringDataQueryRequest deviceMonitoringDataQueryRequest = new DeviceMonitoringDataQueryRequest();
+ deviceMonitoringDataQueryRequest.setSn(sn);
+ return deviceMonitoringDataMapper.selectByCondition(deviceMonitoringDataQueryRequest);
}
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List querytermiteData(@Param("request") TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(@Param("request")TermiteHistoryQueryRequest request);
-
- @Deprecated
- void updateMonitorData(@Param("request")TermiteInfoUpdateyRequest request);
-
void updateMonitorDevice(@Param("request") DeviceInfoUpdateRequest request);
List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request);
@@ -49,13 +31,4 @@
DataUpResponse queryDataUpResponse(@Param("sn")String sn);
UnitInfoDto queryUnitdata();
-
- @Deprecated
- List queryAlarmdata(@Param("projectCode")String projectCode);
-
- @Deprecated
- void updateDeviceLastUpTime(@Param("sn")String sn ,@Param("lastDate") String lastDate);
-
- @Deprecated
- List queryDeviceData(@Param("projectCode")String projectCode);
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
index 9978857..b1f5f0e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java
@@ -2,6 +2,7 @@
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -26,6 +27,14 @@
long insert(DeviceInfoSaveRequest request);
/**
+ * 新增设备信息
+ *
+ * @param request 新增参数
+ * @return 结果
+ */
+ boolean insert(DeviceInfoBatchSaveRequest request);
+
+ /**
* 修改设备信息
*
* @param request 修改参数
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
index 5c05f23..c3e20f7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceMonitoringDataService.java
@@ -1,11 +1,10 @@
package com.newfiber.termite.service;
-import java.util.Date;
-import java.util.List;
import com.newfiber.termite.domain.DeviceMonitoringData;
+import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataSaveRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataUpdateRequest;
-import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
+import java.util.List;
/**
* 白蚁防治数据Service接口
@@ -79,4 +78,12 @@
*/
List selectList(String sn, String startDate, String endDate);
+ /**
+ * 列表查询白蚁防治数据
+ *
+ * @param request 列表参数
+ * @return 白蚁防治数据集合
+ */
+ List selectList(String sn);
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
index b58d719..7883b4f 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java
@@ -1,14 +1,20 @@
package com.newfiber.termite.service;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import org.springframework.web.multipart.MultipartFile;
-
import java.util.List;
+import org.springframework.web.multipart.MultipartFile;
public interface ITermiteService {
@@ -20,8 +26,6 @@
List querytermiteData(TermiteInfoQueryRequest request);
- TermiteInfoResponse queryMonitorData(TermiteHistoryQueryRequest request);
-
boolean updateMonitorData(TermiteInfoUpdateyRequest request);
boolean updateMonitorDevice(DeviceInfoUpdateRequest request);
@@ -36,9 +40,9 @@
UnitInfoDto queryUnitdata();
- List queryAlarmdata(String projectCode);
-
List querySnalarmStatistic(String projectCode);
Object queryNowWeather();
+
+ void transferMySql2Mongo();
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 526364b..8fc56e5 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -6,6 +6,8 @@
import com.newfiber.common.core.web.service.BaseServiceImpl;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
@@ -13,6 +15,7 @@
import com.newfiber.termite.enums.EDeviceSyncState;
import com.newfiber.termite.mapper.DeviceInfoMapper;
import com.newfiber.termite.service.IDeviceInfoService;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
@@ -43,6 +46,22 @@
}
@Override
+ public boolean insert(DeviceInfoBatchSaveRequest request) {
+ if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){
+ return true;
+ }
+ List deviceInfoList = new ArrayList<>();
+ for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){
+ DeviceInfo deviceInfo = new DeviceInfo();
+ BeanUtils.copyProperties(infoImportRequest, deviceInfo);
+ deviceInfo.setProjectCode(request.getProjectCode());
+ deviceInfo.setCategory("project");
+ deviceInfoList.add(deviceInfo);
+ }
+ return saveBatch(deviceInfoList);
+ }
+
+ @Override
public boolean update(DeviceInfoUpdateRequest request) {
DeviceInfo deviceInfo = new DeviceInfo();
BeanUtils.copyProperties(request, deviceInfo);
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
index e7df1ac..85ccf9b 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceMonitoringDataServiceImpl.java
@@ -1,6 +1,5 @@
package com.newfiber.termite.service.impl;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.newfiber.common.core.exception.ServiceException;
import com.newfiber.common.core.web.domain.BaseEntity;
import com.newfiber.common.core.web.service.BaseServiceImpl;
@@ -16,6 +15,10 @@
import java.util.Optional;
import javax.annotation.Resource;
import org.springframework.beans.BeanUtils;
+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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +34,9 @@
@Resource
private DeviceMonitoringDataMapper deviceMonitoringDataMapper;
+ @Resource
+ private MongoTemplate mongoTemplate;
+
@Override
public long insert(DeviceMonitoringDataSaveRequest request) {
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
@@ -52,6 +58,14 @@
return deleteLogic(ids);
}
+ public boolean existCollect(String sn){
+ return mongoTemplate.collectionExists(sn);
+ }
+
+ public void createCollect(String sn){
+ mongoTemplate.createCollection(sn);
+ }
+
@Override
public DeviceMonitoringData selectDetail(Long id) {
DeviceMonitoringData deviceMonitoringData = deviceMonitoringDataMapper.selectOneById(id);
@@ -63,20 +77,28 @@
@Override
public DeviceMonitoringData lastDruging(String sn) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- ne("druing", EDrugFlag.False.getCode()).
- orderByDesc("druing_datetime").last("limit 1");
- return getOne(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"druing_datetime")).
+ addCriteria(Criteria.where("druing").ne(EDrugFlag.False.getCode()));
+ return mongoTemplate.findOne(query, DeviceMonitoringData.class, sn);
+//
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// ne("druing", EDrugFlag.False.getCode()).
+// orderByDesc("druing_datetime").last("limit 1");
+// return getOne(queryWrapper);
}
@Override
public DeviceMonitoringData lastHeating(String sn) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- eq("heating", EHeatingFlag.True.getCode()).
- orderByDesc("heating_datetime").last("limit 1");
- return getOne(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"heating_datetime")).
+ addCriteria(Criteria.where("heating").is(EHeatingFlag.True.getCode()));
+ return mongoTemplate.findOne(query, DeviceMonitoringData.class, sn);
+
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// eq("heating", EHeatingFlag.True.getCode()).
+// orderByDesc("heating_datetime").last("limit 1");
+// return getOne(queryWrapper);
}
@Override
@@ -91,10 +113,21 @@
@Override
public List selectList(String sn, String startDate, String endDate) {
- QueryWrapper queryWrapper = new QueryWrapper().
- eq("sn", sn).
- ge("date", startDate).le("date", endDate).orderByDesc("date");
- return list(queryWrapper);
+ Query query = new Query().with(Sort.by(Sort.Direction.DESC,"date")).
+ addCriteria(Criteria.where("date").gte(startDate)).addCriteria(Criteria.where("date").lte(endDate));
+ return mongoTemplate.find(query, DeviceMonitoringData.class, sn);
+
+// QueryWrapper queryWrapper = new QueryWrapper().
+// eq("sn", sn).
+// ge("date", startDate).le("date", endDate).orderByDesc("date");
+// return list(queryWrapper);
+ }
+
+ @Override
+ public List selectList(String sn) {
+ DeviceMonitoringDataQueryRequest deviceMonitoringDataQueryRequest = new DeviceMonitoringDataQueryRequest();
+ deviceMonitoringDataQueryRequest.setSn(sn);
+ return deviceMonitoringDataMapper.selectByCondition(deviceMonitoringDataQueryRequest);
}
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
index 20281fe..9880812 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
@@ -14,7 +14,6 @@
import com.newfiber.termite.domain.DeviceMonitoringDataRealtime;
import com.newfiber.termite.domain.OneByOneNow;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
@@ -42,19 +41,6 @@
import com.newfiber.termite.service.jingchu.IJingchuDeviceConfigService;
import com.newfiber.termite.service.jingchu.IJingchuProjectConfigService;
import com.newfiber.termite.util.CosUtil;
-import com.newfiber.termite.util.FileUploadUtils;
-import com.newfiber.termite.util.MinioConfig;
-import io.minio.MinioClient;
-import io.minio.PutObjectArgs;
-import io.minio.errors.ErrorResponseException;
-import io.minio.errors.InsufficientDataException;
-import io.minio.errors.InternalException;
-import io.minio.errors.InvalidResponseException;
-import io.minio.errors.ServerException;
-import io.minio.errors.XmlParserException;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -63,32 +49,22 @@
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
-import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
+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.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
@Slf4j
@Service
public class TermiteServiceImpl extends BaseServiceImpl implements ITermiteService {
-
@Resource
private TermiteMapper termiteMapper;
- @Autowired
- private MinioConfig minioConfig;
-
- @Autowired
- private MinioClient client;
-
- @Resource
- private RestTemplate restTemplate;
-
@Resource
private DeviceInfoServiceImpl deviceInfoService;
@@ -107,6 +83,12 @@
@Resource
private JingchuResourceConfig jingchuResourceConfig;
+ @Resource
+ private MongoTemplate mongoTemplate;
+
+// @Resource
+// private MqttClient mqttClient;
+
private final String JINGCHU_UPLOAD_API = "/waterDataTermites/insertDataBatch";
private final ExecutorService jingchuExecutorService = Executors.newFixedThreadPool(4);
@@ -127,6 +109,8 @@
deviceMonitoringData.setDate(DateUtil.formatDateTime(new Date()));
deviceMonitoringDataService.save(deviceMonitoringData);
+ mongoTemplate.save(deviceMonitoringData, termiteDateUpRequest.getSn());
+
// 保存实时数据
deviceMonitoringDataRealtimeService.deleteBySn(termiteDateUpRequest.getSn());
DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime();
@@ -141,6 +125,8 @@
termiteDateUpRequest.setLastPicTime(new Date());
deviceInfoService.update(termiteDateUpRequest);
+// mqttClient.publish("termite_mqtt", JSONObject.toJSONBytes(deviceMonitoringData), 1, true);
+
return new DataUpResponse(url, lastDrugingDeviceMonitoringData, lastHeatingDeviceMonitoringData);
}
@@ -157,12 +143,17 @@
deviceMonitoringData.setIdenpitcu(url);
deviceMonitoringDataService.updateById(deviceMonitoringData);
+ Query updateQuery = new Query().addCriteria(Criteria.where("sn").is(existedDeviceMonitoringData.getSn())).
+ addCriteria(Criteria.where("date").is(existedDeviceMonitoringData.getDate()));
+ Update update = new Update().set("yesnoant", dataDto.getYesnoant()).set("idenpitcu", url);
+ mongoTemplate.updateMulti(updateQuery, update, existedDeviceMonitoringData.getSn());
+
DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime();
BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime);
deviceMonitoringDataRealtimeService.updateById(deviceMonitoringDataRealtime);
// 上传荆楚平台
- jingchuExecutorService.submit(() -> jingChuUpload(existedDeviceMonitoringData, dataDto.getYesnoant()));
+ jingchuExecutorService.execute(() -> jingChuUpload(existedDeviceMonitoringData, dataDto.getYesnoant()));
return url;
}
@@ -234,12 +225,8 @@
}
@Override
- public TermiteInfoResponse queryMonitorData(TermiteHistoryQueryRequest request){
- return termiteMapper.queryMonitorData(request);
- }
-
- @Override
public boolean updateMonitorData(TermiteInfoUpdateyRequest request){
+ // TODO
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
BeanUtils.copyProperties(request, deviceMonitoringData);
if(EDrugFlag.True.getCode().equals(request.getDruing())){
@@ -282,6 +269,7 @@
@Override
public List queryhistoryData(TermiteHistoryQueryRequest request){
+ // TODO
return termiteMapper.queryhistoryData(request);
}
@@ -308,12 +296,6 @@
}
@Override
- @Deprecated
- public List queryAlarmdata(String projectCode){
- return termiteMapper.queryAlarmdata(projectCode);
- }
-
- @Override
public List querySnalarmStatistic(String projectCode){
List result = new ArrayList<>();
//查询所有站点的数据信息
@@ -350,33 +332,27 @@
@Override
public Object queryNowWeather(){
-
String url = "https://gfapi.mlogcn.com/weather/v001/now?areacode=101201403&key=F2hH0eoTQS99jaKr3v4AIWFQkJwRjMAU&output_type=json";
- ResponseEntity forEntity = restTemplate.getForEntity(url, String.class);
- if (forEntity.getStatusCode().is2xxSuccessful()) {
- JSONObject object = JSONObject.parseObject(forEntity.getBody());
- JSONObject result = JSONObject.parseObject(JSON.toJSONString(object.get("result")));
- OneByOneNow oneByOneHours = JSONObject.parseObject(JSONObject.toJSONString(result.get("realtime")),OneByOneNow.class);
- return oneByOneHours;
- }
- else {
- return "gaofen天气Api调用失败";
- }
+ String forEntity = HttpUtil.get(url);
+ JSONObject object = JSONObject.parseObject(forEntity);
+ JSONObject result = JSONObject.parseObject(JSON.toJSONString(object.get("result")));
+ OneByOneNow oneByOneHours = JSONObject.parseObject(JSONObject.toJSONString(result.get("realtime")),OneByOneNow.class);
+ return oneByOneHours;
}
- @NotNull
- private String uploadFile(MultipartFile image)
- throws IOException, ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, NoSuchAlgorithmException, ServerException, XmlParserException {
- String fileName = FileUploadUtils.extractFilename(image);
- PutObjectArgs args = PutObjectArgs.builder()
- .bucket(minioConfig.getBucketName())
- .object(fileName)
- .stream(image.getInputStream(), image.getSize(), -1)
- .contentType(image.getContentType())
- .build();
- client.putObject(args);
- return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
+ @Override
+ public void transferMySql2Mongo() {
+ List deviceInfoList = deviceInfoService.list();
+ for(DeviceInfo deviceInfo : deviceInfoList){
+ if(!mongoTemplate.collectionExists(deviceInfo.getSn())){
+ mongoTemplate.createCollection(deviceInfo.getSn());
+ }
+
+ List deviceMonitoringDataList = deviceMonitoringDataService.selectList(deviceInfo.getSn());
+ mongoTemplate.save(deviceMonitoringDataList, deviceInfo.getSn());
+
+ }
}
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d3d3d3f..20a8988 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -79,17 +79,12 @@
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `sync_state` VARCHAR(32) NULL DEFAULT 'success' COMMENT '同步状态(成功 success | 失败 fail)' AFTER `camera`;
--- 未更新 0611
-CREATE TABLE `thi_jingchu_config` (
+-- 已更新 0613
+CREATE TABLE `thi_jingchu_device_config` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`sn` varchar(100) DEFAULT NULL COMMENT '设备sn',
- `device_id` int(11) DEFAULT NULL COMMENT '设备id',
- `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
- `electricity` int(11) DEFAULT NULL COMMENT '白蚁设备电量',
- `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
- `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序',
- `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
- `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `order` varchar(32) DEFAULT NULL COMMENT '白蚁设备安装的点位顺序(自定义6位数)',
+ `upload_confirm_flag` char(1) DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))',
`remark` varchar(45) DEFAULT NULL,
`status` varchar(16) DEFAULT NULL,
`create_by` varchar(64) DEFAULT NULL,
@@ -97,12 +92,25 @@
`update_by` varchar(64) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`del_flag` char(1) DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台信息';
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD UNIQUE INDEX `index2` (`sn` ASC);
-;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-ADD COLUMN `upload_confirm_flag` CHAR NULL DEFAULT 0 COMMENT '是否上传有白蚁数据(减少误报)' AFTER `station_name`;
-ALTER TABLE `newfiber_standard_termite`.`thi_jingchu_config`
-CHANGE COLUMN `upload_confirm_flag` `upload_confirm_flag` CHAR(1) NULL DEFAULT '0' COMMENT '是否上传有白蚁数据(减少误报(0 否 | 1 是))' ;
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`sn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台设备信息';
+
+CREATE TABLE `thi_jingchu_project_config` (
+ `id` bigint(20) NOT NULL COMMENT '主键id',
+ `project_code` varchar(100) DEFAULT NULL COMMENT '项目编号',
+ `mn_no` varchar(64) DEFAULT NULL COMMENT '设备编码',
+ `station_id` int(11) DEFAULT NULL COMMENT '中心站地址',
+ `station_name` varchar(128) DEFAULT NULL COMMENT '站点名称',
+ `device_id` int(11) DEFAULT NULL COMMENT '设备id',
+ `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
+ `remark` varchar(45) DEFAULT NULL,
+ `status` varchar(16) DEFAULT NULL,
+ `create_by` varchar(64) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `update_by` varchar(64) DEFAULT NULL,
+ `update_time` datetime DEFAULT NULL,
+ `del_flag` char(1) DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `index2` (`project_code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方对接-荆楚平台项目信息';
\ No newline at end of file
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index f2722fb..1611366 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -16,12 +16,6 @@
newfiber-termites-dataup
-
-
- io.minio
- minio
- ${minio.version}
-
org.springframework.integration
@@ -29,6 +23,11 @@
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
com.qcloud
cos_api
5.6.213
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
new file mode 100644
index 0000000..0f4441e
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/MqttConfig.java
@@ -0,0 +1,87 @@
+package com.newfiber.termite.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.IMqttToken;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+
+@Slf4j
+//@Configuration
+public class MqttConfig {
+ /**
+ * MQTT服务端地址
+ */
+ @Value("${spring.mqtt.url}")
+ private String serverURI;
+
+ /**
+ * 发布客户端id(不能重复)
+ */
+ @Value("${spring.mqtt.clientIdPub}")
+ private String clientIdPub;
+
+ /**
+ * 用户名
+ */
+ @Value("${spring.mqtt.username}")
+ private String username;
+
+ /**
+ * 密码
+ */
+ @Value("${spring.mqtt.password}")
+ private String password;
+
+ /**
+ * mqtt发送消息客户端
+ */
+ private static MqttClient sendMqttClient;
+
+ public static MqttClient getSendClient() {
+ return sendMqttClient;
+ }
+
+
+ static MqttConnectOptions opts;
+
+ @Bean
+ MqttConnectOptions mqttConnectOptions() {
+ try {
+ opts = new MqttConnectOptions();
+ opts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
+ opts.setMaxReconnectDelay(5 * 1000);
+ opts.setConnectionTimeout(2 * 1000);
+ opts.setHttpsHostnameVerificationEnabled(false);
+ opts.setCleanSession(false);
+ opts.setKeepAliveInterval(5);
+ opts.setAutomaticReconnect(true);
+ opts.setUserName(username);
+ opts.setPassword(password.toCharArray());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return opts;
+ }
+
+ @Bean
+ MqttClient sendMqttClient() {
+ MqttClient sendClient = null;
+ try {
+
+ MemoryPersistence persistence = new MemoryPersistence();
+ sendClient = new MqttClient(serverURI, clientIdPub + "send", persistence);
+ IMqttToken token = sendClient.connectWithResult(opts);
+ token.waitForCompletion();
+ sendMqttClient = sendClient;
+ } catch (MqttException e) {
+ log.error(e.getMessage());
+ }
+ return sendMqttClient;
+ }
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
deleted file mode 100644
index 7bb1168..0000000
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.newfiber.termite.config;
-
-
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfig {
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
index 122a0e2..18f9974 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java
@@ -1,28 +1,32 @@
package com.newfiber.termite.controller;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.newfiber.common.log.annotation.Log;
-import com.newfiber.common.log.enums.BusinessType;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
-import com.newfiber.termite.service.IDeviceInfoService;
+import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
+import com.newfiber.common.log.annotation.Log;
+import com.newfiber.common.log.enums.BusinessType;
+import com.newfiber.termite.domain.DeviceInfo;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoBatchSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoImportRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
+import com.newfiber.termite.service.IDeviceInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 设备信息Controller
@@ -49,6 +53,33 @@
}
/**
+ * 新增设备信息
+ */
+ @PostMapping("addBatch")
+ @ApiOperation(value = "批量新增设备信息", position = 10)
+ @Log(title = "设备信息", businessType = BusinessType.INSERT)
+ public Result addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
+ deviceInfoService.insert(request);
+ return success();
+ }
+
+ @PostMapping("/parseExcel")
+ public Result> parseExcel(MultipartFile file) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ return success(deviceInfoImportRequestList);
+ }
+
+ @PostMapping("/importExcel")
+ public Result importExcel(MultipartFile file, String projectCode) throws Exception{
+ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class);
+ List deviceInfoImportRequestList = util.importExcel(file.getInputStream());
+ DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
+ deviceInfoService.insert(batchSaveRequest);
+ return success();
+ }
+
+ /**
* 修改设备信息
*/
@PutMapping("edit")
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
index 7e1f88d..42de836 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java
@@ -4,12 +4,21 @@
import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
+import com.newfiber.common.core.web.domain.Result;
+import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
-import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
+import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
@@ -18,14 +27,13 @@
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import com.newfiber.common.core.web.domain.Result;
-import com.newfiber.common.core.web.page.PageResult;
-
-import javax.annotation.Resource;
import java.util.List;
+import javax.annotation.Resource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/termite")
@@ -98,16 +106,6 @@
return success(list);
}
- /**
- * 查询当前行数据
- */
- @PostMapping("/queryMonitorData")
- @ApiOperation(value = "查询当前行数据", position = 60)
- public Result queryMonitorData(TermiteHistoryQueryRequest request){
- TermiteInfoResponse result = termiteService.queryMonitorData(request);
- return success(result);
- }
-
/**
* 更新监测数据
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
new file mode 100644
index 0000000..80c5723
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoBatchSaveRequest.java
@@ -0,0 +1,29 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceInfoBatchSaveRequest {
+
+ /**
+ * 项目编号
+ */
+ @ApiModelProperty(value = "项目编号")
+ private String projectCode;
+
+ private List deviceInfoImportRequestList;
+
+
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
new file mode 100644
index 0000000..f46e241
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java
@@ -0,0 +1,54 @@
+package com.newfiber.termite.domain.request.deviceInfo;
+
+import com.newfiber.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 设备信息对象 ter_device_info
+ *
+ * @author X.K
+ * @date 2024-05-27
+ */
+@Data
+public class DeviceInfoImportRequest {
+
+ /**
+ * 设备编号
+ */
+ @Excel(name = "站点编号(SN)")
+ @ApiModelProperty(value = "设备编号")
+ private String sn;
+
+ /**
+ * 设备地址
+ */
+ @Excel(name = "站点名称")
+ @ApiModelProperty(value = "设备地址")
+ private String location;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经度")
+ private String lonand;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "纬度")
+ @ApiModelProperty(value = "纬度")
+ private String lat;
+
+ /**
+ * 经纬度
+ */
+ @Excel(name = "经度")
+ @ApiModelProperty(value = "经纬度")
+ private String lonandlat;
+
+ public String getLonandlat() {
+ return lonand + "," + lat;
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
index d81f6b4..731042e 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoSaveRequest.java
@@ -1,12 +1,7 @@
package com.newfiber.termite.domain.request.deviceInfo;
-import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.NotBlank;
+import lombok.Data;
/**
* 设备信息对象 ter_device_info
@@ -18,13 +13,6 @@
public class DeviceInfoSaveRequest{
/**
- * 主键id
- */
- @ApiModelProperty(value = "主键id")
- @JsonFormat(shape = JsonFormat.Shape.STRING)
- private Long id;
-
- /**
* 分类(生产 production | 项目 project)
*/
@ApiModelProperty(value = "分类(生产 production | 项目 project)")
@@ -49,22 +37,10 @@
private String location;
/**
- * 初始照片
- */
- @ApiModelProperty(value = "初始照片")
- private String initialpictu;
-
- /**
* 经纬度
*/
@ApiModelProperty(value = "经纬度")
private String lonandlat;
- /**
- * 逻辑删除 0:否 1:是
- */
- @ApiModelProperty(value = "逻辑删除 0:否 1:是")
- private String delFlag;
-
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
index e98e883..9dee2a7 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/DeviceInfoConfigQueryAntResponse.java
@@ -3,7 +3,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.checkerframework.checker.units.qual.A;
/**
* 设备信息对象 ter_device_info
@@ -15,7 +14,6 @@
@AllArgsConstructor
public class DeviceInfoConfigQueryAntResponse {
-
/**
* 数据日期
*/
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
index 214e68d..ffa44d0 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java
@@ -2,38 +2,20 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.AlarmDataDto;
-import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
-import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
-import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermiteMapper extends BaseMapper {
- @Deprecated
- void addtermiteData(@Param("sn")String sn, @Param("datadate")String date,@Param("druing")String druing
- , @Param("uptime")Date uptime, @Param("url")String url,@Param("software")String software,@Param("hardware")String hardware
- ,@Param("temperature")String temperature,@Param("voltage")String voltage,@Param("rssi")String rssi
- ,@Param("ap")String ap,@Param("camera")String camera);
-
- @Deprecated
- void updatephotoIdentify(@Param("id")String id,@Param("yesnoant")String yesnoant, @Param("url")String url);
-
List