Пример #1
0
        public RouteWorkerMatchResult MatchWorkerForStoreTempArticle(DateTime carryoutDate, int depotId, int affairId, string rfid)
        {
            var result = new RouteWorkerMatchResult();
            var worker = WorkManager.GetWorkerByRfid(rfid);

            if (worker == null)
            {
                result.Message = "无此RFID"; return(result);
            }
            ;
            if (WorkManager.HadStore(affairId, worker))
            {
                result.Message = "你已存物"; return(result);
            }

            // found
            (string, RouteCacheItem, RouteWorkerCacheItem, RouteWorkerCacheItem)found = ("找不到任务", null, null, null);
            foreach (var route in _routeCache.Get(carryoutDate, worker.DepotId))
            {
                foreach (var rw in route.Workers)
                {
                    if (WorkManager.GetWorker(rw.GetFactWorkerId()).Rfid == rfid)
                    {
                        if (string.IsNullOrEmpty(_workRoleCache[rw.WorkRoleId].ArticleTypeList))
                        {
                            found = ("此人不需要领还物", null, null, null); break;
                        }

                        RouteWorkerCacheItem rw2 = FindAnotherRouteWorker(route.Workers, _workRoleCache[rw.WorkRoleId]);
                        if (rw2 == null)
                        {
                            found = ("临时存取需要双人操作", null, null, null);
                        }
                        else
                        {
                            found = (null, route, rw, rw2);
                        }
                        break;
                    }
                }
            }

            // Error, Return
            if (found.Item1 != null)
            {
                result.Message = found.Item1; return(result);
            }

            result.RouteMatched = new MatchedRouteDto(found.Item2);
            var w = found.Item3;

            result.WorkerMatched = new MatchedWorkerDto(w.Id, WorkManager.GetWorker(w.GetFactWorkerId()), _workRoleCache[w.WorkRoleId]);
            result.Articles      = GetArticles(found.Item2.Id, w.Id);
            w = found.Item4;
            result.WorkerMatched2 = new MatchedWorkerDto(w.Id, WorkManager.GetWorker(w.GetFactWorkerId()), _workRoleCache[w.WorkRoleId]);
            result.Articles2      = GetArticles(found.Item2.Id, w.Id);
            return(result);
        }
Пример #2
0
        private (string, RouteCacheItem, RouteWorkerCacheItem, RouteWorkerCacheItem) FindEqualRfidWorkerForArticle(bool isLend, List <RouteCacheItem> routes, string rfid, int routeId = 0)
        {
            foreach (var route in routes)
            {
                if (routeId != 0 && route.Id != routeId)
                {
                    continue;
                }

                if (routeId == 0)
                {
                    // 时间段 JUDGE
                    var rt = _routeTypeCache[route.RouteTypeId];
                    if (isLend && !ClcUtils.NowInTimeZone(route.StartTime, rt.LendArticleLead, rt.LendArticleDeadline))
                    {
                        continue;
                    }
                    var span = int.Parse(SettingManager.GetSettingValue(AppSettingNames.TimeRule.ReturnDeadline));
                    if (!isLend && DateTime.Now > ClcUtils.GetDateTime(route.EndTime).AddMinutes(span))
                    {
                        continue;
                    }
                }

                foreach (var rw in route.Workers)
                {
                    var worker = WorkManager.GetWorker(rw.GetFactWorkerId());
                    if (worker.Rfid == rfid)
                    {
                        if (string.IsNullOrEmpty(_workRoleCache[rw.WorkRoleId].ArticleTypeList))
                        {
                            return("此人不需要领还物", null, null, null);
                        }

                        RouteWorkerCacheItem rw2 = FindAnotherRouteWorker(route.Workers, _workRoleCache[rw.WorkRoleId]);
                        return(null, route, rw, rw2);
                    }
                }
            }
            return("无任务或不在时间段", null, null, null);
        }
Пример #3
0
        private (RouteCacheItem, RouteWorkerCacheItem, RouteWorkerCacheItem) FindEqualRfidWorker(List <RouteCacheItem> routes, string rfid, int routeId = 0)
        {
            foreach (var route in routes)
            {
                if (routeId != 0 && route.Id != routeId)
                {
                    continue;
                }


                foreach (var w in route.Workers)
                {
                    var worker = WorkManager.GetWorker(w.WorkerId);
                    if (worker.Rfid == rfid)
                    {
                        RouteWorkerCacheItem w2 = FindAnotherRouteWorker(route.Workers, _workRoleCache[w.WorkRoleId]);
                        return(route, w, w2);
                    }
                }
            }
            return(null, null, null);
        }
Пример #4
0
 public static int GetFactWorkerId(this RouteWorkerCacheItem rw)
 {
     return(rw.AltWorkerId.HasValue ? rw.AltWorkerId.Value : rw.WorkerId);
 }