public async Task <OutCase> GetCaseList(InCase model) { OutCase outCase = new OutCase { Info = new List <OutCase_Info>() }; var express_c = string.Empty; var data = await iOHZBRepository.QueryFirstOrDefaultAsync <OhZb>("select * from OH_ZB where CID>0 and ID=@Id", new { Id = model.ID }); if (data != null) { express_c = data.ExpressC; } var sql = await adsSpAj330304Repository.GetCaseInfo(DateTime.Parse(model.StartTime).ToString("yyyyMM") + "01", Method.GetDaysByMonth(model.EndTime), express_c); var spdata = (await adsSpAj330304Repository.QueryAsync <dynamic>(sql)).ToList(); _logger.LogWarning($"sql 语句返回 dynamic {JsonConvert.SerializeObject(data)}"); for (int i = 0; i < spdata.Count; i++) { outCase.Info.Add(new OutCase_Info { XH = (1 + i).ToString(), AH = spdata[i].ah, AY = spdata[i].ay, BMMC = spdata[i].bmmc, CBRMC = spdata[i].cbrmc, AJLX = spdata[i].ajlx, SPCX = spdata[i].spcx, SARQ = spdata[i].sarq, JARQ = spdata[i].jarq, }); } return(outCase); }
public async Task <OutMQuery> GetComZbList(InMQuery model) { var outMQuery = new OutMQuery { Body = new List <OutMQuery_Body>(), Head = new List <OutMQuery_Head>() }; var head = new List <OutMQuery_Head>(); var data = await ohSetRepository.QueryFirstOrDefaultAsync <OhSet>("select * from OH_Set"); outMQuery.UpdateTime = data.UpdateTime.ToString("yyyy-MM-dd HH:mm"); head.Add(new OutMQuery_Head { Name = "指标名称" }); var zb = await ohSetRepository.QueryAsync <OhZb>("select * from OH_ZB where IsEnable=1 and CID=0"); if (model == null) { var timeN = DateTime.Now.ToString("yyyy-MM"); head.Add(new OutMQuery_Head { Name = $"全院{timeN}至{timeN}" }); foreach (var item in zb) { var Body = new OutMQuery_Body { Row = new List <OutMQuery_Row>() }; var type = item.Type; var formula = item.Formula; var array = Method.GetInteger(item.Formula).Split(",").GroupBy(p => p).Select(p => p.Key).ToArray(); var dt = new DataTable(); Body.Row.Add(new OutMQuery_Row { val = item.Zbmc }); Body.Type = item.Type.ToString(); foreach (var t in array) { var re = await ohSetRepository.GetZBList(timeN, timeN, t.ToString()); formula = formula.Replace("'" + t.ToString() + "'", re); } var ret = double.Parse(dt.Compute(formula, "false").ToString() ?? string.Empty).ToString("0.##"); Body.Row.Add(new OutMQuery_Row { val = ret }); outMQuery.Body.Add(Body); } } else { var table = string.Empty; var type_c = string.Empty; foreach (var item in model.Info) { table = item.Type switch { "bm" => "OH_CBXX", "lx" => "OH_AJLX", "xz" => "OH_AJXZ", "ay" => "OH_AY", "cbr" => "OH_CBXX", "qt" => "", _ => table }; if (string.IsNullOrEmpty(table)) { head.Add(new OutMQuery_Head { Name = $"全院{item.StartTime}至{item.EndTime}" }); } else { var name = await ohSetRepository.QueryFirstOrDefaultAsync <dynamic>($"select name from {table} where Id=@Id", new { Id = item.Data.ToString() }); _logger.LogWarning($"sql 语句返回 dynamic {JsonConvert.SerializeObject(data)}"); head.Add(new OutMQuery_Head { Name = $"{name} {item.StartTime}至{item.EndTime}" }); } } foreach (var item in zb) { var body = new OutMQuery_Body { Row = new List <OutMQuery_Row>() }; var formula = item.Formula; var array = Method.GetInteger(item.Formula).Split(",").GroupBy(p => p).Select(p => p.Key).ToArray(); var dt = new DataTable(); body.Row.Add(new OutMQuery_Row { val = item.Zbmc }); body.Type = item.Type.ToString(); foreach (var t in model.Info) { type_c = t.Type switch { "bm" => "1", "lx" => "2", "xz" => "3", "ay" => "4", "cbr" => "5", "qt" => "0", _ => type_c }; foreach (var t1 in array) { var re = await ohSetRepository.GetComList(t.StartTime, t.EndTime, t1, type_c, t.Data); formula = formula.Replace("'" + t1 + "'", re); } var ret = double.Parse(dt.Compute(formula, "false").ToString() ?? string.Empty).ToString("0.##"); body.Row.Add(new OutMQuery_Row { val = ret }); outMQuery.Body.Add(body); } } } outMQuery.Head = head; return(outMQuery); }
public async Task <OutDepartD> GetDepartDetail(InDepartD model) { OutDepartD outDepartD = new OutDepartD { Info = new List <OutDepartD_List>() }; string formula, re, Ret, formula_t, re_t, Ret_t, formula_h, re_h, Ret_h; string starttime = model.StartTime; string endtime = model.EndTime; string[] array_tb = Method.GetTB(starttime, endtime).Split(","); string starttime_t = array_tb[0].ToString(); string endtime_t = array_tb[1].ToString(); string[] array_hb = Method.GetHB(starttime, endtime).Split(","); string starttime_h = array_hb[0].ToString(); string endtime_h = array_hb[1].ToString(); var ohsetdata = await oHZBRepository.QueryFirstOrDefaultAsync <OhSet>("select * from OH_Set "); outDepartD.UpdateTime = ohsetdata.UpdateTime.ToString("yyyy-MM-dd HH:mm"); var domain = await oHZBRepository.QueryFirstOrDefaultAsync <OhCbxx>("select * from OH_CBXX where Id=@Id", new { Id = model.ID }); outDepartD.DepartName = domain.Name; outDepartD.StartTime = starttime; outDepartD.EndTime = endtime; var zbdata = (await oHZBRepository.QueryAsync <OhZb>("select * from OH_ZB where IsEnable=1 and CID=0")).ToList(); DataTable dt = new DataTable(); foreach (var item in zbdata) { formula_h = formula_t = formula = item.Formula; OutDepartD_List info = new OutDepartD_List(); info.Name = item.Zbmc; info.Type = item.Type.ToString(); var array = Method.GetInteger(item.Formula).Split(",").GroupBy(p => p).Select(p => p.Key).ToArray(); for (int j = 0; j < array.Length; j++) { //部门指标数值 re = await oHZBRepository.GetDepartList(starttime, endtime, array[j].ToString(), model.ID); formula = formula.Replace("'" + array[j].ToString() + "'", re); //同比 if (starttime_t != "") { re_t = await oHZBRepository.GetDepartList(starttime_t, endtime_t, array[j].ToString(), model.ID); formula_t = formula_t.Replace("'" + array[j].ToString() + "'", re_t); } //环比 if (starttime_t != "") { re_h = await oHZBRepository.GetDepartList(starttime_h, endtime_h, array[j].ToString(), model.ID); formula_h = formula_h.Replace("'" + array[j].ToString() + "'", re_h); } } Ret = double.Parse(dt.Compute(formula, "false").ToString()).ToString("0.##"); Ret_t = formula_t == "" ? "" : double.Parse(dt.Compute(formula_t, "false").ToString()).ToString("0.##"); Ret_h = formula_h == "" ? "" : double.Parse(dt.Compute(formula_h, "false").ToString()).ToString("0.##"); Ret_t = (double.Parse(Ret) / double.Parse(Ret_t) - 1).ToString("0.##"); Ret_h = (double.Parse(Ret) / double.Parse(Ret_h) - 1).ToString("0.##"); info.Num = Ret; info.TB = Ret_t; info.HB = Ret_h; outDepartD.Info.Add(info); } return(outDepartD); }