Example #1
0
        public RouteWorkerMatchResult MatchWorkerForTakeTempArticle(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.HadTake(affairId, worker))
            {
                result.Message = "你已取物"; return(result);
            }

            var stores = WorkManager.GetStores(affairId, worker);

            if (stores == null || stores.Count < 2)
            {
                result.Message = "需要双人操作"; return(result);
            }

            var routeInfo = stores[0].Issurer.Split(',')[0];
            var cn        = stores[0].Issurer.Split(',')[1].Split()[0];

            result.RouteMatched  = new MatchedRouteDto(routeInfo);
            result.WorkerMatched = new MatchedWorkerDto(WorkManager.GetWorkerByCn(cn));
            result.Articles      = GetArticles(stores[0].Description);

            cn = stores[1].Issurer.Split(',')[1].Split()[0];
            result.WorkerMatched2 = new MatchedWorkerDto(WorkManager.GetWorkerByCn(cn));
            result.Articles2      = GetArticles(stores[1].Description);
            return(result);
        }
Example #2
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);
        }
Example #3
0
        public RouteWorkerMatchResult MatchWorkerForBox(int wpId, DateTime carryoutDate, int depotId, int affairId, string rfid)
        {
            var depots = WorkManager.GetShareDepots(wpId);
            var result = new RouteWorkerMatchResult();

            (RouteCacheItem, RouteWorkerCacheItem, RouteWorkerCacheItem)found = (null, null, null);
            foreach (var dopotId in depots)
            {
                found = FindEqualRfidWorker(_routeCache.Get(carryoutDate, depotId), rfid);
                if (found.Item1 != null)
                {
                    break;
                }
            }

            if (found.Item1 == null)
            {
                result.Message = "还未安排在激活的任务中";
                return(result);
            }

            // RULE JUDGE
            var wr = _workRoleCache[found.Item2.WorkRoleId];

            if (string.IsNullOrEmpty(wr.Duties) || !wr.Duties.Contains("尾箱"))
            {
                result.Message = "此人非尾箱交接人员";
                return(result);
            }

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

            result.WorkerMatched = new MatchedWorkerDto(w.Id, WorkManager.GetWorker(w.WorkerId), _workRoleCache[w.WorkRoleId]);
            result.Boxes         = new List <RouteBoxCDto>();
            return(result);
        }
Example #4
0
        public RouteWorkerMatchResult MatchWorkerForArticle(bool isLend, int wpId, DateTime carryoutDate, int depotId, string rfid, int routeId)
        {
            var result = new RouteWorkerMatchResult();

            (string, RouteCacheItem, RouteWorkerCacheItem, RouteWorkerCacheItem)found = (null, null, null, null);
            if (routeId > 0)
            {
                found = FindEqualRfidWorkerForArticle(isLend, _routeCache.Get(carryoutDate, depotId), rfid, routeId);
            }
            else
            {
                foreach (var id in WorkManager.GetShareDepots(wpId))
                {
                    var routes = _routeCache.Get(carryoutDate, id);
                    found = FindEqualRfidWorkerForArticle(isLend, routes, rfid);
                    if (found.Item1 == null)
                    {
                        break;
                    }
                }
            }

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

            // Route
            result.RouteMatched           = new MatchedRouteDto(found.Item2);
            result.RouteMatched.CaptainCn = WorkManager.GetCaptain(result.RouteMatched.DepotId).Cn;
            result.RouteMatched.DepotCn   = WorkManager.GetDepot(result.RouteMatched.DepotId).Cn;

            // Worker1
            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);

            // Worker2
            w = found.Item4;
            if (w != null)
            {
                result.WorkerMatched2 = new MatchedWorkerDto(w.Id, WorkManager.GetWorker(w.GetFactWorkerId()), _workRoleCache[w.WorkRoleId]);
                result.Articles2      = GetArticles(found.Item2.Id, w.Id);

                var guns = GetGuns(result.RouteMatched.MainVehicleCn);
                if (guns.Count == 2)
                {
                    result.WorkerMatched.GunNo    = guns[0].Item1;
                    result.WorkerMatched.GunIp    = guns[0].Item2;
                    result.WorkerMatched.BulletNo = guns[0].Item3;

                    result.WorkerMatched2.GunNo    = guns[1].Item1;
                    result.WorkerMatched2.GunIp    = guns[1].Item2;
                    result.WorkerMatched2.BulletNo = guns[1].Item3;
                }
            }
            return(result);
        }