import { Query, QueryTask, QueryType, Operator, CellsysType } from './cellsysUtil.js'; import CellsysEquipment from './cellsysEquipment.js'; import { formatterDate } from './utils/date'; class CellsysMember { constructor(params) { this.cellsysType = CellsysType.Member; if (!params) { params = {}; } this.memberId = params.member_id; this.userId = params.user_id; this.realName = params.realname || ''; this.groupId = params.group_id; //成员加入的群组应该是个数组,所以该字段可能有问题请不要使用,待排查完毕后去除 this.groupIds = params.group_ids; this.groupName = params.group_name; this.mobile = params.mobile; this.email = params.email; this.gender = params.gender; this.memberType = params.member_type; //成员类型id this.typeName = params.type_name || ''; //成员名称 this.orgId = params.org_id; this.orgName = params.org_name; this.isLeader = params.is_leader; this.style = params.style; this.description = params.description; this.macId = params.macid; this.createTime = params.create_time; this.updateTime = params.update_time; this.dateTime = params.datetime; //位置上传时间 this.onlineStatus = { status: 0, //在线状态,默认离线 timeStamp: params.datetime, //最后更新状态时间 outlineColor: '#bfbfbf', //离线状态颜色值 onlineColor: params.style ? params.style.fillColor : '#bfbfbf', //在线状态颜色值 }; /** * 加入组织审核状态 */ // this.status = params.status ? params.status : 1 this.userOrgStatus = params.user_org_status; this.userOrgType = params.user_org_type; this.feedback = params.feedback; this.geometry = params.geometry ? params.geometry : null; this.avatar = params.avatar; // 头像 } get dateTimeStr() { if (this.dateTime) { return formatterDate(this.dateTime, 'YYYY-MM-DD HH:mm'); } } get createTimeFormat() { return formatterDate(this.createTime); } get updateTimeFormat() { return formatterDate(this.updateTime); } setLeader(value) { if (value && value === 1) { this.isLeader = 1; } else { this.isLeader = 0; } } setGeometry(value) { this.geometry = value; } //查询用户绑定的设备详情,带组织联合逻辑,无分页 queryBindDeviceDeatil(params = {}) { let { isUnion } = params; if (this.macId) { let query = new Query(); let queryType = QueryType.Equipment; if (isUnion) { queryType = QueryType.UnionEquipment; } let queryTask = new QueryTask(queryType); query.addFilter('macid', Operator.Equals, this.macId); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let resArr = res.map((item) => { return new CellsysEquipment(item); }); resolve(resArr); }) .catch((err) => { reject(err); }); }); } else { return Promise.reject('该成员没有绑定可以通讯的设备'); } } /** * 获取人员轨迹-5分钟 */ getTrajectory5Minute() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory5Minute; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory5Minute; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-15分钟 */ getTrajectory15Minute() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory15Minute; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory15Minute; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-30分钟 */ getTrajectory30Minute() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory30Minute; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory30Minute; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-1小时 */ getTrajectory1Hour() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory1Hour; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory1Hour; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-2小时 */ getTrajectory2Hour() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory2Hour; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory2Hour; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-4小时 */ getTrajectory4Hour() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.Trajectory4Hour; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectory4Hour; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-今天 */ getTrajectoryToday() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.TrajectoryToday; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectoryToday; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-昨天 */ getTrajectoryYesterday() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.TrajectoryYesterday; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectoryYesterday; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 获取人员轨迹-前天 */ getTrajectoryAnteayer() { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.TrajectoryAnteayer; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectoryAnteayer; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } /** * 时间段查询轨迹 * @param start 开始时间 * @param end 结束时间 * @returns {Promise} */ getTrajectoryByTimePart(start, end) { let query = new Query(); query.addFilter('user_id', Operator.Equals, this.userId); query.addFilter('datetime', Operator.GTE, start); query.addFilter('datetime', Operator.LTE, end); query.setOrder({ datetime: 'asc' }); let queryType = QueryType.TrajectoryDatePath; if (window.CELLSYSORG.unionStatus === 1) { queryType = QueryType.UnionTrajectoryDatePath; } let queryTask = new QueryTask(queryType); return queryTask.execute(query); } } export default CellsysMember;