合并
This commit is contained in:
@@ -135,7 +135,7 @@ namespace WMS.Web.Repositories
|
||||
public async Task<List<UcStockResponse>> GetUcStockAsync(string systemCode, string name, int companyId)
|
||||
{
|
||||
var result = await _singleDataService.GetSysConfigData<ResultList<UcStockResponse>, SystemCodeRequest>
|
||||
(new SystemCodeRequest(systemCode,name, companyId),
|
||||
(new SystemCodeRequest(systemCode, name, companyId),
|
||||
SysConfigAction.GetWmsWarehouseBySystemCodeAndNameAndCompany);
|
||||
if (!result.Success)
|
||||
return null;
|
||||
@@ -168,7 +168,42 @@ namespace WMS.Web.Repositories
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据总公司获取仓位
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<UcStockHeadOfficeResponse>> GetUcStockByHeadOfficeAsync(string name, int companyId)
|
||||
{
|
||||
var result = await _singleDataService.GetSysConfigData<ResultList<UcStockHeadOfficeResponse>, SystemCodeRequest>
|
||||
(new SystemCodeRequest("", name, companyId),
|
||||
SysConfigAction.GetWmsWarehouseByHeadOfficeAndNameAndCompany);
|
||||
if (!result.Success)
|
||||
return null;
|
||||
return result.Data.Where(w => w.ManagementSystem != null).ToList();
|
||||
|
||||
|
||||
//List<UcStockHeadOfficeResponse> list = new List<UcStockHeadOfficeResponse>();
|
||||
//list.Add(new UcStockHeadOfficeResponse()
|
||||
//{
|
||||
// ManagementSystem = 1,
|
||||
// Code = "CK001",
|
||||
// ErpOrgCode = "101"
|
||||
//});
|
||||
//list.Add(new UcStockHeadOfficeResponse()
|
||||
//{
|
||||
// ManagementSystem = 1,
|
||||
// Code = "AD",
|
||||
// ErpOrgCode = "101"
|
||||
//});
|
||||
//list.Add(new UcStockHeadOfficeResponse()
|
||||
//{
|
||||
// ManagementSystem = 2,
|
||||
// Code = "CK002",
|
||||
// ErpOrgCode = "101",
|
||||
// WarehouseCodeOfJushuitan = "ORICO_JD"
|
||||
//});
|
||||
//return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,8 +414,16 @@ namespace WMS.Web.Repositories.Configuration
|
||||
.SetValueComparer(valueComparer); ;
|
||||
});
|
||||
|
||||
//成品即时库存
|
||||
builder.Entity<ProductInventory>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_product_inventory");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
public DbSet<ProductInventory> ProductInventory { get; set; }
|
||||
public DbSet<Materials> Materials { get; set; }
|
||||
public DbSet<BoxMarkBillNo> BoxMarkBillNo { get; set; }
|
||||
public DbSet<BoxMark> BoxMark { get; set; }
|
||||
|
||||
@@ -182,7 +182,10 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.Configure<EmailOptions>(Configuration.GetSection("EmailOptions"));
|
||||
Services.AddOptions<SmsOptions>();
|
||||
Services.Configure<SmsOptions>(Configuration.GetSection("SmsOptions"));
|
||||
|
||||
Services.AddOptions<lingXingOptions>();
|
||||
Services.Configure<lingXingOptions>(Configuration.GetSection("LingXingOptions"));
|
||||
Services.AddOptions<JuShuiTanOptions>();
|
||||
Services.Configure<JuShuiTanOptions>(Configuration.GetSection("JuShuiTanOptions"));
|
||||
|
||||
|
||||
}
|
||||
@@ -200,6 +203,7 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<MaterialsQuartzJob>();//添加注入定时服务
|
||||
Services.AddTransient<ErpDeleteQuartzJob>();//添加注入定时服务
|
||||
//Services.AddTransient<OrderContractQuartzJob>();//添加注入定时服务
|
||||
Services.AddTransient<InventoryQuartzJob>();//添加注入定时服务
|
||||
Services.AddQuartz(q =>
|
||||
{
|
||||
q.UsePersistentStore(x =>
|
||||
@@ -298,6 +302,18 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
||||
.WithDescription("ErpDeleteQuartzJobTriggerDecs"));
|
||||
#endregion
|
||||
|
||||
#region 成品即时库存
|
||||
var jobKey_Inventory = new JobKey("InventoryQuartzJob", options.QuartzJobValue);
|
||||
q.AddJob<InventoryQuartzJob>(jobKey_Inventory, j => j.WithDescription("InventoryQuartzJob"));
|
||||
q.AddTrigger(t => t
|
||||
.WithIdentity("InventoryQuartzJobTrigger")
|
||||
.ForJob(jobKey_Inventory)
|
||||
.StartNow()
|
||||
.WithCronSchedule(options.JobStartProductInventory)
|
||||
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
||||
.WithDescription("InventoryQuartzJobTriggerDecs"));
|
||||
#endregion
|
||||
});
|
||||
//.net core核心托管-添加Quartz服务器
|
||||
Services.AddQuartzServer(options =>
|
||||
@@ -345,8 +361,10 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<ISendMessageService, SendMessageService>();
|
||||
Services.AddTransient<IMaterialService, MaterialService>();
|
||||
Services.AddTransient<IRedisConcurrentProcessService, RedisConcurrentProcessService>();
|
||||
|
||||
|
||||
Services.AddTransient<ILingXingService, LingXingService>();
|
||||
Services.AddTransient<IProductInventoryService, ProductInventoryService>();
|
||||
Services.AddTransient<IJuShuiTanService, JuShuiTanService>();
|
||||
Services.AddTransient<IErpInventoryService, ErpInventoryService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Dto.MoveBoxRecord;
|
||||
using WMS.Web.Core.Dto.OutStock;
|
||||
using WMS.Web.Core.Dto.OutStockTask;
|
||||
using WMS.Web.Core.Dto.ProductInventory;
|
||||
using WMS.Web.Core.Dto.TakeStock;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Repositories;
|
||||
@@ -57,6 +58,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddTransient<IAllFielRepositories<InventoryInOutDetailsQueryRequest>, InventoryInOutDetailsRepositories>();
|
||||
services.AddTransient<IAllFielRepositories<BoxInventoryQueryRequest>, BoxInventoryRepositories>();
|
||||
services.AddTransient<IAllFielRepositories<BackRecordQueryRequest>, BackRecordRepositories>();
|
||||
services.AddTransient<IAllFielRepositories<ProductInventoryQueryRequest>, ProductInventoryRepositories>();
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -81,7 +83,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddTransient<IMaterialsRepositories, MaterialsRepositories>();
|
||||
|
||||
services.AddTransient<ISubscribeNotificationRepositories, SubscribeNotificationRepositories>();
|
||||
|
||||
services.AddTransient<IProductInventoryRepositories, ProductInventoryRepositories>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
string[] pathlist = path.Split('/');
|
||||
bool isLogin = pathlist.Where(x => x == "login" || x.ToLower() == "heart"
|
||||
|| x.ToLower() == "test" || x.ToLower() == "serialnumber" || x.ToLower() == "barcode" ||
|
||||
x.ToLower() == "swagger").Any();
|
||||
x.ToLower() == "swagger" || x.ToLower() == "productinventory").Any();
|
||||
if (isLogin)
|
||||
{
|
||||
context.Response.StatusCode = 200;
|
||||
|
||||
230
src/WMS.Web.Repositories/ProductInventoryRepositories.cs
Normal file
230
src/WMS.Web.Repositories/ProductInventoryRepositories.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.Erp.Customer;
|
||||
using WMS.Web.Core.Dto.Erp.Org;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.ProductInventory;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
using WMS.Web.Core.Dto.OutStockTask;
|
||||
using WMS.Web.Domain.Values.Single;
|
||||
using WMS.Web.Core;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Core.Help;
|
||||
using WMS.Web.Core.Dto.SingleData;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 成品仓即时库存
|
||||
/// </summary>
|
||||
public class ProductInventoryRepositories : IAllFielRepositories<ProductInventoryQueryRequest>, IProductInventoryRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ILoginRepositories _loginRepositories;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
private readonly RepositoryDbContext _context;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
|
||||
public ProductInventoryRepositories(RepositoryDbContext context,
|
||||
IMapper mapper,
|
||||
IErpService erpService,
|
||||
IBasicsRepositories basicsRepositories,
|
||||
ILoginRepositories loginRepositories,
|
||||
IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
{
|
||||
_erpService = erpService;
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_serviceProvider = serviceProvider;
|
||||
_loginRepositories = loginRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||
}
|
||||
|
||||
public async Task<bool> AddRange(List<ProductInventory> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.ProductInventory.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(ProductInventoryType type, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var list = await _context.ProductInventory.Where(w => w.Type == type).ToListAsync();
|
||||
_context.RemoveRange(list);
|
||||
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(List<ProductInventoryQueryResponse> list, int total, List<decimal> details)> GetListAsync(ProductInventoryQueryRequest dto, int companyId = 0)
|
||||
{
|
||||
//因为要开放给别的系统用 固定死
|
||||
companyId = 1;
|
||||
//if (companyId == 0)
|
||||
// companyId = _loginRepositories.CompanyId;
|
||||
#region erp基础资料
|
||||
List<string> mNumber = new List<string>();
|
||||
var materials_result = await _erpService.BillQueryForMaterial();
|
||||
List<ErpMaterialDto> materials = new List<ErpMaterialDto>();
|
||||
if (materials_result.IsSuccess)
|
||||
materials = materials_result.Data.ToList();
|
||||
//物料集合;模糊查询后的物料集合
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
{
|
||||
if (materials != null)
|
||||
mNumber = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)
|
||||
|| w.MaterialName.Contains(dto.MaterialNumber)
|
||||
|| w.Specifications.Contains(dto.MaterialNumber)
|
||||
).Select(s => s.MaterialNumber).ToList();
|
||||
}
|
||||
|
||||
//取组织
|
||||
var org_result = await _erpService.BillQueryForOrg();
|
||||
List<ErpOrgDto> orgs = new List<ErpOrgDto>();
|
||||
if (org_result.IsSuccess)
|
||||
orgs = org_result.Data.ToList();
|
||||
|
||||
var p_stocks = await _basicsRepositories.GetUcStockByHeadOfficeAsync("", 1);
|
||||
#endregion
|
||||
|
||||
var query = _context.ProductInventory
|
||||
.OrderByDescending(o => o.Id)
|
||||
.Where(adv => 1 == 1 && (adv.Qty > 0 || adv.BeforeQty > 0));
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
query = query.Where(w => mNumber.Contains(w.MaterialNumber));
|
||||
if (!string.IsNullOrEmpty(dto.Customer))
|
||||
query = query.Where(w => dto.Customer.Contains(w.Customer));
|
||||
if (!string.IsNullOrEmpty(dto.StockCode))
|
||||
{
|
||||
var split = dto.StockCode.Split("_$");
|
||||
query = query.Where(w => w.StockCode == split[0] && w.OrgCode == split[1]);
|
||||
}
|
||||
|
||||
//组装
|
||||
int total = await query.CountAsync();
|
||||
decimal qty = await query.SumAsync(s => s.Qty);
|
||||
decimal beforeQty = await query.SumAsync(s => s.BeforeQty);
|
||||
List<decimal> details = new List<decimal>();
|
||||
details.Add(qty);
|
||||
details.Add(beforeQty);
|
||||
var list = await query.Select(s => new ProductInventoryQueryResponse()
|
||||
{
|
||||
#region dto组装
|
||||
Id = s.Id,
|
||||
Type = s.Type.GetRemark(),
|
||||
Stock = _erpBasicDataExtendService.GetProductInventoryStockName(p_stocks, s.StockCode),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.OrgCode),
|
||||
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber),
|
||||
MaterialNumber = s.MaterialNumber,
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber),
|
||||
Batch = s.Batch,
|
||||
Customer = s.Customer,
|
||||
Qty = s.Qty,
|
||||
BeforeQty = s.BeforeQty
|
||||
#endregion
|
||||
|
||||
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
return (list, total, details);
|
||||
}
|
||||
|
||||
public async Task<(object obj, int total)> GetListField(ProductInventoryQueryRequest dto, int companyId)
|
||||
{
|
||||
var (list, count, qty) = await GetListAsync(dto, companyId);
|
||||
return (list, count);
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量修改
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditEntityList(List<ProductInventory> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||
|
||||
var res = await _context.ProductInventory
|
||||
.Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
|
||||
_mapper.ToMapList(entitys, res);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取数据
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProductInventory>> GetEntityList(ProductInventoryType type)
|
||||
{
|
||||
var res = await _context.ProductInventory
|
||||
.Where(f => f.Type == type)
|
||||
.ToListAsync();
|
||||
|
||||
return res.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user