schangxiang@126.com
2024-09-06 cb212ea9a9b56540a7fec33f4ec198f59a99020a
iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs
@@ -2,6 +2,7 @@
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using iWare.Wms.Core;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
@@ -20,8 +21,8 @@
    /// <summary>
    /// 外部访问接口日志
    /// </summary>
    //[ApiDescriptionSettings("外部访问接口日志", Name = "AccessInterfaceLog", Order = 100)]
    //[Route("api/[Controller]")]
    [ApiDescriptionSettings("外部访问接口日志", Name = "AccessInterfaceLog", Order = 100)]
    [Route("api/[Controller]")]
    public class AccessInterfaceLogService : IAccessInterfaceLogService, IDynamicApiController, ITransient
    {
        private readonly IRepository<AccessInterfaceLog, MasterDbContextLocator> _accessInterfaceLogRep;
@@ -35,6 +36,28 @@
            _accessInterfaceLogRep = accessInterfaceLogRep;
        }
        [HttpGet("page")]
        public async Task<PageResult<AddAccessInterfaceLogOutnput>> Page([FromQuery] AccessInterfaceLogInputSearch input)
        {
            var workPieceOutbounds = await _accessInterfaceLogRep.DetachedEntities
                                     .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.WorkPieceID.Contains(input.WorkPieceID))
                                     .Where(!string.IsNullOrEmpty(input.WorkingProcedureCurrent), u => u.WorkingProcedureCurrent.Contains(input.WorkingProcedureCurrent))
                                     .Where(!string.IsNullOrEmpty(input.createdUserName), u => u.CreatedUserName.Contains(input.createdUserName))
                                     .Where(input.QualityState != null, u => u.QualityState == input.QualityState)
                                     .Where(!string.IsNullOrEmpty(input.StartTimeBeginTime.ToString()), u => u.CreatedTime >= input.StartTimeBeginTime)
                                     .Where(!string.IsNullOrEmpty(input.StartTimeEndTime.ToString()), u => u.CreatedTime <= input.StartTimeEndTime)
                                     //.OrderBy(PageInputOrder.OrderBuilder<AccessInterfaceLogInputSearch>(input))
                                     .OrderByDescending(x => x.Id)
                                     .ProjectToType<AddAccessInterfaceLogOutnput>()
                                     .ToADPagedListAsync(input.PageNo, input.PageSize);
            return workPieceOutbounds;
        }
        /// <summary>
        /// 添加日志
        /// </summary>
@@ -44,7 +67,12 @@
        public async Task AddInterfaceLogAsync(AddAccessInterfaceLogInput input)
        {
            AccessInterfaceLog log = new();
            log.Id=input.Id;
            log.WorkPieceID = input.WorkPieceID;
            log.WorkingProcedureCurrent = input.WorkingProcedureCurrent;
            log.QualityState = input.QualityState;
            log.Id = input.Id;
            log.ParaJSON = input.JsonString;
            log.Action = input.Action;
            log.IPAddress = input.IpAddress;
@@ -112,7 +140,7 @@
                //    }
                //}
                //log.Keys = string.Join(", ", keys);
                if(input.Result.GetType().Name.Equals("String"))
                if (input.Result.GetType().Name.Equals("String"))
                {
                    log.ResultJson = input.Result.ToString();