police_o.js 270 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873
  1. var DialogObject = {
  2. HintWinHander: null,
  3. MoveState: 0, //移动状态。0 停止移动 1 开始移动 2 移动中
  4. //消息提示窗口。该类型窗口在未关闭时,多次调用时会复用原窗口
  5. OpenHint: function(container, opt) {
  6. if (this.HintWinHander == null) this.HintWinHander = this.Open(container, opt);
  7. return this.HintWinHander;
  8. },
  9. Open: function(container, opt) {
  10. var newcontainer = container.clone();
  11. $("body").append(newcontainer);
  12. newcontainer.attr("id", "dig_" + new Date().getTime());
  13. newcontainer.find(".fa-times,.dlg_close").off("click").on("click", function() {
  14. var container = $(this).parents(".site_device_list");
  15. if (container.css("z-index") == 10000)
  16. $(".clearn").hide();
  17. container.remove();
  18. });
  19. newcontainer.on("click", ".layui-tools button", function() {
  20. if ($(this).hasClass("cancel")) $(this).parents(".site_device_list").find(".fa-times").trigger('click');
  21. else if ($(this).hasClass("confirm")) {
  22. if (opt != null && opt.onSave != null) {
  23. opt.onSave(newcontainer, opt.para, this);
  24. }
  25. }
  26. });
  27. if (opt != null && opt.size != null) {
  28. newcontainer.css({
  29. width: opt.size[0],
  30. height: opt.size[1],
  31. });
  32. }
  33. var total_height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  34. $(".clearn").show().css("height", total_height + "px");
  35. newcontainer.show();
  36. var left = parseInt(newcontainer.width() / 2);
  37. left = -left;
  38. var top = parseInt(newcontainer.height() / 2);
  39. top = -top;
  40. newcontainer.css({
  41. "margin-left": left + "px",
  42. "margin-top": top + "px"
  43. });
  44. newcontainer.find(".caption").width(newcontainer.width() - 8).on("mousedown", function(e) {
  45. newcontainer.attr("MoveState", 1);
  46. var oldpageX = e.pageX;
  47. var oldpageY = e.pageY;
  48. var oldLeft = parseInt(newcontainer.css("left"));
  49. var oldTop = parseInt(newcontainer.css("top"));
  50. newcontainer.on("mousemove", function(ev) {
  51. // console.log(e)
  52. if (newcontainer.attr("MoveState") == "1") {
  53. newcontainer.css({
  54. "left": ev.pageX - oldpageX + oldLeft + "px",
  55. "top": ev.pageY - oldpageY + oldTop + "px"
  56. })
  57. }
  58. })
  59. }).on("mouseup", function() {
  60. newcontainer.attr("MoveState", 0);
  61. newcontainer.off("mousemove");
  62. });
  63. if (opt != null && opt.callback != null) {
  64. opt.callback(newcontainer, opt.para);
  65. }
  66. return newcontainer;
  67. },
  68. Close: function($ele) {
  69. if ($ele != null) {
  70. $(".clearn").hide();
  71. $ele.hide();
  72. } else {
  73. $(".layout_dialog,.clearn").hide();
  74. }
  75. },
  76. Msg: function(msg, opt) {
  77. var ind = layer.msg(msg, opt);
  78. $("#layui-layer" + ind).css("z-index", Global.GetSeqNext());
  79. }
  80. }
  81. var hRate = 1;
  82. var wRate = 1;
  83. var PoliceObject = {
  84. IntervalTime: 1000 * 60 * 5, //每5分钟刷新一次页面
  85. LoddingText: "<i class='layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop' style='margin-right:10px;'></i><span style='color:#ffffff;'>数据加载中...</span>",
  86. MessageObject: null,
  87. AreaID: 0, //当前站/区域ID
  88. ScdID: 0, //当前SCDID
  89. CurentMark: "",
  90. AreaInfo: {},
  91. MainHeight: 0, //页页内容区高度
  92. Tips: {
  93. tips: [3, "#f47920"],
  94. area: ['400', "auto"]
  95. },
  96. CurentCompCheckID: "", //当前用户正在一致性校验的记录ID
  97. CurentParseScdName: "", //当前用户正在解析的SCD名称
  98. TempScdID: "", //临时查看的scdID
  99. ScdList: [], //scd列表
  100. VoltageLevel: [], //电压等级
  101. AreaList: [], //间隔列表
  102. DeviceType: [], //装置类型列表
  103. IedList: [], //IED装置列表
  104. IedTypeMap: {},
  105. OnInited: null, //初始化完成事件
  106. NetWork_ApNodes: null,
  107. init: function() {
  108. //显示用户账号
  109. var userInfo = localStorage.getItem("userinfo");
  110. userInfo = JSON.parse(userInfo);
  111. $("#login_user_name").html(userInfo["name"]);
  112. $("#login_user_role").html("[" + userInfo["rolename"] + "]");
  113. var main_width = $(".monitor_center").width();
  114. var screen_width = document.documentElement.clientWidth;
  115. wRate = (screen_width / 1920).toFixed(2);
  116. var screen_height = document.documentElement.clientHeight;
  117. hRate = (screen_height / 1080).toFixed(2);
  118. $("#left_area_item").prevAll().css("margin-bottom", 20 * hRate + "px");
  119. PoliceObject.MainHeight = Math.ceil(screen_height - 65 * hRate);
  120. $(".body_content,#right_area,#container_map").height(PoliceObject.MainHeight);
  121. //<!--创建变电站列表-->
  122. $("body").append('<div class="station_list hidden" id="station_list"></div>');
  123. //scd树初始化
  124. $("#scd_tree_list").css({
  125. "height": PoliceObject.MainHeight - (70 * hRate) + "px"
  126. });
  127. $("#scd_tree_list>.title:first").css({
  128. "height": 4 + "rem",
  129. "line-height": 4 + "rem"
  130. });
  131. $("#scd_tree_list>.list:first").css({
  132. "height": 66 + "rem"
  133. }).slimScroll({
  134. height: 62 + "rem",
  135. width: "98%",
  136. alwaysVisible: false,
  137. wheelStep: 10,
  138. size: "6px",
  139. color: "#03aee7"
  140. });
  141. $("body").on('click', function() {
  142. if ($(this).attr("id") != "scd_info" && $(this).parent().attr("id") != "scd_info") {
  143. $("#scd_list").addClass("hidden");
  144. $("#scd_info").find("i").attr("class", "fa fa-caret-up");
  145. }
  146. if ($(this).attr("id") != "stationname" && $(this).parent().attr("id") != "stationname") {
  147. $("#station_list").addClass("hidden");
  148. $("#stationname").find("i").attr("class", "fa fa-caret-up");
  149. }
  150. if ($(this).attr("id") != "voltage_level_select" && $(this).parent().attr("id") != "voltage_level_select") {
  151. $("#voltage_level_list").addClass("hidden");
  152. $("#voltage_level_select").find("i").attr("class", "fa fa-caret-up");
  153. }
  154. if ($(this).attr("id") != "area_select" && $(this).parent().attr("id") != "area_select") {
  155. $("#area_list").addClass("hidden");
  156. $("#area_select").find("i").attr("class", "fa fa-caret-up");
  157. }
  158. if ($(this).attr("id") != "device_type_select" && $(this).parent().attr("id") != "device_type_select") {
  159. $("#device_type_list").addClass("hidden");
  160. $("#device_type_select").find("i").attr("class", "fa fa-caret-up");
  161. }
  162. });
  163. //初始化搜索事件
  164. $(document).on("click", function() {
  165. $("#search_result").html("").addClass("hidden");
  166. $("#fulltext_search_condition .datelist").addClass("hidden");
  167. });
  168. //全局关闭窗口事件
  169. $(".layout_close").off("click").on("click", function() {
  170. var container = $(this).parents(".layout_dialog");
  171. container.hide();
  172. if (container.css("z-index") == 10000)
  173. $(".clearn").hide();
  174. });
  175. $("#area_list>div:eq(0)").slimScroll({
  176. height: (300 * hRate) + "px",
  177. width: "100%",
  178. alwaysVisible: false,
  179. wheelStep: 10,
  180. size: "6px",
  181. color: "#03aee7"
  182. });
  183. $("#site_device_list").css({
  184. "bottom": 30 * hRate + "px",
  185. "left": 480 * wRate + "px",
  186. "height": 400 * hRate + "px",
  187. "width": 360 * wRate + "px"
  188. }).children(".dataitemlist").slimScroll({
  189. height: (360 * hRate) + "px",
  190. width: 340 * wRate + "px",
  191. alwaysVisible: false,
  192. wheelStep: 10,
  193. size: "6px",
  194. color: "#03aee7"
  195. });
  196. //点击顶端菜单
  197. $(".main_bar>div").off("click").on("click", function() {
  198. var mark = $(this).attr("mark");
  199. if (mark == null || mark == "") return;
  200. PoliceObject.CurentMark = mark;
  201. var oldActiveEle = $("#main_bar .app_active").removeClass("app_active").addClass("app_default");
  202. $(this).addClass("app_active");
  203. if (mark == "elevator") { //智感梯间
  204. if ($("#container_fulltext_search").is(":visible"))
  205. $("#container_fulltext_search").addClass("hidden");
  206. PoliceObject.GoFloor(0, "");
  207. } else if (mark == "search") {
  208. $("body").css("background-color", "#EEF3FF");
  209. PoliceObject.GoSearch();
  210. }
  211. });
  212. $("#search_panel").show();
  213. this.LoadOrgConfig();
  214. this.LoadNoreadNoitce();
  215. //初始化MQTT
  216. //初始订阅全局人脸搜索结果主题
  217. var face_mqtt = new MqttClient(null, null, ["/jujutong/scd/#"], function() {
  218. console.log("=====订阅成功===");
  219. });
  220. //定义接收消息处理过程
  221. face_mqtt.AddReceivedMqttMessage("/jujutong/scd/", function(topic, message) {
  222. console.log(topic + ":" + message)
  223. //scd文件解析通知
  224. ///jujutong/scd/parse/30000012:{"msg":"","name":"750kVQXB.scd","node":"load-file","rootid":"30000012","state":"0"}
  225. ///jujutong/scd/parse/30000012:{"msg":"","name":"750kVQXB.scd","node":"load-file","rootid":"30000012","state":"1"}
  226. ///jujutong/scd/parse/30000012:{"load":"0","msg":"","name":"750kVQXB.scd","node":"write-db","rootid":"30000012","state":"0","total":"925515"}
  227. ///jujutong/scd/ruleparse/30000012:节点LN属性prefix值最大长度不能超过6,当前属性值[QGD2ILB]长度无效!
  228. ///jujutong/scd/parse/30000012:{"load":"5000","msg":"","name":"750kVQXB.scd","node":"write-db","rootid":"30000012","state":"2","total":"925515"}
  229. ///jujutong/scd/parse/30000012:{"load":"925515","msg":"","name":"750kVQXB.scd","node":"write-db","rootid":"30000012","state":"1","total":"925515"}
  230. ///jujutong/scd/comp/3:{"state":0}
  231. ///jujutong/scd/notice/17:{"Id":0,"StationId":827,"Caption":"有新的SCD文件任务【SCD签入】需要您发布。","NoticeType":100,"SenderName":"李领","SenderTime":"2022-10-30 20:36:26","Content":"","RevId":17,"ReadFlag":0,"ReadTime":"","Cr":"","Ct":""}
  232. ///jujutong/scd/iedblockrelations/30000012/CB7522:{"code":1}
  233. ///jujutong/scd/iedblockinputs/30000012/CB7522/IB7522A:{"code":1}
  234. if (topic.indexOf("/jujutong/scd/notice") > -1) {
  235. PoliceObject.LoadNoreadNoitce();
  236. return;
  237. }
  238. if (topic.indexOf("/jujutong/scd/parse") > -1) {
  239. if (topic.indexOf("error") > 0) {
  240. layer.msg(message, {
  241. icon: Global.ICON_ERROR
  242. })
  243. return;
  244. }
  245. var jsonobj = JSON.parse(message);
  246. //PoliceObject.CurentParseScdName:当前需要解析有SCD名称
  247. //如果是签入操作,该变量值由FlowObject对的签入第一步骤提交时设置
  248. if (PoliceObject.CurentParseScdName != jsonobj.name && PoliceObject.AreaID != jsonobj.stationid) {
  249. return;
  250. }
  251. if (DialogObject.HintWinHander == null) {
  252. DialogObject.OpenHint($("#dialog_public"), {
  253. size: ["40rem", "20rem"],
  254. para: {
  255. "scdname": jsonobj.name
  256. },
  257. callback: function(win, para) {
  258. win.find(".node_area").remove();
  259. win.find(".caption>b").html("SCD解析");
  260. var $dataitemlist = win.find(".dataitemlist").html("<div class='process_msg_hint'></div>");
  261. var showH = $dataitemlist.height() - 25;
  262. $dataitemlist.slimScroll({
  263. height: showH + "px",
  264. width: "100%",
  265. alwaysVisible: false,
  266. wheelStep: 10,
  267. size: "6px",
  268. color: "#03aee7"
  269. });
  270. $dataitemlist.height(showH - 30);
  271. }
  272. });
  273. }
  274. var msgHintEle = DialogObject.HintWinHander.find(".process_msg_hint");
  275. if (jsonobj.state == "1") {
  276. var message = "";
  277. if (jsonobj.node == "load-file") message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "加载完成!";
  278. else if (jsonobj.node == "write-db") message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "结构解析入库完成!";
  279. else if (jsonobj.node == "check-file") message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "语法校验完成!";
  280. else if (jsonobj.node == "crc-file") message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "CRC校验完成!";
  281. Tools.Loading2Ok(msgHintEle);
  282. msgHintEle.append("<div>" + message + "</div>");
  283. if (typeof(FlowObject) == "object") {
  284. //当前处于签出签入界面时,自动刷新数据列表
  285. FlowObject.GetScdInoutRecord(1, 10, MakeScdInoutRecord);
  286. return;
  287. }
  288. if (typeof(LoadStationFiles) == "function") {
  289. //当前处于配置文件界面时,自动刷新数据列表
  290. //需要延迟一点点时间执行,否则获取的数据状态可能不对
  291. setTimeout(function() {
  292. LoadStationFiles(1, 20);
  293. }, 1000);
  294. return;
  295. }
  296. } else if (jsonobj.state == "0") {
  297. var message = "";
  298. if (jsonobj.node == "load-file") message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "开始加载...";
  299. else if (jsonobj.node == "write-db") message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "正在结构解析中,时间可能会稍长,请耐心等待完成... [总节点数:" + jsonobj.total + " 已解析:<span id='write-db-parse-count'><b>-</b></span>]";
  300. else if (jsonobj.node == "check-file") message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "正在进行语法校验,请耐心等待完成...]";
  301. else if (jsonobj.node == "crc-file") message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "正在进行CRC校验,请耐心等待完成...]";
  302. msgHintEle.append("<div>" + message + "</div>");
  303. } else if (jsonobj.state == "2") {
  304. msgHintEle.find("#write-db-parse-count").html(jsonobj.load);
  305. }
  306. return;
  307. }
  308. if (topic.indexOf("/jujutong/scd/ruleparse") > -1) {
  309. var jsonobj = JSON.parse(message);
  310. //PoliceObject.CurentParseScdName:当前需要解析有SCD名称
  311. //如果是签入操作,该变量值由FlowObject对的签入第一步骤提交时设置
  312. if (jsonobj.scdid == null || PoliceObject.ScdID != jsonobj.scdid) {
  313. return;
  314. }
  315. if (jsonobj.code == 0) {
  316. layer.msg(jsonobj.msg, {
  317. icon: Global.ICON_ERROR
  318. });
  319. return;
  320. }
  321. if (DialogObject.HintWinHander == null) {
  322. DialogObject.OpenHint($("#dialog_public"), {
  323. size: ["40rem", "20rem"],
  324. para: {
  325. "scdname": jsonobj.name
  326. },
  327. callback: function(win, para) {
  328. win.find(".caption>b").html("SCD校验");
  329. var $dataitemlist = win.find(".dataitemlist").html("<div class='process_msg_hint'>" + message + "</div>");
  330. $dataitemlist.slimScroll({
  331. height: ($dataitemlist.height() - 5) + "px",
  332. width: "100%",
  333. alwaysVisible: false,
  334. wheelStep: 10,
  335. size: "6px",
  336. color: "#03aee7"
  337. });
  338. }
  339. });
  340. }
  341. var msgHintEle = DialogObject.HintWinHander.find(".process_msg_hint");
  342. if (jsonobj.state == "1") {
  343. var message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件校验完成!";
  344. Tools.Loading2Ok(msgHintEle);
  345. msgHintEle.append("<div>" + message + "</div>");
  346. } else if (jsonobj.state == "0") {
  347. var message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件开始进行校验...";
  348. msgHintEle.append("<div>" + message + "</div>");
  349. }
  350. return;
  351. }
  352. if (topic.indexOf("/jujutong/scd/comp") > -1) {
  353. var jsonobj = JSON.parse(message);
  354. if (PoliceObject.CurentCompCheckID != jsonobj.id) {
  355. return;
  356. }
  357. var msgHintEle = DialogObject.HintWinHander == null ? null : DialogObject.HintWinHander.find(".process_msg_hint");
  358. //SCD文件一致性对比完成
  359. var state = jsonobj.state;
  360. if (state == "1") {
  361. var btn_scdcomp_start = $(".dialog_public .func_scdcomp_start");
  362. if (btn_scdcomp_start.length > 0) {
  363. if ("1" == $.trim(btn_scdcomp_start.attr("comping"))) {
  364. layer.closeAll();
  365. layer.msg("SCD一致性校验完成", {
  366. icon: 1
  367. });
  368. btn_scdcomp_start.attr("comping", "0");
  369. PoliceObject.LoadScdCompList();
  370. return;
  371. }
  372. }
  373. Tools.Loading2Ok(msgHintEle);
  374. var message = Tools.OkIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "一致性校验完成!";
  375. if (msgHintEle != null) msgHintEle.append("<div>" + message + "</div>");
  376. } else {
  377. var message = Tools.LoadingIcon() + new Date().Format("hh:mm:ss") + "===SCD文件" + jsonobj.name + "开始进行一致性校验...";
  378. if (msgHintEle != null) msgHintEle.append("<div>" + message + "</div>");
  379. }
  380. }
  381. if (topic.indexOf("/jujutong/scd/delete") > -1) {
  382. //清除SCD文件操作
  383. var jsonobj = JSON.parse(message);
  384. layer.closeAll();
  385. if (jsonobj.state == 0)
  386. layer.msg("SCD文件[" + jsonobj.scd_name + "]及相关数据正在被<b>" + jsonobj.user + "</b>删除中...", {
  387. icon: Global.ICON_LOADING,
  388. time: 0
  389. })
  390. else {
  391. layer.msg("SCD文件[" + jsonobj.scd_name + "]及相关数据已被<b>" + jsonobj.user + "</b>完全删除!", {
  392. icon: Global.ICON_OK
  393. });
  394. if (typeof(LoadStationFiles) == "function") {
  395. //当前处于配置文件界面时,自动刷新数据列表
  396. //需要延迟一点点时间执行,否则获取的数据状态可能不对
  397. setTimeout(function() {
  398. LoadStationFiles(1, 20);
  399. }, 1000);
  400. return;
  401. }
  402. }
  403. return;
  404. }
  405. if (topic.indexOf("/jujutong/scd/iedblockrelations") > -1) {
  406. var jsonobj = JSON.parse(message);
  407. var iedname = jsonobj["ied_name"];
  408. //数据块关系解析完成消息
  409. var v_win = $(".dialog_public[ied_name='" + iedname + "']");
  410. if (v_win.length == 0) return;
  411. var curBtn = v_win.find("#ied_list_tools .layui-this");
  412. if (curBtn.attr("ind") == "2") {
  413. //当前正在查看输入输出控制块信息
  414. console.log("重新加载" + iedname + "输入输出控制块信息");
  415. //PoliceObject.LoadIedCtrlRelation(PoliceObject.IedList[iedname]);
  416. setTimeout(function() {
  417. curBtn.trigger("click");
  418. }, 500);
  419. }
  420. return;
  421. }
  422. if (topic.indexOf("/jujutong/scd/iedblockinputs") > -1) {
  423. //虚端子关系解析完成消息
  424. return;
  425. }
  426. if (message != "" && message.substring(0, 1) == "{") {
  427. var jsonobj = JSON.parse(message);
  428. }
  429. });
  430. if (PoliceObject.OnInited != null) PoliceObject.OnInited(); //初始化完成事件
  431. },
  432. OpenToXml: function(scdid, lineno, desc) {
  433. //查看指定行数的scd源xml文件
  434. if (typeof lineXmlDig != "undefined") DialogObject.Close(lineXmlDig);
  435. lineXmlDig = DialogObject.Open($("#dialog_public"), {
  436. size: ["70rem", "65rem"],
  437. para: {
  438. "title": "SCD源XML查看",
  439. "scdid": scdid,
  440. "lineno": lineno,
  441. "desc": desc
  442. },
  443. callback: function(win, para) {
  444. if (typeof lineXmlDig != "undefined") win.css("margin-left", "0px");
  445. win.find(".caption>b").html(para.title);
  446. var winContent = win.find(".dataitemlist").css("cssText", "padding-top: 0rem !important;").html('<div style="color:red;border-bottom: 1px solid #e1e1e1;">' + para.desc + '</div><div style="overflow:auto;text-align: left;line-height: 2rem;">正在加载数据中</div>').height(win.height() - win.find(".caption").height() - win.find(".footer").height());
  447. $.getJSON(Global.AccessUrl + "/api/screen/scd/line/sourcexml", {
  448. "scd_id": para.scdid,
  449. "lineno": para.lineno
  450. }, function(data) {
  451. if (data.code != 0) {
  452. win.find(".dataitemlist>div:last").html(data.msg);
  453. return
  454. }
  455. var linestr = [];
  456. var topLine = 0;
  457. for (var i = 0; i < data.data.length; i++) {
  458. var linechars = data.data[i].indexOf(" ")
  459. var lno = data.data[i].substring(0, linechars)
  460. if (para.lineno == lno) {
  461. topLine = i + 1
  462. if (topLine > 25) topLine = topLine - 15;
  463. }
  464. linestr.push('<div line=' + lno + ' style="' + (para.lineno == lno ? 'background: #4d4d86;color: #fff;' : '') + '"><span>' + lno + ' </span><span>' + data.data[i].substring(linechars).replace(/</g, '&lt;').replace(/>/g, '&gt;') + '</span></div>');
  465. }
  466. win.find(".dataitemlist>div:last").height(winContent.height() - win.find(".dataitemlist>div:first").height()).html(linestr.join('')).scrollTop(topLine * win.find(".dataitemlist>div:last>div:eq(0)").height())
  467. })
  468. }
  469. });
  470. },
  471. toScd: function(stationid, scddid, scdname, scdpath) {
  472. //查看指定scd文件
  473. window.localStorage.setItem("PoliceObject.TempScdID", scddid);
  474. window.localStorage.setItem("PoliceObject.TempAreaID", stationid);
  475. window.localStorage.setItem("PoliceObject.TempScdName", scdname);
  476. window.localStorage.setItem("PoliceObject.AreaID", stationid);
  477. window.location.href = 'scd_o.html';
  478. },
  479. //加载配置的单位名称
  480. LoadOrgConfig: function() {
  481. //获取配置的单位名称
  482. $.getJSON(Global.AccessUrl + "/api/getSysParamList", {
  483. "param_name": "orgname"
  484. }, function(r) {
  485. if (r.code != 0 || r.data == null) return;
  486. $("#orgname").html(r.data[0].param_value);
  487. });
  488. },
  489. //加载未读通知提醒
  490. LoadNoreadNoitce: function() {
  491. $.getJSON(Global.AccessUrl + "/api/notice/list", {
  492. "isread": 0
  493. }, function(r) {
  494. if (r.code != 0 || r.data == null) return;
  495. changeBell(r.data.length);
  496. });
  497. var openNoticeWin = function() {
  498. $.getJSON(Global.AccessUrl + "/api/notice/list", {
  499. "isread": 0
  500. }, function(r) {
  501. if (r.code != 0 || r.data == null) return;
  502. changeBell(r.data.length);
  503. if (r.data.length == 0) {
  504. return;
  505. }
  506. DialogObject.Open($("#dialog_public"), {
  507. size: ["81rem", "40rem"],
  508. para: {
  509. "title": "",
  510. "list": r.data
  511. },
  512. callback: function(win, para) {
  513. win.find(".caption>b").html("最新提醒");
  514. win.find(".node_area").remove();
  515. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height());
  516. var dataitemlist = win.find(".dataitemlist").height(h + "px").html("<div class='notice_header f_l' style='border-bottom: 1px solid #334077;font-weight: bold;width: 100%;'></div><div class='notice_list f_l'></div>");
  517. dataitemlist.children(".notice_header").html('<span class="f_l text_overflow" style="width:15rem">时间</span><span class="f_l text_overflow" style="width:15rem">变电站</span><span class="f_l text_overflow" style="width:30rem">提醒内容</span><span class="f_l text_overflow" style="width:10rem">发布者</span><span class="f_l text_overflow" style="width:10rem">操作</span>');
  518. var noticeLst = [];
  519. for (var i = 0; i < para.list.length; i++) {
  520. noticeLst.push("<div class='notice_item f_l' noticeid='" + para.list[i].id + "'><span class='f_l text_overflow' style='width:15rem'>" + para.list[i].sender_time + "</span><span class='f_l text_overflow' style='width:15rem'>" + para.list[i].station_name + "</span><span class='f_l text_overflow' style='width:30rem'>" + para.list[i].caption + "</span><span class='f_l text_overflow' style='width:10rem'>" + para.list[i].sender_name + "</span><span class='f_l text_overflow' style='width:10rem'><span class='btn' style='padding: 0.5rem 1rem;' noticeid='" + para.list[i].id + "'>已读</span></span></div>");
  521. }
  522. var notice_list = dataitemlist.children(".notice_list").html(noticeLst.join(""));
  523. notice_list.slimScroll({
  524. height: (h - dataitemlist.children(".notice_header").height() - 5) + "px",
  525. width: "100%",
  526. alwaysVisible: false,
  527. wheelStep: 10,
  528. size: "6px",
  529. color: "#03aee7"
  530. });
  531. notice_list.find(".btn").off().on('click', function() {
  532. var row = $(this),
  533. noticeid = row.attr("noticeid");
  534. $.post(Global.AccessUrl + "/api/notice/read", {
  535. "id": noticeid
  536. }, function(r) {
  537. layer.msg("操作成功!");
  538. row.parent().parent().remove();
  539. if (notice_list.find(".notice_item").length == 0) {
  540. win.remove();
  541. changeBell(0);
  542. } else {
  543. changeBell(-1);
  544. }
  545. });
  546. });
  547. }
  548. });
  549. });
  550. }
  551. var changeBell = function(numer) {
  552. var menu = $(".monitor_center .header .header_background>div:first");
  553. var noitcemenu = menu.find(".app_default.notice");
  554. if (numer == null || numer == 0) {
  555. noitcemenu.prev().remove();
  556. noitcemenu.remove();
  557. return;
  558. }
  559. //fa-bell
  560. if (noitcemenu.length == 0) {
  561. $('<div class="app_default" style="color: #7A13E1;">|</div><div class="app_default notice" style="border-bottom: 2px solid #7A13E1;height: 93%;position: relative;">' +
  562. '<i class="fa fa-bell" style="color: #00CEFB;font-size: 1.8rem;margin-right: 0.5rem;border: 0;"></i><span class="abs notice_number" style="height: 2rem;width: 2rem;border-radius: 2rem;border: 2px solid #fff;line-height: 2rem;font-size: 1.2rem;text-align: center;background: red;right: -1.5rem;top: 0;color:#fff;">' + numer + '</span>' +
  563. '</div>').insertBefore(menu.children(".app_default:eq(2)"));
  564. noitcemenu = menu.find(".app_default.notice");
  565. noitcemenu.off().on('click', function() {
  566. openNoticeWin();
  567. });
  568. } else {
  569. if (numer == -1) {
  570. //当前值减1
  571. numer = noitcemenu.find(".notice_number").text() * 1 - 1;
  572. }
  573. //最多显示99的数量
  574. noitcemenu.find(".notice_number").html(numer > 99 ? 99 : numer);
  575. }
  576. }
  577. //openNoticeWin();
  578. },
  579. //加载装置类型
  580. LoadDeviceType: function(clickcallback) {
  581. $.getJSON(Global.AccessUrl + "/api/scd/ied/typelist", {
  582. "scd_id": PoliceObject.ScdID
  583. }, function(r) {
  584. if (r.code != 0 || r.returncode == 500 || r.data == null) return;
  585. PoliceObject.DeviceType = r.data;
  586. var container_map_ied = $("#container_map_ied");
  587. var tarEle = container_map_ied.find("#device_type_select").off().on('click', function(e) {
  588. e.stopPropagation();
  589. var t = $(this),
  590. t1 = $("#device_type_list");
  591. t1.removeClass("hidden").css({
  592. top: t.offset().top + t.height() + 10,
  593. left: t.offset().left + t.width() - t1.width()
  594. });
  595. $(this).find("i").attr("class", "fa fa-caret-down");
  596. });
  597. //设备类型采用code,需要把id删除去除
  598. for (var i = 0; i < r.data.length; i++) {
  599. delete(r.data[i]["id"]);
  600. }
  601. $("#device_type_list").html(template('select_item_tpl', {
  602. data: [{
  603. "id": "",
  604. "name": "全部"
  605. }].concat(r.data)
  606. })).find(".station_list_item").off().on('click', function() {
  607. var v = $(this).attr("value");
  608. tarEle.attr("vid", v).children(".filter_text").html("装置类型:" + $(this).text());
  609. tarEle.find("i").attr("class", "fa fa-caret-up");
  610. if (clickcallback != null) clickcallback(v, $(this).text());
  611. });
  612. });
  613. },
  614. //加载变电站列表
  615. LoadStationList: function(loadcallback, clickcallback) {
  616. //获取变电站列表。后台已经根据当前登录人员做了权限过滤
  617. $.getJSON(Global.AccessUrl + "/api/basic_area/list", {
  618. "pid": "0"
  619. }, function(r) {
  620. if (r.code != 0 || r.data == null) return;
  621. var stationname = $("#stationname").html(r.data[0].area_name);
  622. if (loadcallback != null) loadcallback(r);
  623. if (r.data.length > 0) {
  624. PoliceObject.AreaID = r.data[0].id;
  625. //当前人员有权限的站超过1个时,才显示选择列表
  626. /*
  627. stationname.append('<i class="fa fa-caret-up"></i>');
  628. stationname.off().on('click', function(e) {
  629. //点击站名时,显示变电站下拉列表
  630. e.stopPropagation();
  631. $("#station_list").removeClass("hidden");
  632. $(this).find("i").attr("class", "fa fa-caret-down");
  633. });*/
  634. //生成站列表元素
  635. var station_list = $("#scd_tree_list .list").html(template("station_list_item_tpl", r));
  636. /*station_list.css({
  637. top: stationname.offset().top + stationname.height() + 10,
  638. left: stationname.offset().left + stationname.width() - station_list.width()
  639. });*/
  640. station_list.find(".station_list_item").off().on('click', function() {
  641. $("#scd_tree_list .list .active").removeClass("active");
  642. $(this).addClass("active");
  643. //选择某个站时,加载该站的scd信息
  644. var stationid = $(this).attr("stationid");
  645. PoliceObject.AreaID = stationid;
  646. window.localStorage.setItem("PoliceObject.AreaID", stationid);
  647. //stationname.html($(this).text() + '<i class="fa fa-caret-up"></i>');
  648. if (clickcallback != null) clickcallback(stationid);
  649. });
  650. var cur_station_id = $.trim(window.localStorage.getItem("PoliceObject.AreaID"));
  651. if (cur_station_id != "") {
  652. station_list.find(".station_list_item[stationid='" + cur_station_id + "']").trigger('click');
  653. } else {
  654. //默认选择第一个
  655. station_list.find(".station_list_item:first").addClass("active").trigger('click');
  656. }
  657. }
  658. });
  659. },
  660. //加载电压等级列表
  661. LoadVoltageLevelSelect: function(stationid, clickcallback) {
  662. var tmp_load = function(r) {
  663. //绑定电压等级选择事件
  664. var container_map_ied = $("#container_map_ied");
  665. var tarEle = container_map_ied.find("#voltage_level_select").off().on('click', function(e) {
  666. e.stopPropagation();
  667. var t = $(this),
  668. t1 = $("#voltage_level_list");
  669. t1.removeClass("hidden").css({
  670. top: t.offset().top + t.height() + 10,
  671. left: t.offset().left + t.width() - t1.width()
  672. });
  673. $(this).find("i").attr("class", "fa fa-caret-down");
  674. });
  675. $("#voltage_level_list").html(template('select_item_tpl', {
  676. data: [{
  677. "id": "",
  678. "name": "全部"
  679. }].concat(r)
  680. })).find(".station_list_item").off().on('click', function() {
  681. var tarEle = $("#voltage_level_select");
  682. var v = $(this).attr("value");
  683. tarEle.attr("vid", v).children(".filter_text").html("电压等级:" + $(this).text());
  684. tarEle.find("i").attr("class", "fa fa-caret-up");
  685. $("#area_select").attr("vid", "").children(".filter_text").html("间隔");
  686. $("#device_type_select").attr("vid", "").children(".filter_text").html("装置类型");
  687. //过虑所选择的电压等级的间隔
  688. var area_select = $("#area_list");
  689. if (v == "") area_select.find(".station_list_item").removeClass("hidden");
  690. else {
  691. for (var i = 0; i < PoliceObject.AreaList.length; i++) {
  692. var tarItemEle = area_select.find(".station_list_item[value='" + PoliceObject.AreaList[i].id + "']");
  693. if (PoliceObject.AreaList[i].voltage_level == v) {
  694. tarItemEle.removeClass("hidden");
  695. } else {
  696. tarItemEle.addClass("hidden");
  697. }
  698. }
  699. }
  700. if (clickcallback != null) clickcallback(v, $(this).text());
  701. });
  702. if (container_map_ied.find(".scd_area").length > 0) {
  703. //填充电压等级-间隔列表
  704. var scdArea = container_map_ied.find(".scd_area").html(template('voltage_level_item_tpl', {
  705. data: PoliceObject.VoltageLevel
  706. }));
  707. scdArea.slimScroll({
  708. height: $("#container_map .scd_main").height() - $("#container_map .scd_main .scd_filter").height() - $("#container_map .scd_main .scd_filter").css("margin-top").replace("px", "") * 1,
  709. width: "99%",
  710. alwaysVisible: false,
  711. wheelStep: 10,
  712. size: "6px",
  713. color: "#03aee7"
  714. });
  715. //填充间隔列表
  716. PoliceObject.LoadAreaSelect(PoliceObject.ScdID, function(v, text) {
  717. PoliceObject.OpenShowIedList(text, {
  718. "area_id": v,
  719. "voltage_level_id": "",
  720. "device_type_id": ""
  721. });
  722. });
  723. }
  724. if (container_map_ied.find("#network").length > 0) {
  725. //console.log("================PoliceObject.GetSubNetwork")
  726. //填充网络结构
  727. //PoliceObject.GetSubNetwork();
  728. }
  729. }
  730. if (PoliceObject.VoltageLevel == null || PoliceObject.VoltageLevel.length == 0) {
  731. //加载电压等级
  732. $.getJSON(Global.AccessUrl + "/api/getGlobalCode", {
  733. "pcode": "voltage_level"
  734. }, function(r) {
  735. if (r.code != 0 || r.returncode == 500 || r.data == null) return;
  736. PoliceObject.VoltageLevel = r.data;
  737. tmp_load(PoliceObject.VoltageLevel);
  738. });
  739. } else {
  740. tmp_load(PoliceObject.VoltageLevel);
  741. }
  742. },
  743. //加载间隔列表
  744. LoadAreaSelect: function(scdid, clickcallback) {
  745. if (PoliceObject.ScdID == 0) return;
  746. var tmp_load = function(r) {
  747. var container_map_ied = $("#container_map_ied");
  748. var tarEle = container_map_ied.find("#area_select").off().on('click', function(e) {
  749. e.stopPropagation();
  750. var t = $(this),
  751. t1 = $("#area_list");
  752. t1.removeClass("hidden").css({
  753. top: t.offset().top + t.height() + 10,
  754. left: t.offset().left + t.width() - t1.width()
  755. });
  756. });
  757. $("#area_list>div>div:eq(0)").html(template('select_item_tpl', {
  758. data: [{
  759. "id": "",
  760. "name": "全部"
  761. }].concat(PoliceObject.AreaList)
  762. })).find(".station_list_item").off().on('click', function() {
  763. var v = $(this).attr("value");
  764. tarEle.attr("vid", v).children(".filter_text").html("间隔:" + $(this).text());
  765. tarEle.find("i").attr("class", "fa fa-caret-up");
  766. $("#device_type_select").attr("vid", "").children(".filter_text").html("装置类型");
  767. if (clickcallback != null) clickcallback(v, $(this).text());
  768. });
  769. container_map_ied.find(".scd_area .voltage_level_item").each(function() {
  770. if (PoliceObject.AreaList == null) return;
  771. //显示每个电压等级下属的间隔
  772. var $t = $(this),
  773. volid = $t.attr("itemid");
  774. var showDiv = $t.find(".voltage_level_area").html("");
  775. for (var i = 0; i < PoliceObject.AreaList.length; i++) {
  776. var item = PoliceObject.AreaList[i];
  777. if (volid == item.voltage_level) {
  778. showDiv.append('<span class="voltage_level_area_item text_overflow" area_id="' + item.id + '" title="' + item.name + '"><span>' + item.name + '</span></span>')
  779. }
  780. }
  781. var areaLen = showDiv.find(".voltage_level_area_item").length;
  782. if (areaLen == 0) {
  783. //移除没有ied的间隔电压等级
  784. $t.remove();
  785. //移除电压等级列表项
  786. $("#voltage_level_list .station_list_item[value=" + volid + "]").remove();
  787. return
  788. }
  789. if (areaLen > 7) {
  790. //如果间隔超过2排时,需要动态增加区域高度.显示区域默认高度只能显示2排
  791. var trowH = Math.ceil(areaLen / 7) * 12 * hRate;
  792. showDiv.css("height", trowH + "rem");
  793. showDiv.prev().css({
  794. "height": trowH + "rem",
  795. "line-height": (trowH + 1) + "rem"
  796. });
  797. showDiv.parent().css("height", trowH + "rem");
  798. }
  799. /*
  800. showDiv.slimScroll({
  801. height: (14 * hRate) + "rem",
  802. width: "88%",
  803. alwaysVisible: false,
  804. wheelStep: 10,
  805. size: "6px",
  806. color: "#03aee7"
  807. });*/
  808. });
  809. container_map_ied.find(".scd_area .voltage_level_area_item").off().on("click", function() {
  810. //点击间隔,查看该间隔下的IED
  811. var $t = $(this);
  812. var tit = $t.parent().prev().text() + "—" + $t.text();
  813. PoliceObject.OpenShowIedList(tit, {
  814. "area_id": $t.attr("area_id")
  815. });
  816. });
  817. }
  818. if (this.AreaList == null || this.AreaList.length == 0) {
  819. //获取当前变电站的间隔列表
  820. $.getJSON(Global.AccessUrl + "/api/scd/area/list", {
  821. "scd_id": scdid
  822. }, function(r) {
  823. if (r.code != 0) {
  824. layer.msg("间隔信息获取失败:" + r.msg);
  825. return;
  826. }
  827. PoliceObject.AreaList = r.data;
  828. tmp_load(r.data);
  829. })
  830. } else {
  831. tmp_load(this.AreaList);
  832. }
  833. },
  834. CheckScdID: "",
  835. CheckScdTaretID: "",
  836. CheckTools: function(type, title, scdid, scdpath, scdname) {
  837. if (scdid == "0") {
  838. layer.msg("该SCD文件还未解析!", {
  839. icon: Global.ICON_ERROR
  840. });
  841. return;
  842. }
  843. var winSize = ["150rem", "65rem"];
  844. if (type == "scd") {
  845. //scd一致性比较
  846. DialogObject.Open($("#dialog_public"), {
  847. size: ["130rem", "65rem"],
  848. para: {
  849. "title": title,
  850. "type": type,
  851. "scdpath": scdpath,
  852. "scdname": scdname
  853. },
  854. callback: function(win, para) {
  855. win.find(".caption>b").html(para.title);
  856. win.find(".dataitemlist").css("cssText", "padding-top: 1rem !important;").html(template('checktools_' + para.type + '_tpl', {})).height(win.height() - win.find(".caption").height() - win.find(".footer").height());
  857. eval("PoliceObject.checktools_" + para.type + "(win)");
  858. }
  859. });
  860. return;
  861. }
  862. if (type == "cid" || type == "cid_scd" || type == "ccd" || type == "ccd_scd") {
  863. //非scd一致性比较
  864. //开始CID校验
  865. $.post(Global.AccessUrl + "/api/scd/comp/start", {
  866. station_id: PoliceObject.AreaID,
  867. source_scd_id: scdid,
  868. ids: scdpath,
  869. type: type
  870. }, function(r) {
  871. layer.closeAll();
  872. if (r.code != 0) {
  873. layer.msg("操作失败:" + r.msg, {
  874. icon: Global.ICON_ERROR
  875. });
  876. return;
  877. }
  878. //$("#comp_ied_list .ied_data_list").html(r.data.info.iedname + "<br>" + (r.data.info.ieddesc || ""));
  879. //$("#comp_ied_result_show #node_tree>div:first>b").html(r.data.info.f1.filename + "(" + r.data.info.f1.ct + ")");
  880. //$("#comp_ied_result_show #node_tree>div:last>b").html(r.data.info.f2.filename + "(" + r.data.info.f2.ct + ")");
  881. if (r.data.list == null || r.data.list.length == 0) {
  882. layer.msg("当前2个对比文件无差异", {
  883. "icon": Global.ICON_HINT
  884. })
  885. return;
  886. }
  887. r.data["file_type"] = type;
  888. PoliceObject.CheckTools_Scd_Comp_ied_Detail(0, scdid, "", "", 'u', r.data);
  889. });
  890. return;
  891. }
  892. if ($.trim(scdid) == "" && $.trim(scdpath) != "" && $.trim(scdname) != "") {
  893. $.getJSON(Global.AccessUrl + "/api/screen/scd/info", {
  894. 'scdpath': scdpath,
  895. 'scdname': scdname
  896. }, function(r) {
  897. if (r.code != 0) {
  898. layer.msg(r.msg);
  899. return;
  900. }
  901. if (r.data == null) {
  902. layer.msg("无效的SCD名称和路径");
  903. return;
  904. }
  905. PoliceObject.CheckScdID = r.data.id;
  906. DialogObject.Open($("#dialog_public"), {
  907. size: ["150rem", "65rem"],
  908. para: {
  909. "title": r.data.station_name + "—" + r.data.scd_name + "—" + title,
  910. "type": type,
  911. "scdpath": scdpath,
  912. "scdname": scdname,
  913. "info": r.data
  914. },
  915. callback: function(win, para) {
  916. win.find(".caption>b").html(para.title);
  917. if (para.info.is_parse == 1) {
  918. win.find(".dataitemlist").html(template('checktools_' + para.type + '_tpl', {})).height(win.height() - win.find(".caption").height() - win.find(".footer").height());
  919. eval("PoliceObject.checktools_" + para.type + "(win)");
  920. } else {
  921. win.find(".dataitemlist").html(Tools.HintText("文件" + para.scdname + "正在解析中...,稍候重试"));
  922. }
  923. }
  924. });
  925. });
  926. } else if (scdid != null && scdid != "") {
  927. this.CheckScdID = scdid;
  928. PoliceObject.ScdID = scdid;
  929. } else {
  930. this.CheckScdID = PoliceObject.ScdID;
  931. }
  932. if (type != "scd" && (this.CheckScdID == null || this.CheckScdID == "")) {
  933. layer.msg("请选择一个SCD文件", {
  934. "icon": Global.ICON_ERROR
  935. })
  936. return;
  937. }
  938. if (type == "crc") {
  939. winSize = ["100rem", "60rem"];
  940. }
  941. $.getJSON(Global.AccessUrl + "/api/screen/scd/info", {
  942. "scd_id": this.CheckScdID
  943. }, function(jsondata) {
  944. if (jsondata.code != 0) {
  945. layer.msg(jsondata.msg);
  946. return;
  947. }
  948. DialogObject.Open($("#dialog_public"), {
  949. size: winSize,
  950. para: {
  951. "title": jsondata.data.station_name + "—" + jsondata.data.scd_name + "—" + title,
  952. "type": type,
  953. "scdpath": jsondata.data.path,
  954. "scdname": jsondata.data.scd_name
  955. },
  956. callback: function(win, para) {
  957. win.find(".caption>b").html(para.title);
  958. win.find(".dataitemlist").html(template('checktools_' + para.type + '_tpl', {})).height(win.height() - win.find(".caption").height() - win.find(".footer").height());
  959. eval("PoliceObject.checktools_" + para.type + "(win)");
  960. }
  961. });
  962. })
  963. },
  964. checktools_scl: function(win) {
  965. var tree = win.find("#node_tree .ztree");
  966. var dataitemlistH = win.find(".dataitemlist").height() - win.find(".dataitemlist").css("padding-top").replace("px", "") * 1;
  967. tree.slimscroll({
  968. height: (dataitemlistH - 10) + "px",
  969. width: "100%",
  970. alwaysVisible: false,
  971. wheelStep: 10,
  972. size: "6px",
  973. color: "#03aee7"
  974. });
  975. var selectedIedName = "";
  976. var selectedNodeName = "";
  977. var selectedNodeId = "";
  978. var stat = win.find("#content_div .stat");
  979. var pagebar = win.find("#content_div .pagebar");
  980. var datalist = win.find("#content_div .datalist");
  981. datalist.slimscroll({
  982. height: (dataitemlistH - stat.height() - pagebar.height() - win.find(".datalist_header").height() - 10) + "px",
  983. width: "100%",
  984. alwaysVisible: false,
  985. wheelStep: 10,
  986. size: "6px",
  987. color: "#03aee7"
  988. });
  989. win.find(".func_scdcomp_exportexcel").off().on('click', function() {
  990. var isall = $(this).attr("isall");
  991. if (isall == "1") {
  992. //导出所有结果
  993. Tools.ExpExcel({
  994. "code": "scl-check-result",
  995. "caption": "SCL校验结果",
  996. "expcols": "line_no,CREATED_TIME,attr_name,attr_desc,alert_level,parse_result,apply_standard,apply_standard_no",
  997. "expcolnames": "行号,日期,装置名称,装置描述,等级,校验结果内容,应用标准,标准条款",
  998. "scd_id": PoliceObject.CheckScdID,
  999. });
  1000. return
  1001. }
  1002. //导出当前节点结果
  1003. Tools.ExpExcel({
  1004. "code": "scl-check-result",
  1005. "caption": "SCL校验结果",
  1006. "expcols": "line_no,CREATED_TIME,attr_name,attr_desc,alert_level,parse_result,apply_standard,apply_standard_no",
  1007. "expcolnames": "行号,日期,装置名称,装置描述,等级,校验结果内容,应用标准,标准条款",
  1008. "scd_id": PoliceObject.CheckScdID,
  1009. "level": stat.find("span[alert_level].alert_level_active").attr("alert_level"),
  1010. "ied_name": selectedIedName,
  1011. "node_name": selectedNodeName,
  1012. "node_id": selectedNodeId
  1013. });
  1014. });
  1015. var iedHint = false;
  1016. var sumresult = {};
  1017. var arearesult = {};
  1018. var vlresult = {}; //电压等级提示
  1019. var topIedHintType = ""; //最高级的校验结果类型,默认为hint
  1020. var topSCLHintType = "";
  1021. $.getJSON(Global.AccessUrl + "/api/scd/check/sum/result", {
  1022. scd_id: PoliceObject.CheckScdID
  1023. }, function(r) {
  1024. if (r.code != 0) {
  1025. layer.msg("汇总校验结果错误:" + r.msg);
  1026. return;
  1027. }
  1028. if (r.data == null) {
  1029. r.data = [];
  1030. }
  1031. Global.Ztree.Init(tree, {
  1032. url: Global.AccessUrl + "/api/screen/scd/checktools/tree?scd_id=" + PoliceObject.CheckScdID,
  1033. idKey: "id",
  1034. pidKey: "pid",
  1035. nameKey: "title",
  1036. AjaxParam: ["datatype"],
  1037. childrenNodeIcon: 'fa-file-code-o',
  1038. callback: {
  1039. onClick: function(event, treeId, treeNode) {
  1040. //console.log(treeNode)
  1041. paginationLoaded = false;
  1042. selectedIedName = treeNode.attr_name;
  1043. selectedNodeName = treeNode.datatype;
  1044. selectedNodeId = treeNode.attr_name || treeNode.id;
  1045. stat.find("span[alert_level].alert_level_active").removeClass("alert_level_active");
  1046. loadSclCheckResult(1, 20);
  1047. },
  1048. onAsyncSuccess: function(event, treeId, treeNode, msg) {
  1049. }
  1050. },
  1051. DiyDom: function(treeId, treeNode) {
  1052. var aObj = $("#" + treeNode.tId + "_a");
  1053. //console.log(treeNode)
  1054. //aObj.append("<span class='checktools_scl_numberhint alert_level_erro' >5</span>");
  1055. var curNodeId = treeNode.id;
  1056. aObj.append("<span class='checktools_scl_numberhint alert_level_" + treeNode.alert_level + "' ><i class='fa fa-exclamation-circle'></i></span>");
  1057. }
  1058. });
  1059. });
  1060. //获取当前scd所有的结果
  1061. var paginationLoaded = false;
  1062. var loadSclCheckResult = function(pageno, pagesize) {
  1063. $.getJSON(Global.AccessUrl + "/api/scd/check/stat/level", {
  1064. "scd_id": PoliceObject.CheckScdID,
  1065. "ied_name": selectedIedName,
  1066. "node_name": selectedNodeName,
  1067. "node_id": selectedNodeId
  1068. }, function(r1) {
  1069. $("#content_div .stat>span>span[alert_level] b").html("0");
  1070. if (r1.code != 0) {
  1071. layer.msg("分类统计校验信息错误:" + r1.msg);
  1072. return;
  1073. }
  1074. var all = 0;
  1075. if (r1.data == null) {
  1076. layer.msg("校验结果正在统计中,请稍候重试!");
  1077. return;
  1078. }
  1079. for (var i = 0; i < r1.data.length; i++) {
  1080. var item = r1.data[i];
  1081. all += item.cnt * 1;
  1082. var alertlevel = item["alert_level"];
  1083. stat.find("span[alert_level='" + alertlevel + "']>b").html(item.cnt);
  1084. }
  1085. stat.find("span[alert_level='']>b").html(all);
  1086. stat.find("span[alert_level]").off().on("click", function() {
  1087. var t = $(this);
  1088. t.parent().find(".alert_level_active").removeClass("alert_level_active");
  1089. t.addClass("alert_level_active");
  1090. paginationLoaded = false;
  1091. loadSclCheckResult(1, 20, $(this).attr("alert_level"));
  1092. });
  1093. });
  1094. layer.msg("正在查询校验信息中...", {
  1095. time: 30000
  1096. });
  1097. $.getJSON(Global.AccessUrl + "/api/scd/check/resultlist", {
  1098. "scd_id": PoliceObject.CheckScdID,
  1099. "pageno": pageno,
  1100. "pagesize": pagesize,
  1101. "level": stat.find("span[alert_level].alert_level_active").attr("alert_level"),
  1102. "ied_name": selectedIedName,
  1103. "node_name": selectedNodeName,
  1104. "node_id": selectedNodeId
  1105. }, function(r) {
  1106. if (r.code != 0) {
  1107. layer.msg("查询校验信息错误:" + r.msg);
  1108. return;
  1109. }
  1110. layer.closeAll();
  1111. var dl = template('checktools_scl_datalist_tpl', r);
  1112. datalist.html(dl);
  1113. if (r.data == null) {
  1114. r.count = 0;
  1115. pagebar.addClass("hidden");
  1116. datalist.html(Tools.HintText("该节点校验无误!"));
  1117. }
  1118. pagebar.removeClass("hidden");
  1119. if (!paginationLoaded) {
  1120. //生成分页
  1121. pagebar.pagination(r.count, {
  1122. num_edge_entries: 2,
  1123. num_display_entries: 6,
  1124. prev_show_always: false,
  1125. next_show_always: false,
  1126. prev_text: "&lt;",
  1127. next_text: "&gt;",
  1128. callback: function(page_index, jq) {
  1129. //console.log("page_index:" + page_index)
  1130. if (paginationLoaded) loadSclCheckResult(page_index + 1, 20);
  1131. },
  1132. items_per_page: 20
  1133. });
  1134. paginationLoaded = true;
  1135. }
  1136. })
  1137. }
  1138. loadSclCheckResult(1, 20);
  1139. },
  1140. checktools_scd: function(win) {
  1141. if (PoliceObject.CurentCompCheckID != "") {
  1142. layer.msg("正在进行SCD的一致性比对,请稍候...", {
  1143. time: -1,
  1144. icon: Global.ICON_LOADING
  1145. })
  1146. //有scd正在对比中
  1147. win.find(".func_scdcomp_new,.func_scdcomp_start").attr("comping", "1").addClass("btn_disabled");
  1148. }
  1149. var source_scd_id = "";
  1150. var target_scd_id = "";
  1151. win.find(".func_scdcomp_exportexcel").off().on('click', function() {
  1152. var compid = 0;
  1153. var selectComp = win.find("#scd_comp_list .datalist input[name='comp_selected']:checked");
  1154. if (selectComp.length > 0) {
  1155. compid = selectComp.val();
  1156. }
  1157. if (compid == 0) {
  1158. layer.msg("请选择一条历史对比记录或创建新的一致性对比!");
  1159. return;
  1160. }
  1161. Tools.ExpExcel({
  1162. "code": "scd-comp-result",
  1163. "caption": "SCD一致性比对结果",
  1164. "expcols": "source_scd_name,target_scd_name,ied_name,ied_desc,opt,diff_object_type,diff_object_name,desc",
  1165. "expcolnames": "基准SCD,目标比对SCD,装置名称,装置描述,操作,比对内容类型,差异项,差异内容",
  1166. "comp_id": compid
  1167. });
  1168. });
  1169. win.find(".func_scdcomp_new").off().on('click', function() {
  1170. if ($.trim($(this).attr("comping")) == "1") {
  1171. return;
  1172. }
  1173. DialogObject.Open($("#dialog_public"), {
  1174. size: ["80rem", "45rem"],
  1175. para: {
  1176. "title": "新的SCD一致性对比校验"
  1177. },
  1178. callback: function(childwin, para) {
  1179. childwin.find(".caption>b").html(para.title);
  1180. var body = childwin.find("#ln_strcut_detail");
  1181. body.html("<div class='f_l' style='width:100%;line-height: 2rem;'>请同时选择2个scd文件进行对比!</div><div class='left f_l' style='width:99%;height:82%;padding: 1%;background-color: #f7f5f5;border-radius: 3px;border: 1px dotted #ccc;'><div></div></div><div class='layui-tools f_l' style='width: 99%;'><button type='button' class='layui-btn cancel'>关闭</button><button type='button' class='layui-btn layui-btn-normal confirm'>立即比对</button></div>");
  1182. var scddiv = body.find("div.left");
  1183. body.find(".layui-tools .cancel").off().on("click", function() {
  1184. childwin.find(".dlg_close").trigger('click');
  1185. });
  1186. body.find(".layui-tools .confirm").off().on("click", function() {
  1187. //确定按钮
  1188. var scdlist = [];
  1189. scddiv.find("input[type='checkbox']:checked").each(function() {
  1190. var v_scdid = $(this).parent().attr("scdid")
  1191. scdlist.push(v_scdid)
  1192. if (v_scdid != source_scd_id) target_scd_id = v_scdid;
  1193. });
  1194. if (scdlist.length != 2) {
  1195. layer.msg("请同时选择2个scd文件进行对比", {
  1196. icon: Global.ICON_HINT
  1197. })
  1198. return;
  1199. }
  1200. win.find(".func_scdcomp_start").trigger('click');
  1201. childwin.find(".dlg_close").trigger('click');
  1202. });
  1203. body.find(".left>div").slimscroll({
  1204. "height": scddiv.height() + "px",
  1205. "width": "100%",
  1206. alwaysVisible: false,
  1207. wheelStep: 10,
  1208. size: "6px",
  1209. color: "#03aee7"
  1210. })
  1211. scddiv = scddiv.children("div:first").children("div:first");
  1212. var showScdMap = {};
  1213. if (PoliceObject.ScdList != null) {
  1214. for (var i = 0; i < PoliceObject.ScdList.length; i++) {
  1215. showScdMap[PoliceObject.ScdList[i].id] = 1;
  1216. scddiv.append('<div scdid="' + PoliceObject.ScdList[i].id + '" class="f_l" style="width:99%;border-bottom: 1px solid #e8e7e7;"><input class="f_l" type="checkbox" name="scd_selected" style="margin: 1.4rem;"><span class="f_l" style="margin-right: 1.4rem;width: 4rem;height: 1px;">' + PoliceObject.ScdList[i].version + '</span><span class="f_l">' + PoliceObject.ScdList[i].scd_name + '</span><span class="f_r hidden"><input class="f_l" type="radio" name="base_scd_radio" style="margin: 1.4rem;" scdid="' + PoliceObject.ScdList[i].id + '">基准文件</span></div>');
  1217. }
  1218. }
  1219. //获取非管控SCD列表
  1220. $.getJSON(Global.AccessUrl + "/api/screen/scd/list", {
  1221. "stationid": PoliceObject.AreaID,
  1222. "ischeckinscd": ""
  1223. }, function(jsondata) {
  1224. if (jsondata.code != 0) {
  1225. layer.msg("获取非管控SCD列表出错误:" + jsondata.msg, {
  1226. icon: Global.ICON_ERROR
  1227. })
  1228. return;
  1229. }
  1230. if (jsondata.data == null) return;
  1231. for (var i = 0; i < jsondata.data.length; i++) {
  1232. if (showScdMap[jsondata.data[i].id] != null) continue;
  1233. scddiv.append('<div scdid="' + jsondata.data[i].id + '" class="f_l" style="width:99%;border-bottom: 1px solid #e8e7e7;"><input class="f_l" type="checkbox" name="scd_selected" style="margin: 1.4rem;"><span class="f_l" style="margin-right: 1.4rem;width: 4rem;height: 1px;">' + jsondata.data[i].version + '</span><span class="f_l">' + jsondata.data[i].scd_name + '</span><span class="f_r hidden"><input class="f_l" type="radio" name="base_scd_radio" style="margin: 1.4rem;" scdid="' + jsondata.data[i].id + '">基准文件</span></div>');
  1234. }
  1235. scddiv.find("input[type='radio']").off().on('click', function() {
  1236. var t = $(this);
  1237. source_scd_id = t.attr("scdid");
  1238. });
  1239. scddiv.find("input[type='checkbox']").off().on('click', function() {
  1240. var t = $(this);
  1241. if (scddiv.find("input[type='checkbox']:checked").length == 3) {
  1242. t.prop("checked", false);
  1243. layer.msg("最多可选择2个文件进行比对校验!", {
  1244. icon: Global.ICON_HINT
  1245. })
  1246. return
  1247. }
  1248. if (t[0].checked) t.parent().find("input[name='base_scd_radio']").parent().removeClass("hidden");
  1249. else t.parent().find("input[name='base_scd_radio']").parent().addClass("hidden");
  1250. var basescd = $(scddiv.find("input[type='checkbox']:checked")[0]).parent().find("input[name='base_scd_radio']").prop("checked", true)
  1251. source_scd_id = basescd.attr("scdid");
  1252. });
  1253. })
  1254. }
  1255. });
  1256. });
  1257. win.find(".func_scdcomp_start").off().on('click', function() {
  1258. if ($.trim($(this).attr("comping")) == "1") {
  1259. return;
  1260. }
  1261. layer.msg("正在进行SCD的一致性比对,请稍候...", {
  1262. time: -1,
  1263. icon: Global.ICON_LOADING
  1264. })
  1265. var compid = 0;
  1266. var selectComp = win.find("#scd_comp_list .datalist input[name='comp_selected']:checked");
  1267. if (selectComp.length > 0) {
  1268. compid = selectComp.val();
  1269. }
  1270. if (compid == 0 && source_scd_id == "") {
  1271. layer.msg("请选择一条历史校验记录或创建新一致性校验!", {
  1272. icon: 3
  1273. });
  1274. return;
  1275. }
  1276. var optbtn = $(this);
  1277. layer.confirm('该操作耗时较长,校验开始后将清除原有校验结果且无法中止,确定开始吗?', {
  1278. icon: Global.ICON_ASK,
  1279. btn: ['确定', '取消'] //按钮
  1280. }, function(index) {
  1281. layer.close(index);
  1282. optbtn.attr("comping", "1").addClass("btn_disabled");
  1283. win.find(".func_scdcomp_new").attr("comping", "1").addClass("btn_disabled");
  1284. layer.msg("正在进行SCD的一致性比对...请稍候", {
  1285. icon: 16,
  1286. time: -1
  1287. });
  1288. PoliceObject.CurentCompCheckID = compid + source_scd_id;
  1289. $.post(Global.AccessUrl + "/api/scd/comp/start", {
  1290. station_id: PoliceObject.AreaID,
  1291. source_scd_id: source_scd_id,
  1292. target_scd_id: target_scd_id,
  1293. type: "SCD",
  1294. comp_id: compid
  1295. }, function(r) {
  1296. win.find(".func_scdcomp_new,.func_scdcomp_start").attr("comping", "0").removeClass("btn_disabled");
  1297. PoliceObject.CurentCompCheckID = "";
  1298. layer.closeAll();
  1299. if (r.code != 0) {
  1300. layer.msg("操作失败:" + r.msg, {
  1301. icon: Global.ICON_ERROR
  1302. });
  1303. return;
  1304. }
  1305. PoliceObject.LoadScdCompList();
  1306. //等校验完成后,mqtt推送状态信息并更新界面
  1307. });
  1308. });
  1309. });
  1310. var scd_comp_list = win.find("#scd_comp_list");
  1311. var dataitemlistH = win.find(".dataitemlist").height() - win.find(".dataitemlist").css("padding-top").replace("px", "") * 1;
  1312. scd_comp_list.find(".datalist").slimscroll({
  1313. height: (dataitemlistH - win.find(".datalist_header").height() - win.find("#scd_comp_tools").height() - 5) + "px",
  1314. width: "100%",
  1315. alwaysVisible: false,
  1316. wheelStep: 10,
  1317. size: "6px",
  1318. color: "#03aee7"
  1319. });
  1320. this.LoadScdCompList();
  1321. },
  1322. checktools_crc: function(win) {
  1323. var iedcrclist = win.find("#iedcrclist");
  1324. iedcrclist.slimScroll({
  1325. height: iedcrclist.height() + "px",
  1326. width: "99%",
  1327. alwaysVisible: false,
  1328. wheelStep: 10,
  1329. size: "6px",
  1330. color: "#03aee7"
  1331. });
  1332. iedcrclist.html(Tools.HintText("正在加载数据中"));
  1333. $.getJSON(Global.AccessUrl + "/api/screen/scd/crc", {
  1334. "scd_id": PoliceObject.ScdID
  1335. }, function(jsondata) {
  1336. if (jsondata.code != 0) {
  1337. iedcrclist.html(Tools.HintText(jsondata.msg));
  1338. return
  1339. }
  1340. win.find("#scdcrc").html(jsondata.data["scdcrc"]["scdcrc"] || '无');
  1341. win.find("#scdcrc2").html(jsondata.data["scdcrc"]["checkcrc"]);
  1342. win.find("#scdcrcresult").html(jsondata.data["scdcrc"]["checkcrc"] == jsondata.data["scdcrc"]["scdcrc"] ? "校验通过" : "<b style='color:red'>不一致</b><select class='fa-search' style='margin-left: 1rem;'><option>全部</option><option>不一致</option><option>一致</option></select>").find(".fa-search").off().on('change', function() {
  1343. var selecttext = $(this).val();
  1344. iedcrclist.find("tr").each(function() {
  1345. var tr = $(this);
  1346. if (selecttext != "全部" && tr.find("td:last").text().indexOf(selecttext) != 0) {
  1347. tr.addClass("hidden")
  1348. } else {
  1349. tr.removeClass("hidden")
  1350. }
  1351. })
  1352. });
  1353. var h = template('checktools_crc_list_tpl', {
  1354. "data": jsondata.data.list.sort(Tools.SortBy("iedname", true))
  1355. });
  1356. iedcrclist.css("height", "96%").html(h);
  1357. });
  1358. },
  1359. LoadScdCompList: function() {
  1360. $("#scd_comp_list .datalist").html(Tools.HintText("正在加载数据中..."));
  1361. $.getJSON(Global.AccessUrl + "/api/scd/comp/list", {
  1362. "station_id": PoliceObject.AreaID
  1363. }, function(r) {
  1364. if (r.code != 0) {
  1365. layer.msg(r.msg, {
  1366. icon: Global.ICON_ERROR
  1367. });
  1368. return
  1369. }
  1370. if (r.data == null || r.data.length == 0) {
  1371. $("#scd_comp_list .datalist").html(Tools.HintText("还没有SCD一致性校验比对记录!"));
  1372. return;
  1373. }
  1374. var h = template('checktools_scd_datalist_tpl', r);
  1375. $("#scd_comp_list .datalist").html(h);
  1376. })
  1377. },
  1378. CurrentCompResult: null, //当前查看的SCD比对结果
  1379. CheckTools_Scd_Comp_Detail: function(e, compId, sourcescdname, targetscdname, sourcescdid, targetscdid) {
  1380. var queryScdId = "";
  1381. var selectedNodeID = "";
  1382. var selectedNodeType = "";
  1383. var paginationLoaded = false;
  1384. var queryDir = "source"; //查询的是比对的源数据还是目标数据。默认为源数据
  1385. var win = $(e).parents(".site_device_list");
  1386. var scdinfos = win.find("#node_tree>div");
  1387. $(scdinfos[0]).children("b").html(sourcescdname);
  1388. $(scdinfos[2]).children("b").html(targetscdname);
  1389. layer.msg("正在加载数据中")
  1390. $.getJSON(Global.AccessUrl + "/api/scd/comp/stat/result", {
  1391. comp_id: compId
  1392. }, function(r) {
  1393. if (r.data != null && r.data.length > 0) {
  1394. layer.closeAll();
  1395. var data = {
  1396. "crc": {},
  1397. "version": {},
  1398. "ied": {
  1399. "addnum": 0,
  1400. "editnum": 0,
  1401. "delnum": 0
  1402. }
  1403. };
  1404. PoliceObject.CurrentCompResult = r.data;
  1405. for (var i = 0; i < r.data.length; i++) {
  1406. if (r.data[i]["diff_object_type"] == "scd.crc") {
  1407. var v = JSON.parse(r.data[i]["diff_desc"]);
  1408. if (v != null) {
  1409. data["crc"]["source"] = v[0];
  1410. data["crc"]["target"] = v[1];
  1411. }
  1412. } else if (r.data[i]["diff_object_type"] == "scd.version") {
  1413. var v = JSON.parse(r.data[i]["diff_desc"]);
  1414. if (v != null) {
  1415. data["version"]["source"] = v[0];
  1416. data["version"]["target"] = v[1];
  1417. }
  1418. } else if (r.data[i]["diff_object_type"] == "scd.ied") {
  1419. if (r.data[i]["diff_opt"] == "i") data.ied.addnum++;
  1420. if (r.data[i]["diff_opt"] == "u") data.ied.editnum++;
  1421. if (r.data[i]["diff_opt"] == "d") data.ied.delnum++;
  1422. }
  1423. }
  1424. var html = template('comp_scd_tpl', data);
  1425. var comp_show_area = win.find("#comp_show_area").html(html);
  1426. var iedDiv = comp_show_area.find(".comp_scd:last");
  1427. var ied_change_stat = win.find("#ied_change_stat");
  1428. ied_change_stat.css({
  1429. "top": iedDiv.position().top + iedDiv.height() + 250,
  1430. "left": iedDiv.position().left + iedDiv.width() / 2 - ied_change_stat.width() / 2,
  1431. });
  1432. ied_change_stat.find(".change_btn").off().on('click', function() {
  1433. if ($(this).attr('change_num') == "0") {
  1434. return
  1435. }
  1436. var change_type = $(this).attr("change_type");
  1437. if (change_type == 'u') PoliceObject.CheckTools_Scd_Comp_ied_Detail(compId, sourcescdid, sourcescdname, targetscdname, $(this).attr('change_type'));
  1438. else {
  1439. var iedlist = [];
  1440. for (var i = 0; i < PoliceObject.CurrentCompResult.length; i++) {
  1441. var item = PoliceObject.CurrentCompResult[i];
  1442. if (item.diff_opt == change_type && item.diff_object_type == 'scd.ied') {
  1443. iedlist.push({
  1444. "ied_name": item.ied_name,
  1445. "ied_desc": item.ied_desc,
  1446. "scd_id": change_type == "d" ? targetscdid : sourcescdid,
  1447. });
  1448. }
  1449. }
  1450. //查看新增或删除的IED信息
  1451. DialogObject.Open($("#dialog_public"), {
  1452. size: ["150rem", "72rem"],
  1453. para: {
  1454. "title": iedlist[0].ied_desc + "(" + iedlist[0].ied_name + ")—详细信息",
  1455. "scd_id": change_type == "d" ? targetscdid : sourcescdid,
  1456. "ied_name": iedlist[0].ied_name,
  1457. },
  1458. callback: function(win, p1) {
  1459. win.attr({
  1460. "ied_name": p1.ied_name,
  1461. "scd_id": p1.scd_id
  1462. });
  1463. win.find(".caption>b").html(p1.title);
  1464. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height());
  1465. win.find(".dataitemlist").height(h + "px").html(template('ied_detail_tpl', {}));
  1466. win.find(".content").height(h - win.find(".tools").height() + "px");
  1467. win.find("#ied_list_tree").height(h - 20 * hRate);
  1468. //绑定快速查找
  1469. win.find("#ied_list_tree .fast_find_list").off().on("input propertychange", function() {
  1470. var v = ($(this).val()).toLocaleLowerCase();
  1471. var tarEle = win.find("#ied_list_tree .station_list_item");
  1472. if (v == "") tarEle.removeClass("hidden");
  1473. else {
  1474. tarEle.each(function() {
  1475. var $this = $(this);
  1476. if ($this.text().toLocaleLowerCase().indexOf(v) > -1) $this.removeClass("hidden");
  1477. else $this.addClass("hidden");
  1478. })
  1479. }
  1480. });
  1481. PoliceObject.LoadIedTreeList2(null, iedlist, null);
  1482. PoliceObject.LoadIedGraph(null, PoliceObject.GetIedData(p1.ied_name, p1.scd_id));
  1483. }
  1484. });
  1485. }
  1486. });
  1487. setTimeout(function() {
  1488. var x = iedDiv.position().left + iedDiv.width() / 2;
  1489. var y = iedDiv.position().top + iedDiv.height()
  1490. var h = ied_change_stat.position().top - y;
  1491. comp_show_area.append('<div class="pointer_line" style="left:' + x + 'px;top:' + y + 'px;height:' + h + 'px"></div>')
  1492. iedDiv = ied_change_stat.find(".change_btn:first");
  1493. x = ied_change_stat.position().left + (iedDiv.css("margin-left").replace("px", "") * 2 + 4 + iedDiv.width()) / 2;
  1494. h = 40;
  1495. y = ied_change_stat.position().top - h;
  1496. comp_show_area.append('<div class="pointer_line" style="left:' + x + 'px;top:' + y + 'px;height:' + h + 'px"></div>')
  1497. iedDiv = ied_change_stat.find(".change_btn:last");
  1498. var x3 = ied_change_stat.position().left + (iedDiv.css("margin-left").replace("px", "") * 2 + iedDiv.width() + 4) * 2.5;
  1499. h = 40;
  1500. var y3 = ied_change_stat.position().top - h;
  1501. comp_show_area.append('<div class="pointer_line" style="left:' + x3 + 'px;top:' + y3 + 'px;height:' + h + 'px"></div>')
  1502. comp_show_area.append('<div class="pointer_line" style="left:' + x + 'px;top:' + y + 'px;width:' + (x3 - x) + 'px"></div>')
  1503. }, 100)
  1504. } else if (r.code != 0) {
  1505. layer.msg("加载失败:" + r.msg + ",建议进行重新比对!", {
  1506. icon: Global.ICON_ERROR
  1507. })
  1508. } else {
  1509. layer.msg("当前2个SCD文件没有差异!", {
  1510. icon: Global.ICON_HINT
  1511. });
  1512. win.find("#comp_show_area").html("当前2个SCD文件没有差异!");
  1513. }
  1514. });
  1515. },
  1516. CheckTools_Scd_Comp_ied_Detail: function(compId, sourcescdid, sourcescdname, targetscdname, ctype, ccd_cid_info) {
  1517. DialogObject.Open($("#dialog_public"), {
  1518. size: ["130rem", "65rem"],
  1519. para: {
  1520. "title": "一致性比对结果",
  1521. "type": ctype,
  1522. "compId": compId,
  1523. "sourcescdid": sourcescdid,
  1524. "sourcescdname": ccd_cid_info != null ? ccd_cid_info.info.f1.filename + "—" + ccd_cid_info.info.f1.ct : sourcescdname,
  1525. "targetscdname": ccd_cid_info != null ? ccd_cid_info.info.f2.filename + "—" + ccd_cid_info.info.f2.ct : targetscdname,
  1526. "ccd_cid_info": ccd_cid_info
  1527. },
  1528. callback: function(win, para) {
  1529. win.find(".caption>b").html(para.title);
  1530. var opt = para.type == "i" ? "新增" : (para.type == "u" ? "更改" : "删除");
  1531. var iedlist = [];
  1532. if (para.ccd_cid_info != null) {
  1533. iedlist.push({
  1534. "ied_name": para.ccd_cid_info.info.iedname,
  1535. "ied_desc": para.ccd_cid_info.info.ieddesc
  1536. });
  1537. //根据变更、新增、删除类型排序
  1538. var tmpList = [];
  1539. for (var i = 0; i < para.ccd_cid_info.list.length; i++) {
  1540. if (para.ccd_cid_info.list[i].diff_opt == 'u') {
  1541. tmpList.unshift(para.ccd_cid_info.list[i]);
  1542. } else {
  1543. tmpList.push(para.ccd_cid_info.list[i])
  1544. }
  1545. }
  1546. para.ccd_cid_info.list = tmpList;
  1547. } else {
  1548. for (var i = 0; i < PoliceObject.CurrentCompResult.length; i++) {
  1549. var item = PoliceObject.CurrentCompResult[i];
  1550. if (item.diff_opt == para.type && item.diff_object_type == 'scd.ied') {
  1551. iedlist.push({
  1552. "ied_name": item.ied_name,
  1553. "ied_desc": item.ied_desc
  1554. });
  1555. }
  1556. }
  1557. }
  1558. var compTplName = "comp_scd_ied_tpl"; //对比结果加载模板名称
  1559. if (para.ccd_cid_info != null && (para.ccd_cid_info.file_type == "ccd" || para.ccd_cid_info.file_type == "ccd_scd")) compTplName = "comp_ccd_ied_tpl";
  1560. win.find(".dataitemlist").css("cssText", "padding-top: 1rem !important;").html(template(compTplName, {
  1561. 'opt': opt,
  1562. "list": iedlist,
  1563. "num": iedlist.length
  1564. })).height(win.height() - win.find(".caption").height() - win.find(".footer").height());
  1565. var comp_show_area = $("#comp_ied_result_show");
  1566. var scdinfos = comp_show_area.find("#node_tree>div");
  1567. $(scdinfos[0]).children("b").html(para.sourcescdname);
  1568. $(scdinfos[2]).children("b").html(para.targetscdname);
  1569. var ieddatalist = win.find("#comp_ied_list .ied_data_list");
  1570. ieddatalist.slimScroll({
  1571. height: ieddatalist.height() + "px",
  1572. width: "100%",
  1573. alwaysVisible: false,
  1574. wheelStep: 10,
  1575. size: "6px",
  1576. color: "#03aee7"
  1577. });
  1578. win.find("#comp_ied_list .ied_comp_items .node").off().on("click", function() {
  1579. var t = $(this);
  1580. if (t.attr("num") == '0') return;
  1581. var t1 = t.parent().find(".node.active").removeClass("active");
  1582. t1.find(".fa").remove();
  1583. t1.prepend('<i class="f_l fa fa-caret-right" />'); //fa存在伪元素,removeclass后有残留,只能用此方法
  1584. t.addClass("active")
  1585. t.parent().find(".children[p_type='" + t1.attr("type") + "']").addClass("hidden");
  1586. t.find(".fa").remove();
  1587. t.prepend('<i class="f_l fa fa-caret-down" />'); //fa存在伪元素,removeclass后有残留,只能用此方法
  1588. t.parent().find(".children[p_type='" + t.attr("type") + "']").removeClass("hidden");
  1589. t.parent().find(".children[p_type='" + t.attr("type") + "'][num!='0']:first").trigger('click');
  1590. });
  1591. win.find("#comp_ied_list .ied_comp_items .node[num!='0']:first").trigger('click');
  1592. win.find("#comp_ied_list .ied_comp_items .children").off().on("click", function() {
  1593. var t = $(this);
  1594. if (t.attr("num") == '0') return;
  1595. t.parent().find(".children.active").removeClass("active");
  1596. t.addClass("active")
  1597. PoliceObject.GetCompItemDetail(win, para.compId, ieddatalist.find(".ied_item.active").attr("ied_name"), para.type, t.attr("type"), sourcescdid)
  1598. });
  1599. var loadIedCompStat = function(data) {
  1600. var ptypeNums = {};
  1601. var scdiedRelationNum = 0; //回路数量
  1602. var eles = win.find("#comp_ied_list .ied_comp_items");
  1603. for (var k in data) {
  1604. var num = data[k] * 1;
  1605. var ele = eles.find(".children[type='" + k + "']").attr("num", num);
  1606. ele.children(".num").html(num);
  1607. var ptypeNum = ptypeNums[ele.attr("p_type")];
  1608. if (ptypeNum == null) ptypeNums[ele.attr("p_type")] = num;
  1609. else ptypeNums[ele.attr("p_type")] = ptypeNum * 1 + num;
  1610. if (k == "scd.ied.ExtRef") scdiedRelationNum = scdiedRelationNum + num;
  1611. }
  1612. for (var k in ptypeNums) {
  1613. var ele = eles.find(".node[type='" + k + "']").attr("num", ptypeNums[k]);
  1614. ele.children(".num").html(ptypeNums[k]);
  1615. }
  1616. if (scdiedRelationNum > 0) {
  1617. var ele = eles.find(".children[type='scd.ied.Relation']").attr("num", scdiedRelationNum);
  1618. ele.children(".num").html(scdiedRelationNum);
  1619. }
  1620. //触发第一个有变化的节点
  1621. win.find("#comp_ied_list .ied_comp_items .node[num!='0']:first").trigger('click');
  1622. }
  1623. if (ccd_cid_info != null) {
  1624. win.ccd_cid_info = ccd_cid_info;
  1625. var numstatdata = {};
  1626. //统计差异类型数量
  1627. for (var i = 0; i < ccd_cid_info.list.length; i++) {
  1628. var diff_object_type = ccd_cid_info.list[i].diff_object_type;
  1629. if (numstatdata[diff_object_type] == null) numstatdata[diff_object_type] = 1;
  1630. else numstatdata[diff_object_type] = numstatdata[diff_object_type] + 1;
  1631. }
  1632. loadIedCompStat(numstatdata);
  1633. ieddatalist.find(".ied_item:first").addClass("active");
  1634. } else {
  1635. ieddatalist.find(".ied_item").off().on("click", function() {
  1636. ieddatalist.find(".ied_item.active").removeClass("active");
  1637. $(this).addClass("active");
  1638. //获取装备差异分类统计
  1639. var eles = win.find("#comp_ied_list .ied_comp_items");
  1640. eles.children("div").each(function() {
  1641. $(this).attr("num", "0").find(".num").html("0")
  1642. });
  1643. $("#comp_ied_result_show .comp_show_area").html('<div>正在加载数据中</div>')
  1644. layer.msg("正在加载数据中", {
  1645. icon: Global.ICON_HINT
  1646. });
  1647. var clickIedName = $(this).attr("ied_name");
  1648. $.getJSON(Global.AccessUrl + "/api/scd/comp/iedstat/type", {
  1649. 'comp_id': para.compId,
  1650. 'ied_name': clickIedName,
  1651. 'comptype': para.type
  1652. }, function(jsondata) {
  1653. layer.closeAll();
  1654. if (jsondata.code != 0) {
  1655. layer.msg(jsondata.msg, {
  1656. icon: Global.ICON_ERROR
  1657. })
  1658. return
  1659. }
  1660. loadIedCompStat(jsondata.data);
  1661. })
  1662. }).eq(0).trigger('click');
  1663. }
  1664. }
  1665. });
  1666. },
  1667. currentCompItem: null, //当前展示差异数据的对象
  1668. GetCompItemDetail: function(win, compid, iedname, ctype, itemcode, sourcescdid) {
  1669. var itemcode_icon = {
  1670. "scd.ied": "icon_baseinfo.png",
  1671. "scd.ied.YC": "icon_yc.png",
  1672. "scd.ied.YX": "icon_yx.png",
  1673. "scd.ied.YK": "icon_yk.png",
  1674. "scd.ied.YM": "icon_ym.png",
  1675. "scd.ied.DZ": "icon_dz.png",
  1676. "scd.ied.FCDA": "icon_publish.png",
  1677. "scd.ied.ExtRef": "icon_sub.png",
  1678. "scd.ied.Relation": "icon_relation.png",
  1679. "scd.ied.ReportControl": "icon_report_block.png",
  1680. "scd.ied.LogControl": "icon_log_block.png",
  1681. "scd.ied.GSEControl": "icon_goose_block.png",
  1682. "scd.ied.goosepub": "icon_goose_block.png",
  1683. "scd.ied.goosesub": "icon_goose_block.png",
  1684. "scd.ied.SampledValueControl": "icon_sv_block.png",
  1685. "scd.ied.svpub": "icon_sv_block.png",
  1686. "scd.ied.svsub": "icon_sv_block.png",
  1687. "scd.ied.Communication": "icon_ap.png",
  1688. "scd.ied.goosepub.Communication": "icon_ap.png",
  1689. "scd.ied.goosesub.Communication": "icon_ap.png",
  1690. "scd.ied.smvpub.Communication": "icon_ap.png",
  1691. "scd.ied.smvsub.Communication": "icon_ap.png",
  1692. "scd.ied.Communication.GSE": "icon_goose.png",
  1693. "scd.ied.goosepub.Communication.GSE": "icon_goose.png",
  1694. "scd.ied.goosesub.Communication.GSE": "icon_goose.png",
  1695. "scd.ied.Communication.SMV": "icon_sv.png",
  1696. "scd.ied.smvpub.Communication.GSE": "icon_sv.png",
  1697. "scd.ied.smvsub.Communication.GSE": "icon_sv.png",
  1698. "scd.ied.Communication.S1": "icon_mms.png",
  1699. "scd.ied.DatSet": "icon_dataset.png",
  1700. "scd.ied.DatSetMeber": "icon_fcda.png",
  1701. "scd.ied.goosepub.FCDA": "icon_fcda.png",
  1702. "scd.ied.goosesub.FCDA": "icon_fcda.png",
  1703. "scd.ied.smvpub.FCDA": "icon_fcda.png",
  1704. "scd.ied.smvsub.FCDA": "icon_fcda.png",
  1705. }
  1706. var extCompAttrName = {
  1707. "DAI": 1,
  1708. "Address": 1,
  1709. "MaxTime": 1,
  1710. "MinTime": 1,
  1711. "lineno": 1,
  1712. "node_id": 1,
  1713. "SDI": 1,
  1714. "TrgOps": 1,
  1715. "OptFields": 1,
  1716. "RptEnabled": 1,
  1717. "Private": 1,
  1718. "GSE": 1,
  1719. "SMV": 1,
  1720. "PhysConn": 1,
  1721. "SmvOpts": 1,
  1722. }
  1723. var tempCacheData = {};
  1724. //绘制指定差异属性的数据图
  1725. var drawDiffMap = function(ele, iedname) {
  1726. var drawFlagId = ele.attr("idno");
  1727. var itemcode = ele.attr("itemcode");
  1728. var item = tempCacheData[itemcode + "_" + drawFlagId]
  1729. if (item == null) return;
  1730. var diff_desc = JSON.parse(item.diff_desc.replace(/\'| /gi, "").replace(/\r|\n|\t/gi, ""));
  1731. if (diff_desc == null) return;
  1732. var itemname = item.diff_object_name;
  1733. var itemchangetype = item.diff_opt;
  1734. if (item.diff_opt == 'u') {
  1735. //ied变化类型
  1736. //比较差异项
  1737. var s1 = (diff_desc[0])
  1738. var t1 = (diff_desc[1])
  1739. s1DaiMap = {};
  1740. t1DaiMap = {};
  1741. var daiList = diff_desc[0]["DAI"];
  1742. if (daiList != null) {
  1743. for (var p = 0; p < daiList.length; p++) {
  1744. s1DaiMap[daiList[p]["Name"]] = $.trim(daiList[p]["Val"].InnerText);
  1745. }
  1746. }
  1747. daiList = diff_desc[1]["DAI"];
  1748. if (daiList != null) {
  1749. for (var p = 0; p < daiList.length; p++) {
  1750. t1DaiMap[daiList[p]["Name"]] = $.trim(daiList[p]["Val"].InnerText)
  1751. }
  1752. }
  1753. if (diff_desc[0]["P"] != null) {
  1754. for (var p = 0; p < diff_desc[0]["P"].length; p++) {
  1755. var vitem = diff_desc[0]["P"][p];
  1756. s1DaiMap[vitem.Type] = $.trim(vitem.InnerText);
  1757. s1[vitem.Type] = s1DaiMap[vitem.Type]
  1758. }
  1759. delete(s1["P"]);
  1760. }
  1761. if (diff_desc[0]["Address"] != null && diff_desc[0]["Address"]["P"] != null) {
  1762. for (var p = 0; p < diff_desc[0]["Address"]["P"].length; p++) {
  1763. var vitem = diff_desc[0]["Address"]["P"][p];
  1764. s1DaiMap[vitem.Type] = $.trim(vitem.InnerText);
  1765. s1[vitem.Type] = s1DaiMap[vitem.Type]
  1766. }
  1767. delete(s1["Address"]);
  1768. }
  1769. if (diff_desc[0]["MaxTime"] != null) {
  1770. s1DaiMap["MaxTime"] = $.trim(diff_desc[0]["MaxTime"].InnerText);
  1771. s1DaiMap["MinTime"] = $.trim(diff_desc[0]["MinTime"].InnerText);
  1772. }
  1773. if (diff_desc[1]["P"] != null) {
  1774. for (var p = 0; p < diff_desc[1]["P"].length; p++) {
  1775. var vitem = diff_desc[1]["P"][p];
  1776. t1DaiMap[vitem.Type] = $.trim(vitem.InnerText);
  1777. t1[vitem.Type] = t1DaiMap[vitem.Type]
  1778. }
  1779. delete(t1["P"]);
  1780. }
  1781. if (diff_desc[1]["Address"] != null && diff_desc[1]["Address"]["P"] != null) {
  1782. for (var p = 0; p < diff_desc[1]["Address"]["P"].length; p++) {
  1783. var vitem = diff_desc[1]["Address"]["P"][p];
  1784. t1DaiMap[vitem.Type] = $.trim(vitem.InnerText);
  1785. t1[vitem.Type] = t1DaiMap[vitem.Type]
  1786. }
  1787. delete(t1["Address"]);
  1788. }
  1789. if (diff_desc[1]["MaxTime"] != null) {
  1790. t1DaiMap["MaxTime"] = $.trim(diff_desc[1]["MaxTime"].InnerText);
  1791. t1DaiMap["MinTime"] = $.trim(diff_desc[1]["MinTime"].InnerText);
  1792. }
  1793. var diffresult = Tools.GetMapDiffItems(s1DaiMap, t1DaiMap)
  1794. for (var k in s1) {
  1795. if (extCompAttrName[k] != null) {
  1796. for (var c1 in s1[k]) {
  1797. if (JSON.stringify(s1[k][c1]) != JSON.stringify(t1[k][c1])) {
  1798. diffresult.edit[k + "." + c1] = [s1[k][c1] || '[空]', t1[k][c1] || '[空]'];
  1799. diffresult._edit_cnt++;
  1800. }
  1801. }
  1802. continue
  1803. }
  1804. if (s1[k] != t1[k]) {
  1805. diffresult.edit[k] = [s1[k] || '[空]', t1[k] || '[空]'];
  1806. diffresult._edit_cnt++;
  1807. }
  1808. }
  1809. //绘制修改的项
  1810. if (diffresult._edit_cnt > 0) PoliceObject.MakeComp(iedname, itemcode, drawFlagId, itemname, item.diff_opt, 'u', diffresult.edit);
  1811. //绘制新增的项
  1812. if (diffresult._add_cnt > 0) PoliceObject.MakeComp(iedname, itemcode, drawFlagId, itemname, item.diff_opt, 'i', diffresult.add);
  1813. //绘制删除的项
  1814. if (diffresult._del_cnt > 0) PoliceObject.MakeComp(iedname, itemcode, drawFlagId, itemname, item.diff_opt, 'd', diffresult.del);
  1815. } else if (item.diff_opt == 'i') {
  1816. if (diff_desc["RptEnabled"] != null) diff_desc["RptEnabled.Max"] = diff_desc["RptEnabled"]["Max"]
  1817. var obj = {}
  1818. if (diff_desc["P"] != null) {
  1819. for (var p = 0; p < diff_desc["P"].length; p++) {
  1820. var vitem = diff_desc["P"][p];
  1821. diff_desc[vitem.Type] = $.trim(vitem.InnerText);
  1822. }
  1823. delete(diff_desc["P"]);
  1824. }
  1825. if (diff_desc["Address"] != null && diff_desc["Address"]["P"] != null) {
  1826. for (var p = 0; p < diff_desc["Address"]["P"].length; p++) {
  1827. var vitem = diff_desc["Address"]["P"][p];
  1828. diff_desc[vitem.Type] = $.trim(vitem.InnerText);
  1829. }
  1830. delete(diff_desc["Address"]);
  1831. }
  1832. for (var k in diff_desc) {
  1833. if (extCompAttrName[k] == null) obj[k] = diff_desc[k];
  1834. }
  1835. diffresult = {
  1836. "add": obj
  1837. }
  1838. //绘制数据变化图
  1839. PoliceObject.MakeComp(iedname, itemcode, drawFlagId, itemname, item.diff_opt, 'i', diffresult.add);
  1840. } else if (item.diff_opt == 'd') {
  1841. var obj = {}
  1842. if (diff_desc["P"] != null) {
  1843. for (var p = 0; p < diff_desc["P"].length; p++) {
  1844. var vitem = diff_desc["P"][p];
  1845. diff_desc[vitem.Type] = $.trim(vitem.InnerText);
  1846. }
  1847. delete(diff_desc["P"]);
  1848. }
  1849. if (diff_desc["Address"] != null && diff_desc["Address"]["P"] != null) {
  1850. for (var p = 0; p < diff_desc["Address"]["P"].length; p++) {
  1851. var vitem = diff_desc["Address"]["P"][p];
  1852. diff_desc[vitem.Type] = $.trim(vitem.InnerText);
  1853. }
  1854. delete(diff_desc["Address"]);
  1855. }
  1856. for (var k in diff_desc) {
  1857. if (extCompAttrName[k] == null) obj[k] = diff_desc[k];
  1858. }
  1859. diffresult = {
  1860. "del": obj
  1861. }
  1862. //绘制数据变化图
  1863. PoliceObject.MakeComp(iedname, itemcode, drawFlagId, itemname, item.diff_opt, 'd', diffresult.del);
  1864. }
  1865. }
  1866. var loadCompResult = function(iedname, itemcode, resultData) {
  1867. var comp_show_area = $("#comp_ied_result_show .comp_show_area");
  1868. comp_show_area.attr("itemcode", itemcode).html(template('comp_ied_result_show_tpl', {}));
  1869. var vh = comp_show_area.height();
  1870. comp_show_area.slimScroll({
  1871. height: (vh * 0.99) + "px",
  1872. width: "98%",
  1873. alwaysVisible: false,
  1874. wheelStep: 10,
  1875. size: "6px",
  1876. color: "#03aee7"
  1877. });
  1878. comp_show_area.css("width", "100%").find(".comp_ied_result_split_line");
  1879. if (itemcode == "scd.ied.Relation") {
  1880. //虚回路
  1881. resultData.sort(Tools.SortBy("no", true));
  1882. PoliceObject.drawIedInputsRelation(sourcescdid, PoliceObject.GetIedData(iedname, sourcescdid), comp_show_area, resultData);
  1883. return
  1884. }
  1885. var source_ied = comp_show_area.find(".source_ied .ied_name").html(iedname).parent();
  1886. var target_ied = comp_show_area.find(".target_ied .ied_name").html(iedname).parent();
  1887. var drawFlagId = {};
  1888. var nosameitem = {};
  1889. //基础信息显示
  1890. if (itemcode == "scd.ied") {
  1891. if (ctype == 'u') {
  1892. //比较差异项
  1893. for (var k in resultData[0]) {
  1894. if (k == "lineno" || k == "node_id") continue;
  1895. if (resultData[0][k] != resultData[1][k]) {
  1896. nosameitem[k] = [resultData[0][k] || '[空]', resultData[1][k] || '[空]'];
  1897. }
  1898. }
  1899. } else {
  1900. for (var k in resultData[0]) {
  1901. if (k == "lineno" || k == "node_id") continue;
  1902. nosameitem[k] = resultData[0][k] || '[空]';
  1903. }
  1904. }
  1905. tempCacheData[itemcode + "_9999"] = item;
  1906. var itemname = "基本信息";
  1907. var itemchangetype = 'u'
  1908. comp_show_area.append('<div itemopt="u" itemcode="' + itemcode + '" idno=9999 class="typeele" dir="source"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1909. comp_show_area.append('<div itemopt="u" itemcode="' + itemcode + '" idno=9999 class="typeele" dir="target"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1910. setTimeout(function() {
  1911. comp_show_area.find(".typeele[dir='source']:first").trigger('click');
  1912. PoliceObject.MakeComp(iedname, itemcode, 9999, itemname, 'u', ctype, nosameitem);
  1913. }, 300)
  1914. } else {
  1915. for (var i = 0; i < resultData.length; i++) {
  1916. var item = resultData[i];
  1917. //console.log(item.diff_desc.replace(/\'| /gi, "").replace(/\r|\n|\t/gi, "a"))
  1918. var diff_desc = JSON.parse(item.diff_desc.replace(/\'| /gi, "").replace(/\r|\n|\t/gi, ""));
  1919. if (diff_desc == null) continue;
  1920. var itemname = item.diff_object_name;
  1921. var itemchangetype = item.diff_opt;
  1922. drawFlagId[itemcode + i] = 1001 + (i * 100000) //当前类型将绘制元素的起始id号及差异项代码
  1923. tempCacheData[itemcode + "_" + drawFlagId[itemcode + i]] = item;
  1924. if (item.diff_opt == 'u') {
  1925. comp_show_area.append('<div itemopt="u" itemcode="' + itemcode + '" idno=' + drawFlagId[itemcode + i] + ' title="' + itemname + '" class="typeele" dir="source"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1926. comp_show_area.append('<div itemopt="u" itemcode="' + itemcode + '" idno=' + drawFlagId[itemcode + i] + ' title="' + itemname + '" class="typeele" dir="target"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1927. } else if (item.diff_opt == 'i') {
  1928. comp_show_area.append('<div itemopt="i" itemcode="' + itemcode + '" idno=' + drawFlagId[itemcode + i] + ' title="' + itemname + '" class="typeele" dir="source"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1929. } else if (item.diff_opt == 'd') {
  1930. comp_show_area.append('<div itemopt="d" itemcode="' + itemcode + '" idno=' + drawFlagId[itemcode + i] + ' title="' + itemname + '" class="typeele" dir="target"><img class="type_icon" src="/static/images/comp_scd/' + itemcode_icon[itemcode] + '"><div class="type_name color_' + itemchangetype + '">' + itemname + '</div><span class="state_icon state_icon_' + itemchangetype + '"></span></div>')
  1931. }
  1932. }
  1933. //drawDiffMap(comp_show_area.find(".typeele:first"), iedname);
  1934. }
  1935. var iedFirstLineWidth = 40;
  1936. var iedItemLineWidth = 20;
  1937. //重新排列基准SCD中的typeele
  1938. var totlcnt = comp_show_area.find(".typeele[dir='source']").length;
  1939. if (totlcnt >= 1) {
  1940. //绘制IED与差异之前的连线
  1941. var sourceIedLine = PoliceObject.drawDivLine(comp_show_area, [source_ied.position().left + source_ied.width(), source_ied.position().top + source_ied.css("margin-top").replace("px", "") * 1 + source_ied.height() / 2], [iedFirstLineWidth, null],
  1942. "source_ied_first_line",
  1943. "bgcolor_0"
  1944. );
  1945. var sourceIedLineXY = sourceIedLine.position();
  1946. var one = comp_show_area.find(".typeele[dir='source']:first");
  1947. var left = sourceIedLineXY.left + iedFirstLineWidth + iedItemLineWidth;
  1948. var sigleH = one.height() + one.css("margin-top").replace("px", "") * 1;
  1949. var totalH = totlcnt * sigleH;
  1950. var inith = 0; //初始化top
  1951. if (totalH >= vh) {
  1952. inith = 60;
  1953. comp_show_area.find(".comp_ied_result_split_line").height(inith + 30 + sigleH * totlcnt);
  1954. } else {
  1955. if (totlcnt > 1) inith = (vh - totalH) / 2;
  1956. else inith = sourceIedLineXY.top - sigleH / 2;
  1957. }
  1958. var preEle = null;
  1959. var firstEle = null;
  1960. comp_show_area.find(".typeele[dir='source']").each(function(index) {
  1961. var t = $(this);
  1962. t.on('click', function() {
  1963. var t = $(this);
  1964. if (PoliceObject.currentCompItem != null) {
  1965. var oldIDNo = PoliceObject.currentCompItem.attr("idno");
  1966. comp_show_area.find(".typeele.active").removeClass("active");
  1967. comp_show_area.find(".typeele[dir='target'][idno='" + oldIDNo + "']").removeClass("active");
  1968. //清除之前绘制的元素
  1969. comp_show_area.children("div[flagid='" + oldIDNo + "']").remove();
  1970. }
  1971. PoliceObject.currentCompItem = t.addClass("active");
  1972. comp_show_area.find(".typeele[dir='target'][idno='" + t.attr("idno") + "']").addClass("active");
  1973. //点击差异属性,切换展示数据数据图
  1974. //绘制点击元素的数据图
  1975. var currentCompItemXY = PoliceObject.currentCompItem.position();
  1976. //如果当前元素top为负时,需要自动将画布向上滚动一定距离,至少保证top为不负数
  1977. if (currentCompItemXY.top < 60) {
  1978. var scrollHeight = PoliceObject.currentCompItem.attr("oldtop") * 1 - currentCompItemXY.top;
  1979. comp_show_area.slimScroll({
  1980. scrollTo: scrollHeight - 100
  1981. });
  1982. setTimeout(function() {
  1983. //当点击元素处于非完全可见时(即top为负时),需要延时绘图,等滚动条自动滚动完成,否则获取到的位置不正确
  1984. drawDiffMap(t, iedname);
  1985. }, 300)
  1986. return;
  1987. }
  1988. drawDiffMap(t, iedname);
  1989. });
  1990. var newtop = inith;
  1991. if (preEle == null)
  1992. t.css({
  1993. "top": inith,
  1994. "left": left
  1995. });
  1996. else {
  1997. newtop = preEle.position().top + (preEle.height() + preEle.css("margin-top").replace("px", "") * 1);
  1998. t.css({
  1999. "top": newtop,
  2000. "left": left
  2001. });
  2002. }
  2003. if (firstEle == null) firstEle = t;
  2004. preEle = t.attr("oldtop", newtop);
  2005. PoliceObject.drawDivLine(comp_show_area, [sourceIedLineXY.left + sourceIedLine.width(), newtop + (t.height() + t.css("margin-top").replace("px", "") * 1) / 2], [iedItemLineWidth, null],
  2006. "source_ied_item_line_" + index,
  2007. "bgcolor_0"
  2008. );
  2009. })
  2010. var lineH = preEle.position().top - firstEle.position().top;
  2011. PoliceObject.drawDivLine(comp_show_area, [sourceIedLineXY.left + sourceIedLine.width(), firstEle.position().top + (firstEle.css("margin-top").replace("px", "") * 1 + firstEle.height()) / 2], [null, lineH],
  2012. "source_ied_item_line",
  2013. "bgcolor_0"
  2014. );
  2015. }
  2016. //重新排列比对SCD中的typeele
  2017. var targettotlcnt = comp_show_area.find(".typeele[dir='target']").length;
  2018. if (targettotlcnt >= 1) {
  2019. //绘制IED与差异之前的连线
  2020. var targetIedLine = PoliceObject.drawDivLine(comp_show_area, [target_ied.position().left - iedFirstLineWidth, target_ied.position().top + target_ied.css("margin-top").replace("px", "") * 1 + target_ied.height() / 2], [iedFirstLineWidth, null],
  2021. "target_ied_first_line",
  2022. "bgcolor_0"
  2023. );
  2024. var targetIedLineXY = targetIedLine.position();
  2025. var one = comp_show_area.find(".typeele[dir='target']:first");
  2026. var left = targetIedLineXY.left - iedItemLineWidth;
  2027. var sigleH = one.height() + one.css("margin-top").replace("px", "") * 1;
  2028. var totalH = targettotlcnt * sigleH;
  2029. var inith = 0; //初始化top
  2030. if (totalH >= vh) {
  2031. inith = 60;
  2032. if (comp_show_area.find(".comp_ied_result_split_line").height() < totalH) {
  2033. comp_show_area.find(".comp_ied_result_split_line").height(inith + 30 + sigleH * totlcnt);
  2034. }
  2035. } else {
  2036. if (targettotlcnt > 1) inith = (vh - totalH) / 2;
  2037. else inith = targetIedLineXY.top - sigleH / 2;
  2038. }
  2039. var preEle = null;
  2040. var firstEle = null;
  2041. comp_show_area.find(".typeele[dir='target']").each(function(index) {
  2042. var t = $(this);
  2043. if (t.attr("itemopt") == "d") {
  2044. t.on('click', function() {
  2045. var t = $(this);
  2046. if (PoliceObject.currentCompItem != null) {
  2047. var oldIDNo = PoliceObject.currentCompItem.attr("idno");
  2048. comp_show_area.find(".typeele.active").removeClass("active");
  2049. comp_show_area.find(".typeele[dir='source'][idno='" + oldIDNo + "']").removeClass("active");
  2050. //清除之前绘制的元素
  2051. comp_show_area.children("div[flagid='" + oldIDNo + "']").remove();
  2052. }
  2053. PoliceObject.currentCompItem = t.addClass("active");
  2054. comp_show_area.find(".typeele[dir='source'][idno='" + t.attr("idno") + "']").addClass("active");
  2055. //点击差异属性,切换展示数据数据图
  2056. //绘制点击元素的数据图
  2057. var currentCompItemXY = PoliceObject.currentCompItem.position();
  2058. //如果当前元素top为负时,需要自动将画布向上滚动一定距离,至少保证top为不负数
  2059. if (currentCompItemXY.top < 60) {
  2060. var scrollHeight = PoliceObject.currentCompItem.attr("oldtop") * 1 - currentCompItemXY.top;
  2061. comp_show_area.slimScroll({
  2062. scrollTo: scrollHeight - 100
  2063. });
  2064. setTimeout(function() {
  2065. //当点击元素处于非完全可见时(即top为负时),需要延时绘图,等滚动条自动滚动完成,否则获取到的位置不正确
  2066. drawDiffMap(t, iedname);
  2067. //调整当前查看的差异属性连线位置
  2068. var scrollHeight = PoliceObject.currentCompItem.attr("oldtop") * 1 - PoliceObject.currentCompItem.position().top;
  2069. var itemAttrsSourcelineEle = comp_show_area.find("#" + t.attr("idno") + "_item_attrs_target").css("top", scrollHeight + t.position().top + t.height() / 2);
  2070. var itemAttrsSourceAlllineEle = comp_show_area.find("#" + t.attr("idno") + "_item_attrs_target_all");
  2071. if (itemAttrsSourceAlllineEle.position().top > itemAttrsSourcelineEle.position().top) {
  2072. itemAttrsSourceAlllineEle.css({
  2073. "top": itemAttrsSourcelineEle.position().top,
  2074. "height": itemAttrsSourceAlllineEle.position().top - itemAttrsSourcelineEle.position().top
  2075. })
  2076. }
  2077. }, 300)
  2078. return;
  2079. }
  2080. drawDiffMap(t, iedname);
  2081. var deallist = ["target"];
  2082. for (var di = 0; di < deallist.length; di++) {
  2083. //调整当前查看的差异属性连线位置
  2084. var scrollHeight = PoliceObject.currentCompItem.attr("oldtop") * 1 - PoliceObject.currentCompItem.position().top;
  2085. var itemAttrsSourcelineEle = comp_show_area.find("#" + t.attr("idno") + "_item_attrs_" + deallist[di]).css("top", scrollHeight + t.position().top + t.height() / 2);
  2086. var itemAttrsSourceAlllineEle = comp_show_area.find("#" + t.attr("idno") + "_item_attrs_" + deallist[di] + "_all");
  2087. if (itemAttrsSourceAlllineEle.position().top > itemAttrsSourcelineEle.position().top) {
  2088. itemAttrsSourceAlllineEle.css({
  2089. "top": itemAttrsSourcelineEle.position().top,
  2090. "height": itemAttrsSourceAlllineEle.position().top - itemAttrsSourcelineEle.position().top
  2091. })
  2092. }
  2093. }
  2094. });
  2095. }
  2096. var newtop = inith;
  2097. if (preEle == null)
  2098. t.css({
  2099. "top": inith,
  2100. "left": left - t.width()
  2101. });
  2102. else {
  2103. newtop = preEle.position().top + (preEle.height() + preEle.css("margin-top").replace("px", "") * 1);
  2104. t.css({
  2105. "top": newtop,
  2106. "left": left - t.width()
  2107. });
  2108. }
  2109. if (firstEle == null) firstEle = t;
  2110. preEle = t.attr("oldtop", newtop);
  2111. PoliceObject.drawDivLine(comp_show_area, [targetIedLineXY.left - iedItemLineWidth, newtop + (t.height() + t.css("margin-top").replace("px", "") * 1) / 2], [iedItemLineWidth, null],
  2112. "target_ied_item_line_" + index,
  2113. "bgcolor_0"
  2114. );
  2115. })
  2116. var lineH = preEle.position().top - firstEle.position().top;
  2117. PoliceObject.drawDivLine(comp_show_area, [targetIedLineXY.left, firstEle.position().top + (firstEle.css("margin-top").replace("px", "") * 1 + firstEle.height()) / 2], [null, lineH],
  2118. "target_ied_item_line",
  2119. "bgcolor_0"
  2120. );
  2121. }
  2122. if (totlcnt > 0) {
  2123. comp_show_area.find(".typeele[dir='source']:first").trigger('click');
  2124. } else {
  2125. //如果基准scd侧没有变化的元素,则默认自动点击对比侧第一个元素
  2126. comp_show_area.find(".typeele[dir='target']:first").trigger('click');
  2127. }
  2128. layer.closeAll();
  2129. }
  2130. this.currentCompItem = null;
  2131. layer.msg("正在加载数据中");
  2132. if (win.ccd_cid_info != null) {
  2133. var datalist = [];
  2134. for (var i = 0; i < win.ccd_cid_info.list.length; i++) {
  2135. if (win.ccd_cid_info.list[i].diff_object_type == itemcode) {
  2136. if (itemcode == "scd.ied") {
  2137. //转换ied基本差异信息
  2138. var diff_desc = JSON.parse(win.ccd_cid_info.list[i].diff_desc.replace(/\'| /gi, "").replace(/\r|\n|\t/gi, ""));
  2139. if (diff_desc == null) continue;
  2140. datalist = diff_desc;
  2141. } else {
  2142. datalist.push(win.ccd_cid_info.list[i]);
  2143. }
  2144. }
  2145. }
  2146. loadCompResult(iedname, itemcode, datalist);
  2147. } else {
  2148. $.getJSON(Global.AccessUrl + "/api/scd/comp/result", {
  2149. comp_id: compid,
  2150. ied_name: iedname,
  2151. comptype: ctype,
  2152. itemcode: itemcode
  2153. }, function(jsondata) {
  2154. if (jsondata.code != 0) {
  2155. layer.msg(jsondata.msg, {
  2156. icon: Global.ICON_ERROR
  2157. })
  2158. return
  2159. }
  2160. loadCompResult(iedname, itemcode, jsondata.data);
  2161. });
  2162. }
  2163. },
  2164. MakeComp: function(iedname, itemcode, flagId, itemname, itemchangetype, ctype, nosameitem) {
  2165. var comp_show_area = $("#comp_ied_result_show .comp_show_area");
  2166. var sourceied = comp_show_area.find(".source_ied .ied_name").parent();
  2167. var targetied = comp_show_area.find(".target_ied .ied_name").parent();
  2168. //生成详细项.先确定细项位置
  2169. var v_top = 60; //初始位置
  2170. var scrollHeight = 0; //滚动条滚动距离
  2171. if (PoliceObject.currentCompItem != null) {
  2172. var currentCompItemXY = PoliceObject.currentCompItem.position(); //当前元素的当前位置。当滚动了画布时,以当前为置为准
  2173. v_top = PoliceObject.currentCompItem.attr("oldtop") * 1;
  2174. scrollHeight = v_top - currentCompItemXY.top;
  2175. }
  2176. var detailItemtotalH = 0;
  2177. var detailItems = null;
  2178. var firstDetailItem = null;
  2179. var detailItemsCount = 0;
  2180. for (var k in nosameitem) {
  2181. var attrDesc = Global.SCD_COMP_ATTR_CONST["ied." + k]
  2182. if (attrDesc == null) attrDesc = k;
  2183. if (ctype == 'u') {
  2184. //属性修改
  2185. detailItems = $('<div flagId="' + flagId + '" attr_name="' + attrDesc + '" style="left:50%;margin-left:-13rem;top:' + (v_top) + 'px;color:#09162C;font-weight:bold;" class="comp_scd_detail_item bordercolor_' + ctype + '"><div style="width:40%">' + (nosameitem[k][0] == "" ? "[空]" : nosameitem[k][0]) + '</div><div style="width:17%"><img class="allow_img" src="/static/images/comp_scd/allow_edit.png"></div><div style="width:40%">' + (nosameitem[k][1] == "" ? "[空]" : nosameitem[k][1]) + '</div></div>');
  2186. } else if (ctype == 'i') {
  2187. //属性新增
  2188. detailItems = $('<div flagId="' + flagId + '" attr_name="' + attrDesc + '" style="left:37%;margin-left:0;width:10rem;top:' + (v_top) + 'px;color:#09162C;font-weight:bold;" class="comp_scd_detail_item bordercolor_' + ctype + '"><div style="width:100%">' + (nosameitem[k] == "" ? "[空]" : nosameitem[k]) + '</div></div>');
  2189. } else {
  2190. //属性删除
  2191. detailItems = $('<div flagId="' + flagId + '" attr_name="' + attrDesc + '" style="left:52%;margin-left:0;width:10rem;top:' + (v_top) + 'px;color:#09162C;font-weight:bold;" class="comp_scd_detail_item bordercolor_' + ctype + '"><div style="width:100%">' + (nosameitem[k] == "" ? "[空]" : nosameitem[k]) + '</div></div>');
  2192. }
  2193. comp_show_area.append(detailItems)
  2194. if (firstDetailItem == null) firstDetailItem = detailItems;
  2195. v_top = detailItems.position().top + detailItems.height() + 50 + scrollHeight;
  2196. detailItemsCount++;
  2197. }
  2198. if (detailItems == null) return;
  2199. detailItemtotalH = detailItems.position().top + detailItems.height() - firstDetailItem.position().top;
  2200. //重新计算初始位置 ,使其显示的中间
  2201. var vh = comp_show_area.height();
  2202. //根据当前点击的变化属性元素,计算出需要上下移动的距离
  2203. var v_top_new = 60;
  2204. if (vh >= detailItemtotalH) {
  2205. v_top_new = (vh - detailItemtotalH) / 2;
  2206. }
  2207. var lineFirstXY = null; //基准侧第一个属性元素框
  2208. var lineEndXY = null; //基准侧最后一属性元素框
  2209. var lineFirstXY_right = null; //比对侧第一个属性元素框
  2210. var lineEndXY_right = null; //比对侧最后一属性元素框
  2211. var currentCompItemXY = PoliceObject.currentCompItem.position();
  2212. var one = comp_show_area.find(".comp_scd_detail_item:first");
  2213. one.css("top", scrollHeight + currentCompItemXY.top - 100);
  2214. var lastEle = one;
  2215. var oneXY = one.position();
  2216. var topSub = v_top_new - oneXY.top;
  2217. comp_show_area.find(".comp_scd_detail_item").each(function() {
  2218. var t = $(this);
  2219. if (detailItemsCount > 1) {
  2220. //微调差异内容框top位置
  2221. if (lastEle == null) {
  2222. var tmpTop = t.css("top").replace("px", "") * 1 + (topSub);
  2223. if (t.next().length == 0 && tmpTop > currentCompItemXY.top) {
  2224. tmpTop = tmpTop - topSub; //还原top
  2225. }
  2226. } else {
  2227. tmpTop = scrollHeight + lastEle.position().top + lastEle.height() + 40;
  2228. }
  2229. } else {
  2230. var tmpTop = scrollHeight + currentCompItemXY.top + (PoliceObject.currentCompItem.height() / 2) + 1 - (t.height() + 4) / 2;
  2231. }
  2232. t.css("top", tmpTop);
  2233. lastEle = t;
  2234. var txy = t.position();
  2235. var newTop = scrollHeight + txy.top + t.css("padding-top").replace("px", "") * 1 + t.height() / 2;
  2236. //绘制差异内容框与元素之间的连接线
  2237. if (ctype == 'u' || ctype == 'i') {
  2238. //基准SCD
  2239. var tMarginleft = txy.left + t.css("margin-left").replace("px", "") * 1
  2240. var line = PoliceObject.drawDivLine(comp_show_area, [tMarginleft - 100, newTop], [100, null], null, "bgcolor_" + ctype);
  2241. line.attr({
  2242. "flagId": flagId
  2243. })
  2244. }
  2245. if (ctype == 'u' || ctype == 'd') {
  2246. var tMarginleft = txy.left + t.css("margin-left").replace("px", "") * 1
  2247. //比对SCD,其中4为左右边框总宽度
  2248. var right_left = tMarginleft + t.width() + t.css("padding-right").replace("px", "") * 2 + 4;
  2249. var line = PoliceObject.drawDivLine(comp_show_area, [right_left, newTop], [100, null], null, "bgcolor_" + ctype);
  2250. line.attr({
  2251. "flagId": flagId
  2252. })
  2253. }
  2254. //绘制差异项名称
  2255. if (ctype == 'u' || ctype == 'i') {
  2256. //基准SCD
  2257. comp_show_area.append('<div flagId="' + flagId + '" class="abs comp_scd_detail_item_attrtag bordercolor_' + ctype + ' color_' + ctype + '" style="left:' + (tMarginleft - 100 + 20) + 'px;top:' + (newTop - 13) + 'px;">' + t.attr('attr_name') + '</div>');
  2258. }
  2259. if (ctype == 'u' || ctype == 'd') {
  2260. //比对SCD
  2261. comp_show_area.append('<div flagId="' + flagId + '" class="abs comp_scd_detail_item_attrtag bordercolor_' + ctype + ' color_' + ctype + '" style="left:' + (line.position().left + 20) + 'px;top:' + (newTop - 13) + 'px;">' + t.attr('attr_name') + '</div>');
  2262. }
  2263. if (ctype == 'u' || ctype == 'i') {
  2264. if (lineFirstXY == null) lineFirstXY = [tMarginleft - 100, newTop];
  2265. lineEndXY = [tMarginleft - 100, newTop];
  2266. }
  2267. if (ctype == 'u' || ctype == 'd') {
  2268. if (lineFirstXY_right == null) lineFirstXY_right = [right_left + line.width(), newTop];
  2269. lineEndXY_right = [right_left + line.width(), newTop];
  2270. }
  2271. });
  2272. //绘制当前点击差异属性元素与内容项之间的连接线
  2273. if (ctype == 'u' || ctype == 'i') {
  2274. var lineEle2 = PoliceObject.drawDivLine(comp_show_area, lineFirstXY, [null, lineEndXY[1] - lineFirstXY[1]], flagId + "_item_attrs_source_all", "bgcolor_" + ctype);
  2275. lineEle2.attr({
  2276. "flagId": flagId
  2277. })
  2278. var currEleXY = PoliceObject.currentCompItem.position();
  2279. var v_x = currEleXY.left + PoliceObject.currentCompItem.width() + PoliceObject.currentCompItem.css("border-width").replace("px", "") * 2;
  2280. var lineEle = PoliceObject.drawDivLine(comp_show_area, [v_x, scrollHeight + currEleXY.top - 1 + PoliceObject.currentCompItem.css("margin-top").replace("px", "") * 1 + PoliceObject.currentCompItem.height() / 2], [lineFirstXY[0] - v_x, null], flagId + "_item_attrs_source", "bgcolor_" + ctype);
  2281. lineEle.attr({
  2282. "flagId": flagId
  2283. })
  2284. if (lineEle2.height() == 0) {
  2285. if (lineFirstXY[1] > scrollHeight + lineEle.position().top) lineFirstXY[1] = lineEle.position().top
  2286. lineEle2.css({
  2287. "top": lineFirstXY[1],
  2288. "height": lineEndXY[1] - lineFirstXY[1]
  2289. });
  2290. }
  2291. }
  2292. if (ctype == 'u' || ctype == 'd') {
  2293. var currEle = comp_show_area.find(".typeele[dir='target'][idno='" + PoliceObject.currentCompItem.attr("idno") + "']");
  2294. if (currEle.length > 0) {
  2295. //绘制与比对ied差异项元素之间的连接线
  2296. var lineEle2 = PoliceObject.drawDivLine(comp_show_area, lineFirstXY_right, [null, lineEndXY_right[1] - lineFirstXY_right[1]], flagId + "_item_attrs_target_all", "bgcolor_" + ctype);
  2297. lineEle2.attr({
  2298. "flagId": flagId
  2299. })
  2300. var li1 = $("#" + PoliceObject.currentCompItem.attr("idno") + "_item_attrs_target_all")
  2301. var v_x = li1.position().left
  2302. var lineEle = PoliceObject.drawDivLine(comp_show_area, [v_x, scrollHeight + currEle.position().top - 1 + currEle.css("margin-top").replace("px", "") * 1 + currEle.height() / 2], [currEle.position().left - v_x, null], flagId + "_item_attrs_target", "bgcolor_" + ctype);
  2303. lineEle.attr({
  2304. "flagId": flagId
  2305. })
  2306. if (lineEle2.height() == 0) {
  2307. if (lineFirstXY_right[1] > scrollHeight + lineEle.position().top) lineFirstXY_right[1] = lineEle.position().top
  2308. lineEle2.css({
  2309. "top": lineFirstXY_right[1],
  2310. "height": lineEndXY_right[1] - lineFirstXY_right[1]
  2311. });
  2312. }
  2313. }
  2314. }
  2315. var maxH = 0;
  2316. if (lineEndXY != null) {
  2317. var typeeleLast = comp_show_area.find(".typeele[dir='source']:last");
  2318. var typeeleLastY = typeeleLast.position().top + typeeleLast.height();
  2319. maxH = lineEndXY[1];
  2320. if (maxH < typeeleLastY) maxH = typeeleLastY;
  2321. }
  2322. if (lineEndXY_right != null) {
  2323. var tmpH = lineEndXY_right[1];
  2324. var typeeleLast = comp_show_area.find(".typeele[dir='target']:last");
  2325. var typeeleLastY = typeeleLast.position().top + typeeleLast.height();
  2326. if (maxH < tmpH) maxH = tmpH;
  2327. if (maxH < typeeleLastY) maxH = typeeleLastY;
  2328. }
  2329. maxH = maxH + 74;
  2330. var splitLine = comp_show_area.find(".comp_ied_result_split_line");
  2331. if (maxH > splitLine.height()) splitLine.height(maxH);
  2332. },
  2333. drawDivLine: function(parentele, fromXY, toWH, lineid, color) {
  2334. var id = (lineid == null ? ("L" + (parseInt(fromXY[0]) + "_" + parseInt(fromXY[1]))) : lineid);
  2335. while (parentele.find("#" + id).length > 0) {
  2336. id = id + (parentele.find("#" + id).length + 1)
  2337. }
  2338. parentele.append('<div class="pointer_line" id="' + id + '"></div>')
  2339. var line = parentele.find("#" + id);
  2340. if (color != null) line.addClass(color);
  2341. line.css({
  2342. left: fromXY[0],
  2343. top: fromXY[1],
  2344. width: toWH[0] == null ? 1 : toWH[0],
  2345. height: toWH[1] == null ? 1 : toWH[1],
  2346. });
  2347. return line;
  2348. },
  2349. subNetworkIsLoading: false,
  2350. GetSubNetwork: function() {
  2351. if (this.subNetworkIsLoading) {
  2352. return;
  2353. }
  2354. this.subNetworkIsLoading = true;
  2355. var network = $("#container_map_ied #network").html("");
  2356. network.css("top", 20 * hRate);
  2357. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  2358. "scd_id": PoliceObject.ScdID,
  2359. "pagesize": 10000,
  2360. "name": "SubNetwork"
  2361. }, function(r) {
  2362. PoliceObject.subNetworkIsLoading = false;
  2363. if (r.data == null) return;
  2364. var avgWidth = 100 / r.data.length;
  2365. for (var i = 0; i < r.data.length; i++) {
  2366. network.append('<div class="network_item" style="width:' + avgWidth + '%" network_id="' + r.data[i].node_id + '"><img style="width: 10rem;" src="/static/images/network_hub.png"><div class="network_desc">' + r.data[i].attr_desc + '</div><div class="network_name">' + r.data[i].attr_name + '</div></div>');
  2367. }
  2368. network.find(".network_item").off().on("click", function() {
  2369. network.find(".active").removeClass("active");
  2370. loadNetworkAPInfo($(this).attr('network_id'));
  2371. });
  2372. network.append('<div class="network_ap aplist">正在加载数据中</div>');
  2373. network.append('<div class="network-iedlist"></div>');
  2374. var loadNetworkAPInfo = function(networkid) {
  2375. var loadApInfo = [];
  2376. var $aplistEle = $("#network .network_ap").attr("networkid", networkid).html("");
  2377. var ledlist = $("#network .network-iedlist").html("<div class='f_l' style='margin-left:6%'></div>");
  2378. $("#network .network-line").remove();
  2379. $("#network .network-ied-line").remove();
  2380. $("#network .network-ied-line2").remove();
  2381. for (var key in PoliceObject.NetWork_ApNodes) {
  2382. if (networkid == null || key.indexOf(networkid) > -1) {
  2383. networkid = key.split(".")[0];
  2384. loadApInfo.push(PoliceObject.NetWork_ApNodes[key]);
  2385. }
  2386. }
  2387. var sourceNetworkEle = network.find(".network_item[network_id='" + networkid + "']").addClass("active");
  2388. if (loadApInfo.length == 0) {
  2389. return;
  2390. }
  2391. for (var i = 0; i < loadApInfo.length; i++) {
  2392. var apname = loadApInfo[i].attr_ap_name;
  2393. $aplistEle.append('<div class="sub_line ' + apname + '" apname="' + apname + '" style="top:' + ((i + 1) * 2) + 'rem"><span class="line-apname ' + apname + '">' + apname + '</span></div>')
  2394. }
  2395. $aplistEle.css("height", loadApInfo.length * 22 + "px").find(".sub_line").off().on('click', function() {
  2396. //单击总线,只显示该总线的设备
  2397. if ($aplistEle.find(".sub_line").length < 2) return;
  2398. var tmp1 = $(this);
  2399. tmp1.parent().find(".sub_line").css("opacity", 0.3);
  2400. tmp1.css("opacity", 1);
  2401. var ishow = $.trim(tmp1.attr("ishow"));
  2402. var v_apname = tmp1.attr("apname");
  2403. ishow = ishow == "" || ishow == "1" ? "0" : "1";
  2404. tmp1.attr("ishow", ishow);
  2405. $("#network .network-line").each(function() {
  2406. var t = $(this);
  2407. t.css("opacity", t.attr("apname") == v_apname ? 1 : 0.3);
  2408. /*if (t.attr("apname") == v_apname) {
  2409. if (ishow == "0") t.addClass("hidden");
  2410. else t.removeClass("hidden");
  2411. t.css("opacity", 1);
  2412. }*/
  2413. });
  2414. $("#network .network-ied-line").each(function() {
  2415. var t = $(this);
  2416. if (t.attr("apname") == v_apname) t.removeClass("hidden");
  2417. else t.addClass("hidden");
  2418. //t.css("opacity", t.attr("apname") == v_apname ? 1 : 0.2);
  2419. /*if (t.attr("apname") == v_apname) {
  2420. if (ishow == "0") t.addClass("hidden");
  2421. else t.removeClass("hidden");
  2422. t.css("opacity", 1);
  2423. }*/
  2424. });
  2425. var rel_ied_list = [];
  2426. $("#network .network-ied-line2").each(function() {
  2427. var t = $(this);
  2428. if (t.attr("apname") == v_apname) t.removeClass("hidden");
  2429. else t.addClass("hidden");
  2430. //t.css("opacity", t.attr("apname") == v_apname ? 1 : 0.2);
  2431. if (t.attr("apname") == v_apname) {
  2432. rel_ied_list.push(t.attr("foried"));
  2433. }
  2434. /*
  2435. if (t.attr("apname") == v_apname) {
  2436. if (ishow == "0") t.addClass("hidden");
  2437. else t.removeClass("hidden");
  2438. }*/
  2439. });
  2440. $("#network .network-iedlist .ied_item").css("opacity", 0.3);
  2441. for (var i = 0; i < rel_ied_list.length; i++) {
  2442. $("#network .network-iedlist .ied_item[ied_name='" + rel_ied_list[i] + "']").css("opacity", 1);
  2443. }
  2444. });
  2445. //绘制ap与总线的连接线
  2446. //初始连接线位置
  2447. var w = 10 * wRate; //固定间隔距离
  2448. if (sourceNetworkEle.length == 0) {
  2449. return;
  2450. }
  2451. var linkLeft = sourceNetworkEle.position().left + (sourceNetworkEle.width() - ((loadApInfo.length - 1) * w)) / 2;
  2452. var startTop = sourceNetworkEle.position().top + sourceNetworkEle.height() + sourceNetworkEle.css("margin-top").replace("px", "") * 1;
  2453. $aplistEle.find(".sub_line").each(function(ind) {
  2454. var tmp0 = $(this);
  2455. var h = tmp0.position().top + tmp0.parent().position().top - startTop;
  2456. network.append('<div class="network-line ' + tmp0.attr("apname") + '" apname=' + tmp0.attr("apname") + ' style="top:' + startTop + 'px;left:' + (linkLeft + 10 * wRate * ind) + 'px;height:' + h + 'px"></div>');
  2457. });
  2458. var iedListTop = $("#network .sub_line:last").position().top + $("#network .sub_line:last").parent().position().top + 60 * hRate;
  2459. var iedListH = $("#container_map_ied .network").height() - iedListTop;
  2460. ledlist.css({
  2461. "top": iedListTop,
  2462. //"height": iedListH + "px"
  2463. });
  2464. //加载IED
  2465. var iedListDiv = $("#network .network-iedlist>div:first");
  2466. $aplistEle.find(".sub_line").each(function() {
  2467. var apname = $(this).attr("apname");
  2468. //ap对应的总线
  2469. var totalLine = network.find(".sub_line[apname='" + apname + "']");
  2470. var vTop = totalLine.position().top + totalLine.parent().position().top + totalLine.height();
  2471. var viedList = PoliceObject.NetWork_ApNodes[networkid + "." + apname];
  2472. if (viedList.list == null) return;
  2473. for (var i = 0; i < viedList.list.length; i++) {
  2474. var ieddata = viedList.list[i].ied_name;
  2475. var curIed = network.find(".network-iedlist .ied_item[ied_name='" + ieddata.attr_ied_name + "']");
  2476. if (curIed.length == 0) {
  2477. var iplist = [];
  2478. var ip = PoliceObject.IedNetaddrList[ieddata.attr_ied_name + "ip"];
  2479. if (ip != null) {
  2480. for (var ipi = 0; ipi < ip.length; ipi++) {
  2481. iplist.push('<div class="ip">' + ip[ipi].node_value + '</div>');
  2482. }
  2483. }
  2484. iedListDiv.append('<div ied_name="' + ieddata.attr_ied_name + '" title="' + ieddata.attr_desc + '" class="ied_item"><img src="/static/images/default_ied.png"><div>' + ieddata.attr_desc + '</div><div>' + ieddata.attr_ied_name + '</div>' + iplist.join("") + '</div>');
  2485. curIed = network.find(".network-iedlist .ied_item[ied_name='" + ieddata.attr_ied_name + "']");
  2486. }
  2487. //绘制总线与IED连接线
  2488. var left = curIed.position().left.toFixed(1);
  2489. var h = curIed.position().top - vTop + ledlist.position().top + 40 * hRate;
  2490. var lineCss = "left:" + left + "px;top:" + vTop + "px;height:" + h + "px";
  2491. network.append('<div apname="' + apname + '" foried="' + ieddata.attr_ied_name + '" class="network-ied-line ' + apname + '" style="' + lineCss + '"></div>');
  2492. var w = 45 * wRate;
  2493. var lineCss2 = "left:" + left + "px;top:" + (vTop + h) + "px;width:" + w + "px";
  2494. network.append('<div apname="' + apname + '" foried="' + ieddata.attr_ied_name + '" class="network-ied-line2 ' + apname + '" style="' + lineCss2 + '"></div>');
  2495. }
  2496. });
  2497. iedListDiv.find(".ied_item").off().on('click', function() {
  2498. //点击装置时查看装备信息
  2499. var t = $(this);
  2500. //查看IED信息
  2501. DialogObject.Open($("#dialog_public"), {
  2502. size: ["150rem", "72rem"],
  2503. para: {
  2504. "title": t.attr("title") + "(" + t.attr("ied_name") + ")—详细信息",
  2505. "ied_id": t.attr("id"),
  2506. "ied_name": t.attr("ied_name"),
  2507. },
  2508. callback: function(win, p1) {
  2509. win.attr("ied_name", p1.ied_name);
  2510. win.find(".caption>b").html(p1.title);
  2511. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height() - 20 * hRate); //20为paddingTop
  2512. win.find(".dataitemlist").height(h + "px").html(template('ied_detail_tpl', {}));
  2513. win.find(".content").height(h - win.find(".tools").height() + "px");
  2514. win.find("#ied_list_tree").height(h - 20 * hRate); //20为底边留空
  2515. //绑定快速查找
  2516. win.find("#ied_list_tree .fast_find_list").off().on("input propertychange", function() {
  2517. var v = ($(this).val()).toLocaleLowerCase();
  2518. var tarEle = win.find("#ied_list_tree .station_list_item");
  2519. if (v == "") tarEle.removeClass("hidden");
  2520. else {
  2521. tarEle.each(function() {
  2522. var $this = $(this);
  2523. if ($this.text().toLocaleLowerCase().indexOf(v) > -1) $this.removeClass("hidden");
  2524. else $this.addClass("hidden");
  2525. })
  2526. }
  2527. });
  2528. PoliceObject.LoadIedGraph(null, PoliceObject.IedList[p1.ied_name]);
  2529. }
  2530. });
  2531. });
  2532. //如果有2条及以上总线时,需要判断同一设备是否接入多条总线,是则需要微调连接位置 ,使其不重合
  2533. if ($aplistEle.find(".sub_line").length > 0) {
  2534. var leftSameLine = {};
  2535. network.find(".network-ied-line").each(function() {
  2536. var t = $(this);
  2537. var v_apname = t.attr("apname");
  2538. var v_left = t.css("left");
  2539. if (leftSameLine[v_left] == null) leftSameLine[v_left] = [{
  2540. "apname": v_apname,
  2541. "ele": t
  2542. }];
  2543. else {
  2544. var has = 0;
  2545. for (var i = 0; i < leftSameLine[v_left].length; i++) {
  2546. if (leftSameLine[v_left][i].apname == v_apname) {
  2547. has = 1;
  2548. break;
  2549. }
  2550. }
  2551. if (has == 0) leftSameLine[v_left].push({
  2552. "apname": v_apname,
  2553. "ele": t
  2554. });
  2555. }
  2556. })
  2557. //遍历查找同一ap同一left相同连线数量大于2条的
  2558. //console.log(leftSameLine)
  2559. for (var left in leftSameLine) {
  2560. if (leftSameLine[left].length < 2) continue;
  2561. for (var i = 1; i < leftSameLine[left].length; i++) {
  2562. //从第二条开始微调left
  2563. var v_ele = leftSameLine[left][i].ele;
  2564. var oldLeft = v_ele.css("left");
  2565. var v_apname = leftSameLine[left][i].apname;
  2566. network.find(".network-ied-line[apname='" + v_apname + "']").each(function() {
  2567. var t1 = $(this);
  2568. var t1Left = t1.css("left");
  2569. if (oldLeft == t1Left) {
  2570. t1.css({
  2571. "left": oldLeft.replace("px", "") * 1 - (i * 5 * wRate) + "px",
  2572. "height": t1.height() + (i * 5) + "px"
  2573. });
  2574. }
  2575. });
  2576. //调整当前总线-连接线上的装置连接线
  2577. network.find(".network-ied-line2[apname='" + v_apname + "']").each(function() {
  2578. var t1 = $(this);
  2579. var t1Left = t1.css("left");
  2580. var t1OldTop = t1.css("top");
  2581. if (oldLeft == t1Left) {
  2582. var newTop = t1OldTop.replace("px", "") * 1 + (i * 5 * hRate);
  2583. t1.css({
  2584. "top": newTop + "px",
  2585. "width": t1.width() + (i * 5 * wRate) + "px",
  2586. "left": oldLeft.replace("px", "") * 1 - (i * 5 * wRate) + "px"
  2587. });
  2588. }
  2589. });
  2590. }
  2591. }
  2592. }
  2593. var divH = $("#container_map_ied").height() - $("#container_map_ied .scd_tools").height() - (70 * hRate);
  2594. network.slimScroll({
  2595. height: divH + "px",
  2596. width: "100%",
  2597. alwaysVisible: false,
  2598. wheelStep: 10,
  2599. size: "6px",
  2600. color: "#03aee7"
  2601. })
  2602. network.height(divH);
  2603. layer.closeAll();
  2604. }
  2605. if (PoliceObject.NetWork_ApNodes == null) {
  2606. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  2607. "scd_id": PoliceObject.ScdID,
  2608. "pagesize": 10000,
  2609. "name": "ConnectedAP"
  2610. }, function(list) {
  2611. PoliceObject.NetWork_ApNodes = {};
  2612. for (var i = 0; i < list.data.length; i++) {
  2613. var pid = list.data[i].parent_node_id;
  2614. var apname = list.data[i]["attr_ap_name"];
  2615. var key = pid + "." + apname;
  2616. if (PoliceObject.NetWork_ApNodes[key] == null) {
  2617. PoliceObject.NetWork_ApNodes[key] = ($.extend({
  2618. "node_type": "ap",
  2619. "name": key,
  2620. list: [{
  2621. "ied_name": list.data[i]
  2622. }]
  2623. }, list.data[i]));
  2624. } else {
  2625. PoliceObject.NetWork_ApNodes[key].list.push({
  2626. "ied_name": list.data[i]
  2627. });
  2628. }
  2629. }
  2630. network.find(".apname").off().on('click', function() {
  2631. var $t = $(this);
  2632. LoadIedGraph(null, $t.parent().parent().find(".network_name").text() + "—" + $t.attr("apname"), "ap");
  2633. });
  2634. //PoliceObject.NetWork_ApNodes.sort(Tools.SortBy("name", true))
  2635. loadNetworkAPInfo();
  2636. });
  2637. } else {
  2638. loadNetworkAPInfo();
  2639. }
  2640. })
  2641. },
  2642. LoadIedList: function() {
  2643. //layer.msg("努力加载文件数据中...")
  2644. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/relation", {
  2645. "scd_id": PoliceObject.ScdID
  2646. }, function(r) {
  2647. PoliceObject.IedList = r.data;
  2648. var container_map_ied = $("#container_map_ied");
  2649. container_map_ied.find(".scd_filter .iedNumber>b").html(r.count);
  2650. var firstShowIed = "",
  2651. refCount = 0;
  2652. for (var iedname in r.data) {
  2653. if (refCount < r.data[iedname].list.length) {
  2654. firstShowIed = iedname;
  2655. refCount = r.data[iedname].list.length;
  2656. }
  2657. }
  2658. iedLoadState = 1;
  2659. PoliceObject.LoadIedNetAddr();
  2660. });
  2661. },
  2662. LoadIedNetAddr: function() {
  2663. PoliceObject.IedNetaddrList = {};
  2664. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/netaddr", {
  2665. "scd_id": PoliceObject.ScdID
  2666. }, function(r) {
  2667. if (r.code != 0) {
  2668. $("#network").html(Tools.HintText(r.msg + "\n该SCD可能已被清理,需要重新分析!"));
  2669. return;
  2670. }
  2671. if (r.data == null) {
  2672. $("#network").html(Tools.HintText("未发现网络配置信息,或者该SCD可能已被清理,需要重新分析!"));
  2673. return;
  2674. }
  2675. for (var i = 0; i < r.data.length; i++) {
  2676. var k = r.data[i].attr_ied_name + r.data[i].addrtype;
  2677. var lst = PoliceObject.IedNetaddrList[k];
  2678. if (lst == null) PoliceObject.IedNetaddrList[k] = [r.data[i]];
  2679. else PoliceObject.IedNetaddrList[k].push(r.data[i]);
  2680. }
  2681. netaddrLoadState = 1;
  2682. if ($("#network .network-iedlist .ied_item").length == 0) {
  2683. //尝试再加载一次网络结构
  2684. PoliceObject.GetSubNetwork();
  2685. }
  2686. });
  2687. },
  2688. OpenShowIedList: function(title, filter_cond) {
  2689. var tmp_load = function(title, data) {
  2690. DialogObject.Open($("#dialog_public"), {
  2691. size: ["122rem", "70rem"],
  2692. para: {
  2693. "title": title,
  2694. "list": data
  2695. },
  2696. callback: function(win, para) {
  2697. win.find(".caption>b").html(para.title);
  2698. var h = template("ied_list_tpl", {
  2699. data: para.list
  2700. });
  2701. win.find(".dataitemlist").css("margin-top", "-2rem").html(h).slimScroll({
  2702. height: (win.height() - win.find(".caption").height() - win.find(".footer").height()) + "px",
  2703. width: "100%",
  2704. alwaysVisible: false,
  2705. wheelStep: 10,
  2706. size: "6px",
  2707. color: "#03aee7"
  2708. });
  2709. win.find(".ied_list_item").off().on('click', function() {
  2710. var t = $(this);
  2711. //查看IED信息
  2712. DialogObject.Open($("#dialog_public"), {
  2713. size: ["150rem", "72rem"],
  2714. para: {
  2715. "title": t.find("span:last").text() + "(" + t.find("span:first").text() + ")—详细信息",
  2716. "ied_id": t.attr("id"),
  2717. "ied_name": t.attr("name"),
  2718. },
  2719. callback: function(win, p1) {
  2720. win.attr("ied_name", p1.ied_name);
  2721. win.find(".caption>b").html(p1.title);
  2722. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height());
  2723. win.find(".dataitemlist").height(h + "px").html(template('ied_detail_tpl', {}));
  2724. win.find(".content").height(h - win.find(".tools").height() + "px");
  2725. win.find("#ied_list_tree").height(h - 20 * hRate);
  2726. //绑定快速查找
  2727. win.find("#ied_list_tree .fast_find_list").off().on("input propertychange", function() {
  2728. var v = ($(this).val()).toLocaleLowerCase();
  2729. var tarEle = win.find("#ied_list_tree .station_list_item");
  2730. if (v == "") tarEle.removeClass("hidden");
  2731. else {
  2732. tarEle.each(function() {
  2733. var $this = $(this);
  2734. if ($this.text().toLocaleLowerCase().indexOf(v) > -1) $this.removeClass("hidden");
  2735. else $this.addClass("hidden");
  2736. })
  2737. }
  2738. });
  2739. PoliceObject.LoadIedGraph(null, PoliceObject.IedList[p1.ied_name]);
  2740. }
  2741. });
  2742. });
  2743. }
  2744. });
  2745. }
  2746. var lst = [];
  2747. //判断是否是根据间隔ID来查看
  2748. $.getJSON(Global.AccessUrl + "/api/scd/area/ied/list", {
  2749. scd_id: PoliceObject.ScdID,
  2750. area_id: filter_cond.area_id,
  2751. voltage_level_id: filter_cond.voltage_level_id,
  2752. device_type_id: filter_cond.device_type_id
  2753. }, function(r) {
  2754. if (r.code != 0) {
  2755. layer.msg(r.msg, {
  2756. icon: Global.ICON_ERROR
  2757. });
  2758. return;
  2759. }
  2760. if (r.data == null) {
  2761. layer.msg("该类型下无装置!", {
  2762. icon: Global.ICON_ERROR
  2763. })
  2764. return
  2765. }
  2766. tmp_load(title, r.data.sort(Tools.SortBy("attr_name", true)));
  2767. })
  2768. },
  2769. LoadIedNetWorkInfo: function(ied_name, scdid, callback) {
  2770. if (scdid == null) scdid = "";
  2771. var lst = PoliceObject.GetIedData(ied_name, scdid).network;
  2772. if (lst != null) {
  2773. if (callback != null) callback(lst);
  2774. return;
  2775. }
  2776. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/network/info", {
  2777. "scd_id": scdid == null || scdid == "" ? PoliceObject.ScdID : scdid,
  2778. "ied_name": ied_name
  2779. }, function(r) {
  2780. if (r.code != 0) {
  2781. return;
  2782. }
  2783. var ieddata = PoliceObject.OtherIedList[scdid + ied_name];
  2784. if (ieddata != null) ieddata["network"] = r.data;
  2785. else PoliceObject.IedList[ied_name]["network"] = r.data;
  2786. if (callback != null) callback(r.data);
  2787. })
  2788. },
  2789. LoadIedTreeList: function(iedListTree, isrefesh) {
  2790. this.LoadIedTreeList2(iedListTree, null, isrefesh);
  2791. },
  2792. LoadIedTreeList2: function(iedListTree, iedlist, isrefesh) {
  2793. iedListTree = iedListTree == null ? $("#ied_list_tree") : iedListTree;
  2794. if (isrefesh == null && iedListTree.attr("isloaded") == "1") return;
  2795. if (iedListTree.find(".station_list_item").length == 0) {
  2796. var iedListTreeDiv = iedListTree.children("div:last").html('').slimscroll({
  2797. height: (iedListTree.height() - iedListTree.children("div:first").height()) + "px",
  2798. width: "100%",
  2799. alwaysVisible: false,
  2800. wheelStep: 10,
  2801. size: "6px",
  2802. color: "#03aee7"
  2803. });
  2804. var lstItems = [];
  2805. var isOtherScdid = "";
  2806. if (iedlist != null) {
  2807. for (var i = 0; i < iedlist.length; i++) {
  2808. isOtherScdid = iedlist[i].scd_id;
  2809. lstItems.push({
  2810. "scd_id": iedlist[i].scd_id,
  2811. "code": iedlist[i].ied_name,
  2812. "name": "<span style='width: 9rem;display: inline-block;'>" + iedlist[i].ied_name + "</span><span style='color:#516380;margin-left:0.5rem;'>" + iedlist[i].ied_desc + "</span>"
  2813. });
  2814. }
  2815. } else {
  2816. for (var ied_name in PoliceObject.IedList) {
  2817. lstItems.push({
  2818. "code": ied_name,
  2819. "name": "<span style='width: 9rem;display: inline-block;'>" + ied_name + "</span><span style='color:#516380;margin-left:0.5rem;'>" + PoliceObject.IedList[ied_name].desc + "</span>"
  2820. });
  2821. }
  2822. }
  2823. iedListTreeDiv.html(template('select_item_tpl', {
  2824. data: lstItems.sort(Tools.SortBy("code", true))
  2825. })).find(".station_list_item").attr("scd_id", isOtherScdid).off().on('click', function() {
  2826. iedListTreeDiv.find(".active").removeClass("active");
  2827. var $t = $(this),
  2828. v = $t.attr("value");
  2829. $t.addClass("active");
  2830. var scdid = $.trim($t.attr("scd_id"));
  2831. $t.parents(".site_device_list").attr("scd_id", scdid == "" ? PoliceObject.ScdID : scdid).attr("ied_name", v).find(".caption>b").html($t.children("span:last").text() + "(" + $t.children("span:first").text() + ")" + "—详细信息");
  2832. var tools = iedListTree.next();
  2833. //tools.find("li").removeClass("layui-this");
  2834. //tools.find("li:first").addClass("layui-this");
  2835. tools.find("li.layui-this").trigger('click');
  2836. //PoliceObject.LoadIedGraph(PoliceObject.IedList[v]);
  2837. });
  2838. }
  2839. var tools = iedListTree.next();
  2840. tools.find("li").removeClass("layui-this");
  2841. tools.find("li:first").addClass("layui-this");
  2842. iedListTree.attr("isloaded", "1");
  2843. },
  2844. LoadIedCtrlRelation: function(evt, ieddata) {
  2845. //加载IED列表树
  2846. this.LoadIedTreeList($("#ied_list_tree"));
  2847. var tmp_load = function(data) {
  2848. ied_strcut_detail.html('').slimscroll({
  2849. height: ied_strcut_detail.height() + "px",
  2850. width: "100%",
  2851. alwaysVisible: false,
  2852. wheelStep: 10,
  2853. size: "6px",
  2854. color: "#03aee7"
  2855. });
  2856. ied_strcut_detail.append('<span class="f_l ied_show_block self_ied" style="font-size: 1.4rem;"></span>');
  2857. var selfIed = ied_strcut_detail.children(".ied_show_block.self_ied").html(ieddata.ied_name + "<br>" + ieddata.desc).attr("ied_name", ieddata.ied_name);
  2858. var iddXY = ied_strcut_detail.position();
  2859. for (var i = 0; i < ieddata.list.length; i++) {
  2860. var itme = ieddata.list[i];
  2861. if (itme.ref_ied_name == null || itme.ref_ied_name == "" || ied_strcut_detail.find("span[ied_name='" + itme.ref_ied_name + "']").length > 0) continue;
  2862. if (itme.ref_type == "1") {
  2863. //输入关系
  2864. ied_strcut_detail.append('<span class="ied_show_block salve_ied" ied_name="' + itme.ref_ied_name + '">' + itme.ref_ied_name + '<br>' + itme.ref_ied_desc + '</span>');
  2865. } else {
  2866. //输出关系
  2867. ied_strcut_detail.append('<span class="ied_show_block salve_ied" ied_name="' + itme.ref_ied_name + '" style="color:#51637F">' + itme.ref_ied_name + '<br>' + itme.ref_ied_desc + '</span>');
  2868. }
  2869. }
  2870. ied_strcut_detail.find(".salve_ied").off().on('click', function() {
  2871. //点击装置进行切换
  2872. PoliceObject.LoadIedCtrlRelation(null, PoliceObject.GetIedData($(this).attr("ied_name")));
  2873. });
  2874. if (data.ControlBlock == null) return;
  2875. //生成其他IED控制块
  2876. for (var i = 0; i < data.ControlBlock.length; i++) {
  2877. var item = data.ControlBlock[i];
  2878. if (item.ref_type == 0) {
  2879. //主IED输出到其他IED
  2880. //var sourceCtrlID=item.ctrl_id;
  2881. //目标IED
  2882. //var toIedName=item.source_ied_name;
  2883. continue;
  2884. }
  2885. if (item.ld_id == "") {
  2886. console.log(item)
  2887. continue;
  2888. }
  2889. var tarEle = ied_strcut_detail.find(".ied_show_block[ied_name='" + item.target_ied_name + "']");
  2890. var ldEle = tarEle.children(".ld[ld_id=" + item.ld_id + "]");
  2891. if (ldEle.length == 0) {
  2892. tarEle.append('<span class="ld f_l" ld_id=' + item.ld_id + '><span class=f_l style="padding: 0.5rem;padding: 0.5rem;width: 100%;text-align: left;">' + item.ld_inst + ' ' + item.ld_desc + '</span></span>');
  2893. ldEle = tarEle.children(".ld[ld_id=" + item.ld_id + "]");
  2894. }
  2895. ldEle.append('<span class="block" attr_type="' + item.ctrl_type + '" ctrl_id="' + item.ctrl_id + '" inputs_cnt=' + item.inputs_cnt + '><div>' + item.ctrl_name + '</div><div>' + item.datset_desc + '<div></span>');
  2896. }
  2897. var iedList = ied_strcut_detail.children("span.salve_ied");
  2898. for (var i = 0; i < iedList.length; i++) {
  2899. if (i % 2 == 0) iedList.eq(i).addClass("left");
  2900. else iedList.eq(i).addClass("right");
  2901. }
  2902. ied_strcut_detail.children("span.ied_show_block.left").each(function(ind) {
  2903. var t = 150;
  2904. if (ind > 0) {
  2905. var $tmp = ied_strcut_detail.children("span.ied_show_block.left:eq(" + (ind - 1) + ")");
  2906. t = $tmp.position().top + $tmp.height() + 30;
  2907. }
  2908. $(this).css({
  2909. left: "5rem",
  2910. top: t + "px"
  2911. });
  2912. });
  2913. ied_strcut_detail.children("span.ied_show_block.right").each(function(ind) {
  2914. var t = 150;
  2915. if (ind > 0) {
  2916. var $tmp = ied_strcut_detail.children("span.ied_show_block.right:eq(" + (ind - 1) + ")");
  2917. t = $tmp.position().top + $tmp.height() + 30;
  2918. }
  2919. $(this).css({
  2920. left: "90rem",
  2921. top: t + "px"
  2922. });
  2923. });
  2924. //计算主IED的高度
  2925. var lastLeftEle = ied_strcut_detail.children("span.ied_show_block.left:last");
  2926. var lastRigthEle = ied_strcut_detail.children("span.ied_show_block.right:last");
  2927. if (lastLeftEle.length > 0 && lastRigthEle.length > 0)
  2928. selfIed.css("height", Math.max(lastLeftEle.position().top + lastLeftEle.height(), lastRigthEle.position().top + lastRigthEle.height()) + 50 + "px");
  2929. else if (lastLeftEle.length > 0)
  2930. selfIed.css("height", Math.max(lastLeftEle.position().top + lastLeftEle.height(), 0) + 50 + "px");
  2931. else if (lastRigthEle.length > 0)
  2932. selfIed.css("height", Math.max(0, lastRigthEle.position().top + lastRigthEle.height()) + 50 + "px");
  2933. else return;
  2934. //生成主IED的控制块
  2935. makeSlefIedBlock(selfIed, data, drawRelationLine);
  2936. }
  2937. var drawRelationLine = function(data) {
  2938. var selfIed = ied_strcut_detail.children(".ied_show_block.self_ied");
  2939. ied_strcut_detail.append("<canvas id='canvas' class='abs canvas' style='width:100%;height:" + selfIed.height() + "px;z-index:1;pointer-events: none;'></canvas>");
  2940. var canvas = PoliceObject.p_createCanvas(ied_strcut_detail.find("canvas"));
  2941. //---------------------------
  2942. //绘制连接线
  2943. var selfIedXY = selfIed.position();
  2944. ied_strcut_detail.find(".ied_show_block.left .block").each(function() {
  2945. //左侧ied输入到主IED的连接线
  2946. var t = $(this),
  2947. xy = t.position();
  2948. var leftSelf = selfIedXY.left + selfIed.css("margin-left").replace("px", "") * 1;
  2949. var left = xy.left + t.width() + t.parent().parent().position().left + (t.css("margin-left").replace("px", "") * 1) + 2;
  2950. var top = xy.top + (t.height() / 2) + t.parent().parent().position().top + (t.css("margin-top").replace("px", "") * 1) + 1;
  2951. var lineColor = "#134BEA";
  2952. var attrtype = $.trim(t.attr('attr_type')).toLocaleLowerCase();
  2953. if (attrtype != "" && "smv,sv".indexOf(attrtype) > -1) {
  2954. lineColor = "red";
  2955. t.css({
  2956. "color": lineColor,
  2957. "border-color": lineColor
  2958. });
  2959. }
  2960. PoliceObject.p_drawLine(canvas, [left, top], [leftSelf, top], lineColor);
  2961. var n1 = PoliceObject.p_drawNumber(ied_strcut_detail, [leftSelf, top], [left, top], t.attr('inputs_cnt'), "left");
  2962. n1.attr({
  2963. "m_iedname": selfIed.attr("ied_name"),
  2964. "s_iedname": t.parents(".salve_ied").attr("ied_name"),
  2965. "s_ctrlid": t.attr('ctrl_id')
  2966. });
  2967. });
  2968. ied_strcut_detail.find(".ied_show_block.right .block").each(function() {
  2969. //右侧ied输入到主IED的连接线
  2970. var t = $(this),
  2971. xy = t.position();
  2972. var left1 = selfIedXY.left + selfIed.width() + selfIed.css("margin-left").replace("px", "") * 1 + 5;
  2973. var left2 = xy.left + t.parent().parent().position().left + (t.css("margin-left").replace("px", "") * 1) + 2;
  2974. var top = xy.top + (t.height() / 2) + t.parent().parent().position().top + (t.css("margin-top").replace("px", "") * 1) + 1;
  2975. var lineColor = "#134BEA";
  2976. var attrtype = $.trim(t.attr('attr_type')).toLocaleLowerCase();
  2977. if (attrtype != "" && "smv,sv".indexOf(attrtype) > -1) {
  2978. lineColor = "red";
  2979. t.css({
  2980. "color": lineColor,
  2981. "border-color": lineColor
  2982. });
  2983. }
  2984. PoliceObject.p_drawLine(canvas, [left2, top], [left1, top], lineColor);
  2985. var n1 = PoliceObject.p_drawNumber(ied_strcut_detail, [left1, top], [left2, top], t.attr('inputs_cnt'), "right");
  2986. n1.attr({
  2987. "m_iedname": selfIed.attr("ied_name"),
  2988. "s_iedname": t.parents(".salve_ied").attr("ied_name"),
  2989. "s_ctrlid": t.attr('ctrl_id')
  2990. });
  2991. });
  2992. //绘制输出连接线
  2993. var outR_cnt = 0;
  2994. var outL_cnt = 0;
  2995. for (var i = 0; i < data.ControlBlock.length; i++) {
  2996. var item = data.ControlBlock[i];
  2997. //主IED输出到其他IED
  2998. var sourceCtrl = selfIed.find(".block[node_id='" + item.ctrl_id + "']");
  2999. //目标IED
  3000. var toIed = ied_strcut_detail.find(".ied_show_block[ied_name='" + item.source_ied_name + "']");
  3001. var x1, y1, x2, y2 = 0;
  3002. var w, h, l, t = 0;
  3003. var lineColor = "#516380";
  3004. var attrtype = $.trim(sourceCtrl.attr('attr_type')).toLocaleLowerCase();
  3005. if (attrtype != "" && "smv,sv".indexOf(attrtype) > -1) {
  3006. lineColor = "red";
  3007. sourceCtrl.css({
  3008. "color": lineColor,
  3009. "border-color": lineColor
  3010. });
  3011. }
  3012. if (item.ref_type == 0) {
  3013. var direction = "";
  3014. if (toIed.hasClass("left")) {
  3015. direction = "left";
  3016. //在左边
  3017. x1 = selfIedXY.left + sourceCtrl.position().left + sourceCtrl.css("margin-left").replace("px", "") * 1 + selfIed.css("margin-left").replace("px", "") * 1;
  3018. y1 = selfIedXY.top + sourceCtrl.position().top + sourceCtrl.css("margin-top").replace("px", "") * 1 + selfIed.css("margin-top").replace("px", "") * 1 + sourceCtrl.height() / 2;
  3019. x2 = toIed.position().left + toIed.width();
  3020. y2 = toIed.position().top + (toIed.height() / 2);
  3021. PoliceObject.p_drawLine(canvas, [x1, y1], [x2, y2 + outL_cnt * 8], lineColor);
  3022. outL_cnt++;
  3023. } else {
  3024. direction = "right";
  3025. //在右边
  3026. x1 = selfIedXY.left + sourceCtrl.position().left + sourceCtrl.width() + sourceCtrl.css("margin-left").replace("px", "") * 1 + selfIed.css("margin-left").replace("px", "") * 1 + 5;
  3027. y1 = selfIedXY.top + sourceCtrl.position().top + sourceCtrl.css("margin-top").replace("px", "") * 1 + (sourceCtrl.height() / 2);
  3028. x2 = toIed.position().left;
  3029. y2 = toIed.position().top + (toIed.height() / 2);
  3030. PoliceObject.p_drawLine(canvas, [x1, y1], [x2, y2 + outR_cnt * 8], lineColor);
  3031. outR_cnt++;
  3032. }
  3033. var n1 = PoliceObject.p_drawNumber(ied_strcut_detail, [x1, y1], [x2, y2], item.inputs_cnt, direction);
  3034. n1.attr({
  3035. "m_iedname": selfIed.attr("ied_name"),
  3036. "s_iedname": item.source_ied_name,
  3037. "m_ctrlid": item.ctrl_id,
  3038. "s_ctrlid": ""
  3039. });
  3040. }
  3041. }
  3042. //绑定控制块关系数量,点击数量打开许端子详细关系窗口
  3043. ied_strcut_detail.find(".inputs_num").off().on('click', function() {
  3044. var tmpEle = $(this);
  3045. DialogObject.Open($("#dialog_public"), {
  3046. size: ["100rem", "55rem"],
  3047. para: {
  3048. "title": "虚端子—详细信息",
  3049. "s_ied_name": $.trim(tmpEle.attr("s_iedname")),
  3050. "m_ied_name": $.trim(tmpEle.attr("m_iedname")),
  3051. "m_ctrlid": $.trim(tmpEle.attr("m_ctrlid")),
  3052. "s_ctrlid": $.trim(tmpEle.attr("s_ctrlid")),
  3053. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID
  3054. },
  3055. callback: function(win, p1) {
  3056. win.find(".caption>b").html(p1.title);
  3057. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height() - win.find(".dataitemlist").css("padding-top").replace("px", "") * 1);
  3058. var dataContent = win.find(".dataitemlist").height(h + "px").html(Tools.LoadingText("正在加载数据中...")).slimscroll({
  3059. height: h + "px",
  3060. width: "100%",
  3061. alwaysVisible: false,
  3062. wheelStep: 10,
  3063. size: "6px",
  3064. color: "#03aee7"
  3065. });
  3066. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/inputs", p1, function(r) {
  3067. dataContent.html("<div id='m_ied' class='abs inputs_ied_box' style='left:10%;'></div><div id='s_ied' class='abs inputs_ied_box' style='right:10%;'></div>");
  3068. if (r.code != 0) {
  3069. layer.msg(r.msg);
  3070. return;
  3071. }
  3072. var mIedEle = dataContent.find("#m_ied");
  3073. var sIedEle = dataContent.find("#s_ied");
  3074. mIedData = PoliceObject.GetIedData(p1.m_ied_name, p1.scd_id)
  3075. sIedData = PoliceObject.GetIedData(p1.s_ied_name, p1.scd_id)
  3076. mIedEle.append('<div class="f_l" style="width: 100%;line-height: 2rem;border-bottom: 1px solid #C8D4E2;"><span class="f_l" style="width:100%">' + p1.m_ied_name + '</span><span style="color: #134BEA;">' + mIedData.desc + '</span></div>');
  3077. sIedEle.append('<div class="f_l" style="width: 100%;line-height: 2rem;border-bottom: 1px solid #C8D4E2;"><span class="f_l" style="width:100%">' + p1.s_ied_name + '</span><span style="color: #134BEA;">' + sIedData.desc + '</span></div>');
  3078. //获取控制块信息
  3079. var inout_type = ""; //相对于主IED的输入输出关系
  3080. for (var i = 0; i < mIedData.ControlBlock.length; i++) {
  3081. var ctrlInfo = mIedData.ControlBlock[i];
  3082. if (ctrlInfo.ctrl_id == p1.m_ctrlid || ctrlInfo.ctrl_id == p1.s_ctrlid) {
  3083. inout_type = ctrlInfo.ref_type;
  3084. //console.log(ctrlInfo)
  3085. if (ctrlInfo.ref_type == 1) {
  3086. //输入控制块
  3087. mIedEle.append('<div class="abs" style="width:90%;left:5%;top:7rem;min-height:33rem;border: 1px solid #C8D4E2;border-radius: 3px;"><div style="text-align: left;margin-top: -2.3rem;float: left;line-height: 2rem;padding: 0 5px;"><b>' + (r.data[0].to_ld_inst || '') + "</b> " + (r.data[0].to_ld_desc || '') + '</div><div class="f_l output_ctrl" style="width:100%;color: #43526B;background: #fff;margin-bottom: 1rem;">&nbsp;</div></div>');
  3088. //输出控制块
  3089. sIedEle.append('<div class="abs" style="width:90%;left:5%;top:7rem;min-height:33rem;border: 1px solid #C8D4E2;border-radius: 3px;"><div style="text-align: left;margin-top: -2.3rem;float: left;line-height: 2rem;padding: 0 5px;"><b>' + ctrlInfo.ld_inst + "</b> " + ctrlInfo.ld_desc + '</div><div class="f_l output_ctrl" style="width: 100%;color: #43526B;background: #fff;margin-bottom: 1rem;"><span style="margin-right:1rem">' + ctrlInfo.ctrl_name + '</span><span>' + ctrlInfo.datset_desc + '</span></div></div>');
  3090. } else {
  3091. sIedEle.append('<div class="abs" style="width:90%;left:5%;top:7rem;min-height:33rem;border: 1px solid #C8D4E2;border-radius: 3px;"><div style="text-align: left;margin-top: -2.3rem;float: left;line-height: 2rem;padding: 0 5px;"><b>' + (r.data[0].to_ld_inst || '') + "</b> " + (r.data[0].to_ld_desc || '') + '</div><div class="f_l output_ctrl" style="width:100%;color: #43526B;background: #fff;margin-bottom: 1rem;">&nbsp;</div></div>');
  3092. //输出控制块
  3093. mIedEle.append('<div class="abs" style="width:90%;left:5%;top:7rem;min-height:33rem;border: 1px solid #C8D4E2;border-radius: 3px;"><div style="text-align: left;margin-top: -2.3rem;float: left;line-height: 2rem;padding: 0 5px;"><b>' + ctrlInfo.ld_inst + "</b> " + ctrlInfo.ld_desc + '</div><div class="f_l output_ctrl" style="width: 100%;color: #43526B;background: #fff;margin-bottom: 1rem;"><span style="margin-right:1rem">' + ctrlInfo.ctrl_name + '</span><span>' + ctrlInfo.datset_desc + '</span></div></div>');
  3094. }
  3095. break;
  3096. }
  3097. }
  3098. var mIedEleCtl = mIedEle.children("div:last");
  3099. var sIedEleCtl = sIedEle.children("div:last");
  3100. //生成许端子元素
  3101. for (var i = 0; i < r.data.length; i++) {
  3102. var item = r.data[i];
  3103. var fIntAddr = item.attr_ld_inst + "/" + (item.attr_prefix || '') + item.attr_ln_class + item.attr_ln_inst + "." + item.attr_do_name + "." + item.attr_da_name;
  3104. if (inout_type == 1) {
  3105. mIedEleCtl.append('<div class="f_l output_ctrl inputs_extref" style="width: 80%;color: #09162C;border: 1px solid #516380;background: #F6FAFF;line-height: 2rem;margin-left:10%;margin-bottom: 1rem;text-align: center;"><span>' + item.to_doi_desc + '</span><span class="f_l" style="width:100%">' + item.attr_int_addr + '</span></div>');
  3106. sIedEleCtl.append('<div class="f_l output_ctrl inputs_extref" style="width: 80%;color: #09162C;border: 1px solid #516380;background: #F6FAFF;line-height: 2rem;margin-left:10%;margin-bottom: 1rem;text-align: center;"><span>' + item.from_doi_desc + '</span><span class="f_l" style="width:100%">' + fIntAddr + '</span></div>');
  3107. } else {
  3108. mIedEleCtl.append('<div class="f_l output_ctrl inputs_extref" style="width: 80%;color: #09162C;border: 1px solid #516380;background: #F6FAFF;line-height: 2rem;margin-left:10%;margin-bottom: 1rem;text-align: center;"><span>' + item.from_doi_desc + '</span><span class="f_l" style="width:100%">' + fIntAddr + '</span></div>');
  3109. sIedEleCtl.append('<div class="f_l output_ctrl inputs_extref" style="width: 80%;color: #09162C;border: 1px solid #516380;background: #F6FAFF;line-height: 2rem;margin-left:10%;margin-bottom: 1rem;text-align: center;"><span>' + item.to_doi_desc + '</span><span class="f_l" style="width:100%">' + item.attr_int_addr + '</span></div>');
  3110. }
  3111. }
  3112. //重新计算 区域高度
  3113. mIedEle.height(mIedEleCtl.height() + 120 * hRate);
  3114. sIedEle.height(sIedEleCtl.height() + 120 * hRate);
  3115. var maxH = Math.max(mIedEle.height(), sIedEle.height()) + 100 * hRate;
  3116. //dataContent.height(maxH);
  3117. //绘制连接
  3118. dataContent.append("<canvas id='canvas' class='abs canvas' style='width:100%;height:" + maxH + "px;z-index:0;pointer-events: none;'></canvas>");
  3119. var canvas = PoliceObject.p_createCanvas(win.find("#canvas"));
  3120. var m_ied_position = $("#m_ied").position();
  3121. var s_ied_position = win.find("#s_ied").position();
  3122. mIedEle.find(".inputs_extref").each(function(ind) {
  3123. var ele = $(this),
  3124. eleXY = ele.position();
  3125. var y = m_ied_position.top + eleXY.top + ele.parent().position().top + ele.height() / 2 - dataContent.css("padding-top").replace("px", "") * 1;
  3126. var x = ele.offset().left - ele.css("margin-left").replace("px", "") * 1 - ele.parent().position().left - win.css("padding-left").replace("px", "") * 1;
  3127. var masterIedJoinPoint = [x, y];
  3128. var s_ied_extref = win.find("#s_ied .inputs_extref:eq(" + ind + ")");
  3129. var sy = s_ied_position.top + s_ied_extref.position().top + s_ied_extref.parent().position().top + s_ied_extref.height() / 2 - dataContent.css("padding-top").replace("px", "") * 1;
  3130. var sx = s_ied_extref.offset().left - s_ied_extref.css("margin-left").replace("px", "") * 1 - s_ied_extref.parent().position().left - s_ied_extref.width() - win.css("padding-left").replace("px", "") * 1;
  3131. var salveJoinPoint = [sx, sy];
  3132. if (p1.m_ctrlid != "") {
  3133. //m_Ied->s_Ied:连线从左到右,箭头在右
  3134. PoliceObject.p_drawLine(canvas, masterIedJoinPoint, salveJoinPoint, "#134BEA");
  3135. } else {
  3136. //m_Ied<-s_Ied:连线从右到左,箭头在左
  3137. PoliceObject.p_drawLine(canvas, salveJoinPoint, masterIedJoinPoint, "#134BEA")
  3138. }
  3139. })
  3140. });
  3141. }
  3142. });
  3143. });
  3144. }
  3145. var makeSlefIedBlock = function(iedEle, data, callback) {
  3146. var count = 0;
  3147. if (data.SampledValueControl != null && data.SampledValueControl.length > 0) {
  3148. for (var i = 0; i < data.SampledValueControl.length; i++) {
  3149. var item = data.SampledValueControl[i];
  3150. iedEle.append('<span class="block" attr_type="SV" cb_name="' + item.ldinst + "/" + item.attr_name + '" node_id="' + item.node_id + '"><div>' + item.ldinst + '/' + item.attr_name + '</div><div>' + item.datset_desc + '</div><div style="font-size: 1.2rem;color: #516380;"></div></span>');
  3151. count++;
  3152. }
  3153. }
  3154. if (data.GSEControl != null && data.GSEControl.length > 0) {
  3155. for (var i = 0; i < data.GSEControl.length; i++) {
  3156. var item = data.GSEControl[i];
  3157. //if(item.attr_type!="GOOSE") continue;
  3158. iedEle.append('<span class="block" attr_type="GOOSE" cb_name="' + item.ldinst + "/" + item.attr_name + '" node_id="' + item.node_id + '"><div>' + item.ldinst + '/' + item.attr_name + '</div><div>' + item.datset_desc + '</div><div style="font-size: 1.2rem;color: #516380;"></div></span>');
  3159. count++;
  3160. }
  3161. }
  3162. PoliceObject.LoadIedNetWorkInfo(data.ied_name, ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID, function(r) {
  3163. for (var i = 0; i < r.length; i++) {
  3164. var tmpEle = iedEle.children(".block[cb_name='" + r[i].ld_inst + "/" + r[i].cb_name + "']");
  3165. if (tmpEle.length == 0 || r[i].address_json == "") continue;
  3166. var addressJson = JSON.parse(r[i].address_json);
  3167. tmpEle.children("div:eq(2)").html("APPID:" + (addressJson["APPID"] || ""));
  3168. }
  3169. var lastBlock = iedEle.find(".block:last");
  3170. var totalH = lastBlock.position().top + lastBlock.height() + 60 + lastBlock.css("margin-top").replace("px", "") * 1;
  3171. var iedEleH = iedEle.height();
  3172. var marginTop = 0;
  3173. if (iedEleH < totalH) {
  3174. iedEle.height(totalH + "px");
  3175. } else {
  3176. marginTop = (iedEleH - totalH) / 2;
  3177. iedEle.find(".block:first").css("margin-top", marginTop + "px");
  3178. }
  3179. if (callback != null) callback(data);
  3180. });
  3181. }
  3182. if (evt != null) {
  3183. var $t = $(evt);
  3184. //切换显示div
  3185. var chs = $t.parents(".dataitemlist").children(".content");
  3186. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3187. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3188. }
  3189. var ele = $("#ied_relation").removeClass("hidden");
  3190. ele.parents(".site_device_list").attr("ied_name", ieddata.ied_name).find("b").html(ieddata.desc + "(" + ieddata.ied_name + ")—详细信息");
  3191. ele.children("div.tools").children("li").off().on("click", function() {
  3192. var liclass = $.trim($(this).attr("class").replace("layui-this", ""));
  3193. switch (liclass) {
  3194. case "ref_map":
  3195. //块关联图
  3196. PoliceObject.LoadIedCtrlRelation(null, ieddata);
  3197. break;
  3198. case "sv_send":
  3199. //sv发送
  3200. PoliceObject.LoadIedSVSendBlockTable(null, ieddata);
  3201. break;
  3202. case "sv_revice":
  3203. //sv接收
  3204. PoliceObject.LoadIedSVReviceBlockTable(null, ieddata);
  3205. break;
  3206. case "goose_send":
  3207. //goose接收
  3208. PoliceObject.LoadIedGooseSendBlockTable(null, ieddata);
  3209. break;
  3210. case "goose_revice":
  3211. //goose接收
  3212. PoliceObject.LoadIedGooseReviceBlockTable(null, ieddata);
  3213. break;
  3214. default:
  3215. break;
  3216. }
  3217. });
  3218. if (!ele.children("div.tools").find(".ref_map").hasClass("layui-this")) {
  3219. //如果当前不是块关联图,自动切换过去
  3220. ele.children("div.tools").find(".ref_map").addClass("layui-this").trigger('click');
  3221. return;
  3222. }
  3223. var ied_strcut_detail = ele.find("#ied_strcut_detail").html("");
  3224. ied_strcut_detail.html(Tools.LoadingText("正在加载装置(" + ieddata.ied_name + ")数据中..."));
  3225. if (ieddata["GSEControl"] != null || ieddata["SampledValueControl"] != null) {
  3226. //判断装置关联关系是否已分析.未分析时重新分析
  3227. if ($.trim(ieddata["isreset"]) != "1" && (ieddata.list == null || ieddata.list.length <= 1)) {
  3228. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/relation", {
  3229. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  3230. "ied_name": ieddata.ied_name,
  3231. "reset": "1"
  3232. }, function(r) {
  3233. if (r.code != 0) {
  3234. layer.msg("获取装置信息失败:" + r.msg)
  3235. return;
  3236. }
  3237. layer.closeAll();
  3238. if (r.data == null) {
  3239. return
  3240. }
  3241. ieddata = r.data[ieddata.ied_name];
  3242. ieddata["isreset"] = "1";
  3243. PoliceObject.IedList[ieddata.ied_name] = ieddata;
  3244. PoliceObject.LoadIedCtrlRelation(null, ieddata, "1");
  3245. });
  3246. return;
  3247. } else {
  3248. tmp_load(ieddata);
  3249. }
  3250. } else {
  3251. var scdid = $.trim(ied_strcut_detail.parents(".site_device_list").attr("scd_id"));
  3252. scdid = scdid == "" ? PoliceObject.ScdID : scdid
  3253. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/ctrlblock", {
  3254. "scd_id": scdid,
  3255. "ied_name": ieddata.ied_name
  3256. }, function(r) {
  3257. if (r.code != 0) {
  3258. layer.msg(r.msg);
  3259. return;
  3260. }
  3261. ieddata["GSEControl"] = r.data.GSEControl;
  3262. ieddata["SampledValueControl"] = r.data.SampledValueControl;
  3263. PoliceObject.IedList[ieddata.ied_name] = ieddata;
  3264. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/ref/ctrlblock", {
  3265. "scd_id": scdid,
  3266. "ied_name": ieddata.ied_name,
  3267. "forcerefresh": ieddata["isforcerefresh"] == null ? "0" : ieddata["isforcerefresh"]
  3268. }, function(r1) {
  3269. if (r1.code != 0) {
  3270. layer.msg(r1.msg);
  3271. return;
  3272. }
  3273. if ($.trim(ieddata["isforcerefresh"]) != "1") {
  3274. //判断返回的块关系数是否与装置关系数相同,如果不同重新生成一次
  3275. if (r1.data != null && r1.data.length < ieddata.list.length) {
  3276. ieddata["GSEControl"] = null;
  3277. ieddata["SampledValueControl"] = null;
  3278. ieddata["isforcerefresh"] = "1";
  3279. PoliceObject.LoadIedCtrlRelation(null, ieddata);
  3280. return;
  3281. }
  3282. }
  3283. ieddata["isforcerefresh"] = "0";
  3284. ieddata["ControlBlock"] = r1.data;
  3285. PoliceObject.IedList[ieddata.ied_name] = ieddata;
  3286. tmp_load(ieddata);
  3287. });
  3288. });
  3289. }
  3290. },
  3291. //装置关联关系
  3292. LoadIedGraph: function(evt, ieddata, node_type, isreset) {
  3293. if (ieddata == null) return;
  3294. //加载IED列表树
  3295. this.LoadIedTreeList($("#ied_list_tree"));
  3296. if (evt != null) {
  3297. var $t = $(evt);
  3298. //切换显示div
  3299. var chs = $t.parents(".dataitemlist").children(".content");
  3300. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3301. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3302. }
  3303. var ele = $("#ied_info").removeClass("hidden");
  3304. ele.parents(".site_device_list").attr("ied_name", ieddata.ied_name).find("b").html(ieddata.desc + "(" + ieddata.ied_name + ")—详细信息");
  3305. var ied_strcut_detail = ele.find("#ied_strcut_detail").html("");
  3306. var iedRefList = ieddata.list;
  3307. if (iedRefList == null || iedRefList.length == 0) {
  3308. return;
  3309. }
  3310. if (iedRefList.length == 1 && isreset == null) {
  3311. //尝试重新分析该装置关系
  3312. this.GetIedData(ieddata.ied_name);
  3313. PoliceObject.LoadIedGraph(null, PoliceObject.IedList[ieddata.ied_name], node_type, 1);
  3314. return
  3315. }
  3316. ied_strcut_detail.slimscroll({
  3317. height: ied_strcut_detail.height() + "px",
  3318. width: "100%",
  3319. alwaysVisible: false,
  3320. wheelStep: 10,
  3321. size: "6px",
  3322. color: "#03aee7"
  3323. });
  3324. ied_strcut_detail.append('<span class="f_l ied_show_block self_ied ied_show_item" style="color:#134BEA;height:34rem;border:0px;"></span>');
  3325. var selfIed = ied_strcut_detail.children(".ied_show_block.self_ied").html("<div class='abs' style='top: 68%;width:100%;font-weight:bold;font-size:1.5rem;'>" + ieddata.ied_name + "<br>" + ieddata.desc + "</div>").attr("ied_name", ieddata.ied_name);
  3326. var iddXY = ied_strcut_detail.position();
  3327. for (var i = 0; i < ieddata.list.length; i++) {
  3328. var itme = ieddata.list[i];
  3329. var existRefIed = ied_strcut_detail.find("span[ied_name='" + itme.ref_ied_name + "']");
  3330. if (itme.ref_ied_name == null || itme.ref_ied_name == "" || existRefIed.length > 0) {
  3331. if (existRefIed.attr("ref_type") != itme.ref_type) {
  3332. //双向输入输出关系
  3333. existRefIed.attr("ref_type", '2');
  3334. }
  3335. continue;
  3336. }
  3337. if (itme.ref_type == "1") {
  3338. //输入关系
  3339. ied_strcut_detail.append('<span ref_type=' + itme.ref_type + ' class="ied_show_block salve_ied ied_show_item" ied_name="' + itme.ref_ied_name + '" style="border:0px;"><div class="abs" style="width: 100%;line-height: 1.6rem;">' + itme.ref_ied_name + '<br>' + itme.ref_ied_desc + '</div></span>');
  3340. } else {
  3341. //输出关系
  3342. ied_strcut_detail.append('<span ref_type=' + itme.ref_type + ' class="ied_show_block salve_ied ied_show_item" ied_name="' + itme.ref_ied_name + '" style="border:0px;"><div class="abs" style="width: 100%;line-height: 1.6rem;color:#51637F">' + itme.ref_ied_name + '<br>' + itme.ref_ied_desc + '</div></span>');
  3343. }
  3344. }
  3345. ied_strcut_detail.find(".ied_show_item").off().on('click', function() {
  3346. //点击装置进行切换
  3347. PoliceObject.LoadIedGraph(null, PoliceObject.IedList[$(this).attr("ied_name")]);
  3348. });
  3349. var iedList = ied_strcut_detail.children("span.salve_ied");
  3350. for (var i = 0; i < iedList.length; i++) {
  3351. if (i % 2 == 0) iedList.eq(i).addClass("left");
  3352. else iedList.eq(i).addClass("right");
  3353. }
  3354. var leftIedCount = 0;
  3355. ied_strcut_detail.children("span.ied_show_block.left").each(function(ind) {
  3356. var t = 0;
  3357. if (ind > 0) {
  3358. var $tmp = ied_strcut_detail.children("span.ied_show_block.left:eq(" + (ind - 1) + ")");
  3359. t = $tmp.position().top + $tmp.height() + 50;
  3360. }
  3361. $(this).css({
  3362. left: "5rem",
  3363. top: t + "px"
  3364. });
  3365. leftIedCount++;
  3366. });
  3367. var rightIedCount = 0; //右边IED显示的装置总数
  3368. ied_strcut_detail.children("span.ied_show_block.right").each(function(ind) {
  3369. var t = 0;
  3370. if (ind > 0) {
  3371. var $tmp = ied_strcut_detail.children("span.ied_show_block.right:eq(" + (ind - 1) + ")");
  3372. t = $tmp.position().top + $tmp.height() + 50;
  3373. }
  3374. $(this).css({
  3375. left: "90rem",
  3376. top: t + "px"
  3377. });
  3378. rightIedCount++;
  3379. });
  3380. //计算主IED的高度
  3381. var lastLeftEle = ied_strcut_detail.children("span.ied_show_block.left:last");
  3382. var lastRigthEle = ied_strcut_detail.children("span.ied_show_block.right:last");
  3383. if (lastLeftEle.length > 0 && lastRigthEle.length > 0) {
  3384. selfIed.css("height", Math.max(lastLeftEle.position().top + lastLeftEle.height(), lastRigthEle.position().top + lastRigthEle.height()) + 50 + "px");
  3385. } else if (lastLeftEle.length > 0)
  3386. selfIed.css("height", Math.max(lastLeftEle.position().top + lastLeftEle.height(), 500) + 50 + "px");
  3387. else if (lastRigthEle.length > 0)
  3388. selfIed.css("height", Math.max(500, lastRigthEle.position().top + lastRigthEle.height()) + 50 + "px");
  3389. if (selfIed.height() < 500) selfIed.height(500); //中间的主IED最小高度
  3390. //当右边装置数量不是偶数时,需要重新排列右边装置的位置,主要是top位置
  3391. //if (rightIedCount % 2 != 0) {
  3392. var rightIedFirst = ied_strcut_detail.children("span.ied_show_block.right:first");
  3393. if (rightIedFirst.length > 0) {
  3394. var newRightFirstIedTop = (selfIed.height() - rightIedCount * (rightIedFirst.height() + (rightIedCount == 1 ? 0 : 50))) / 2;
  3395. var topSubValue = newRightFirstIedTop - rightIedFirst.css("top").replace("px", "") * 1;
  3396. //微调每一个右侧IED的top
  3397. ied_strcut_detail.children("span.ied_show_block.right").each(function() {
  3398. var v_ied_oldtop = $(this).css("top").replace("px", "") * 1;
  3399. var t = v_ied_oldtop + topSubValue + selfIed.css("top").replace("px", "") * 1;
  3400. if (t < 0) t = 0;
  3401. $(this).css("top", t + "px");
  3402. });
  3403. }
  3404. var leftIedFirst = ied_strcut_detail.children("span.ied_show_block.left:first");
  3405. if (leftIedFirst.length > 0) {
  3406. var newLeftFirstIedTop = (selfIed.height() - leftIedCount * (leftIedFirst.height() + (leftIedCount == 1 ? 0 : 50))) / 2;
  3407. var topSubValue = newLeftFirstIedTop - leftIedFirst.css("top").replace("px", "") * 1;
  3408. //微调每一个左侧IED的top
  3409. ied_strcut_detail.children("span.ied_show_block.left").each(function() {
  3410. var v_ied_oldtop = $(this).css("top").replace("px", "") * 1;
  3411. var t = v_ied_oldtop + topSubValue + selfIed.css("top").replace("px", "") * 1;
  3412. if (t < 0) t = 10;
  3413. $(this).css("top", t + "px");
  3414. });
  3415. }
  3416. ied_strcut_detail.append("<canvas id='canvas' class='abs canvas' style='width:100%;height:" + selfIed.height() + "px;z-index:0;pointer-events: none;'></canvas>");
  3417. var canvas = this.p_createCanvas(ied_strcut_detail.find("canvas"));
  3418. //绘制连接线
  3419. //主设备的左右边连接点[x,y]
  3420. var masterIedLeftJoinPoint = [selfIed.position().left + selfIed.css("margin-left").replace("px", "") * 1, selfIed.position().top + selfIed.height() / 2];
  3421. var masterIedRightJoinPoint = [selfIed.position().left + selfIed.width() + selfIed.css("margin-left").replace("px", "") * 1, selfIed.position().top + selfIed.height() / 2];
  3422. //绘制左边连接
  3423. var inIedCnt = 0;
  3424. ied_strcut_detail.children("span.ied_show_block.left").each(function(ind) {
  3425. var t = $(this);
  3426. var salveRightJoinPoint = [t.position().left + t.width() + 5 - (t.width() * 0.2), t.position().top + t.height() / 2];
  3427. if (t.attr("ref_type") == "0") //输出到其他IED
  3428. PoliceObject.p_drawLine(canvas, masterIedLeftJoinPoint, salveRightJoinPoint, "#134BEA");
  3429. else if (t.attr("ref_type") == "1") {
  3430. PoliceObject.p_drawLine(canvas, salveRightJoinPoint, [masterIedLeftJoinPoint[0], masterIedLeftJoinPoint[1] + inIedCnt * 5], "#516380");
  3431. inIedCnt++;
  3432. } else {
  3433. PoliceObject.p_drawLine(canvas, [masterIedLeftJoinPoint[0], masterIedLeftJoinPoint[1] + inIedCnt * 5], salveRightJoinPoint, "#516380");
  3434. PoliceObject.p_drawLine(canvas, salveRightJoinPoint, [masterIedLeftJoinPoint[0], masterIedLeftJoinPoint[1] + inIedCnt * 5], "#134BEA");
  3435. inIedCnt++;
  3436. }
  3437. //var n1 = PoliceObject.p_drawNumber(ied_strcut_detail, masterIedLeftJoinPoint, salveRightJoinPoint, 12, "left");
  3438. //n1.attr("ied_name", t.attr("ied_name"));
  3439. });
  3440. //绘制右边连接
  3441. var outIedCnt = 0;
  3442. ied_strcut_detail.children("span.ied_show_block.right").each(function(ind) {
  3443. var t = $(this);
  3444. var salveLeftJoinPoint = [t.position().left + (t.width() * 0.2) - 5, t.position().top + t.height() / 2];
  3445. if (t.attr("ref_type") == "0") //输出到其他IED
  3446. {
  3447. PoliceObject.p_drawLine(canvas, masterIedRightJoinPoint, salveLeftJoinPoint, "#134BEA");
  3448. } else if (t.attr("ref_type") == "1") {
  3449. PoliceObject.p_drawLine(canvas, salveLeftJoinPoint, [masterIedRightJoinPoint[0], masterIedRightJoinPoint[1] + outIedCnt * 5], "#516380");
  3450. outIedCnt++;
  3451. } else {
  3452. PoliceObject.p_drawLine(canvas, [masterIedRightJoinPoint[0], masterIedRightJoinPoint[1] + outIedCnt * 5], salveLeftJoinPoint, "#516380");
  3453. PoliceObject.p_drawLine(canvas, salveLeftJoinPoint, [masterIedRightJoinPoint[0], masterIedRightJoinPoint[1] + outIedCnt * 5], "#134BEA");
  3454. outIedCnt++;
  3455. }
  3456. //var n1 = PoliceObject.p_drawNumber(ied_strcut_detail, masterIedRightJoinPoint, salveLeftJoinPoint, 12, "right");
  3457. //n1.attr("ied_name", t.attr("ied_name"));
  3458. });
  3459. },
  3460. //指定指定SCD下的ied信息
  3461. OtherIedList: {},
  3462. GetIedData: function(ied_name, scdid) {
  3463. if (scdid == null || scdid == PoliceObject.ScdID) scdid = "";
  3464. var ieddata = scdid != PoliceObject.ScdID ? PoliceObject.OtherIedList[scdid + ied_name] : PoliceObject.IedList[ied_name];
  3465. if (ieddata == null) {
  3466. layer.msg("正在获取装置信息...", {
  3467. time: 0
  3468. });
  3469. $.ajaxSettings.async = false;
  3470. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/relation", {
  3471. "scd_id": (scdid == null || scdid == "") ? PoliceObject.ScdID : scdid,
  3472. "ied_name": ied_name,
  3473. "reset": "1"
  3474. }, function(r) {
  3475. $.ajaxSettings.async = true;
  3476. if (r.code != 0) {
  3477. layer.msg("获取装置信息失败:" + r.msg)
  3478. return null;
  3479. }
  3480. layer.closeAll();
  3481. if (r.data == null) {
  3482. return null;
  3483. }
  3484. ieddata = r.data[ied_name];
  3485. if (scdid != null && scdid != "" && scdid == PoliceObject.ScdID) PoliceObject.IedList[ied_name] = ieddata;
  3486. else PoliceObject.OtherIedList[scdid + ied_name] = ieddata
  3487. return ieddata;
  3488. });
  3489. $.ajaxSettings.async = true;
  3490. }
  3491. layer.closeAll();
  3492. return ieddata;
  3493. },
  3494. LoadIedAllPointRelation: function(evt, refdata) {
  3495. if (evt != null) {
  3496. var $t = $(evt);
  3497. //切换显示div
  3498. var chs = $t.parents(".dataitemlist").children(".content");
  3499. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3500. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3501. }
  3502. var ele = $("#ied_allpoint_info").removeClass("hidden");
  3503. ele.parents(".site_device_list").attr("ied_name", refdata.ied_name).find("b").html(refdata.desc + "(" + refdata.ied_name + ")—详细信息");
  3504. var dataitemlist = ele.find("#ied_strcut_detail").html(PoliceObject.LoddingText);
  3505. var curIedName = refdata.ied_name;
  3506. /*
  3507. for (var iedname in PoliceObject.IedList) {
  3508. //输出关系
  3509. if (curIedName == iedname) {
  3510. for (var i = 0; i < PoliceObject.IedList[iedname].list.length; i++) {
  3511. var itme = PoliceObject.IedList[iedname].list[i];
  3512. if (itme.ref_type == "1") {
  3513. //输入关系
  3514. ref_ied_list.append('<span style="float:left;padding:1rem;margin:1rem;color:yellow">' + itme.ref_ied_desc + '</span>');
  3515. } else {
  3516. //输出关系
  3517. ref_ied_list.append('<span style="float:left;padding:1rem;margin:1rem;">' + itme.ref_ied_desc + '</span>');
  3518. }
  3519. }
  3520. }
  3521. }*/
  3522. var v_scdid = ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID;
  3523. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/inputs", {
  3524. "scd_id": v_scdid,
  3525. "ied_name": curIedName
  3526. }, function(r) {
  3527. PoliceObject.drawIedInputsRelation(v_scdid, refdata, dataitemlist, r.data);
  3528. })
  3529. },
  3530. //绘制装置的输入输出关系图
  3531. drawIedInputsRelation: function(v_scdid, refdata, dataitemlist, data) {
  3532. var w = dataitemlist.width(),
  3533. h = dataitemlist.height();
  3534. var curIedName = refdata.ied_name
  3535. //定义IED名称图形,该图形固定显示在中间,并且不显示连接点
  3536. dataitemlist.html("<div ied_name='" + curIedName + "' class='ied'><span style='height: 9rem;background-color: #a9bdee;border-radius: 1rem 1rem 0 0;'><img src='/static/images/ied.png'><span class='ied_header_desc'>" + refdata.desc + "</span><span class='ied_header_name'>" + curIedName + "</span></span><span class='master_ied'></span></div>");
  3537. var links = [];
  3538. var tmp = {};
  3539. var masterIed = dataitemlist.find(".master_ied");
  3540. var preExtrefEle_no = 0;
  3541. for (var i = 0; i < data.length; i++) {
  3542. var item = data[i];
  3543. if (item.no != null) {
  3544. if (preExtrefEle_no > 0 && (preExtrefEle_no + 1) != (item.no * 1)) {
  3545. //判断no是否是连续的,不连续时使用一个...代表中间有间隔
  3546. masterIed.append("<div class='extref' style='font-size: 1.5rem;font-weight: bold;letter-spacing: 0.5rem;'><span>...</span></div>");
  3547. }
  3548. preExtrefEle_no = item.no * 1;
  3549. }
  3550. var daname = $.trim(item["attr_da_name"]) == "" ? "" : "." + item["attr_da_name"];
  3551. var targetName = item["attr_ld_inst"] + "/" + item["attr_prefix"] + item["attr_ln_class"] + item["attr_ln_inst"] + "." + item["attr_do_name"] + daname;
  3552. if (item.inout_type == "out") {
  3553. masterIed.append("<div intAddr='" + targetName + "' to_ied_name='" + item.ied_name + "' to_addr='" + item["attr_int_addr"] + "' class='extref extref_opt_" + (item.opt || '') + "'><span class='extref_no'>" + (item["no"] || '') + "</span><span>" + targetName + "<br>" + item["do_source_desc"] + "</span><span class='linkpoint_right'></span><span class='extref_icon_opt_" + (item.opt || '') + "'></span></div>");
  3554. } else {
  3555. masterIed.append("<div intAddr='" + item["attr_int_addr"] + "' in_ied_name='" + item.ied_name + "' class='extref extref_opt_" + (item.opt || '') + "'><span class='linkpoint_left'></span><span class='extref_no'>" + (item["no"] || '') + "</span><span>" + item["attr_int_addr"] + "<br>" + item["do_target_desc"] + "</span><span class='extref_icon_opt_" + (item.opt || '') + "'></span></div>");
  3556. }
  3557. var ied_slave = dataitemlist.find(".ied." + item.inout_type + "[ied_name='" + item.ied_name + "']");
  3558. if (ied_slave.length == 0) {
  3559. var iedObj = PoliceObject.GetIedData(item.ied_name, item.scd_id || v_scdid)
  3560. if (item.inout_type == "in") {
  3561. var inIedCnt = dataitemlist.find(".ied.in:last");
  3562. var top = inIedCnt.length == 0 ? 10 : inIedCnt.height() + inIedCnt.position().top + 10;
  3563. if (iedObj == null) {
  3564. console.log(item)
  3565. continue;
  3566. }
  3567. dataitemlist.append("<div ied_name='" + item.ied_name + "' class='ied in' style='right:auto;left:25%;top:" + top + "px;width:20rem;'><span class='ied_header'><img src='/static/images/ied.png' style='height:4rem;width:5rem'><span class='ied_header_desc'>" + iedObj.desc + "</span><span class='ied_header_name'>" + item.ied_name + "</span></span><span class='master_ied'></span></div>");
  3568. } else {
  3569. var inIedCnt = dataitemlist.find(".ied.out:last");
  3570. var top = inIedCnt.length == 0 ? 10 : inIedCnt.height() + inIedCnt.position().top + 10;
  3571. if (iedObj == null) {
  3572. console.log(item)
  3573. continue;
  3574. }
  3575. dataitemlist.append("<div ied_name='" + item.ied_name + "' class='ied out' style='left:auto;right:10%;top:" + top + "px;width:20rem;'><span class='ied_header'><img src='/static/images/ied.png' style='height:4rem;width:5rem'><span class='ied_header_desc'>" + iedObj.desc + "</span><span class='ied_header_name'>" + item.ied_name + "</span></span><span class='master_ied'></span></div>");
  3576. }
  3577. ied_slave = dataitemlist.find(".ied." + item.inout_type + "[ied_name='" + item.ied_name + "']");
  3578. }
  3579. if (item.inout_type == "out") {
  3580. ied_slave.attr("class", "ied out");
  3581. //显示在主设备右边
  3582. ied_slave.find(".master_ied").append("<div intAddr='" + item["attr_int_addr"] + "' in_ied_name='" + curIedName + "' class='extref'><span class='linkpoint_left '></span><span>" + item["attr_int_addr"] + "<br>" + item["do_target_desc"] + "</span></div>");
  3583. } else {
  3584. ied_slave.attr("class", "ied in");
  3585. //显示在主设备左边
  3586. ied_slave.find(".master_ied").append("<div intAddr='" + targetName + "' to_ied_name='" + curIedName + "' to_addr='" + item["attr_int_addr"] + "' class='extref'><span>" + targetName + "<br>" + item["do_source_desc"] + "</span><span class='linkpoint_right'></span></div>");
  3587. }
  3588. }
  3589. if (item.opt == null) {
  3590. dataitemlist.find(".ied").off().on('click', function() {
  3591. //切换装置
  3592. PoliceObject.LoadIedAllPointRelation(null, PoliceObject.GetIedData($(this).attr("ied_name"), v_scdid));
  3593. });
  3594. }
  3595. var maxTopHei = 0;
  3596. dataitemlist.find(".ied.out").each(function(ind) {
  3597. var $t = $(this);
  3598. var thisIedName = $t.attr("ied_name");
  3599. var master_ied_first_extref = masterIed.children(".extref[to_ied_name='" + thisIedName + "']:first");
  3600. if (ind == 0) {
  3601. $t.css({
  3602. "left": "auto",
  3603. "right": "10%",
  3604. "top": master_ied_first_extref.position().top + "px"
  3605. });
  3606. } else {
  3607. var prev = dataitemlist.find(".ied.out:eq(" + (ind - 1) + ")");
  3608. $t.css({
  3609. "left": "auto",
  3610. "right": "10%",
  3611. "top": (prev.position().top * 1 + prev.height() + 30) + "px"
  3612. });
  3613. }
  3614. var tmpH = $t.position().top * 1 + $t.height();
  3615. if (maxTopHei < tmpH) maxTopHei = tmpH;
  3616. });
  3617. dataitemlist.find(".ied.in").each(function(ind) {
  3618. var $t = $(this);
  3619. if (ind == 0) {
  3620. $t.css({
  3621. "left": "20%",
  3622. "right": "auto",
  3623. "top": "1rem"
  3624. });
  3625. } else {
  3626. var prev = dataitemlist.find(".ied.in:eq(" + (ind - 1) + ")");
  3627. $t.css({
  3628. "left": "20%",
  3629. "right": "auto",
  3630. "top": (prev.position().top * 1 + prev.height() + 30) + "px"
  3631. });
  3632. }
  3633. var tmpH = $t.position().top * 1 + $t.height();
  3634. if (maxTopHei < tmpH) maxTopHei = tmpH;
  3635. });
  3636. var masterParentIed = masterIed.parent();
  3637. var master_ied_H = masterParentIed.position().top * 1 + masterParentIed.height();
  3638. if (maxTopHei < master_ied_H) maxTopHei = master_ied_H;
  3639. dataitemlist.append("<div class='ied blank' style='top:" + maxTopHei + "px;height:3rem;background: transparent;border: 0;'></div>");
  3640. dataitemlist.slimscroll({
  3641. height: dataitemlist.height() + "px",
  3642. width: "100%",
  3643. alwaysVisible: false,
  3644. wheelStep: 10,
  3645. size: "6px",
  3646. color: "#03aee7"
  3647. });
  3648. dataitemlist.append("<canvas class='abs canvas' style='width:100%;height:" + maxTopHei + "px;z-index:1;pointer-events: none;'></canvas>");
  3649. var canvas = PoliceObject.p_createCanvas(dataitemlist.find("canvas"));
  3650. var lastIed = dataitemlist.find(".ied.blank");
  3651. var topP = dataitemlist.offset();
  3652. dataitemlist.find(".extref").each(function() {
  3653. var $t = $(this),
  3654. toiedname = $.trim($t.attr("to_ied_name")),
  3655. toextref = $t.attr("to_addr");
  3656. var currIedname = $t.parent().parent().attr("ied_name");
  3657. if (toiedname == "") {
  3658. return;
  3659. }
  3660. var point = $t.find(".linkpoint_right,.linkpoint_left");
  3661. try {
  3662. if (point.length > 0) {
  3663. var toEle = dataitemlist.find(".ied[ied_name='" + toiedname + "'] .extref[intaddr='" + toextref + "'][in_ied_name='" + currIedname + "']").find(".linkpoint_right,.linkpoint_left");
  3664. var p = point.position(),
  3665. p1 = point.parents(".ied");
  3666. var t = toEle.position(),
  3667. t1 = toEle.parents(".ied");
  3668. var sourceLeft = p1.position().left * 1;
  3669. if (point.hasClass("linkpoint_right")) sourceLeft = sourceLeft + p1.width() + 5 - (p1.css("margin-left").replace("px", "") * -1);
  3670. else sourceLeft = p1.left - (p1.css("margin-left").replace("px", "") * -1);
  3671. var targetLeft = t1.position().left * 1;
  3672. if (toEle.hasClass("linkpoint_right")) targetLeft = targetLeft + t1.width() + 5 - (t1.css("margin-left").replace("px", "") * -1);
  3673. else targetLeft = targetLeft - (t1.css("margin-left").replace("px", "") * -1);
  3674. //p_drawPoly(canvascontext, [sourceLeft, p.top * 1 - topP.top + 5], [targetLeft, t.top * 1 - topP.top + 5]);
  3675. PoliceObject.p_drawLine(canvas, [sourceLeft, p1.position().top * 1 + 5 + point.parent().position().top + point.position().top], [targetLeft, t1.position().top + toEle.parent().position().top + toEle.position().top + 5], "#A6B1BF");
  3676. }
  3677. } catch (e) {
  3678. console.log(e)
  3679. }
  3680. })
  3681. },
  3682. //加载装置基本信息
  3683. LoadIedStrcut: function(evt, ieddata) {
  3684. //console.log(ieddata)
  3685. if (evt != null) {
  3686. var $t = $(evt);
  3687. //切换显示div
  3688. var chs = $t.parents(".dataitemlist").children(".content");
  3689. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3690. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3691. }
  3692. var ele = $("#ied_basicinfo").removeClass("hidden");
  3693. if (ele.parent().hasClass("slimScrollDiv")) {
  3694. ele.parent().removeClass("hidden");
  3695. }
  3696. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(PoliceObject.LoddingText);
  3697. ele.slimscroll({
  3698. height: ele.height() + "px",
  3699. width: "100%",
  3700. alwaysVisible: false,
  3701. wheelStep: 10,
  3702. size: "6px",
  3703. color: "#03aee7"
  3704. });
  3705. var iddXY = ied_strcut_detail.position();
  3706. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/attrs", {
  3707. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  3708. "node_id": ieddata.node_id,
  3709. "ied_name": ieddata.ied_name,
  3710. }, function(list) {
  3711. var thisIedName = list.data.name;
  3712. var wh = 200 * wRate;
  3713. var l = (ele.width() - wh) / 2;
  3714. ied_strcut_detail.html('<div class="ied_strcut" style="position:absolute;background-size:contain;background-repeat: no-repeat;background-image:url(/static/images/default_ied.png);width:' + wh + 'px;height:' + wh + 'px;left:' + l + 'px;top:30%;"><div class="ied_strcut_desc text_overflow" title="' + list.data.desc + '">' + list.data.desc + '</div><div class="ied_strcut_manufacturer text_overflow" style="top:50%;left:63%;" title="' + list.data.name + '">' + list.data.name + '</div><div class="ied_strcut_manufacturer text_overflow" title="' + list.data.manufacturer + '">' + list.data.manufacturer + '</div><div class="ied_strcut_type text_overflow" title="' + list.data.type + '">' + list.data.type + '</div></div>');
  3715. //生成IED装备固上定位置的连接点(上下左右)
  3716. var tmpIed = ied_strcut_detail.find(".ied_strcut");
  3717. var tmpIedOffset = tmpIed.position();
  3718. //主设备上的4连接点坐标
  3719. var iedTopPointXY = [tmpIedOffset.left + tmpIed.width() / 2, tmpIedOffset.top - iddXY.top];
  3720. var iedBottompointXY = [tmpIedOffset.left + tmpIed.width() / 2, tmpIedOffset.top - iddXY.top + tmpIed.height()];
  3721. var iedLeftPointXY = [tmpIedOffset.left, tmpIedOffset.top - iddXY.top + tmpIed.height() / 2];
  3722. var iedRightPointXY = [tmpIedOffset.left + tmpIed.width(), tmpIedOffset.top - iddXY.top + tmpIed.height() / 2];
  3723. //在界面上创建主IED在连接点
  3724. ied_strcut_detail.append('<span accessPoint="ied" class="ied_linkpoint left hidden" ind=2 style="top: ' + iedLeftPointXY[1] + 'px;left: ' + iedLeftPointXY[0] + 'px;"></span><span accessPoint="ied" ind=1 class="ied_linkpoint middle hidden" style="left: ' + iedBottompointXY[0] + 'px;top: ' + iedBottompointXY[1] + 'px;"></span><span accessPoint="ied" ind=3 class="ied_linkpoint right hidden" style="left: ' + iedRightPointXY[0] + 'px;top: ' + iedRightPointXY[1] + 'px;"></span><span accessPoint="ied" ind="" class="ied_linkpoint top" style="left: ' + iedTopPointXY[0] + 'px;top: ' + iedTopPointXY[1] + 'px;"></span>');
  3725. //固定的dataset关系
  3726. ied_strcut_detail.append('<div class="accessPoint" accessPoint="DataSet" style="position:absolute;top:1rem;left:48.2%;width: 6rem;background: transparent;color: aqua;"></div><span class="ied_linkpoint" accessPoint="DataSet" style="top: 6rem;left: 2.22rem;"></span>');
  3727. var accesspointEle = ied_strcut_detail.find(".accessPoint[accessPoint='DataSet']").css("left", function() {
  3728. return iedTopPointXY[0] - $(this).width() / 2;
  3729. });
  3730. var datasetPointStart = ied_strcut_detail.find(".ied_linkpoint[accessPoint='DataSet']").css({
  3731. "left": iedTopPointXY[0],
  3732. "top": accesspointEle.position().top + accesspointEle.height() - iddXY.top - 10
  3733. });
  3734. //生成固定的dataset连接线
  3735. var datasetlineheight = (iddXY.top + iedTopPointXY[1] - datasetPointStart.position().top);
  3736. ied_strcut_detail.append('<div class="line" style="position:absolute;top:' + (datasetPointStart.position().top - iddXY.top + datasetPointStart.height()) + 'px;left:' + (iedTopPointXY[0] + 2.5) + 'px;width: 1px;background: #134BEA;color: #516380;font-size: 1rem;height: ' + datasetlineheight + 'px;line-height:' + datasetlineheight + 'px;">DataSet</div>');
  3737. //加载DataSet列表
  3738. PoliceObject.LoadDataSet(thisIedName);
  3739. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  3740. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  3741. "pagesize": 10000,
  3742. "ied_name": thisIedName,
  3743. "name": "AccessPoint"
  3744. }, function(result) {
  3745. //生成访问点并进行布局。现固定支持最多3个accesspoint
  3746. for (var i = 0; i < result.data.length; i++) {
  3747. var master_link_point = ied_strcut_detail.find(".ied_linkpoint[ind=" + (i + 1) + "]").removeClass("hidden");
  3748. if (master_link_point.length == 0) continue;
  3749. var item = result.data[i];
  3750. var css = "";
  3751. var linkpoint_css = "";
  3752. var top = master_link_point.position().top - iddXY.top;
  3753. var linpoint_left = 0;
  3754. if (i == 0) {
  3755. //底边区域:第一个访问点生成及位置
  3756. var top1 = top + 120;
  3757. var left = master_link_point.position().left - ied_strcut_detail.width() / 2;
  3758. //left=master_link_point.offset().left-left;
  3759. css = 'width:39rem;height:auto;left:50%;top:' + top1 + 'px;margin-left: -20rem;min-height: 5rem;';
  3760. linpoint_left = iedBottompointXY[0];
  3761. linkpoint_css = 'top: ' + (top1 - 5) + 'px;';
  3762. } else if (i == 1) {
  3763. //右边区域:第2个访问点生成及位置
  3764. var top1 = top - 20;
  3765. css = 'width:39rem;height:auto;left:17%;top:' + top1 + 'px;margin-left: -20rem;min-height: 5rem;';
  3766. linkpoint_css = 'top: ' + iedLeftPointXY[1] + 'px;';
  3767. } else if (i == 2) {
  3768. //右边区域:第3个访问点生成及位置
  3769. var top1 = top - 20;
  3770. //var left=master_link_point.offset().left-ied_strcut_detail.width()*0.75;
  3771. css = 'width:39rem;height:auto;left:80%;top:' + top1 + 'px;margin-left: -20rem;min-height: 5rem;';
  3772. linkpoint_css = 'top: ' + iedRightPointXY[1] + 'px;';
  3773. }
  3774. //生成AccessPoint区域
  3775. ied_strcut_detail.append('<div class="accessPoint" accessPoint="' + item.attr_name + '" style="' + css + '"><div class="accessPoint_name">' + item.attr_name + ' (' + (item.attr_desc || '—') + ')</div><div class="networkinfo">正在加载网络信息...</div><div class="networkinfo_nmuber hidden"></div><div class="ldevice_list"><span style="position: absolute;top: -1rem;left: 1rem;background: #516380;line-height: 2rem;padding: 0 1rem;border-radius: 1rem;font-size: 1.4rem;color:#fff">LDevice</span></div></div>');
  3776. if (i > 0) {
  3777. //计算左右2侧accesspoint上的连接点left位置
  3778. accesspointEle = ied_strcut_detail.find(".accessPoint[accessPoint='" + item.attr_name + "']");
  3779. linpoint_left = accesspointEle.position().left + accesspointEle.css("margin-left").replace("px", "") * 1;
  3780. if (i == 1) linpoint_left = linpoint_left + accesspointEle.width();
  3781. }
  3782. //生成目标连接点
  3783. ied_strcut_detail.append('<span class="ied_linkpoint" accessPoint="' + item.attr_name + '" ind=' + (i + 1) + ' style="left:' + linpoint_left + 'px;' + linkpoint_css + '"></span>');
  3784. }
  3785. //生成连线
  3786. ied_strcut_detail.find(".ied_linkpoint[accessPoint='ied']").each(function() {
  3787. var $t = $(this),
  3788. start = $t.position();
  3789. if (!$t.hasClass("hidden")) {
  3790. var ind = $t.attr("ind");
  3791. if (ind == "") return; //dataset的连接点不具备ind属性
  3792. //需要连接的目标AccessPoint
  3793. var toEle = ied_strcut_detail.find(".ied_linkpoint[ind=" + ind + "][accessPoint!='ied']"),
  3794. to = toEle.position();
  3795. //计算连线长度
  3796. var line_width = Math.abs(start.left - to.left);
  3797. if (ind == 1) {
  3798. //连线高度
  3799. line_width = Math.abs(start.top - to.top);
  3800. ied_strcut_detail.append('<div class="line" style="position:absolute;height:' + line_width + 'px;width:1px;background-color:#134BEA;left:' + (start.left + $t.width() / 2) + 'px;top:' + (start.top - iddXY.top + $t.height() / 2) + 'px;color: #516380;font-size: 1rem;line-height: ' + line_width + 'px;">AccessPoint</div>');
  3801. } else {
  3802. //判断目标AccessPoint在主IED在左边还是右边
  3803. if (start.left < to.left)
  3804. ied_strcut_detail.append('<div class="line" style="position:absolute;height:1px;width:' + line_width + 'px;background-color:#134BEA;left:' + (start.left + $t.width()) + 'px;top:' + (start.top - iddXY.top + $t.height() / 2) + 'px;color: #516380;font-size: 1rem;line-height: 0rem;">AccessPoint</div>');
  3805. else {
  3806. ied_strcut_detail.append('<div class="line" style="position:absolute;height:1px;width:' + line_width + 'px;background-color:#134BEA;left:' + (to.left + toEle.width()) + 'px;top:' + (to.top - iddXY.top + toEle.height() / 2) + 'px;color: #516380;font-size: 1rem;line-height: 0rem;">AccessPoint</div>');
  3807. }
  3808. }
  3809. }
  3810. });
  3811. //获取每个访问点下的Ldevice列表
  3812. for (var i = 0; i < result.data.length; i++) {
  3813. PoliceObject.LoadLdeviceList(result.data[i].node_id, result.data[i].attr_name);
  3814. }
  3815. //获取设备的网络信息
  3816. PoliceObject.LoadIedNetWorkInfo(ieddata.ied_name, ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID, function(r) {
  3817. var tmpEle = ied_strcut_detail.find(".accessPoint .networkinfo").html("");
  3818. for (var i = 0; i < r.length; i++) {
  3819. var apName = r[i].ap_name;
  3820. var accesspointEle = ied_strcut_detail.find(".accessPoint[accessPoint='" + apName + "']");
  3821. if (accesspointEle.length == 0) continue;
  3822. var address_json = $.trim(r[i].address_json);
  3823. if (address_json == "") continue;
  3824. address_json = JSON.parse(address_json);
  3825. var accesspointNetEle = accesspointEle.children(".networkinfo");
  3826. var netHtml = [];
  3827. netHtml.push('<div cbname="' + r[i].cb_name + '">');
  3828. netHtml.push('<div><span class="f_l v_label">MAC-Address:</span><span class="f_l v_value">' + (address_json['MAC-Address'] || "无") + '</span></div>');
  3829. netHtml.push('<div><span class="f_l v_label">VLAN-PRIORITY:</span><span class="f_l v_value">' + (address_json['VLAN-PRIORITY'] || "无") + '</span></div>');
  3830. netHtml.push('<div><span class="f_l v_label">APPID:</span><span class="f_l v_value">' + (address_json['APPID'] || "无") + '</span></div>');
  3831. netHtml.push('<div><span class="f_l v_label">VLAN-ID:</span><span class="f_l v_value">' + (address_json['VLAN-ID'] || "无") + '</span></div>');
  3832. netHtml.push('</div>');
  3833. accesspointNetEle.append(netHtml.join(""));
  3834. var accesspointNumnerEle = accesspointEle.children(".networkinfo_nmuber");
  3835. accesspointNumnerEle.append('<span title="' + r[i].cb_name + '">' + (accesspointNumnerEle.children("span").length + 1) + '</span>');
  3836. }
  3837. ied_strcut_detail.find(".accessPoint[accessPoint]").each(function() {
  3838. var t123 = $(this).find(".networkinfo");
  3839. if (t123.children("div").length == 0) {
  3840. t123.addClass("hidden")
  3841. }
  3842. });
  3843. ied_strcut_detail.find(".networkinfo_nmuber").each(function() {
  3844. var me = $(this);
  3845. var mespan = me.children('span');
  3846. if (mespan.length > 1) me.removeClass("hidden");
  3847. else return;
  3848. mespan.off().on('click', function() {
  3849. var t = $(this);
  3850. var tp = t.parent().prev();
  3851. t.parent().children(".active").removeClass("active");
  3852. tp.children("div").addClass("hidden");
  3853. tp.children("div[cbname='" + t.attr("title") + "']").removeClass("hidden");
  3854. t.addClass("active");
  3855. }).eq(0).trigger('click');
  3856. });
  3857. });
  3858. });
  3859. });
  3860. },
  3861. //加载装置定值条目
  3862. LoadIedDingzhiTable: function(evt, ieddata) {
  3863. ///api/screen/scd/dingzhi/list?scd_id=4000002&pagesize=10000&ied_name=AE1101&name=DataSet
  3864. var $t = null;
  3865. if (evt != null) {
  3866. var $t = $(evt);
  3867. //切换显示div
  3868. var chs = $t.parents(".dataitemlist").children(".content");
  3869. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3870. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3871. }
  3872. var ele = $("#ied_dingzhiinfo").removeClass("hidden");
  3873. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(PoliceObject.LoddingText);
  3874. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/dingzhi", {
  3875. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  3876. "ied_name": ieddata.ied_name
  3877. }, function(jsondata) {
  3878. if (jsondata.code != 0) {
  3879. layer.msg(jsondata.msg)
  3880. return;
  3881. }
  3882. if (jsondata.data.length == 0) {
  3883. ied_strcut_detail.html(Tools.HintText("没有定值信息"));
  3884. return;
  3885. }
  3886. ied_strcut_detail.html('<div class="datasetlist" style="width:100%;height:32%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:100%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">定值条目列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:64%;margin: 1rem;"></div>');
  3887. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  3888. for (var i = 0; i < jsondata.data.length; i++) {
  3889. jsondata.data[i]["fcdalist"] = JSON.stringify(jsondata.data[i]["list"]);
  3890. }
  3891. tmpDsList.html(template("dingzhi_datasetlist_tpl", jsondata)).find("tbody>tr").off('click').on('click', function() {
  3892. tmpDsList.find("tr.active").removeClass("active");
  3893. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  3894. var targetdiv = ied_strcut_detail.find(".fcdalist");
  3895. $("#dataset_fcda_total").html("-");
  3896. if (fcdalist == "") {
  3897. targetdiv.html(Tools.HintText("没有条目信息"));
  3898. return;
  3899. }
  3900. fcdalist = JSON.parse(fcdalist);
  3901. ied_strcut_detail.find("#dataset_fcda_total").html(fcdalist.length);
  3902. targetdiv.html(template("dingzhi_fcdalist_tpl", {
  3903. "data": fcdalist
  3904. })).find("tbody>tr").off('click').on('click', function() {
  3905. targetdiv.find("tr.active").removeClass("active");
  3906. $(this).addClass("active");
  3907. });
  3908. targetdiv.children(".detailtable").slimscroll({
  3909. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  3910. width: "99%",
  3911. alwaysVisible: false,
  3912. wheelStep: 10,
  3913. size: "6px",
  3914. color: "#03aee7"
  3915. });
  3916. });
  3917. tmpDsList.children(".detailtable").slimscroll({
  3918. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  3919. width: "99%",
  3920. alwaysVisible: false,
  3921. wheelStep: 10,
  3922. size: "6px",
  3923. color: "#03aee7"
  3924. });
  3925. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  3926. });
  3927. },
  3928. //加载信息点表
  3929. LoadIedPointTable: function(evt, ieddata) {
  3930. ///api/screen/scd/dingzhi/list?scd_id=4000002&pagesize=10000&ied_name=AE1101&name=DataSet
  3931. var $t = null;
  3932. if (evt != null) {
  3933. var $t = $(evt);
  3934. //切换显示div
  3935. var chs = $t.parents(".dataitemlist").children(".content");
  3936. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  3937. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  3938. }
  3939. var ele = $("#ied_pointtableinfo").removeClass("hidden");
  3940. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(PoliceObject.LoddingText);
  3941. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/pointtable", {
  3942. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  3943. "ied_name": ieddata.ied_name
  3944. }, function(jsondata) {
  3945. if (jsondata.code != 0) {
  3946. layer.msg(jsondata.msg)
  3947. return;
  3948. }
  3949. if (jsondata.data.length == 0) {
  3950. ied_strcut_detail.html(Tools.HintText("没有信息点表"));
  3951. return;
  3952. }
  3953. ied_strcut_detail.html('<div class="datasetlist" style="width:100%;height:42%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:100%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">点表条目列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:54%;margin: 1rem;"></div>');
  3954. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  3955. for (var i = 0; i < jsondata.data.length; i++) {
  3956. jsondata.data[i]["fcdalist"] = JSON.stringify(jsondata.data[i]["list"]);
  3957. jsondata.data[i]["point_cnt"] = jsondata.data[i]["list"].length;
  3958. }
  3959. tmpDsList.html(template("pointtable_datasetlist_tpl", jsondata)).find("tbody>tr").off('click').on('click', function() {
  3960. tmpDsList.find("tr.active").removeClass("active");
  3961. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  3962. var targetdiv = ied_strcut_detail.find(".fcdalist");
  3963. $("#dataset_fcda_total").html("-");
  3964. if (fcdalist == "") {
  3965. targetdiv.html(Tools.HintText("没有条目信息"));
  3966. return;
  3967. }
  3968. fcdalist = JSON.parse(fcdalist);
  3969. ied_strcut_detail.find("#dataset_fcda_total").html(fcdalist.length);
  3970. targetdiv.html(template("pointtable_fcdalist_tpl", {
  3971. "data": fcdalist
  3972. })).find("tbody>tr").off('click').on('click', function() {
  3973. targetdiv.find("tr.active").removeClass("active");
  3974. $(this).addClass("active");
  3975. });
  3976. targetdiv.children(".detailtable").slimscroll({
  3977. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  3978. width: "99%",
  3979. alwaysVisible: false,
  3980. wheelStep: 10,
  3981. size: "6px",
  3982. color: "#03aee7"
  3983. });
  3984. });
  3985. tmpDsList.children(".detailtable").slimscroll({
  3986. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  3987. width: "99%",
  3988. alwaysVisible: false,
  3989. wheelStep: 10,
  3990. size: "6px",
  3991. color: "#03aee7"
  3992. });
  3993. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  3994. });
  3995. },
  3996. //加载信息点表
  3997. LoadIedSourceXML: function(evt, ieddata) {
  3998. var $t = null;
  3999. if (evt != null) {
  4000. var $t = $(evt);
  4001. //切换显示div
  4002. var chs = $t.parents(".dataitemlist").children(".content");
  4003. chs.children("div:eq(" + $t.index() + ")").removeClass("hidden");
  4004. chs.children("div:not(" + $t.index() + ")").addClass("hidden");
  4005. }
  4006. var ele = $("#ied_sourcexmlinfo").removeClass("hidden");
  4007. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(PoliceObject.LoddingText);
  4008. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/sourcexml", {
  4009. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4010. "ied_name": ieddata.ied_name
  4011. }, function(jsondata) {
  4012. if (jsondata.code != 0) {
  4013. layer.msg(jsondata.msg)
  4014. return;
  4015. }
  4016. ied_strcut_detail.html("<textarea style='width:100%;height:98%;border: 1px solid #d3d1d1;color: #666;font-family: initial;padding-left: 1rem;'>" + formateXml(jsondata.data) + "</textarea>");
  4017. });
  4018. },
  4019. //加载SV发送列表
  4020. LoadIedSVSendBlockTable: function(evt, ieddata) {
  4021. var ele = $("#ied_relation").removeClass("hidden");
  4022. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(Tools.LoadingText("正在加载装置(" + ieddata.ied_name + ")数据中..."));
  4023. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/ctrlblock", {
  4024. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4025. "ied_name": ieddata.ied_name
  4026. }, function(jsondata) {
  4027. if (jsondata.code != 0) {
  4028. ied_strcut_detail.html(jsondata.msg);
  4029. return;
  4030. }
  4031. if (jsondata.data.SampledValueControl == null || jsondata.data.SampledValueControl.length == 0) {
  4032. ied_strcut_detail.html(Tools.HintText("该装置无SV发送"))
  4033. return;
  4034. }
  4035. var h = template('svsend_datasetlist_tpl', {
  4036. "data": jsondata.data.SampledValueControl
  4037. });
  4038. ied_strcut_detail.html('<div class="datasetlist" style="width:100%;height:42%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:100%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">SMV端子列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:50%;margin: 1rem;"></div>');
  4039. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  4040. tmpDsList.html(h).find("tbody>tr").off('click').on('click', function() {
  4041. tmpDsList.find("tr.active").removeClass("active");
  4042. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  4043. var ctrlId = $(this).attr("ctrl_id")
  4044. var targetdiv = ied_strcut_detail.find(".fcdalist");
  4045. $("#dataset_fcda_total").html("-");
  4046. targetdiv.html(Tools.HintText("正在加载端子列表数据..."));
  4047. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/smv_ctrlblock/sendfcdalist", {
  4048. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4049. "ied_name": ieddata.ied_name,
  4050. "ctrlid": ctrlId
  4051. }, function(jsondata) {
  4052. if (jsondata.code != 0) {
  4053. targetdiv.html(Tools.HintText(jsondata.msg));
  4054. return;
  4055. }
  4056. if (jsondata.data == null || jsondata.data.length == 0) {
  4057. $("#dataset_fcda_total").html("0");
  4058. targetdiv.html(Tools.HintText("未查找到端子列表"));
  4059. return;
  4060. }
  4061. $("#dataset_fcda_total").html(jsondata.data.length);
  4062. targetdiv.html(template('svsend_fcdalist_tpl', jsondata));
  4063. targetdiv.children(".detailtable").slimscroll({
  4064. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  4065. width: "99%",
  4066. alwaysVisible: false,
  4067. wheelStep: 10,
  4068. size: "6px",
  4069. color: "#03aee7"
  4070. });
  4071. })
  4072. });
  4073. tmpDsList.children(".detailtable").slimscroll({
  4074. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  4075. width: "99%",
  4076. alwaysVisible: false,
  4077. wheelStep: 10,
  4078. size: "6px",
  4079. color: "#03aee7"
  4080. });
  4081. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  4082. });
  4083. },
  4084. //加载SV接收列表
  4085. LoadIedSVReviceBlockTable: function(evt, ieddata) {
  4086. var ele = $("#ied_relation").removeClass("hidden");
  4087. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(Tools.LoadingText("正在加载装置(" + ieddata.ied_name + ")数据中..."));
  4088. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/smv_ctrlblock/receive", {
  4089. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4090. "ied_name": ieddata.ied_name
  4091. }, function(jsondata) {
  4092. if (jsondata.code != 0) {
  4093. ied_strcut_detail.html(jsondata.msg);
  4094. return;
  4095. }
  4096. if (jsondata.data == null || jsondata.data.length == 0) {
  4097. ied_strcut_detail.html(Tools.HintText("该装置无SV接收"))
  4098. return;
  4099. }
  4100. //拆分为主从结构
  4101. var masterdatalist = [],
  4102. tmplist = {};
  4103. for (var i = 0; i < jsondata.data.length; i++) {
  4104. var item = jsondata.data[i];
  4105. var key = item.out_ied_name + item.out_smv_ctrl_name + item.out_dataset_name;
  4106. if (tmplist[key] == null) {
  4107. tmplist[key] = {
  4108. "info": item,
  4109. "list": [item]
  4110. };
  4111. } else {
  4112. tmplist[key]["list"].push(item);
  4113. }
  4114. }
  4115. for (var k in tmplist) {
  4116. tmplist[k]["info"]["list"] = JSON.stringify(tmplist[k]["list"]);
  4117. masterdatalist.push(tmplist[k]);
  4118. }
  4119. var h = template('svrev_datasetlist_tpl', {
  4120. "data": masterdatalist
  4121. });
  4122. tmplist = null;
  4123. masterdatalist = null;
  4124. ied_strcut_detail.html('<div class="datasetlist" style="width:99%;height:42%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:99%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">SMV端子列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:50%;margin: 1rem;"></div>');
  4125. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  4126. tmpDsList.html(h).find("tbody>tr").off('click').on('click', function() {
  4127. tmpDsList.find("tr.active").removeClass("active");
  4128. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  4129. var ctrlId = $(this).attr("ctrl_id")
  4130. var targetdiv = ied_strcut_detail.find(".fcdalist");
  4131. ied_strcut_detail.find("#dataset_fcda_total").html("-");
  4132. if (fcdalist == "") {
  4133. ied_strcut_detail.find("#dataset_fcda_total").html("0");
  4134. targetdiv.html(Tools.HintText("未查找到端子列表"));
  4135. return;
  4136. }
  4137. fcdalist = JSON.parse(fcdalist);
  4138. ied_strcut_detail.find("#dataset_fcda_total").html(fcdalist.length);
  4139. targetdiv.html(template('svrev_fcdalist_tpl', {
  4140. "data": fcdalist
  4141. }));
  4142. targetdiv.children(".detailtable").slimscroll({
  4143. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  4144. width: "99%",
  4145. alwaysVisible: false,
  4146. wheelStep: 10,
  4147. size: "6px",
  4148. color: "#03aee7"
  4149. });
  4150. });
  4151. tmpDsList.children(".detailtable").slimscroll({
  4152. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  4153. width: "99%",
  4154. alwaysVisible: false,
  4155. wheelStep: 10,
  4156. size: "6px",
  4157. color: "#03aee7"
  4158. });
  4159. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  4160. });
  4161. },
  4162. //加载goose发送列表
  4163. LoadIedGooseSendBlockTable: function(evt, ieddata) {
  4164. var ele = $("#ied_relation").removeClass("hidden");
  4165. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(Tools.LoadingText("正在加载装置(" + ieddata.ied_name + ")数据中..."));
  4166. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/ctrlblock", {
  4167. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4168. "ied_name": ieddata.ied_name
  4169. }, function(jsondata) {
  4170. if (jsondata.code != 0) {
  4171. ied_strcut_detail.html(jsondata.msg);
  4172. return;
  4173. }
  4174. if (jsondata.data.GSEControl == null || jsondata.data.GSEControl.length == 0) {
  4175. ied_strcut_detail.html(Tools.HintText("该装置无GOOSE发送"))
  4176. return;
  4177. }
  4178. var h = template('goosesend_datasetlist_tpl', {
  4179. "data": jsondata.data.GSEControl
  4180. });
  4181. ied_strcut_detail.html('<div class="datasetlist" style="width:100%;height:42%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:100%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">GOOSE端子列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:50%;margin: 1rem;"></div>');
  4182. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  4183. tmpDsList.html(h).find("tbody>tr").off('click').on('click', function() {
  4184. tmpDsList.find("tr.active").removeClass("active");
  4185. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  4186. var ctrlId = $(this).attr("ctrl_id")
  4187. var targetdiv = ied_strcut_detail.find(".fcdalist");
  4188. $("#dataset_fcda_total").html("-");
  4189. targetdiv.html(Tools.HintText("正在加载端子列表数据..."));
  4190. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/goose_ctrlblock/sendfcdalist", {
  4191. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4192. "ied_name": ieddata.ied_name,
  4193. "ctrlid": ctrlId
  4194. }, function(jsondata) {
  4195. if (jsondata.code != 0) {
  4196. targetdiv.html(Tools.HintText(jsondata.msg));
  4197. return;
  4198. }
  4199. if (jsondata.data == null || jsondata.data.length == 0) {
  4200. $("#dataset_fcda_total").html("0");
  4201. targetdiv.html(Tools.HintText("未查找到端子列表"));
  4202. return;
  4203. }
  4204. $("#dataset_fcda_total").html(jsondata.data.length);
  4205. targetdiv.html(template('goosesend_fcdalist_tpl', jsondata));
  4206. targetdiv.children(".detailtable").slimscroll({
  4207. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  4208. width: "99%",
  4209. alwaysVisible: false,
  4210. wheelStep: 10,
  4211. size: "6px",
  4212. color: "#03aee7"
  4213. });
  4214. })
  4215. });
  4216. tmpDsList.children(".detailtable").slimscroll({
  4217. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  4218. width: "99%",
  4219. alwaysVisible: false,
  4220. wheelStep: 10,
  4221. size: "6px",
  4222. color: "#03aee7"
  4223. });
  4224. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  4225. });
  4226. },
  4227. //加载GOOSE接收列表
  4228. LoadIedGooseReviceBlockTable: function(evt, ieddata) {
  4229. var ele = $("#ied_relation").removeClass("hidden");
  4230. var ied_strcut_detail = ele.find("#ied_strcut_detail").html(Tools.LoadingText("正在加载装置(" + ieddata.ied_name + ")数据中..."));
  4231. $.getJSON(Global.AccessUrl + "/api/screen/scd/ied/goose_ctrlblock/receive", {
  4232. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4233. "ied_name": ieddata.ied_name
  4234. }, function(jsondata) {
  4235. if (jsondata.code != 0) {
  4236. ied_strcut_detail.html(jsondata.msg);
  4237. return;
  4238. }
  4239. if (jsondata.data == null || jsondata.data.length == 0) {
  4240. ied_strcut_detail.html(Tools.HintText("该装置无GOOSE接收"))
  4241. return;
  4242. }
  4243. //拆分为主从结构
  4244. var masterdatalist = [],
  4245. tmplist = {};
  4246. for (var i = 0; i < jsondata.data.length; i++) {
  4247. var item = jsondata.data[i];
  4248. var key = item.out_ied_name + item.out_smv_ctrl_name + item.out_dataset_name;
  4249. if (tmplist[key] == null) {
  4250. tmplist[key] = {
  4251. "info": item,
  4252. "list": [item]
  4253. };
  4254. } else {
  4255. tmplist[key]["list"].push(item);
  4256. }
  4257. }
  4258. for (var k in tmplist) {
  4259. tmplist[k]["info"]["list"] = JSON.stringify(tmplist[k]["list"]);
  4260. masterdatalist.push(tmplist[k]);
  4261. }
  4262. var h = template('gooserev_datasetlist_tpl', {
  4263. "data": masterdatalist
  4264. });
  4265. tmplist = null;
  4266. masterdatalist = null;
  4267. ied_strcut_detail.html('<div class="datasetlist" style="width:100%;height:42%;margin: 1rem;border: 1px solid #ededed;"></div><div style="width:100%;height:2rem;text-align: left;line-height: 2rem;"><span style="margin: 0 2rem;font-weight: bold;">GOOSE端子列表详情(共 <b id="dataset_fcda_total"></b> 条)</span></div><div class="fcdalist" style="width:100%;height:50%;margin: 1rem;"></div>');
  4268. var tmpDsList = ied_strcut_detail.find(".datasetlist");
  4269. tmpDsList.html(h).find("tbody>tr").off('click').on('click', function() {
  4270. tmpDsList.find("tr.active").removeClass("active");
  4271. var fcdalist = $.trim($(this).addClass("active").attr("fcdalist"));
  4272. var ctrlId = $(this).attr("ctrl_id")
  4273. var targetdiv = ied_strcut_detail.find(".fcdalist");
  4274. ied_strcut_detail.find("#dataset_fcda_total").html("-");
  4275. if (fcdalist == "") {
  4276. ied_strcut_detail.find("#dataset_fcda_total").html("0");
  4277. targetdiv.html(Tools.HintText("未查找到端子列表"));
  4278. return;
  4279. }
  4280. fcdalist = JSON.parse(fcdalist);
  4281. ied_strcut_detail.find("#dataset_fcda_total").html(fcdalist.length);
  4282. targetdiv.html(template('gooserev_fcdalist_tpl', {
  4283. "data": fcdalist
  4284. }));
  4285. targetdiv.children(".detailtable").slimscroll({
  4286. height: targetdiv.height() - targetdiv.find(".headertable").height() + "px",
  4287. width: "99%",
  4288. alwaysVisible: false,
  4289. wheelStep: 10,
  4290. size: "6px",
  4291. color: "#03aee7"
  4292. });
  4293. });
  4294. tmpDsList.children(".detailtable").slimscroll({
  4295. height: tmpDsList.height() - (tmpDsList.css("margin").replace("px", "") * 2) - tmpDsList.find(".headertable").height() + "px",
  4296. width: "99%",
  4297. alwaysVisible: false,
  4298. wheelStep: 10,
  4299. size: "6px",
  4300. color: "#03aee7"
  4301. });
  4302. tmpDsList.height(tmpDsList.height() - 24).find("tbody>tr:first").trigger('click');
  4303. });
  4304. },
  4305. //加载DataSet列表
  4306. LoadDataSet: function(thisIedName) {
  4307. var $ied_strcut = $("#ied_basicinfo");
  4308. var $datasetList = $("#ied_basicinfo #dataset_list");
  4309. if ($datasetList.length == 0) {
  4310. $ied_strcut.append('<div id="dataset_list"></div>');
  4311. $datasetList = $("#ied_basicinfo #dataset_list");
  4312. } else {
  4313. $datasetList.removeClass("hidden").html("");
  4314. }
  4315. var datasetEle = $ied_strcut.find(".accessPoint[accessPoint='DataSet']");
  4316. $datasetList.css({
  4317. "left": "1rem",
  4318. "top": datasetEle.position().top
  4319. });
  4320. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  4321. "scd_id": $ied_strcut.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4322. "pagesize": 10000,
  4323. "ied_name": thisIedName,
  4324. "name": "DataSet"
  4325. }, function(result) {
  4326. var eles = [];
  4327. for (var i = 0; i < result.data.length; i++) {
  4328. eles.push('<span dataset_id="' + result.data[i].node_id + '"><i class="fa fa-database"></i><span class="f_l" style="width:100%;font-weight: 400;font-size:1.4rem;">' + result.data[i].attr_name + '</span><span class="f_l" style="width:100%;color:#A38BF3;font-weight: 800;font-size:1.2rem;">(' + result.data[i].attr_desc + ')</span></span>');
  4329. }
  4330. $datasetList.html(eles.join("")).children("span").off().on('click', function() {
  4331. var t = $(this);
  4332. PoliceObject.LoadFCDAList(this, t.attr("dataset_id"), t.find("span:last").text());
  4333. });
  4334. var datasetPoint = $(".ied_linkpoint[accesspoint='DataSet']").css({
  4335. "top": $datasetList.position().top + $datasetList.height() + (15 * hRate) + "px"
  4336. })
  4337. var h1 = $(".ied_linkpoint.top").position().top - datasetPoint.position().top;
  4338. datasetPoint.next().css({
  4339. "top": datasetPoint.position().top + 5 + "px",
  4340. "height": h1 + "px",
  4341. "line-height": h1 + "px"
  4342. });
  4343. });
  4344. },
  4345. //加载AccessPoint下的LDevice列表
  4346. LoadLdeviceList: function(accessPointId, accessPointName) {
  4347. var ele = $("#ied_basicinfo .accessPoint[accesspoint='" + accessPointName + "']");
  4348. if (ele.length == 0) return;
  4349. $.getJSON(Global.AccessUrl + "/api/screen/scd/ldevice/list", {
  4350. "scd_id": ele.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4351. "accessPointId": accessPointId
  4352. }, function(r) {
  4353. if (r.data == null) {
  4354. return;
  4355. }
  4356. var $ldeviceList = ele.find(".ldevice_list");
  4357. for (var i = 0; i < r.data.length; i++) {
  4358. var item = r.data[i];
  4359. var txt = item.attr_inst;
  4360. if (item.attr_desc != "") txt += "<br><font style='font-size:1rem;color: #94A3B8;'>" + item.attr_desc + "</font>";
  4361. $ldeviceList.append('<span title="点击查看LN" onclick="PoliceObject.LoadLnList(this,\'' + item.node_id + '\')" class="ldevice_item" ldevice_id="' + item.node_id + '"><img src="/static/images/ldevice.png"><div>' + txt + '</div></span>');
  4362. }
  4363. });
  4364. },
  4365. //加载LDevice下的LN列表
  4366. LoadLnList: function(ele, ldeviceId) {
  4367. var $ied_strcut = $("#ied_basicinfo");
  4368. var ied_strcut_detail = $("#ied_basicinfo #ied_strcut_detail");
  4369. layer.msg("正在加载LN列表...", {
  4370. time: 0
  4371. });
  4372. var showLnList = $ied_strcut.find("#showLnList");
  4373. if (showLnList.length == 0) {
  4374. $ied_strcut.append("<div id='showLnList'><span style='cursor:pointer;position:absolute;top:7px;right:7px;color:#299BFF;font-size:1.5rem;z-index:100' class='fa fa-times' onclick='$(\"#showLnList\").remove();'></span><span class='caption'></span><span class='ln_list_title'><table style='width:100%;text-align: center;font-size: 1rem;'><thead><tr><td style='width:7%'>序号</td><td style='width:8%'>inst</td><td style='width:10%'>lnClass</td><td style='width:40%'>lnType</td><td style='width:35%'>desc</td></tr></thead></table></span><span class='ln_list'><table style='width:100%;text-align: center;color: #ccc;font-size: 1rem;color:#09162C'></table></span></div>");
  4375. showLnList = $ied_strcut.find("#showLnList");
  4376. } else {
  4377. showLnList.removeClass("hidden").find(".ln_list table").html("");
  4378. }
  4379. var toEle = $(ele),
  4380. toXY = toEle.position();
  4381. showLnList.find(".caption").html(toEle.text() + "—LN/LN0节点列表");
  4382. showLnList.css({
  4383. top: $ied_strcut.height() * 0.25,
  4384. left: ($ied_strcut.width() - showLnList.width()) / 2
  4385. });
  4386. var lndatalistEle = showLnList.find(".ln_list table");
  4387. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  4388. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4389. "parent_node_id": ldeviceId,
  4390. "pagesize": 1000,
  4391. "name": "LN0"
  4392. }, function(r) {
  4393. var trs = [];
  4394. for (var i = 0; i < r.data.length; i++) {
  4395. var item = r.data[i];
  4396. trs.push("<tr json='" + JSON.stringify(item) + "' node_id=" + item.node_id + "><td style='width:7%'>1</td><td class='text_overflow' style='width:8%'>" + (item.attr_inst || "&nbsp;") + "</td><td class='text_overflow' style='width:10%'>" + item.attr_ln_class + "</td><td class='text_overflow' style='width:40%'>" + item.attr_ln_type + "</td><td class='text_overflow' style='width:35%'>" + item.attr_desc + "</td></tr>");
  4397. }
  4398. lndatalistEle.prepend(trs.join(""));
  4399. lndatalistEle.find("tr").each(function(ind, ele) {
  4400. $(ele).children("td:first").html(ind + 1);
  4401. });
  4402. });
  4403. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  4404. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4405. "parent_node_id": ldeviceId,
  4406. "pagesize": 1000,
  4407. "name": "LN"
  4408. }, function(r) {
  4409. var trs = [];
  4410. layer.closeAll();
  4411. for (var i = 0; i < r.data.length; i++) {
  4412. var item = r.data[i];
  4413. trs.push("<tr json='" + JSON.stringify(item) + "' node_id=" + item.node_id + "><td style='width:7%'>序号</td><td class='text_overflow' style='width:8%'>" + (item.attr_inst || "&nbsp;") + "</td><td class='text_overflow' style='width:10%'>" + item.attr_ln_class + "</td><td class='text_overflow' style='width:40%'>" + item.attr_ln_type + "</td><td class='text_overflow' style='width:35%'>" + item.attr_desc + "</td></tr>");
  4414. }
  4415. lndatalistEle.append(trs.join(""));
  4416. lndatalistEle.find("tr").each(function(ind, ele) {
  4417. $(ele).children("td:first").html(ind + 1);
  4418. });
  4419. });
  4420. lndatalistEle.off().on("click", "tr", function() {
  4421. var jsondata = JSON.parse($(this).attr("json"));
  4422. //暂时屏蔽该逻辑
  4423. /*
  4424. DialogObject.Open($("#dialog_public"), {
  4425. callback: PoliceObject.LoadLnStrcut,
  4426. para: jsondata,
  4427. size: ["100rem", "70rem"]
  4428. });
  4429. */
  4430. });
  4431. },
  4432. LoadLnStrcut: function(win, para) {
  4433. win.find(".caption>b").html((para.attr_ln_class == "LLN0" ? "LLN0" : "LN") + "结构详情—" + para.attr_desc);
  4434. var h = (win.height() - win.find(".caption").height() - win.find(".footer").height());
  4435. win.find(".dataitemlist").height(h + "px");
  4436. var ln_strcut_detail = win.find("#ln_strcut_detail");
  4437. layer.msg("正在加载DOI数据...", {
  4438. time: 0
  4439. });
  4440. //生成根节点
  4441. var trs = [{
  4442. "id": para.node_id,
  4443. "isroot": true,
  4444. "topic": para.attr_desc || para.attr_ln_class
  4445. }];
  4446. kmsjsmap.inited = kmsjsmap.isInit = false; //重置初始化状态为未初始化
  4447. var jsmind = kmsjsmap.init({
  4448. container: ln_strcut_detail[0],
  4449. data: trs,
  4450. editable: false,
  4451. onRelation: function(item) {
  4452. if (item.children.length == 0 && item.data.badge != "" && !item.data.isloaded) {
  4453. //加载该节点下的子节点
  4454. var node = jsmind.get_node(item.id);
  4455. //console.log('当前选择中的是', node)
  4456. PoliceObject.AppendMindNodes(para.scdid, jsmind, node, item.id, item.topic);
  4457. }
  4458. }
  4459. });
  4460. //移除组件自带的放大缩小插件
  4461. win.find(".lui-jsmind-innerToolBar").remove();
  4462. PoliceObject.AppendMindNodeType(para.scdid, jsmind, jsmind.get_node(para.node_id), para.node_id);
  4463. },
  4464. AppendMindNodeType: function(scdid, jsmind, parentItem, pid, callback) {
  4465. layer.closeAll();
  4466. //获取下级节点及数量
  4467. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/children/stat", {
  4468. "scd_id": scdid,
  4469. "node_id": pid
  4470. }, function(r) {
  4471. parentItem.data.isloaded = true;
  4472. if (r.data == null || r.data.length == 0) {
  4473. if (callback != null) callback();
  4474. return;
  4475. }
  4476. jsmind.options.editable = true;
  4477. for (var i = 0; i < r.data.length; i++) {
  4478. var cItem = r.data[i];
  4479. var nid = pid + "_" + cItem.node_name;
  4480. jsmind.data.jm.add_node(parentItem, nid, cItem.node_name, {
  4481. "badge": cItem.cnt,
  4482. "isloaded": false
  4483. });
  4484. }
  4485. jsmind.options.editable = false;
  4486. if (callback != null) callback();
  4487. });
  4488. },
  4489. //加载指定节点的子节点到导图中
  4490. AppendMindNodes: function(scdid, jsmind, parentItem, pid, nodeName, callback) {
  4491. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  4492. "scd_id": scdid,
  4493. "parent_node_id": pid,
  4494. "name": nodeName,
  4495. "pagesize": 10000
  4496. }, function(r) {
  4497. parentItem.data.isloaded = true;
  4498. if (r.data == null || r.data.length == 0) {
  4499. if (callback != null) callback();
  4500. return;
  4501. }
  4502. jsmind.options.editable = true;
  4503. for (var i = 0; i < r.data.length; i++) {
  4504. var daiItem = r.data[i];
  4505. var sddr = daiItem.attr_saddr;
  4506. var txt = daiItem.attr_name;
  4507. if (daiItem.node_name == "SDI") {
  4508. if ($.trim(daiItem.attr_desc) != "") txt = txt + "(" + daiItem.attr_desc + ")";
  4509. }
  4510. if (daiItem.node_name == "DAI") {
  4511. if ($.trim(daiItem.attr_saddr) != "") txt = txt + "(sAddr:" + daiItem.attr_saddr + ")";
  4512. }
  4513. if (daiItem.node_name == "Val") {
  4514. txt = daiItem.node_value;
  4515. }
  4516. if (daiItem.node_name == "FCDA") {
  4517. txt = daiItem.attr_ln_class + "_" + daiItem.attr_ln_inst;
  4518. }
  4519. if (daiItem.node_name == "ExtRef") {
  4520. txt = daiItem.attr_ln_class + "_" + daiItem.attr_ln_inst + "(intAddr:" + daiItem.attr_int_addr + ")";
  4521. }
  4522. var nid = daiItem.node_id || daiItem.nodeid;
  4523. var newNode = jsmind.data.jm.add_node(parentItem, nid, txt, {
  4524. "badge": "",
  4525. "isloaded": false
  4526. });
  4527. PoliceObject.AppendMindNodeType(jsmind, newNode, nid);
  4528. }
  4529. jsmind.options.editable = false;
  4530. if (callback != null) callback();
  4531. });
  4532. },
  4533. //加载DataSet下的FCDA列表
  4534. LoadFCDAList: function(ele, dataset_id, dataset_name) {
  4535. var $ied_strcut = $("#ied_basicinfo");
  4536. var ied_strcut_detail = $ied_strcut.find("#ied_strcut_detail");
  4537. layer.msg("正在加载FCDA列表...", {
  4538. time: 0
  4539. });
  4540. var showLnList = $ied_strcut.find("#showLnList");
  4541. if (showLnList.length == 0) {
  4542. $ied_strcut.append("<div id='showLnList'><span style='cursor:pointer;position:absolute;top:7px;right:7px;color:#299BFF;font-size:1.5rem;z-index:100' class='fa fa-times' onclick='$(\"#showLnList\").remove();'></span><span class='caption'></span><span class='ln_list_title'><table style='width:100%;text-align: center;font-size: 1rem;'><thead><tr><td style='width:10%' class='text_overflow'>ldInst</td><td style='width:15%' class='text_overflow'>prefix</td><td style='width:15%' class='text_overflow'>lnClass</td><td style='width:10%' class='text_overflow'>lnInst</td><td style='width:30%' class='text_overflow'>doName</td><td style='width:10%' class='text_overflow'>daName</td><td style='width:10%' class='text_overflow'>fc</td></tr></thead></table></span><span class='ln_list'><table style='width:100%;text-align: center;font-size: 1rem;color:#09162C;'></table></span></div>");
  4543. showLnList = $ied_strcut.find("#showLnList");
  4544. } else {
  4545. showLnList.removeClass("hidden").find(".ln_list table").html("");
  4546. }
  4547. var toEle = $(ele),
  4548. toXY = toEle.position();
  4549. showLnList.find(".caption").html(dataset_name + "—FCDA列表");
  4550. showLnList.css({
  4551. top: $ied_strcut.height() * 0.25,
  4552. left: ($ied_strcut.width() - showLnList.width()) / 2
  4553. });
  4554. var lndatalistEle = showLnList.find(".ln_list table");
  4555. $.getJSON(Global.AccessUrl + "/api/screen/scd/node/list", {
  4556. "scd_id": ied_strcut_detail.parents(".site_device_list").attr("scd_id") || PoliceObject.ScdID,
  4557. "parent_node_id": dataset_id,
  4558. "pagesize": 1000,
  4559. "name": "FCDA"
  4560. }, function(r) {
  4561. var trs = [];
  4562. layer.closeAll();
  4563. for (var i = 0; i < r.data.length; i++) {
  4564. var item = r.data[i];
  4565. trs.push("<tr node_id=" + item.node_id + "><td class='text_overflow' style='width:10%'>" + (item.attr_ld_inst || "&nbsp;") + "</td><td style='width:15%' class='text_overflow'>" + (item.attr_prefix || "&nbsp;") + "</td><td class='text_overflow' style='width:15%'>" + (item.attr_ln_class || "&nbsp;") + "</td><td class='text_overflow' style='width:10%'>" + (item.attr_ln_inst || "&nbsp;") + "</td><td class='text_overflow' style='width:30%'>" + (item.attr_do_name || "&nbsp;") + "</td><td class='text_overflow' style='width:10%'>" + (item.attr_da_name || "&nbsp;") + "</td><td class='text_overflow' style='width:10%'>" + (item.attr_fc || "&nbsp;") + "</td></tr>");
  4566. }
  4567. lndatalistEle.prepend(trs.join(""));
  4568. });
  4569. },
  4570. p_createCanvas: function(canvasconEle) {
  4571. var canvas = canvasconEle[0];
  4572. canvas.width = canvasconEle.width();
  4573. canvas.height = canvasconEle.height();
  4574. var canvascontext = canvas.getContext('2d');
  4575. return canvascontext
  4576. },
  4577. p_drawPoly(canvascontext, point1, point2) {
  4578. //canvascontext.setLineDash([]);
  4579. canvascontext.strokeStyle = "#08b008";
  4580. canvascontext.lineWidth = 1;
  4581. canvascontext.lineJoin = 'round';
  4582. canvascontext.lineCap = 'round';
  4583. canvascontext.beginPath();
  4584. canvascontext.moveTo(point1[0], point1[1]);
  4585. canvascontext.lineTo(point1[0] + 10, point1[1]);
  4586. canvascontext.stroke();
  4587. canvascontext.closePath();
  4588. canvascontext.beginPath();
  4589. canvascontext.moveTo(point1[0] + 9, point1[1]);
  4590. if (point2[1] < point1[1]) canvascontext.quadraticCurveTo(point1[0] + 50, point1[1] - 20, point2[0], point2[1]);
  4591. else canvascontext.quadraticCurveTo(point1[0] + 50, point1[1] + 20, point2[0], point2[1]);
  4592. canvascontext.stroke();
  4593. },
  4594. p_drawNumber: function(ele, masterIedJoinPoint, salveJoinPoint, num, direction) {
  4595. //额外加减的11px为数字高宽的一半
  4596. if (direction == "left") {
  4597. var numberLeft = masterIedJoinPoint[0] - (masterIedJoinPoint[0] - salveJoinPoint[0]) / 2 - 11;
  4598. var numberTop = masterIedJoinPoint[1] - (masterIedJoinPoint[1] - salveJoinPoint[1]) / 2 - 11;
  4599. return ele.append('<span class="abs inputs_num" style="left:' + numberLeft + 'px;top:' + numberTop + 'px">' + num + '</span>').find(".inputs_num:last");
  4600. } else {
  4601. //右边的
  4602. var numberLeft = masterIedJoinPoint[0] + (salveJoinPoint[0] - masterIedJoinPoint[0]) / 2 - 11;
  4603. var numberTop = masterIedJoinPoint[1] - (masterIedJoinPoint[1] - salveJoinPoint[1]) / 2 - 11;
  4604. return ele.append('<span class="abs inputs_num" style="left:' + numberLeft + 'px;top:' + numberTop + 'px">' + num + '</span>').find(".inputs_num:last");
  4605. }
  4606. },
  4607. p_drawLine: function(cxt, point1, point2, color) {
  4608. /*cxt.strokeStyle = "#fff";
  4609. cxt.lineWidth = 1;
  4610. cxt.lineJoin = 'round';
  4611. cxt.lineCap = 'round';
  4612. //cxt.fillStyle = paintConfig.fillStyle;
  4613. cxt.beginPath();
  4614. cxt.moveTo(point1[0], point1[1]);
  4615. cxt.lineTo(point2[0], point2[1]);
  4616. cxt.stroke();*/
  4617. //this.p_drawArrow(cxt, point1[0], point1[1], point2[0], point2[1], 30, 10, 1, color);
  4618. this.p_drawArrow2(cxt, point1[0], point1[1], point2[0], point2[1], 1, 1, 18, 5, color, 1.5)
  4619. },
  4620. //
  4621. //ctx:Canvas绘图环境
  4622. //fromX, fromY:起点坐标(也可以换成p1,只不过它是一个数组)
  4623. //toX, toY:终点坐标 (也可以换成p2,只不过它是一个数组)
  4624. //theta:三角斜边一直线夹角
  4625. //headlen:三角斜边长度
  4626. //width:箭头线宽度
  4627. //color:箭头颜色
  4628. p_drawArrow: function(ctx, fromX, fromY, toX, toY, theta, headlen, width, color) {
  4629. theta = typeof(theta) != 'undefined' ? theta : 30;
  4630. headlen = typeof(theta) != 'undefined' ? headlen : 10;
  4631. width = typeof(width) != 'undefined' ? width : 1;
  4632. color = typeof(color) != 'undefined' ? color : '#fff';
  4633. // 计算各角度和对应的P2,P3坐标
  4634. var angle = Math.atan2(fromY - toY, fromX - toX) * 180 / Math.PI,
  4635. angle1 = (angle + theta) * Math.PI / 180,
  4636. angle2 = (angle - theta) * Math.PI / 180,
  4637. topX = headlen * Math.cos(angle1),
  4638. topY = headlen * Math.sin(angle1),
  4639. botX = headlen * Math.cos(angle2),
  4640. botY = headlen * Math.sin(angle2);
  4641. ctx.save();
  4642. ctx.beginPath();
  4643. var arrowX = fromX - topX,
  4644. arrowY = fromY - topY;
  4645. ctx.moveTo(arrowX, arrowY);
  4646. ctx.moveTo(fromX, fromY);
  4647. ctx.lineTo(toX, toY);
  4648. arrowX = toX + topX;
  4649. arrowY = toY + topY;
  4650. ctx.moveTo(arrowX, arrowY);
  4651. ctx.lineTo(toX, toY);
  4652. arrowX = toX + botX;
  4653. arrowY = toY + botY;
  4654. ctx.lineTo(arrowX, arrowY);
  4655. ctx.strokeStyle = color;
  4656. ctx.lineWidth = width;
  4657. ctx.stroke();
  4658. ctx.restore();
  4659. },
  4660. // Draw arrow head
  4661. drawHead: function(ctx, x0, y0, x1, y1, x2, y2, style, color, width) {
  4662. if (typeof(x0) == 'string') {
  4663. x0 = parseInt(x0);
  4664. }
  4665. if (typeof(y0) == 'string') {
  4666. y0 = parseInt(y0);
  4667. }
  4668. if (typeof(x1) == 'string') {
  4669. x1 = parseInt(x1);
  4670. }
  4671. if (typeof(y1) == 'string') {
  4672. y1 = parseInt(y1);
  4673. }
  4674. if (typeof(x2) == 'string') {
  4675. x2 = parseInt(x2);
  4676. }
  4677. if (typeof(y2) == 'string') {
  4678. y2 = parseInt(y2);
  4679. }
  4680. var radius = 3,
  4681. twoPI = 2 * Math.PI;
  4682. ctx.save();
  4683. ctx.beginPath();
  4684. ctx.strokeStyle = color;
  4685. ctx.fillStyle = color;
  4686. ctx.lineWidth = width;
  4687. ctx.moveTo(x0, y0);
  4688. ctx.lineTo(x1, y1);
  4689. ctx.lineTo(x2, y2);
  4690. switch (style) {
  4691. case 0:
  4692. var backdist = Math.sqrt(((x2 - x0) * (x2 - x0)) + ((y2 - y0) * (y2 - y0)));
  4693. ctx.arcTo(x1, y1, x0, y0, .55 * backdist);
  4694. ctx.fill();
  4695. break;
  4696. case 1:
  4697. ctx.beginPath();
  4698. ctx.moveTo(x0, y0);
  4699. ctx.lineTo(x1, y1);
  4700. ctx.lineTo(x2, y2);
  4701. ctx.lineTo(x0, y0);
  4702. ctx.fill();
  4703. break;
  4704. case 2:
  4705. ctx.stroke();
  4706. break;
  4707. case 3:
  4708. var cpx = (x0 + x1 + x2) / 3;
  4709. var cpy = (y0 + y1 + y2) / 3;
  4710. ctx.quadraticCurveTo(cpx, cpy, x0, y0);
  4711. ctx.fill();
  4712. break;
  4713. case 4:
  4714. var cp1x, cp1y, cp2x, cp2y, backdist;
  4715. var shiftamt = 5;
  4716. if (x2 == x0) {
  4717. backdist = y2 - y0;
  4718. cp1x = (x1 + x0) / 2;
  4719. cp2x = (x1 + x0) / 2;
  4720. cp1y = y1 + backdist / shiftamt;
  4721. cp2y = y1 - backdist / shiftamt;
  4722. } else {
  4723. backdist = Math.sqrt(((x2 - x0) * (x2 - x0)) + ((y2 - y0) * (y2 - y0)));
  4724. var xback = (x0 + x2) / 2;
  4725. var yback = (y0 + y2) / 2;
  4726. var xmid = (xback + x1) / 2;
  4727. var ymid = (yback + y1) / 2;
  4728. var m = (y2 - y0) / (x2 - x0);
  4729. var dx = (backdist / (2 * Math.sqrt(m * m + 1))) / shiftamt;
  4730. var dy = m * dx;
  4731. cp1x = xmid - dx;
  4732. cp1y = ymid - dy;
  4733. cp2x = xmid + dx;
  4734. cp2y = ymid + dy;
  4735. }
  4736. ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x0, y0);
  4737. ctx.fill();
  4738. break;
  4739. }
  4740. ctx.restore();
  4741. },
  4742. // draw arrow
  4743. //p_drawArrow2(ctx, 100, 50, 200, 50, 1, 1, 18, 5, '#f36', 1);
  4744. //p_drawArrow2(ctx, 300, 50, 450, 50, 2, 1, 18, 4, 'blue', 0.5);
  4745. p_drawArrow2: function(ctx, x1, y1, x2, y2, style, which, angle, d, color, width) {
  4746. if (typeof(x1) == 'string') {
  4747. x1 = parseInt(x1);
  4748. }
  4749. if (typeof(y1) == 'string') {
  4750. y1 = parseInt(y1);
  4751. }
  4752. if (typeof(x2) == 'string') {
  4753. x2 = parseInt(x2);
  4754. }
  4755. if (typeof(y2) == 'string') {
  4756. y2 = parseInt(y2);
  4757. }
  4758. style = typeof(style) != 'undefined' ? style : 3;
  4759. which = typeof(which) != 'undefined' ? which : 1;
  4760. angle = typeof(angle) != 'undefined' ? angle : Math.PI / 9;
  4761. d = typeof(d) != 'undefined' ? d : 10;
  4762. color = typeof(color) != 'undefined' ? color : '#fff';
  4763. width = typeof(width) != 'undefined' ? width : 1;
  4764. var toDrawHead = typeof(style) != 'function' ? this.drawHead : style;
  4765. var dist = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  4766. var ratio = (dist - d / 3) / dist;
  4767. var tox, toy, fromx, fromy;
  4768. if (which & 1) {
  4769. tox = Math.round(x1 + (x2 - x1) * ratio);
  4770. toy = Math.round(y1 + (y2 - y1) * ratio);
  4771. } else {
  4772. tox = x2;
  4773. toy = y2;
  4774. }
  4775. if (which & 2) {
  4776. fromx = x1 + (x2 - x1) * (1 - ratio);
  4777. fromy = y1 + (y2 - y1) * (1 - ratio);
  4778. } else {
  4779. fromx = x1;
  4780. fromy = y1;
  4781. }
  4782. ctx.beginPath();
  4783. ctx.strokeStyle = color;
  4784. ctx.lineWidth = width;
  4785. ctx.moveTo(fromx, fromy);
  4786. ctx.lineTo(tox, toy);
  4787. ctx.stroke();
  4788. var lineangle = Math.atan2(y2 - y1, x2 - x1);
  4789. var h = Math.abs(d / Math.cos(angle));
  4790. if (which & 1) {
  4791. var angle1 = lineangle + Math.PI + angle;
  4792. var topx = x2 + Math.cos(angle1) * h;
  4793. var topy = y2 + Math.sin(angle1) * h;
  4794. var angle2 = lineangle + Math.PI - angle;
  4795. var botx = x2 + Math.cos(angle2) * h;
  4796. var boty = y2 + Math.sin(angle2) * h;
  4797. toDrawHead(ctx, topx, topy, x2, y2, botx, boty, style, color, width);
  4798. }
  4799. if (which & 2) {
  4800. var angle1 = lineangle + angle;
  4801. var topx = x1 + Math.cos(angle1) * h;
  4802. var topy = y1 + Math.sin(angle1) * h;
  4803. var angle2 = lineangle - angle;
  4804. var botx = x1 + Math.cos(angle2) * h;
  4805. var boty = y1 + Math.sin(angle2) * h;
  4806. toDrawHead(ctx, topx, topy, x1, y1, botx, boty, style, color, width);
  4807. }
  4808. },
  4809. AlwaysTimer: function() {
  4810. var time = new Date();
  4811. var year = time.getFullYear();
  4812. var month = time.getMonth() + 1;
  4813. var date = time.getDate();
  4814. var hour = time.getHours();
  4815. var minutes = time.getMinutes();
  4816. var seconds = time.getSeconds();
  4817. month = month < 10 ? "0" + month : month;
  4818. date = date < 10 ? "0" + date : date;
  4819. if (hour < 10) {
  4820. hour = "0" + hour;
  4821. }
  4822. if (minutes < 10) {
  4823. minutes = "0" + minutes;
  4824. }
  4825. if (seconds < 10) {
  4826. seconds = "0" + seconds;
  4827. }
  4828. $(".yyyymmdd").html(year + "-" + month + "-" + date);
  4829. $(".week").html(PoliceObject.GetWeek());
  4830. $(".hour_minute").html(hour + ":" + minutes + ":" + seconds);
  4831. setTimeout('PoliceObject.AlwaysTimer()', 1000);
  4832. },
  4833. GetWeek: function() {
  4834. var time = new Date();
  4835. var day = time.getDay();
  4836. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  4837. return weeks[day];
  4838. }
  4839. }