diff --git a/Admin.NET/Admin.NET.Application/Entity/DistributorInvoice.cs b/Admin.NET/Admin.NET.Application/Entity/DistributorInvoice.cs new file mode 100644 index 0000000..c2230d7 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Entity/DistributorInvoice.cs @@ -0,0 +1,46 @@ +using Admin.NET.Core; +namespace Admin.NET.Application.Entity; + +/// +/// 分销出库 +/// +[SugarTable("DistributorInvoice","分销出库")] +public class DistributorInvoice : EntityTenant +{ + /// + /// 仓库ID + /// + [SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")] + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + [SugarColumn(ColumnName = "TargetWarehouseId", ColumnDescription = "目标仓库ID")] + public long? TargetWarehouseId { get; set; } + + /// + /// 分销商ID + /// + [SugarColumn(ColumnName = "DistributorId", ColumnDescription = "分销商ID")] + public long? DistributorId { get; set; } + + /// + /// 分销商 + /// + [SugarColumn(ColumnName = "Distributor", ColumnDescription = "分销商", Length = 32)] + public string? Distributor { get; set; } + + /// + /// 业务日期 + /// + [SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")] + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)] + public string? Remarks { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Entity/Invoice.cs b/Admin.NET/Admin.NET.Application/Entity/Invoice.cs index f50918f..37d57e9 100644 --- a/Admin.NET/Admin.NET.Application/Entity/Invoice.cs +++ b/Admin.NET/Admin.NET.Application/Entity/Invoice.cs @@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity; /// /// 发货通知单 /// -[SugarTable("Invoice","发货通知单")] +[SugarTable("invoice","发货通知单")] public class Invoice : EntityTenant { /// @@ -22,18 +22,21 @@ public class Invoice : EntityTenant /// /// 业务类型 /// + [Required] [SugarColumn(ColumnName = "BusinessType", ColumnDescription = "业务类型", Length = 32)] public string BusinessType { get; set; } /// /// 客户 /// + [Required] [SugarColumn(ColumnName = "Custom", ColumnDescription = "客户", Length = 32)] public string Custom { get; set; } /// /// 仓库 /// + [Required] [SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 32)] public string Warehouse { get; set; } @@ -97,4 +100,10 @@ public class Invoice : EntityTenant [SugarColumn(ColumnName = "SendOutExpand", ColumnDescription = "发货拓展", Length = 32)] public string? SendOutExpand { get; set; } + /// + /// 仓库ID + /// + [SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")] + public long? WarehouseId { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Entity/Outbound.cs b/Admin.NET/Admin.NET.Application/Entity/Outbound.cs index 40c07d2..bef9fcb 100644 --- a/Admin.NET/Admin.NET.Application/Entity/Outbound.cs +++ b/Admin.NET/Admin.NET.Application/Entity/Outbound.cs @@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity; /// /// 出库单 /// -[SugarTable("Outbound","出库单")] +[SugarTable("outbound","出库单")] public class Outbound : EntityTenant { /// @@ -16,15 +16,10 @@ public class Outbound : EntityTenant /// /// 来源单号 /// + [Required] [SugarColumn(ColumnName = "SourceCodeNum", ColumnDescription = "来源单号", Length = 32)] public string SourceCodeNum { get; set; } - /// - /// 业务日期 - /// - [SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期", Length = 32)] - public string? StartDate { get; set; } - /// /// 状态 /// @@ -40,15 +35,10 @@ public class Outbound : EntityTenant /// /// 收货单位 /// + [Required] [SugarColumn(ColumnName = "Consignee", ColumnDescription = "收货单位", Length = 32)] public string Consignee { get; set; } - /// - /// 仓库 - /// - [SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库")] - public string? Warehouse { get; set; } - /// /// 审核人ID /// @@ -67,4 +57,22 @@ public class Outbound : EntityTenant [SugarColumn(ColumnName = "OutboundExpandString", ColumnDescription = "出库单字符串拓展字段", Length = 64)] public string? OutboundExpandString { get; set; } + /// + /// 仓库 + /// + [SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 255)] + public string? Warehouse { get; set; } + + /// + /// 业务日期 + /// + [SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")] + public DateTime? StartDate { get; set; } + + /// + /// 仓库ID + /// + [SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")] + public long? WarehouseId { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Entity/OutboundDetail.cs b/Admin.NET/Admin.NET.Application/Entity/OutboundDetail.cs new file mode 100644 index 0000000..b4a4d7c --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Entity/OutboundDetail.cs @@ -0,0 +1,23 @@ +using Admin.NET.Core; +namespace Admin.NET.Application.Entity; + +/// +/// 出库详细 +/// +[SugarTable("OutboundDetail","出库详细")] +public class OutboundDetail : EntityBaseId +{ + /// + /// 出库单ID + /// + [SugarColumn(ColumnName = "OutboundId", ColumnDescription = "出库单ID")] + public long? OutboundId { get; set; } + + /// + /// 条码ID列表 + /// + [SugarColumn(ColumnName = "CodeTableIds", ColumnDescription = "条码ID列表", ColumnDataType = StaticConfig.CodeFirst_BigString)] + [Required] + public string? CodeTableIds { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs index 0a887da..2c87e72 100644 --- a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs +++ b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs @@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity; /// /// 打印条码详情 /// -[SugarTable("PrintCodeDetail","打印条码详情")] +[SugarTable("printcodedetail","打印条码详情")] public class PrintCodeDetail : EntityBase { /// @@ -97,4 +97,10 @@ public class PrintCodeDetail : EntityBase [SugarColumn(ColumnName = "FatherId", ColumnDescription = "父节点ID")] public long? FatherId { get; set; } + /// + /// 物料ID + /// + [SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")] + public long? MaterialsId { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Entity/WarehouseTransfer.cs b/Admin.NET/Admin.NET.Application/Entity/WarehouseTransfer.cs new file mode 100644 index 0000000..6480e56 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Entity/WarehouseTransfer.cs @@ -0,0 +1,34 @@ +using Admin.NET.Core; +namespace Admin.NET.Application.Entity; + +/// +/// 调库出库 +/// +[SugarTable("warehousetransfer","调库出库")] +public class WarehouseTransfer : EntityTenant +{ + /// + /// 原仓库ID + /// + [SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "原仓库ID")] + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + [SugarColumn(ColumnName = "TargetWarehouseId", ColumnDescription = "目标仓库ID")] + public long? TargetWarehouseId { get; set; } + + /// + /// 业务日期 + /// + [SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")] + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)] + public string? Remarks { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Service/Distributor/DistributorService.cs b/Admin.NET/Admin.NET.Application/Service/Distributor/DistributorService.cs index 17ebe34..ebc27eb 100644 --- a/Admin.NET/Admin.NET.Application/Service/Distributor/DistributorService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Distributor/DistributorService.cs @@ -114,10 +114,12 @@ public class DistributorService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "List")] public async Task> List() { - return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync(); + return await _rep.AsQueryable().Select().Where(a => !a.IsDelete).ToListAsync(); } + + } diff --git a/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/DistributorInvoiceService.cs b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/DistributorInvoiceService.cs new file mode 100644 index 0000000..9faab6c --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/DistributorInvoiceService.cs @@ -0,0 +1,286 @@ +using Admin.NET.Core.Service; +using Admin.NET.Application.Const; +using Admin.NET.Application.Entity; +using Microsoft.AspNetCore.Http; +namespace Admin.NET.Application; +/// +/// 分销出库服务 +/// +[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)] +public class DistributorInvoiceService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _rep; + private readonly PrintCodeDetailService _codeDetailService; + private readonly ProductRetrospectService _productRetrospect; + private readonly ReportTableService _reportTableService; + private readonly OutboundService _outboundService; + private readonly OutboundDetailService _outboundDetailService; + private readonly UserManager _userManager; + public DistributorInvoiceService(SqlSugarRepository rep, + UserManager userManager, + PrintCodeDetailService codeDetailService, + ReportTableService reportTableService, + OutboundService outboundService, + OutboundDetailService outboundDetailService, + ProductRetrospectService productRetrospect) + { + _rep = rep; + _userManager = userManager; + _codeDetailService = codeDetailService; + _productRetrospect = productRetrospect; + _reportTableService = reportTableService; + _outboundService = outboundService; + _outboundDetailService = outboundDetailService; + } + + /// + /// 分页查询分销出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(DistributorInvoiceInput input) + { + var query = _rep.AsQueryable().Where(a => !a.IsDelete) + .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => + u.Distributor.Contains(input.SearchKey.Trim()) + || u.Remarks.Contains(input.SearchKey.Trim()) + ) + .WhereIF(input.WarehouseId>0, u => u.WarehouseId == input.WarehouseId) + .WhereIF(input.TargetWarehouseId>0, u => u.TargetWarehouseId == input.TargetWarehouseId) + .WhereIF(input.DistributorId>0, u => u.DistributorId == input.DistributorId) + .WhereIF(!string.IsNullOrWhiteSpace(input.Distributor), u => u.Distributor.Contains(input.Distributor.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim())) + .Select(); + if(input.StartDateRange != null && input.StartDateRange.Count >0) + { + DateTime? start= input.StartDateRange[0]; + query = query.WhereIF(start.HasValue, u => u.StartDate > start); + if (input.StartDateRange.Count >1 && input.StartDateRange[1].HasValue) + { + var end = input.StartDateRange[1].Value.AddDays(1); + query = query.Where(u => u.StartDate < end); + } + } + return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加分销出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Add")] + public async Task Add(AddDistributorInvoiceInput input) + { + var entity = input.Adapt(); + await _rep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 删除分销出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Delete")] + public async Task Delete(DeleteDistributorInvoiceInput input) + { + var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); + await _rep.FakeDeleteAsync(entity); //假删除 + //await _rep.DeleteAsync(entity); //真删除 + } + + /// + /// 更新分销出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Update")] + public async Task Update(UpdateDistributorInvoiceInput input) + { + var entity = input.Adapt(); + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 获取分销出库 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "Detail")] + public async Task Detail([FromQuery] QueryByIdDistributorInvoiceInput input) + { + return await _rep.GetFirstAsync(u => u.Id == input.Id); + } + + /// + /// 获取分销出库列表 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "List")] + public async Task> List() + { + return await _rep.AsQueryable().Select().Where(a => !a.IsDelete).ToListAsync(); + } + + + /// + /// 商品出货 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "ShipmentProduct")] + public async Task ShipmentProduct(AddProductCodeInput input) + { + if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + + + var invoice = await Detail(new QueryByIdDistributorInvoiceInput() { Id = input.WarehousingTableId.Value }); + if (invoice == null) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode); + var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode)); + var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList(); + if (repeatCodes == null || repeatCodes.Count < 1) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + + var userId = _userManager.UserId; + var userName = _userManager.RealName; + var addOutbound = new AddOutboundInput() + { + //BusinessType = invoice.BusinessType, + //CodeNum = invoice.CodeNum, + //Consignee = invoice.Consignee, + CreateTime = invoice.CreateTime, + CreateUserId = userId, + CreateUserName = userName, + SourceCodeNum = invoice.Id.ToString(), + StartDate = invoice.StartDate, + State = 0, + //Warehouse = invoice.Warehouse, + WarehouseId = invoice.WarehouseId, + TenantId = invoice.TenantId, + }; + var outbound = await _outboundService.Add(addOutbound); + + + var codeIds = new List(); + var list = new List(); + foreach (var c1 in repeatCodes) + { + codeIds.Add(c1.Id); + c1.WarehouseID = null; + //c1.FatherCode = null; + //c1.FatherId = null; + await _codeDetailService.UpdateByEntity(c1.Adapt()); + list.Add(c1); + var child1 = details.Find(a => a.FatherCode == c1.Code); + if (child1 != null) + { + child1.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child1.Adapt()); + list.Add(child1); + + var child2 = details.Find(a => a.FatherCode == c1.Code); + if (child2 != null) + { + child2.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child2.Adapt()); + list.Add(child2); + + var child3 = details.Find(a => a.FatherCode == c1.Code); + if (child3 != null) + { + child3.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child3.Adapt()); + list.Add(child3); + + var child4 = details.Find(a => a.FatherCode == c1.Code); + if (child4 != null) + { + child4.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child4.Adapt()); + list.Add(child4); + } + } + } + } + + } + + var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound }; + await _outboundDetailService.Add(addOutboundDetail); + + foreach (var item in list) + { + var report = await GetReport(item.ReportTableId); + var retrospect1 = new AddProductRetrospectInput() + { + BaseCount = item.BaseCount, + BaseUnit = item.BaseUnit, + //Batch = report.Batch, + BusinessType = report.ProductType, + CodeType = item.CodeName, + Location = addOutbound.Consignee, + Department = report.ProductionLine, + //WarehouseID = input.WarehouseId, + WarehousingDate = DateTime.Now, + Count = 1, + CreateTime = DateTime.Now, + ScanCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + MaterialsId = report.MaterialsId, + OddNumber = report.OddNumber, + Receipt = "分销出库单", + SourceId = outbound, + Unit = item.Unit, + Name = item.CodeName, + Code = item.Code, + //Destination = invoice.Consignee + }; + await _productRetrospect.Add(retrospect1); + } + + } + + static Dictionary reportDic = new Dictionary(); + private async Task GetReport(long? reportId) + { + if (reportId == null) + { + return new ReportTable(); + } + if (reportDic.ContainsKey(reportId.Value)) + { + return reportDic[reportId.Value]; + } + var report = await _reportTableService.GetBySource(reportId); + if (report == null) + { + return new ReportTable(); + } + else + { + return report; + } + } + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceDto.cs b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceDto.cs new file mode 100644 index 0000000..2183f0f --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceDto.cs @@ -0,0 +1,83 @@ +namespace Admin.NET.Application; + + /// + /// 分销出库输出参数 + /// + public class DistributorInvoiceDto + { + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 分销商ID + /// + public long? DistributorId { get; set; } + + /// + /// 分销商 + /// + public string? Distributor { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + } diff --git a/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceInput.cs b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceInput.cs new file mode 100644 index 0000000..a1453ed --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceInput.cs @@ -0,0 +1,168 @@ +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + + /// + /// 分销出库基础输入参数 + /// + public class DistributorInvoiceBaseInput + { + /// + /// 仓库ID + /// + public virtual long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public virtual long? TargetWarehouseId { get; set; } + + /// + /// 分销商ID + /// + public virtual long? DistributorId { get; set; } + + /// + /// 分销商 + /// + public virtual string? Distributor { get; set; } + + /// + /// 业务日期 + /// + public virtual DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + /// + /// 租户Id + /// + public virtual long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public virtual long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public virtual string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public virtual long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public virtual string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public virtual bool IsDelete { get; set; } + + } + + /// + /// 分销出库分页查询输入参数 + /// + public class DistributorInvoiceInput : BasePageInput + { + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 分销商ID + /// + public long? DistributorId { get; set; } + + /// + /// 分销商 + /// + public string? Distributor { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 业务日期范围 + /// + public List StartDateRange { get; set; } + /// + /// 备注 + /// + public string? Remarks { get; set; } + + } + + /// + /// 分销出库增加输入参数 + /// + public class AddDistributorInvoiceInput : DistributorInvoiceBaseInput + { + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + + } + + /// + /// 分销出库删除输入参数 + /// + public class DeleteDistributorInvoiceInput : BaseIdInput + { + } + + /// + /// 分销出库更新输入参数 + /// + public class UpdateDistributorInvoiceInput : DistributorInvoiceBaseInput + { + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + + } + + /// + /// 分销出库主键查询输入参数 + /// + public class QueryByIdDistributorInvoiceInput : DeleteDistributorInvoiceInput + { + + } diff --git a/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceOutput.cs b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceOutput.cs new file mode 100644 index 0000000..a414f5d --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/DistributorInvoice/Dto/DistributorInvoiceOutput.cs @@ -0,0 +1,85 @@ +namespace Admin.NET.Application; + +/// +/// 分销出库输出参数 +/// +public class DistributorInvoiceOutput +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 分销商ID + /// + public long? DistributorId { get; set; } + + /// + /// 分销商 + /// + public string? Distributor { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + } + + diff --git a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceDto.cs b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceDto.cs index ac5ed65..506300c 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceDto.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceDto.cs @@ -1,128 +1,134 @@ namespace Admin.NET.Application; +/// +/// 发货通知单输出参数 +/// +public class InvoiceDto +{ /// - /// 发货通知单输出参数 + /// 主键Id /// - public class InvoiceDto - { - /// - /// 主键Id - /// - public long Id { get; set; } - - /// - /// 单号 - /// - public string? CodeNum { get; set; } - - /// - /// 业务日期 - /// - public DateTime? StartDate { get; set; } - - /// - /// 业务类型 - /// - public string BusinessType { get; set; } - - /// - /// 客户 - /// - public string Custom { get; set; } - - /// - /// 仓库 - /// - public string Warehouse { get; set; } - - /// - /// 部门 - /// - public string? Department { get; set; } - - /// - /// 车牌号 - /// - public string? CarNumber { get; set; } - - /// - /// 停车位 - /// - public string? ParkingSpace { get; set; } - - /// - /// 业务员 - /// - public string? Salesman { get; set; } - - /// - /// 收货单位 - /// - public string? Consignee { get; set; } - - /// - /// 交货日期 - /// - public DateTime? DeliveryDate { get; set; } - - /// - /// 交货地址 - /// - public string? DeliveryAddress { get; set; } - - /// - /// 备注 - /// - public string? Remarks { get; set; } - - /// - /// 方案客户拓展 - /// - public string? CustomExpand { get; set; } - - /// - /// 发货拓展 - /// - public string? SendOutExpand { get; set; } - - /// - /// 租户Id - /// - public long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public string? UpdateUserName { get; set; } - - /// - /// 软删除 - /// - public bool IsDelete { get; set; } - - } + public long Id { get; set; } + + /// + /// 单号 + /// + public string? CodeNum { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 业务类型 + /// + public string BusinessType { get; set; } + + /// + /// 客户 + /// + public string Custom { get; set; } + + /// + /// 仓库 + /// + public string Warehouse { get; set; } + + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 部门 + /// + public string? Department { get; set; } + + /// + /// 车牌号 + /// + public string? CarNumber { get; set; } + + /// + /// 停车位 + /// + public string? ParkingSpace { get; set; } + + /// + /// 业务员 + /// + public string? Salesman { get; set; } + + /// + /// 收货单位 + /// + public string? Consignee { get; set; } + + /// + /// 交货日期 + /// + public DateTime? DeliveryDate { get; set; } + + /// + /// 交货地址 + /// + public string? DeliveryAddress { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 方案客户拓展 + /// + public string? CustomExpand { get; set; } + + /// + /// 发货拓展 + /// + public string? SendOutExpand { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs index e2e26f4..d7ed7c9 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs @@ -3,263 +3,273 @@ using System.ComponentModel.DataAnnotations; namespace Admin.NET.Application; +/// +/// 发货通知单基础输入参数 +/// +public class InvoiceBaseInput +{ /// - /// 发货通知单基础输入参数 + /// 单号 /// - public class InvoiceBaseInput - { - /// - /// 单号 - /// - public virtual string? CodeNum { get; set; } - - /// - /// 业务日期 - /// - public virtual DateTime? StartDate { get; set; } - - /// - /// 业务类型 - /// - public virtual string BusinessType { get; set; } - - /// - /// 客户 - /// - public virtual string Custom { get; set; } - - /// - /// 仓库 - /// - public virtual string Warehouse { get; set; } - - /// - /// 部门 - /// - public virtual string? Department { get; set; } - - /// - /// 车牌号 - /// - public virtual string? CarNumber { get; set; } - - /// - /// 停车位 - /// - public virtual string? ParkingSpace { get; set; } - - /// - /// 业务员 - /// - public virtual string? Salesman { get; set; } - - /// - /// 收货单位 - /// - public virtual string? Consignee { get; set; } - - /// - /// 交货日期 - /// - public virtual DateTime? DeliveryDate { get; set; } - - /// - /// 交货地址 - /// - public virtual string? DeliveryAddress { get; set; } - - /// - /// 备注 - /// - public virtual string? Remarks { get; set; } - - /// - /// 方案客户拓展 - /// - public virtual string? CustomExpand { get; set; } - - /// - /// 发货拓展 - /// - public virtual string? SendOutExpand { get; set; } - - /// - /// 租户Id - /// - public virtual long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public virtual DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public virtual DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public virtual long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public virtual string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public virtual long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public virtual string? UpdateUserName { get; set; } - - /// - /// 软删除 - /// - public virtual bool IsDelete { get; set; } - - } + public virtual string? CodeNum { get; set; } /// - /// 发货通知单分页查询输入参数 + /// 业务日期 /// - public class InvoiceInput : BasePageInput - { - /// - /// 关键字查询 - /// - public string? SearchKey { get; set; } - - /// - /// 单号 - /// - public string? CodeNum { get; set; } - - /// - /// 业务日期 - /// - public DateTime? StartDate { get; set; } - - /// - /// 业务日期范围 - /// - public List StartDateRange { get; set; } - /// - /// 业务类型 - /// - public string? BusinessType { get; set; } - - /// - /// 客户 - /// - public string? Custom { get; set; } - - /// - /// 仓库 - /// - public string? Warehouse { get; set; } - - /// - /// 部门 - /// - public string? Department { get; set; } - - /// - /// 车牌号 - /// - public string? CarNumber { get; set; } - - /// - /// 停车位 - /// - public string? ParkingSpace { get; set; } - - /// - /// 业务员 - /// - public string? Salesman { get; set; } - - /// - /// 收货单位 - /// - public string? Consignee { get; set; } - - /// - /// 交货日期 - /// - public DateTime? DeliveryDate { get; set; } - - /// - /// 交货日期范围 - /// - public List DeliveryDateRange { get; set; } - /// - /// 交货地址 - /// - public string? DeliveryAddress { get; set; } - - } + public virtual DateTime? StartDate { get; set; } /// - /// 发货通知单增加输入参数 + /// 业务类型 /// - public class AddInvoiceInput : InvoiceBaseInput - { - /// - /// 业务类型 - /// - [Required(ErrorMessage = "业务类型不能为空")] - public override string BusinessType { get; set; } - - /// - /// 客户 - /// - [Required(ErrorMessage = "客户不能为空")] - public override string Custom { get; set; } - - /// - /// 仓库 - /// - [Required(ErrorMessage = "仓库不能为空")] - public override string Warehouse { get; set; } - - /// - /// 软删除 - /// - [Required(ErrorMessage = "软删除不能为空")] - public override bool IsDelete { get; set; } - - } + public virtual string BusinessType { get; set; } /// - /// 发货通知单删除输入参数 + /// 客户 /// - public class DeleteInvoiceInput : BaseIdInput - { - } + public virtual string Custom { get; set; } /// - /// 发货通知单更新输入参数 + /// 仓库 /// - public class UpdateInvoiceInput : InvoiceBaseInput - { - /// - /// 主键Id - /// - [Required(ErrorMessage = "主键Id不能为空")] - public long Id { get; set; } - - } + public virtual string Warehouse { get; set; } /// - /// 发货通知单主键查询输入参数 + /// 仓库ID /// - public class QueryByIdInvoiceInput : DeleteInvoiceInput - { + public long? WarehouseId { get; set; } - } + /// + /// 部门 + /// + public virtual string? Department { get; set; } + + /// + /// 车牌号 + /// + public virtual string? CarNumber { get; set; } + + /// + /// 停车位 + /// + public virtual string? ParkingSpace { get; set; } + + /// + /// 业务员 + /// + public virtual string? Salesman { get; set; } + + /// + /// 收货单位 + /// + public virtual string? Consignee { get; set; } + + /// + /// 交货日期 + /// + public virtual DateTime? DeliveryDate { get; set; } + + /// + /// 交货地址 + /// + public virtual string? DeliveryAddress { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + /// + /// 方案客户拓展 + /// + public virtual string? CustomExpand { get; set; } + + /// + /// 发货拓展 + /// + public virtual string? SendOutExpand { get; set; } + + /// + /// 租户Id + /// + public virtual long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public virtual long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public virtual string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public virtual long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public virtual string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public virtual bool IsDelete { get; set; } + +} + +/// +/// 发货通知单分页查询输入参数 +/// +public class InvoiceInput : BasePageInput +{ + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 单号 + /// + public string? CodeNum { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 业务日期范围 + /// + public List StartDateRange { get; set; } + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 客户 + /// + public string? Custom { get; set; } + + /// + /// 仓库 + /// + public string? Warehouse { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 部门 + /// + public string? Department { get; set; } + + /// + /// 车牌号 + /// + public string? CarNumber { get; set; } + + /// + /// 停车位 + /// + public string? ParkingSpace { get; set; } + + /// + /// 业务员 + /// + public string? Salesman { get; set; } + + /// + /// 收货单位 + /// + public string? Consignee { get; set; } + + /// + /// 交货日期 + /// + public DateTime? DeliveryDate { get; set; } + + /// + /// 交货日期范围 + /// + public List DeliveryDateRange { get; set; } + /// + /// 交货地址 + /// + public string? DeliveryAddress { get; set; } + +} + +/// +/// 发货通知单增加输入参数 +/// +public class AddInvoiceInput : InvoiceBaseInput +{ + /// + /// 业务类型 + /// + [Required(ErrorMessage = "业务类型不能为空")] + public override string BusinessType { get; set; } + + /// + /// 客户 + /// + [Required(ErrorMessage = "客户不能为空")] + public override string Custom { get; set; } + + /// + /// 仓库 + /// + [Required(ErrorMessage = "仓库不能为空")] + public override string Warehouse { get; set; } + + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + +} + +/// +/// 发货通知单删除输入参数 +/// +public class DeleteInvoiceInput : BaseIdInput +{ +} + +/// +/// 发货通知单更新输入参数 +/// +public class UpdateInvoiceInput : InvoiceBaseInput +{ + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + +} + +/// +/// 发货通知单主键查询输入参数 +/// +public class QueryByIdInvoiceInput : DeleteInvoiceInput +{ + +} diff --git a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceOutput.cs b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceOutput.cs index 04d9b41..eab0523 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceOutput.cs @@ -34,7 +34,12 @@ public class InvoiceOutput /// 仓库 /// public string Warehouse { get; set; } - + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + /// /// 部门 /// diff --git a/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs b/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs index 0a590bd..46f9470 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs @@ -2,6 +2,8 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; +using NewLife.Reflection; + namespace Admin.NET.Application; /// /// 发货通知单服务 @@ -10,27 +12,27 @@ namespace Admin.NET.Application; public class InvoiceService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; - private readonly MaterialsService _materialsService; - private readonly SysUnitService _sysUnitService; private readonly PrintCodeDetailService _codeDetailService; private readonly ProductRetrospectService _productRetrospect; private readonly ReportTableService _reportTableService; + private readonly OutboundService _outboundService; + private readonly OutboundDetailService _outboundDetailService; private readonly UserManager _userManager; public InvoiceService(SqlSugarRepository rep, UserManager userManager, - MaterialsService materialsService, - SysUnitService sysUnitService, PrintCodeDetailService codeDetailService, ReportTableService reportTableService, + OutboundService outboundService, + OutboundDetailService outboundDetailService, ProductRetrospectService productRetrospect) { _rep = rep; _userManager = userManager; - _materialsService = materialsService; - _sysUnitService = sysUnitService; _codeDetailService = codeDetailService; _productRetrospect = productRetrospect; _reportTableService = reportTableService; + _outboundService = outboundService; + _outboundDetailService = outboundDetailService; } /// @@ -168,50 +170,117 @@ public class InvoiceService : IDynamicApiController, ITransient throw Oops.Oh(ErrorCodeEnum.xg1002); } - var repeatCodes = await _codeDetailService.GetRepeat(input.CodeDatas); - + var invoice = await Detail(new QueryByIdInvoiceInput() { Id = input.WarehousingTableId.Value }); if (invoice == null) { throw Oops.Oh(ErrorCodeEnum.xg1002); } + var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode); + var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode)); + var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList(); + if (repeatCodes == null || repeatCodes.Count < 1) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + + var userId = _userManager.UserId; + var userName = _userManager.RealName; + var addOutbound = new AddOutboundInput() + { + BusinessType = invoice.BusinessType, + CodeNum = invoice.CodeNum, + Consignee = invoice.Consignee, + CreateTime = invoice.CreateTime, + CreateUserId = userId, + CreateUserName = userName, + SourceCodeNum = invoice.Id.ToString(), + StartDate = invoice.StartDate, + State = 0, + Warehouse = invoice.Warehouse, + WarehouseId = invoice.WarehouseId, + TenantId = invoice.TenantId, + }; + var outbound = await _outboundService.Add(addOutbound); + var codeIds = new List(); + var list = new List(); + foreach (var c1 in repeatCodes) + { + codeIds.Add(c1.Id); + c1.WarehouseID = null; + //c1.FatherCode = null; + //c1.FatherId = null; + await _codeDetailService.UpdateByEntity(c1.Adapt()); + list.Add(c1); + var child1 = details.Find(a => a.FatherCode == c1.Code); + if (child1!=null) + { + child1.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child1.Adapt()); + list.Add(child1); - //var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId); - //var baseUnit = units.FirstOrDefault().Name; - //var userId = _userManager.UserId; - //var userName = _userManager.RealName; - //var topDatas = input.CodeDatas.FindAll(a => string.IsNullOrEmpty(a.FatherCode)); + var child2 = details.Find(a => a.FatherCode == c1.Code); + if (child2 != null) + { + child2.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child2.Adapt()); + list.Add(child2); - //foreach (var dic in list) - //{ - // var item = dic.Key; - // var retrospect1 = new AddProductRetrospectInput() - // { - // BaseCount = item.BaseCount, - // BaseUnit = baseUnit, - // Batch = warehousing.Batch, - // BusinessType = "生产任务单", - // CodeType = item.CodeName, - // Department = warehousing.ProductionLine, - // //WarehouseID = input.WarehouseId, - // WarehousingDate = DateTime.Now, - // Count = 1, - // CreateTime = DateTime.Now, - // ScanCodeTime = DateTime.Now, - // CreateUserId = userId, - // CreateUserName = userName, - // MaterialsId = dic.Value, - // OddNumber = warehousing.OddNumber, - // Receipt = "汇报单", - // SourceId = warehousing.Id, - // Unit = item.Unit, - // Name = materials.Name, - // Code = item.Code - // };//Destination = warehousing.Supplier, - // await _productRetrospect.Add(retrospect1); - //} + var child3 = details.Find(a => a.FatherCode == c1.Code); + if (child3 != null) + { + child3.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child3.Adapt()); + list.Add(child3); + + var child4 = details.Find(a => a.FatherCode == c1.Code); + if (child4 != null) + { + child4.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child4.Adapt()); + list.Add(child4); + } + } + } + } + + } + + var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound }; + await _outboundDetailService.Add(addOutboundDetail); + + foreach (var item in list) + { + var report = await GetReport(item.ReportTableId); + var retrospect1 = new AddProductRetrospectInput() + { + BaseCount = item.BaseCount, + BaseUnit = item.BaseUnit, + //Batch = report.Batch, + BusinessType = report.ProductType, + CodeType = item.CodeName, + Location=addOutbound.Consignee, + Department = report.ProductionLine, + //WarehouseID = input.WarehouseId, + WarehousingDate = DateTime.Now, + Count = 1, + CreateTime = DateTime.Now, + ScanCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + MaterialsId = report.MaterialsId, + OddNumber = report.OddNumber, + Receipt = "发货通知单", + SourceId = outbound, + Unit = item.Unit, + Name = item.CodeName, + Code = item.Code, + Destination = invoice.Consignee + }; + await _productRetrospect.Add(retrospect1); + } //var report = await _reportTableService.GetBySource(input.WarehousingTableId); //if (report == null) @@ -222,8 +291,27 @@ public class InvoiceService : IDynamicApiController, ITransient } - - + static Dictionary reportDic = new Dictionary(); + private async Task GetReport(long? reportId) + { + if (reportId == null) + { + return new ReportTable(); + } + if (reportDic.ContainsKey(reportId.Value)) + { + return reportDic[reportId.Value]; + } + var report = await _reportTableService.GetBySource(reportId); + if (report == null) + { + return new ReportTable(); + } + else + { + return report; + } + } } diff --git a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundDto.cs b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundDto.cs index d9a5378..b9deac8 100644 --- a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundDto.cs +++ b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundDto.cs @@ -1,103 +1,107 @@ namespace Admin.NET.Application; +/// +/// 出库单输出参数 +/// +public class OutboundDto +{ /// - /// 出库单输出参数 + /// 主键Id /// - public class OutboundDto - { - /// - /// 主键Id - /// - public long Id { get; set; } - - /// - /// 单号 - /// - public string? CodeNum { get; set; } - - /// - /// 来源单号 - /// - public string SourceCodeNum { get; set; } - - /// - /// 业务日期 - /// - public string? StartDate { get; set; } - - /// - /// 状态 - /// - public int? State { get; set; } - - /// - /// 业务类型 - /// - public string? BusinessType { get; set; } - - /// - /// 收货单位 - /// - public string Consignee { get; set; } - - /// - /// 审核人ID - /// - public long? ExaminerId { get; set; } - - /// - /// 出库单整型拓展字段 - /// - public int? OutboundExpandInt { get; set; } - - /// - /// 出库单字符串拓展字段 - /// - public string? OutboundExpandString { get; set; } - - /// - /// 租户Id - /// - public long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public string? UpdateUserName { get; set; } - - /// - /// 软删除 - /// - public bool IsDelete { get; set; } - - /// - /// 仓库 - /// - public string? Warehouse { get; set; } - - } + public long Id { get; set; } + + /// + /// 单号 + /// + public string? CodeNum { get; set; } + + /// + /// 来源单号 + /// + public string SourceCodeNum { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 状态 + /// + public int? State { get; set; } + + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 收货单位 + /// + public string Consignee { get; set; } + + /// + /// 审核人ID + /// + public long? ExaminerId { get; set; } + + /// + /// 出库单整型拓展字段 + /// + public int? OutboundExpandInt { get; set; } + + /// + /// 出库单字符串拓展字段 + /// + public string? OutboundExpandString { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + /// + /// 仓库 + /// + public string? Warehouse { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } +} diff --git a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundInput.cs b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundInput.cs index 2b2930d..539ca64 100644 --- a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundInput.cs @@ -3,198 +3,202 @@ using System.ComponentModel.DataAnnotations; namespace Admin.NET.Application; +/// +/// 出库单基础输入参数 +/// +public class OutboundBaseInput +{ /// - /// 出库单基础输入参数 + /// 单号 /// - public class OutboundBaseInput - { - /// - /// 单号 - /// - public virtual string? CodeNum { get; set; } - - /// - /// 来源单号 - /// - public virtual string SourceCodeNum { get; set; } - - /// - /// 业务日期 - /// - public virtual string? StartDate { get; set; } - - /// - /// 状态 - /// - public virtual int? State { get; set; } - - /// - /// 业务类型 - /// - public virtual string? BusinessType { get; set; } - - /// - /// 收货单位 - /// - public virtual string Consignee { get; set; } - - /// - /// 审核人ID - /// - public virtual long? ExaminerId { get; set; } - - /// - /// 出库单整型拓展字段 - /// - public virtual int? OutboundExpandInt { get; set; } - - /// - /// 出库单字符串拓展字段 - /// - public virtual string? OutboundExpandString { get; set; } - - /// - /// 租户Id - /// - public virtual long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public virtual DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public virtual DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public virtual long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public virtual string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public virtual long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public virtual string? UpdateUserName { get; set; } - - /// - /// 软删除 - /// - public virtual bool IsDelete { get; set; } - - /// - /// 仓库 - /// - public virtual string? Warehouse { get; set; } - - } + public virtual string? CodeNum { get; set; } /// - /// 出库单分页查询输入参数 + /// 来源单号 /// - public class OutboundInput : BasePageInput - { - /// - /// 关键字查询 - /// - public string? SearchKey { get; set; } - - /// - /// 单号 - /// - public string? CodeNum { get; set; } - - /// - /// 来源单号 - /// - public string? SourceCodeNum { get; set; } - - /// - /// 业务日期 - /// - public string? StartDate { get; set; } - - /// - /// 状态 - /// - public int? State { get; set; } - - /// - /// 业务类型 - /// - public string? BusinessType { get; set; } - - /// - /// 收货单位 - /// - public string? Consignee { get; set; } - - /// - /// 审核人ID - /// - public long? ExaminerId { get; set; } - } + public virtual string SourceCodeNum { get; set; } /// - /// 出库单增加输入参数 + /// 业务日期 /// - public class AddOutboundInput : OutboundBaseInput - { - /// - /// 来源单号 - /// - [Required(ErrorMessage = "来源单号不能为空")] - public override string SourceCodeNum { get; set; } - - /// - /// 收货单位 - /// - [Required(ErrorMessage = "收货单位不能为空")] - public override string Consignee { get; set; } - - /// - /// 软删除 - /// - [Required(ErrorMessage = "软删除不能为空")] - public override bool IsDelete { get; set; } - - } + public virtual DateTime? StartDate { get; set; } /// - /// 出库单删除输入参数 + /// 状态 /// - public class DeleteOutboundInput : BaseIdInput - { - } + public virtual int? State { get; set; } /// - /// 出库单更新输入参数 + /// 业务类型 /// - public class UpdateOutboundInput : OutboundBaseInput - { - /// - /// 主键Id - /// - [Required(ErrorMessage = "主键Id不能为空")] - public long Id { get; set; } - - } + public virtual string? BusinessType { get; set; } /// - /// 出库单主键查询输入参数 + /// 收货单位 /// - public class QueryByIdOutboundInput : DeleteOutboundInput - { + public virtual string Consignee { get; set; } - } + /// + /// 审核人ID + /// + public virtual long? ExaminerId { get; set; } + + /// + /// 出库单整型拓展字段 + /// + public virtual int? OutboundExpandInt { get; set; } + + /// + /// 出库单字符串拓展字段 + /// + public virtual string? OutboundExpandString { get; set; } + + /// + /// 租户Id + /// + public virtual long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public virtual long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public virtual string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public virtual long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public virtual string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public virtual bool IsDelete { get; set; } + + /// + /// 仓库 + /// + public virtual string? Warehouse { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } +} + +/// +/// 出库单分页查询输入参数 +/// +public class OutboundInput : BasePageInput +{ + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 单号 + /// + public string? CodeNum { get; set; } + + /// + /// 来源单号 + /// + public string? SourceCodeNum { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 状态 + /// + public int? State { get; set; } + + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 收货单位 + /// + public string? Consignee { get; set; } + + /// + /// 审核人ID + /// + public long? ExaminerId { get; set; } +} + +/// +/// 出库单增加输入参数 +/// +public class AddOutboundInput : OutboundBaseInput +{ + /// + /// 来源单号 + /// + [Required(ErrorMessage = "来源单号不能为空")] + public override string SourceCodeNum { get; set; } + + /// + /// 收货单位 + /// + [Required(ErrorMessage = "收货单位不能为空")] + public override string Consignee { get; set; } + + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + +} + +/// +/// 出库单删除输入参数 +/// +public class DeleteOutboundInput : BaseIdInput +{ +} + +/// +/// 出库单更新输入参数 +/// +public class UpdateOutboundInput : OutboundBaseInput +{ + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + +} + +/// +/// 出库单主键查询输入参数 +/// +public class QueryByIdOutboundInput : DeleteOutboundInput +{ + +} diff --git a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundOutput.cs b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundOutput.cs index 7458f22..65ecf59 100644 --- a/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/Outbound/Dto/OutboundOutput.cs @@ -9,97 +9,102 @@ public class OutboundOutput /// 主键Id /// public long Id { get; set; } - + /// /// 单号 /// public string? CodeNum { get; set; } - + /// /// 来源单号 /// public string SourceCodeNum { get; set; } - + /// /// 业务日期 /// - public string? StartDate { get; set; } - + public DateTime? StartDate { get; set; } + /// /// 状态 /// public int? State { get; set; } - + /// /// 业务类型 /// public string? BusinessType { get; set; } - + /// /// 收货单位 /// public string Consignee { get; set; } - + /// /// 审核人ID /// public long? ExaminerId { get; set; } - + /// /// 出库单整型拓展字段 /// public int? OutboundExpandInt { get; set; } - + /// /// 出库单字符串拓展字段 /// public string? OutboundExpandString { get; set; } - + /// /// 租户Id /// public long? TenantId { get; set; } - + /// /// 创建时间 /// public DateTime? CreateTime { get; set; } - + /// /// 更新时间 /// public DateTime? UpdateTime { get; set; } - + /// /// 创建者Id /// public long? CreateUserId { get; set; } - + /// /// 创建者姓名 /// public string? CreateUserName { get; set; } - + /// /// 修改者Id /// public long? UpdateUserId { get; set; } - + /// /// 修改者姓名 /// public string? UpdateUserName { get; set; } - + /// /// 软删除 /// public bool IsDelete { get; set; } - + /// /// 仓库 /// public string? Warehouse { get; set; } - - } - + + /// + /// 仓库ID + /// + public long? WarehouseId { get; set; } + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/Outbound/OutboundService.cs b/Admin.NET/Admin.NET.Application/Service/Outbound/OutboundService.cs index 6d2da8a..600b00e 100644 --- a/Admin.NET/Admin.NET.Application/Service/Outbound/OutboundService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Outbound/OutboundService.cs @@ -2,6 +2,8 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; +using Nest; + namespace Admin.NET.Application; /// /// 出库单服务 @@ -10,9 +12,13 @@ namespace Admin.NET.Application; public class OutboundService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; - public OutboundService(SqlSugarRepository rep) + private readonly OutboundDetailService _outboundDetailService; + private readonly PrintCodeDetailService _codeDetailService; + public OutboundService(SqlSugarRepository rep, OutboundDetailService outboundDetailService, PrintCodeDetailService codeDetailService) { _rep = rep; + _outboundDetailService = outboundDetailService; + _codeDetailService = codeDetailService; } /// @@ -28,13 +34,11 @@ public class OutboundService : IDynamicApiController, ITransient .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => u.CodeNum.Contains(input.SearchKey.Trim()) || u.SourceCodeNum.Contains(input.SearchKey.Trim()) - || u.StartDate.Contains(input.SearchKey.Trim()) || u.BusinessType.Contains(input.SearchKey.Trim()) || u.Consignee.Contains(input.SearchKey.Trim()) ) .WhereIF(!string.IsNullOrWhiteSpace(input.CodeNum), u => u.CodeNum.Contains(input.CodeNum.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.SourceCodeNum), u => u.SourceCodeNum.Contains(input.SourceCodeNum.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.StartDate), u => u.StartDate.Contains(input.StartDate.Trim())) .WhereIF(input.State>0, u => u.State == input.State) .WhereIF(!string.IsNullOrWhiteSpace(input.BusinessType), u => u.BusinessType.Contains(input.BusinessType.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.Consignee), u => u.Consignee.Contains(input.Consignee.Trim())) @@ -108,7 +112,74 @@ public class OutboundService : IDynamicApiController, ITransient return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync(); } + /// + /// 获取出库单 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "GetOutboundDetail")] + public async Task> GetOutboundDetail([FromQuery] QueryByIdOutboundInput input) + { + var outbound = await _outboundDetailService.GetByOutboundId(input.Id); + if (string.IsNullOrEmpty(outbound.CodeTableIds)) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var result = new List(); + var details = await _codeDetailService.List(); + if (details == null || details.Count < 1) + { + return result; + } + var ids = outbound.CodeTableIds.Split(',').Select(a => Convert.ToInt64(a)).ToList(); + //var printDetails = details.FindAll(a => ids.Contains(a.Id)); + //if (printDetails.Count < 1) + //{ + // return result; + //} + var father = details.FindAll(a => ids.Contains(a.Id)); + foreach (var item in father) + { + var treeData1 = item.Adapt(); + var list1 = details.FindAll(a => a.FatherId == item.Id); + if (list1.Count > 0) + { + treeData1.Children = new List(); + treeData1.HasChildren = false; + foreach (var dt in list1) + { + var list2 = details.FindAll(a => a.FatherId == dt.Id); + var treeData2 = dt.Adapt(); + if (list2.Count > 0) + { + treeData2.Children = new List(); + treeData2.HasChildren = false; + foreach (var dt3 in list2) + { + var list3 = details.FindAll(a => a.FatherId == dt3.Id); + var treeData3 = dt3.Adapt(); + if (list3.Count > 0) + { + treeData3.Children = new List(); + treeData3.HasChildren = false; + foreach (var dt4 in list3) + { + var treeData4 = dt4.Adapt(); + treeData3.Children.Add(treeData4); + } + } + treeData2.Children.Add(treeData3); + } + } + treeData1.Children.Add(treeData2); + } + } + result.Add(treeData1); + } + return result; + } diff --git a/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailDto.cs b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailDto.cs new file mode 100644 index 0000000..1e03cdf --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailDto.cs @@ -0,0 +1,23 @@ +namespace Admin.NET.Application; + + /// + /// 出库详细输出参数 + /// + public class OutboundDetailDto + { + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 出库单ID + /// + public long? OutboundId { get; set; } + + /// + /// 条码ID列表 + /// + public string? CodeTableIds { get; set; } + + } diff --git a/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailInput.cs b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailInput.cs new file mode 100644 index 0000000..054cd9b --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailInput.cs @@ -0,0 +1,78 @@ +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + + /// + /// 出库详细基础输入参数 + /// + public class OutboundDetailBaseInput + { + /// + /// 出库单ID + /// + public virtual long? OutboundId { get; set; } + + /// + /// 条码ID列表 + /// + public virtual string? CodeTableIds { get; set; } + + } + + /// + /// 出库详细分页查询输入参数 + /// + public class OutboundDetailInput : BasePageInput + { + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 出库单ID + /// + public long? OutboundId { get; set; } + + /// + /// 条码ID列表 + /// + public string? CodeTableIds { get; set; } + + } + + /// + /// 出库详细增加输入参数 + /// + public class AddOutboundDetailInput : OutboundDetailBaseInput + { + } + + /// + /// 出库详细删除输入参数 + /// + public class DeleteOutboundDetailInput : BaseIdInput + { + } + + /// + /// 出库详细更新输入参数 + /// + public class UpdateOutboundDetailInput : OutboundDetailBaseInput + { + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + + } + + /// + /// 出库详细主键查询输入参数 + /// + public class QueryByIdOutboundDetailInput : DeleteOutboundDetailInput + { + + } diff --git a/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailOutput.cs b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailOutput.cs new file mode 100644 index 0000000..4457321 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/Dto/OutboundDetailOutput.cs @@ -0,0 +1,25 @@ +namespace Admin.NET.Application; + +/// +/// 出库详细输出参数 +/// +public class OutboundDetailOutput +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 出库单ID + /// + public long? OutboundId { get; set; } + + /// + /// 条码ID列表 + /// + public string? CodeTableIds { get; set; } + + } + + diff --git a/Admin.NET/Admin.NET.Application/Service/OutboundDetail/OutboundDetailService.cs b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/OutboundDetailService.cs new file mode 100644 index 0000000..c71c8c1 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/OutboundDetail/OutboundDetailService.cs @@ -0,0 +1,117 @@ +using Admin.NET.Core.Service; +using Admin.NET.Application.Const; +using Admin.NET.Application.Entity; +using Microsoft.AspNetCore.Http; +namespace Admin.NET.Application; +/// +/// 出库详细服务 +/// +[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)] +public class OutboundDetailService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _rep; + public OutboundDetailService(SqlSugarRepository rep) + { + _rep = rep; + } + + /// + /// 分页查询出库详细 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(OutboundDetailInput input) + { + var query = _rep.AsQueryable() + .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => + u.CodeTableIds.Contains(input.SearchKey.Trim()) + ) + .WhereIF(input.OutboundId>0, u => u.OutboundId == input.OutboundId) + .WhereIF(!string.IsNullOrWhiteSpace(input.CodeTableIds), u => u.CodeTableIds.Contains(input.CodeTableIds.Trim())) + .Select(); + return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加出库详细 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Add")] + public async Task Add(AddOutboundDetailInput input) + { + var entity = input.Adapt(); + await _rep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 删除出库详细 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Delete")] + public async Task Delete(DeleteOutboundDetailInput input) + { + var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); + //await _rep.FakeDeleteAsync(entity); //假删除 + await _rep.DeleteAsync(entity); //真删除 + } + + /// + /// 更新出库详细 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Update")] + public async Task Update(UpdateOutboundDetailInput input) + { + var entity = input.Adapt(); + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 获取出库详细 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "Detail")] + public async Task Detail([FromQuery] QueryByIdOutboundDetailInput input) + { + return await _rep.GetFirstAsync(u => u.Id == input.Id); + } + + /// + /// 获取出库详细列表 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "List")] + public async Task> List() + { + return await _rep.AsQueryable().Select().ToListAsync(); + } + + /// + /// 获取出库详细 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "GetByOutboundId")] + public async Task GetByOutboundId(long? outboundId) + { + return await _rep.GetFirstAsync(u => u.OutboundId == outboundId); + } + + + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs index 0e2b06f..6d58d34 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs @@ -70,6 +70,11 @@ public class PrintCodeDetailOutput /// public long? FatherId { get; set; } + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + /// /// 打码时间 /// diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseDetails/WarehouseDetailsService.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseDetails/WarehouseDetailsService.cs index 59f8cd3..3e1d89c 100644 --- a/Admin.NET/Admin.NET.Application/Service/WarehouseDetails/WarehouseDetailsService.cs +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseDetails/WarehouseDetailsService.cs @@ -10,9 +10,18 @@ namespace Admin.NET.Application; public class WarehouseDetailsService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; - public WarehouseDetailsService(SqlSugarRepository rep) + private readonly PrintCodeDetailService _codeDetailService; + private readonly MaterialsService _materialsService; + private readonly SysUnitService _sysUnitService; + public WarehouseDetailsService(SqlSugarRepository rep, + PrintCodeDetailService codeDetailService, + MaterialsService materialsService, + SysUnitService sysUnitService) { _rep = rep; + _codeDetailService = codeDetailService; + _materialsService = materialsService; + _sysUnitService = sysUnitService; } /// @@ -153,6 +162,21 @@ public class WarehouseDetailsService : IDynamicApiController, ITransient return await _rep.AsQueryable().Select().ToListAsync(); } + /// + /// 获取仓库库存 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "GetInventory")] + public async Task GetInventory([FromQuery] QueryByIdWarehousingInput input) + { + var codeDetails = await _codeDetailService.List(); + var warehousingCodes = codeDetails.FindAll(a => a.WarehouseID == null || a.WarehouseID < 1); + + + throw new NotImplementedException(); + } } diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferDto.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferDto.cs new file mode 100644 index 0000000..44a40ca --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferDto.cs @@ -0,0 +1,73 @@ +namespace Admin.NET.Application; + + /// + /// 调库出库输出参数 + /// + public class WarehouseTransferDto + { + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 原仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + } diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferInput.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferInput.cs new file mode 100644 index 0000000..6353c33 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferInput.cs @@ -0,0 +1,148 @@ +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + + /// + /// 调库出库基础输入参数 + /// + public class WarehouseTransferBaseInput + { + /// + /// 原仓库ID + /// + public virtual long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public virtual long? TargetWarehouseId { get; set; } + + /// + /// 业务日期 + /// + public virtual DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + /// + /// 租户Id + /// + public virtual long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public virtual long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public virtual string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public virtual long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public virtual string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public virtual bool IsDelete { get; set; } + + } + + /// + /// 调库出库分页查询输入参数 + /// + public class WarehouseTransferInput : BasePageInput + { + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 原仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 业务日期范围 + /// + public List StartDateRange { get; set; } + /// + /// 备注 + /// + public string? Remarks { get; set; } + + } + + /// + /// 调库出库增加输入参数 + /// + public class AddWarehouseTransferInput : WarehouseTransferBaseInput + { + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + + } + + /// + /// 调库出库删除输入参数 + /// + public class DeleteWarehouseTransferInput : BaseIdInput + { + } + + /// + /// 调库出库更新输入参数 + /// + public class UpdateWarehouseTransferInput : WarehouseTransferBaseInput + { + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + + } + + /// + /// 调库出库主键查询输入参数 + /// + public class QueryByIdWarehouseTransferInput : DeleteWarehouseTransferInput + { + + } diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferOutput.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferOutput.cs new file mode 100644 index 0000000..9fbf1e0 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/Dto/WarehouseTransferOutput.cs @@ -0,0 +1,75 @@ +namespace Admin.NET.Application; + +/// +/// 调库出库输出参数 +/// +public class WarehouseTransferOutput +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 原仓库ID + /// + public long? WarehouseId { get; set; } + + /// + /// 目标仓库ID + /// + public long? TargetWarehouseId { get; set; } + + /// + /// 业务日期 + /// + public DateTime? StartDate { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + } + + diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs new file mode 100644 index 0000000..9b2cf8e --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs @@ -0,0 +1,284 @@ +using Admin.NET.Core.Service; +using Admin.NET.Application.Const; +using Admin.NET.Application.Entity; +using Microsoft.AspNetCore.Http; +namespace Admin.NET.Application; +/// +/// 调库出库服务 +/// +[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)] +public class WarehouseTransferService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _rep; + private readonly PrintCodeDetailService _codeDetailService; + private readonly ProductRetrospectService _productRetrospect; + private readonly ReportTableService _reportTableService; + private readonly OutboundService _outboundService; + private readonly OutboundDetailService _outboundDetailService; + private readonly UserManager _userManager; + public WarehouseTransferService(SqlSugarRepository rep, + UserManager userManager, + PrintCodeDetailService codeDetailService, + ReportTableService reportTableService, + OutboundService outboundService, + OutboundDetailService outboundDetailService, + ProductRetrospectService productRetrospect) + { + _rep = rep; + _userManager = userManager; + _codeDetailService = codeDetailService; + _productRetrospect = productRetrospect; + _reportTableService = reportTableService; + _outboundService = outboundService; + _outboundDetailService = outboundDetailService; + } + + /// + /// 分页查询调库出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(WarehouseTransferInput input) + { + var query = _rep.AsQueryable().Where(a => !a.IsDelete) + .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => + u.Remarks.Contains(input.SearchKey.Trim()) + ) + .WhereIF(input.WarehouseId>0, u => u.WarehouseId == input.WarehouseId) + .WhereIF(input.TargetWarehouseId>0, u => u.TargetWarehouseId == input.TargetWarehouseId) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim())) + .Select(); + if(input.StartDateRange != null && input.StartDateRange.Count >0) + { + DateTime? start= input.StartDateRange[0]; + query = query.WhereIF(start.HasValue, u => u.StartDate > start); + if (input.StartDateRange.Count >1 && input.StartDateRange[1].HasValue) + { + var end = input.StartDateRange[1].Value.AddDays(1); + query = query.Where(u => u.StartDate < end); + } + } + return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加调库出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Add")] + public async Task Add(AddWarehouseTransferInput input) + { + var entity = input.Adapt(); + await _rep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 删除调库出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Delete")] + public async Task Delete(DeleteWarehouseTransferInput input) + { + var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); + await _rep.FakeDeleteAsync(entity); //假删除 + //await _rep.DeleteAsync(entity); //真删除 + } + + /// + /// 更新调库出库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Update")] + public async Task Update(UpdateWarehouseTransferInput input) + { + var entity = input.Adapt(); + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 获取调库出库 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "Detail")] + public async Task Detail([FromQuery] QueryByIdWarehouseTransferInput input) + { + return await _rep.GetFirstAsync(u => u.Id == input.Id); + } + + /// + /// 获取调库出库列表 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "List")] + public async Task> List() + { + return await _rep.AsQueryable().Select().Where(a => !a.IsDelete).ToListAsync(); + } + + + /// + /// 商品出货 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "ShipmentProduct")] + public async Task ShipmentProduct(AddProductCodeInput input) + { + if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + + + var invoice = await Detail(new QueryByIdWarehouseTransferInput() { Id = input.WarehousingTableId.Value }); + if (invoice == null) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode); + var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode)); + var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList(); + if (repeatCodes == null || repeatCodes.Count < 1) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + + var userId = _userManager.UserId; + var userName = _userManager.RealName; + var addOutbound = new AddOutboundInput() + { + //BusinessType = invoice.BusinessType, + //CodeNum = invoice.CodeNum, + //Consignee = invoice.Consignee, + CreateTime = invoice.CreateTime, + CreateUserId = userId, + CreateUserName = userName, + SourceCodeNum = invoice.Id.ToString(), + StartDate = invoice.StartDate, + State = 0, + //Warehouse = invoice.Warehouse, + WarehouseId = invoice.WarehouseId, + TenantId = invoice.TenantId, + }; + var outbound = await _outboundService.Add(addOutbound); + + + var codeIds = new List(); + var list = new List(); + foreach (var c1 in repeatCodes) + { + codeIds.Add(c1.Id); + c1.WarehouseID = null; + //c1.FatherCode = null; + //c1.FatherId = null; + await _codeDetailService.UpdateByEntity(c1.Adapt()); + list.Add(c1); + var child1 = details.Find(a => a.FatherCode == c1.Code); + if (child1 != null) + { + child1.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child1.Adapt()); + list.Add(child1); + + var child2 = details.Find(a => a.FatherCode == c1.Code); + if (child2 != null) + { + child2.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child2.Adapt()); + list.Add(child2); + + var child3 = details.Find(a => a.FatherCode == c1.Code); + if (child3 != null) + { + child3.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child3.Adapt()); + list.Add(child3); + + var child4 = details.Find(a => a.FatherCode == c1.Code); + if (child4 != null) + { + child4.WarehouseID = null; + await _codeDetailService.UpdateByEntity(child4.Adapt()); + list.Add(child4); + } + } + } + } + + } + + var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound }; + await _outboundDetailService.Add(addOutboundDetail); + + foreach (var item in list) + { + var report = await GetReport(item.ReportTableId); + var retrospect1 = new AddProductRetrospectInput() + { + BaseCount = item.BaseCount, + BaseUnit = item.BaseUnit, + //Batch = report.Batch, + BusinessType = report.ProductType, + CodeType = item.CodeName, + Location = addOutbound.Consignee, + Department = report.ProductionLine, + //WarehouseID = input.WarehouseId, + WarehousingDate = DateTime.Now, + Count = 1, + CreateTime = DateTime.Now, + ScanCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + MaterialsId = report.MaterialsId, + OddNumber = report.OddNumber, + Receipt = "调库出库单", + SourceId = outbound, + Unit = item.Unit, + Name = item.CodeName, + Code = item.Code, + //Destination = invoice.Consignee + }; + await _productRetrospect.Add(retrospect1); + } + + } + + static Dictionary reportDic = new Dictionary(); + private async Task GetReport(long? reportId) + { + if (reportId == null) + { + return new ReportTable(); + } + if (reportDic.ContainsKey(reportId.Value)) + { + return reportDic[reportId.Value]; + } + var report = await _reportTableService.GetBySource(reportId); + if (report == null) + { + return new ReportTable(); + } + else + { + return report; + } + } + + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/Warehousing/WarehousingService.cs b/Admin.NET/Admin.NET.Application/Service/Warehousing/WarehousingService.cs index 8860658..0a41207 100644 --- a/Admin.NET/Admin.NET.Application/Service/Warehousing/WarehousingService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Warehousing/WarehousingService.cs @@ -105,7 +105,6 @@ public class WarehousingService : IDynamicApiController, ITransient /// /// 获取入库单列表 /// - /// /// [HttpGet] [ApiDescriptionSettings(Name = "List")] @@ -116,7 +115,5 @@ public class WarehousingService : IDynamicApiController, ITransient - - } diff --git a/Web/.env.development b/Web/.env.development index d854af8..78ced16 100644 --- a/Web/.env.development +++ b/Web/.env.development @@ -2,4 +2,4 @@ ENV = development # 本地环境接口地址http://localhost:5005 http://139.199.191.197:9005 -VITE_API_URL = http://139.199.191.197:9005 \ No newline at end of file +VITE_API_URL = http://localhost:5005 \ No newline at end of file diff --git a/Web/src/api/main/distributor.ts b/Web/src/api/main/distributor.ts index 495413e..cfadab2 100644 --- a/Web/src/api/main/distributor.ts +++ b/Web/src/api/main/distributor.ts @@ -5,6 +5,7 @@ enum Api { UpdateDistributor = '/api/distributor/update', PageDistributor = '/api/distributor/page', DetailDistributor = '/api/distributor/detail', + ListDistributor = '/api/distributor/list', } // 增加分销商 @@ -39,6 +40,14 @@ export const pageDistributor = (params?: any) => data: params, }); +// 列表分销商 +export const listDistributor = () => + request({ + url: Api.ListDistributor, + method: 'get', + data: { }, + }); + // 详情分销商 export const detailDistributor = (id: any) => request({ diff --git a/Web/src/api/main/distributorInvoice.ts b/Web/src/api/main/distributorInvoice.ts new file mode 100644 index 0000000..ab10974 --- /dev/null +++ b/Web/src/api/main/distributorInvoice.ts @@ -0,0 +1,59 @@ +import request from '/@/utils/request'; +enum Api { + AddDistributorInvoice = '/api/distributorInvoice/add', + DeleteDistributorInvoice = '/api/distributorInvoice/delete', + UpdateDistributorInvoice = '/api/distributorInvoice/update', + PageDistributorInvoice = '/api/distributorInvoice/page', + DetailDistributorInvoice = '/api/distributorInvoice/detail', + ListDistributorInvoice = '/api/distributorInvoice/list', +} + +// 增加分销出库 +export const addDistributorInvoice = (params?: any) => + request({ + url: Api.AddDistributorInvoice, + method: 'post', + data: params, + }); + +// 删除分销出库 +export const deleteDistributorInvoice = (params?: any) => + request({ + url: Api.DeleteDistributorInvoice, + method: 'post', + data: params, + }); + +// 编辑分销出库 +export const updateDistributorInvoice = (params?: any) => + request({ + url: Api.UpdateDistributorInvoice, + method: 'post', + data: params, + }); + +// 分页查询分销出库 +export const pageDistributorInvoice = (params?: any) => + request({ + url: Api.PageDistributorInvoice, + method: 'post', + data: params, + }); + +// 列表分销出库 +export const listDistributorInvoice = () => + request({ + url: Api.ListDistributorInvoice, + method: 'get', + data: { }, + }); + +// 详情分销出库 +export const detailDistributorInvoice = (id: any) => + request({ + url: Api.DetailDistributorInvoice, + method: 'get', + data: { id }, + }); + + diff --git a/Web/src/api/main/warehouseTransfer.ts b/Web/src/api/main/warehouseTransfer.ts new file mode 100644 index 0000000..7626c30 --- /dev/null +++ b/Web/src/api/main/warehouseTransfer.ts @@ -0,0 +1,59 @@ +import request from '/@/utils/request'; +enum Api { + AddWarehouseTransfer = '/api/warehouseTransfer/add', + DeleteWarehouseTransfer = '/api/warehouseTransfer/delete', + UpdateWarehouseTransfer = '/api/warehouseTransfer/update', + PageWarehouseTransfer = '/api/warehouseTransfer/page', + DetailWarehouseTransfer = '/api/warehouseTransfer/detail', + ListWarehouseTransfer = '/api/warehouseTransfer/list', +} + +// 增加调库出库 +export const addWarehouseTransfer = (params?: any) => + request({ + url: Api.AddWarehouseTransfer, + method: 'post', + data: params, + }); + +// 删除调库出库 +export const deleteWarehouseTransfer = (params?: any) => + request({ + url: Api.DeleteWarehouseTransfer, + method: 'post', + data: params, + }); + +// 编辑调库出库 +export const updateWarehouseTransfer = (params?: any) => + request({ + url: Api.UpdateWarehouseTransfer, + method: 'post', + data: params, + }); + +// 分页查询调库出库 +export const pageWarehouseTransfer = (params?: any) => + request({ + url: Api.PageWarehouseTransfer, + method: 'post', + data: params, + }); + +// 列表调库出库 +export const listWarehouseTransfer = () => + request({ + url: Api.ListWarehouseTransfer, + method: 'get', + data: { }, + }); + +// 详情调库出库 +export const detailWarehouseTransfer = (id: any) => + request({ + url: Api.DetailWarehouseTransfer, + method: 'get', + data: { id }, + }); + + diff --git a/Web/src/views/distributionManagement/distributorInvoice/component/editDialog.vue b/Web/src/views/distributionManagement/distributorInvoice/component/editDialog.vue new file mode 100644 index 0000000..5112947 --- /dev/null +++ b/Web/src/views/distributionManagement/distributorInvoice/component/editDialog.vue @@ -0,0 +1,156 @@ + + + + + + + diff --git a/Web/src/views/distributionManagement/distributorInvoice/index.vue b/Web/src/views/distributionManagement/distributorInvoice/index.vue new file mode 100644 index 0000000..4dc094d --- /dev/null +++ b/Web/src/views/distributionManagement/distributorInvoice/index.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/Web/src/views/inventoryManagement/warehouseTransfer/component/editDialog.vue b/Web/src/views/inventoryManagement/warehouseTransfer/component/editDialog.vue new file mode 100644 index 0000000..2a8c698 --- /dev/null +++ b/Web/src/views/inventoryManagement/warehouseTransfer/component/editDialog.vue @@ -0,0 +1,142 @@ + + + + + + + diff --git a/Web/src/views/inventoryManagement/warehouseTransfer/index.vue b/Web/src/views/inventoryManagement/warehouseTransfer/index.vue new file mode 100644 index 0000000..46049de --- /dev/null +++ b/Web/src/views/inventoryManagement/warehouseTransfer/index.vue @@ -0,0 +1,198 @@ + + + + + diff --git a/Web/src/views/warehouseManagement/warehousingStatistics/index.vue b/Web/src/views/warehouseManagement/warehousingStatistics/index.vue index 11e6318..fc2b655 100644 --- a/Web/src/views/warehouseManagement/warehousingStatistics/index.vue +++ b/Web/src/views/warehouseManagement/warehousingStatistics/index.vue @@ -183,8 +183,6 @@ import { ref } from "vue"; import { ElMessageBox, ElMessage } from "element-plus"; import { auth } from '/@/utils/authFunction'; - import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils'; - import { formatDate } from '/@/utils/formatTime'; import printDialog from '/@/views/labelPrinting/print/component/hiprint/preview.vue'