Example #1
0
        public IHttpActionResult DoorList(string personId)
        {
            //获取入住信息
            var roomUser   = roomUserService.GetByPersonId(personId);
            var deviceList = new List <RoomUserCardDeviceListDto>();

            if (roomUser != null)
            {
                var cardIds  = userCardService.GetUserCardsByUserID(roomUser.RoomUserUUID);
                var authList = cardAuthService.GetCardAuthList(cardIds);

                foreach (var auth in authList)
                {
                    DoorDto   doorDto   = new DoorDto();
                    DeviceDto deviceDto = new DeviceDto();
                    if (!string.IsNullOrWhiteSpace(auth.DoorUUID))
                    {
                        doorDto = doorService.GetById(auth.DoorUUID);
                        if (!string.IsNullOrWhiteSpace(doorDto.DeviceUUID))
                        {
                            deviceDto = deviceService.GetById(doorDto.DeviceUUID);
                        }
                    }
                    CardDto cardDto = new CardDto();
                    if (!string.IsNullOrWhiteSpace(auth.CardUUID))
                    {
                        cardDto = cardService.GetCardById(auth.CardUUID);
                    }

                    var dto = new RoomUserCardDeviceListDto
                    {
                        CardNo     = cardDto.CardNo,
                        ValidFrom  = cardDto.ValidFrom.Value,
                        ValidTo    = cardDto.ValidTo.Value,
                        DoorType   = doorDto.DoorTypeName,
                        DoorName   = doorDto.DoorName,
                        DoorUUID   = doorDto.DoorUUID,
                        DeviceType = deviceDto.DeviceTypeName,
                        DeviceName = deviceDto.DeviceName,
                        SNNumber   = deviceDto.SNNumber
                    };
                    deviceList.Add(dto);
                }
            }

            return(Ok(new
            {
                code = 0,
                data = deviceList
            }));
        }
Example #2
0
        [HttpGet, Route("Managedevice")] //, RequestAuthorize("sys:auth:device")
        public IHttpActionResult ManageDoorList(string personId, string cardId)
        {
            //获取入住信息
            var manageCard = manageCardService.GetByPersonId(personId);
            var deviceList = new List <RoomUserCardDeviceListDto>();

            if (manageCard != null)
            {
                var cardIds = manageCard.Select(s => s.CardUUID).ToArray();
                if (cardIds == null || !cardIds.Contains(cardId))
                {
                    return(Ok(new
                    {
                        code = 1,
                        msg = "未找到任何权限信息!",

                        data = deviceList
                    }));
                }
                var authList = cardAuthService.GetCardAuthList(cardId);

                foreach (var auth in authList)
                {
                    DoorDto   doorDto   = new DoorDto();
                    DeviceDto deviceDto = new DeviceDto();
                    if (!string.IsNullOrWhiteSpace(auth.DoorUUID))
                    {
                        doorDto = doorService.GetById(auth.DoorUUID);
                        if (!string.IsNullOrWhiteSpace(doorDto.DeviceUUID))
                        {
                            deviceDto = deviceService.GetById(doorDto.DeviceUUID);
                        }
                    }
                    CardDto cardDto = new CardDto();
                    if (!string.IsNullOrWhiteSpace(auth.CardUUID))
                    {
                        cardDto = cardService.GetCardById(auth.CardUUID);
                    }

                    var dto = new RoomUserCardDeviceListDto
                    {
                        CardNo     = cardDto.CardNo,
                        ValidFrom  = cardDto.ValidFrom.Value,
                        ValidTo    = cardDto.ValidTo.Value,
                        DoorType   = doorDto.DoorTypeName,
                        DoorName   = doorDto.DoorName,
                        DoorUUID   = doorDto.DoorUUID,
                        DeviceType = deviceDto.DeviceTypeName,
                        DeviceName = deviceDto.DeviceName,
                        SNNumber   = deviceDto.SNNumber
                    };
                    deviceList.Add(dto);
                }
            }

            return(Ok(new
            {
                code = 0,
                data = deviceList
            }));
        }