Ejemplo n.º 1
0
 public BasicResponse <List <JC_LargedataAnalysisConfigInfo> > GetLargeDataAnalysisConfigListByTempleteId(LargedataAnalysisConfigGetRequest jc_LargedataAnalysisConfigRequest)
 {
     return(_largedataAnalysisConfigService.GetLargeDataAnalysisConfigListByTempleteId(jc_LargedataAnalysisConfigRequest));
 }
        /// <summary>
        /// 添加分析模板 dataType : add 新增  edit 修改
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string AddAnalysisTemplateConfig(AnalysisTemplateBusinessModel data, string dataType)
        {
            try
            {
                string error = "";
                if (dataType == "add")
                {
                    //1.模板
                    AnalysisTemplateAddRequest analysisTemplateRequest = new AnalysisTemplateAddRequest();
                    analysisTemplateRequest.JC_AnalysisTemplateInfo = data.AnalysisTemplateInfo;
                    //调用接口
                    Basic.Framework.Web.BasicResponse <JC_AnalysisTemplateInfo> analysisTemplateResult =
                        analysisTemplateService.AddJC_Analysistemplate(analysisTemplateRequest);

                    if (analysisTemplateResult.IsSuccess == false)
                    {
                        error = analysisTemplateResult.Message;
                        return(error);
                    }
                    else
                    {
                        if (analysisTemplateResult.Code == 100)
                        {
                            error = "100";
                        }
                        else
                        {
                            error = analysisTemplateResult.Message;
                        }
                    }
                    if (error != "100")
                    {
                        return(error);
                    }
                }
                else if (dataType == "edit")
                {
                    //1.检查模板是否被使用,如果模板使用,需要将模型停用才可以修改模型
                    //调用接口
                    Basic.Framework.Web.BasicResponse <List <JC_LargedataAnalysisConfigInfo> > largedataAnalysisConfigResult =
                        largedataAnalysisConfigService.GetLargeDataAnalysisConfigListByTempleteId(new LargedataAnalysisConfigGetRequest()
                    {
                        TempleteId = data.AnalysisTemplateInfo.Id
                    });

                    if (largedataAnalysisConfigResult.IsSuccess == false)
                    {
                        return(largedataAnalysisConfigResult.Message);
                    }

                    if (largedataAnalysisConfigResult.Data != null && largedataAnalysisConfigResult.Data.Count > 0)
                    {
                        return("此模板已被使用,不能修改。");
                    }
                    //更新分析模板
                    //analysisTemplateService.UpdateJC_Analysistemplate(new AnalysisTemplateUpdateRequest() { JC_AnalysisTemplateInfo = data.AnalysisTemplateInfo });
                    //1.删除表达式
                    //根据模板ID 查询表达式信息
                    var JC_ExpressionConfigInfoList = expressionconfigService.GetExpressionConfigListByTempleteId(
                        new ExpressionConfigGetListRequest()
                    {
                        TempleteId = data.AnalysisTemplateInfo.Id
                    }
                        ).Data;

                    //global_AnalyticalExpressionService_GetAnalyticalExpressionListByTempleteId
                    analyticalExpressionService.DeleteJC_AnalyticalexpressionByTempleteId(
                        new AnalyticalExpressionGetListRequest()
                    {
                        TempleteId = data.AnalysisTemplateInfo.Id
                    }
                        );
                    //2.删除分析模板配置表
                    analysisTemplateConfigService.DeleteJC_AnalysistemplateconfigByTempleteId(
                        new AnalysisTemplateConfigGetByTempleteIdRequest()
                    {
                        TempleteId = data.AnalysisTemplateInfo.Id
                    }
                        );
                    //3.删除表达式配置表
                    expressionconfigService.DeleteJC_ExpressionconfigByTempleteId(
                        new ExpressionConfigGetListRequest()
                    {
                        JC_ExpressionConfigInfoList = JC_ExpressionConfigInfoList
                    }
                        );
                }

                //2.表达式
                AnalyticalExpressionListAddRequest analyticalExpressionAddRequestRequest = new AnalyticalExpressionListAddRequest();
                analyticalExpressionAddRequestRequest.JC_AnalyticalExpressionInfoList = data.AnalysisExpressionInfoList;
                //调用接口
                Basic.Framework.Web.BasicResponse <List <JC_AnalyticalExpressionInfo> > analysisExpressionResult = analyticalExpressionService.AddAnalyticalExpressionList(analyticalExpressionAddRequestRequest);

                if (analysisExpressionResult.IsSuccess == false)
                {
                    error = analysisExpressionResult.Message;
                }
                else
                {
                    if (analysisExpressionResult.Code == 100)
                    {
                        error = "100";
                    }
                    else
                    {
                        error = analysisExpressionResult.Message;
                    }
                }

                //3.分析模板配置表
                AnalysisTemplateConfigListAddRequest analysisTemplateConfigListAddRequest = new AnalysisTemplateConfigListAddRequest();
                analysisTemplateConfigListAddRequest.JC_AnalysisTemplateConfigInfoList = data.JC_AnalysisTemplateConfigInfoList;
                //调用接口
                Basic.Framework.Web.BasicResponse <List <JC_AnalysisTemplateConfigInfo> > analysisTemplateConfigResult =
                    analysisTemplateConfigService.AddAnalysistemplateconfigList(analysisTemplateConfigListAddRequest);

                if (analysisTemplateConfigResult.IsSuccess == false)
                {
                    error = analysisTemplateConfigResult.Message;
                }
                else
                {
                    if (analysisTemplateConfigResult.Code == 100)
                    {
                        error = "100";
                    }
                    else
                    {
                        error = analysisTemplateConfigResult.Message;
                    }
                }
                //4.表达式配置表
                ExpressionConfigListAddRequest expressionConfigListAddRequest = new ExpressionConfigListAddRequest();
                expressionConfigListAddRequest.JC_ExpressionConfigInfoList = data.ExpressionConfigInfoList;
                //调用接口
                Basic.Framework.Web.BasicResponse <List <JC_ExpressionConfigInfo> > expressionConfigResult =
                    expressionconfigService.AddExpressionConfigList(expressionConfigListAddRequest);

                if (expressionConfigResult.IsSuccess == false)
                {
                    error = expressionConfigResult.Message;
                }
                else
                {
                    if (expressionConfigResult.Code == 100)
                    {
                        error = "100";
                    }
                    else
                    {
                        error = expressionConfigResult.Message;
                    }
                }

                return(error);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                return(ex.Message);
            }
        }