public BasicResponse <Jc_DefInfo> GetPointDefineCacheByPointID(PointDefineGetByPointIDRequest PointDefineRequest) { return(_PointDefineService.GetPointDefineCacheByPointID(PointDefineRequest)); }
/// <summary> /// 多系统融合应急联动输出 /// </summary> /// <param name="responsesysEmergencyLinkInfos"></param> private void SysEmergencyLinkHandle(JC_LargedataAnalysisConfigInfo analysisConfigInfo, SysEmergencyLinkageInfo responsesysEmergencyLinkInfo) { try { //如果模型成立则1.添加控制 2.更新配置缓存 3.写运行记录 if (analysisConfigInfo.AnalysisResult == 2) { //如果不是强制结束则立即执行,如果是强制结束则在大于延迟时间时执行 var isforceend = responsesysEmergencyLinkInfo.IsForceEnd; TimeSpan span = DateTime.Now - responsesysEmergencyLinkInfo.EndTime; if (!isforceend || (isforceend && span.TotalSeconds > responsesysEmergencyLinkInfo.DelayTime)) { #region 1.更新控制缓存 string bpointlist = string.Empty; string rpointlist = string.Empty; string rpersonlist = string.Empty; //如果应急联动配置存在被控区域,则获取此区域的人员设备和广播设备 if (responsesysEmergencyLinkInfo.PassiveAreas != null && responsesysEmergencyLinkInfo.PassiveAreas.Count > 0) { responsesysEmergencyLinkInfo.PassiveAreas.ForEach(area => { //处理区域广播呼叫 var bdefinfos = b_defCacheService.GetPointDefineCacheByAreaID(new PointDefineGetByAreaIDRequest { AreaId = area.AreaId }).Data; bdefinfos.ForEach(b => { bpointlist += b.PointID + ","; }); //处理区域人员呼叫 var rdefinfos = rdefCacheService.GetPointDefineCacheByAreaID(new PointDefineGetByAreaIDRequest { AreaId = area.AreaId }).Data; rdefinfos.ForEach(r => { rpointlist += r.Point + ","; }); }); } //如果应急联动配置存在被控人员,则获取被控人员列表 if (responsesysEmergencyLinkInfo.PassivePersons != null && responsesysEmergencyLinkInfo.PassivePersons.Count > 0) { responsesysEmergencyLinkInfo.PassivePersons.ForEach(p => { RPersoninfCacheGetByKeyRequest persongetrequest = new RPersoninfCacheGetByKeyRequest(); var person = personService.GetPersoninfCache(new R_PersoninfGetRequest() { Id = p.PersonId }).Data; if (person != null) { rpersonlist += person.Bh + ","; } }); } //如果应急联动配置存在被控设备,则根据类型获取被控测点 if (responsesysEmergencyLinkInfo.PassivePoints != null && responsesysEmergencyLinkInfo.PassivePoints.Count > 0) { responsesysEmergencyLinkInfo.PassivePoints.ForEach(p => { //人员定位 if (p.Sysid == (int)SystemEnum.Personnel) { var rdef = rdefCacheService.GetPointDefineCacheByPointID(new PointDefineGetByPointIDRequest { PointID = p.PointId }).Data; if (rdef != null && !string.IsNullOrEmpty(rdef.PointID)) { rpointlist += rdef.Point + "|"; } } //广播 else if (p.Sysid == (int)SystemEnum.Broadcast) { var bdef = b_defCacheService.GetPointDefineCacheByPointID(new PointDefineGetByPointIDRequest { PointID = p.PointId }).Data; if (bdef != null && !string.IsNullOrEmpty(bdef.PointID)) { bpointlist += bdef.PointID + "|"; } } }); } //添加广播呼叫 if (bpointlist.Length > 0) { BCallInfoGetByMasterIDRequest b_defExistsRequest = new BCallInfoGetByMasterIDRequest(); b_defExistsRequest.MasterId = analysisConfigInfo.Id; b_defExistsRequest.CallType = 1; var bcallinfo = bCallService.GetBCallInfoByMasterID(b_defExistsRequest).Data.FirstOrDefault(); if (bcallinfo == null) { bpointlist = bpointlist.Substring(0, bpointlist.Length - 1); var bpointarr = bpointlist.Split('|'); B_CallInfo bcalladdinfo = new B_CallInfo(); string callid = IdHelper.CreateLongId().ToString(); bcalladdinfo.Id = callid; bcalladdinfo.CallType = 1; bcalladdinfo.CallTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); bcalladdinfo.MasterId = analysisConfigInfo.Id; bcalladdinfo.Message = analysisConfigInfo.TrueDescription; //bcalladdinfo.PointList = bpointlist; List <B_CallpointlistInfo> callpointdetails = new List <B_CallpointlistInfo>(); Array.ForEach(bpointarr, point => { B_CallpointlistInfo callpointdetail = new B_CallpointlistInfo(); callpointdetail.Id = IdHelper.CreateLongId().ToString(); callpointdetail.BCallId = callid; callpointdetail.CalledPointId = point; callpointdetails.Add(callpointdetail); }); bcalladdinfo.CallPointList = callpointdetails; bCallService.AddCall(new B_CallAddRequest { CallInfo = bcalladdinfo }); } } //添加人员定位设备呼叫 if (rpointlist.Length > 0) { RCallInfoGetByMasterIDRequest rcallgetRequest = new RCallInfoGetByMasterIDRequest(); rcallgetRequest.MasterId = analysisConfigInfo.Id; rcallgetRequest.CallType = 1; rcallgetRequest.IsQueryByType = true; rcallgetRequest.Type = 1; var rcallinfo = rCallService.GetRCallInfoByMasterID(rcallgetRequest).Data.FirstOrDefault(); if (rcallinfo == null) { rpointlist = rpointlist.Substring(0, rpointlist.Length - 1); R_CallInfo rcalladdinfo = new R_CallInfo(); rcalladdinfo.Id = IdHelper.CreateLongId().ToString(); rcalladdinfo.Type = 1; rcalladdinfo.CallType = 1; rcalladdinfo.CallTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); rcalladdinfo.MasterId = analysisConfigInfo.Id; rcalladdinfo.CallPersonDefType = 4; rcalladdinfo.PointList = rpointlist; rCallService.AddCall(new R_CallAddRequest { CallInfo = rcalladdinfo }); } } //添加人员卡号呼叫 if (rpersonlist.Length > 0) { RCallInfoGetByMasterIDRequest rcallgetRequest = new RCallInfoGetByMasterIDRequest(); rcallgetRequest.MasterId = analysisConfigInfo.Id; rcallgetRequest.CallType = 1; rcallgetRequest.IsQueryByType = true; rcallgetRequest.Type = 0; var rcallinfo = rCallService.GetRCallInfoByMasterID(rcallgetRequest).Data.FirstOrDefault(); if (rcallinfo == null) { rpersonlist = rpersonlist.Substring(0, rpersonlist.Length - 1); R_CallInfo rcalladdinfo = new R_CallInfo(); rcalladdinfo.Id = IdHelper.CreateLongId().ToString(); rcalladdinfo.Type = 0; rcalladdinfo.CallType = 1; rcalladdinfo.CallTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); rcalladdinfo.MasterId = analysisConfigInfo.Id; rcalladdinfo.CallPersonDefType = 2; rcalladdinfo.BhContent = rpersonlist; rCallService.AddCall(new R_CallAddRequest { CallInfo = rcalladdinfo }); } } #endregion } if (responsesysEmergencyLinkInfo.EmergencyLinkageState != 1) { //2.更新配置缓存 responsesysEmergencyLinkInfo.EmergencyLinkageState = 1; sysEmergencyLinkageService.UpdateSysEmergencyLinkage(new SysEmergencyLinkageUpdateRequest { SysEmergencyLinkageInfo = responsesysEmergencyLinkInfo }); //3.写运行记录 EmergencyLinkHistoryAddRequest ehistoryaddrequest = new EmergencyLinkHistoryAddRequest(); EmergencyLinkHistoryInfo ehistory = new EmergencyLinkHistoryInfo(); ehistory.Id = IdHelper.CreateLongId().ToString(); ehistory.IsForceEnd = 0; ehistory.SysEmergencyLinkageId = responsesysEmergencyLinkInfo.Id; ehistory.StartTime = DateTime.Now; ehistory.EndTime = new DateTime(1900, 1, 1, 0, 0, 0); ehistoryaddrequest.EmergencyLinkHistoryInfo = ehistory; emergencyLinkHistoryService.AddEmergencyLinkHistory(ehistoryaddrequest); } } //如果模型不成立则1.解除控制 2.更新配置缓存 3.更新运行记录 else { //解除广播控制 BCallInfoGetByMasterIDRequest b_defExistsRequest = new BCallInfoGetByMasterIDRequest(); b_defExistsRequest.MasterId = analysisConfigInfo.Id; b_defExistsRequest.CallType = 1; var bcallinfo = bCallService.GetBCallInfoByMasterID(b_defExistsRequest).Data.FirstOrDefault(); if (bcallinfo != null && bcallinfo.CallType != 2) { bcallinfo.CallType = 2; bCallService.UpdateCall(new B_CallUpdateRequest { CallInfo = bcallinfo }); } //解除人员定位控制 RCallInfoGetByMasterIDRequest rcallgetRequest = new RCallInfoGetByMasterIDRequest(); rcallgetRequest.MasterId = analysisConfigInfo.Id; rcallgetRequest.CallType = 1; rcallgetRequest.IsQueryByType = false; rcallgetRequest.Type = 0; var rcallinfo = rCallService.GetRCallInfoByMasterID(rcallgetRequest).Data; if (rcallinfo.Count > 0) { rcallinfo.ForEach(o => { if (o.CallType != 2) { o.CallType = 2; rCallService.UpdateCall(new R_CallUpdateRequest { CallInfo = o }); } }); } if (responsesysEmergencyLinkInfo.EmergencyLinkageState != 0) { //2.更新配置缓存 responsesysEmergencyLinkInfo.EmergencyLinkageState = 0; sysEmergencyLinkageService.UpdateSysEmergencyLinkage(new SysEmergencyLinkageUpdateRequest { SysEmergencyLinkageInfo = responsesysEmergencyLinkInfo }); } //3.更新运行记录 var emergencyLinkHistory = emergencyLinkHistoryService.GetEmergencyLinkHistoryByEmergency(new EmergencyLinkHistoryGetByEmergencyRequest { EmergencyId = responsesysEmergencyLinkInfo.Id }).Data; if (emergencyLinkHistory != null && !string.IsNullOrEmpty(emergencyLinkHistory.Id) && emergencyLinkHistory.EndTime.Year == 1900) { emergencyLinkHistory.EndTime = DateTime.Now; emergencyLinkHistoryService.UpdateEmergencyLinkHistory(new EmergencyLinkHistoryUpdateRequest { EmergencyLinkHistoryInfo = emergencyLinkHistory }); } } } catch (Exception ex) { LogHelper.Info(" 多系统融合应急联动输出出错!" + ex.Message); } }
/// <summary> /// 获取应急联动实时主控和被控测点 /// </summary> private string RefreshRealPoint() { try { string jsonStr = string.Empty; if (!string.IsNullOrEmpty(selectid)) { var selectSysEmergencyLinkageInfo = SysEmergencyLinkageInfos.FirstOrDefault(o => o.Id == selectid); //获取选中应急联动配置的主控测点 SysEmergencyLinkageGetRequest getrequest = new SysEmergencyLinkageGetRequest(); getrequest.Id = selectid; var masterpoints = sysEmergencyLinkageService.GetAllMasterPointsById(getrequest).Data; //如果不存在主控测点,则获取关联大数据分析模型配置 if (masterpoints.Count > 0) { masterpoints.ForEach(o => { jsonStr += o.Point + "|"; }); } else if (!string.IsNullOrEmpty(selectSysEmergencyLinkageInfo.MasterModelId)) { var analysisConfigs = largedataAnalysisConfigCacheService.GetAllLargeDataAnalysisConfigCache(new Sys.Safety.Request.LargeDataAnalysisCacheClientGetAllRequest()).Data; if (analysisConfigs != null && analysisConfigs.Count > 0) { var analysisConfig = analysisConfigs.FirstOrDefault(o => o.Id == selectSysEmergencyLinkageInfo.MasterModelId); if (analysisConfig != null) { jsonStr += analysisConfig.Name + "|"; } } } //获取选中应急联动配置的被控测点 //如果应急联动配置存在被控区域,则获取此区域的人员设备和广播设备 if (selectSysEmergencyLinkageInfo.PassiveAreas.Count > 0) { selectSysEmergencyLinkageInfo.PassiveAreas.ForEach(area => { //处理区域广播呼叫 var bdefinforesponse = bdefService.GetAllPointDefineCache(); if (bdefinforesponse.IsSuccess) { var areabdefinfos = bdefinforesponse.Data.Where(b => b.Areaid == area.AreaId).ToList(); areabdefinfos.ForEach(def => jsonStr += def.Point + "|"); } //处理区域人员呼叫 var rdefinforesponse = rdefService.GetAllPointDefineCache(); if (rdefinforesponse.IsSuccess) { var areardefinfos = rdefinforesponse.Data.Where(b => b.Areaid == area.AreaId).ToList(); areardefinfos.ForEach(def => jsonStr += def.Point + "|"); } }); } //如果应急联动配置存在被控人员,则获取被控人员实时识别器列表 if (selectSysEmergencyLinkageInfo.PassivePersons.Count > 0) { var prealinfos = prealService.GetAllPrealCacheList(new RPrealCacheGetAllRequest()).Data; if (prealinfos != null) { selectSysEmergencyLinkageInfo.PassivePersons.ForEach(p => { var personreponse = personinfoService.GetAllDefinedPersonInfoCache(new BasicRequest()); if (personreponse.IsSuccess) { var person = personinfoService.GetPersoninfCache(new R_PersoninfGetRequest() { Id = p.PersonId }).Data; var preal = prealinfos.FirstOrDefault(pr => pr.Bh == person.Bh); if (preal != null) { var persondef = rdefService.GetPointDefineCacheByPointID(new PointDefineGetByPointIDRequest { PointID = preal.Pointid }).Data; if (persondef != null && !jsonStr.Contains(persondef.Point)) { jsonStr += persondef.Point + "|"; } } } }); } } //如果应急联动配置存在被控设备,则根据类型获取被控测点 if (selectSysEmergencyLinkageInfo.PassivePoints.Count > 0) { selectSysEmergencyLinkageInfo.PassivePoints.ForEach(p => { //人员定位 if (p.Sysid == (int)SystemEnum.Personnel) { var rdef = rdefService.GetPointDefineCacheByPointID(new PointDefineGetByPointIDRequest { PointID = p.PointId }).Data; if (rdef != null && !jsonStr.Contains(rdef.Point)) { jsonStr += rdef.Point + "|"; } } //广播 else if (p.Sysid == (int)SystemEnum.Broadcast) { var bdef = bdefService.GetPointDefineCacheByPointID(new PointDefineGetByPointIDRequest { PointID = p.PointId }).Data; var bdefpoints = jsonStr.Split('|'); if (bdef != null && !bdefpoints.Contains(bdef.Point)) { jsonStr += bdef.Point + "|"; } } //视频 else if (p.Sysid == (int)SystemEnum.Video) { var vdef = vdefService.GetDefById(new Sys.Safety.Request.Def.DefGetRequest { Id = p.PointId }).Data; if (vdef != null && !jsonStr.Contains(vdef.IPAddress)) { jsonStr += vdef.IPAddress + "|"; } } }); } if (jsonStr.LastIndexOf('|') > 0) { jsonStr = jsonStr.Substring(0, jsonStr.Length - 1); } } return(jsonStr); } catch (Exception ex) { LogHelper.Info("获取应急联动配置主控被控测点出错:" + ex.Message); return(string.Empty); } }