/// <summary> /// 报警上限值 /// </summary> /// <param name="pointId">测点号</param> /// <returns>报警上限值</returns> public BasicResponse <FactorValueInfo> AlarmUpperValue(FactorValueGetRequest factorValueGetRequest) { var pointDefineCacheResponse = pointDefineCacheService.PointDefineCacheByPointIdRequeest( new PointDefineCacheByPointIdRequeest() { PointID = factorValueGetRequest.PointId } ); var factorValueResponse = new BasicResponse <FactorValueInfo>(); FactorValueInfo factorValueInfo = new FactorValueInfo(); if (pointDefineCacheResponse.Code == 100) { if (pointDefineCacheResponse.Data != null) { factorValueInfo.Value = pointDefineCacheResponse.Data.Z2.ToString(); } } factorValueResponse.Data = factorValueInfo; factorValueResponse.Code = pointDefineCacheResponse.Code; factorValueResponse.Message = pointDefineCacheResponse.Message; return(factorValueResponse); }
/// <summary> /// 批量新增区域断点设置 /// </summary> /// <param name="jC_RegionOutageConfigListAddRequest"></param> /// <returns></returns> public BasicResponse <List <JC_RegionOutageConfigInfo> > AddJC_RegionOutageConfigList(RegionOutageConfigListAddRequest jC_RegionOutageConfigListAddRequest) { string analysisModelId = jC_RegionOutageConfigListAddRequest.AnalysisModelId; var _jC_RegionOutageConfig = ObjectConverter.CopyList <JC_RegionOutageConfigInfo, JC_RegionoutageconfigModel>(jC_RegionOutageConfigListAddRequest.JC_RegionOutageConfigInfoList); List <JC_RegionoutageconfigModel> updateList = _jC_RegionOutageConfig == null ? new List <JC_RegionoutageconfigModel>() : _jC_RegionOutageConfig.ToList(); List <JC_RegionoutageconfigModel> regionOutageByModelList = _Repository.GetRegionOutageConfigListByAnalysisModelId(analysisModelId); List <JC_RegionoutageconfigModel> removeList = new List <JC_RegionoutageconfigModel>(); List <Jc_JcsdkzInfo> removeSDKZControlList = new List <Jc_JcsdkzInfo>(); if (regionOutageByModelList != null && regionOutageByModelList.Count > 0) { var oriControlList = regionOutageByModelList.Where(q => q.ControlStatus == 1).ToList(); //var oriRemoveControlList = regionOutageByModelList.Where(q => q.ControlStatus == 0).ToList(); foreach (var item in oriControlList) { if (!updateList.Where(q => q.ControlStatus == 1).ToList().Exists(q => q.PointId == item.PointId)) { removeList.Add(item); } } /* * foreach (var item in oriRemoveControlList) * { * if (!updateList.Where(q => q.ControlStatus == 0).ToList().Exists(q => q.PointId == item.PointId)) * { * var switchModelId = ObjectConverter.Copy<JC_RegionoutageconfigModel, JC_RegionoutageconfigModel>(item); * switchModelId.AnalysisModelId = switchModelId.RemoveModelId; * removeList.Add(switchModelId); * } * } */ } if (removeList.Count > 0) { IEnumerable <IGrouping <string, JC_RegionoutageconfigModel> > removeSDKZModelGroup = removeList.GroupBy(p => p.AnalysisModelId); foreach (var removeSDKZModelList in removeSDKZModelGroup) { string queryAnalysisModelId = removeSDKZModelList.FirstOrDefault().AnalysisModelId; BasicResponse <List <Jc_JcsdkzInfo> > analysisZKResponse = manualCrossControlService.GetManualCrossControlByTypeZkPoint(new ManualCrossControlGetByTypeZkPointRequest() { ZkPoint = queryAnalysisModelId, Type = (short)Enums.ControlType.LargeDataAnalyticsAreaPowerOff }); if (analysisZKResponse != null && analysisZKResponse.Data != null && analysisZKResponse.Data.Count > 0) { foreach (var removeSDKZModel in removeSDKZModelList) { BasicResponse <Jc_DefInfo> cachedPoint = pointDefineCacheService.PointDefineCacheByPointIdRequeest(new Sys.Safety.Request.Cache.PointDefineCacheByPointIdRequeest() { PointID = removeSDKZModel.PointId }); if (null != cachedPoint && cachedPoint.Data != null) { Jc_JcsdkzInfo removeSDKZInfo = analysisZKResponse.Data.FirstOrDefault(q => q.Bkpoint == cachedPoint.Data.Point); if (null != removeSDKZInfo) { removeSDKZControlList.Add(removeSDKZInfo); } } } } } } TransactionsManager.BeginTransaction(() => { if (removeSDKZControlList.Count > 0) { manualCrossControlService.DeleteManualCrossControls(new ManualCrossControlsRequest() { ManualCrossControlInfos = removeSDKZControlList }); } _Repository.DeleteUserRoleByAnalysisModelId(analysisModelId); _Repository.AddJC_RegionOutageConfigList(_jC_RegionOutageConfig.ToList()); }); if (Basic.Framework.Data.PlatRuntime.Items.ContainsKey(DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey)) { Basic.Framework.Data.PlatRuntime.Items[DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey] = DateTime.Now; } else { Basic.Framework.Data.PlatRuntime.Items.Add(DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey, DateTime.Now); } var jC_RegionOutageConfig = new BasicResponse <List <JC_RegionOutageConfigInfo> >(); jC_RegionOutageConfig.Data = jC_RegionOutageConfigListAddRequest.JC_RegionOutageConfigInfoList; return(jC_RegionOutageConfig); }
/// <summary> /// 根据测点编号获取测点定义缓存 /// </summary> /// <param name="request"></param> /// <returns></returns> public BasicResponse <Jc_DefInfo> PointDefineCacheByPointIdRequeest(PointDefineCacheByPointIdRequeest request) { var response = pointDefineCacheService.PointDefineCacheByPointIdRequeest(request); return(response); }
/// <summary> /// 添加分析模型,及其关联的测点。 /// </summary> /// <param name="jc_LargedataAnalysisConfigRsequest">分析模型的添加请求</param> /// <returns>Mas应答对象包含分析模型</returns> public BasicResponse <JC_LargedataAnalysisConfigInfo> AddLargeDataAnalysisConfig(LargedataAnalysisConfigAddRequest jc_LargedataAnalysisConfigRsequest) { BasicResponse validationResponse = largeDataAnalysisConfigValidation(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo); if (!validationResponse.IsSuccess) { return new BasicResponse <JC_LargedataAnalysisConfigInfo>() { Code = validationResponse.Code, Message = validationResponse.Message, Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo } } ; var jC_Largedataanalysisconfigresponse = new BasicResponse <JC_LargedataAnalysisConfigInfo>(); var _jC_Largedataanalysisconfig = ObjectConverter.Copy <JC_LargedataAnalysisConfigInfo, JC_LargedataanalysisconfigModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo); var _jcSetAnalysisModelPointRecordList = ObjectConverter.CopyList <JC_SetAnalysisModelPointRecordInfo, JC_SetanalysismodelpointrecordModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList); bool isSingleExpressionAndParameter1 = isSingleExpressionAndParameter(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.TempleteId); bool isBindDevType = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList[0].DevTypeId > -1; if (isSingleExpressionAndParameter1 && !isBindDevType /*&& jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList.Count > 1*/) { List <JC_SetAnalysisModelPointRecordInfo> listOfPoint = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList; string[] pointIds = listOfPoint[0].PointId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (pointIds.Length > 1) { foreach (var pointId in pointIds) { List <JC_SetAnalysisModelPointRecordInfo> toAddPointList = new List <JC_SetAnalysisModelPointRecordInfo>(); foreach (var oriPoint in listOfPoint) { JC_SetAnalysisModelPointRecordInfo addPoint = ObjectConverter.DeepCopy(oriPoint); addPoint.PointId = pointId; BasicResponse <Jc_DefInfo> pointDefine = pointDefineCacheService.PointDefineCacheByPointIdRequeest(new Sys.Safety.Request.Cache.PointDefineCacheByPointIdRequeest() { PointID = pointId }); if (pointDefine.IsSuccess && pointDefine.Data != null) { addPoint.Point = pointDefine.Data.Point; } toAddPointList.Add(addPoint); } //JC_LargedataAnalysisConfigInfo largedataAnalysisConfigInfo = ObjectConverter.Copy<JC_LargedataAnalysisConfigInfo, JC_LargedataAnalysisConfigInfo>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo); JC_LargedataAnalysisConfigInfo largedataAnalysisConfigInfo = ObjectConverter.DeepCopy <JC_LargedataAnalysisConfigInfo>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo); largedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList = toAddPointList; jC_Largedataanalysisconfigresponse = AddLargeDataAnalysisConfig(new LargedataAnalysisConfigAddRequest() { JC_LargedataAnalysisConfigInfo = largedataAnalysisConfigInfo }); } return(jC_Largedataanalysisconfigresponse); } } //给模型赋默认值 Start _jC_Largedataanalysisconfig.Id = IdHelper.CreateLongId().ToString(); StringBuilder points = new StringBuilder(); foreach (var jcSetAnalysisModelPointRecord in _jcSetAnalysisModelPointRecordList) { jcSetAnalysisModelPointRecord.Id = IdHelper.CreateLongId().ToString(); jcSetAnalysisModelPointRecord.AnalysisModelId = _jC_Largedataanalysisconfig.Id; JC_SetAnalysisModelPointRecordInfo analysisModelPointRecordInfo = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList.FirstOrDefault(q => q.PointId == jcSetAnalysisModelPointRecord.PointId); if (string.IsNullOrEmpty(points.ToString())) { points.Append(analysisModelPointRecordInfo.Point); } //points.Append(analysisModelPointRecordInfo.Point).Append(","); } if (string.IsNullOrEmpty(_jC_Largedataanalysisconfig.Name)) { _jC_Largedataanalysisconfig.Name = _AnalysisTemplateRepository.GetJC_AnalysistemplateById(_jC_Largedataanalysisconfig.TempleteId).Name; } if (isSingleExpressionAndParameter1 && !isBindDevType) { _jC_Largedataanalysisconfig.Name = string.Format("{0}({1})", _jC_Largedataanalysisconfig.Name, points.ToString().Trim(',')); } //给模型赋默认值 End JC_LargedataanalysisconfigModel existsModel = _Repository.GetLargeDataAnalysisConfigByName(_jC_Largedataanalysisconfig.Name); if (null != existsModel) { return new BasicResponse <JC_LargedataAnalysisConfigInfo>() { Code = -100, Message = "分析模型名称已存在", Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo } } ; JC_LargedataanalysisconfigModel resultjC_Largedataanalysisconfig = null; TransactionsManager.BeginTransaction(() => { //保存分析模型 resultjC_Largedataanalysisconfig = _Repository.AddJC_Largedataanalysisconfig(_jC_Largedataanalysisconfig); //保持分析模型中表达式参数与测点的关联关系. _AnalysisModelPointRecordRepository.Insert(_jcSetAnalysisModelPointRecordList); }); if (resultjC_Largedataanalysisconfig != null) { jC_Largedataanalysisconfigresponse.Data = ObjectConverter.Copy <JC_LargedataanalysisconfigModel, JC_LargedataAnalysisConfigInfo>(resultjC_Largedataanalysisconfig); BasicResponse <IList <JC_SetAnalysisModelPointRecordInfo> > pointListResponse = _AnalysisModelPointRecordService.GetCustomizationAnalysisModelPointRecordInfoByModelId(new SetAnalysisModelPointRecordByModelIdGetRequest() { AnalysisModelId = resultjC_Largedataanalysisconfig.Id }); if (pointListResponse != null && pointListResponse.Data != null) { jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList = pointListResponse.Data.ToList(); } try { //添加到缓存 _LargeDataAnalysisConfigCacheService.AddLargeDataAnalysisConfigCache(new LargeDataAnalysisConfigCacheAddRequest() { LargeDataAnalysisConfigInfo = jC_Largedataanalysisconfigresponse.Data }); } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(string.Format("添加分析模型后再添加到缓存出错:{0}", ex.StackTrace)); } if (Basic.Framework.Data.PlatRuntime.Items.ContainsKey(DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey)) { Basic.Framework.Data.PlatRuntime.Items[DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey] = DateTime.Now; } else { Basic.Framework.Data.PlatRuntime.Items.Add(DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey, DateTime.Now); } } return(jC_Largedataanalysisconfigresponse); }