public async Task <IActionResult> GetDefaultDialysisTypeJson() { var data = await _itemsDetailApp.GetDefaultDialysisType(); return(Content(data)); }
public async Task FillData(DateTime monday, string filepath, string hospitalName) { NPOIExcel excel = new NPOIExcel(); DataTable table = new DataTable(); table.Columns.AddRange(new DataColumn[] { new DataColumn("GroupName"), new DataColumn("BedNo"), new DataColumn("Col1"), new DataColumn("Col2"), new DataColumn("Col3"), new DataColumn("Col4"), new DataColumn("Col5"), new DataColumn("Col6"), new DataColumn("Col7"), new DataColumn("Col8"), new DataColumn("Col9"), new DataColumn("Col10"), new DataColumn("Col11"), new DataColumn("Col12"), new DataColumn("Col13"), new DataColumn("Col14"), new DataColumn("Col15"), new DataColumn("Col16"), new DataColumn("Col17"), new DataColumn("Col18"), new DataColumn("Col19"), new DataColumn("Col20"), new DataColumn("Col21"), new DataColumn("ShowOrder", typeof(Int32)) }); var list = new List <string> { "星期一" + "(" + monday.ToDateString().Replace("-", "") + ")", "星期二" + "(" + monday.AddDays(1).ToDateString().Replace("-", "") + ")", "星期三" + "(" + monday.AddDays(2).ToDateString().Replace("-", "") + ")", "星期四" + "(" + monday.AddDays(3).ToDateString().Replace("-", "") + ")", "星期五" + "(" + monday.AddDays(4).ToDateString().Replace("-", "") + ")", "星期六" + "(" + monday.AddDays(5).ToDateString().Replace("-", "") + ")", "星期日" + "(" + monday.AddDays(6).ToDateString().Replace("-", "") + ")", }; var startDate = monday.Date; var endDate = startDate.AddDays(6); var expression = ExtLinq.True <DialysisScheduleEntity>(); expression = expression.And(t => t.F_VisitDate >= startDate); expression = expression.And(t => t.F_VisitDate <= endDate); expression = expression.And(t => t.F_DeleteMark != true); expression = expression.And(t => t.F_EnabledMark != false); var records = _service.IQueryable(expression).Select(t => new { VisitDate = t.F_VisitDate, VisitNo = t.F_VisitNo, GroupName = t.F_GroupName, BedNo = t.F_DialysisBedNo, Name = t.F_Name, DialysisType = t.F_DialysisType }).ToList(); var results = records.Select(t => new { VisitDate = t.VisitDate.ToDate(), VisitNo = t.VisitNo.ToInt(), t.GroupName, t.BedNo, t.Name, t.DialysisType }); //默认透析模式 不显示 var filterTypes = new string[] { await _itemsDetailApp.GetDefaultDialysisType() ?? "HD" }; foreach (var item in results) { var row = table.Select("GroupName='" + item.GroupName + "' and BedNo='" + item.BedNo + "'").FirstOrDefault(); //row = row ?? table.NewRow(); if (row == null) { row = table.NewRow(); row[0] = item.GroupName; row[1] = item.BedNo; if (!int.TryParse(item.BedNo, out int showOrder)) { showOrder = 9999; } row[23] = showOrder; table.Rows.Add(row); } var interval = (item.VisitDate - startDate).TotalDays.ToInt(); row[2 + interval * 3 + item.VisitNo - 1] = item.Name + (filterTypes.Contains(item.DialysisType) ? "" : item.DialysisType); } var tableView = table.DefaultView; tableView.Sort = "GroupName asc, ShowOrder asc"; table = tableView.ToTable(); excel.ToExcelForSchedule(table, hospitalName + "排班表", "日期:" + startDate.ToDateString() + " ~ " + endDate.ToDateString(), list, "合计: 人次", "排班明细", filepath); }