public async Task <IActionResult> GetDepartZBList([FromForm] InDepart model) { var data = await departService.GetDepartZBList(model); return(Ok(new ResutModel <OutDepart> { data = data, errorCode = 0, errorMsg = "" })); }
public async Task <OutDepart> GetDepartZBList(InDepart model) { OutDepart outDepart = new OutDepart { Head = new List <OutDepart_Head>(), Body = new List <OutDepart_Body>() }; var Head = new List <OutDepart_Head>(); string starttime = string.Empty; string endtime = string.Empty; DateTime time = DateTime.Now; if (model.StartTime == null || model.EndTime == null) { starttime = endtime = time.ToString("yyyy-MM"); } else { starttime = model.StartTime; endtime = model.EndTime; } var ohsetdata = await oHZBRepository.QueryFirstOrDefaultAsync <OhSet>("select * from OH_Set "); outDepart.UpdateTime = ohsetdata.UpdateTime.ToString("yyyy-MM-dd HH:mm"); outDepart.StartTime = starttime; outDepart.EndTime = endtime; var ohzb = (await oHZBRepository.QueryAsync <OhZb>("select * from OH_ZB where IsEnable=1 and CID=0")).ToList(); Head.Add(new OutDepart_Head() { ID = "", Name = "指标名称" }); DataTable dt = new DataTable(); for (int i = 0; i < ohzb.Count(); i++) { var Body = new OutDepart_Body() { Row = new List <OutDepart_Row>() }; Body.Type = ohzb[i].Type.ToString(); Body.Row.Add(new OutDepart_Row { val = ohzb[i].Zbmc }); var array = Method.GetInteger(ohzb[i].Formula).Split(",").GroupBy(p => p).Select(p => p.Key).ToArray(); var bm = await oHZBRepository.QueryAsync <OhCbxx>("select * from OH_CBXX where IsEnable=1 and CID=0"); foreach (var items in bm) { var id = items.Id.ToString(); if (i == 0) { Head.Add(new OutDepart_Head() { ID = id, Name = $"{items.Name}+{starttime} 至+{endtime} " }); } for (int j = 0; j < array.Length; j++) { var re = await oHZBRepository.GetDepartList(starttime, endtime, array[j].ToString(), id); ohzb[i].Formula = ohzb[i].Formula.Replace("'" + array[j].ToString() + "'", re); } var Ret = double.Parse(dt.Compute(ohzb[i].Formula, "false").ToString()).ToString("0.##"); Body.Row.Add(new OutDepart_Row { val = Ret }); } outDepart.Body.Add(Body); } outDepart.Head = Head; return(outDepart); throw new NotImplementedException(); }