/// <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); } }
public BasicResponse <List <Jc_DefInfo> > GetPointDefineCacheByAreaID(PointDefineGetByAreaIDRequest PointDefineRequest) { return(_PointDefineService.GetPointDefineCacheByAreaID(PointDefineRequest)); }