Commit f616c2e3 by 孙香冬

no message

parent ced98d04
<config> <config>
<port>30001</port> <port>30001</port>
<sockentPort>30002</sockentPort> <sockentPort>30002</sockentPort>
<rightView> <rightView>http://10.51.50.136:8090/sql/execute</rightView>
<ipPort>http://10.51.50.136:8090/sql/execute</ipPort>
</rightView>
<leftView> <leftView>
<cloudResource>http://10.51.50.140:8080/api/static/PrivateCloudUsageStatics</cloudResource> <cloudResource>http://10.51.50.140:8080/api/static/PrivateCloudUsageStatics</cloudResource>
<physicalResource>http://10.51.50.140:8080/api/v1/PrivateCloudCurrentUsages</physicalResource> <physicalResource>http://10.51.50.140:8080/api/v1/PrivateCloudCurrentUsages</physicalResource>
......
const path = require('path'); const path = require('path');
import * as fs from "fs"; import * as fs from "fs";
import { SysError } from "../util/bizError"; import { BizError, SysError } from "../util/bizError";
import { analysisXml } from "../util/myXML"; import { analysisXml } from "../util/myXML";
import { SYSTEMERRORENUM } from "./errorEnum"; import { SYSTEMERRORENUM } from "./errorEnum";
export let port = Number(process.env.PORT) || Number(process.argv[3]); export let port = Number(process.env.PORT) || Number(process.argv[3]);
// export let = "http://10.51.50.140:8080/api/static/PrivateCloudUsageStatics";
// export let = "http://10.51.50.140:8080/api/v1/PrivateCloudCurrentUsages";
// export let = "http://10.51.48.213/nlink/v2/getAllDevicesInfo?prjid=0255e1f7515348cc87c7bb2cc6341fer&online=3&broken=3&token=09a98bc555474e058ef90b6cc6e23638";
export let sockentPort; export let sockentPort;
export let dbConfig; export let dbConfig;
export let appConfig = { export let appConfig = {
cloudResource:'', rightView: 'http://10.51.50.136:8090/sql/execute',
physicalResource:'', cloudResource:'http://10.51.50.140:8080/api/static/PrivateCloudUsageStatics',
mapPort:'' physicalResource:'http://10.51.50.140:8080/api/v1/PrivateCloudCurrentUsages',
mapPort:'http://10.51.48.213/nlink/v2/getAllDevicesInfo?prjid=0255e1f7515348cc87c7bb2cc6341fer&online=3&broken=3&token=09a98bc555474e058ef90b6cc6e23638'
}; };
export let mongoServerConstVal; export let mongoServerConstVal;
export let mySqlConfig; export let mySqlConfig;
...@@ -27,21 +25,21 @@ export async function initConfig() { ...@@ -27,21 +25,21 @@ export async function initConfig() {
let configInfo:any = await analysisXml(configStr); let configInfo:any = await analysisXml(configStr);
if (!configInfo || !configInfo.config) console.log("xml中无配置加载"); if (!configInfo || !configInfo.config) console.log("xml中无配置加载");
else { else {
let {port, sockentPort} = configInfo.config; let {port, sockentPort, rightView, leftView, mapView} = configInfo.config;
if ( !getConf(port)) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 port');
if ( !getConf(sockentPort)) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 sockentPort');
if ( !getConf(rightView)) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 rightView');
if ( !getConf(leftView)) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 leftView');
if ( !getConf(mapView)) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 mapView');
if ( !getConf(port)|| !getConf(sockentPort) ) throw new SysError(SYSTEMERRORENUM.初始化配置失败, 'serverConfig.xml中 缺少 port 或 sockentPort');
//左屏 //左屏
let leftView = config.leftView[0]; appConfig.cloudResource = leftView[0].cloudResource[0];
appConfig.cloudResource = leftView.cloudResource[0]; appConfig.physicalResource = leftView[0].physicalResource[0];
appConfig.physicalResource = leftView.physicalResource[0];
//地图 //地图
let mapView = config.mapView[0]; let online = mapView[0].online[0];
let online = mapView.online[0]; let broken = mapView[0].broken[0];
let broken = mapView.broken[0]; let token = mapView[0].token[0];
let token = mapView.token[0]; appConfig.mapPort = mapView[0].mapPort[0] + "&online=" + online + "&broken=" + broken + "&token=" + token || appConfig.mapPort;
mapPort = mapView.mapPort[0] + "&online=" + online + "&broken=" + broken + "&token=" + token || mapPort;
} }
console.log("config init success"); console.log("config init success");
......
import { ERRORENUM } from "../../config/errorEnum"; import { ERRORENUM } from "../../config/errorEnum";
import { cloudResource, physicalResource } from "../../config/serverConfig"; import { appConfig } from "../../config/serverConfig";
import { BizError } from "../../util/bizError"; import { BizError } from "../../util/bizError";
import { get } from "../../util/request"; import { get } from "../../util/request";
//虚拟机上的数据 //虚拟机上的数据
export async function getHardware() { export async function getHardware() {
let 云资源result:any = await get(cloudResource); let 云资源result:any = await get(appConfig.cloudResource);
let 使用率result:any = await get(physicalResource); let 使用率result:any = await get(appConfig.physicalResource);
if (!云资源result) throw new BizError(ERRORENUM.未找到数据, "云资源"); if (!云资源result) throw new BizError(ERRORENUM.未找到数据, "云资源");
if (!使用率result) throw new BizError(ERRORENUM.未找到数据, "使用率"); if (!使用率result) throw new BizError(ERRORENUM.未找到数据, "使用率");
......
import { ERRORENUM } from "../../config/errorEnum"; import { ERRORENUM } from "../../config/errorEnum";
import { appConfig } from "../../config/serverConfig";
import { BizError } from "../../util/bizError"; import { BizError } from "../../util/bizError";
import { get } from "../../util/request"; import { get } from "../../util/request";
export async function getMap() { export async function getMap() {
let data:any = await get("http://10.51.48.213/nlink/v2/getAllDevicesInfo?prjid=0255e1f7515348cc87c7bb2cc6341fer&online=3&broken=3&token=09a98bc555474e058ef90b6cc6e23638"); let data:any = await get(appConfig.mapPort);
if(!data) throw new BizError(ERRORENUM.未找到数据, "地图数据"); if(!data) throw new BizError(ERRORENUM.未找到数据, "地图数据");
let cameraData = []; let cameraData = [];
......
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