Пример #1
0
        public async Task <CheckCardTypeModel> CheckCardType(int placeId, int boxId, string cardValue)
        {
            _logger.LogWarning($"--------------开始检查证卡:{cardValue}--------------");
            var card = await _cardRepository.GetQueryable().Where(a => a.Value == cardValue).FirstOrDefaultAsync();

            if (card == null)
            {
                return(new CheckCardTypeModel());
            }
            _logger.LogWarning($"证卡号:{card.Number},证卡值:{card.Value}");
            var user = await _userRepository.GetQueryable().Include(a => a.Department).FirstOrDefaultAsync(a => a.Id == card.UserId);

            _logger.LogWarning($"所属用户:{user.DisplayName}");
            var objects = await _boxObjectRepository.GetQueryable().Where(a => a.BoxId == boxId).ToListAsync();

            var objectSigner = await _objectSignerRepository.GetQueryable().Where(a => objects.Any(b => b.ExchangeObjectId == a.ExchangeObjectId) && a.UserId == user.Id).FirstOrDefaultAsync();

            var checkCardModel = new CheckCardTypeModel
            {
                Boxs = new List <int>
                {
                    boxId
                },
                UserName       = user.DisplayName,
                DepartmentName = user.Department.Name
            };

            if (objectSigner != null)
            {
                checkCardModel.Type = 22;
                _logger.LogWarning($"交换员身份:用户是该流转对象签收人");
            }
            else
            {
                var placeWarden = await _placeWardenRepository.GetQueryable().Where(a => a.PlaceId == placeId && a.UserId == user.Id).FirstOrDefaultAsync();

                if (placeWarden != null)
                {
                    //当前刷卡人为本场所管理员
                    _logger.LogWarning($"管理员身份:当前刷卡人为本场所管理员");
                    checkCardModel.Type = 21;
                }
            }
            _logger.LogWarning($"--------------结束检查证卡--------------");
            return(checkCardModel);
        }
Пример #2
0
        public async Task <ResultEntity> AssignObjectSigner(int objectId, List <int> userIds)
        {
            var result         = new ResultEntity();
            var exchangeObject = await _exchangeObjectRepository.GetByIdAsync(objectId);

            var objectSigners = await _objectSignerRepository.GetQueryable().Include(a => a.ExchangeObject).Include(a => a.User).ThenInclude(a => a.Department).Where(a => a.ExchangeObjectId == objectId).ToListAsync();

            //记录原有数据
            result.Data = new
            {
                OldData = objectSigners.Select(a => a.User).Select(a => new { a.Id, a.UserName, a.DisplayName, a.Department.FullName }),
                NewData = userIds
            };

            if (objectSigners.Count > 0)
            {
                //删除原数据
                foreach (var objectSigner in objectSigners)
                {
                    await _objectSignerRepository.DeleteByIdAsync(objectSigner.Id);
                }
            }

            //添加新数据
            foreach (var useId in userIds)
            {
                var boxObject = new ExchangeObjectSigner
                {
                    ExchangeObjectId = objectId,
                    UserId           = useId
                };
                await _objectSignerRepository.AddAsync(boxObject);
            }

            result.Success = true;
            result.Message = $"流转对象【{exchangeObject.Name}】已成功分配签收人";
            return(result);
        }
Пример #3
0
        public async Task <ResultEntity> GetCheckInfo(int userId, int placeId, DateTime beginTime, DateTime endTime)
        {
            var result      = new ResultEntity();
            var listInfo    = new List <string>();
            var managePlace = await _placeWardenRepository.GetQueryable().Include(a => a.Place).FirstOrDefaultAsync(a => a.UserId == userId);

            var place = await _placeRepository.GetQueryable().Include(a => a.Parent).FirstOrDefaultAsync(a => a.Id == placeId);

            if (managePlace == null)
            {
                result.Message = "非场所管理员,无法使用此功能";
                return(result);
            }

            if (managePlace.PlaceId == placeId)
            {
                if (place.ParentId == null)
                {
                    result.Message = "使用场所错误,无法核销";
                }
                else
                {
                    var objectIds = await _objectSignerRepository.GetQueryable().Where(a => a.UserId == userId)
                                    .Select(a => a.ExchangeObjectId).ToListAsync();

                    var receiveLogs = await _barcodeLogRepository.GetQueryable().Where(a =>
                                                                                       a.BarcodeStatus == EnumBarcodeStatus.已签收 && a.CurrentPlaceId == place.ParentId &&
                                                                                       a.OperationTime.Date >= beginTime.Date && a.OperationTime.Date <= endTime.Date && objectIds.Contains(a.CurrentObjectId)).Select(a => a.BarcodeNumber)
                                      .ToListAsync();

                    listInfo.Add($"场所【{place.Parent.Name}】取件【{receiveLogs.Count}】");
                    var sendLogs = await _barcodeLogRepository.GetQueryable().Where(a =>
                                                                                    a.BarcodeStatus == EnumBarcodeStatus.已投递 && a.CurrentPlaceId == placeId &&
                                                                                    a.OperationTime.Date >= beginTime.Date && a.OperationTime.Date <= endTime.Date && receiveLogs.Contains(a.BarcodeNumber)).Select(a => a.BarcodeNumber).ToListAsync();

                    listInfo.Add($"场所【{place.Name}】投件【{sendLogs.Count}】");
                    listInfo.Add(receiveLogs.Count == sendLogs.Count
                        ? "成功!所有文件已成功投递"
                        : $"警告!{receiveLogs.Count - sendLogs.Count}份文件尚未投递,请查看下方明细!");
                }
            }
            else
            {
                var insideObjects = await _exchangeObjectRepository.GetQueryable()
                                    .Where(a => a.ObjectType == EnumObjectType.道).Select(a => a.Id).ToListAsync();

                var receiveLogs = await _barcodeLogRepository.GetQueryable().Where(a =>
                                                                                   a.BarcodeStatus == EnumBarcodeStatus.已签收 && a.CurrentPlaceId == managePlace.PlaceId &&
                                                                                   a.OperationTime.Date >= beginTime.Date && a.OperationTime.Date <= endTime.Date && insideObjects.Contains(a.CurrentObjectId)).Select(a => a.BarcodeNumber)
                                  .ToListAsync();

                listInfo.Add($"场所【{managePlace.Place.Name}】取件【{receiveLogs.Count}】");
                var sendLogs = await _barcodeLogRepository.GetQueryable().Where(a =>
                                                                                a.BarcodeStatus == EnumBarcodeStatus.已投递 && a.CurrentPlaceId == placeId &&
                                                                                a.OperationTime.Date >= beginTime.Date && a.OperationTime.Date <= endTime.Date &&
                                                                                receiveLogs.Contains(a.BarcodeNumber)).Select(a => a.BarcodeNumber).ToListAsync();

                listInfo.Add($"场所【{place.Name}】投件【{sendLogs.Count}】");
                listInfo.Add(receiveLogs.Count == sendLogs.Count
                    ? "成功!所有文件已成功投递"
                    : $"警告!{receiveLogs.Count - sendLogs.Count}份文件尚未投递,请查看下方明细!");
            }
            result.Success = true;
            result.Data    = listInfo;
            return(result);
        }