123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176 |
- app.controller('devManageCtrl', ['$scope', '$filter', '$http', '$state', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', 'QRCodeOptions', 'FileUploader', function ($scope, $filter, $http, $state, $stateParams, $timeout, uiGridConstants, i18nService, toaster, QRCodeOptions, FileUploader) {
- i18nService.setCurrentLang("zh-cn");
- moment.locale('zh-cn');
- var managerId = $stateParams.managerId;
- var agentId = $stateParams.agentId;
- var dealerId = $stateParams.dealerId;
- var searchKey = $stateParams.searchKey || "";
- $scope.gridOptions = {
- data: 'myData',
- showGridFooter: true, //是否显示grid footer
- // rowHeight: 80,
- //-------- 分页属性 ----------------
- paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
- paginationCurrentPage: 1, //当前页码
- paginationPageSize: 10, //每页显示个数
- totalItems: 0,// 总数量
- useExternalPagination: true,//是否使用分页按钮
- //过滤
- // enableFiltering: true,
- columnDefs: [],
- //---------------api---------------------
- onRegisterApi: function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- if ($scope.setPagingData) {
- $scope.getPagedDataAsync(newPage, pageSize, true);//翻页是强制刷新
- }
- });
- }
- };
- //查询条件
- var condition = $scope.condition = {
- registered: {value: true, label: "已注册"},
- online: {value: "", label: "-选择在线状态-"},
- logicalCode: '',
- searchKey: searchKey,
- fileContent: ''
- };
- //枚举常量
- $scope.enum = {};
- $scope.enum.registered = [
- {value: "", label: "-选择注册状态-"},
- {value: true, label: "已注册"},
- {value: false, label: "未注册"}
- ];
- $scope.enum.online = [
- {value: "", label: "-选择在线状态-"},
- {value: 0, label: "离线设备"},
- {value: 1, label: "在线设备"},
- ];
- //事件
- $scope.event = {
- statusChange: function (key, item) {
- condition[key].value = item.value;
- condition[key].label = item.label;
- this.search()
- },
- search: function () {
- // 就在当前 厂商|代理商|经销商的域下进行搜索
- if (condition.searchKey === "") {
- $.confirm({
- content: '条件为空,数据量较大,确定继续?',
- buttons: {
- ok: {
- text: '搜索',
- action: function () {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize, true);
- }
- },
- }
- });
- } else {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- }
- },
- searchByLogicalCode: function () {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- }
- };
- $scope.batchQuery = function () {
- $(".devManageMain #batchQueryForm").modal();
- $scope.dialogData = {}
- }
- $scope.batchQueryOk = function () {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize, true);
- };
- $scope.changeFile = function (files) {
- if (files.length) {
- var file = files[0];
- var reader = new FileReader();
- // 文件不能大于1M
- if (file.size > 1000 * 1024) {
- toaster.pop("info", "提示", "文件太大,请重新选择");
- } else {
- reader.onload = function () {
- if (reader.result) {
- var text = reader.result
- $scope.condition.fileContent = text
- $scope.dialogData.fileName = file.name
- $scope.$apply();
- }
- };
- reader.readAsText(file);
- }
- }
- }
- function getLogicalList(logicalCodeList) {
- var needList = logicalCodeList.split("\n")
- for (var i = needList.length - 1; i >= 0; i--) {
- var item = needList[i];
- needList[i] = $.trim(item);
- if (needList[i] === '') {
- needList.splice(i, 1)
- }
- }
- needList = needList.filter(function (item, i, self) {
- var flag = self.indexOf(item) === i
- return flag;
- })
- return needList
- }
- // 查询条件缓存,用于导出报表用
- $scope.queryCache = {}
- // 导出查询设备的报表
- $scope.exportDevice = function () {
- if ($.isEmptyObject($scope.queryCache)) {
- toaster.pop("info", "提示", "请先根据条件查询一次数据");
- return
- }
- $http({
- method: 'POST',
- url: '/superadmin/exportDevice',
- data: $scope.queryCache
- }).then(function (response) {
- toaster.pop("success", "提示", "操作成功,请到结果页面下载报表");
- $state.go('app.tool.offlineTask', {
- searchKey: response.data.payload
- });
- }, function (response) {
- toaster.pop("error", "提示", "保存失败!");
- });
- }
- $scope.modelEvent = {
- //根据条件搜索粉丝详情
- searchDetail: function () {
- //重新加载 折线图
- loadChartData();
- },
- startTimeOpen: false,
- endTimeOpen: false,
- timeChange: function (passDay) {
- $scope.modelEvent.startTimeOpen = false;
- $scope.modelEvent.endTimeOpen = false;
- },
- quickTime: function (evt, passDay) {
- $scope.chartCondition.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD");
- $scope.chartCondition.endTime = moment().format("YYYY-MM-DD");
- },
- };
- $scope.powerModelEvent = {
- //根据条件搜索粉丝详情
- searchDetail: function () {
- //重新加载 折线图
- loadPowerChartData();
- },
- startTimeOpen: false,
- endTimeOpen: false,
- timeChange: function (passDay) {
- $scope.powerModelEvent.startTimeOpen = false;
- $scope.powerModelEvent.endTimeOpen = false;
- },
- quickTime: function (evt, passDay) {
- $scope.powerChartCondition.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD");
- $scope.powerChartCondition.endTime = moment().format("YYYY-MM-DD");
- },
- };
- function setColumnDefs() {
- $scope.gridOptions.columnDefs = [
- {
- field: 'oper', displayName: '查看',
- width: 230,
- enableFiltering: false,
- enableSorting: false,
- enableHiding: false,//禁止在列选择器中隐藏
- enableColumnMenu: false,// 是否显示列头部菜单按钮
- cellTemplate: '<div class="grid-button">' +
- '<button class="btn btn-sm btn-rounded btn-info" ng-click="grid.appScope.showChart(row.entity)"><i class="iconfont icon-wifi" style="font-size: 12px"></i> 信号</button>' +
- '<button class="btn btn-sm btn-rounded btn-info" ng-if="row.entity.supportPG" ng-click="grid.appScope.showPowerChart(row.entity)"><i class="iconfont icon-voltage" style="font-size: 12px"></i> 功率</button>' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.queryChargeRecord(row.entity)"><i class="iconfont icon-recharge" style="font-size: 12px"></i> 续费记录</button>' +
- '</div>'
- },
- {
- field: 'logicalCode',
- displayName: '逻辑编号',
- width: 80,
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showDevDetailInfo(\'设备详细信息\',row.entity)" >{{row.entity.logicalCode}}</div>'
- },
- {
- field: 'devNo',
- displayName: '设备编号',
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showDevDetailInfo(\'设备详细信息\',row.entity)" >{{row.entity.devNo}}</div>'
- },
- {
- field: 'devTypeCode',
- displayName: '设备Code',
- cellTemplate: '<div class="temp-row" >{{row.entity.devType.code}}</div>'
- },
- {
- field: 'simStatus',
- displayName: 'sim卡状态',
- },
- {
- field: 'owner',
- displayName: '经销商',
- width: 140,
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showDevOwnerInfo(\'设备属主信息\',row.entity)" >{{row.entity.dealer.nickname + " " + row.entity.dealer.username}}</div>'
- },
- {
- field: 'softVer',
- displayName: '软件版本',
- width: 60
- },
- {
- field: 'hwVer',
- displayName: '硬件版本',
- width: 60
- },
- {
- field: 'coreVer',
- displayName: '核心版本',
- width: 60,
- },
- {
- field: 'driverCode',
- displayName: '驱动编码',
- width: 60,
- },
- {
- field: 'online',
- displayName: '在线状态',
- width: 80,
- cellTemplate: '<div class="temp-row" ng-class="{\'text-success\':row.entity.online==1}" ng-bind="(row.entity.online==1)?\'在线(\' + row.entity.signal + \')\':\'离线(\'+row.entity.signal + \')\'"></div>'
- },
- {
- field: 'lastOffTime', displayName: '最近离线时间',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.lastOffTime?(row.entity.lastOffTime| date:\'yyyy-MM-dd HH:mm:ss\'):\'无\'"></div>',
- width: 140
- },
- {
- field: 'registered',
- displayName: '注册状态',
- width: 80,
- cellTemplate: '<div class="temp-row" ng-class="{\'text-success\':row.entity.registered!=false,\'text-danger\':row.entity.registered==false}">{{row.entity.registered==false?"未注册":"已注册"}}</div>'
- },
- {
- field: 'createdTime',
- displayName: '注册时间',
- width: 140,
- },
- {
- field: 'iccid',
- displayName: 'ICCID',
- width: 120,
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showSimCard(row.entity.iccid)" >{{row.entity.iccid}}</div>'
- },
- {
- field: 'simExpireDate',
- displayName: '过期时间',
- width: 140,
- },
- {
- field: 'server',
- displayName: '服务器',
- width: 140,
- },
- {
- field: 'oper',
- displayName: '操作',
- enableFiltering: false,
- enableSorting: false,
- enableHiding: false,//禁止在列选择器中隐藏
- enableColumnMenu: false,// 是否显示列头部菜单按钮
- width: 480,
- cellTemplate: '<div class="grid-button">' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.getQRCode(row.entity)"><i class="fa fa-qrcode"></i>二维码</button>' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.unbindDevice(row.entity)" ng-disabled="row.entity.registered==false"><i class="fa fa-trash-o"></i>解绑</button>' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.cleanCache(row.entity)"><i class="fa fa-trash-o"></i>清理缓存</button>' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.setDebugFlag(row.entity)"><i class="fa fa-flag"></i>调试标记</button>' +
- '<button class="btn btn-sm btn-rounded btn-info" ng-click="grid.appScope.sendCommand(row.entity)"><i class="fa fa-file-code-o"></i> 指令</button>' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.leaseDev(row.entity)"><i class="fa fa-bullhorn"></i>出租设备</button>' +
- '</div>'
- },
- ];
- var fields = $scope.gridOptions.columnDefs;
- for (var index in fields) {
- var item = fields[index];
- if (item && item['minWidth'] == null) {
- item['minWidth'] = 100;
- }
- }
- }
- $scope.setPagingData = function (data) {
- var pagedData = data.data.dataList;
- $scope.myData = pagedData;
- $scope.gridOptions.totalItems = data.data.total;
- };
- $scope.getPagedDataAsync = function (curPage, pageSize, force) {
- if ($scope.gridOptionsLoading) {
- return;
- }
- var params = {
- pageSize: pageSize,
- pageIndex: curPage,
- };
- if (condition.registered.value !== '') {
- params.registered = condition.registered.value
- }
- if (condition.online.value !== '') {
- params.online = condition.online.value
- }
- if (condition.logicalCode !== "") {
- params.logicalCode = condition.logicalCode
- }
- if (condition.searchKey !== "") {
- params.searchKey = condition.searchKey
- }
- if (dealerId) {
- params.dealerId = dealerId;
- }
- if (agentId) {
- params.agentId = agentId;
- }
- if (managerId) {
- params.managerId = managerId;
- }
- // 如果没有条件,则不查询,因为数据量太大,加载太卡!
- if (force) {
- // nothing
- } else if (!params.dealerId && !params.agentId && !params.managerId && !params.logicalCode && !params.searchKey) {
- toaster.pop("info", "温馨提示", "请输入查询条件进行查询");
- return
- }
- // 批量查询时候的条件
- var logicalCodeList = getLogicalList($scope.condition.fileContent)
- if (logicalCodeList.length > 0) {
- params.logicalCodeList = logicalCodeList
- }
- $scope.queryCache = params;
- $scope.gridOptionsLoading = true;
- $http.get('/superadmin/getDeviceDetailList', {
- params: params
- }).then(function (data) {
- data = data.data
- $scope.gridOptionsLoading = false;
- $scope.setPagingData(data, curPage, pageSize);
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据列表失败");
- });
- };
- function initDataGrid(force) {
- //首次加载表格
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize, force);
- }
- setColumnDefs();
- initDataGrid();
- $scope.getQRCode = function (entity) {
- $(".devManageMain #devQRCodePanel").modal();
- var currentDomain = location.protocol + "//" + location.host;
- var dataURL = QRCodeOptions.getQRCodeImageData({
- text: currentDomain + "/userLogin?l=" + entity.logicalCode,
- label: entity.logicalCode,
- // logoDom: $("#qrcodeOptPreviewLogo")[0]
- });
- $(".devManageMain #previewImg").attr({
- "width": 200,
- "height": 240,
- "src": dataURL
- });
- };
- $scope.closeQRCode = function () {
- $(".devManageMain #devQRCodePanel").modal('hide');
- };
- //强制解绑
- $scope.unbindDevice = function (entity) {
- $.confirm({
- content: '确定解绑?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: "/superadmin/unbindDevByAdmin",
- data: {logicalCode: entity.logicalCode}
- }).then(function (response) {
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- toaster.pop("info", "提示", "解绑成功!");
- }, function (response) {
- toaster.pop("error", "提示", "操作失败!");
- });
- }
- },
- }
- });
- };
- // 清理缓存
- $scope.cleanCache = function (entity) {
- $.confirm({
- content: '确定清理?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: "/superadmin/device/clearCache",
- data: {devNo: entity.devNo}
- }).then(function (response) {
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- toaster.pop("info", "提示", "清理成功!");
- }, function (response) {
- toaster.pop("error", "提示", "清理失败!");
- });
- }
- },
- }
- });
- };
- //设置调试标记
- $scope.setDebugFlag = function (entity) {
- $(".devManageMain #deviceDebugPanel").modal();
- $scope.devNo = entity.devNo;
- };
- var dialogData = $scope.dialogData = {};
- $scope.devNo = "";
- //发送指令
- $scope.sendCommand = function (entity) {
- $scope.commandInfoPanel.$setPristine();
- $scope.commandInfoPanel.$setUntouched();
- $scope.devNo = entity.devNo;
- $http.get('/superadmin/getCommandByDevice', {
- params: {logicalCode: entity.logicalCode}
- }).then(function (data) {
- data = data.data
- if (data.result == 1) {
- dialogData.commandList = data.payload.dataList
- $scope.currentCmdIndex = -1
- $scope.currentCmd = null;
- }
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取常用命令列表失败");
- });
- $(".devManageMain #commandInfoPanel").modal();
- };
- $scope.selectCommand = function (index, item) {
- $scope.currentCmdIndex = index
- $scope.currentCmd = item;
- };
- $scope.sendCommandConfirm = function () {
- if ($scope.commandInfoPanel.$invalid) {
- return;
- }
- var currentCmd = $scope.currentCmd
- if (!$scope.currentCmd.id) {
- toaster.pop("info", "提示", "请选择指令!");
- return
- }
- var params = []
- for (var index in currentCmd.params) {
- var item = currentCmd.params[index]
- params.push({
- id: item.id,
- default: item.default,
- })
- }
- $http({
- method: 'POST',
- url: '/superadmin/sendCommand',
- data: {id: currentCmd.id, devNo: $scope.devNo, params: params}
- }).then(function (response) {
- var data = response.data;
- if (data.result == 1) {
- toaster.pop("success", "提示", "操作成功!");
- $scope.currentResult = JSON.parse(data.data);
- }
- }, function (response) {
- toaster.pop("error", "提示", "操作失败!");
- });
- };
- $scope.closeCommandPanel = function () {
- $(".devManageMain #commandInfoPanel").modal("hide");
- delete dialogData.command;
- };
- $scope.leaseDev = function (entity) {
- $.confirm({
- content: '确定出租设备?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/rentDevice',
- data: {logicalCode: entity.logicalCode}
- }).then(function (response) {
- var data = response.data;
- if (data.result == 1) {
- toaster.pop("success", "提示", "操作成功!");
- }
- }, function () {
- toaster.pop("error", "提示", "操作失败!");
- });
- }
- },
- }
- });
- }
- $scope.sendDeviceDebugConfirm = function () {
- $http({
- method: 'POST',
- url: '/superadmin/device/setDebug',
- data: {devNo: $scope.devNo, debugFlag: dialogData.debugFlag}
- }).then(function (response) {
- $scope.devNo = "";
- var data = response.data;
- if (data.result == 1) {
- toaster.pop("success", "提示", "操作成功!");
- }
- }, function (response) {
- $scope.devNo = "";
- toaster.pop("error", "提示", "操作失败!");
- });
- };
- $scope.closeDeviceDebugPanel = function () {
- $(".devManageMain #deviceDebugPanel").modal("hide");
- delete dialogData.debugFlag;
- $scope.devNo = "";
- };
- //展示设备属主信息
- $scope.showDevOwnerInfo = function (title, content) {
- var owner = {
- dealer: content.dealer,
- agent: content.agent,
- manager: content.manager
- }
- $scope.infoDetail = {title: title, content: owner};
- $(".devManageMain #detailInfoPanel").modal();
- };
- //展示设备类型详情
- $scope.showDevTypeDetailInfo = function (title, content) {
- $scope.infoDetail = {title: title, content: content};
- $(".devManageMain #detailInfoPanel").modal();
- };
- //展示设备详情
- $scope.showDevDetailInfo = function (title, content) {
- var detail = {
- server: content.server,
- softVer: content.softVer,
- hwVer: content.hwVer,
- coreVer: content.coreVer,
- driverVersion: content.driverVersion,
- cycle: content.cycle,
- washConfig: content.washConfig,
- pulseInterval1: content.pulseInterval1,
- remarks: content.remarks,
- battery: content.battery,
- groupId: content.groupId,
- groupName: content.groupName,
- address: content.address,
- pulseWidth1: content.pulseWidth1,
- mcuVersion: content.mcuVersion,
- boardValid: content.boardValid,
- simStatus: content.simStatus,
- dateTimeBinded: content.dateTimeBinded,
- }
- $scope.infoDetail = {title: title, content: detail};
- $(".devManageMain #detailInfoPanel").modal();
- };
- //显示SIM卡信息
- $scope.showSimCard = function (iccid) {
- $http.get('/superadmin/sim/get', {
- params: {iccid: iccid}
- }).then(function (data) {
- data = data.data
- if (data.result == 1) {
- $scope.infoDetail = {title: 'SIM详细信息', content: data.payload};
- $(".devManageMain #detailInfoPanel").modal();
- }
- }).catch(function () {
- toaster.pop("error", "提示", "获取SIM卡信息失败");
- });
- };
- $scope.closeDetailPanel = function () {
- $(".devManageMain #detailInfoPanel").modal("hide");
- };
- // 信号趋势图
- var chartCondition = $scope.chartCondition = {
- "logicalCode": null,
- startTime: moment().format("YYYY-MM-DD"),
- endTime: moment().format("YYYY-MM-DD")
- };
- var signalChartPanel;
- $scope.showChart = function (entity, type) {
- $("#chartInfoPanel").modal();
- chartCondition.logicalCode = entity.logicalCode;
- //展示趋势图
- signalChartPanel = echarts.init(document.getElementById('signalChartPanel')); //resize事件绑定
- $(window).off("resize.signalChartPanel").on("resize.signalChartPanel", function () {
- signalChartPanel.resize();
- });
- loadChartData();
- };
- $scope.closeChart = function () {
- $("#chartInfoPanel").modal('hide');
- };
- $scope.closeChart = function () {
- $("#chartInfoPanel").modal('hide');
- };
- var loadChartData = $scope.loadChartData = function () {
- var params = chartCondition;
- let url = '/superadmin/getSignalTrendByDevice'
- //获取数据
- $http.get(url, {
- params: {
- logicalCode: params.logicalCode,
- startTime: params.startTime + ' 00:00:00',
- endTime: params.endTime + ' 23:59:59',
- }
- }).then(function (data) {
- var payload = data.data.payload
- var option = signalChartOption(payload.dataList);
- signalChartPanel.setOption(option);
- });
- };
- function signalChartOption(dataList) {
- var xData = [];
- var seriesData = [];
- function getColor(v) {
- if (v > 8 && v <= 20) {
- return '#FFC000'
- } else if (v > 20) {
- return '#07C160'
- } else {
- return '#ED6066'
- }
- }
- var min = 31;
- var max = 0;
- for (var index in dataList) {
- var item = dataList[index]
- xData.push(moment(item.dateStr).format("MM-DD HH:mm:ss"));
- seriesData.push(parseFloat(item.signal));
- if (min > item.signal) {
- min = item.signal
- }
- if (max < item.signal) {
- max = item.signal
- }
- }
- var option = {
- legend: {
- show: false
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- lineStyle: {
- color: '#108EE9',
- width: .3,
- }
- }
- },
- grid: {
- x: 40,
- x2: 15,
- y: 45,
- y2: 40,
- },
- xAxis: [
- {
- type: 'category',
- axisLabel: {
- textStyle: {
- color: "#aaa",
- fontSize: "12px"
- }
- },
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- data: xData
- }
- ],
- yAxis: [
- {
- type: 'value',
- axisLabel: {
- textStyle: {
- color: "#aaa",
- fontSize: "12px"
- }
- },
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- splitLine: {
- lineStyle: {
- color: '#ccc',
- width: 0.3,
- type: 'dotted'
- }
- },
- },
- ],
- series: []
- };
- option.yAxis[0].max = 31
- option.visualMap = {
- show: false,
- pieces: [{
- gt: 0,
- lte: 8,
- color: '#ED6066'
- }, {
- gt: 8,
- lte: 20,
- color: '#FFC000'
- }, {
- gt: 20,
- lte: 31,
- color: '#07C160'
- }]
- }
- option.series.push({
- name: '信号',
- stack: '信号',
- type: 'line',
- symbolSize: 0,
- markPoint: {
- data: [
- {type: 'max', name: '信号最强', itemStyle: {color: getColor(max)}},
- {
- type: 'min',
- name: '信号最差',
- symbolRotate: 180,
- label: {position: 'insideBottom', distance: 8},
- itemStyle: {color: getColor(min)}
- }
- ]
- },
- itemStyle: {
- normal: {
- color: "rgba(244,81,108,0.8)",
- }
- },
- data: seriesData,
- });
- return option
- }
- // 功率趋势图
- var powerChartCondition = $scope.powerChartCondition = {
- "logicalCode": null,
- "port": null,
- startTime: moment().format("YYYY-MM-DD"),
- endTime: moment().format("YYYY-MM-DD")
- };
- var powerChartPanel;
- $scope.showPowerChart = function (entity) {
- $("#powerChartInfoPanel").modal();
- powerChartCondition.logicalCode = entity.logicalCode;
- powerChartCondition.port = entity.port;
- //展示趋势图
- powerChartPanel = echarts.init(document.getElementById('powerChartPanel')); //resize事件绑定
- $(window).off("resize.powerChartPanel").on("resize.powerChartPanel", function () {
- powerChartPanel.resize();
- });
- loadPowerChartData();
- };
- $scope.closePowerChart = function () {
- $("#powerChartInfoPanel").modal('hide');
- };
- var loadPowerChartData = $scope.loadPowerChartData = function () {
- var params = powerChartCondition;
- let url = '/common/getPowerGraph'
- //获取数据
- $http.get(url, {
- params: {
- logicalCode: params.logicalCode,
- port: params.port,
- startTime: params.startTime + ' 00:00:00',
- endTime: params.endTime + ' 23:59:59',
- }
- }).then(function (data) {
- var payload = data.data.payload
- var option = powerChartOption(payload.dataList);
- powerChartPanel.setOption(option);
- });
- };
- function powerChartOption(dataList) {
- var xData = [];
- var seriesData = [];
- for (var index in dataList) {
- var item = dataList[index]
- xData.push(moment(item.dateStr).format("MM-DD HH:mm:ss"));
- seriesData.push(parseFloat(item.power));
- }
- var option = {
- legend: {
- show: false
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- lineStyle: {
- color: '#108EE9',
- width: .3,
- }
- }
- },
- grid: {
- x: 40,
- x2: 15,
- y: 45,
- y2: 40,
- },
- xAxis: [
- {
- type: 'category',
- axisLabel: {
- textStyle: {
- color: "#aaa",
- fontSize: "12px"
- }
- },
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- data: xData
- }
- ],
- yAxis: [
- {
- type: 'value',
- axisLabel: {
- textStyle: {
- color: "#aaa",
- fontSize: "12px"
- }
- },
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- splitLine: {
- lineStyle: {
- color: '#ccc',
- width: 0.3,
- type: 'dotted'
- }
- },
- },
- ],
- series: []
- };
- option.series.push({
- name: '功率',
- stack: '功率',
- type: 'line',
- symbolSize: 0,
- itemStyle: {
- normal: {
- color: "rgba(244,81,108,0.8)",
- }
- },
- data: seriesData,
- });
- return option
- }
- // 续费记录
- $scope.chargeRecord = [];
- // 查询记录
- $scope.queryChargeRecord = function (entity) {
- $scope.chargeRecord = entity.chargeRecord || []
- $("#chargeRecordForm").modal();
- }
- function getSelectRows() {
- var rows = $scope.gridApi.selection.getSelectedRows();
- if (rows.length === 0) {
- toaster.pop("info", "提示", "请选择数据!");
- return false;
- }
- var ids = [];
- for (var i = 0; i < rows.length; i++) {
- ids.push(rows[i].logicalCode);
- }
- $scope.selectedIds = ids;
- return ids
- }
- $scope.manualRechargeSimCard = function () {
- var ids = getSelectRows()
- if (!ids) {
- return
- }
- $.confirm({
- content: '您选择的设备为 ' + ids + ' ,确认手动续费?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/manualRechargeSimCard',
- data: {logicalCode: ids}
- }).then(function (response) {
- initDataGrid();
- }, function (response) {
- toaster.pop("error", "提示", "续费失败!");
- });
- }
- },
- }
- });
- }
- $scope.lockDeviceSimStatus = function () {
- var ids = getSelectRows()
- if (!ids) {
- return
- }
- $.confirm({
- content: '您选择的设备为 ' + ids + ' ,确认操作?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- text: '锁定',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/lockDeviceSimStatus',
- data: {logicalCode: ids}
- }).then(function (response) {
- initDataGrid(true);
- toaster.pop("success", "提示", "锁定成功!");
- }, function (response) {
- toaster.pop("error", "提示", "锁定失败!");
- });
- }
- },
- unlock: {
- btnClass: 'btn-green',
- text: '解锁',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/unlockDeviceSimStatus',
- data: {logicalCode: ids}
- }).then(function (response) {
- initDataGrid(true);
- toaster.pop("success", "提示", "解锁成功!");
- }, function (response) {
- toaster.pop("error", "提示", "解锁失败!");
- });
- }
- },
- close: {
- isHidden: true
- },
- }
- });
- }
- $scope.changeDevCode = function (entity) {
- $scope.changeDevCodeForm.$setPristine();
- $scope.changeDevCodeForm.$setUntouched();
- var ids = getSelectRows()
- if (!ids) {
- return
- }
- $scope.dialogData = {logicalCodeList: ids};
- $("#changeDevCodeForm").modal();
- }
- $scope.changeDevCodeSave = function () {
- if ($scope.changeDevCodeForm.$invalid) {
- return;
- }
- $.confirm({
- content: '您选择的设备为 ' + $scope.dialogData.logicalCodeList + ' ,确认修改Code?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/modifyDeviceCode',
- data: {
- logicalCodeList: $scope.dialogData.logicalCodeList,
- code: $scope.dialogData.code
- }
- }).then(function (response) {
- console.log(response.data.description, response.data.payload)
- toaster.pop("success", "提示", response.data.description);
- $('#changeDevCodeForm').modal('hide');
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- }, function (response) {
- toaster.pop("error", "提示", "修改Code失败!");
- });
- }
- },
- }
- });
- }
- $scope.serviceSwitch = function (key, value) {
- var ids = getSelectRows()
- if (!ids) {
- return
- }
- let data = {
- logicalCode: ids,
- }
- data[key] = value
- $.confirm({
- content: '您选择的设备为 ' + ids + ' ,确认操作?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: '/superadmin/setServiceButtonStatus',
- data: data
- }).then(function (response) {
- toaster.pop("success", "提示", '操作成功');
- }, function (response) {
- toaster.pop("error", "提示", "操作失败!");
- });
- }
- },
- }
- });
- }
- }]);
|