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

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

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