예제 #1
0
        private static void ProduceDeviceDayRunningTime(long hotelIdentity)
        {
            if (ProcessInvoke.Instance <MonitorDataProcess>().GetDataCount(obj => obj.ProjectIdentity == hotelIdentity))
            {
                return;
            }
            Log($"【{DateTime.Now:yyyy-MM-dd HH:mm:ss}】开始处理每日设备运行时间数据。");
            var process = ProcessInvoke.Instance <RunningTimeProcess>();

            var lastDate         = process.LastRecordDateTime(hotelIdentity, RunningTimeType.Device);
            var firstMonitorData = ProcessInvoke.Instance <MonitorDataProcess>().GetFirst(obj => obj.ProjectIdentity == hotelIdentity);
            var startDate        = lastDate == DateTime.MinValue
                    ? firstMonitorData.UpdateTime
                    : lastDate.AddDays(1);

            while (startDate <= _produceEndDay)
            {
                var date    = startDate;
                var runTime = ProcessInvoke.Instance <HotelRestaurantProcess>()
                              .GetDeviceRunTime(hotelIdentity, date);

                var runningTime = new RunningTimeRepository().CreateDefaultModel();
                runningTime.UpdateTime      = date.GetToday();
                runningTime.ProjectIdentity = hotelIdentity;
                runningTime.RunningTimeSpan = runTime;
                runningTime.DeviceIdentity  = firstMonitorData.DeviceIdentity;
                runningTime.Type            = RunningTimeType.Device;
                ProcessInvoke.Instance <RunningTimeProcess>().StoreRunningTime(runningTime);

                startDate = startDate.AddDays(1);
            }
        }
예제 #2
0
        private static void ProduceDayRunningTime(long hotelIdentity)
        {
            foreach (var data in RunningTimeDatas)
            {
                if (!ProcessInvoke.Instance <MonitorDataProcess>().GetDataCount(obj => obj.ProjectIdentity == hotelIdentity && obj.CommandDataId == data.Id))
                {
                    continue;
                }
                Log($"【{DateTime.Now:yyyy-MM-dd HH:mm:ss}】开始处理每日运行时间数据,数据名称:{data.DataName}");
                var process = ProcessInvoke.Instance <RunningTimeProcess>();

                var type             = GetRunningType(data.DataName);
                var lastDate         = process.LastRecordDateTime(hotelIdentity, type);
                var firstMonitorData = ProcessInvoke.Instance <MonitorDataProcess>().GetFirst(obj => obj.ProjectIdentity == hotelIdentity && obj.CommandDataId == data.Id);
                var startDate        = lastDate == DateTime.MinValue
                        ? firstMonitorData.UpdateTime
                        : lastDate.AddDays(1);

                while (startDate <= _produceEndDay)
                {
                    var date    = startDate;
                    var runTime = ProcessInvoke.Instance <HotelRestaurantProcess>()
                                  .GetRunTime(hotelIdentity, date, data.Id);

                    var runningTime = new RunningTimeRepository().CreateDefaultModel();
                    runningTime.UpdateTime      = date.GetToday();
                    runningTime.ProjectIdentity = hotelIdentity;
                    runningTime.RunningTimeSpan = runTime;
                    runningTime.DeviceIdentity  = firstMonitorData.DeviceIdentity;
                    runningTime.Type            = type;

                    ProcessInvoke.Instance <RunningTimeProcess>().StoreRunningTime(runningTime);

                    startDate = startDate.AddDays(1);
                }
            }
        }