/////////////////////////////////////////////////////////////////////////// // Copyright © 2019 zhongsong. All Rights Reserved. // 模块描述:水文要素 /////////////////////////////////////////////////////////////////////////// define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', 'dojo/topic', 'jimu/BaseWidget'], function (declare, lang, array, html, topic, BaseWidget) { return declare([BaseWidget], { baseClass: 'jimu-widget-Hydrology', name: 'Hydrology', // 保存鼠标点击事件 hydroHandler3D: null, dataListEntity: [], flag: true, flagyl: false, flagsw: false, flagll: false, flagdxs: false, flagzf: false, flagsq: false, flagswen: false, flagaw: false, flagsz: false, flagns: false, hydroWellTabel: { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }, hydrofaultTabel: { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }, hydroQueryTabel: { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }, startup: function startup() { // this.inherited(arguments); // 暴露在外的接口 topic.subscribe("closehydrology", lang.hitch(this, this.closeHydro)); var that = this; // 注册点击事件 $(".jimu-widget-Hydrology .hydro-list-mean li a").click(function () { that.hydroWellTabel = { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }; that.hydrofaultTabel = { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }; that.hydroQueryTabel = { lgtd: [], lttd: [], tabletm: [], tablename: [], tabledata: [], num: null, str: [], comparisonValue: [] }; // 存放表格数据 that.flag = true; var tableObj = { tableTM: [], tableName: [], tableData: [], lgtd: [], lttd: [], num: null, comparisonValue: [] }; // 检测当前点击的A标签是否已经拥有类名ON,如已经如有,则删除地图上的实体,并且移除类名 if ($(this).hasClass('on')) { that.flag = false; // 并且删除实体 that.entityDelete(); $(this).removeClass('on'); return; } // 删除实体 that.entityDelete(); // 当前点击的a标签添加类名,兄弟移除类名 $(this).addClass('on').parent().siblings().children('a').removeClass('on'); // ind 记录当前点击的下标 var ind = $(this).parent().index(); that.flagyl = false; that.flagsw = false; that.flagll = false; that.flagdxs = false; that.flagzf = false; that.flagsq = false; that.flagswen = false; that.flagaw = false; that.flagsz = false; that.flagns = false; if (ind == 0) { that.flagyl = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/pptnr/drpOne?parttype=yl', type: "get", dataType: 'json', success: function success(data) { if (that.flagyl == true && that.flag != false) { tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && ((Date.parse(new Date()) - Date.parse(new Date(item.list.TM.substring(0, 11).replace(/-/g, '/') + item.list.TM.substring(11)))) < 86400000)) { that.entitys({ id: item.SiteList.site_code + "yl", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/js.png', text: item.list.DRP + " mm" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.fromBytes(103, 188, 214), het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "yl", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy0.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "yl"); tableObj.tableTM.push(item.list.TM); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list.DRP + ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 1) { that.flagsw = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/riverr/rthyinfo?parttype=sw', type: 'post', dataType: "json", success: function success(data) { if (that.flagsw == true && that.flag != false) { that.flag = true; tableObj.num = ind; var colorSl; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.TM.substring(0, 11).replace(/-/g, '/') + item.list.TM.substring(11))) < 86400000) { if (item.list.Z > item.list.yjsw) { colorSl = Cesium.Color.RED; } else { colorSl = Cesium.Color.SKYBLUE; } that.entitys({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/swei.png', text: item.list.Z + " M" + '\n' + item.SiteList.site_name, labOutColor: colorSl, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy1.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "sw"); tableObj.tableTM.push(item.list ? item.list.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.Z + "" : ''); tableObj.comparisonValue.push(item.list ? item.list.yjsw + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 2) { that.flagll = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/riverr/rthyinfo?parttype=ll', type: 'post', dataType: "json", success: function success(data) { if (that.flagll == true && that.flag != false) { that.flag = true; tableObj.num = ind; var colorSl; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.TM.substring(0, 11).replace(/-/g, '/') + item.list.TM.substring(11))) < 86400000) { if (item.list.Q > item.list.yjll) { colorSl = Cesium.Color.RED; } else { colorSl = Cesium.Color.SKYBLUE; } that.entitys({ id: item.SiteList.site_code + "ll", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/ll.png', text: item.list.Q + "m3/s" + '\n' + item.SiteList.site_name, labOutColor: colorSl, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "ll", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy2.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "ll"); tableObj.tableTM.push(item.list ? item.list.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.Q + "" : ''); tableObj.comparisonValue.push(item.list ? item.list.yjll + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 4) { that.flagzf = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/history/selectRealTimeByEv?parttype=zf', type: "post", dataType: 'json', success: function success(data) { if (that.flagzf == true && that.flag != false) { that.flag = true; tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list.sum_ev == undefined) { item.list.sum_ev = '0'; } if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.tm.substring(0, 11).replace(/-/g, '/') + item.list.tm.substring(11))) < 86400000) { that.entitys({ id: item.SiteList.site_code + "zf", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/zf.png', text: item.list.sum_ev + "%" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "zf", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy4.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "zf"); tableObj.tableTM.push(item.list ? item.list.tm : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.sum_ev + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 5) { that.flagsq = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/soilr/selectRealTimeBySoil?parttype=sq', type: "post", dataType: 'json', success: function success(data) { if (that.flagsq == true && that.flag != false) { that.flag = true; tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.tm.substring(0, 11).replace(/-/g, '/') + item.list.tm.substring(11))) < 86400000) { that.entitys({ id: item.SiteList.site_code + "zf", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/sq.png', text: item.list.srlslm + "%" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "zf", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy5.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "zf"); tableObj.tableTM.push(item.list ? item.list.tm : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.srlslm + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 6) { that.flagswen = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/tmpr/selectRealTimeByTmp?parttype=sw', type: "GET", dataType: 'json', success: function success(data) { if (that.flagswen == true && that.flag != false) { that.flag = true; tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.TM.substring(0, 11).replace(/-/g, '/') + item.list.TM.substring(11))) < 86400000) { that.entitys({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/sw.png', text: item.list.WTMP + "℃" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy6.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "sw"); tableObj.tableTM.push(item.list ? item.list.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.WTMP + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 7) { that.flagaw = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/tmpr/selectRealTimeByTmp?parttype=qw', type: "GET", dataType: 'json', success: function success(data) { if (that.flagaw == true && that.flag != false) { that.flag = true; tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.list && item.list != {} && Date.parse(new Date()) - Date.parse(new Date(item.list.TM.substring(0, 11).replace(/-/g, '/') + item.list.TM.substring(11))) < 86400000) { that.entitys({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/jw.png', text: item.list.ATMP + "℃" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy7.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "sw"); tableObj.tableTM.push(item.list ? item.list.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.ATMP + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 8) { that.flagsz = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/wq/selectWqRPage?parttype=sz', type: "post", dataType: 'json', success: function success(data) { if (that.flagsz == true && that.flag != false) { that.flag = true; tableObj.num = ind; data.data.forEach(function (item, index) { if (item.SiteList != '') { console.log(item) that.entitys({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/sz.png', text: item.list.WCHRCD + "类" + '\n' + item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); that.dataListEntity.push(item.SiteList.site_code + "sw"); tableObj.tableTM.push(item.list ? item.list.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.list ? item.list.WCHRCD + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 9) { that.flagns = true; $.ajax({ url: 'http://localhost:82/blade-ycreal/sedr/selectRealTimeBySed?parttype=ns', type: "GET", dataType: 'json', success: function success(data) { if (that.flagns == true && that.flag != false) { that.flag = true; tableObj.num = ind; console.log(data); data.data.forEach(function (item, index) { if (item.SiteList != '') { if (item.List && item.List != {} && Date.parse(new Date()) - Date.parse(new Date(item.List.TM.substring(0, 11).replace(/-/g, '/') + item.List.TM.substring(11))) < 86400000) { that.entitys({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/ns.png', text: item.List.S + "kg" + '\n' + +item.SiteList.site_name, labOutColor: Cesium.Color.SKYBLUE, het: 20 }); } else { that.whiteEntities({ id: item.SiteList.site_code + "sw", name: item.SiteList.site_name, x: Number(item.SiteList.lgtd), y: Number(item.SiteList.lttd), img: './images/hy9.png', text: item.SiteList.site_name, het: 20 }); } that.dataListEntity.push(item.SiteList.site_code + "sw"); tableObj.tableTM.push(item.List ? item.List.TM : ''); tableObj.tableName.push(item.SiteList.site_name); tableObj.tableData.push(item.List ? item.List.S + "" : ''); tableObj.lgtd.push(item.SiteList.lgtd); tableObj.lttd.push(item.SiteList.lttd); } }); that.hydroTableSort(tableObj); } } }); } else if (ind == 3) { that.flagdxs = true; $.ajax({ url: "widgets/Hydrology/riverInformation.json", type: "GET", dataType: "json", success: function success(data) { if (that.flagdxs == true && that.flag != false) { var data = eval(data); // eval() 计算字符串 var enId, cnx, cny, fieldName; that.createHydroTable({ data: data.features, num: ind }); data.features.forEach(function (item, index) { // cnx, cny 定义经纬度,获取json文件里面定义好的 cnx = item.geometry.center.x; cny = item.geometry.center.y; // 获取ID enId = item.ID; var dataTry = data.features.length; if (dataTry == 0) { return; } fieldName = item.fieldValues[8]; if (fieldName == 'undefined' || fieldName == null || fieldName == 0) return; // 添加图层 that.map.entities.add({ id: enId, name: fieldName, position: Cesium.Cartesian3.fromDegrees(Number(cnx), Number(cny), 100), // 与实体相关的点 point: { show: true, pixelSize: 8, color: Cesium.Color.fromBytes(13, 80, 143), outlineColor: Cesium.Color.fromBytes(13, 80, 143), outlineWidth: 2, disableDepthTestDistance: Number.POSITIVE_INFINITY }, label: { show: true, text: fieldName, font: "700 16px '黑体'", color: Cesium.Color.fromBytes(13, 80, 143), backgroundColor: Cesium.Color.DEEPSKYBLUE, style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineWidth: 2, outlineColor: Cesium.Color.SKYBLUE, pixelOffset: new Cesium.Cartesian2(30, 0), scale: 0.8, disableDepthTestDistance: Number.POSITIVE_INFINITY } }); // 将ID追加到存放ID值得数组里面 that.dataListEntity.push(enId); // 取消默认双击事件 that.map.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK); }); /** * 动态添加气泡窗口 */ that.hydroHandler3D = new Cesium.ScreenSpaceEventHandler(that.map.scene.canvas); var scene = that.map.scene; //绑定鼠标单击 that.hydroHandler3D.setInputAction(function (movement) { var ray = that.map.camera.getPickRay(movement.position); var cartesian = scene.globe.pick(ray, scene); var pick = scene.pick(movement.position); if (pick && pick.id) { var infoWindow = function infoWindow(obj) { var picked = scene.pick(obj.position); if (Cesium.defined(picked)) { var id = Cesium.defaultValue(picked.id, picked.primitive.id); if (id instanceof Cesium.Entity) { $('#trackPopUpLink').empty(); $('#trackPopUpLink').append(obj.content); var c = new Cesium.Cartesian2(obj.position.x, obj.position.y); $('#trackPopUp').show(); $('.leaflet-popup-close-button').click(function () { $('#trackPopUp').hide(); $('#trackPopUpLink').empty(); return false; }); return id; } } }; var updataPopupPosition = function updataPopupPosition(cartesian) { if (!cartesian) return; var px_position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, cartesian); var trackPopUpContent = window.document.getElementById("trackPopUpContent"); var popw = document.getElementById("trackPopUpContent").offsetWidth; var poph = document.getElementById("trackPopUpContent").offsetHeight; trackPopUpContent.style.left = px_position.x - (popw / 2 + 70) + "px"; trackPopUpContent.style.top = px_position.y - (poph + 60) + "px"; }; var inv = pick.id._id; // 获取属性 var feat = data.features[inv - 1].fieldValues; // 内容 var content = '
测站位置
' + '建站类型
' + '站点类型
' + '水文地质单元
' + '地貌类型
' + '地下水类型
' + '监测层位
' + '井管管材
' + '管材标准(口径)MM
' + '