/// <summary>
        /// 获取设备数据  例:班制shift为0, 首班时间为8:00:00,统计延时30分钟时, 5月28日的数据为5月28日(含)至5月29日8:30:00(不含)
        /// <param name="shift">班制 0 全天 1  2  ...  </param>
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <MonitoringKanBanDevice> GetKanBanDevices(Workshop workshop, DateTime time, KanBanShiftsEnum shift, IEnumerable <int> deviceIds)
        {
            var res = new List <MonitoringKanBanDevice>();

            try
            {
                var workshopId = workshop.Id;
                var deviceList = (deviceIds != null && deviceIds.Any())
                    ? DeviceHelper.GetMenus(workshopId, deviceIds.Distinct()).ToDictionary(x => x.Id, x => x.Code)
                    : new Dictionary <int, string>();
                deviceIds = deviceList.Select(x => x.Key).ToList();
                if (!deviceIds.Any())
                {
                    return(res);
                }
                var      currentWorkTimes = DateTimeExtend.GetCurrentWorkTimeRanges(workshop.Shifts, workshop.StatisticTimeList, time);
                var      shiftTimes = DateTimeExtend.GetDayWorkTimeRanges(workshop.Shifts, workshop.StatisticTimeList, time);
                var      workTime = DateTimeExtend.GetDayWorkDay(workshop.Shifts, workshop.StatisticTimeList, time);
                DateTime startTime = default(DateTime), endTime = default(DateTime);
                var      sft = 0;
                switch (shift)
                {
                case KanBanShiftsEnum.当前班次:
                    startTime = currentWorkTimes.ElementAt(1).Item1;
                    endTime   = currentWorkTimes.ElementAt(1).Item2.AddSeconds(-1);
                    sft       = shiftTimes.IndexOf(currentWorkTimes.ElementAt(1));
                    break;

                case KanBanShiftsEnum.个班:
                    startTime = currentWorkTimes.ElementAt(0).Item1;
                    endTime   = currentWorkTimes.ElementAt(0).Item2.AddSeconds(-1);
                    sft       = shiftTimes.IndexOf(currentWorkTimes.ElementAt(1));
                    if (sft == -1)
                    {
                        time             = time.AddDays(-1);
                        currentWorkTimes = DateTimeExtend.GetCurrentWorkTimeRanges(workshop.Shifts, workshop.StatisticTimeList, time);
                        shiftTimes       = DateTimeExtend.GetDayWorkTimeRanges(workshop.Shifts, workshop.StatisticTimeList, time);
                        sft = shiftTimes.IndexOf(currentWorkTimes.ElementAt(1));
                    }
                    break;

                case KanBanShiftsEnum.今日:
                    startTime = workTime.Item1;
                    endTime   = workTime.Item2.AddSeconds(-1);
                    break;

                case KanBanShiftsEnum.昨日:
                    startTime = workTime.Item1.AddDays(-1);
                    endTime   = workTime.Item2.AddDays(-1).AddSeconds(-1);
                    break;
                }
                if (startTime == default(DateTime) || endTime == default(DateTime))
                {
                    return(res);
                }
                var data = GetKanBanDevices(startTime.Date, endTime.Date, 0, deviceIds);
                foreach (var(id, name) in deviceList)
                {
                    var dData = data.Where(x => x.DeviceId == id);
                    if (shift == 0)
                    {
                        AddMonitoringKanBanDevice(endTime, ref res, dData, -1, 0, null, id, name);
                    }
                    else
                    {
                        var tData = dData.Where(x => x.ExtraData.Parts.Any(y => y.Shift == sft)).Select(x => x.ExtraData.Parts.FirstOrDefault(y => y.Shift == sft));
                        AddMonitoringKanBanDevice(endTime, ref res, tData, -1, 0, null, id, name);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            return(res);
        }