import { CellsysType, Operator, Query, QueryMG, QueryTask } from './cellsysUtil.js'; class CellsysEquipment { constructor(params = {}) { this.cellsysType = CellsysType.Equipment; this.id = params.id; this.name = params.name; this.macId = params.macid; this.orgId = params.org_id; this.type = params.type; //系统设备类型id this.style = params.style ? params.style : {}; this.description = params.description; this.orgName = params.org_name; this.typeName = params.type_name; this.createdId = params.create_by; this.createdTime = params.create_time; this.updatedId = params.update_by; this.updatedTime = params.update_time; this.bindId = params.user_id; this.realname = params.realname; this.bindTime = params.bind_time; this.rdNumber = params.rd_number; this.geom = params.geom || null; } setId(value) { this.id = value; } setName(value) { this.name = value; } setDescription(value) { this.description = value; } setMacId(value) { this.macId = value; } setTypeId(value) { this.typeId = value; } setTypeName(value) { this.typeName = value; } getIcon() { return this.style ? this.style.icon : null; } getColor() { return this.style ? this.style.color : '#000000'; } //查询设备监控量数据,监控量为对象形式 queryMonitorObjectData(params) { let query = new Query(); let { pageInfo } = params ? params : {}; query.setType('mongodb'); query.addFilter('macid', Operator.Equals, this.macId); query.addFilter('orgId', Operator.Equals, this.orgId); //不加orgid可能会筛选出其他组织的设备数据 if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } let queryType = QueryMG.Equipment_Historical_Object; query.setOrder({ createTime: 'desc' }); let queryTask = new QueryTask(queryType, pageInfo); return queryTask.execute(query); } queryMonitorData(params) { let query = new Query(); let { pageInfo } = params ? params : {}; query.setType('mongodb'); query.addFilter('macid', Operator.Equals, this.macId); query.addFilter('orgId', Operator.Equals, this.orgId); //不加orgid可能会筛选出其他组织的设备数据 query.addFilter('type', Operator.Equals, this.type); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } let queryType = QueryMG.Equipment_Historical; query.setOrder({ createTime: 'desc' }); let queryTask = new QueryTask(queryType, pageInfo); return queryTask.execute(query); } } export default CellsysEquipment;