cellsysBase/cellsysSystem.js

232 lines
7.6 KiB
JavaScript
Raw Permalink Normal View History

2024-08-14 16:20:56 +08:00
import { Query, QueryTask, QueryType, Operator, SubmitTask, SubmitType } from './cellsysUtil.js';
import CellsysEventType from './cellsysEventType';
import CellsysApp from './cellsysApp';
import CellsysLayerGroup from './cellsysLayerGroup';
import CellsysEquipmentType from './cellsysEquipmentType';
import CellsysGroup from './cellsysGroup';
import CellsysLineType from './cellsysLineType';
import CellsysPolygonType from './cellsysPolygonType';
import CellsysMarkType from './cellsysMarkType';
import CellsysOrg from './cellsysOrg';
import CellsysMemberType from './cellsysMemberType';
class CellsysSystem {
constructor(params) {}
2024-12-26 16:18:03 +08:00
static token = null; //当前token
static adminToken = null; //管理员token
2024-12-26 11:21:07 +08:00
static hostname = null;
2024-08-14 16:20:56 +08:00
//在边缘工作站上查询设备列表
static querEdgeOrgList() {
let query = new Query();
query.setPageSize(0);
let queryTask = new QueryTask(QueryType.EdgeOrgList);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((orgList) => {
2024-12-26 16:18:03 +08:00
debugger;
2024-08-14 16:20:56 +08:00
resolve(orgList);
})
.catch((err) => {
reject(err);
});
});
}
static queryEdgeMemberTypeList() {
let query = new Query();
query.setPageSize(0);
let queryTask = new QueryTask(QueryType.EdgeMemberTypeList);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((List) => {
resolve(List);
})
.catch((err) => {
reject(err);
});
});
}
static queryEdgeGroupList() {
let query = new Query();
query.setPageSize(0);
let queryTask = new QueryTask(QueryType.EdgeGroupList);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((List) => {
resolve(List);
})
.catch((err) => {
reject(err);
});
});
}
static queryOrgData() {
//新版本初始化
let query = new Query();
let queryTask = new QueryTask('/rpc/cellsysOrgDataInit', false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let {
_event_sets,
_apps,
_maps,
_device_sets,
_groups,
_member_roles,
_line_sets,
_area_sets,
_marker_sets,
_org,
} = res;
let result = {
eventSet: _event_sets.map((item) => {
return new CellsysEventType(item);
}),
apps: _apps.map((item) => {
return new CellsysApp(item);
}),
maps: _maps.map((item) => {
return new CellsysLayerGroup(item);
}),
deviceSet: _device_sets.map((item) => {
return new CellsysEquipmentType(item);
}),
memberRoles: _member_roles.map((item) => {
return new CellsysMemberType(item);
}),
groups: _groups.map((item) => {
return new CellsysGroup(item);
}),
lineSet: _line_sets.map((item) => {
return new CellsysLineType(item);
}),
areaSet: _area_sets.map((item) => {
return new CellsysPolygonType(item);
}),
markerSet: _marker_sets.map((item) => {
return new CellsysMarkType(item);
}),
cellsysOrg: new CellsysOrg(_org),
};
resolve(result);
})
.catch((err) => {
reject(err);
});
});
}
static queryVersion(projectName, filters) {
let query = new Query();
query.setCurrPage(1);
query.setPageSize(1);
if (projectName) {
query.addFilter('name', Operator.Equals, projectName);
}
if (filters && filters.length > 0) {
filters.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
query.setOrder({ version: 'desc' });
let queryTask = new QueryTask(QueryType.ServerVersion, true);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let _data = [];
if (res.data) {
_data = res.data;
}
resolve(_data);
})
.catch((err) => {
reject(err);
});
});
}
//根据字典类型查询系统字典数据
static queryDictDataByType(dictType, pageInfo) {
let query = new Query();
query.addFilter('dict_type', Operator.Equals, dictType);
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
}
let queryTask = new QueryTask(QueryType.sysDictData, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
resolve(res.data);
}
} else {
resolve(res);
}
})
.catch((err) => {
reject(err);
});
});
}
static queryDictDataByValue(dictValue, pageInfo) {
let query = new Query();
query.addFilter('dict_value', Operator.Equals, dictValue);
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
}
let queryTask = new QueryTask(QueryType.sysDictData, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
resolve(res.data);
}
} else {
resolve(res);
}
})
.catch((err) => {
reject(err);
});
});
}
static queryIndustry(pageInfo) {
let query = new Query();
let queryTask = new QueryTask(QueryType.Industry);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
}
}
export default CellsysSystem;