コード例 #1
0
        /// <summary>
        /// 传感器分级报警输出
        /// </summary>
        /// <param name="analysisConfigInfo"></param>
        /// <param name="analysistemplatealarmlevelInfo"></param>
        private void AnalysistemplateAlarmLevelHandle(JC_LargedataAnalysisConfigInfo analysisConfigInfo, Jc_AnalysistemplatealarmlevelInfo analysistemplatealarmlevelInfo)
        {
            try
            {
                //如果分析配置成立,则添加手动控制
                if (analysisConfigInfo.AnalysisResult == 2)
                {
                    string level = analysistemplatealarmlevelInfo.Level.ToString();

                    if (analysisConfigInfo.AnalysisSuccessfulPointList.Count > 0)
                    {
                        List <Jc_JcsdkzInfo> jckzinfos       = new List <Jc_JcsdkzInfo>();
                        List <Jc_JcsdkzInfo> updatejckzinfos = new List <Jc_JcsdkzInfo>();

                        analysisConfigInfo.AnalysisSuccessfulPointList.ForEach(point =>
                        {
                            //判断是否存在同一配置被控测点的控制缓存,如果不存在则新增一条控制
                            ManualCrossControlGetByTypeZkPointBkPointRequest mcrequest = new ManualCrossControlGetByTypeZkPointBkPointRequest();
                            mcrequest.Type    = 12;
                            mcrequest.ZkPoint = analysisConfigInfo.Id;
                            mcrequest.BkPoint = point.Point;
                            var kzinfo        = manualCrossControlService.GetManualCrossControlByTypeZkPointBkPoint(mcrequest).Data.FirstOrDefault();

                            if (kzinfo == null)
                            {
                                Jc_JcsdkzInfo JkInfo = new Jc_JcsdkzInfo();
                                JkInfo.ID            = IdHelper.CreateLongId().ToString();
                                JkInfo.Type          = 12;
                                JkInfo.ZkPoint       = analysisConfigInfo.Id;
                                JkInfo.Bkpoint       = point.Point;
                                JkInfo.Upflag        = level;

                                jckzinfos.Add(JkInfo);
                            }
                            else if (kzinfo.Upflag != level)
                            {
                                kzinfo.Upflag = level;
                                updatejckzinfos.Add(kzinfo);
                            }
                        });

                        //删除已经结束的分级报警传感器  20180919
                        List <Jc_JcsdkzInfo> manualCrossControlList = manualCrossControlService.GetAllManualCrossControl().Data.FindAll(a => a.Upflag != "0");
                        foreach (Jc_JcsdkzInfo manualCrossControl in manualCrossControlList)
                        {
                            bool isInanalysisConfigInfo = false;
                            foreach (AnalysisSuccessfulPointInfo point in analysisConfigInfo.AnalysisSuccessfulPointList)
                            {
                                if (point.Point == manualCrossControl.Bkpoint)
                                {
                                    isInanalysisConfigInfo = true;
                                    break;
                                }
                            }
                            if (!isInanalysisConfigInfo)//如果在当前成立的表达式中没有找到对应交叉控制测点的表达式,则清除传感器分级报警
                            {
                                manualCrossControl.Upflag = "0";
                                updatejckzinfos.Add(manualCrossControl);
                            }
                        }

                        if (jckzinfos.Count > 0)
                        {
                            ManualCrossControlsRequest batchinsertrequest = new ManualCrossControlsRequest();
                            batchinsertrequest.ManualCrossControlInfos = jckzinfos;
                            manualCrossControlService.AddManualCrossControls(batchinsertrequest);
                        }

                        if (updatejckzinfos.Count > 0)
                        {
                            ManualCrossControlsRequest updaterequest = new ManualCrossControlsRequest();
                            updaterequest.ManualCrossControlInfos = updatejckzinfos;
                            manualCrossControlService.UpdateManualCrossControls(updaterequest);
                        }
                    }
                }
                //如果分析不成立,则修改报警等级为0
                else
                {
                    ManualCrossControlGetByTypeZkPointRequest mcrequest = new ManualCrossControlGetByTypeZkPointRequest();
                    mcrequest.Type    = 12;
                    mcrequest.ZkPoint = analysisConfigInfo.Id;
                    var kzinfo = manualCrossControlService.GetManualCrossControlByTypeZkPoint(mcrequest).Data;

                    if (kzinfo.Count > 0)
                    {
                        kzinfo.ForEach(kz => kz.Upflag = "0");

                        ManualCrossControlsRequest updaterequest = new ManualCrossControlsRequest();
                        updaterequest.ManualCrossControlInfos = kzinfo;
                        manualCrossControlService.UpdateManualCrossControls(updaterequest);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info("传感器分级报警输出出错!" + ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存分析模型传感器报警等级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                AnalysistemplatealarmlevelGetByAnalysistemplateIdRequest request = new AnalysistemplatealarmlevelGetByAnalysistemplateIdRequest();
                request.AnalysistemplateId = _analysistemplateId;
                var alarmlevel = _AnalysistemplatealarmlevelService.GetAnalysistemplatealarmlevelByAnalysistemplateId(request).Data;

                int level = 0;
                if (this.cbxlevel.SelectedIndex == 1)
                {
                    level = 4;
                }
                else if (this.cbxlevel.SelectedIndex == 2)
                {
                    level = 3;
                }
                else if (this.cbxlevel.SelectedIndex == 3)
                {
                    level = 2;
                }
                else if (this.cbxlevel.SelectedIndex == 4)
                {
                    level = 1;
                }
                else
                {
                    level = 0;
                }

                //如果不存在则新增报警等级配置
                if (alarmlevel == null)
                {
                    if (level != 0)
                    {
                        alarmlevel    = new Jc_AnalysistemplatealarmlevelInfo();
                        alarmlevel.Id = IdHelper.CreateLongId().ToString();
                        alarmlevel.AnalysisModelId = _analysistemplateId;
                        alarmlevel.Level           = level;

                        _AnalysistemplatealarmlevelService.AddAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelAddRequest
                        {
                            AnalysistemplatealarmlevelInfo = alarmlevel
                        });
                    }
                }
                else
                {
                    //如果level==0,则删除报警等级配置;反之修改报警等级配置
                    if (level == 0)
                    {
                        _AnalysistemplatealarmlevelService.DeleteAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelDeleteRequest
                        {
                            Id = alarmlevel.Id
                        });
                    }
                    else
                    {
                        alarmlevel.Level = level;
                        _AnalysistemplatealarmlevelService.UpdateAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelUpdateRequest
                        {
                            AnalysistemplatealarmlevelInfo = alarmlevel
                        });
                    }
                }

                this.StaticMsg.Caption = "保存成功!";
            }
            catch (Exception ex)
            {
                LogHelper.Info("保存传感器报警等级配置失败!" + ex.Message);
                this.StaticMsg.Caption = "保存失败!";
            }
        }