Commit 40657a89 authored by 赵啸非's avatar 赵啸非

修改设备获取服务器地址方式

parent b99c19a7
......@@ -16,7 +16,6 @@
<groupId>com.mortals.xhx</groupId>
<artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath/>
</parent>
<properties>
<rabbitmq.version>4.8.0</rabbitmq.version>
......
use `device-platform`;
use
`device-platform`;
-- ----------------------------
-- 设备表
-- ----------------------------
......@@ -84,7 +85,7 @@ DROP TABLE IF EXISTS `mortals_xhx_product`;
CREATE TABLE mortals_xhx_product
(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`platformId` bigint(20) NOT NULL COMMENT '关联平台',
`platformId` bigint(20) NOT NULL COMMENT '关联平台',
`productName` varchar(20) NOT NULL COMMENT '产品名称,名称唯一',
`productCode` varchar(256) COMMENT '产品编码',
`skinId` bigint(20) NOT NULL COMMENT '皮肤id',
......@@ -298,6 +299,26 @@ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备统计';
DROP TABLE IF EXISTS `mortals_xhx_device_module_distribute`;
CREATE TABLE `mortals_xhx_device_module_distribute`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`productId` bigint(20) NULL DEFAULT NULL COMMENT '产品Id',
`productCode` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品编码',
`productName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`imageResolution` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分辨率',
`imageResolutionValue` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分辨率值',
`filePath` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件相对路径地址',
`distributeFilePath` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件部署路径地址',
`version` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本号',
`distribute` tinyint(2) NOT NULL COMMENT '是否部署(0.否,1.是)',
`createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`updateUserId` bigint(20) NULL DEFAULT NULL COMMENT '更新用户',
`updateTime` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备前端模块部署' ROW_FORMAT = Dynamic;
-- ----------------------------
-- 产品客户端版本表
......
......@@ -60,4 +60,12 @@ INSERT INTO `mortals_xhx_product` VALUES (11, 1, 'LED通屏', 'ledtp', NULL, NUL
INSERT INTO `mortals_xhx_product` VALUES (13, 4, '取件柜', 'qjg', NULL, NULL, 'http://www.baidu.com', NULL, '', 1, '2022-07-26 10:28:42', 1, '2022-07-26 10:28:42');
INSERT INTO `mortals_xhx_product` VALUES (14, 5, '信息发布屏', 'xxfbp', NULL, '', '', NULL, '', 1, '2022-08-04 09:42:01', 1, '2022-08-04 09:46:51');
INSERT INTO `mortals_xhx_product` VALUES (15, 6, '背靠背评价设备', 'bkb', NULL, '', '', NULL, '背靠背评价设备', 1, '2022-08-17 16:35:05', 1, '2022-08-17 16:35:05');
INSERT INTO `mortals_xhx_product` VALUES (16, 7, '数字样表机', 'szybj', NULL, '', '', NULL, '', 1, '2022-10-27 16:21:41', 1, '2022-10-27 16:21:41');
\ No newline at end of file
INSERT INTO `mortals_xhx_product` VALUES (16, 7, '数字样表机', 'szybj', NULL, '', '', NULL, '', 1, '2022-10-27 16:21:41', 1, '2022-10-27 16:21:41');
INSERT INTO `mortals_xhx_task` VALUES (3, '设备状态任务', 'deviceStatTask', 0, 'DeviceStatTask', NULL, '', 4, 60, '00', NULL, '192.168.56.1', '2022-07-06 10:18:29', 0, '2022-03-09 15:59:51', 1, '系统管理员');
INSERT INTO `mortals_xhx_task` VALUES (4, '站点设备统计', 'siteStatTask', 0, 'SiteStatTask', NULL, NULL, 4, 60, '00', NULL, '127.0.1.1', '2023-01-13 14:41:36', 0, '2022-06-30 17:15:21', 1, '系统管理员');
INSERT INTO `mortals_xhx_task` VALUES (5, '设备统计任务', 'deviceTotalStatTask', 0, 'DeviceTotalStatTask', NULL, NULL, 4, 120, '00:00', NULL, '127.0.1.1', '2023-01-13 14:41:35', 0, '2022-07-05 16:33:30', 1, '系统管理员');
INSERT INTO `mortals_xhx_task`VALUES (6, '短信发送任务', 'smsSendTask', 0, 'SmsSendTask', NULL, NULL, 4, 10, '00', NULL, '127.0.1.1', '2023-01-13 14:42:18', 0, '2022-07-05 16:34:25', 1, '系统管理员');
INSERT INTO `mortals_xhx_task`VALUES (7, '用户同步', 'syncUserTask', 0, 'SyncUserTask', NULL, NULL, 4, 120, '00', NULL, '127.0.1.1', '2023-01-13 14:41:35', 0, '2022-07-06 10:49:48', 1, '系统管理员');
INSERT INTO `mortals_xhx_task` VALUES (9, '设备状态修正任务', 'deviceStatTask', 0, 'DeviceStatTask', NULL, NULL, 4, 120, '00', NULL, '127.0.1.1', '2023-01-13 14:41:35', 0, '2022-07-20 16:50:42', 1, '系统管理员');
......@@ -137,27 +137,27 @@
<profiles.server.port>18222</profiles.server.port>
<profiles.platform.type>cloud</profiles.platform.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://127.0.0.1:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://172.15.28.121:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.uri>172.15.28.120</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>6</profiles.redis.database>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.host>172.15.28.120</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.exchange>amp.direct</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.smsSendUrl>http://172.15.28.114:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.filepath>/home/mortals/app/data</profiles.filepath>
<profiles.log.level>INFO</profiles.log.level>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>172.15.28.120:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<package.environment>yibin</package.environment>
......
......@@ -93,7 +93,7 @@ project_deploy() {
project_ui_deploy() {
writelog "${PROJECT_NAME}_ui_deploy"
clear_ui_deploy ${PROJECT_UI_EXECPATH}
tar -zvxf ./${PROJECT_UI_FILENAME} -C ${PUBLISH_PATH}
tar -zvx ./${PROJECT_UI_FILENAME} -C ${PUBLISH_PATH}
writelog "${PROJECT_NAME}_ui_deploy_finish"
}
......
......@@ -2,6 +2,7 @@ package com.mortals.xhx.busiz.web;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -61,6 +62,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
......@@ -137,10 +139,13 @@ public class DeviceApiController {
ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp();
URL url = getServerUrl();
try {
DeviceEntity deviceEntity = checkDeviceExistAndCreate(req);
DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo();
authInfo.setHost(host);
// authInfo.setHost(host);
authInfo.setHost(url.getHost());
authInfo.setPort(port);
authInfo.setUsername(username);
authInfo.setPassword(password);
......@@ -214,6 +219,12 @@ public class DeviceApiController {
return JSON.toJSONString(rsp);
}
private static URL getServerUrl() {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
URL url = URLUtil.url(domain);
return url;
}
/**
* 获取Token
......@@ -376,7 +387,9 @@ public class DeviceApiController {
}
DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo();
authInfo.setHost(host);
URL url = getServerUrl();
//authInfo.setHost(host);
authInfo.setHost(url.getHost());
authInfo.setPort(port);
authInfo.setUsername(username);
authInfo.setPassword(password);
......@@ -837,15 +850,15 @@ public class DeviceApiController {
if (!ObjectUtils.isEmpty(deviceEntity.getHomeUrl())) {
homeUrl = deviceEntity.getHomeUrl();
}
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
log.info("domain:"+GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL,""));
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.3.24:11078");
serverInfo.setHomeUrl(UrlBuilder.of(domain).addPath(homeUrl).toString());
log.info("homeurl:"+serverInfo.getHomeUrl());
serverInfo.setEventUrl(productEntity.getEventUrl());
}
private void buildDownloadUrl(ProductVersionEntity productVersionEntity, ProductVersionInfo productVersionInfo) {
String download = "";
if (!ObjectUtils.isEmpty(productVersionEntity.getFilePath())) {
download = productVersionEntity.getFilePath();
}
......
......@@ -77,7 +77,7 @@ public final class Constant {
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
/**
* 服务器http
* 服务器http 映射外网可访问地址
*/
public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
......
package com.mortals.xhx.daemon.netty.server.controlserver.handler;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.GlobalSysInfo;
......@@ -56,7 +55,8 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
String serverPort = SpringUtil.getProperty("server.port");
// String serverPort = SpringUtil.getProperty("server.port");
String serverPort = "11091";
ByteBuf byteBuf = packet.copy().content();
byte[] bytes = new byte[byteBuf.readableBytes()];
......@@ -73,17 +73,15 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
String action = jsonObject.getString("action");
resp.setMsg("获取服务端地址成功!");
if (!ObjectUtils.isEmpty(action) && "findserver".equals(action)) {
String domain = "";
String currentIp = getInet4Address();
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
/* String currentIp = getInet4Address();
if (currentIp != null) {
domain = "http://" + currentIp + ":" + serverPort;
} else {
domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
}
}*/
URL url = URLUtil.url(domain);
log.info("getServerUrl:" + domain);
String deviceRegisterApi = servletPath + registerApiPath;
String deviceInitApi = servletPath + deviceInitApiPath;
String deviceUpdateApi = servletPath + deviceUpdateApiPath;
......@@ -165,14 +163,15 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
public static void main(String[] args) {
/* String domain="http://192.168.0.98:11801";
String domain="http://192.168.0.98:11801";
URL url = URLUtil.url(domain);
System.out.println(url.getHost());
System.out.println(url.getPort());*/
System.out.println(url.getPort());
InetAddress currentIp = NettyUDPServerHandler.getCurrentIp();
/* InetAddress currentIp = NettyUDPServerHandler.getCurrentIp();
System.out.println(currentIp.getHostName());
System.out.println(getInet4Address());
System.out.println(getInet4Address());*/
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment