private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (string.IsNullOrEmpty(this.txtreason.Text.Trim())) { XtraMessageBox.Show("应急联动强制结束必须填写结束原因!"); return; } //强制结束应急联动1.更新呼叫控制 2.更新应急联动状态 3.更新应急联动运行记录 if (selectSysEmergencyLinkageInfo.EmergencyLinkageState != 0) { var masterid = selectSysEmergencyLinkageInfo.Type == 1 ? selectSysEmergencyLinkageInfo.Id : selectSysEmergencyLinkageInfo.MasterModelId; //解除广播控制 BCallInfoGetByMasterIDRequest b_defExistsRequest = new BCallInfoGetByMasterIDRequest(); b_defExistsRequest.MasterId = masterid; b_defExistsRequest.CallType = 1; var bcallinfo = bCallService.GetBCallInfoByMasterID(b_defExistsRequest).Data.FirstOrDefault(); if (bcallinfo != null) { bcallinfo.CallType = 2; bCallService.UpdateCall(new B_CallUpdateRequest { CallInfo = bcallinfo }); } //解除人员定位控制 RCallInfoGetByMasterIDRequest rcallgetRequest = new RCallInfoGetByMasterIDRequest(); rcallgetRequest.MasterId = masterid; rcallgetRequest.CallType = 1; rcallgetRequest.IsQueryByType = false; rcallgetRequest.Type = 0; var rcallinfo = rCallService.GetRCallInfoByMasterID(rcallgetRequest).Data; if (rcallinfo.Count > 0) { rcallinfo.ForEach(o => { o.CallType = 2; rCallService.UpdateCall(new R_CallUpdateRequest { CallInfo = o }); }); } //2.更新配置缓存 selectSysEmergencyLinkageInfo.EmergencyLinkageState = 0; selectSysEmergencyLinkageInfo.IsForceEnd = true; selectSysEmergencyLinkageInfo.EndTime = DateTime.Now; var delaytime = Convert.ToInt32(this.spinEdit1.Text); //延迟时间数据库存秒 selectSysEmergencyLinkageInfo.DelayTime = delaytime * 60; SysEmergencyLinkageUpdateRequest upddateRequest = new SysEmergencyLinkageUpdateRequest(); upddateRequest.SysEmergencyLinkageInfo = selectSysEmergencyLinkageInfo; sysEmergencyLinkageService.UpdateSysEmergencyLinkage(upddateRequest); //3.更新运行记录 var emergencyLinkHistory = emergencyLinkHistoryService.GetEmergencyLinkHistoryByEmergency(new EmergencyLinkHistoryGetByEmergencyRequest { EmergencyId = selectSysEmergencyLinkageInfo.Id }).Data; if (emergencyLinkHistory != null && !string.IsNullOrEmpty(emergencyLinkHistory.Id)) { emergencyLinkHistory.EndTime = DateTime.Now; emergencyLinkHistory.IsForceEnd = 1; emergencyLinkHistory.By1 = this.txtreason.Text; ClientItem _ClientItem = Basic.Framework.Data.PlatRuntime.Items[KeyConst.ClientItemKey] as ClientItem; if (_ClientItem != null) { emergencyLinkHistory.EndPerson = _ClientItem.UserID; } emergencyLinkHistoryService.UpdateEmergencyLinkHistory(new EmergencyLinkHistoryUpdateRequest { EmergencyLinkHistoryInfo = emergencyLinkHistory }); } } this.Close(); } catch (Exception ex) { LogHelper.Error("应急联动强制结束失败:" + ex.Message); } }
/// <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 Basic.Framework.Web.BasicResponse <List <Sys.Safety.DataContract.B_CallInfo> > GetBCallInfoByMasterID(Sys.Safety.Request.R_Call.BCallInfoGetByMasterIDRequest callRequest) { return(_bcallService.GetBCallInfoByMasterID(callRequest)); }
/// <summary>结束之前的历史记录和call /// /// </summary> /// <param name="item"></param> /// <param name="nowTime"></param> private static void EndLinkageHisAndCall(SysEmergencyLinkageInfo item, DateTime nowTime, bool ifUpdateRealTimeValue) { //结束之前的历史记录 var req12 = new EndByLinkageIdRequest { EndTime = nowTime, Id = item.Id }; EmergencyLinkHistoryService.EndByLinkageId(req12); //结束之前的rcall RCallInfoGetByMasterIDRequest req13 = new RCallInfoGetByMasterIDRequest(); req13.CallType = 1; if (item.MasterModelId != "0") { req13.MasterId = item.MasterModelId; } else { req13.MasterId = item.Id; } var res13 = RcallService.GetRCallInfoByMasterID(req13); var req14 = new EndRcallByRcallInfoListEequest { RcallInfo = res13.Data }; RcallService.EndRcallByRcallInfoList(req14); //结束之前的bcall BCallInfoGetByMasterIDRequest req15 = new BCallInfoGetByMasterIDRequest(); req15.CallType = 1; if (item.MasterModelId != "0") { req15.MasterId = item.MasterModelId; } else { req15.MasterId = item.Id; } var res15 = BcallService.GetBCallInfoByMasterID(req15); var req16 = new EndBcallByBcallInfoListRequest { Info = res15.Data }; BcallService.EndBcallByBcallInfoList(req16); if (ifUpdateRealTimeValue) { //更新实时状态 var req10 = new UpdateRealTimeStateRequest { LinkageId = item.Id, State = "0" }; SysEmergencyLinkageService.UpdateRealTimeState(req10); } }