public BasicResponse <IList <JC_SetAnalysisModelPointRecordInfo> > GetCustomizationAnalysisModelPointRecordInfoByModelId(SetAnalysisModelPointRecordByModelIdGetRequest jc_SetAnalysisModelPointRecordByModelIdGetRequest) { return(setAnalysisModelPointRecordService.GetCustomizationAnalysisModelPointRecordInfoByModelId(jc_SetAnalysisModelPointRecordByModelIdGetRequest)); }
/// <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); }