public async Task <List <ImportScheduleModel> > ImportDatas(DateTime startDate, string filePath)
        {
            var defaultDialysisType = await _itemsDetailApp.GetDefaultDialysisType() ?? "HD";

            var       list          = new List <ImportScheduleModel>();
            NPOIExcel excel         = new NPOIExcel();
            var       dialysisTypes = (await _itemsDetailApp.GetItemList("DialysisType")).Select(t => t.F_ItemCode).OrderByDescending(t => t.Length).ToList();
            var       records       = excel.ToListForSchedule("排班明细", filePath, dialysisTypes, 4, 0);
            //var groups =
            var groups = (await _itemsDetailApp.GetItemList("BedGroup")).Select(t => t.F_ItemCode).ToList();
            var beds   = await _dialysisMachineApp.GetList();

            var patients = await _patientApp.GetList();

            foreach (var item in records.GroupBy(t => t.F_GroupName))
            {
                if (!groups.Contains(item.Key))
                {
                    continue;
                }
                foreach (var child in item.GroupBy(t => t.F_DialysisBedNo))
                {
                    var findBed = beds.Find(t => t.F_GroupName == item.Key && t.F_DialylisBedNo == child.Key);
                    if (findBed == null)
                    {
                        continue;
                    }
                    foreach (var ele in child)
                    {
                        var patient = patients.Find(t => t.F_Name == ele.F_Name.Trim());
                        if (patient == null)
                        {
                            continue;
                        }
                        list.Add(new ImportScheduleModel
                        {
                            F_GroupName     = item.Key,
                            F_DialysisBedNo = child.Key,
                            F_BId           = findBed.F_Id,
                            F_VisitDate     = startDate.AddDays(ele.DayOfWeek - 1),
                            F_VisitNo       = ele.F_VisitNo,
                            F_PId           = patient.F_Id,
                            F_DialysisNo    = patient.F_DialysisNo,
                            F_Name          = patient.F_Name,
                            F_DialysisType  = ele.F_DialysisType ?? defaultDialysisType,
                            F_Sort          = findBed.F_ShowOrder.ToInt()
                        });
                    }
                }
            }
            return(list);
        }
        public async Task <IActionResult> GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows    = await _dialysisMachineApp.GetList(pagination, keyword),
                total   = pagination.total,
                page    = pagination.page,
                records = pagination.records
            };

            return(Content(data.ToJson()));
        }
예제 #3
0
        public async Task <IActionResult> GetCardList()
        {
            var list = await _dialysisMachineApp.GetList();

            var data = list.GroupBy(t => t.F_GroupName).Select(t => new
            {
                groupName = t.Key,
                count     = t.Count(),
                items     = t.Select(r => new
                {
                    id          = r.F_Id,
                    bedNo       = r.F_DialylisBedNo,
                    machineName = r.F_MachineName,
                    machineNo   = r.F_MachineNo,
                    defaultType = r.F_DefaultType,
                    creatorTime = r.F_CreatorTime,
                    showOrder   = r.F_ShowOrder
                }).OrderBy(r => r.showOrder)
            }).OrderBy(t => t.groupName);

            return(Ok(data));
        }