public Tuple <int, bool> QueryExistedStatsCount(int eNodebId, byte sectorId, DateTime date)
        {
            var beginDay = date.Date;
            var nextDay  = date.AddDays(1).Date;

            return(new Tuple <int, bool>(_repository.Count(
                                             x =>
                                             x.ENodebId == eNodebId && x.SectorId == sectorId && x.RecordTime >= beginDay &&
                                             x.RecordTime < nextDay), _statRepository.Get(eNodebId, sectorId, beginDay) != null));
        }
        private List <ICellStastic> QueryDateSpanStatList(int eNodebId, short pci, DateTime begin, DateTime end)
        {
            var dateSpanStats = new List <ICellStastic>();

            while (begin < end)
            {
                var oneDayMysqlStat = _statRepository.Get(eNodebId, pci, begin);
                if (oneDayMysqlStat != null)
                {
                    dateSpanStats.Add(oneDayMysqlStat);
                }
                else
                {
                    var oneDayStats = _repository.GetList(eNodebId, pci, begin);

                    if (oneDayStats.Any())
                    {
                        var stat = new CellStatMysql
                        {
                            Mod3Count      = oneDayStats.Sum(x => x.Mod3Count),
                            Mod6Count      = oneDayStats.Sum(x => x.Mod6Count),
                            MrCount        = oneDayStats.Sum(x => x.MrCount),
                            OverCoverCount = oneDayStats.Sum(x => x.OverCoverCount),
                            PreciseCount   = oneDayStats.Sum(x => x.PreciseCount),
                            WeakCoverCount = oneDayStats.Sum(x => x.WeakCoverCount),
                            CurrentDate    = begin,
                            ENodebId       = eNodebId,
                            Pci            = pci,
                            SectorId       =
                                _cellRepository.FirstOrDefault(x => x.ENodebId == eNodebId && x.Pci == pci)?.SectorId ??
                                0
                        };
                        dateSpanStats.Add(stat);
                        _statRepository.Insert(stat);
                        _statRepository.SaveChanges();
                    }
                }

                begin = begin.AddDays(1);
            }
            return(dateSpanStats);
        }