Exemplo n.º 1
0
        public void checkout(int workerId, DateTime carryoutDate, int depotId, int affairId)
        {
            var aw = WorkManager.GetCacheAffairWorker(carryoutDate, depotId, affairId, workerId);

            if (aw.Item2 == null)
            {
                return;
            }
            WorkManager.DoCheckout(aw.Item1, aw.Item2, workerId);
        }
Exemplo n.º 2
0
        public string GetWorkerRfidByCn(string cn)
        {
            var worker = WorkManager.GetWorkerByCn(cn);

            if (worker == null)
            {
                return("NNNNN");
            }
            return(worker.Rfid);
        }
Exemplo n.º 3
0
        public void SetReportDate()
        {
            int depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);
            var depot   = _depotRepository.Get(depotId);

            var t    = SettingManager.GetSettingValue(AppSettingNames.TimeRule.ActivateTime);
            var time = ClcUtils.GetDateTime(t, true);

            depot.LastReportDate = time;
            _depotRepository.Update(depot);
        }
Exemplo n.º 4
0
        private List <RouteArticleCDto> GetArticles(int routeId, int workerId)
        {
            List <RouteArticleCDto> ret = new List <RouteArticleCDto>();
            var articles = _routeArticleRepository.GetAllIncluding(x => x.ArticleRecord).Where(x => x.RouteId == routeId && x.RouteWorkerId == workerId).ToList();

            foreach (var a in articles)
            {
                var article = WorkManager.GetArticle(a.ArticleRecord.ArticleId);
                ret.Add(new RouteArticleCDto(article, a.ArticleRecordId, a.ArticleRecord.ReturnTime.HasValue));
            }
            return(ret);
        }
Exemplo n.º 5
0
        public async Task <List <SigninDto> > GetSigninsAsync(DateTime carryoutDate)
        {
            int depotId = WorkManager.GetWorkerDepotId(await GetCurrentUserWorkerIdAsync());
            var query   = _signinRepository.GetAllIncluding(x => x.Worker);

            query = query.Where(x => x.CarryoutDate == carryoutDate && x.DepotId == depotId);
            var entities = await AsyncQueryableExecuter.ToListAsync(query);

            entities.Sort((a, b) => a.Worker.Cn.CompareTo(b.Worker.Cn));
            // var list = entities.Distinct(new LambdaEqualityComparer<Signin>((a, b) => a.Worker.Cn == b.Worker.Cn)).ToList();
            return(ObjectMapper.Map <List <SigninDto> >(entities));
        }
Exemplo n.º 6
0
        public List <RouteCacheItem> GetCachedRoutes(int wpId, DateTime carryoutDate, int depotId, int affairId)
        {
            var depots = WorkManager.GetShareDepots(wpId);
            var ret    = new List <RouteCacheItem>();

            foreach (var depot in depots)
            {
                var lst = _routeCache.Get(carryoutDate, depot);
                lst.Sort((a, b) => a.StartTime.CompareTo(b.StartTime));
                ret.AddRange(lst);
            }
            return(ret);
        }
Exemplo n.º 7
0
        private (string, string) GetWorkersInfo(AffairCacheItem affair)
        {
            string info = null;
            string cns  = null;

            foreach (var aw in affair.Workers)
            {
                var worker = WorkManager.GetWorker(aw.WorkerId);
                cns  += worker.Cn;
                info += string.Format("{0} ", worker.Name);
            }
            return(info, cns);
        }
Exemplo n.º 8
0
        public string GetVehiclePhoto(int id)
        {
            var v = WorkManager.GetVehicle(id);

            if (v.Photo != null)
            {
                return(Convert.ToBase64String(v.Photo));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public string GetAgentString()
        {
            int    workerId = GetCurrentUserWorkerIdAsync().Result;
            int    depotId  = WorkManager.GetWorkerDepotId(workerId);
            string agentCn  = WorkManager.GetDepot(depotId).AgentCn;
            var    worker   = WorkManager.GetWorkerByCn(agentCn);

            if (worker == null)
            {
                return(null);
            }
            return(string.Format("{0} {1}", worker.Cn, worker.Name));
        }
Exemplo n.º 10
0
        public string GetMyPhoto(int id)
        {
            var worker = WorkManager.GetWorker(id);

            if (worker.Photo != null)
            {
                return(Convert.ToBase64String(worker.Photo));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 11
0
        public void SetReportTime(string depotName)
        {
            var d = WorkManager.GetDepotByName(depotName);

            if (d == null)
            {
                return;
            }

            var depot = _depotRepository.Get(d.Id);

            depot.LastReportDate = DateTime.Now;
            _depotRepository.Update(depot);
        }
Exemplo n.º 12
0
        public SimpleWorkerDto GetWorkerByRfid(string rfid)
        {
            var worker = WorkManager.GetWorkerByRfid(rfid);

            if (worker != null)
            {
                return new SimpleWorkerDto()
                       {
                           Name = string.Format("{0} {1}", worker.Cn, worker.Name)
                       }
            }
            ;
            return(null);
        }
Exemplo n.º 13
0
        public (bool, string) SigninByRfid(string rfid)
        {
            int    depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);
            Worker worker  = WorkManager.GetWorkerByRfid(rfid);

            if (worker == null)
            {
                return(false, "找不到此人");
            }
            if (worker.DepotId != depotId)
            {
                return(false, "此人不应在此运作中心签到");
            }

            return(WorkManager.DoSignin(depotId, worker.Id, "刷卡"));
        }
Exemplo n.º 14
0
        public AffairWorkDto FindDutyAffair()
        {
            var dto      = new AffairWorkDto();
            int workerId = GetCurrentUserWorkerIdAsync().Result;

            dto.DepotId = WorkManager.GetWorker(workerId).DepotId;
            var affair = WorkManager.FindDutyAffairByWorkerId(workerId);

            if (affair == null)
            {
                return(dto);
            }

            var wp = WorkManager.GetWorkplace(affair.WorkplaceId);

            return(dto.SetAffair(affair, wp.Name, false));
        }
Exemplo n.º 15
0
        public List <ComboboxItemDto> GetLeaders()
        {
            var leaders = WorkManager.GetWorkersByDefaultWorkRoleName("公司领导");
            var lst     = new List <ComboboxItemDto>();

            if (leaders != null)
            {
                foreach (var w in leaders)
                {
                    lst.Add(new ComboboxItemDto {
                        Value = w.Id.ToString(), DisplayText = $"{w.Cn} {w.Name}"
                    });
                }
            }

            return(lst);
        }
Exemplo n.º 16
0
        public MeDto GetMe()
        {
            int workerId = GetCurrentUserWorkerIdAsync().Result;

            if (workerId == 0)
            {
                return(new MeDto("system", "", "", 0));
            }

            if (WorkManager.WorkerHasDefaultWorkRoleName(workerId, "队长"))
            {
                workerId = WorkManager.GetCaptainOrAgentId(workerId);
            }

            var worker = WorkManager.GetWorker(workerId);

            return(new MeDto(worker.LoginRoleNames, worker.Cn, worker.Name, worker.DepotId));
        }
Exemplo n.º 17
0
        private List <RouteArticleCDto> GetArticles(string strList)
        {
            List <RouteArticleCDto> ret = new List <RouteArticleCDto>();
            var articles = strList.Split(',');

            foreach (var a in articles)
            {
                if (a.Length == 0)
                {
                    continue;
                }

                var article = WorkManager.GetArticle(a.Split(' ')[0]);
                if (article != null)
                {
                    ret.Add(new RouteArticleCDto(article, 0, false));
                }
            }
            return(ret);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        public (bool, string) CheckinByRfid(string rfid, DateTime carryoutDate, int depotId, int affairId)
        {
            Worker worker = WorkManager.GetWorkerByRfid(rfid);

            if (worker == null)
            {
                return(false, "找不到此人");
            }
            var aw = WorkManager.GetCacheAffairWorker(carryoutDate, depotId, affairId, worker.Id);

            if (aw.Item2 == null)
            {
                return(false, "此人没被安排在此任务中");
            }
            if (!ClcUtils.NowInTimeZone(aw.Item1.StartTime, aw.Item1.EndTime))
            {
                return(false, "没在任务时段");
            }
            WorkManager.DoCheckin(aw.Item1, aw.Item2, worker.Id);
            return(true, "刷卡验入成功");
        }
Exemplo n.º 20
0
        public AffairWorkDto GetMyCheckinAffair()
        {
            var dto      = new AffairWorkDto();
            int workerId = GetCurrentUserWorkerIdAsync().Result;

            dto.DepotId = WorkManager.GetWorkerDepotId(workerId);

            var affair = WorkManager.FindCheckinAffairByWorkerId(workerId);

            if (affair == null)
            {
                return(dto);
            }
            var wp = WorkManager.GetWorkplace(affair.WorkplaceId);

            var ret = GetWorkersInfo(affair);

            dto.Workers   = ret.Item1;
            dto.WorkerCns = ret.Item2;
            return(dto.SetAffair(affair, wp.Name, false));
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        public (bool, string) CheckinByFinger(string finger, int workerId, DateTime carryoutDate, int depotId, int affairId)
        {
            var mR = WorkManager.MatchFinger(finger, workerId);

            if (!mR.Item1)
            {
                return(mR);
            }

            var aw = WorkManager.GetCacheAffairWorker(carryoutDate, depotId, affairId, workerId);

            if (aw.Item2 == null)
            {
                return(false, "此人没被安排在此任务中");
            }
            if (!ClcUtils.NowInTimeZone(aw.Item1.StartTime, aw.Item1.EndTime))
            {
                return(false, "没在任务时段");
            }
            WorkManager.DoCheckin(aw.Item1, aw.Item2, workerId);
            return(true, "验入成功!" + mR.Item2);
        }
Exemplo n.º 23
0
        public (bool, string) SigninByFinger(string finger)
        {
            int    depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);
            int    score   = 0;
            string index   = null;
            Worker worker  = WorkManager.GetWorkerByFinger(depotId, finger, ref index, ref score);

            if (worker == null)
            {
                return(false, "找不到此人");
            }

            var ret = WorkManager.DoSignin(depotId, worker.Id, "指纹");

            if (ret.Item1)
            {
                return(true, ret.Item2 + string.Format("({0},得分{1})", index, score));
            }
            else
            {
                return(ret);
            }
        }
Exemplo n.º 24
0
        public List <TempArticleDto> GetTempArticles(int affairId)
        {
            List <TempArticleDto> dtos = new List <TempArticleDto>();
            var es = WorkManager.GetTempArticles(affairId);

            foreach (var s in es.Item1)
            {
                var dto = ObjectMapper.Map <TempArticleDto>(s);

                var routeInfo = dto.Issurer.Split(',')[0];
                foreach (var t in es.Item2)
                {
                    if (t.Issurer.Contains(routeInfo))
                    {
                        dto.TakeTime = t.EventTime;
                    }
                }

                dtos.Add(dto);
            }

            return(dtos);
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        public TaskReportDto GetTaskReportData()
        {
            var data = new TaskReportDto();

            // Route
            int depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);
            var routes  = _routeCache.Get(DateTime.Now.Date, depotId);
            int count   = 0;

            foreach (var r in routes)
            {
                count += r.Workers.Count;
            }
            data.Route = new CountPair(routes.Count, count);

            // Affair
            var ret = WorkManager.GetAffairReportData(DateTime.Now.Date, depotId);

            data.Affair = new CountPair(ret.Item1, ret.Item2);

            // Task (fee)
            var query = _routeTaskRepository.GetAllIncluding(x => x.Route, x => x.Outlet, x => x.Outlet.Customer, x => x.TaskType)
                        .Where(x => x.Route.CarryoutDate == DateTime.Now.Date && x.Route.DepotId == depotId && x.TaskType.isTemporary == true);

            data.Tasks = ObjectMapper.Map <List <TemporaryTaskDto> >(query.ToList());

            var fee = 0;

            foreach (var t in data.Tasks)
            {
                fee += t.Price.HasValue ? (int)t.Price : t.TaskTypeBasicPrice;
            }
            data.Task = new CountPair(data.Tasks.Count, fee);

            return(data);
        }
Exemplo n.º 27
0
        public bool AllowCardWhenCheckin()
        {
            int depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);

            return(WorkManager.GetDepot(depotId).AllowCardWhenCheckin);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        public (bool, string) ConfirmByFinger(string finger, int workerId)
        {
            var ret = WorkManager.MatchFinger(finger, workerId);

            return(ret);
        }
Exemplo n.º 30
0
        public (string, string) GetReportToManagers()
        {
            int depotId = WorkManager.GetWorkerDepotId(GetCurrentUserWorkerIdAsync().Result);

            return(WorkManager.GetDepot(depotId).Name, WorkManager.GetReportToManagers(depotId));
        }