From a41d9610b074c23f0e5d032f50282da7fb6763a2 Mon Sep 17 00:00:00 2001 From: czt <czt18638530771@163.com> Date: 星期一, 26 五月 2025 18:31:13 +0800 Subject: [PATCH] 优化巡检记录 --- igds-dzhwk-web/src/main/resources/static/dzhwk/recir/recir-control-pfc.js | 417 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 417 insertions(+), 0 deletions(-) diff --git a/igds-dzhwk-web/src/main/resources/static/dzhwk/recir/recir-control-pfc.js b/igds-dzhwk-web/src/main/resources/static/dzhwk/recir/recir-control-pfc.js new file mode 100644 index 0000000..778f128 --- /dev/null +++ b/igds-dzhwk-web/src/main/resources/static/dzhwk/recir/recir-control-pfc.js @@ -0,0 +1,417 @@ +var layer; +var form; +var deviceList;// 褰撳墠浠撳簱鐨勬墍鏈夎澶囧垪琛� +var depotId; +var deviceType = DeviceType.TYPE_05;// 琚�変腑鐨勮澶囩被鍨嬶紝璁惧绫诲瀷 绌鸿皟 +var viewTargetStatus;// 鐩爣鐘舵�侊紝鏍规嵁璁惧绫诲瀷鍜屽綋鍓嶅�艰皟鐢ㄥ姩鏁� +var domSelectDevice;// 琚�変腑鐨勮澶嘾om瀵硅薄 + +$(function () { + layui.use(['layer', 'form'], function () { + form = layui.form; + layer = layui.layer; + + form.render(); + + // 鐩戝惉浠撳簱閫夋嫨 + form.on('select(select_depotId)', function (obj) { + return onDepotChange(obj); + }); + + //鍒濆鍖栧埛鏂版暟鎹� + initData(); + }); + + // 娣诲姞鍒囨崲鍔ㄤ綔 + $(".js-tf-btn").click( + function () { + $(this).addClass("active").siblings(".js-tf-btn").removeClass( + "active"); + }); + + $(".js-xg115-arrow").click(function () { + $(this).siblings(".xg115-btnhide").toggle() + $(this).toggleClass("active"); + }); +}); + +function initData() { + if (depotId) { + $("#depotId").val(depotId); + query(true, true, true); + form.render(); + } +} + +/** + * 妫�娴嬩粨搴撶被鍨嬫槸鍚﹀彂鐢熸敼鍙橈紝濡傛灉鍙戠敓鏀瑰彉锛岄噸鏂板垏鎹㈤〉闈� + */ +function onDepotChange(obj) { + var depotType = obj.elem[obj.elem.selectedIndex].getAttribute('type'); + if (depotType == DEPOT_TYPE) { + query(true, true, true); + } else { + changeView(depotType); + } +} + +function changeView(depotType) { + //绫诲瀷鏀瑰彉锛岃嚜鍔ㄥ垏鎹㈤〉闈� + if (socket) { + socket.close(); + } + depotId = $("#depotId").val(); + window.location.href = "./gateway?depotId=" + depotId + "&depotType=" + depotType; + return true; +} + +function showVideo() { + window.parent.openTab("./basic/security/aerial-video?t=1", "瑙嗛楦熺灠", "aerial-video"); +}; + +function closeAll() { + layer.msg("缁堢涓嶆敮鎸佸綋鍓嶅姛鑳解�︹��"); +}; + +// 鐘舵�佹煡璇� +function queryStatus() { + depotId = $("#depotId").val(); + if (!depotId) { + layer.msg("璇峰厛閫夋嫨浠撳簱锛�"); + return; + } + //鎶婂綋鍓嶉〉闈㈢殑璁惧浼犻�掑埌鍚庡彴 + var data = { + depotId: depotId, + deptId: deptId, + deviceList: [] + }; + var tips = $(".device"); + $.each(tips, function (index, item) { + data.deviceList.push({ + id: item.id, + depotId: item.getAttribute("depotid"), + passCode: item.getAttribute("passcode"), + name: item.getAttribute("name"), + serId: item.getAttribute("serid"), + link: item.getAttribute("link"), + type: item.getAttribute("type"), + companyId: companyId + }); + }); + + $.ajax({ + type: "POST", + url: "../../basic/temp/query-status", + dataType: "json", + contentType: "application/json;charset=UTF-8", + data: JSON.stringify(data), + success: function (result) { + layer.msg(result.msg); + }, + error: function (result) { + layer.msg("鑾峰彇鏁版嵁澶辫触锛岃閲嶆柊灏濊瘯锛�"); + } + }); +}; + +/** + * @param isNew 鏄惁鏂板簱璺熸柊浠撳簱淇℃伅骞舵墽琛岀姸鎬佸埛鏂� + * @param isCut 鏄惁鍒囨崲椤甸潰 + * @param isQueryStatus 鏄惁鏇存柊鐘舵�� + */ +function query(isNew, isCut, isQueryStatus) { + depotId = $("#depotId").val(); + if (!depotId) { + layer.msg("璇峰厛閫夋嫨浠撳簱锛�"); + return; + } + if (isNew) { + updateGrainInfo(); + } + deviceList = [{"companyId":"5303","depotId":"P0101","id":"53030P190220_11001","link":"3001","location":"01","locationName":"02-鑳岄潰","name":"绌鸿皟#1","passCode":1001,"posX":857,"posY":216,"serId":"20","status":"OPEN","statusName":"椋庢満姝h浆","type":"05","typeName":"05-绌鸿皟"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_11002","link":"3002","location":"01","locationName":"02-鑳岄潰","name":"绌鸿皟#2","passCode":1002,"posX":469,"posY":212,"serId":"20","status":"CLOSE","statusName":"椋庡彛寮�","type":"05","typeName":"05-绌鸿皟"}]; + if(isCut){ + toCutExe(viewAB,true); + } + // $.ajax({ + // type: "POST", + // url: "../../basic/temp/list-device-manual", + // dataType: "json", + // contentType: "application/json;charset=UTF-8", + // data: JSON.stringify({ + // depotId: depotId + // }), + // success: function (result) { + // if (isNew) { + // updateGrainInfo(); + // } + // + // if (result.code != "0000") { + // layer.msg(result.msg); + // deviceList = null; + // if(isCut){ + // toCutExe(viewAB,true); + // } + // return; + // } + // deviceList = result.data; + // if(isCut){ + // toCutExe(viewAB,true); + // } + // if (isQueryStatus) { + // queryStatus(); + // } + // }, + // error: function (result) { + // layer.msg("鑾峰彇鏁版嵁澶辫触锛岃閲嶆柊灏濊瘯锛�"); + // } + // }); +}; + +// 鑾峰彇褰撳墠浠撳簱鐨勬渶鏂扮伯鎯呮暟鎹俊鎭� +function updateGrainInfo() { + $("#tempIn").text("26.6"); + $("#humidityIn").text("41"); + $("#humidityOut").text("63"); + $("#tempOut").text("32.4"); + $("#updateTime").text("2025-05-16 09:05"); + // $.ajax({ + // type: "POST", + // url: "../../basic/grain/grain-data", + // dataType: "json", + // contentType: "application/json;charset=UTF-8", + // data: JSON.stringify({ + // depotId: depotId + // }), + // success: function (result) { + // if (result.code != "0000") { + // layer.msg(result.msg); + // return; + // } + // var grainData = result.data; + // // 鏇存柊淇℃伅 + // $("#tempIn").text(grainData.tempIn <= -100?"--":(grainData.tempIn).toFixed(1)); + // $("#humidityIn").text((grainData.humidityIn).toFixed(1)); + // $("#humidityOut").text((grainData.humidityOut).toFixed(1)); + // $("#tempOut").text(grainData.tempOut <= -100?"--":(grainData.tempOut).toFixed(1)); + // $("#updateTime").text(grainData.receiveDate); + // }, + // error: function (result) { + // layer.msg("褰撳墠浠撳簱鐨勭伯鎯呮暟鎹俊鎭幏鍙栧け璐ワ紒"); + // } + // }); +}; + +/** + * 鍒囨崲鏁堟灉 + * @param target 姝e弽闈� + * @param isCutImg 鏄惁鎵ц鍒囧浘 + */ +function toCutExe(target, isCutImg) { + // 鑾峰彇褰撳墠浠撳簱鏁堟灉鍥� + viewAB = target; + if (isCutImg) { + cutImg(depotId, viewAB); + } + // 鏍规嵁璁惧鍒楄〃娣诲姞鍘熷瀷淇℃伅 + addDevice(deviceList, viewAB); +}; + +// 鎵嬪姩鎵ц锛屽悓鏃舵洿鏂扮姸鎬� +function toCut(target) { + if(target == "03" || target == "04"){ + layer.msg("鏆傛湭瀵规帴锛�"); + return; + } + toCutExe(target, true); +}; + +// 娣诲姞鎿嶄綔鏃ュ織 +function addLog(htmlStr) { + var info = $("#areationInfo").html(); + $("#areationInfo").html(htmlStr + "</br>" + info); +}; + +function addRedLog(htmlStr) { + var info = $("#areationInfo").html(); + $("#areationInfo").html( + "<span class='font-red'>" + htmlStr + "</span></br>" + info); +}; + +/** + * 寮瑰嚭鎿嶄綔妗� + */ +function showControl(id) { + domSelectDevice = $("#" + id); + var curDepotId = domSelectDevice.attr("depotid"); + // 濡傛灉鐐瑰嚮鐨勮澶囦笉鏄�夋嫨浠撳簱鐨勶紝涓嶆墽琛� + if (curDepotId != depotId) { + addLog("<font color='red'>褰撳墠鎵�閫夎澶囷細" + domSelectDevice.attr("name") + + "銆愰潪鎵�閫変粨搴撱��</font>"); + return; + } else { + addLog("褰撳墠鎵�閫夎澶囷細" + domSelectDevice.attr("name")); + } + // 鏇存柊鎵�閫夋嫨鐨勮澶囩被鍨� + deviceType = domSelectDevice.attr("type"); + if (1 == deviceType) + deviceType = "01"; + if (2 == deviceType) + deviceType = "02"; + if (3 == deviceType) + deviceType = "03"; + if (4 == deviceType) + deviceType = "04"; + if (5 == deviceType) + deviceType = "05"; + if (6 == deviceType) + deviceType = "06"; + if (7 == deviceType) + deviceType = "07"; + if (8 == deviceType) + deviceType = "08"; + if (9 == deviceType) + deviceType = "09"; + + // 鏍规嵁璁惧绫诲瀷寮瑰嚭涓嶄竴鏍风殑寮瑰嚭妗� + if (DeviceType.TYPE_04 == deviceType) {// 鐜祦椋庢満 + layer.open({ + type: 1, + title: '璁惧鎿嶄綔-' + domSelectDevice.attr("name"), + area: ['450px', '200px'], + shade: 0, + content: $('#control-HL2'), + btn: 0, + closeBtn: 2 + }); + } else { + layer.open({ + type: 1, + title: '绌鸿皟鎺у埗-' + domSelectDevice.attr("name"), + area: ['420px', '280px'], + shade: 0, + content: $('#tempControl'), + btn: ['纭畾鎵ц', '鍙栨秷鎿嶄綔'], + yes: function () { + layer.msg("鏆傛湭瀵规帴璁惧"); + return; + toExecute(); + layer.closeAll(); + layer.msg("寮�濮嬫墽琛屸�︹��"); + }, + btn2: function () { + layer.closeAll(); + }, + closeBtn: 0 + }); + } +}; + +function toExecute(targetStatus) { + if (deviceType == "04"){ + toExecute04(targetStatus) + } + if (deviceType == "05"){ + toExecute05() + } +}; + +// 鎿嶄綔绌鸿皟 +function toExecute05() { + var targetStatus = $('input[name="targetStatus"]:checked').val(); + var targetTemp = $("#targetTemp").val(); + var targetModel = $('input[name="targetModel"]:checked').val(); + + if (!targetTemp) + targetTemp = 16; + if (targetTemp < 16) + targetTemp = 16; + if (targetTemp > 24) + targetTemp = 24; + + if ("on" == targetStatus) { + targetStatus = "OPEN"; + } else { + targetStatus = "CLOSE"; + } + var exeDevice = null; + $.each(deviceList, function (index, item) { + if (item.id == domSelectDevice.attr("id")) { + exeDevice = item; + return true; + } + }); + + var data = { + companyId: companyId, + deptId: deptId, + depotId: depotId, + targetStatus: targetStatus, + targetTemp: targetTemp, + targetModel: targetModel, + deviceList: [exeDevice] + }; + $.ajax({ + type: "POST", + url: "../../basic/temp/control", + data: JSON.stringify(data), + dataType: "json", + contentType: "application/json;charset=UTF-8", + success: function (result) { + if ("ORDER_SUCCESS" == result.code) { + layer.msg("娓╂帶鍛戒护鍙戦�佹垚鍔燂紝璇疯绛夊緟鎵ц缁撴灉鈥︹��"); + } else { + layer.msg("鎵ц澶辫触锛屼俊鎭細" + result.msg); + } + }, + error: function () { + layer.msg("娓╂帶鎵ц澶辫触锛屽悗鍙板嚭鐜伴敊璇紒"); + } + }); +}; + +// 鎿嶄綔鐜祦椋庢満 +function toExecute04(targetStatus) { + viewTargetStatus = targetStatus; + + var data = { + depotId: depotId, + deptId: deptId, + deviceList: [] + }; + + data.deviceList.push({ + id: domSelectDevice.id, + depotId: domSelectDevice.attr("depotid"), + passCode: domSelectDevice.attr("passcode"), + name: domSelectDevice.attr("name"), + serId: domSelectDevice.attr("serid"), + link: domSelectDevice.attr("link"), + type: domSelectDevice.attr("type"), + targetStatus: targetStatus + }); + + // 寮�濮嬭皟鐢ㄥ悗鍙版墽琛� + layer.load(1); + $.ajax({ + type: 'POST', + url: "../../basic/verb/control-device", + dataType: 'JSON', + contentType: "application/json;charset=UTF-8", + data: JSON.stringify(data), + success: function (result) { + layer.closeAll(); + if (result.code != "ORDER_SUCCESS") { + layer.msg("鎵ц澶辫触锛�" + result.msg); + } else { + layer.msg("鎿嶄綔鎸囦护鍙戦�佹垚鍔燂紝寰呯粓绔搷搴斺�︹��"); + // 寮�濮嬭皟鐢ㄥ姩鐢� TODO + updateAnimate(deviceType, targetStatus, false); + } + }, + error: function (result) { + layer.closeAll(); + layer.msg("鎿嶄綔鍙戠敓寮傚父锛屾殏鏃舵棤娉曡В鍐筹紒锛�"); + } + }); +}; \ No newline at end of file -- Gitblit v1.9.3