/*
|
* @Description:
|
* @Version: 1.0
|
* @Author: yangsx
|
* @Date: 2019-12-09 19:01:40
|
* @LastEditors: yangsx
|
* @LastEditTime: 2019-12-14 14:44:57
|
*/
|
define([
|
"dojo",
|
"dojo/_base/declare",
|
"dojo/_base/lang",
|
"base/BaseWidget",
|
"dojo/text!widgets/realTimePolice/template.html",
|
"base/AppEvent",
|
"base/ConfigData",
|
"widgets/realTimePolice/config",
|
"dojo/dom",
|
"dojo/dom-construct",
|
"dojo/dom-attr",
|
"dojo/dom-style",
|
"dojo/on",
|
"esri/layers/ArcGISDynamicMapServiceLayer",
|
"esri/layers/ArcGISTiledMapServiceLayer",
|
"esri/layers/FeatureLayer",
|
"controls/tab/TabControl",
|
"esri/dijit/SymbolStyler",
|
"esri/styles/basic",
|
"dojo/_base/array",
|
"esri/InfoTemplate",
|
"esri/tasks/query",
|
"esri/tasks/QueryTask",
|
"esri/Color",
|
"esri/graphic",
|
"esri/geometry/Point",
|
"esri/tasks/FeatureSet",
|
"esri/renderers/HeatmapRenderer",
|
"esri/symbols/SimpleLineSymbol",
|
"esri/symbols/SimpleFillSymbol",
|
"esri/symbols/PictureMarkerSymbol",
|
"esri/symbols/SimpleMarkerSymbol",
|
"esri/SpatialReference",
|
"esri/tasks/GeometryService",
|
"esri/tasks/ProjectParameters",
|
"esri/layers/GraphicsLayer",
|
"esri/layers/LabelLayer",
|
"esri/symbols/TextSymbol",
|
"esri/renderers/SimpleRenderer",
|
"esri/renderers/ClassBreaksRenderer",
|
"esri/tasks/Geoprocessor",
|
"esri/tasks/DataFile",
|
"esri/geometry/webMercatorUtils",
|
"esri/symbols/Font",
|
"esri/geometry/ScreenPoint",
|
"esri/layers/ImageParameters",
|
"esri/geometry/geometryEngine",
|
"dojo/domReady!"
|
], function (
|
dojo,
|
declare,
|
lang,
|
BaseWidget,
|
template,
|
AppEvent,
|
ConfigData,
|
config,
|
dom,
|
domConstruct,
|
domAttr,
|
domStyle,
|
on,
|
ArcGISDynamicMapServiceLayer,
|
ArcGISTiledMapServiceLayer,
|
FeatureLayer,
|
TabControl,
|
SymbolStyler,
|
basic,
|
arrayUtils,
|
InfoTemplate,
|
Query,
|
QueryTask,
|
Color,
|
Graphic,
|
Point,
|
FeatureSet,
|
HeatmapRenderer,
|
SimpleLineSymbol,
|
SimpleFillSymbol,
|
PictureMarkerSymbol,
|
SimpleMarkerSymbol,
|
SpatialReference,
|
GeometryService,
|
ProjectParameters,
|
GraphicsLayer,
|
LabelLayer,
|
TextSymbol,
|
SimpleRenderer,
|
ClassBreaksRenderer,
|
Geoprocessor,
|
DataFile,
|
webMercatorUtils,
|
Font,
|
ScreenPoint,
|
ImageParameters,
|
geometryEngine
|
) {
|
var Widget = declare([BaseWidget], {
|
widgetName: "ClientManagement",
|
label: "客户管理",
|
templateString: template,
|
_map: null,
|
objThis: null,
|
_siteLayer: new GraphicsLayer(),
|
layuiLayer: null,
|
layuiLadate: null,
|
tabIndex: 0,
|
|
// 保留添加实体图层的变量
|
realTimeAddEntitys: null,
|
entitysData: [],
|
realTimeEquipment: [],
|
layerIndex: null,
|
historyPoliceData: [],
|
historyPoliceId: null,
|
realTimeQuery: null,
|
constructor: function (options, srcRefNode) {
|
this._map = options.map;
|
objThis = this;
|
|
|
|
|
this.realTimeAddEntitys = new GraphicsLayer({ id: 'realTimeAddEntitys' });
|
this.addOneEntitys = new GraphicsLayer({ id: 'addOneEntitys' });
|
this.addTwoEntitys = new GraphicsLayer({ id: 'addTwoEntitys' });
|
this.addThreeEntitys = new GraphicsLayer({ id: 'addThreeEntitys' });
|
|
this._map.addLayer(this.realTimeAddEntitys);
|
this._map.addLayer(this.addOneEntitys);
|
},
|
startup: function () {
|
objThis._map.addLayer(objThis._siteLayer);
|
var that = this;
|
// 顶部tab得切换事件
|
$('.real-time-police-tab li').off('click').click(function () {
|
layui.use('layer', function () {
|
layui.layer.closeAll();
|
})
|
if (that.tabIndex == $(this).index()) return;
|
|
|
if (that.entitysData.length > 0) {
|
that.realTimeAddEntitys.clear();
|
that.entitysData = [];
|
}
|
|
|
if ($(this).index() == 0) {
|
if (!$('.real-time-police .layer-realtime-equipment').is(':hidden')) {
|
$('.real-time-police .layer-realtime-equipment .close').trigger('click');
|
}
|
that.getRealTimePoliceTable($('.realtime-container-police').find('.tbody tbody'), 0);
|
that.layerRealtime();
|
} else {
|
window.clearTimeout(that.realTimeQuery);
|
that.realTimeEquipment = [];
|
that.treeStructure();
|
}
|
|
|
$(this).addClass('on').siblings().removeClass('on');
|
var ind = $(this).index();
|
$($('.realtime-container > div')[ind]).stop().show().siblings().stop().hide();
|
|
|
that.tabIndex = $(this).index();
|
})
|
|
|
|
|
// 时间查询
|
$('#policeSelectTime').off('click').click(function () {
|
var times = $(this).prevAll();
|
// 开始时间
|
var startTime = $(times[1]).val();
|
// 结束时间
|
var endTime = $(times[0]).val();
|
var text = $('#policeCategory div:eq(0)').text().trim();
|
that.getPoliceTable($('.realtime-container-police').find('.tbody tbody'), startTime, endTime, text == '全部' ? '' : text);
|
})
|
|
// 警情列表中的点击事件
|
$('.realtime-container-police .realtime-table-content .tbody').off('click', 'tr').on('click', 'tr', function () {
|
|
var id = $(this).attr('term-list');
|
var deviceNumber = $(this).attr('deviceNumber');
|
var lgtd = Number($(this).attr('lgtd'));
|
var lttd = Number($(this).attr('lttd'));
|
|
var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 }));//根据输入坐标信息找地图上的点
|
that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
|
|
console.log(that._map, 111111111);
|
|
|
that.realTimePoliceDetails(id, deviceNumber);
|
|
})
|
|
// 设备列表中的点击事件
|
$('.realtime-container-equipment .realtime-table-content .tbody').off('click', 'tr').on('click', 'tr', function () {
|
|
|
var id = $(this).attr('term-listid');
|
|
|
var url = '/popup/html/equipment-details.html?obj=' + id;
|
|
layui.use('layer', function () {
|
|
that.layuiLayer = layui.layer;
|
that.layuiLayer.config({
|
extend: 'myskin/equipment-details.css'
|
});
|
|
that.layuiLayer.close(that.layuiLayer.index);
|
|
that.layuiLayer.open({
|
title: '警情详情',
|
type: 2,
|
shadeClose: true,
|
shade: false,
|
maxmin: false, //开启最大化最小化按钮
|
area: ['520px', '320px'],
|
offset: 'auto',
|
skin: 'equipment-details',
|
content: url,
|
closeBtn: 1,
|
resize: false
|
});
|
})
|
})
|
|
// 音频的播放关闭
|
$('.real-time-police .layer-realtime-police .audio').off('click').click(function () {
|
var audio = $(this).children('audio');
|
if ($(this).hasClass('open')) {
|
audio[0].pause();
|
$(this).removeClass('open').addClass('close');
|
} else {
|
audio[0].play()
|
$(this).removeClass('close').addClass('open');
|
|
}
|
|
// $(this).children('audio').$('div').hasClass('redColor')
|
})
|
|
// 报警的切换 向上
|
$('.real-time-police .layer-realtime-police .bottom-tab .up-tab').off('click').click(function () {
|
|
var list = $('.real-time-police .layer-realtime-police ul li');
|
if ($(this).hasClass('on')) {
|
if ($('.real-time-police .bottom-tab .down-tab').hasClass('off')) {
|
$('.real-time-police .bottom-tab .down-tab').removeClass('off').addClass('on');
|
}
|
if (list.length > 0) {
|
for (var i = 0; i < list.length; i++) {
|
if ($(list[i]).hasClass('on')) {
|
$(list[i]).removeClass('on').prev().addClass('on');
|
if (i - 1 == 0) {
|
$(this).removeClass('on').addClass('off');
|
break;
|
} else {
|
break
|
}
|
}
|
}
|
}
|
}
|
|
})
|
|
// 报警的切换 向下
|
$('.real-time-police .layer-realtime-police .bottom-tab .down-tab').off('click').click(function () {
|
var list = $('.real-time-police .layer-realtime-police ul li');
|
if ($(this).hasClass('on')) {
|
if ($('.real-time-police .bottom-tab .up-tab').hasClass('off')) {
|
$('.real-time-police .bottom-tab .up-tab').removeClass('off').addClass('on');
|
}
|
console.log(list);
|
if (list.length > 0) {
|
for (var i = 0; i < list.length; i++) {
|
if ($(list[i]).hasClass('on')) {
|
$(list[i]).removeClass('on').next().addClass('on');
|
if (i == list.length - 2) {
|
$(this).removeClass('on').addClass('off');
|
break;
|
} else {
|
break
|
}
|
}
|
}
|
}
|
}
|
})
|
|
// 实时提醒的关闭
|
$('.real-time-police .layer-realtime-police .layer-header .close').off('click').click(function () {
|
$('.real-time-police .layer-realtime-police').stop().hide();
|
$('.real-time-police .layer-realtime-police .audio audio')[0].pause();
|
that.layerRealtime();
|
})
|
|
// 设置设备布撤防
|
$('.real-time-police .layer-realtime-equipment .bottom-preservation input').off('click').click(function () {
|
var devicenumber = $('.layer-realtime-equipment .device-management-box tbody tr:eq(5)').attr('deviceNumber');
|
var devicename = $('.layer-realtime-equipment .device-management-box tbody tr:eq(5)').attr('deviceName');
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/deploy/deploy/updateb',
|
type: 'POST',
|
data: {
|
devicenumber: devicenumber,
|
devicename: devicename,
|
btime: $('#startDeploymentAndWithdrawal').val(),
|
etime: $('#endDeploymentAndWithdrawal').val(),
|
btype: $('.layer-realtime-equipment .device-management-box tbody select').find("option:selected").val() == '布防' ? '1' : '0'
|
},
|
success: function (data) {
|
if (data.msg == '修改成功') {
|
console.log(data.msg);
|
$('.real-time-police .layer-realtime-equipment .close').trigger('click');
|
}
|
}
|
})
|
})
|
|
// 关闭设备布撤防显示详情
|
$('.real-time-police .layer-realtime-equipment .close').off('click').click(function () {
|
$('.real-time-police .layer-realtime-equipment .device-management-box tbody').empty();
|
$('.real-time-police .layer-realtime-equipment').stop().hide();
|
})
|
|
// 接警信息中类别移入事件
|
$('#realtimeDistrict').mouseenter(function () {
|
if ($('#realtimeDistrict .select-list').is(':hidden')) {
|
$('#realtimeDistrict .select-list').stop().slideDown(0);
|
}
|
})
|
// 接警信息中得类别移出事件
|
$('#realtimeDistrict').mouseleave(function () {
|
if (!$('#realtimeDistrict .select-list').is(':hidden')) {
|
$('#realtimeDistrict .select-list').stop().slideUp(0);
|
}
|
})
|
// 接警信息中的等级移入事件
|
$('#realtimeLevel').mouseenter(function () {
|
if ($('#realtimeLevel .select-list').is(':hidden')) {
|
$('#realtimeLevel .select-list').stop().slideDown(0);
|
}
|
})
|
// 接警信息中的等级移出事件
|
$('#realtimeLevel').mouseleave(function () {
|
if (!$('#realtimeLevel .select-list').is(':hidden')) {
|
$('#realtimeLevel .select-list').stop().slideUp(0);
|
}
|
})
|
|
|
// 警情信息类,接警信息类,设备信息类别,具体项的点击事件
|
$('.realtime-container > div .select-list').off('click', 'li').on('click', 'li', function (event) {
|
|
var text = $(this).text();
|
var dataArr = [];
|
|
var textOne = '';
|
var textTwo = '';
|
$(this).parent().parent().prev().html(text + '<i></i>');
|
$(this).parent().parent().stop().slideUp(0);
|
|
if (that.entitysData.length > 0) {
|
that.realTimeAddEntitys.clear();
|
that.entitysData = [];
|
}
|
|
|
if ($(this).attr('addvcd')) {
|
textOne = $(this).text();
|
textTwo = $('#realtimeLevel >div:eq(0)').text().trim();
|
} else {
|
textOne = $("#realtimeDistrict >div:eq(0)").text().trim();
|
textTwo = $(this).text();
|
}
|
|
if (textOne == '全部') {
|
if (textTwo == '全部') {
|
dataArr = that.historyPoliceData;
|
} else {
|
for (var i = 0; i < that.historyPoliceData.length; i++) {
|
if (textTwo == that.historyPoliceData[i].waringType) {
|
dataArr.push(that.historyPoliceData[i]);
|
}
|
}
|
}
|
} else {
|
if (textTwo == '全部') {
|
for (var i = 0; i < that.historyPoliceData.length; i++) {
|
if (textOne == that.historyPoliceData[i].addvnm) {
|
dataArr.push(that.historyPoliceData[i]);
|
}
|
}
|
} else {
|
for (var i = 0; i < that.historyPoliceData.length; i++) {
|
if (textTwo == that.historyPoliceData[i].waringType && textOne == that.historyPoliceData[i].addvnm) {
|
dataArr.push(that.historyPoliceData[i]);
|
}
|
}
|
}
|
}
|
|
|
that.condition(dataArr, $('.realtime-container-police').find('.tbody tbody'));
|
|
|
})
|
},
|
open: function () {
|
|
|
$('.real-time-police .realtime-container .realtime-district .select-list ul').empty();
|
$('.real-time-police .realtime-container .realtime-district .select-list ul').append("<li addvcd='orr'>全部</li>");
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/district/district/selectList',
|
type: 'POST',
|
dataType: 'JSON',
|
success: function (data) {
|
console.log(data, 2222222);
|
for (var i = 0; i < data.data.length; i++) {
|
$('.real-time-police .realtime-container .realtime-district .select-list ul').append("<li addvcd=" + data.data[i].addvcd + ">" + data.data[i].addvnm + "</li>");
|
}
|
}
|
})
|
|
|
|
var that = this;
|
|
that.tabIndex = 0;
|
|
$('.real-time-police .realtime-container-police').stop().show().siblings().stop().hide();
|
$('.real-time-police .real-time-police-tab li:eq(0)').removeClass().addClass('on').siblings().removeClass();
|
|
|
|
that.getRealTimePoliceTable($('.realtime-container-police').find('.tbody tbody'), 0);
|
that.clickHand();
|
that.layerRealtime();
|
|
window.deleteRealtimePolice = function (id) {
|
|
if (that.layuiLayer != null) {
|
that.layuiLayer.closeAll();
|
|
that.layerIndex = null;
|
|
}
|
|
for (var i = 0; i < that.historyPoliceData.length; i++) {
|
if (id == that.historyPoliceData[i].id) {
|
that.historyPoliceData.splice(i, 1);
|
break;
|
|
}
|
}
|
|
var list = $('.realtime-container-police').find('.tbody tbody tr');
|
for (var i = 0; i < list.length; i++) {
|
if ($(list[i]).attr('term-list') == id) {
|
list[i].remove();
|
break;
|
}
|
}
|
|
for (var i = 0; i < that.realTimeAddEntitys.graphics.length; i++) {
|
if (id == that.realTimeAddEntitys.graphics[i].geometry.entityData.id) {
|
that.realTimeAddEntitys.remove(that.realTimeAddEntitys.graphics[i])
|
break;
|
}
|
}
|
|
for (var i = 0; i < that.entitysData.length; i++) {
|
if (id == that.entitysData[i].id) {
|
that.entitysData.splice(i, 1);
|
break;
|
}
|
}
|
|
var listtd = $('.realtime-container-police').find('.tbody tbody tr');
|
for (var i = 0; i < listtd.length; i++) {
|
console.log(i);
|
$(listtd[i]).children('td:eq(0)').text(Number(i) + 1);
|
}
|
}
|
|
|
},
|
|
close: function () {
|
var that = this;
|
window.clearTimeout(that.realTimeQuery);
|
if (that.layuiLayer != null) {
|
that.layuiLayer.closeAll();
|
|
that.layerIndex = null;
|
|
}
|
if (that.entitysData.length > 0) {
|
that.realTimeAddEntitys.clear();
|
that.entitysData = [];
|
}
|
if (!$('.real-time-police .layer-realtime-police').is(':hidden')) {
|
$('.real-time-police .layer-realtime-police').stop().hide();
|
}
|
if (!$('.real-time-police .layer-realtime-equipment').is(':hidden')) {
|
$('.real-time-police .layer-realtime-equipment .close').trigger('click');
|
}
|
},
|
|
// 鼠标点击事件
|
clickHand: function () {
|
var self = this;
|
|
|
self._map.onClick = mapClick;
|
|
|
function mapClick(evt) {
|
|
if (evt.graphic) {
|
var result = evt.graphic.geometry.entityData;
|
var liText = evt.graphic.symbol.name;
|
if (liText == '实时报警') {
|
self.realTimePoliceDetails(result.id, result.deviceNumber);
|
} else if (liText == '传感器管理') {
|
self.realEquipmentManage(result.id, result.deviceNumber);
|
}
|
}
|
}
|
},
|
|
// 实时警情详情
|
realTimePoliceDetails: function (id, deviceNumber) {
|
var that = this;
|
var url = '/popup/html/realtime-police-details.html?obj=' + id + '&deviceNumber=' + deviceNumber;
|
|
layui.use('layer', function () {
|
that.layuiLayer = layui.layer;
|
that.layuiLayer.config({
|
extend: 'myskin/realtime-police-details.css'
|
});
|
|
that.layuiLayer.closeAll();
|
that.layerIndex = null;
|
|
that.layerIndex = that.layuiLayer.open({
|
title: '警情详情',
|
type: 2,
|
shadeClose: true,
|
shade: false,
|
maxmin: false, //开启最大化最小化按钮
|
area: ['756px', '368px'],
|
offset: 'auto',
|
skin: 'realtime-police-details',
|
content: url,
|
closeBtn: 1,
|
resize: false
|
});
|
})
|
},
|
|
// 传感器管理点击事件
|
realEquipmentManage: function (id, deviceNumber) {
|
layui.use('laydate', function () {
|
var laydate = layui.laydate;
|
if (!$('.real-time-police .layer-realtime-equipment').is(':hidden')) {
|
$('.real-time-police .layer-realtime-equipment .close').trigger('click');
|
}
|
|
$('.layer-realtime-equipment').stop().show();
|
|
var str = '';
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/equipment/equipment/detail?id=' + id,
|
type: 'GET',
|
dataType: 'JSON',
|
success: function (data) {
|
var result = data.data;
|
|
str += "<tr> <td>设备名称:</td> <td>" + result.deviceName + "</td> <td>设备编码:</td> <td>" + result.deviceNumber + "</td> </tr>";
|
str += "<tr> <td>设备类型:</td> <td>" + result.deviceType + "</td> <td>权属:</td> <td>" + result.ownership + "</td> </tr>";
|
str += "<tr> <td>行政区编码:</td> <td>" + result.addvcd + "</td> <td>行政区:</td> <td>" + result.addvnm + "</td> </tr>";
|
str += "<tr> <td>街道:</td> <td>" + result.streeName + "</td> <td>安装时间:</td> <td>" + result.stime + "</td> </tr>";
|
str += "<tr> <td>设备状态:</td> <td>" + (result.dtype == '' ? '' : (result.dtype == '2' ? '报警' : (result.dtype == '1' ? '测试' : '掉线'))) + "</td> <td>布撤防状态:</td> <td>" + (result.devicestate == 1 ? '布防' : '撤防') + "</td> </tr>";
|
str += "<tr deviceName='" + result.deviceName + "' deviceNumber='" + result.deviceNumber + "'> <td>布撤防设定:</td> <td> <input type='text' readonly id='startDeploymentAndWithdrawal' placeholder='开始时间'> <input type='text' readonly id='endDeploymentAndWithdrawal' placeholder='结束时间'> <select name='' id='realTimeDeploymentAndWithdrawal'> <option value='布防'>布防</option> <option value='撤防'>撤防</option> </select> </td> </tr>";
|
$('.layer-realtime-equipment .device-management-box tbody').append(str);
|
// 获取设备布撤防信息
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/deploy/deploy/selectInfo',
|
type: 'POST',
|
data: {
|
devicenumber: deviceNumber
|
},
|
success: function (data) {
|
var data = data.data[0];
|
$('#startDeploymentAndWithdrawal').val(data.btime);
|
$('.layer-realtime-equipment .device-management-box tbody select').val(data.btype == '1' ? '布防' : '撤防');
|
$('#endDeploymentAndWithdrawal').val(data.etime);
|
|
}
|
})
|
|
laydate.render({
|
elem: '#startDeploymentAndWithdrawal'
|
, type: 'time'
|
, trigger: 'click'
|
})
|
|
laydate.render({
|
elem: '#endDeploymentAndWithdrawal'
|
, type: 'time'
|
, trigger: 'click'
|
})
|
|
}
|
})
|
|
})
|
},
|
|
// 定时器,定时发送请求,监听是否有新的报警
|
layerRealtime: function () {
|
var that = this;
|
that.realTimeQuery = setInterval(function () {
|
if (that.historyPoliceId != null) {
|
console.log(that.historyPoliceId);
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/alarm/alarm/selecttx',
|
type: 'POST',
|
dataType: 'JSON',
|
data: {
|
id: that.historyPoliceId
|
},
|
success: function (data) {
|
if (data.data.length > 0) {
|
// 清除页面中的其他弹框
|
if (that.layuiLayer != null) {
|
that.layuiLayer.closeAll();
|
|
that.layerIndex = null;
|
|
}
|
// 清除定时器
|
window.clearTimeout(that.realTimeQuery);
|
// 清除ul中内容(存储新增的报警信息)
|
$('.real-time-police .layer-realtime-police ul').empty();
|
// 新增警情的面板
|
$('.real-time-police .layer-realtime-police').stop().show();
|
|
// 检测audio标签父元素的类名
|
if (!$('.real-time-police .layer-realtime-police .audio').hasClass('open')) {
|
$('.real-time-police .layer-realtime-police .audio').removeClass().addClass('audio open')
|
}
|
|
// 判断数据长度是否大于1,如果是,则显示上下页切换
|
if (data.data.length > 1) {
|
$('.real-time-police .layer-realtime-police .bottom-tab').stop().show();
|
}
|
// audio标签播放
|
$('.real-time-police .layer-realtime-police .audio audio')[0].play();
|
// 获取警情列表的dom用来更行警情列表
|
var dom = $('.realtime-container-police').find('.tbody tbody');
|
// 保存返回的数据,方便操作
|
var result = data.data;
|
var str = '';
|
var tableStr = '';
|
// 记录最新的一个id
|
that.historyPoliceId = result[result.length - 1].id;
|
var li = $('<li></li>');
|
var table = $('<table></table>');
|
var tbody = $('<tbody></tbody>');
|
|
var addvnmList = $('.real-time-police .realtime-container .realtime-district .select-list ul li');
|
for (var a, time, t, e, y, h, gt, i = 0; i < result.length; i++) {
|
that.historyPoliceData.unshift(result[i]);
|
that.createEntitys(that.realTimeAddEntitys, that.entitysData, '实时报警', { lgtd: result[i].jd, lttd: result[i].wd, id: result[i].id, deviceNumber: result[i].deviceNumber }, result[i].jd, result[i].wd, '/views/map/images/real-time-callPolice.png');
|
|
t = result[i].alarmTime.substr(0, 10);
|
e = result[i].alarmTime.substr(11);
|
time = t + ' ' + e;
|
y = result[i].alarmTime.substr(0, 10);
|
h = result[i].alarmTime.substr(11);
|
gt = y + ' ' + h;
|
str += "<tr> <td>报警人:</td> <td>" + result[i].galarmPeople + "</td> <td>性别:</td> <td>" + (result[i].sex == 1 ? '女' : '男') + "</td> </tr>";
|
str += "<tr> <td>联系电话:</td> <td>" + result[i].phoneNumber + "</td> <td>事发地址:</td> <td>" + result[i].place + "</td> </tr>";
|
str += "<tr> <td>警情类别:</td> <td>" + result[i].waringType + "</td> <td>设备编号:</td> <td>" + result[i].deviceNumber + "</td> </tr>";
|
str += "<tr> <td>接警人:</td> <td>" + result[i].alarmPeople + "</td> <td>接警时间:</td> <td>" + gt + "</td> </tr>";
|
str += "<tr> <td>报警时间:</td> <td>" + time + "</td> <td>行政区:</td> <td>" + result[i].addvnm + "</td> </tr>";
|
str += "<tr> <td>报警内容:</td> <td>" + result[i].content + "</td> </tr>";
|
|
|
li.append(table.append(tbody.append(str)));
|
$('.real-time-police .layer-realtime-police ul').append(li);
|
if (i == 0) {
|
li.addClass('on');
|
}
|
|
if (addvnmList.length > 0) {
|
for (var j = 0; j < addvnmList.length; j++) {
|
if (result[i].addvnm != $(addvnmList[j]).text()) {
|
if (j == addvnmList.length - 1) {
|
$('.real-time-police .realtime-container .realtime-district .select-list ul').append("<li addvcd=" + result[i].addvcd + ">" + result[i].addvnm + "</li>");
|
}
|
}
|
}
|
} else {
|
$('.real-time-police .realtime-container .realtime-district .select-list ul').append("<li addvcd=" + result[i].addvcd + ">" + result[i].addvnm + "</li>");
|
}
|
|
|
|
str = '';
|
|
}
|
|
dom.empty();
|
for (var a, time, t, e, y, h, i = 0; i < that.historyPoliceData.length; i++) {
|
t = that.historyPoliceData[i].alarmTime.substr(0, 10);
|
e = that.historyPoliceData[i].alarmTime.substr(11);
|
time = t + ' ' + e;
|
y = that.historyPoliceData[i].alarmTime.substr(5, 5);
|
h = that.historyPoliceData[i].alarmTime.substr(11, 5);
|
a = Number(i) + 1;
|
tableStr += '<tr lgtd=' + that.historyPoliceData[i].jd + ' lttd=' + that.historyPoliceData[i].wd + ' term-list=' + that.historyPoliceData[i].id + ' deviceNumber=' + that.historyPoliceData[i].deviceNumber + '>';
|
tableStr += '<td>' + a + '</td>';
|
tableStr += '<td>' + that.historyPoliceData[i].deviceNumber + '</td>';
|
tableStr += '<td>' + that.historyPoliceData[i].addvnm + '</td>';
|
tableStr += '<td>' + that.historyPoliceData[i].waringType + '</td>';
|
tableStr += "<td><a href='javascript:;' title=" + time + ">" + y + ' ' + h + "</a></td>";
|
tableStr += '</tr>';
|
dom.append(tableStr);
|
tableStr = '';
|
}
|
|
}
|
|
}
|
})
|
}
|
|
}, 5000)
|
},
|
|
//热力图渲染器,加载热力图
|
heatmFeaLayers: function () {
|
|
var layerDefinition = {
|
"geometryType": "esriGeometryPoint",
|
"fields": [{
|
"num": "num",
|
editable: true,
|
nullable: true,
|
"type": "esriFieldTypeInteger",
|
"alias": "数量"
|
}]
|
};
|
var featureCollection = {
|
layerDefinition: layerDefinition,
|
featureSet: null
|
};
|
//创建 FeatureLayer 图层
|
var featureLayer = new esri.layers.FeatureLayer(featureCollection, {
|
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
|
outFields: ["*"],
|
opacity: .8
|
});
|
//设置渲染方式
|
|
return featureLayer;
|
},
|
|
// 获取当前时间,以及昨天现在的时间
|
getTime: function getTime() {
|
var timestamp = Date.parse(new Date());
|
|
// 当前时间
|
var currentTime = new Date(timestamp);
|
// 年
|
var currentY = currentTime.getFullYear();
|
// 月
|
var currentM = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1;
|
// 日
|
var currentD = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
|
// 时
|
var currentH = currentTime.getHours() < 10 ? '0' + currentTime.getHours() : currentTime.getHours();
|
// 分
|
var currentDd = currentTime.getMinutes() < 10 ? '0' + currentTime.getMinutes() : currentTime.getMinutes();
|
// 明天
|
var tomorrowTime = new Date(timestamp - 60 * 60 * 24 * 1000);
|
// 年
|
var tomorrowY = tomorrowTime.getFullYear();
|
// 月
|
var tomorrowM = tomorrowTime.getMonth() + 1 < 10 ? '0' + (tomorrowTime.getMonth() + 1) : tomorrowTime.getMonth() + 1;
|
// 日
|
var tomorrowD = tomorrowTime.getDate() < 10 ? '0' + tomorrowTime.getDate() : tomorrowTime.getDate();
|
// 时
|
var tomorrowH = tomorrowTime.getHours() < 10 ? '0' + tomorrowTime.getHours() : tomorrowTime.getHours();
|
// 分
|
var tomorrowDd = tomorrowTime.getMinutes() < 10 ? '0' + tomorrowTime.getMinutes() : tomorrowTime.getMinutes();
|
return {
|
current: currentY + '-' + currentM + '-' + currentD + ' ' + currentH + ':' + currentDd,
|
tomorrow: tomorrowY + '-' + tomorrowM + '-' + tomorrowD + ' ' + tomorrowH + ':' + tomorrowDd,
|
month: currentM + currentD
|
};
|
},
|
|
// 获取警情信息列表
|
getRealTimePoliceTable: function (dom, jtype, addvcd, waringType) {
|
var that = this;
|
|
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/alarm/alarm/selectList',
|
type: 'POST',
|
dataType: 'JSON',
|
data: {
|
jtype: jtype,
|
addvcd: addvcd,
|
waringType: waringType
|
},
|
success: function (data) {
|
|
if (data.data.length == 0) return;
|
var result = data.data;
|
that.historyPoliceId = result[result.length - 1].id;
|
that.historyPoliceData = result;
|
that.condition(result, dom);
|
}
|
})
|
},
|
|
// 获取传感器信息列表
|
getOwnerTable: function (dom, type, dj) {
|
dom.empty();
|
var that = this;
|
$.ajax({
|
url: 'http://47.110.245.84:9031:80/suser/suser/selectList?type=' + type + '&dj=' + dj,
|
type: 'GET',
|
dataType: 'JSON',
|
success: function (data) {
|
var result = data.data;
|
var str = '';
|
var aa = 115.36;
|
var bb = 28.28;
|
for (var a, i = 0; i < result.length; i++) {
|
a = Number(i) + 1;
|
str += "<tr>";
|
str += '<td>' + a + '</td>';
|
str += '<td>' + result[i].type + '</td>';
|
str += '<td>' + result[i].dj + '</td>';
|
str += '<td>' + result[i].yname + '</td>';
|
str += '</tr>';
|
dom.append(str);
|
str = '';
|
}
|
|
that.entitysData = [];
|
that.realTimeAddEntitys.clear();
|
|
for (var i = 0; i < 500; i++) {
|
var dd = Math.random();
|
var cc = Math.random();
|
that.createEntitys(that.realTimeAddEntitys, that.entitysData, '业主信息', { lgtd: aa + dd, lttd: bb + cc }, aa + dd, bb + cc, 'views/map/images/owner.png');
|
}
|
}
|
})
|
},
|
|
// 创建实体图层
|
createEntitys: function (entitys, entityContent, name, item, lgtd, lttd, outlineColors) {
|
|
var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 16, 16);
|
symbol.name = name;
|
var pt = new Point(lgtd, lttd, new SpatialReference({ wkid: 4326 }));
|
pt.entityData = item;
|
var graphic = new esri.Graphic(pt, symbol);
|
entitys.add(graphic);
|
|
|
entityContent.push(item);
|
},
|
|
treeStructure: function () {
|
$('#ztree').empty();
|
var that = this;
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/district/district/selectList',
|
type: 'POST',
|
dataType: 'JSON',
|
success: function (data) {
|
console.log(data, 11111);
|
var result = data.data;
|
for (var i = 0; i < result.length; i++) {
|
|
that.realTimeEquipment.push({ title: result[i].addvnm, children: [] });
|
if (result[i].streetVOS.length > 0) {
|
that.realTimeEquipment[i].children = [];
|
for (var j = 0; j < result[i].streetVOS.length; j++) {
|
that.realTimeEquipment[i].children.push({ title: result[i].streetVOS[j].streeName, children: [] });
|
}
|
|
}
|
|
}
|
|
|
$.ajax({
|
url: 'https://s16s652780.51mypc.cn/api/jfpt/equipment/equipment/selectList?deviceType=',
|
type: 'GET',
|
dataType: 'JSON',
|
success: function (data) {
|
var data = data.data;
|
console.log(data, 2222222222);
|
|
|
var imgUrl = null;
|
|
for (var i = 0; i < data.length; i++) {
|
|
if (data[i].parentId != '0') {
|
|
if (data[i].devicestate == 1) { // bu fang
|
if (data[i].btype == '0') { // diao xian
|
imgUrl = 'views/map/images/diaoxian.png';
|
} else if (data[i].btype == '1') { // ce shi
|
imgUrl = 'views/map/images/ceshi.png';
|
} else if (data[i].btype == '2') { // bao jing
|
imgUrl = 'views/map/images/baojing.png';
|
}
|
} else if (data[i].devicestate == 0) { // che fang
|
if (data[i].btype == '0') {
|
imgUrl = 'views/map/images/diaoxian.png';
|
} else if (data[i].btype == '1') {
|
imgUrl = 'views/map/images/ceshi.png';
|
}
|
}
|
that.createEntitys(that.realTimeAddEntitys, that.entitysData, '传感器管理', { lgtd: data[i].jd, lttd: data[i].wd, id: data[i].id, deviceNumber: data[i].deviceNumber }, data[i].jd, data[i].wd, imgUrl);
|
|
|
|
for (var j = 0; j < that.realTimeEquipment.length; j++) {
|
|
if (data[i].addvnm == that.realTimeEquipment[j].title) {
|
if (that.realTimeEquipment[j].children && that.realTimeEquipment[j].children.length > 0) {
|
for (var k = 0; k < that.realTimeEquipment[j].children.length; k++) {
|
if (data[i].streeName == that.realTimeEquipment[j].children[k].title) {
|
if (that.realTimeEquipment[j].children[k].children) {
|
|
that.realTimeEquipment[j].children[k].children.push({ title: data[i].deviceName, id: data[i].id, field: data[i].deviceName, deviceNumber: data[i].deviceNumber, lgtd: data[i].jd, lttd: data[i].wd })
|
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
}
|
|
// var arr = [];
|
|
// for (var i = 0; i < 30; i++) {
|
// arr.push(that.realTimeEquipment[0]);
|
// }
|
|
|
|
|
layui.use(['tree', 'laydate'], function () {
|
var tree = layui.tree;
|
var laydate = layui.laydate;
|
//渲染
|
var inst1 = tree.render({
|
//绑定元素
|
elem: '#ztree',
|
data: that.realTimeEquipment,
|
// showCheckbox: true,
|
// edit: true
|
accordion: true,
|
click: function (obj) {
|
console.log(obj);
|
// console.log(obj.data); //得到当前点击的节点数据
|
// console.log(obj.state); //得到当前节点的展开状态:open、close、normal
|
// console.log(obj.elem); //得到当前节点元素
|
//
|
// console.log(obj.data.children); //当前节点下是否有子节点
|
|
if (!obj.data.children && obj.data.id) {
|
|
var id = obj.data.id;
|
var deviceNumber = obj.data.deviceNumber;
|
var position = new esri.geometry.Point(Number(obj.data.lgtd), Number(obj.data.lttd), new esri.SpatialReference({ wkid: 4326 }));//根据输入坐标信息找地图上的点
|
that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
|
that.realEquipmentManage(id, deviceNumber, obj.data.lgtd);
|
|
|
}
|
}
|
});
|
});
|
|
// console.log(that.realTimeEquipment)
|
|
}
|
})
|
}
|
})
|
},
|
|
condition: function (result, dom) {
|
dom.empty();
|
var that = this;
|
var str = '';
|
for (var a, time, t, e, y, h, i = 0; i < result.length; i++) {
|
that.createEntitys(that.realTimeAddEntitys, that.entitysData, '实时报警', { lgtd: result[i].jd, lttd: result[i].wd, id: result[i].id, deviceNumber: result[i].deviceNumber }, result[i].jd, result[i].wd, '/views/map/images/real-time-callPolice.png');
|
t = result[i].alarmTime.substr(0, 10);
|
e = result[i].alarmTime.substr(11);
|
time = t + ' ' + e;
|
y = result[i].alarmTime.substr(5, 5);
|
h = result[i].alarmTime.substr(11, 5);
|
a = Number(i) + 1;
|
str += '<tr lgtd=' + result[i].jd + ' lttd=' + result[i].wd + ' term-list=' + result[i].id + ' deviceNumber=' + result[i].deviceNumber + '>';
|
str += '<td>' + a + '</td>';
|
str += '<td>' + result[i].deviceNumber + '</td>';
|
str += '<td>' + result[i].addvnm + '</td>';
|
str += '<td>' + result[i].waringType + '</td>';
|
str += "<td><a href='javascript:;' title=" + time + ">" + y + ' ' + h + "</a></td>";
|
str += '</tr>';
|
dom.append(str);
|
str = '';
|
}
|
}
|
});
|
return Widget;
|
});
|