This commit is contained in:
tongfei
2023-11-14 14:59:50 +08:00
27 changed files with 1372 additions and 17 deletions

View File

@@ -68,6 +68,11 @@ namespace WMS.Web.Repositories.Configuration
ent.ToTable("t_wms_sync_date");
ent.HasKey(x => x.Id);
});
builder.Entity<FileDownManager>(ent =>
{
ent.ToTable("t_wms_file_down_manager");
ent.HasKey(x => x.Id);
});
#region
@@ -253,6 +258,7 @@ namespace WMS.Web.Repositories.Configuration
base.OnModelCreating(builder);
}
public DbSet<FileDownManager> FileDownManager { get; set; }
public DbSet<SerialNumbers> SerialNumbers { get; set; }
public DbSet<ErpOpsSyncDate> ErpOpsSyncDate { get; set; }
public DbSet<SerialNumberOperate> SerialNumberOperate { get; set; }

View File

@@ -177,6 +177,8 @@ namespace WMS.Web.Repositories.DependencyInjection
Services.Configure<ErpOptions>(Configuration.GetSection("ErpOptions"));
Services.AddOptions<OpsOptions>();
Services.Configure<OpsOptions>(Configuration.GetSection("OpsOptions"));
Services.AddOptions<QiniuOptions>();
Services.Configure<QiniuOptions>(Configuration.GetSection("Qiniu"));
}
/// <summary>
@@ -252,7 +254,8 @@ namespace WMS.Web.Repositories.DependencyInjection
Services.AddTransient<IOpsService, OpsService>();
Services.AddTransient<IErpBasicDataExtendService, ErpBasicDataExtendService>();
Services.AddTransient<IExportExcelService, ExportExcelService>();
Services.AddTransient<IQiniuUploadService, QiniuUploadService>();
Services.AddTransient<IBoxService, BoxService>();

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using WMS.Web.Core.Dto.OutStockTask;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Repositories;
using WMS.Web.Repositories.Configuration;
@@ -36,7 +37,11 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddTransient<IBoxRepositories, BoxRepositories>();
services.AddTransient<IBasicsRepositories, BasicsRepositories>();
services.AddTransient<ITransactionRepositories, TransactionRepositories>();
#region
services.AddTransient<IAllFielRepositories<OutStockTaskQueryRequest>, OutStockTaskRepositories>();
#endregion
services.AddTransient<IInStockRepositories, InStockRepositories>();
services.AddTransient<IInStockTaskRepositories, InStockTaskRepositories>();
@@ -44,7 +49,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddTransient<IInventoryDetailsRepositories, InventoryDetailsRepositories>();
services.AddTransient<IInventoryInOutDetailsRepositories, InventoryInOutDetailsRepositories>();
services.AddTransient<IBoxInventoryRepositories, BoxInventoryRepositories>();
services.AddTransient<IFileDownManagerRepositories, FileDownManagerRepositories>();
services.AddTransient<ISerialNumbersRepositories, SerialNumbersRepositories>();
services.AddTransient<ISerialNumberOperateRepositories, SerialNumberOperateRepositories>();

View File

@@ -0,0 +1,103 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core;
using WMS.Web.Core.Dto;
using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Values;
using WMS.Web.Domain.Values.Single;
using WMS.Web.Repositories.Configuration;
namespace WMS.Web.Repositories
{
public class FileDownManagerRepositories : IFileDownManagerRepositories
{
private readonly IMapper _mapper;
private readonly RepositoryDbContext _context;
private readonly ISingleDataService _singleDataService;
public FileDownManagerRepositories(RepositoryDbContext context, IMapper mapper, ISingleDataService singleDataService)
{
_mapper = mapper;
_context = context;
_singleDataService = singleDataService;
}
public async Task<FileDownManager> Add(FileDownManager entity)
{
await _context.FileDownManager.AddAsync(entity);
await _context.SaveChangesAsync();
return entity;
}
public async Task<FileDownManager> Edit(FileDownManager entity)
{
var res = await _context.FileDownManager
.FirstOrDefaultAsync(f => f.Id == entity.Id);
if (res == null) return null;
_mapper.Map(entity, res);
await _context.SaveChangesAsync();
return res;
}
public async Task<FileDownManagerResponse> GetList(FileDownManagerRequest dto, int companyId)
{
List<int> userIds = new List<int>();
if (!string.IsNullOrEmpty(dto.User))
userIds = _singleDataService.GetIdsBySingleName(SingleAction.Staffs, companyId, dto.User);
var res = _context.FileDownManager
//.GroupJoin(_context.UcStaff, manager => manager.UserId, user => user.Id, (manager, user) => new { manager, user })
// .SelectMany(x => x.user.DefaultIfEmpty(), (d, user) => new { d.manager, user })
.OrderByDescending(o => o.Date)
.Where(w => w.CompanyId == companyId);
#region
if (!string.IsNullOrEmpty(dto.User))
res = res.Where(w => userIds.Contains(w.UserId));
if (dto.BeginDate != null)
res = res.Where(w => w.Date >= dto.BeginDate);
if (dto.EndDate != null)
res = res.Where(w => w.Date <= (dto.EndDate ?? DateTime.Now).AddHours(23).AddMinutes(59).AddSeconds(59));
if (dto.Type != null)
res = res.Where(w => w.Type == (FileDownLoadOrderType)dto.Type);
if (dto.SupplierId != null)
res = res.Where(w => w.SupplierId == dto.SupplierId);
if (dto.Status != null)
{
if ((ExportStatus)dto.Status == ExportStatus.Ing)
res = res.Where(w => w.Status == ExportStatus.Ing && w.Date >= DateTime.Now.AddHours(-1));
else if ((ExportStatus)dto.Status == ExportStatus.Fail)
res = res.Where(w => (w.Status == ExportStatus.Fail) || (w.Status == ExportStatus.Ing && w.Date < DateTime.Now.AddHours(-1)));
else
res = res.Where(w => w.Status == (ExportStatus)dto.Status);
}
#endregion
int total = await res.CountAsync();
var list = await res.Select(s => new FileDownInfoManagerResponse(_mapper.Map<FileDownInfoManagerResponse>(s))
{
StatusKey = (s.Status == ExportStatus.Ing && s.Date < DateTime.Now.AddHours(-1)) ? (int)ExportStatus.Fail : (int)s.Status,
Status = (s.Status == ExportStatus.Ing && s.Date < DateTime.Now.AddHours(-1)) ? ExportStatus.Fail.GetRemark() : s.Status.GetRemark(),
UserName = dto.SupplierId != null
? _singleDataService.GetSingleData(SingleAction.Users, companyId, s.UserId)
: _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.UserId),//s.StaffName
})
.Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize)
.ToListAsync();
return new FileDownManagerResponse(list, total);
}
}
}

View File

@@ -20,7 +20,7 @@ using WMS.Web.Repositories.Configuration;
namespace WMS.Web.Repositories
{
public class OutStockTaskRepositories : IOutStockTaskRepositories
public class OutStockTaskRepositories : IAllFielRepositories<OutStockTaskQueryRequest>, IOutStockTaskRepositories
{
private readonly IMapper _mapper;
private readonly IServiceProvider _serviceProvider;
@@ -425,5 +425,16 @@ namespace WMS.Web.Repositories
.Select(s => s.BillNo)
.ToListAsync();
}
/// <summary>
/// 导出列表
/// </summary>
/// <param name="dto"></param>
/// <param name="companyId"></param>
/// <returns></returns>
public async Task<(object obj, int total)> GetListField(OutStockTaskQueryRequest dto, int companyId)
{
return await GetListAsync(dto);
}
}
}