Пример #1
0
        /// <summary>
        /// 批量新增分析模型配置
        /// </summary>
        /// <param name="jC_ExpressionconfigModelList"></param>
        /// <returns></returns>
        public BasicResponse <List <JC_ExpressionConfigInfo> > AddExpressionConfigList(ExpressionConfigListAddRequest jC_ExpressionConfigListAddRequest)
        {
            var _jC_ExpressionConfig        = ObjectConverter.CopyList <JC_ExpressionConfigInfo, JC_ExpressionconfigModel>(jC_ExpressionConfigListAddRequest.JC_ExpressionConfigInfoList);
            var resultjC_ExpressionConfig   = _Repository.AddExpressionconfigList(_jC_ExpressionConfig);
            var jC_ExpressionConfigresponse = new BasicResponse <List <JC_ExpressionConfigInfo> >();

            jC_ExpressionConfigresponse.Data = ObjectConverter.CopyList <JC_ExpressionconfigModel,
                                                                         JC_ExpressionConfigInfo>(resultjC_ExpressionConfig).ToList();
            return(jC_ExpressionConfigresponse);
        }
        /// <summary>
        /// 修改分析模板
        /// </summary>
        /// <param name="id">模板ID</param>
        ///  <param name="data"></param>
        /// <returns></returns>
        public string UpdateAnalysisTemplateConfig(string id, AnalysisTemplateBusinessModel data)
        {
            try
            {
                //1.检查模板是否被使用,如果模板使用,需要将模型停用才可以修改模型
                //调用接口
                Basic.Framework.Web.BasicResponse <List <JC_AnalysisTemplateConfigInfo> > analysisTemplateResult =
                    analysisTemplateConfigService.GetJC_AnalysistemplateconfigByTempleteId(
                        new AnalysisTemplateConfigGetByTempleteIdRequest()
                {
                    TempleteId = id
                });

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

                if (analysisTemplateResult.Data != null && analysisTemplateResult.Data.Count > 0)
                {
                    return("此模板已被使用,不能对模型进行修改操作。");
                }

                //2.更新模板信息
                //2.1 删除模板关系,重新建立模板关系
                string error = "";

                //1.模板

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

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


                //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 = analysisTemplateResult.Message;
                }
                else
                {
                    error = "100";
                }
                //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
                {
                    error = "100";
                }

                return(error);
            }
            catch (Exception ex)
            {
                return("更新失败");
            }
        }
        /// <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);
            }
        }
 public BasicResponse <List <JC_ExpressionConfigInfo> > AddExpressionConfigList(ExpressionConfigListAddRequest jC_ExpressionConfigListAddRequest)
 {
     return(_expressionConfigService.AddExpressionConfigList(jC_ExpressionConfigListAddRequest));
 }