예제 #1
0
        /// <summary>
        /// 绑定查询sql的服务
        /// </summary>
        /// <param name="ServiceName"></param>
        /// <param name="ServiceModule"></param>
        /// <param name="jobj"></param>
        /// <returns></returns>
        public IActionResult BindServiceForSql(AbpvNextHISInterfaceDbContext db, string ServiceName, string ServiceModule, JObject jobj)
        {
            COM_ZHYY_CONFIG myconfig = this.GetServiceConfigAsync(ServiceName, ServiceModule).Result;

            if (myconfig == null)
            {
                return(new ObjectResult(new { msg = "请求失败", data = $"服务名为{ServiceModule}/{ServiceName}未配置不可使用!", code = "500" }));
            }
            if (myconfig.VALID_FALG == "0")
            {
                return(new ObjectResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}该服务的已被作废!", code = "500" }));
            }
            string[]      inparameters   = myconfig.INPARAMETERNAMES == null ? new string[0] : myconfig.INPARAMETERNAMES.Split('|');
            string[]      intypes        = myconfig.INPARAMETERTYPES == null ? new string[0] : myconfig.INPARAMETERTYPES.Split('|');
            string[]      procedureprops = myconfig.INPROCEDUREPROP == null ? new string[0] : myconfig.INPROCEDUREPROP.Split('|');
            string[]      outparameters  = myconfig.OUTPARAMETERNAMES == null ? new string[0] : myconfig.OUTPARAMETERNAMES.Split('|');
            string[]      outtypes       = myconfig.OUTPARAMETERTYPES == null ? new string[0] : myconfig.OUTPARAMETERTYPES.Split('|');
            List <object> objlist        = new List <object>();

            for (int i = 0; i < inparameters.Length; i++)
            {
                if (myconfig.SERVICENAME == "QueryZBInfoByDate" && inparameters[i] == "date")
                {
                    objlist.Add(Convert.ToDateTime(jobj.GetValue(inparameters[i]).ToString()).ToString("yyyy-MM-01"));
                }
                else
                {
                    objlist.Add(jobj.GetValue(inparameters[i]).ToString());
                }
            }
            ObjectResult res = new ObjectResult("");
            string       Sql = string.Format(myconfig.PROCEDURENAME, objlist.ToArray());

            db = db == null ? dbContext : db;
            var       dt  = this.QuerySql(db, Sql);
            ArrayList arr = this.getJObject(dt);

            if (Convert.ToInt32(myconfig.ISFY) == (int)SonShowType.微生物查询)
            {
                res = GetWswList(arr);
            }
            else
            {
                res = new ObjectResult(new { msg = $"查询成功!", data = arr, code = 200 });
            }
            if (arr == null)
            {
                res = new ObjectResult(new { msg = $"{ServiceModule}/{ServiceName}没有找到如何数据的信息!", data = "查询结果为空", code = 404 });
            }
            if (arr.Count == 0)
            {
                res = new ObjectResult(new { msg = $"{ServiceModule}/{ServiceName}没有找到如何数据的信息!", data = "查询结果为空", code = 404 });
            }
            return(res);
        }
예제 #2
0
        /// <summary>
        /// 绑定数据库中配置的服务
        /// </summary>
        /// <param name="ServiceName"></param>
        /// <param name="ServiceModule"></param>
        public IActionResult BindService(AbpvNextHISInterfaceDbContext db, string ServiceName, string ServiceModule, JObject jobj)
        {
            COM_ZHYY_CONFIG myconfig = this.GetServiceConfigAsync(ServiceName, ServiceModule).Result;

            if (myconfig == null)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"服务名为{ServiceModule}/{ServiceName}未配置不可使用!", code = "500" }));
            }
            if (myconfig.VALID_FALG == "0")
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}该服务的已被作废!", code = "500" }));
            }
            string[] inparameters   = myconfig.INPARAMETERNAMES == null ? new string[0] : myconfig.INPARAMETERNAMES.Split('|');
            string[] intypes        = myconfig.INPARAMETERTYPES == null ? new string[0] : myconfig.INPARAMETERTYPES.Split('|');
            string[] procedureprops = myconfig.INPROCEDUREPROP == null ? new string[0] : myconfig.INPROCEDUREPROP.Split('|');
            string[] outparameters  = myconfig.OUTPARAMETERNAMES == null ? new string[0] : myconfig.OUTPARAMETERNAMES.Split('|');
            string[] outtypes       = myconfig.OUTPARAMETERTYPES == null ? new string[0] : myconfig.OUTPARAMETERTYPES.Split('|');
            if (inparameters.Length != intypes.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}入参和入参的类型无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            else if (inparameters.Length != procedureprops.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}入参和数据库入参无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            else if (outparameters.Length != outtypes.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}出参和出参类型无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            //输入参数
            List <OracleParameter> parems = new List <OracleParameter>();

            try
            {
                for (int i = 0; i < inparameters.Length; i++)
                {
                    parems.Add(GetInput(procedureprops[i], (OracleDbType)Int32.Parse(intypes[i]), GetParameterByType((OracleDbType)Int32.Parse(intypes[i]), jobj.GetValue(inparameters[i]).ToString())));
                }
            }
            catch (Exception)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}请检查您所传递的参数是否有误!", code = "500" }));
            }
            //输出参数(绑定数据库中的配置表)
            for (int i = 0; i < outparameters.Length; i++)
            {
                int len = Int32.Parse(outtypes[i]) == 121 ? 1024 : (Int32.Parse(outtypes[i]) == 112 ? 200 : 200);
                parems.Add(GetOutput(outparameters[i], (OracleDbType)Int32.Parse(outtypes[i]), len));
            }
            //parems.Add(GetOutput("ResultSet", (OracleDbType)121, 1024));
            //parems.Add(GetOutput("ReturnCode", (OracleDbType)112, 200));
            //parems.Add(GetOutput("ErrorMsg", (OracleDbType)126, 200));
            db = db == null ? dbContext : db;
            var          ds  = SqlQuery(db, myconfig.PROCEDURENAME, parems.ToArray());
            ObjectResult obj = GetResult(parems, ds, outparameters, outtypes);

            if (myconfig.ISFY == "1")
            {
                if (!jobj.ContainsKey("Page"))
                {
                    return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}此接口需要分页,没有找到参数名为Page的参数!", code = "500" }));
                }
                if (!jobj.ContainsKey("pageSize"))
                {
                    return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}此接口需要分页,没有找到参数名为pageSize的参数!", code = "500" }));
                }
                int page      = int.Parse(jobj.GetValue("Page", StringComparison.OrdinalIgnoreCase).ToString());
                int pageCount = int.Parse(jobj.GetValue("pageSize", StringComparison.OrdinalIgnoreCase).ToString());
                obj = GetResult(parems, ds, page, pageCount);
            }
            if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.科室查询)
            {
                obj = GetResultAndHaveSon(parems, ds);
            }
            else if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.微生物查询)
            {
            }
            else if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.费用查询)
            {
                if (!jobj.ContainsKey("type"))
                {
                    obj = new ObjectResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}没有找到参数名为type的参数!", code = "500" });
                }
                if (jobj.GetValue("type").ToString() == "2")
                {
                    obj = this.GetHosListGroup(ds);
                }
                else if (jobj.GetValue("type").ToString() == "3")
                {
                    obj = this.GetHosListGroup(ds);
                }
                else
                {
                    //Console.WriteLine("返回参数:\n" + JsonConvert.SerializeObject(Methods.GetResult(parems, ds)));
                    obj = GetResult(parems, ds, outparameters, outtypes);
                }
            }
            return(obj);
        }