import './cellsysKeyword.js'; import { Query, QueryTask, QueryType, EditTask, EditType, Operator, CellsysType, QueryMG, SubmitType, } from './cellsysUtil.js'; import * as CellsysPush from './cellsysPush.js'; import CellsysUser from './cellsysUser.js'; import CellsysApp from './cellsysApp.js'; import CellsysAppModelType from './CellsysAppModelType.js'; import CellsysAppModel from './cellsysAppModel.js'; import CellsysGroup from './cellsysGroup.js'; import CellsysMember from './cellsysMember.js'; import CellsysMemberType from './cellsysMemberType.js'; import CellsysMark from './cellsysMark.js'; import CellsysMarkType from './cellsysMarkType.js'; import CellsysPolygon from './cellsysPolygon.js'; import CellsysPolygonType from './cellsysPolygonType.js'; import CellsysLine from './cellsysLine.js'; import CellsysLineType from './cellsysLineType.js'; import CellsysLayer from './cellsysLayer.js'; import CellsysLayerGroup from './cellsysLayerGroup.js'; import CellsysEvent from './cellsysEvent.js'; import CellsysEventType from './cellsysEventType.js'; import CellsysEquipment from './cellsysEquipment.js'; import CellsysEquipmentUser from './cellsysEquipmentUser.js'; import CellsysEquipmentType from './cellsysEquipmentType.js'; import CellsysFenceEvent from './cellsysFenceEvent.js'; import CellsysTask from './cellsysTask.js'; import CellsysTaskGeom from './cellsysTaskGeom.js'; import CellsysTaskType from './cellsysTaskType.js'; import CellsysOfflinePolygon from './cellsysOfflinePolygon.js'; import CellsysOfflinePolygonType from './cellsysOfflinePolygonType'; import CellsysEquipmentMonitor from './cellsysEquipmentMonitor'; import CellsysTag from './cellsysTag'; /** */ class CellsysOrg { constructor(params) { this.cellsysType = CellsysType.Org; if (!params) { params = {}; } this.id = params.id ? params.id : null; this.name = params.name ? params.name : null; this.logo = params.logo ? params.logo : null; this.status = params.status || params.status === 0 ? params.status : null; this.abbreviation = params.abbreviation ? params.abbreviation : null; this.create_by = params.create_by ? params.create_by : null; this.description = params.description ? params.description : null; this.address = params.address ? params.address : null; this.contact = params.contact ? params.contact : null; this.phone = params.phone ? params.phone : null; this.email = params.email ? params.email : null; this.options = params.options ? params.options : {}; this.keyword = params.keyword ? Object.assign(window['CellsysKeyword'], params.keyword) : window['CellsysKeyword']; this.uuid = params.uuid ? params.uuid : null; this.industryId = params.industry_id ? params.industry_id : []; this.actionType = { //???为什么org会有这个属性 1: { id: 1, name: '进入围栏' }, 2: { id: 2, name: '离开围栏' }, }; this.unionStatus = params.union_status; //联合组织状态 1-处于联合状态父级组织 this.unionOrgIds = params.union_org; //联合组织的子组织id集合 window.CELLSYSORG = this || {}; //cellsysSDK不应该依赖于vue才能访问到cellsysOrg对象,因此引入window全局属性来缓存cellsysOrg对象 //组织所有者的信息 this.ownerUserId = params.owner_user_id; this.ownerUserMobile = params.owner_user_mobile; this.ownerUserRealname = params.owner_user_realname; this.isPublish = params.is_publish || 0; this.publishRange = params.publish_range; //发布范围 0-群组 1-组织 this.publishGroup = params.publish_group ? params.publish_group : []; //发布的群组 this.isEditable = params.is_update === 1 ? true : false; //is_update表示是否允许其他人编辑 0-不允许 1-允许 this.isUnlock = params.is_unlock; //是否未锁定,0-已锁定,1-未锁定 this.realname = params.realname; // this.dataName = params.data_name; this.dataType = params.data_type; } get edgeOptions() { let options = { guideStep: 'guideMemberType', //有组织的情况下向导步骤必定是最先从成员类型开始,全部完成为finish }; if (this.options && this.options['edgeOptions']) { let _edgeOptions = this.options['edgeOptions']; options = { guideStep: _edgeOptions['guideStep'], }; } return options; } get cloudOptions() { let options = { account: null, token: null, connectId: null, cloudIp: '', edgeNetworkIp: '', isConnect: false, }; if (this.options && this.options['cloudOptions']) { let cloudOptions = this.options['cloudOptions']; options = { account: cloudOptions['account'], token: cloudOptions['token'], connectId: cloudOptions['connectId'], cloudIp: cloudOptions['cloudIp'], edgeNetworkIp: cloudOptions['egdeNetworkIp'], isConnect: cloudOptions['isConnect'], }; } return options; } get mapOptions() { if (this.options && this.options['mapOptions']) { return this.options['mapOptions']; } else { return {}; } } /** * 更新组织信息 */ updateOrg(params) { let editTask = new EditTask(EditType.Org_Update); editTask.addParam('_name', params.name); editTask.addParam('_unit', params.unit); editTask.addParam('_contact', params.contact); editTask.addParam('_email', params.email); editTask.addParam('_address', params.address); editTask.addParam('_description', params.description); editTask.addParam('_phone', params.phone); editTask.addParam('_logo', params.logo); editTask.addParam('_options', params.options); if (params.industryId != null) { editTask.addParam('_industry_id', params.industryId); } return editTask.execute(); } /** * 更新组织配置信息(主页信息) */ updateOrgOptions(params) { let editTask = new EditTask(EditType.Org_Options_Update); editTask.addParam('_options', params.options); if (params.keyword) { editTask.addParam('_keyword', params.keyword); } if (params.httpConfig) { editTask.setHttpConfig(params.httpConfig); } return editTask.execute(); } /** * 更新组织行业 */ 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); }); }); } /** * 获取用户信息 */ queryUserInfo() { let query = new Query(); let queryTask = new QueryTask(QueryType.User); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res) { res = new CellsysUser(res); resolve(res); } }) .catch((err) => { reject(err); }); }); } /** * 根据id获取用户信息 * @param userId * @returns {Promise} */ queryUserInfoById(userId) { let query = new Query(); query.addFilter('id', QueryType.Equals, userId); let queryTask = new QueryTask(QueryType.User); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res) { res = new CellsysUser(res); resolve(res); } }) .catch((err) => { reject(err); }); }); } /** * 更新用户信息 */ updateUserInfo(params) { let editTask = new EditTask(EditType.User_Update); editTask.addParam('_mobile', params.mobile); editTask.addParam('_username', params.userName); editTask.addParam('_realname', params.realName); editTask.addParam('_email', params.email); editTask.addParam('_gender', params.gender); editTask.addParam('_birthday', params.birthday); editTask.addParam('_avatar', params.avatar); editTask.addParam('_is_username', 0); editTask.addParam('_is_mobile', 0); return editTask.execute(); } /** * 修改密码 * @param oldPassword * @param newPassword * @returns {Promise} */ updatePassword(oldPassword, newPassword) { let editTask = new EditTask(EditType.User_Pwd); editTask.addParam('_old_password', oldPassword); editTask.addParam('_new_password', newPassword); return editTask.execute(); } /** * 解绑微信账号 _identity_type 第三方类型:wechat、qq、weibo * @returns {Promise} */ unbindWechat() { let editTask = new EditTask(EditType.User_Unbind); editTask.addParam('_identity_type', 'wechat'); return editTask.execute(); } /** * 查询用户轨迹 * @param filters * @returns {Promise} */ queryUserTrajectory(filters, order) { let query = new Query(); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ datetime: 'asc' }); } let queryTask = new QueryTask(QueryType.TrajectoryDatePath); return queryTask.execute(query); } /** * 查询组织内的所有App */ queryApps(pageInfo, order, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (order) { query.setOrder(order); } else { query.setOrder({ create_time: 'desc' }); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryTask = new QueryTask(QueryType.App, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { item.orgUnionStatus = this.unionStatus; //将组织联合状态传递给cellsysApp才能在app里做相应的逻辑判断 return new CellsysApp(item); }); resolve(res); } } else { let resArr = res.map((item) => { item.orgUnionStatus = this.unionStatus; //将组织联合状态传递给cellsysApp才能在app里做相应的逻辑判断 return new CellsysApp(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询已发布的app * @param pageInfo * @param order * @returns {Promise} */ queryAppListByPublish(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('is_publish', Operator.Equals, 1); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (order) { query.setOrder(order); } else { query.setOrder({ model_id: 'asc', create_time: 'desc' }); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryTask = new QueryTask(QueryType.App, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { item.orgUnionStatus = this.unionStatus; //将组织联合状态传递给cellsysApp才能在app里做相应的逻辑判断 return new CellsysApp(item); }); resolve(res); } } else { let resArr = res.map((item) => { item.orgUnionStatus = this.unionStatus; //将组织联合状态传递给cellsysApp才能在app里做相应的逻辑判断 return new CellsysApp(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } queryAppById(id) { let query = new Query(); query.addFilter('id', Operator.Equals, id); let queryTask = new QueryTask(QueryType.App); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let appData = res.map((item) => { item.orgUnionStatus = this.unionStatus; //将组织联合状态传递给cellsysApp才能在app里做相应的逻辑判断 return new CellsysApp(item); }); resolve(appData[0]); } else { reject('没有app信息'); } }) .catch((err) => { reject(err); }); }); } createApp(app) { let editTask = new EditTask(EditType.App_Create); editTask.addParam('_name', app.name); editTask.addParam('_description', app.description); editTask.addParam('_status', app.status); editTask.addParam('_uri', app.uri); editTask.addParam('_is_show_app', app.isShowApp); //editTask.addParam('_is_publish', 0); //这个已经没用了下次看到可以删掉了 editTask.addParam('_model_id', app.modelId); editTask.addParam('_options', app.options); if (app.modelOptions) { editTask.addParam('_model_options', app.modelOptions); } return new Promise((resolve, reject) => { editTask .execute() .then((res) => { let cellsysApp = new CellsysApp(res.data); resolve(cellsysApp); }) .catch((err) => { reject(err); }); }); } /** * 更新App信息 */ updateApp(app) { let editTask = new EditTask(EditType.App_Update); editTask.addParam('_id', app.id); editTask.addParam('_name', app.name); editTask.addParam('_description', app.description); editTask.addParam('_uri', app.uri); editTask.addParam('_is_show_app', app.isShowApp); editTask.addParam('_is_publish', app.isPublish); editTask.addParam('_options', app.options); editTask.addParam('_model_options', app.modelOptions); return editTask.execute(); } /** * 删除App */ removeApp(app) { let editTask = new EditTask(EditType.App_Delete); editTask.addParam('_id', app.id); return editTask.execute(); } /** *模板在创建/修改/进入前,需要调用鉴权接口 * @param {*} * @returns */ OrgAppModelSelect(param) { let editTask = new EditTask(EditType.OrgAppModelSelect); editTask.addParam('_app_model_id', param); return editTask.execute(); } /** * 查询组织内的所有可用模板 */ queryAppModels(pageInfo, filters) { let query = new Query(); // query.addFilter('is_publish', Operator.Equals, 1); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } // query.addFilter('id', Operator.NotEquals, 23);//屏蔽掉查验报告模板 if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'asc' }); let queryTask = new QueryTask(QueryType.AppModel, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysAppModel(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysAppModel(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询应用模板类型 * @returns {Promise} */ queryAppModelTypeList() { let query = new Query(); query.setOrder({ id: 'asc' }); let queryTask = new QueryTask(QueryType.AppModelType, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (Array.isArray(res)) { let result = res.map((item) => { return new CellsysAppModelType(item); }); resolve(result); } }) .catch((err) => { reject(err); }); }); } queryAppModelById(id) { let query = new Query(); query.addFilter('id', Operator.Equals, id); let queryTask = new QueryTask(QueryType.AppModel); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let appData = res.map((item) => { return new CellsysAppModel(item); }); resolve(appData[0]); } else { reject('没有模板信息'); } }) .catch((err) => { reject(err); }); }); } /** * @name: ag * @Date: 2022-03-03 11:48:13 * @Description: 查询组织下的所有的群组 * @param {*} pageInfo * @param {*} filters * @param {*} getUnion 是否需要获取联合信息 */ queryGroups(pageInfo, filters, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.Group; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织,并且需要获取联合信息 queryType = QueryType.UinonGroup; } else { query.setOrder({ org_id: 'asc', id: 'desc' }); } if (order) { query.setOrder(order); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysGroup(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysGroup(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * @name: ag * @Date: 2022-03-03 11:50:19 * @Description: 查询已发布的群组 * @param {*} pageInfo * @param {*} getUnion */ queryIsPublishGroups(pageInfo, order, getUnion, httpConfig) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('is_publish', Operator.Equals, 1); if (httpConfig) { query.setHttpConfig(httpConfig); } if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } let queryType = QueryType.Group; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UinonGroup; } else { //联合查询父级的排序条件由后端添加 query.setOrder({ id: 'desc' }); } if (order) { query.setOrder(order); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysGroup(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysGroup(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } queryGroupById(id, getUnion) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.Equals, id); let queryType = QueryType.Group; if (this.unionStatus === 1 && getUnion) { //联合状态为父级组织 queryType = QueryType.UinonGroup; } let queryTask = new QueryTask(queryType); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let groupData = res.map((item) => { return new CellsysGroup(item); }); resolve(groupData[0]); } else { reject('没有群组信息'); } }) .catch((err) => { reject(err); }); }); } /** * 查询组织下的所有成员 */ queryOrgMembers(filters, pageInfo, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ org_id: 'asc', id: 'asc', realname: 'asc' }); } let queryType = QueryType.OrgMember; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionOrgMember; } let queryTask = new QueryTask(queryType, !!pageInfo); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询申请加入组织的成员 */ queryOrgJoinMembers(pageInfo, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'asc' }); let queryTask = new QueryTask(QueryType.OrgJoinMember, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { item.member_type = item.member_type_id; return new CellsysMember(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 审核加入组织 * @param userId * @param audit true:通过,false:不通过 * @param feedback 审核意见 * @returns {function(): Promise} */ auditJoinOrgMember(params) { let { userId, audit, feedback, memberTypeId, groudIds } = params; let editTask = new EditTask(EditType.OrgMember_Update); let status = audit ? 2 : 3; // if(status===2){ // editTask.addParam('_user_id', memberType); // } editTask.addParam('_user_id', userId); editTask.addParam('_status', status); editTask.addParam('_feedback', feedback); if (memberTypeId) { editTask.addParam('_member_type_id', memberTypeId); } if (groudIds) { editTask.addParam('_group_ids', groudIds); } return editTask.execute(); } /** * 移除组织成员 * @param params 用户id集合 * @returns {Promise | Promise} */ removeOrgMember(params) { let editTask = new EditTask(EditType.OrgMember_Remove); editTask.addParam('_user_ids', params); return editTask.execute(); } /** * 退出组织 */ quitOrg(member) { let editTask = new EditTask(EditType.Org_Quit); editTask.addParam('_org_id', this.id); editTask.addParam('_user_id', member.userId); return editTask.execute(); } /** *转让组织 * * @returns Org_MarkOver */ markOver(params) { let editTask = new EditTask(EditType.Org_MarkOver); editTask.addParam('_user_id', params); return editTask.execute(); } /** * 创建群组 */ createGroup(group) { var editTask = new EditTask(EditType.Group_Create); editTask.addParam('_name', group.name); editTask.addParam('_description', group.description); editTask.addParam('_status', group.isPublish); editTask.addParam('_org_id', this.id); editTask.addParam('_style', group.style); editTask.addParam('_is_publish', group.isPublish); return editTask.execute(); } /** * 更新群组信息 */ updateGroup(group) { let editTask = new EditTask(EditType.Group_Update); editTask.addParam('_id', group.id); editTask.addParam('_name', group.name); editTask.addParam('_status', group.status); editTask.addParam('_description', group.description); editTask.addParam('_style', group.style); editTask.addParam('_is_publish', group.isPublish); return editTask.execute(); } /** * 删除群组 */ removeGroup(group) { let editTask = new EditTask(EditType.Group_Delete); editTask.addParam('_id', group.id); return editTask.execute(); } /** * 查询组织下的所有成员类型 */ queryMemberTypes(pageInfo, filters, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ org_id: 'asc', id: 'desc' }); } let queryType = QueryType.MemberType; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMemberType; } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMemberType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMemberType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 创建成员类型 */ createMemberType(memberType) { var editTask = new EditTask(EditType.MemberType_Create); editTask.addParam('_name', memberType.name); editTask.addParam('_description', memberType.description); editTask.addParam('_style', memberType.style); return editTask.execute(); } /** * 更新成员类型 */ updateMemberType(memberType) { let editTask = new EditTask(EditType.MemberType_Update); editTask.addParam('_id', memberType.id); editTask.addParam('_name', memberType.name); editTask.addParam('_style', memberType.style); editTask.addParam('_description', memberType.description); return editTask.execute(); } /** * 删除成员类型 */ removeMemberType(memberType) { let editTask = new EditTask(EditType.MemberType_Delete); editTask.addParam('_id', memberType.id); return editTask.execute(); } /** * 批量修改群组成员 */ updateGroupMembers(groupId, userIds) { var editTask = new EditTask(EditType.GroupMember_Update); editTask.addParam('_group_id', groupId); editTask.addParam('_user_ids', userIds); return editTask.execute(); } /** * 批量修改类型成员 */ updateMembersByType(memberTypeId, userIds) { var editTask = new EditTask(EditType.MembersType_Update); editTask.addParam('_member_type_id', memberTypeId); editTask.addParam('_user_ids', userIds); return editTask.execute(); } /** * 查询群组下所有成员,不包含位置信息 * @param groupId * @param pageInfo * @returns {Promise} */ queryMembersByGroup(groupId, pageInfo, getUnion) { let query = new Query(); query.addFilter('group_id', Operator.Equals, groupId); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } query.setOrder({ member_id: 'asc' }); let queryType = QueryType.Member; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMember; } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据成员id查询成员信息 * @param memberIds * @param pageInfo * @returns {Promise} */ queryMemberListById(memberIds, pageInfo) { let query = new Query(); query.setOrder({ user_id: 'asc' }); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('user_id', Operator.In, memberIds); let queryTask = new QueryTask(QueryType.Member, !!pageInfo); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询成员类型成员 */ queryMemberTypeUser(type, getUnion) { let query = new Query(); query.addFilter('member_type', '=', type); query.setOrder({ realname: 'asc' }); let queryType = QueryType.MemberTypeUser; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMemberTypeUser; } let queryTask = new QueryTask(queryType, true); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } }) .catch((err) => { reject(err); }); }); } /** * 根据用户id查询成员的信,注:用户可以在多个群组里面,因此返回数据是数组 * @param userId * @returns {Promise} */ queryGroupMemberByUserId(userId, getUnion, httpConfig) { let query = new Query(); query.addFilter('user_id', '=', userId); if (httpConfig) { query.setHttpConfig(httpConfig); } let queryType = QueryType.Member; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMember; } let queryTask = new QueryTask(queryType, true); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let data = res && res.data ? res.data.map((item) => { return new CellsysMember(item); }) : []; resolve(data); }) .catch((err) => { reject(err); }); }); } /** * 查询群组成员 */ queryGroupMembers(pageInfo, getUnion, httpConfig) { let query = new Query(pageInfo); let queryType = QueryType.Member; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMember; } if (httpConfig) { query.setHttpConfig(httpConfig); } let queryTask = new QueryTask(queryType, pageInfo); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } else { let data = res.map((item) => { return new CellsysMember(item); }); resolve(data); } }) .catch((err) => { reject(err); }); }); } /** * 根据成员类型、群组ID查询群组成员 */ queryGroupMemberByCondition(member_type_id, group_id, getUnion) { let query = new Query(); if (member_type_id) { query.addFilter('member_type', Operator.Equals, member_type_id); } if (group_id) { query.addFilter('group_id', Operator.Equals, group_id); } query.setOrder({ realname: 'asc' }); let queryType = QueryType.Member; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionMember; } let queryTask = new QueryTask(queryType, true); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } }) .catch((err) => { reject(err); }); }); } /*queryMembersLocalByGroup(groupId, pageInfo) { let query = new Query(); query.addFilter('group_id', Operator.Equals, groupId); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } query.setOrder({ datetime: 'desc' }); let queryTask = new QueryTask(QueryType.UserLocal, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMember(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); }*/ /** * 批量查询群组成员信息 * @param groupIds * @returns {Promise} */ queryMembersLocalByGroups(groupIds, getUnion) { let query = new Query(); query.addFilter('group_id', Operator.In, groupIds); let queryType = QueryType.UserLocal; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionUserLocal; } else { query.setOrder({ datetime: 'desc' }); } let queryTask = new QueryTask(queryType, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let resArr = res.map((item) => { return new CellsysMember(item); }); resolve(resArr); }) .catch((err) => { reject(err); }); }); } /** * 查询组织下所有区域信息 */ queryPolygons(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } // query.setOrder({ create_time: 'desc' }); if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.Polygon, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysPolygon(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysPolygon(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 创建区域 */ createPolygon(polygon) { let editTask = new EditTask(EditType.Polygon_Create); editTask.addParam('_name', polygon.name); editTask.addParam('_type', polygon.type); editTask.addParam('_status', 1); editTask.addParam('_geom', polygon.geometry); editTask.addParam('_action', polygon.action); editTask.addParam('_buffer_distance', polygon.bufferDistance); editTask.addParam('_description', polygon.description); if (polygon.links) { if (polygon.links['href'].indexOf('http') === -1) { polygon.links['href'] = 'http://' + polygon.links['href']; } editTask.addParam('_links', [polygon.links]); //可以传数组,目前只考虑单个的情况 } return editTask.execute(); } /** * 批量创建区域 */ createPolygons(polygons) { let editTask = new EditTask(EditType.Polygon_Creates), paramList = []; if (polygons.length > 0) { polygons.forEach((polygon) => { paramList.push({ _name: polygon.name, _geom: polygon.geometry, _buffer_distance: polygon.bufferDistance, _type: polygon.type, _status: 1, _action: polygon.action, _description: polygon.description, }); }); editTask.addParam('_fences', paramList); } return editTask.execute(); } /** * 更新区域信息 */ updatePolygonProperty(polygon) { let editTask = new EditTask(EditType.Polygon_Update_Property); editTask.addParam('_id', polygon.id); editTask.addParam('_name', polygon.name); editTask.addParam('_type', polygon.type); editTask.addParam('_status', 1); editTask.addParam('_action', polygon.action); editTask.addParam('_buffer_distance', polygon.bufferDistance); editTask.addParam('_description', polygon.description); if (polygon.links) { if (polygon.links['href'].indexOf('http') === -1) { polygon.links['href'] = 'http://' + polygon.links['href']; } editTask.addParam('_links', [polygon.links]); //可以传数组,目前只考虑单个的情况 } else { //没有链接时要置空 editTask.addParam('_links', null); } return editTask.execute(); } /** * 更新区域坐标和形状 */ updatePolygonGeometry(polygon) { let editTask = new EditTask(EditType.Polygon_Update_Geometry); editTask.addParam('_id', polygon.id); editTask.addParam('_geom', polygon.geometry); return editTask.execute(); } /** * 删除区域 */ removePolygon(polygons) { let editTask = new EditTask(EditType.Polygon_Delete); let _ids = []; if (polygons instanceof Array === true) { polygons.forEach((polygon) => { _ids.push(polygon.id); }); } else { _ids.push(polygons.id); } editTask.addParam('_ids', _ids); return editTask.execute(); } /** * 查询组织下所有区域类型 */ queryPolygonTypes(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.PolygonType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysPolygonType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysPolygonType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } queryActionType() { return { 1: { id: 1, name: '进入围栏' }, 2: { id: 2, name: '离开围栏' }, }; } /** * 创建区域类型 */ createPolygonType(polygonType) { let editTask = new EditTask(EditType.PolygonType_Create); editTask.addParam('_name', polygonType.name); editTask.addParam('_description', polygonType.description); editTask.addParam('_style', polygonType.style); return editTask.execute(); } /** * 更新区域类型 */ updatePolygonType(polygonType) { let editTask = new EditTask(EditType.PolygonType_Update); editTask.addParam('_id', polygonType.id); editTask.addParam('_name', polygonType.name); editTask.addParam('_description', polygonType.description); editTask.addParam('_style', polygonType.style); editTask.addParam('_is_publish', polygonType.isPublish); return editTask.execute(); } /** * 删除区域类型 */ removePolygonType(polygonType) { let editTask = new EditTask(EditType.PolygonType_Delete); editTask.addParam('_id', polygonType.id); return editTask.execute(); } /** * 清空指定区域类型数据 */ removePolygonsType(polygonType) { let editTask = new EditTask(EditType.PolygonsType_Delete); editTask.addParam('_id', polygonType.id); return editTask.execute(); } /** * 查询组织下所有标记信息 */ queryMarkers(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.Marker, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMark(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMark(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } queryMarkerById(id) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.Equals, id); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.Marker); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let resArr = []; if (res && res.length > 0) { resArr = res.map((item) => { return new CellsysMark(item); }); } resolve(resArr); }) .catch((err) => { reject(err); }); }); } /** * 创建标记 */ createMarker(marker) { let editTask = new EditTask(EditType.Marker_Create); editTask.addParam('_name', marker.name); editTask.addParam('_geom', marker.geometry); editTask.addParam('_buffer_distance', marker.bufferDistance); editTask.addParam('_radius', marker.radius); editTask.addParam('_type', marker.type); editTask.addParam('_status', 1); editTask.addParam('_action', marker.action); editTask.addParam('_description', marker.description); if (marker.links) { if (marker.links['href'].indexOf('http') === -1) { marker.links['href'] = 'http://' + marker.links['href']; } editTask.addParam('_links', [marker.links]); //可以传数组,目前只考虑单个的情况 } return editTask.execute(); } /** * 批量创建标记 */ createMarkers(markers) { let editTask = new EditTask(EditType.Markers_Create), paramList = []; if (markers.length > 0) { markers.forEach((marker) => { paramList.push({ _name: marker.name, _geom: marker.geometry, _buffer_distance: marker.bufferDistance, _radius: marker.radius, _type: marker.type, _status: 1, _action: marker.action, _description: marker.description, }); }); editTask.addParam('_fence_points', paramList); } return editTask.execute(); } /** * 更新标记属性 */ updateMarkerProperty(marker) { let editTask = new EditTask(EditType.Marker_Update_Property); editTask.addParam('_id', marker.id); editTask.addParam('_name', marker.name); editTask.addParam('_type', marker.type); editTask.addParam('_status', 1); editTask.addParam('_description', marker.description); editTask.addParam('_radius', marker.radius); editTask.addParam('_action', marker.action); editTask.addParam('_buffer_distance', marker.bufferDistance); if (marker.links) { if (marker.links['href'].indexOf('http') === -1) { marker.links['href'] = 'http://' + marker.links['href']; } editTask.addParam('_links', [marker.links]); //可以传数组,目前只考虑单个的情况 } else { //没有链接时要置空 editTask.addParam('_links', null); } return editTask.execute(); } /** * 更新标记图形和位置信息 */ updateMarkerGeometry(marker) { let editTask = new EditTask(EditType.Marker_Update_Geometry); editTask.addParam('_id', marker.id); editTask.addParam('_geom', marker.geometry); return editTask.execute(); } /** * 删除标记 */ removeMarker(markers) { let editTask = new EditTask(EditType.Marker_Delete); let _ids = []; if (markers instanceof Array === true) { markers.forEach((marker) => { _ids.push(marker.id); }); } else { _ids.push(markers.id); } editTask.addParam('_ids', _ids); return editTask.execute(); } /** * 查询组织下的所有标记类型 */ queryMarkerType(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.MarkerType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysMarkType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysMarkType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 标记类型 */ createMarkerType(markerType) { let editTask = new EditTask(EditType.MarkerType_Create); editTask.addParam('_name', markerType.name); editTask.addParam('_description', markerType.description); editTask.addParam('_style', markerType.style); return editTask.execute(); } updateMarkerType(markerType) { let editTask = new EditTask(EditType.MarkerType_Update); editTask.addParam('_id', markerType.id); editTask.addParam('_name', markerType.name); editTask.addParam('_style', markerType.style); editTask.addParam('_description', markerType.description); editTask.addParam('_action', markerType.action); editTask.addParam('_is_publish', markerType.isPublish); return editTask.execute(); } removeMarkerType(markerType) { let editTask = new EditTask(EditType.MarkerType_Delete); editTask.addParam('_id', markerType.id); return editTask.execute(); } /** * 清空指定标记类型数据 * @param markerType * @returns {Promise} */ removeMarkersType(markerType) { let editTask = new EditTask(EditType.MarkersType_Delete); editTask.addParam('_id', markerType.id); return editTask.execute(); } /** * 路线 */ queryLines(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.Line, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysLine(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysLine(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } createLine(line) { let editTask = new EditTask(EditType.Line_Create); editTask.addParam('_name', line.name); editTask.addParam('_type', line.type); editTask.addParam('_status', 1); editTask.addParam('_geom', line.geometry); editTask.addParam('_action', line.action); editTask.addParam('_buffer_distance', line.bufferDistance); editTask.addParam('_radius', line.radius); editTask.addParam('_description', line.description); if (line.links) { if (line.links['href'].indexOf('http') === -1) { line.links['href'] = 'http://' + line.links['href']; } editTask.addParam('_links', [line.links]); //可以传数组,目前只考虑单个的情况 } return editTask.execute(); } //批量导入 createLines(lines) { let editTask = new EditTask(EditType.Line_Creates), paramList = []; if (lines.length > 0) { lines.forEach((line) => { paramList.push({ _name: line.name, _geom: line.geometry, _buffer_distance: line.bufferDistance, _type: line.type, _status: 1, _action: line.action, _description: line.description, }); }); editTask.addParam('_fence_lines', paramList); } return editTask.execute(); } updateLineProperty(line) { let editTask = new EditTask(EditType.Line_Update_Property); editTask.addParam('_id', line.id); editTask.addParam('_name', line.name); editTask.addParam('_type', line.type); editTask.addParam('_status', 1); editTask.addParam('_action', line.action); editTask.addParam('_buffer_distance', line.bufferDistance); editTask.addParam('_radius', line.radius); editTask.addParam('_description', line.description); if (line.links) { if (line.links['href'].indexOf('http') === -1) { line.links['href'] = 'http://' + line.links['href']; } editTask.addParam('_links', [line.links]); //可以传数组,目前只考虑单个的情况 } else { //没有链接时要置空 editTask.addParam('_links', null); } return editTask.execute(); } updateLineGeometry(line) { let editTask = new EditTask(EditType.Line_Update_Geometry); editTask.addParam('_id', line.id); editTask.addParam('_geom', line.geometry); return editTask.execute(); } removeLine(lines) { let editTask = new EditTask(EditType.Line_Delete); let _ids = []; if (lines instanceof Array === true) { lines.forEach((line) => { _ids.push(line.id); }); } else { _ids.push(lines.id); } editTask.addParam('_ids', _ids); return editTask.execute(); } /** * 路线类型 */ queryLineTypes(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.LineType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysLineType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysLineType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 新增路线类型 * @param lineType */ createLineType(lineType) { let editTask = new EditTask(EditType.LineType_Create); editTask.addParam('_name', lineType.name); editTask.addParam('_description', lineType.description); editTask.addParam('_style', lineType.style); return editTask.execute(); } /** * 修改路线类型 * @param lineType */ updateLineType(lineType) { let editTask = new EditTask(EditType.LineType_Update); editTask.addParam('_id', lineType.id); editTask.addParam('_name', lineType.name); editTask.addParam('_style', lineType.style); editTask.addParam('_description', lineType.description); editTask.addParam('_is_publish', lineType.isPublish); return editTask.execute(); } removeLineType(lineType) { let editTask = new EditTask(EditType.LineType_Delete); editTask.addParam('_id', lineType.id); return editTask.execute(); } /** * 清空指定路线类型数据 * @param lineType * @returns {Promise} */ removeLinesType(lineType) { let editTask = new EditTask(EditType.LinesType_Delete); editTask.addParam('_id', lineType.id); return editTask.execute(); } /** * 查询组织下的所有专题信息 */ queryLayerGroups(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.LayerGroup, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysLayerGroup(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysLayerGroup(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询已发布的 * @param pageInfo * @returns {Promise} */ queryIsPublishLayerGroups(pageInfo, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('is_publish', Operator.Equals, 1); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.LayerGroup, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysLayerGroup(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysLayerGroup(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据id查询专题信息 * @param id * @returns {Promise} */ queryLayerGroupById(id) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.Equals, id); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.LayerGroup); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let appData = res.map((item) => { return new CellsysLayerGroup(item); }); resolve(appData[0]); } else { reject('没有专题信息'); } }) .catch((err) => { reject(err); }); }); } createLayerGroup(layerGroup) { let editTask = new EditTask(EditType.LayerGroup_Create); editTask.addParam('_name', layerGroup.name); editTask.addParam('_description', layerGroup.description); editTask.addParam('_options', layerGroup.options); //editTask.addParam('_is_publish', layerGroup.isPublish); return editTask.execute(); } updateLayerGroup(layerGroup) { let editTask = new EditTask(EditType.LayerGroup_Update); editTask.addParam('_id', layerGroup.id); editTask.addParam('_name', layerGroup.name); editTask.addParam('_description', layerGroup.description); editTask.addParam('_options', layerGroup.options); editTask.addParam('_is_publish', layerGroup.isPublish); return editTask.execute(); } removeLayerGroup(layerGroup) { let editTask = new EditTask(EditType.LayerGroup_Delete); editTask.addParam('_id', layerGroup.id); return editTask.execute(); } /** * 查询组织下所有图层信息 */ queryLayers(pageInfo, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); // query.addFilter('data_param', Operator.Equals, { type: 73 }); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.LayerBasic, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysLayer(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysLayer(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据专题id查询专题下的图层 * @param layerId * @returns {Promise} */ queryLayersByGroupId(layerId) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('layer_group_id', Operator.Equals, layerId); query.setOrder({ legend_order: 'asc' }); let queryTask = new QueryTask(QueryType.Layer); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { const data = res.map((o) => { return new CellsysLayer(o); }); resolve(data); }) .catch((err) => { reject(err); }); }); } /** * 批量查询专题图层 * @param layerIds * @returns {Promise} */ queryLayersByGroupIds(layerIds) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('layer_group_id', Operator.In, layerIds); query.setOrder({ legend_order: 'asc' }); let queryTask = new QueryTask(QueryType.Layer); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { const data = res.map((o) => { return new CellsysLayer(o); }); resolve(data); }) .catch((err) => { reject(err); }); }); } queryLayersByName(name) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('name', Operator.Like, name); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.LayerBasic); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let appData = res.map((item) => { return new CellsysLayer(item); }); resolve(appData); } else { resolve(); } }) .catch((err) => { reject(err); }); }); } createLayer(layer) { let editTask = new EditTask(EditType.Layer_Create); editTask.addParam('_name', layer.layerName); editTask.addParam('_description', layer.description); editTask.addParam('_geometry_type', layer.geometryType); editTask.addParam('_data_url', layer.dataUrl); editTask.addParam('_style', layer.style); editTask.addParam('_type', layer.type); editTask.addParam('_data_api', layer.dataApi); editTask.addParam('_data_param', layer.dataParam); return editTask.execute(); } /** * 批量新增图层 20200708 yw * @param layers * @returns {Promise} */ createLayers(layers) { const editTask = new EditTask(EditType.Layer_BatchCreate); const _layers = layers.map((o) => { return { _name: o.layerName, _description: o.description, _geometry_type: o.geometryType, _data_url: o.dataUrl, _style: o.style, _type: o.type, _data_api: o.dataApi, _data_param: o.dataParam, }; }); editTask.addParam('_layers', _layers); return editTask.execute(); } updateLayer(layer) { let editTask = new EditTask(EditType.Layer_Update); editTask.addParam('_id', layer.id); editTask.addParam('_name', layer.layerName); editTask.addParam('_description', layer.description); editTask.addParam('_geometry_type', layer.geometryType); editTask.addParam('_data_url', layer.dataUrl); editTask.addParam('_style', layer.style); editTask.addParam('_type', layer.type); editTask.addParam('_data_api', layer.dataApi); editTask.addParam('_data_param', layer.dataParam); return editTask.execute(); } removeLayer(layer) { let editTask = new EditTask(EditType.Layer_Delete); editTask.addParam('_id', layer.id); return editTask.execute(); } getLayerTypes() { return [ { geometryType: 0, name: '标记' }, { geometryType: 1, name: '路线' }, { geometryType: 2, name: '区域' }, ]; } /** * 查询组织下的所有事件信息 */ queryEvents(pageInfo, filters, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { if (item['type']) { query.addFilter(item['name'], item['operator'], item['value'], item['type']); } else { query.addFilter(item['name'], item['operator'], item['value']); } }); } let queryType = QueryType.Event; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEvent; } if (order) { query.setOrder(order); } else { //事件因为带有时间属性,所以默认应该是时间升序 query.setOrder({ datetime: 'asc' }); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEvent(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEvent(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 批量查询事件 * @param ids * @returns {Promise} */ queryEventByIds(ids, getUnion) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); query.setOrder({ datetime: 'asc', org_id: 'asc' }); query.addFilter('type', Operator.In, ids); let queryType = QueryType.Event; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEvent; } let queryTask = new QueryTask(queryType, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { resolve( res.map((item) => { return new CellsysEvent(item); }), ); }) .catch((err) => { reject(err); }); }); } createEvent(event) { let editTask = new EditTask(EditType.Event_Create); editTask.addParam('_name', event.name); editTask.addParam('_description', event.description); editTask.addParam('_type', event.type); editTask.addParam('_datetime', event.dateTime); if (event.links) { if (event.links['href'].indexOf('http') === -1) { event.links['href'] = 'http://' + event.links['href']; } editTask.addParam('_links', [event.links]); //可以传数组,目前只考虑单个的情况 } //editTask.addParam('_pictures', event.pictures); //新增时不传图片,只生成事件记录 editTask.addParam('_geom', event.geometry); return editTask.execute(); } updateEvent(event) { let editTask = new EditTask(EditType.Event_Update); editTask.addParam('_id', event.id); editTask.addParam('_name', event.name); editTask.addParam('_description', event.description); editTask.addParam('_type', event.type); if (event.links) { if (event.links['href'].indexOf('http') === -1) { event.links['href'] = 'http://' + event.links['href']; } editTask.addParam('_links', [event.links]); //可以传数组,目前只考虑单个的情况 } else { //没有链接时要置空 editTask.addParam('_links', null); } editTask.addParam('_datetime', event.dateTime); //editTask.addParam('_pictures', event.pictures); 文件流上传不再传此参数 let eventImages = event.eventImages; let _img_path = [], _litimg_path = [], _file_path = []; for (let item of eventImages) { let fileNameSplit = item['imgPath'].split('/'); if (fileNameSplit.length > 0) { let fileName = fileNameSplit.at(-1); //取数组最后一位 _file_path.push(fileName); } _img_path.push(item['imgPath']); _litimg_path.push(item['litimgPath']); } editTask.addParam('_file_path', _file_path); editTask.addParam('_img_paths', _img_path); editTask.addParam('_litimg_paths', _litimg_path); editTask.addParam('_geom', event.geometry); return editTask.execute(); } removeEvent(event) { let editTask = new EditTask(EditType.Event_Delete); editTask.addParam('_id', event.id); return editTask.execute(); } /** * */ EventTypeLock(params) { let editTask = new EditTask(EditType.eventTypeLock); editTask.addParam('_id', params.id); editTask.addParam('_is_unlock', params.isUnlock); return editTask.execute(); } /** * 查询组织下的所有事件类型 */ queryEventTypes(pageInfo, filters, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.EventType; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEventType; } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } // else { // query.setOrder({ is_publish: 'desc', id: 'desc', }); // } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEventType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEventType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询已发布的事件类型 * @param pageInfo * @returns {Promise} */ queryIsPublishEvenTypes(pageInfo, order, getUnion) { let query = new Query(); query.addFilter('is_publish', Operator.Equals, 1); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } let queryType = QueryType.EventType; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEventType; } else { //联合的组织排序必须由后端排 query.setOrder({ id: 'desc' }); } if (order) { query.setOrder(order); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEventType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEventType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } createEventType(eventType) { let editTask = new EditTask(EditType.EventType_Create); editTask.addParam('_name', eventType.name); editTask.addParam('_description', eventType.description); editTask.addParam('_style', eventType.style); return editTask.execute(); } updateEventType(eventType) { let editTask = new EditTask(EditType.EventType_Update); editTask.addParam('_id', eventType.id); editTask.addParam('_name', eventType.name); editTask.addParam('_style', eventType.style); editTask.addParam('_description', eventType.description); editTask.addParam('_is_publish', eventType.isPublish); return editTask.execute(); } removeEventType(eventType) { let editTask = new EditTask(EditType.EventType_Delete); editTask.addParam('_id', eventType.id); return editTask.execute(); } /** * 查询组织下的所有设备类型 */ queryEquipmentType(pageInfo, filters, getUnion, order) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.OrgEquipmentType; if (this.unionStatus === 1 && getUnion === true) { queryType = QueryType.UnionOrgEquipmentType; } if (order) { query.setOrder(order); } else { query.setOrder({ is_publish: 'desc' }); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEquipmentType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEquipmentType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询已发布的设备类型 * @param pageInfo * @param filters * @returns {Promise} */ queryIsPublishEquipmentTypeList(pageInfo, filters, order, getUnion) { let query = new Query(); //query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } query.addFilter('is_publish', Operator.Equals, 1); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.OrgEquipmentType; if (this.unionStatus === 1 && getUnion === true) { queryType = QueryType.UnionOrgEquipmentType; } else { query.setOrder({ id: 'desc' }); } if (order) { query.setOrder(order); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEquipmentType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEquipmentType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } // 添加组织的设备类型 createEquipmentType(equipmentType) { let editTask = new EditTask(EditType.EquipmentType_Create); editTask.addParam('_type', equipmentType.type); editTask.addParam('_name', equipmentType.name); editTask.addParam('_description', equipmentType.description); editTask.addParam('_style', equipmentType.style); //editTask.addParam('_is_publish', equipmentType.isPublish); return editTask.execute(); } // 修改组织的设备类型 updateEquipmentType(equipmentType) { let editTask = new EditTask(EditType.EquipmentType_Update); editTask.addParam('_id', equipmentType.id); editTask.addParam('_type', equipmentType.type); editTask.addParam('_name', equipmentType.name); editTask.addParam('_description', equipmentType.description); editTask.addParam('_style', equipmentType.style); editTask.addParam('_is_publish', equipmentType.isPublish); return editTask.execute(); } // 删除组织的设备类型 removeEquipmentType(equipmentType) { let editTask = new EditTask(EditType.EquipmentType_Delete); editTask.addParam('_type', equipmentType.type); editTask.addParam('_id', equipmentType.id); //组织设备类型id editTask.addParam('_confirm', equipmentType.confirm); //是否一键解绑并删除设备类型下的所有设备 return editTask.execute(); } /** * 查询监控量 * @param filters * @returns {Promise} */ queryEquipmentTypeMonitorList(filters) { let query = new Query(); // query.addFilter('org_id', Operator.E // quals, this.id) if (filters) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ create_time: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentTypeMonitors, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let resArr = res.map((item) => { return new CellsysEquipmentMonitor(item); }); resolve(resArr); }) .catch((err) => { reject(err); }); }); } /** * 查询组织下的所有设备 */ queryEquipment(pageInfo, filters, getUnion, order) { let query = new Query(); //query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.Equipment; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEquipment; } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEquipment(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEquipment(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据设备Id查询设备 */ queryEquipmentById(id) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.Equals, id); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.Equipment); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let equData = res.map((item) => { return new CellsysEquipment(item); }); resolve(equData[0]); } else { reject('没有设备信息'); } }) .catch((err) => { reject(err); }); }); } /** * 根据macid查询设备详情 * @param macid * @returns {Promise} */ queryEquipmentByMacId(macid, getUnion) { let query = new Query(); //query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('macid', Operator.Equals, macid); let queryType = QueryType.Equipment; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEquipment; } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(queryType); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let equData = res.map((item) => { return new CellsysEquipment(item); }); resolve(equData[0]); } else { reject('没有设备信息'); } }) .catch((err) => { reject(err); }); }); } /** * 根据多个设备id查询设备信息 * @param typeIds * @returns {Promise} */ queryEquipmentByTypeIds(typeIds, getUnion) { let query = new Query(); //query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('type_id', Operator.In, typeIds); let queryType = QueryType.Equipment; if (this.unionStatus === 1 && getUnion === true) { //联合状态为父级组织 queryType = QueryType.UnionEquipment; } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(queryType); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { resolve( res.map((item) => { return new CellsysEquipment(item); }), ); }) .catch((err) => { reject(err); }); }); } /** * 根据用户查询设备信息 * @param pageInfo * @param filters * @returns {Promise} */ queryUserEquipment(filters, pageInfo, getUnion) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryType.EquipmentUser; if (this.unionStatus === 1 && getUnion === true) { queryType = QueryType.UnionEquipmentUser; } else { query.setOrder({ create_time: 'desc' }); } let queryTask = new QueryTask(queryType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEquipment(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEquipment(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据类型查询当前登录用户绑定的设备 * @param typeId * @param filters * @returns {Promise} */ queryUserEquipmentByType(typeId, filters) { let query = new Query(); // query.addFilter('org_id', Operator.Equals, this.id) query.addFilter('type', Operator.Equals, typeId); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentUser); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { resolve( res.map((item) => { return new CellsysEquipment(item); }), ); }) .catch((err) => { reject(err); }); }); } /** * 根据多个设备id查询设备信息 * @param typeIds * @param filters * @returns {Promise} */ queryUserEquipmentListByTypes(typeIds, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('type_id', Operator.In, typeIds); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentUser); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { resolve(res); } else { reject(new Error('没有设备信息')); } }) .catch((err) => { reject(err); }); }); } /** * 根据id查询设备信息 * @param id * @returns {Promise} */ queryUserEquipmentById(id) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.Equals, id); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentUser); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let equData = res.map((item) => { return new CellsysEquipment(item); }); resolve(equData[0]); } else { reject('没有设备信息'); } }) .catch((err) => { reject(err); }); }); } /** * 根据id批量查询设备 * @param ids * @returns {Promise} */ queryUserEquipmentByIds(ids) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('id', Operator.In, ids); query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentUser); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (res.length > 0) { let equData = res.map((item) => { return new CellsysEquipment(item); }); resolve(equData); } else { reject('没有设备信息'); } }) .catch((err) => { reject(err); }); }); } createEquipment(equipment) { let editTask = new EditTask(EditType.Equipment_Create); editTask.addParam('_name', equipment.name); editTask.addParam('_type', equipment.type); editTask.addParam('_macid', equipment.macId); editTask.addParam('_description', equipment.description); editTask.addParam('_rd_number', equipment.rdNumber); editTask.addParam('_status', 1); return editTask.execute(); } updateEquipment(equipment) { let editTask = new EditTask(EditType.Equipment_Update); editTask.addParam('_id', equipment.id); editTask.addParam('_name', equipment.name); editTask.addParam('_description', equipment.description); editTask.addParam('_rd_number', equipment.rdNumber); editTask.addParam('_status', 1); return editTask.execute(); } // 删除设备 removeEquipment(equipment) { let editTask = new EditTask(EditType.Equipment_Delete); editTask.addParam('_id', equipment.id); // editTask.addParam('_confirm', equipment.confirm) return editTask.execute(); } /** * 查询组织用户已绑设备列表 */ queryEquipmentUser(pageInfo, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.EquipmentUser, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEquipmentUser(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEquipmentUser(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } // 绑定设备 bindEquipment(macId, userId) { let editTask = new EditTask(EditType.EquipmentUser_Create); editTask.addParam('_macid', macId); editTask.addParam('_user_id', userId); return editTask.execute(); } // 解绑设备 unbindEquipment(macId, userId) { let editTask = new EditTask(EditType.EquipmentUser_Delete); editTask.addParam('_macid', macId); editTask.addParam('_user_id', userId); return editTask.execute(); } /** * 批量查询事件类型的事件 * @param types * @param pageInfo * @returns {Promise} */ queryEventByTypes(types, pageInfo, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (types && types.length > 0) { query.addFilter('type', Operator.In, types); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.Event, !!pageInfo); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysEvent(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysEvent(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询所有围栏事件信息 */ queryFenceEvents(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ datetime: 'desc' }); } let queryTask = new QueryTask(QueryType.FenceEvent, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysFenceEvent(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysFenceEvent(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 根据围栏id查询当前app下的围栏事件 */ queryFenceEventsById(pageInfo, fenceIds) { let query = new Query(); // query.addFilter("org_id", Operator.Equals, this.orgId); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (fenceIds && fenceIds.length > 0) { query.addFilter('fence_id', Operator.In, fenceIds); } query.setOrder({ datetime: 'desc' }); let queryTask = new QueryTask(QueryType.FenceEvent, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysFenceEvent(item); }); resolve(res); } } else { // let resArr = res.map(item => { // return new CellsysFenceEvent(item); // }) // resolve(resArr); reject('没有围栏事件信息'); } }) .catch((err) => { reject(err); }); }); } /*** * 新增任务 */ createTask(task) { let editTask = new EditTask(EditType.Task_Create); editTask.addParam('_name', task.name); editTask.addParam('_task_type_id', 1); //任务操作类型 editTask.addParam('_description', task.description); editTask.addParam('_is_public', 1); //是否公开 // editTask.addParam('_status', task.status) editTask.addParam('_start_time', task.startTime); editTask.addParam('_end_time', task.endTime); // editTask.addParam('_finish_time', null) editTask.addParam('_user_ids', task.userIds); editTask.addParam('_task_group_ids', task.groupIds); editTask.addParam('_task_geometry_ids', task.geometryIds); editTask.addParam('_task_type_custom_id', task.taskTypeCustomId); return editTask.execute(); } /** * 更新任务 */ updateTask(task) { let editTask = new EditTask(EditType.Task_Update); editTask.addParam('_id', task.id); editTask.addParam('_name', task.name); editTask.addParam('_task_type_id', 1); editTask.addParam('_is_public', 1); editTask.addParam('_description', task.description); // editTask.addParam('_status', task.status) editTask.addParam('_start_time', task.startTime); editTask.addParam('_end_time', task.endTime); // editTask.addParam('_finish_time', null) editTask.addParam('_user_ids', task.userIds); editTask.addParam('_task_group_ids', task.groupIds); editTask.addParam('_task_geometry_ids', task.geometryIds); editTask.addParam('_task_type_custom_id', task.taskTypeCustomId); return editTask.execute(); } /** * 删除任务 */ deleteTask(task) { let editTask = new EditTask(EditType.Task_Delete); editTask.addParam('_id', task.id); return editTask.execute(); } /** * 查询任务列表 */ queryTaskList(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ start_time: 'desc' }); } let queryTask = new QueryTask(QueryType.Task, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysTask(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysTask(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询任务图形列表 */ queryTaskGromList(pageInfo, filters) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ id: 'desc' }); let queryTask = new QueryTask(QueryType.TaskGeom, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysTaskGeom(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysTaskGeom(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 查询任务关联的图形 20200628 yw * @param id * @returns {Promise} */ queryTaskGeomRelById(id) { const query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); query.addFilter('task_id', Operator.Equals, id); query.setOrder({ task_id: 'desc' }); const queryTask = new QueryTask(QueryType.TaskGeomRel, false); return queryTask.execute(query); } /*** * 新增任务图形列表 */ createTaskGeom(taskGeom) { let editTask = new EditTask(EditType.TaskGeom_Create); editTask.addParam('_name', taskGeom.name); editTask.addParam('_description', taskGeom.description); editTask.addParam('_geom_type', taskGeom.geomType); editTask.addParam('_geom', taskGeom.geometry); // editTask.addParam('_buffer_distance', taskGeom.bufferDistance) // editTask.addParam('_action', taskGeom.action) // editTask.addParam('_status', taskGeom.status) return editTask.execute(); } /*** * 导入任务图形列表 */ importTaskGeom(taskGeom) { let editTask = new EditTask(EditType.TaskGeom_Import); editTask.addParam('_object', taskGeom.object); editTask.addParam('_object_ids', taskGeom.objectIds); return editTask.execute(); } /*** * 更新任务图形 */ updateTaskGeom(taskGeom) { let editTask = new EditTask(EditType.TaskGeom_Update); editTask.addParam('_id', taskGeom.id); editTask.addParam('_name', taskGeom.name); editTask.addParam('_description', taskGeom.description); editTask.addParam('_geom_type', taskGeom.geomType); editTask.addParam('_geom', taskGeom.geometry); // editTask.addParam('_buffer_distance', taskGeom.bufferDistance) // editTask.addParam('_action', taskGeom.action) // editTask.addParam('_status', taskGeom.status) return editTask.execute(); } /*** * 更新任务图形列表 */ removeTaskGeom(taskGeom) { let editTask = new EditTask(EditType.TaskGeom_Delete); editTask.addParam('_id', taskGeom.id); return editTask.execute(); } /** * 查询任务类型列表 */ queryTaskTypeList(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.TaskType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysTaskType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysTaskType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /*** * 新增任务类型列表 */ createTaskType(taskType) { let editTask = new EditTask(EditType.TaskType_Create); editTask.addParam('_name', taskType.name); editTask.addParam('_description', taskType.description); editTask.addParam('_is_publish', taskType.isPublish); return editTask.execute(); } /*** * 更新任务类型列表 */ updateTaskType(taskType) { let editTask = new EditTask(EditType.TaskType_Update); editTask.addParam('_id', taskType.id); editTask.addParam('_name', taskType.name); editTask.addParam('_description', taskType.description); editTask.addParam('_is_publish', taskType.isPublish); return editTask.execute(); } /*** * 更新任务类型列表 */ removeTaskType(taskType) { let editTask = new EditTask(EditType.TaskType_Delete); editTask.addParam('_id', taskType.id); return editTask.execute(); } /** * 查询组织下所有离线区域信息 */ queryOfflinePolygons(pageInfo, filters, order, httpConfig) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } if (httpConfig) { query.setHttpConfig(httpConfig); } let queryTask = new QueryTask(QueryType.OfflinePolygon, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysOfflinePolygon(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysOfflinePolygon(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 创建离线区域 */ createOfflinePolygon(polygon) { let editTask = new EditTask(EditType.OfflinePolygon_Create); editTask.addParam('_name', polygon.name); editTask.addParam('_type', polygon.type); editTask.addParam('_status', 1); editTask.addParam('_geom', polygon.geometry); editTask.addParam('_action', polygon.action); editTask.addParam('_buffer_distance', polygon.bufferDistance); editTask.addParam('_description', polygon.description); return editTask.execute(); } /** * 批量创建离线区域 */ createOfflinePolygons(polygons) { let editTask = new EditTask(EditType.OfflinePolygon_Creates), paramList = []; if (polygons.length > 0) { polygons.forEach((polygon) => { paramList.push({ _name: polygon.name, _geom: polygon.geometry, _buffer_distance: polygon.bufferDistance, _type: polygon.type, _status: 1, _action: polygon.action, _description: polygon.description, }); }); editTask.addParam('_offline_fences', paramList); } return editTask.execute(); } /** * 更新离线区域信息 */ updateOfflinePolygonProperty(polygon) { let editTask = new EditTask(EditType.OfflinePolygon_Update_Property); editTask.addParam('_id', polygon.id); editTask.addParam('_name', polygon.name); editTask.addParam('_type', polygon.type); editTask.addParam('_status', 1); editTask.addParam('_action', polygon.action); editTask.addParam('_buffer_distance', polygon.bufferDistance); editTask.addParam('_description', polygon.description); return editTask.execute(); } /** * 更新离线区域坐标和形状 */ updateOfflinePolygonGeometry(polygon) { let editTask = new EditTask(EditType.OfflinePolygon_Update_Geometry); editTask.addParam('_id', polygon.id); editTask.addParam('_geom', polygon.geometry); return editTask.execute(); } /** * 删除离线区域 */ removeOfflinePolygon(polygons) { let editTask = new EditTask(EditType.OfflinePolygon_Delete); let _ids = []; if (polygons instanceof Array === true) { polygons.forEach((polygon) => { _ids.push(polygon.id); }); } else { _ids.push(polygons.id); } editTask.addParam('_ids', _ids); return editTask.execute(); } /** * 生成离线区域的地图切片数据 */ createOfflinePolygonMapTile(polygon) { let editTask = new EditTask(EditType.OfflinePolygon_Create_MapTile); editTask.addParam('_id', polygon.id); return editTask.execute(); } /** * 查询组织下所有离线区域类型信息 */ queryOfflinePolygonTypes(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.OfflinePolygonType, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysOfflinePolygonType(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysOfflinePolygonType(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } /** * 创建离线区域类型 */ createOfflinePolygonType(polygonType) { let editTask = new EditTask(EditType.OfflinePolygonType_Create); editTask.addParam('_name', polygonType.name); editTask.addParam('_description', polygonType.description); //editTask.addParam('_is_publish', polygonType.isPublish); editTask.addParam('_style', polygonType.style); return editTask.execute(); } /** * 更新离线区域类型 */ updateOfflinePolygonType(polygonType) { let editTask = new EditTask(EditType.OfflinePolygonType_Update); editTask.addParam('_id', polygonType.id); editTask.addParam('_name', polygonType.name); editTask.addParam('_description', polygonType.description); editTask.addParam('_style', polygonType.style); return editTask.execute(); } /** * 删除离线区域类型 */ removeOfflinePolygonType(polygonType) { let editTask = new EditTask(EditType.OfflinePolygonType_Delete); editTask.addParam('_id', polygonType.id); return editTask.execute(); } /** * 清空指定离线区域类型数据 */ removeOfflinePolygonsType(polygonType) { let editTask = new EditTask(EditType.OfflinePolygonsType_Delete); editTask.addParam('_id', polygonType.id); return editTask.execute(); } //统计模块 20200706 yw /** * 查询点类型的要素总数 * @param typeFactor * @returns {Promise} */ queryPointCount() { const query = new Query(); query.setOrder({ id: 'desc' }); const queryTask = new QueryTask(QueryType.StatsPointCount, false); return queryTask.execute(query); } /** * 查询线类型的要素总数 * @param typeFactor * @returns {Promise} */ queryLineCount() { const query = new Query(); query.setOrder({ id: 'desc' }); const stats = new QueryTask(QueryType.StatsLineCount, false); return stats.execute(query); } /** * 查询区域类型的要素总数 * @param typeFactor * @returns {Promise} */ queryFenceCount() { const query = new Query(); query.setOrder({ id: 'desc' }); const stats = new QueryTask(QueryType.StatsFenceCount, false); return stats.execute(query); } /** * 查询事件数量 * @param event * @returns {Promise} */ queryEventCount() { const query = new Query(); query.setOrder({ id: 'desc' }); const stats = new QueryTask(QueryType.StatsEventCount, false); return stats.execute(query); } /** * 查询图标类型列表 */ queryIconTypeList() { let query = new Query(); query.setPageSize(0); query.setOrder({ sort: 'asc', id: 'asc' }); let queryTask = new QueryTask(QueryType.IconType, true); return queryTask.execute(query); } /** * 查询图标列表 */ queryIconList(filters) { let query = new Query(); query.setPageSize(0); query.setOrder({ type: 'asc', sort: 'asc', name: 'asc', id: 'asc' }); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['field'], item['operator'], item['value'], item['type']); }); } let queryTask = new QueryTask(QueryType.Icon, true); return queryTask.execute(query); } /** * 查询二维码 * @param filters 必须包含_obj_id和_obj_type(1-组织;2-群组;3-成员类型),_pass_status:邀请通过状态( 1-需要审核;2-直接通过,默认 ) * @param pageInfo * @returns {Promise} */ queryQRCodeList(filters, pageInfo) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } query.addFilter('org_id', Operator.Equals, this.id); if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.setOrder({ create_time: 'desc' }); let task = new QueryTask(QueryType.QRCodeList, pageInfo); return task.execute(query); } /** * 创建组织二维码邀请 * @param invalidTime * @param remarks * @returns {Promise} */ createOrgQRCode(invalidTime, remarks) { let editTask = new EditTask(EditType.QRCode_Create); editTask.addParam('_obj_type', 1); editTask.addParam('_obj_id', this.id); editTask.addParam('_qr_exp_time', invalidTime); editTask.addParam('_qr_remark', remarks); editTask.addParam('_pass_status', 2); return editTask.execute(); } /** * 创建群组二维码邀请 * @param groupId 群组id * @param memberTypeId 成员类型id * @param invalidTime 失效时间 * @param remarks 备注 * @returns {Promise} */ createGroupQRCode(groupId, memberTypeId, invalidTime, remarks) { let editTask = new EditTask(EditType.QRCode_Create); editTask.addParam('_obj_type', 2); editTask.addParam('_obj_id', groupId); editTask.addParam('_qr_exp_time', invalidTime); editTask.addParam('_qr_remark', remarks); editTask.addParam('_pass_status', 2); //默认通过 editTask.addParam('_rel_obj_type', 3); editTask.addParam('_rel_obj_id', memberTypeId); return editTask.execute(); } /** * 成员类型二维码邀请 * @param typeId * @param invalidTime * @param remarks * @returns {Promise | Promise} */ createMemberTypeQRCode(typeId, invalidTime, remarks) { let editTask = new EditTask(EditType.QRCode_Create); editTask.addParam('_obj_type', 3); editTask.addParam('_obj_id', typeId); editTask.addParam('_qr_exp_time', invalidTime); editTask.addParam('_qr_remark', remarks); editTask.addParam('_pass_status', 2); //默认通过 return editTask.execute(); } /** * * @param codeId 二维码id * @param invalidTime 失效时间 * @param remarks 备注 * @param refresh 是否刷新,默认false,(刷新:在源数据上修改,不是新建一条二维码数据) * @returns {Promise} */ updateQRCode(codeId, invalidTime, remarks, refresh = false) { let editTask = new EditTask(EditType.QRCode_Update); editTask.addParam('_qr_id', codeId); editTask.addParam('_qr_exp_time', invalidTime); editTask.addParam('_qr_remark', remarks); editTask.addParam('_qr_refresh', refresh); //不刷新 editTask.addParam('_pass_status', 2); return editTask.execute(); } /** * 批量更新二维码 * @param params [{qr_id,exp_time,remark,refresh,pass_status},...,N] * @returns {Promise} */ updateBatchQRCode(params) { let editTask = new EditTask(EditType.QRCode_BatchUpdate); let arr = params.map((o) => { return { _qr_id: o['qr_id'], _qr_exp_time: o['exp_time'], _qr_remark: o['remark'], _qr_refresh: o['refresh'], _pass_status: o['pass_status'], }; }); editTask.addParam('_qr_codes', arr); return editTask.execute(); } /** * 删除二维码 * @param codeId * @returns {Promise} */ deleteQRCode(codeId) { let editTask = new EditTask(EditType.QRCode_Delete); editTask.addParam('_qr_id', codeId); return editTask.execute(); } /** * banner类型数据 * @returns {Promise} */ queryBannerTypeList() { let query = new Query(); query.setOrder({ sort: 'asc' }); let queryTask = new QueryTask(QueryType.BannerType, false); return queryTask.execute(query); } /** * 查询banner数据 * @returns {Promise} */ queryBannerListByTypeId(typeId) { let query = new Query(); query.addFilter('type', Operator.Equals, typeId); let queryTask = new QueryTask(QueryType.BannerList, false); return queryTask.execute(query); } /** * 查询设备历史数据 ps:参数必须包含macid和type(系统类型) * @param filters * @param pageInfo * @returns {Promise} */ queryEquipmentPointListById(filters, pageInfo) { let query = new Query(); query.setType('mongodb'); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } // query.addFilter('dataType', Operator.NotEquals, 'null') if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryType = QueryMG.Equipment_Historical; if (this.unionStatus === 1) { //联合状态为父级组织 queryType = QueryMG.Union_Equipment_Historical; } query.setOrder({ createTime: 'desc' }); let queryTask = new QueryTask(queryType, pageInfo); return queryTask.execute(query); } /** * 系统集成token * 查询token列表 * @param {*} params */ connectToken(pageInfo, filters, order) { let query = new Query(); query.addFilter('org_id', Operator.Equals, this.id); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.CheckToken, pageInfo); return queryTask.execute(query); } /** * 更新token * @param {*} params */ refreshToken(params) { let editTask = new EditTask(EditType.TokenEidt); editTask.addParam('_id', params.id); editTask.addParam('_jwt_expire', params.jwt_expire); editTask.addParam('_description', params.description); editTask.addParam('_name', params.name); editTask.addParam('_status', params.status); return editTask.execute(); // } /** * 删除token * @param {*} params */ clearToken(rowId) { // EditType.TokenDelete let editTask = new EditTask(EditType.TokenDelete); editTask.addParam('_id', rowId); return editTask.execute(); } /** * 创建token * @param {*} params */ creationToken(params) { // EditType.TokenCreate let editTask = new EditTask(EditType.TokenCreate); editTask.addParam('_jwt_expire', params.jwt_expire); editTask.addParam('_description', params.description); editTask.addParam('_name', params.name); editTask.addParam('_status', params.status); return editTask.execute(); } /** * * 查询第三方列表 * @returns */ thirdpartyList(pageInfo) { let query = new Query(); query.setOrder({ id: 'asc' }); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } let queryTask = new QueryTask(QueryType.ThirdpartyList, pageInfo ? true : false); return queryTask.execute(query); } /** * 新增类型关联API * @param */ typeAddAPI(params) { let editTask = new EditTask(EditType.TypeAddAPI); editTask.addParam('_object_type', params.objectType); editTask.addParam('_api_is_publish', 1); editTask.addParam('_type_id', params.typeID); editTask.addParam('_api_name', params.api_name); editTask.addParam('_api_url', params.api_url); editTask.addParam('_api_description', params.description); return editTask.execute(); } /** * 修改类型关联API * @param */ typeUpdateAPI(params) { let editTask = new EditTask(EditType.TypeUpdateAPI); editTask.addParam('_api_is_publish', params.isPublish); editTask.addParam('_id', params.id); editTask.addParam('_api_name', params.apiName); editTask.addParam('_api_url', params.apiUrl); editTask.addParam('_api_description', params.description); return editTask.execute(); } /** * 删除类型关联API * @param {*} params */ typeDeleteAPI(params) { // EditType.TokenDelete let editTask = new EditTask(EditType.TypeDeleteAPI); editTask.addParam('_id', params); return editTask.execute(); } /** *查询组织联合列表 * @param {*} params */ orgUnion(pageInfo, filters) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryTask = new QueryTask(QueryType.OrgUnion, pageInfo ? true : false); return queryTask.execute(query); } /** *查询组织联合记录列表 * @param {*} params */ UnionRecord(pageInfo, filters) { let query = new Query(); query.setOrder({ create_time: 'desc' }); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryTask = new QueryTask(QueryType.UnionRecord, pageInfo ? true : false); return queryTask.execute(query); } /** *查询组织联合记录详情列表 * @param {*} params */ unionRecordDetail(pageInfo, filters, order) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ datetime: 'desc' }); } let queryTask = new QueryTask(QueryType.UnionRecordDetail, pageInfo ? true : false); return queryTask.execute(query); } /** *申请或邀请组织联合 * @param {*} params */ UnionInvite(params) { let editTask = new EditTask(EditType.UnionInvite); editTask.addParam('_union_way', params.unionWay); editTask.addParam('_abbreviation', params.abbreviation); editTask.addParam('_description', params.description); return editTask.execute(); } /** *审核组织联合的邀请 * @param {*} params * status:2 邀请通过 9 邀请被拒 */ UnionAudit(params) { let editTask = new EditTask(EditType.UnionAudit); editTask.addParam('_id', params.id); editTask.addParam('_status', params.status); editTask.addParam('_description', params.description); return editTask.execute(); } /** *主动解除组织关联(退出) * @param {*} params * */ UnionExit(params) { let editTask = new EditTask(EditType.UnionExit); // editTask.addParam('_children_org_id', params.id); editTask.addParam('_description', params.description); return editTask.execute(); } /** *解除组织关联 * @param {*} params * */ UnionRemove(params) { let editTask = new EditTask(EditType.UnionRemove); editTask.addParam('_children_org_id', params.id); editTask.addParam('_description', params.description); return editTask.execute(); } /** *取消组织联合的邀请 * @param {*} params * */ CloseUnionAudit(params) { let editTask = new EditTask(EditType.CloseUnionAudit); editTask.addParam('_id', params.id); return editTask.execute(); } /** *查询组织列表 * @param {*} params */ orgList(pageInfo, filters) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } let queryTask = new QueryTask(QueryType.orgList, pageInfo ? true : false); return queryTask.execute(query); } /** * 查询求救消息 */ sosRecord(pageInfo, filters, order) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ status: 'asc', datetime: 'desc' }); } let queryTask = new QueryTask(QueryType.sosLecord, pageInfo ? true : false); return queryTask.execute(query); } /**处理求救 */ sosStatusUpdate(params) { let editTask = new EditTask(EditType.sosStatusUpdate); editTask.addParam('_ids', params); return editTask.execute(); } /************* * 查看通知 */ noticeMessageList(pageInfo, filters, order) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ create_time: 'desc' }); } let queryTask = new QueryTask(QueryType.noticeMessage, pageInfo ? true : false); return queryTask.execute(query); } /* /!** * 发送通知 *!/ sendNotice(params) { return thirdpartyPost(SubmitType.sendNoticeMessage, params); }*/ /**************** * 查询协同数据审核列表 */ getSyneryData(pageInfo, filters, order) { let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ id: 'desc' }); } let queryTask = new QueryTask(QueryType.syneryData, pageInfo ? true : false); return queryTask.execute(query); } /** * 更新协同数据审核状态 */ updataSyneryData(params) { let editTask = new EditTask(EditType.synergyUpdata); editTask.addParam('_id', params.id); editTask.addParam('_status', params.status); editTask.addParam('_remark', params.remark); return editTask.execute(); } /************************ MQTT *****************************/ //订阅人员位置信息 subscribeMemberLoc(params) { let param = Object.assign({}, params.object); if (!param.orgId) param.orgId = this.id; let MemberLocTopic = new CellsysPush.MemberLocTopic(param); let pushTask = new CellsysPush.pushTask(); pushTask.subscribe({ cellsysTopic: MemberLocTopic, onReceive: params.onReceive, onSuccess: params.onSuccess, onFail: params.onFail, }); } //取消订阅人员位置信息 unSubscribeMemberLoc(params) { let param = Object.assign({}, params.object); if (!param.orgId) param.orgId = this.id; let MemberLocTopic = new CellsysPush.MemberLocTopic(param); let pushTask = new CellsysPush.pushTask(); pushTask.unSubscribe({ cellsysTopic: MemberLocTopic, onSuccess: params.onSuccess, onFail: params.onFail, }); } //订阅设备信息 subscribeEquipment(params) { let equipment = params.object, onSuccess = params.onSuccess, onFail = params.onFail, onReceive = params.onReceive; let equipmentLocTopic = new CellsysPush.EquipmentTopic(equipment); let pushTask = new CellsysPush.pushTask(); pushTask.subscribe({ cellsysTopic: equipmentLocTopic, onReceive: onReceive, onSuccess: onSuccess, onFail: onFail, }); } /** * 发送消息 * @param params */ sendSysMessage(params) { let onSuccess = params.onSuccess, content = params.content, receiveIds = params.receivers; if (Array.isArray(receiveIds)) { //消息发送 //let payload = `{"content":"${content}","receiveIds":[${receiveIds.join(',')}],"timestamp":${Date.now()}}`; //调整成使用标准json格式,再由JSON.stringify转成json字符串,否则则会出现特殊字符显示问题。 let payload = { content: content, receiveIds: receiveIds, timestamp: Date.now(), }; let topic = new CellsysPush.ChatSystemTopic(this.id); let pushTask = new CellsysPush.pushTask(); pushTask.send({ cellsysTopic: topic, message: JSON.stringify(payload), }); } } //发送单聊消息topic sendSingleMessage(params) { let { content, conversationId, conversationName, senderId, senderName } = params; let singlePayload = { content: content, conversationId: conversationId, conversationName: conversationName, conversationType: 0, msgType: 0, senderId: senderId, senderName: senderName, }; let topic = new CellsysPush.SingleChatTopic(this.id, conversationId, senderId); let pushTask = new CellsysPush.pushTask(); pushTask.send({ cellsysTopic: topic, message: JSON.stringify(singlePayload), }); } //接收回复 subscribeReplySysMessage(params) { let currentUser = params.currentUser; if (currentUser.isAdmin) { //只有管理员才会监听此话题 let pushTask = new CellsysPush.pushTask(); let receiveTopic = new CellsysPush.ChatSystemReplyTopic(this.id, params.receiver); //父组织 pushTask.subscribe({ cellsysTopic: receiveTopic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); let childrenReceiveTopics = []; if (this.unionStatus === 1) { //联合状态下同时订阅子组织聊天信息 let unionOrgIds = this.unionOrgIds; if (unionOrgIds && unionOrgIds.length > 0) { unionOrgIds.forEach((id) => { childrenReceiveTopics.push( new CellsysPush.ChatSystemReplyTopic(id, params.receiver), ); }); } childrenReceiveTopics.forEach((item) => { pushTask.subscribe({ cellsysTopic: item, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }); } } //单聊订阅 let singleChartPushTask = new CellsysPush.pushTask(); let singleChartTopic = new CellsysPush.SingleChatReplyTopic( this.id, params.currentUser.userId, ); //父组织 singleChartPushTask.subscribe({ cellsysTopic: singleChartTopic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } /** * 订阅围栏事件 * @param params */ subscribeFenceEvent(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.FenceEventTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } /** * 订阅SOS+求救 */ subscribeSOS(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.SosTopic({ orgId: this.id }); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); //组织联合模式下子组织消息订阅 let childrenReceiveTopics = []; if (this.unionStatus === 1) { //联合状态下同时订阅子组织SOS let unionOrgIds = this.unionOrgIds; if (unionOrgIds && unionOrgIds.length > 0) { unionOrgIds.forEach((id) => { childrenReceiveTopics.push(new CellsysPush.SosTopic({ orgId: id })); }); } childrenReceiveTopics.forEach((item) => { pushTask.subscribe({ cellsysTopic: item, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }); } } /** * 北斗盒子订阅 * @param params subscribeBDBox(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.BDBoxTopic({ orgId: this.id }, this); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }*/ /** * 订阅设备(监控组) */ subscribeEquipmentMonitor(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.EquipmentMonitorTopic({ orgId: this.id, topicName: params.topicName, }); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } /** * 事件上传组织系统消息订阅 * @param params */ subscribeEventMessage(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.eventNoticeTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); //组织联合模式下子组织消息订阅 let childrenReceiveTopics = []; if (this.unionStatus === 1) { //联合状态下同时订阅子组织SOS let unionOrgIds = this.unionOrgIds; if (unionOrgIds && unionOrgIds.length > 0) { unionOrgIds.forEach((id) => { childrenReceiveTopics.push(new CellsysPush.eventNoticeTopic(id)); }); } childrenReceiveTopics.forEach((item) => { pushTask.subscribe({ cellsysTopic: item, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }); } } /** * 标记上传组织系统消息订阅 * @param params */ subscribeMarkerMessage(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.markerNoticeTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); //组织联合模式下子组织消息订阅 let childrenReceiveTopics = []; if (this.unionStatus === 1) { //联合状态下同时订阅子组织SOS let unionOrgIds = this.unionOrgIds; if (unionOrgIds && unionOrgIds.length > 0) { unionOrgIds.forEach((id) => { childrenReceiveTopics.push(new CellsysPush.markerNoticeTopic(id)); }); } childrenReceiveTopics.forEach((item) => { pushTask.subscribe({ cellsysTopic: item, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }); } } //监听设备状态 subscribeEquipmentStatus(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.EquipmentStatusTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); //组织联合模式下子组织消息订阅 let childrenReceiveTopics = []; if (this.unionStatus === 1) { //联合状态下同时订阅子组织SOS let unionOrgIds = this.unionOrgIds; if (unionOrgIds && unionOrgIds.length > 0) { unionOrgIds.forEach((id) => { childrenReceiveTopics.push(new CellsysPush.EquipmentStatusTopic(id)); }); } childrenReceiveTopics.forEach((item) => { pushTask.subscribe({ cellsysTopic: item, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); }); } } //监听edgeCommonder消息 subscribeEdgeCommander(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.EquToEdgeTopic(this.id, params.macId); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } //监听cellsys系统消息,如成员加入组织申请 subscribeMemberJoin(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.memberJoinTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } //管理员批量更新协同数据发布状态 updateSynergyDatasPublish(dataList, type) { let editTask = new EditTask(EditType.SynergyDatasPublishUpdate); let datas = null; if (dataList && dataList.length > 0) { datas = dataList.map((item) => { let { id, isPublish, dataName, remark } = item; return { _id: id, _is_publish: isPublish, _data_name: dataName, _remark: remark, }; }); } if (datas) { editTask.addParam('_synergy_datas', datas); } editTask.addParam('_synergy_data_type', type); return editTask.execute(); } //查询标签 queryTags(queryParams) { if (!queryParams) { queryParams = { pageInfo: { currPage: 1, pageSize: 0, }, }; } let { pageInfo, filters, order } = queryParams; let query = new Query(); if (pageInfo) { query.setCurrPage(pageInfo.currPage); query.setPageSize(pageInfo.pageSize); } if (filters && filters.length > 0) { filters.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } if (order) { query.setOrder(order); } else { query.setOrder({ create_time: 'desc' }); } let queryTask = new QueryTask(QueryType.Tag, pageInfo ? true : false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new CellsysTag(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new CellsysTag(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } //创建标签组 createTagGroup(tagTypeParams) { let editTask = new EditTask(EditType.TagGroup_Insert); editTask.addParam('_name', tagTypeParams.name); editTask.addParam('_description', tagTypeParams.description); return editTask.execute(); } //创建标签 createTag(tagParams) { let editTask = new EditTask(EditType.Tag_Insert); editTask.addParam('_name', tagParams.name); editTask.addParam('_description', tagParams.description); if (tagParams.tagGroupName) { editTask.addParam('_tag_group_name', tagParams.tagGroupName); } return editTask.execute(); } //批量创建标签 createTags(tags) { let editTask = new EditTask(EditType.Tags_Insert); let _tags = tags.map((item) => { let param = { _name: item.name, _description: item.description, }; if (item.tagGroupName) { param['_tag_group_name'] = item.tagGroupName; } return param; }); editTask.addParam('_tags', _tags); return editTask.execute(); } //更新标签 updateTag(tag) { let editTask = new EditTask(EditType.Tag_Update); editTask.addParam('_id', tag.id); editTask.addParam('_name', tag.name); editTask.addParam('_description', tag.description); return editTask.execute(); } //删除标签 deleteTag(tag) { let editTask = new EditTask(EditType.Tag_Delete); editTask.addParam('_id', tag.id); return editTask.execute(); } updateTagRel(relParams) { let { tags, modelCode, modelObjectId } = relParams; //if (!Array.isArray(modelObjectIds)) { // throw new Error("参数错误,modelObjectIds应该为数组") //} let editTask = new EditTask(EditType.TagsGroupModeleUpdate); if (Array.isArray(tags)) { let tagNames = tags.map((tag) => { return tag.name; }); editTask.addParam('_tag_names', tagNames); } editTask.addParam('_model_code', modelCode); editTask.addParam('_model_object_id', modelObjectId); return editTask.execute(); } //修改标签与模块组的关联 updateTagModeleGroup(params) { if (!Array.isArray(params.modelObjectIds)) { throw new Error('参数错误,modelObjectIds应该为数组'); } let editTask = new EditTask(EditType.TagModeleGroupUpdate); editTask.addParam('_tag_name', params.tagName); editTask.addParam('_model_code', params.modelCode); editTask.addParam('_model_object_ids', params.modelObjectIds); return editTask.execute(); } //发送成员审核结果通知 sendMemberAuditMessage(params) { let { status, userId } = params; let payload = { status: status, orgName: this.name, abbreviation: this.abbreviation, timeStamp: new Date().getTime(), }; let topic = new CellsysPush.memberAuditTopic(this.id, userId); let pushTask = new CellsysPush.pushTask(); pushTask.send({ cellsysTopic: topic, message: JSON.stringify(payload), }); } //发送离线地图生成状态 sendOfflineFenceState(params) { let pushTask = new CellsysPush.pushTask(); let topic = new CellsysPush.offlineFenceTopic(this.id); pushTask.subscribe({ cellsysTopic: topic, onSuccess: params.onSuccess, onFail: params.onFail, onReceive: params.onReceive, }); } } export default CellsysOrg;