Commit b82570fc authored by 皮倩雯's avatar 皮倩雯

fix: '物联网统一接入接入优化'

parent dde7705d
Pipeline #69074 passed with stages
......@@ -17,7 +17,7 @@ import {
Modal,
Space,
} from 'antd';
import { CloseCircleFilled, InfoCircleFilled } from '@ant-design/icons';
import { CloseCircleFilled, InfoCircleFilled, QuestionCircleOutlined } from '@ant-design/icons';
import styles from './IotConfig.less';
import Internet from '../../../../assets/images/icons/物联.svg';
import EMQ from '../../../../assets/images/icons/EMQ.svg';
......@@ -39,6 +39,7 @@ import {
GetGateWay,
IsIotUpgrade, // 判断是否需要升级物联网统一接入平台
IotUpgrade, // 升级物联网统一接入平台
GetIotVersion, // 检查版本BS还是CS
} from '@/services/hostmanager/hostmanager';
import {
GetDbProduct, // 获取产品方案配置
......@@ -107,20 +108,17 @@ const IotConfig = props => {
GetDataBaseConfig().then(res => {
if (res.code === 0) {
GetDbProduct({ ...res.data }).then(ress => {
console.log(res.data);
console.log(ress.data.Project);
if (ress.data.Project.length > 0) {
console.log(ress.data.Project[ress.data.Project.length - 1].projectName);
setKeep(ress.data.Project[ress.data.Project.length - 1].projectName);
}
});
setCurrentDataBase(res.data);
// 数据库是否已添加
setLoading(true);
CheckIsServiceAdd({ host: res.data.ip, dataBaseName: res.data.dbName })
CheckIsServiceAdd({ ip: res.data.ip })
.then(resdata1 => {
setLoading(false);
if (resdata1.success) {
if (resdata1.code === 0) {
setShow3('inline-block');
setShow4('none');
getStatus(res.data.ip, res.data.dbName);
......@@ -133,6 +131,7 @@ const IotConfig = props => {
}
})
.catch(err => {
message.error('网络异常');
setLoading(false);
});
}
......@@ -141,34 +140,38 @@ const IotConfig = props => {
const getStatus = (x, y) => {
// 查询是否禁用
GetServiceInfo({ host: x, dataBaseName: y })
GetServiceInfo({ ip: x })
.then(resdata => {
setDbStatus(resdata.response.statusText);
setProcessLength(resdata.response.loadingProgress * 100);
if (resdata.response.statusText != '正常' && resdata.response.statusText != '已禁用') {
setBuStatus('启动中');
setSwitchStatus(true);
time = setTimeout(() => {
getStatus(x, y);
}, 1000);
} else {
if (resdata.response.statusText == '正常') {
setBuStatus('停止');
}
if (resdata.response.statusText == '已禁用') {
setBuStatus('启动');
}
if (time) {
clearTimeout(time);
time = null;
if (resdata.code === 0) {
setDbStatus(resdata.data.statusText);
setProcessLength(resdata.data.loadingProgress * 100);
if (resdata.data.statusText != '正常' && resdata.data.statusText != '已禁用') {
setBuStatus('启动中');
setSwitchStatus(true);
time = setTimeout(() => {
getStatus(x, y);
}, 1000);
} else {
if (resdata.data.statusText == '正常') {
setBuStatus('停止');
}
if (resdata.data.statusText == '已禁用') {
setBuStatus('启动');
}
if (time) {
clearTimeout(time);
time = null;
}
setSwitchStatus(false);
}
setSwitchStatus(false);
}
if (resdata.response.statusText == '正常') {
setCurrentConfig(true);
if (resdata.data.statusText == '正常') {
setCurrentConfig(true);
} else {
setCurrentConfig(false);
}
} else {
setCurrentConfig(false);
message.error(resdata.msg);
}
})
.catch(err => {
......@@ -176,7 +179,7 @@ const IotConfig = props => {
clearTimeout(time);
time = null;
}
message.error('访问异常请稍后再试');
// message.error('访问异常请稍后再试');
});
};
......@@ -205,8 +208,7 @@ const IotConfig = props => {
Object.keys(currentIotConfig).forEach(k => {
obj[k] = res.data[k];
});
console.log(obj);
PingIOTPlatform({
GetIotVersion({
ip: obj.IotAddress ? obj.IotAddress : '127.0.0.1',
}).then(resdata => {
if (resdata.code === 0) {
......@@ -214,21 +216,25 @@ const IotConfig = props => {
GetGateWay().then(resda => {
if (resda.code === 0) {
if (resda.data === false) {
setFlag(0);
setGetWayVisible(true);
} else {
HealthCheck()
.then(ress => {
if (ress.success) {
setFlag(1);
getCurrentConfig();
getSiteCode();
} else {
setFlag(0);
}
})
.catch(err => {
console.log(err);
});
setFlag(1);
getCurrentConfig();
getSiteCode();
// HealthCheck()
// .then(ress => {
// if (ress.success) {
// setFlag(1);
// getCurrentConfig();
// getSiteCode();
// } else {
// setFlag(0);
// }
// })
// .catch(err => {
// console.log(err);
// });
}
}
});
......@@ -325,8 +331,6 @@ const IotConfig = props => {
// 添加当前连接数据库
const PingIot2 = () => {
console.log(buStatus);
console.log(show3);
if (show3 === 'inline-block') {
// 数据库已添加
if (buStatus === '停止') {
......@@ -338,15 +342,10 @@ const IotConfig = props => {
// 数据库未添加
setLoading(true);
AddDB({
host: currentDataBase.ip,
user: currentDataBase.userName,
pwd: currentDataBase.password,
dataBaseName: currentDataBase.dbName,
siteCode: currentSiteInfo,
name: keep,
ip: currentDataBase.ip,
}).then(res => {
setLoading(false);
if (res.success) {
if (res.code === 0) {
setShow3('inline-block');
setShow4('none');
message.success('添加成功!');
......@@ -405,12 +404,11 @@ const IotConfig = props => {
setSwitchStatus(true);
setLoading(true);
DepositServiceEnable({
host: currentDataBase.ip,
dataBaseName: currentDataBase.dbName,
ip: currentDataBase.ip,
}).then(res => {
setLoading(false);
getStatus(currentDataBase.ip, currentDataBase.dbName);
if (res.success) {
if (res.code === 0) {
// setCurrentConfig(checked);
message.success(res.msg);
} else {
......@@ -420,11 +418,10 @@ const IotConfig = props => {
} else {
setLoading(true);
DepositServiceDisable({
host: currentDataBase.ip,
dataBaseName: currentDataBase.dbName,
ip: currentDataBase.ip,
}).then(res => {
setLoading(false);
if (res.success) {
if (res.code === 0) {
setDbStatus('已禁用');
setBuStatus('启动');
setProcessLength(0);
......@@ -502,11 +499,11 @@ const IotConfig = props => {
placeholder="请输入服务地址"
/>
</Form.Item>
<Button type="primary" onClick={() => PingIot1()} style={{ marginLeft: '25px' }}>
<Button onClick={() => PingIot1()} style={{ marginLeft: '-88px' }}>
测试连接
</Button>
{upgrade && (
<Tooltip title="添加物联统一接入平台的子网站,并导入网页菜单数据">
<>
<Button
type="primary"
onClick={() => PingIotUpdata()}
......@@ -514,7 +511,12 @@ const IotConfig = props => {
>
平台升级
</Button>
</Tooltip>
<Tooltip title="添加物联统一接入平台的子网站,并导入网页菜单数据">
<QuestionCircleOutlined
style={{ fontSize: '18px', marginLeft: '10px', marginTop: '12px' }}
/>
</Tooltip>
</>
)}
<span style={{ display: show1 }}>
<img
......@@ -633,9 +635,9 @@ const IotConfig = props => {
visible={getWayVisible}
title="提示"
width="350px"
closable={false}
// maskClosable={false}
// onCancel={() => setGetWayVisible(false)}
closable
maskClosable={false}
onCancel={() => setGetWayVisible(false)}
all
footer={
<Space>
......
......@@ -18,7 +18,6 @@
align-items: center;
.template_type {
height: 60px;
display: flex;
flex-direction: row;
justify-content: flex-start;
......
......@@ -24,23 +24,39 @@ export const GetTCPConfigInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetTCPConfigInfo`, param);
export const PingIOTPlatform = param =>
get(`${PUBLISH_SERVICE}/HostManager/PingIOTPlatform`, param);
// 判断是否需要升级物联网统一接入平台
export const IsIotUpgrade = param => get(`${PUBLISH_SERVICE}/HostManager/IsIotUpgrade`, param);
// 升级物联网统一接入平台
export const IotUpgrade = param => get(`${PUBLISH_SERVICE}/HostManager/IotUpgrade`, param);
export const SaveTcpAddress = param => get(`${PUBLISH_SERVICE}/HostManager/SaveTcpAddress`, param);
// 健康检查接口
export const HealthCheck = param => get(`/Iot/api/HealthCheck`, param);
export const GetIotVersion = param => get(`${PUBLISH_SERVICE}/HostManager/GetIotVersion`, param);
// 判断数据库服务是否已添加
export const CheckIsServiceAdd = param => post(`/Iot/api/DB/CheckIsServiceAdd`, param);
export const CheckIsServiceAdd = param =>
get(`${PUBLISH_SERVICE}/HostManager/CheckIsServiceAdd`, param);
// 查询当前数据库服务状态信息
export const GetServiceInfo = param => post(`/Iot/api/DB/GetServiceInfo`, param);
export const GetServiceInfo = param => get(`${PUBLISH_SERVICE}/HostManager/GetServiceInfo`, param);
// 添加数据库
export const AddDB = param => post(`/Iot/api/DB/AddDBV2`, param);
export const AddDB = param => get(`${PUBLISH_SERVICE}/HostManager/AddDBV2`, param);
// 停止数据库服务
export const DepositServiceDisable = param => post(`/Iot/api/DB/DepositServiceDisable`, param);
export const DepositServiceDisable = param =>
get(`${PUBLISH_SERVICE}/HostManager/DepositServiceDisable`, param);
// 启用数据库服务
export const DepositServiceEnable = param => post(`/Iot/api/DB/DepositServiceEnable`, param);
export const DepositServiceEnable = param =>
get(`${PUBLISH_SERVICE}/HostManager/DepositServiceEnable`, param);
// 升级物联网统一接入平台
export const IotUpgrade = param => get(`${PUBLISH_SERVICE}/HostManager/IotUpgrade`, param);
export const SaveTcpAddress = param => get(`${PUBLISH_SERVICE}/HostManager/SaveTcpAddress`, param);
// 健康检查接口
export const HealthCheck = param => get(`/Iot/api/HealthCheck`, param);
// // 判断数据库服务是否已添加
// export const CheckIsServiceAdd = param => post(`/Iot/api/DB/CheckIsServiceAdd`, param);
// // 查询当前数据库服务状态信息
// export const GetServiceInfo = param => post(`/Iot/api/DB/GetServiceInfo`, param);
// // 添加数据库
// export const AddDB = param => post(`/Iot/api/DB/AddDBV2`, param);
// // 停止数据库服务
// export const DepositServiceDisable = param => post(`/Iot/api/DB/DepositServiceDisable`, param);
// // 启用数据库服务
// export const DepositServiceEnable = param => post(`/Iot/api/DB/DepositServiceEnable`, param);
// 消息平台接口
export const GetMessageConfigInfo = param =>
......
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