From 39f87ba916934609ac73e755e419620544618708 Mon Sep 17 00:00:00 2001 From: liangzongpeng <532365025@qq.com> Date: Tue, 2 Jul 2024 11:23:29 +0800 Subject: [PATCH] 0702 --- .../Admin.NET.Application/Entity/Invoice.cs | 6 +- .../Entity/MaterialList.cs | 40 ++++ .../Service/Invoice/Dto/InvoiceInput.cs | 32 ++- .../Service/Invoice/InvoiceService.cs | 98 ++++++--- .../MaterialList/Dto/MaterialListDto.cs | 38 ++++ .../MaterialList/Dto/MaterialListInput.cs | 108 ++++++++++ .../MaterialList/Dto/MaterialListOutput.cs | 40 ++++ .../MaterialList/MaterialListService.cs | 120 +++++++++++ .../PrintCodeDetail/PrintCodeDetailService.cs | 1 + .../ProductRetrospectService.cs | 40 +++- .../ReportDetailTableService.cs | 53 +++-- .../ReportTable/Dto/ReportTableInput.cs | 1 + .../Service/ReportTable/ReportTableService.cs | 15 +- .../WarehouseTransferService.cs | 32 +-- .../WarehousingStatisticsService.cs | 187 +++++------------- Web/src/api/main/materials.ts | 9 + .../invoice/component/editDialog.vue | 153 ++++++++++++-- 17 files changed, 722 insertions(+), 251 deletions(-) create mode 100644 Admin.NET/Admin.NET.Application/Entity/MaterialList.cs create mode 100644 Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListDto.cs create mode 100644 Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListInput.cs create mode 100644 Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListOutput.cs create mode 100644 Admin.NET/Admin.NET.Application/Service/MaterialList/MaterialListService.cs diff --git a/Admin.NET/Admin.NET.Application/Entity/Invoice.cs b/Admin.NET/Admin.NET.Application/Entity/Invoice.cs index 37d57e9..478fde4 100644 --- a/Admin.NET/Admin.NET.Application/Entity/Invoice.cs +++ b/Admin.NET/Admin.NET.Application/Entity/Invoice.cs @@ -24,21 +24,21 @@ public class Invoice : EntityTenant /// [Required] [SugarColumn(ColumnName = "BusinessType", ColumnDescription = "业务类型", Length = 32)] - public string BusinessType { get; set; } + public string? BusinessType { get; set; } /// /// 客户 /// [Required] [SugarColumn(ColumnName = "Custom", ColumnDescription = "客户", Length = 32)] - public string Custom { get; set; } + public string? Custom { get; set; } /// /// 仓库 /// [Required] [SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 32)] - public string Warehouse { get; set; } + public string? Warehouse { get; set; } /// /// 部门 diff --git a/Admin.NET/Admin.NET.Application/Entity/MaterialList.cs b/Admin.NET/Admin.NET.Application/Entity/MaterialList.cs new file mode 100644 index 0000000..fbff537 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Entity/MaterialList.cs @@ -0,0 +1,40 @@ +using Admin.NET.Core; +namespace Admin.NET.Application.Entity; + +/// +/// 物料列表 +/// +[SugarTable("MaterialList","物料列表")] +public class MaterialList : EntityBaseId +{ + /// + /// 物料ID + /// + [SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")] + public long? MaterialsId { get; set; } + + /// + /// 单位 + /// + [SugarColumn(ColumnName = "Unit", ColumnDescription = "单位", Length = 32)] + public string? Unit { get; set; } + + /// + /// 数量 + /// + [SugarColumn(ColumnName = "Count", ColumnDescription = "数量")] + public int? Count { get; set; } + + /// + /// 来源ID + /// + [SugarColumn(ColumnName = "SourceId", ColumnDescription = "来源ID")] + public long? SourceId { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)] + public string? Remarks { 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 d7ed7c9..2f7a0bd 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/Dto/InvoiceInput.cs @@ -21,17 +21,17 @@ public class InvoiceBaseInput /// /// 业务类型 /// - public virtual string BusinessType { get; set; } + public virtual string? BusinessType { get; set; } /// /// 客户 /// - public virtual string Custom { get; set; } + public virtual string? Custom { get; set; } /// /// 仓库 /// - public virtual string Warehouse { get; set; } + public virtual string? Warehouse { get; set; } /// /// 仓库ID @@ -220,30 +220,16 @@ public class InvoiceInput : BasePageInput /// 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 List TableData { get; set; } } /// @@ -264,6 +250,10 @@ public class UpdateInvoiceInput : InvoiceBaseInput [Required(ErrorMessage = "主键Id不能为空")] public long Id { get; set; } + /// + /// 物料列表 + /// + public List TableData { 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 46f9470..1ed0206 100644 --- a/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Invoice/InvoiceService.cs @@ -3,6 +3,7 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; using NewLife.Reflection; +using Nest; namespace Admin.NET.Application; /// @@ -18,13 +19,15 @@ public class InvoiceService : IDynamicApiController, ITransient private readonly OutboundService _outboundService; private readonly OutboundDetailService _outboundDetailService; private readonly UserManager _userManager; + private readonly MaterialListService _materialListService; public InvoiceService(SqlSugarRepository rep, UserManager userManager, PrintCodeDetailService codeDetailService, ReportTableService reportTableService, OutboundService outboundService, OutboundDetailService outboundDetailService, - ProductRetrospectService productRetrospect) + ProductRetrospectService productRetrospect, + MaterialListService materialListService) { _rep = rep; _userManager = userManager; @@ -33,6 +36,7 @@ public class InvoiceService : IDynamicApiController, ITransient _reportTableService = reportTableService; _outboundService = outboundService; _outboundDetailService = outboundDetailService; + _materialListService = materialListService; } /// @@ -102,7 +106,16 @@ public class InvoiceService : IDynamicApiController, ITransient { var entity = input.Adapt(); await _rep.InsertAsync(entity); - return entity.Id; + var id = entity.Id; + if (input.TableData!=null&&input.TableData.Count>0) + { + foreach (var item in input.TableData) + { + item.SourceId = id; + await _materialListService.Add(item); + } + } + return id; } /// @@ -130,6 +143,22 @@ public class InvoiceService : IDynamicApiController, ITransient { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + if (input.TableData != null && input.TableData.Count > 0) + { + var list = await _materialListService.ListBySourceId(input.Id); + if (list!=null) + { + for (int i = 0; i < list.Count; i++) + { + await _materialListService.Delete(new DeleteMaterialListInput() { Id = list[i].Id }); + } + } + foreach (var item in input.TableData) + { + item.SourceId = input.Id; + await _materialListService.Add(item); + } + } } /// @@ -254,32 +283,34 @@ public class InvoiceService : IDynamicApiController, ITransient 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 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); + + await _productRetrospect.AddRetrospect(item.Adapt(), report, "发货通知单", addOutbound.Consignee, outbound, input.WarehousingTableId); } //var report = await _reportTableService.GetBySource(input.WarehousingTableId); @@ -313,5 +344,16 @@ public class InvoiceService : IDynamicApiController, ITransient } } + + /// + /// 获取物料列表列表 + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "MaterialListById")] + public async Task> MaterialListById(long? id) + { + return await _materialListService.ListBySourceId(id); + } } diff --git a/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListDto.cs b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListDto.cs new file mode 100644 index 0000000..436a07f --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListDto.cs @@ -0,0 +1,38 @@ +namespace Admin.NET.Application; + + /// + /// 物料列表输出参数 + /// + public class MaterialListDto + { + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 来源ID + /// + public long? SourceId { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + } diff --git a/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListInput.cs b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListInput.cs new file mode 100644 index 0000000..4924af3 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListInput.cs @@ -0,0 +1,108 @@ +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + + /// + /// 物料列表基础输入参数 + /// + public class MaterialListBaseInput + { + /// + /// 物料ID + /// + public virtual long? MaterialsId { get; set; } + + /// + /// 单位 + /// + public virtual string? Unit { get; set; } + + /// + /// 数量 + /// + public virtual int? Count { get; set; } + + /// + /// 来源ID + /// + public virtual long? SourceId { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + } + + /// + /// 物料列表分页查询输入参数 + /// + public class MaterialListInput : BasePageInput + { + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 来源ID + /// + public long? SourceId { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + } + + /// + /// 物料列表增加输入参数 + /// + public class AddMaterialListInput : MaterialListBaseInput + { + } + + /// + /// 物料列表删除输入参数 + /// + public class DeleteMaterialListInput : BaseIdInput + { + } + + /// + /// 物料列表更新输入参数 + /// + public class UpdateMaterialListInput : MaterialListBaseInput + { + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + + } + + /// + /// 物料列表主键查询输入参数 + /// + public class QueryByIdMaterialListInput : DeleteMaterialListInput + { + + } diff --git a/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListOutput.cs b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListOutput.cs new file mode 100644 index 0000000..60ed24b --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/MaterialList/Dto/MaterialListOutput.cs @@ -0,0 +1,40 @@ +namespace Admin.NET.Application; + +/// +/// 物料列表输出参数 +/// +public class MaterialListOutput +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 来源ID + /// + public long? SourceId { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + } + + diff --git a/Admin.NET/Admin.NET.Application/Service/MaterialList/MaterialListService.cs b/Admin.NET/Admin.NET.Application/Service/MaterialList/MaterialListService.cs new file mode 100644 index 0000000..b355094 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/MaterialList/MaterialListService.cs @@ -0,0 +1,120 @@ +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 MaterialListService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _rep; + public MaterialListService(SqlSugarRepository rep) + { + _rep = rep; + } + + /// + /// 分页查询物料列表 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(MaterialListInput input) + { + var query = _rep.AsQueryable() + .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => + u.Unit.Contains(input.SearchKey.Trim()) + || u.Remarks.Contains(input.SearchKey.Trim()) + ) + .WhereIF(input.MaterialsId>0, u => u.MaterialsId == input.MaterialsId) + .WhereIF(!string.IsNullOrWhiteSpace(input.Unit), u => u.Unit.Contains(input.Unit.Trim())) + .WhereIF(input.Count>0, u => u.Count == input.Count) + .WhereIF(input.SourceId>0, u => u.SourceId == input.SourceId) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim())) + .Select(); + return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加物料列表 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Add")] + public async Task Add(AddMaterialListInput input) + { + var entity = input.Adapt(); + await _rep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 删除物料列表 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Delete")] + public async Task Delete(DeleteMaterialListInput 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(UpdateMaterialListInput input) + { + var entity = input.Adapt(); + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 获取物料列表 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "Detail")] + public async Task Detail([FromQuery] QueryByIdMaterialListInput 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 = "ListBySourceId")] + public async Task> ListBySourceId(long? sourceId) + { + return await _rep.AsQueryable().WhereIF(sourceId > 0, u => u.SourceId == sourceId).Select().ToListAsync(); + } + + + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs index 50682d9..32e2f8d 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs @@ -163,5 +163,6 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient { return await _rep.GetFirstAsync(a => a.Code == productCode); } + } diff --git a/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs index 0f4c3e9..d595536 100644 --- a/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs @@ -151,6 +151,7 @@ public class ProductRetrospectService : IDynamicApiController, ITransient return await _rep.AsQueryable().Select().Where(a => !a.IsDelete).ToListAsync(); } + /// /// 获取商品追溯列表 /// @@ -163,7 +164,42 @@ public class ProductRetrospectService : IDynamicApiController, ITransient return await _rep.AsQueryable().Where(u => !u.IsDelete && u.Code == productCode).Select().ToListAsync(); } - public async Task AddRetrospect(PrintCodeDetail item ,ReportTable report,string receipt, string location ,long? sourceId) + + /// + /// 查询打印条码状态 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "CheckCodeStatus")] + public async Task CheckCodeStatus(string? productCode) + { + var codeEnt = await _rep.AsQueryable().Where(u => !u.IsDelete && u.Code == productCode).Select().ToListAsync(); + if (codeEnt == null || codeEnt.Count<1) + { + return 0; + } + var last = codeEnt.OrderBy(a => a.WarehousingDate).FirstOrDefault(); + var receipt = last.Receipt == null ? "" : last.Receipt; + if (receipt.Contains("汇报单")) + { + return 1; + } + else if (receipt.Contains("仓库")) + { + return 2; + } + else if (receipt.Contains("发货")) + { + return 3; + } + else if (receipt.Contains("分销")) + { + return 3; + } + return 3; + } + public async Task AddRetrospect(PrintCodeDetail item ,ReportTable report,string receipt, string location ,long? sourceId,long? warehousingId) { var userId = _userManager.UserId; var userName = _userManager.RealName; @@ -176,7 +212,7 @@ public class ProductRetrospectService : IDynamicApiController, ITransient CodeType = item.CodeName, Location = location, Department = report.ProductionLine, - //WarehouseID = input.WarehouseId, + WarehouseID = warehousingId, WarehousingDate = DateTime.Now, Count = 1, CreateTime = DateTime.Now, diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs index 6de682f..e7ba1f9 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs @@ -190,6 +190,40 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var userId = _userManager.UserId; var userName = _userManager.RealName; var topDatas = input.CodeDatas.FindAll(a => string.IsNullOrEmpty(a.FatherCode)); + long reprotId = 0; + var report = await _reportTableService.GetBySource(input.WarehousingTableId); + if (report == null) + { + var newReport = new AddReportTableInput() + { + CreateTime = DateTime.Now, + IsDelete = false, + OddNumber = warehousing.OddNumber, + State = 0, + MaterialsId = warehousing.MaterialsId, + SourceId = input.WarehousingTableId, + ProductType = warehousing.ProductType, + ProductionLine = warehousing.ProductionLine, + BaseProductCount = repeatCodes.Count, + ProductCount = repeatCodes.Count, + Batch = warehousing.Batch, + CodeNum = materials.CodeNum, + Name = materials.Name, + CreateUserId = userId, + CreateUserName = userName, + StartDate = DateTime.Now, + SourceNumber = warehousing.SourceNumber, + Unit = warehousing.Unit, + Remarks = warehousing.Remarks + }; + reprotId = await _reportTableService.Add(newReport); + } + else + { + reprotId = report.Id; + } + + Dictionary list = new Dictionary(); foreach (var item in topDatas) { @@ -199,7 +233,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var detail = new AddPrintCodeDetailInput() { - ReportTableId = input.WarehousingTableId, + ReportTableId = reprotId, Code = code, CodeName = codeType, ChildCount = unit.ChildUnitCount, @@ -221,7 +255,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var unit2 = units.Find(a => a.Name == child.PackageName); var detail2 = new AddPrintCodeDetailInput() { - ReportTableId = input.WarehousingTableId, + ReportTableId = reprotId, Code = code2, CodeName = codeType, ChildCount = unit2.ChildUnitCount, @@ -245,7 +279,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var unit3 = units.Find(a => a.Name == child3.PackageName); var detail3 = new AddPrintCodeDetailInput() { - ReportTableId = input.WarehousingTableId, + ReportTableId = reprotId, Code = code3, CodeName = codeType, ChildCount = unit3.ChildUnitCount, @@ -270,7 +304,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var unit4 = units.Find(a => a.Name == child4.PackageName); var detail4 = new AddPrintCodeDetailInput() { - ReportTableId = input.WarehousingTableId, + ReportTableId = reprotId, Code = code4, CodeName = codeType, ChildCount = unit4.ChildUnitCount, @@ -295,7 +329,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var unit5 = units.Find(a => a.Name == child5.PackageName); var detail5 = new AddPrintCodeDetailInput() { - ReportTableId = input.WarehousingTableId, + ReportTableId = reprotId, Code = code5, CodeName = codeType, ChildCount = unit5.ChildUnitCount, @@ -348,14 +382,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient await _productRetrospect.Add(retrospect1); } - var report = await _reportTableService.GetBySource(input.WarehousingTableId); - if (report == null) - { - var newReport = new AddReportTableInput() { CreateTime = DateTime.Now, IsDelete = false, OddNumber = warehousing.OddNumber, State = 0, MaterialsId = warehousing.MaterialsId, SourceId = input.WarehousingTableId, ProductType = warehousing.ProductType, ProductionLine = warehousing.ProductionLine }; - var addReport = await _reportTableService.Add(newReport); - } - - + //var details = await _warehouseDetails.List(); //if (details != null && details.Any(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit)) //{ diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs index 639bf28..865f9e3 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs @@ -229,4 +229,5 @@ public class UpdateReportTableInput : ReportTableBaseInput public class QueryByIdReportTableInput : DeleteReportTableInput { public string? Code { get; set; } + public long? SourceId { get; set; } } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs index f325740..34748ae 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs @@ -117,7 +117,7 @@ public class ReportTableService : IDynamicApiController, ITransient item.ReportTableId = entity.Id; var ent = item.Adapt(); await _codeDetailService.UpdateByEntity(ent); - await _productRetrospectService.AddRetrospect(ent, entity, "汇报单", entity.ProductionLine, entity.Id); + await _productRetrospectService.AddRetrospect(ent, entity, "汇报单", entity.ProductionLine, entity.Id, null); } } @@ -162,7 +162,7 @@ public class ReportTableService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "Detail")] public async Task Detail([FromQuery] QueryByIdReportTableInput input) { - return await _rep.GetFirstAsync(u => u.Id == input.Id); + return await _rep.GetFirstAsync(u => u.Id == input.Id || (input.SourceId > 0 && u.SourceId == input.SourceId)); } /// @@ -261,9 +261,9 @@ public class ReportTableService : IDynamicApiController, ITransient { throw new ArgumentNullException(nameof(unitGroup)); } - var unit = units.Find(a => a.Name == input.Name); + var unit = units.Find(a => a.Name == input.Package); if (unit == null) - throw new ArgumentNullException(nameof(unitGroup)); + throw new ArgumentNullException(nameof(unit)); var newReport = new AddPrintRecordsInput() { CreateTime = DateTime.Now, Unit = input.Package, Name = input.Name, IsDelete = false, Batch = input.Batch, ProductDate = input.ProductDate, LoseDate = input.LoseDate, ProductCount = input.PrintDatas?.Count, MaterialsId = input.MaterialsId }; var addReport = await _printRecordsService.Add(newReport); @@ -292,6 +292,7 @@ public class ReportTableService : IDynamicApiController, ITransient BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, + MaterialsId = input.MaterialsId, CreateUserName = userName }; var detailId = await _codeDetailService.Add(detail); @@ -307,7 +308,7 @@ public class ReportTableService : IDynamicApiController, ITransient foreach (var dt in printDatas) { var code2 = CodeHelper.GetCode(dt.BarCode, dt.QrCode); - var detail2 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code, FatherId = detailId, Code = code2, ChildCount = currUnit.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit.Name, BaseCount = currUnit.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detail2 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code, FatherId = detailId, MaterialsId = input.MaterialsId, Code = code2, ChildCount = currUnit.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit.Name, BaseCount = currUnit.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; var detailId2 = await _codeDetailService.Add(detail2); var treeData2 = detail2.Adapt(); if (tempUnits.Count > 1) @@ -318,7 +319,7 @@ public class ReportTableService : IDynamicApiController, ITransient foreach (var dt3 in printDatas3) { var code3 = CodeHelper.GetCode(dt3.BarCode, dt3.QrCode); - var detail3 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code2, FatherId = detailId2, Code = code3, ChildCount = currUnit3.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit3.Name, BaseCount = currUnit3.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detail3 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code2, FatherId = detailId2, MaterialsId = input.MaterialsId, Code = code3, ChildCount = currUnit3.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit3.Name, BaseCount = currUnit3.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; var detailId3 = await _codeDetailService.Add(detail3); var treeData3 = detail3.Adapt(); if (tempUnits.Count > 2) @@ -329,7 +330,7 @@ public class ReportTableService : IDynamicApiController, ITransient foreach (var dt4 in printDatas4) { var code4 = CodeHelper.GetCode(dt4.BarCode, dt4.QrCode); - var detail4 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code3, FatherId = detailId3, Code = code4, ChildCount = currUnit4.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit4.Name, BaseCount = currUnit4.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detail4 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code3, FatherId = detailId3, MaterialsId = input.MaterialsId, Code = code4, ChildCount = currUnit4.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit4.Name, BaseCount = currUnit4.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; var treeData4 = detail4.Adapt(); treeData3.Children.Add(treeData4); } diff --git a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs index 9b2cf8e..3a1a8c1 100644 --- a/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs +++ b/Admin.NET/Admin.NET.Application/Service/WarehouseTransfer/WarehouseTransferService.cs @@ -2,6 +2,8 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; +using SqlSugar; + namespace Admin.NET.Application; /// /// 调库出库服务 @@ -130,7 +132,7 @@ public class WarehouseTransferService : IDynamicApiController, ITransient /// - /// 商品出货 + /// 商品调库 /// /// /// @@ -227,34 +229,8 @@ public class WarehouseTransferService : IDynamicApiController, ITransient 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); + await _productRetrospect.AddRetrospect(item.Adapt(), report, "调库出库单", "", item.ReportTableId, input.WarehousingTableId); } - } static Dictionary reportDic = new Dictionary(); diff --git a/Admin.NET/Admin.NET.Application/Service/WarehousingStatistics/WarehousingStatisticsService.cs b/Admin.NET/Admin.NET.Application/Service/WarehousingStatistics/WarehousingStatisticsService.cs index b641c04..88174b2 100644 --- a/Admin.NET/Admin.NET.Application/Service/WarehousingStatistics/WarehousingStatisticsService.cs +++ b/Admin.NET/Admin.NET.Application/Service/WarehousingStatistics/WarehousingStatisticsService.cs @@ -2,6 +2,8 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; +using Mapster; + namespace Admin.NET.Application; /// /// 入库统计服务 @@ -13,12 +15,12 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient private readonly WarehouseDetailsService _warehouseDetails; private readonly MaterialsService _materialsService; private readonly SysUnitService _sysUnitService; - private readonly MaterialClassifyService _materialClassifyService; private readonly PrintCodeDetailService _codeDetailService; private readonly ProductRetrospectService _productRetrospect; - //private readonly ProductWarehousingService _productWarehousing; private readonly ReportDetailTableService _reportDetailTable; private readonly UserManager _userManager; + private readonly ReportTableService _reportTableService; + private readonly WarehouseService _warehouseService; public WarehousingStatisticsService(SqlSugarRepository rep, UserManager userManager, @@ -27,8 +29,9 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient SysUnitService sysUnitService, PrintCodeDetailService codeDetailService, ProductRetrospectService productRetrospect, - MaterialClassifyService materialClassifyService, - ReportDetailTableService reportDetailTable) + ReportDetailTableService reportDetailTable, + ReportTableService reportTableService, + WarehouseService warehouseService) { _rep = rep; _userManager = userManager; @@ -37,9 +40,9 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient _sysUnitService = sysUnitService; _codeDetailService = codeDetailService; _productRetrospect = productRetrospect; - _materialClassifyService = materialClassifyService; - //_productWarehousing = productWarehousing; _reportDetailTable = reportDetailTable; + _reportTableService = reportTableService; + _warehouseService = warehouseService; } /// @@ -176,7 +179,9 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient var details = await _warehouseDetails.List(); var userId = _userManager.UserId; var userName = _userManager.RealName; - ReportDetailTable reportTable = null; + ReportTable reportTable = null; + var warehouse = await _warehouseService.Detail(new QueryByIdWarehouseInput() { Id = input.WarehouseId.Value }); + var warehouseName = warehouse == null ? "" : warehouse.Name; foreach (var item in input.CodeDatas) { var product = await _codeDetailService.GetByProductCode(item); @@ -185,16 +190,44 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient continue; } //product.WarehouseID = input.WarehouseId; - reportTable = await _reportDetailTable.Detail(new QueryByIdReportDetailTableInput() { Id = product.ReportTableId.Value }); + reportTable = await _reportTableService.Detail(new QueryByIdReportTableInput() { Id = product.ReportTableId.Value,SourceId=product.ReportTableId }); + if (reportTable==null) + { + var table = await _reportDetailTable.Detail(new QueryByIdReportDetailTableInput() { Id = product.ReportTableId.Value }); + if (table!=null) + { + reportTable = new ReportTable() + { + BaseProductCount = table.BaseProductCount, + Batch = table.Batch, + CodeNum = table.CodeNum, + CreateTime = table.CreateTime, + CreateUser = table.CreateUser, + CreateUserId = table.CreateUserId, + CreateUserName = table.CreateUserName, + MaterialsId = table.MaterialsId, + OddNumber = table.OddNumber, + ProductCount = table.ProductCount, + ProductionLine = table.ProductionLine, + ProductType = table.ProductType, + SourceNumber = table.SourceNumber, + StartDate = table.ProductDate, + Unit = table.Unit, + Remarks = table.Remarks + }; + } + } if (reportTable!=null) { var materials = await _materialsService.GetById(reportTable.MaterialsId); if (materials == null) continue; var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId); - var baseUnit = units.LastOrDefault().Name; + var baseUnit = units.FirstOrDefault().Name; var unit = units.Find(a => a.Name == reportTable.Unit); + if (unit == null) + unit = units.FirstOrDefault(); if (details != null && details.Any(a => a.MaterialsId == reportTable.MaterialsId && a.Unit == reportTable.Unit)) { @@ -214,36 +247,11 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient newEnt.BaseCount = unit.Rate; newEnt.WarehouseId = input.WarehouseId; newEnt.GoodCode = item; - newEnt.MaterialsNum = reportTable.ProductCodeNum; + newEnt.MaterialsNum = materials.CodeNum; var addId = await _warehouseDetails.Add(newEnt); } - - - var retrospect1 = new AddProductRetrospectInput() - { - BaseCount = unit.Rate, - BaseUnit = baseUnit, - Batch = reportTable.Batch, - BusinessType = "入库单", - CodeType = input.WarehousingType, - Department = reportTable.ProductionLine, - //WarehouseID = input.WarehouseId, - WarehousingDate = DateTime.Now, - Count = 1, - CreateTime = DateTime.Now, - ScanCodeTime = DateTime.Now, - CreateUserId = userId, - CreateUserName = userName, - MaterialsId = reportTable.MaterialsId, - OddNumber = reportTable.OddNumber, - Receipt = "汇报单", - SourceId = reportTable.Id, - Unit = unit.Name, - Name = materials.Name, - Code = item - };//Destination = warehousing.Supplier, - await _productRetrospect.Add(retrospect1); + await _productRetrospect.AddRetrospect(product, reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId); var childs = codeDetails.FindAll(a => a.FatherCode == item); if (childs.Count>0) @@ -251,30 +259,7 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient var currentUnit = units.FirstOrDefault(a => a.Name == childs.FirstOrDefault().Unit); foreach (var c1 in childs) { - var retrospect2 = new AddProductRetrospectInput() - { - BaseCount = currentUnit.Rate, - BaseUnit = baseUnit, - Batch = reportTable.Batch, - BusinessType = "入库单", - CodeType = input.WarehousingType, - Department = reportTable.ProductionLine, - //WarehouseID = input.WarehouseId, - WarehousingDate = DateTime.Now, - Count = 1, - CreateTime = DateTime.Now, - ScanCodeTime = DateTime.Now, - CreateUserId = userId, - CreateUserName = userName, - MaterialsId = reportTable.MaterialsId, - OddNumber = reportTable.OddNumber, - Receipt = "汇报单", - SourceId = reportTable.Id, - Unit = currentUnit.Name, - Name = materials.Name, - Code = c1.Code - };//Destination = warehousing.Supplier, - await _productRetrospect.Add(retrospect2); + await _productRetrospect.AddRetrospect(c1.Adapt(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId); var childs3 = codeDetails.FindAll(a => a.FatherCode == c1.Code); if (childs3.Count > 0) @@ -282,61 +267,14 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient var currentUnit3 = units.FirstOrDefault(a => a.Name == childs3.FirstOrDefault().Unit); foreach (var c3 in childs3) { - var retrospect3 = new AddProductRetrospectInput() - { - BaseCount = currentUnit3.Rate, - BaseUnit = baseUnit, - Batch = reportTable.Batch, - BusinessType = "入库单", - CodeType = input.WarehousingType, - Department = reportTable.ProductionLine, - //WarehouseID = input.WarehouseId, - WarehousingDate = DateTime.Now, - Count = 1, - CreateTime = DateTime.Now, - ScanCodeTime = DateTime.Now, - CreateUserId = userId, - CreateUserName = userName, - MaterialsId = reportTable.MaterialsId, - OddNumber = reportTable.OddNumber, - Receipt = "汇报单", - SourceId = reportTable.Id, - Unit = currentUnit3.Name, - Name = materials.Name, - Code = c3.Code - };//Destination = warehousing.Supplier, - await _productRetrospect.Add(retrospect3); - + await _productRetrospect.AddRetrospect(c3.Adapt(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId); var childs4 = codeDetails.FindAll(a => a.FatherCode == c3.Code); if (childs4.Count > 0) { var currentUnit4 = units.FirstOrDefault(a => a.Name == childs4.FirstOrDefault().Unit); foreach (var c4 in childs4) { - var retrospect4 = new AddProductRetrospectInput() - { - BaseCount = currentUnit4.Rate, - BaseUnit = baseUnit, - Batch = reportTable.Batch, - BusinessType = "入库单", - CodeType = input.WarehousingType, - Department = reportTable.ProductionLine, - //WarehouseID = input.WarehouseId, - WarehousingDate = DateTime.Now, - Count = 1, - CreateTime = DateTime.Now, - ScanCodeTime = DateTime.Now, - CreateUserId = userId, - CreateUserName = userName, - MaterialsId = reportTable.MaterialsId, - OddNumber = reportTable.OddNumber, - Receipt = "汇报单", - SourceId = reportTable.Id, - Unit = currentUnit4.Name, - Name = materials.Name, - Code = c4.Code - };//Destination = warehousing.Supplier, - await _productRetrospect.Add(retrospect4); + await _productRetrospect.AddRetrospect(c4.Adapt(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId); } } @@ -348,34 +286,11 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient } - - //var warehousing = await Detail(new QueryByIdReportDetailTableInput() { Id = input.WarehousingTableId.Value }); - //if (warehousing == null) - //{ - // throw Oops.Oh(ErrorCodeEnum.xg1002); - //} - - //var details = await _warehouseDetails.List(); - //if (details != null && details.Any(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit)) - //{ - // var unit = units.Find(a => a.Name == warehousing.Unit); - // var detail = details.Find(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit); - // detail.Count += warehousing.Count; - // if (unit != null) - // { - // detail.BaseCount = detail.Count * unit.Rate; - // } - // await _warehouseDetails.UpdateByEntity(detail.Adapt()); - //} - //else - //{ - // var newEnt = warehousing.Adapt(); - // newEnt.SourceId = warehousing.Id; - // var addId = await _warehouseDetails.Add(newEnt); - //} - var newDetail = reportTable.Adapt(); - newDetail.SourceId = reportTable.Id; + if (reportTable!=null) + { + newDetail.SourceId = reportTable?.Id; + } await Add(newDetail); } diff --git a/Web/src/api/main/materials.ts b/Web/src/api/main/materials.ts index 66dd831..614213d 100644 --- a/Web/src/api/main/materials.ts +++ b/Web/src/api/main/materials.ts @@ -6,6 +6,7 @@ enum Api { PageMaterials = '/api/materials/page', DetailMaterials = '/api/materials/detail', ListMaterials = '/api/materials/list', + MtListBySourceId = '/api/materialList/listBySourceId' } // 增加物料 @@ -56,3 +57,11 @@ export const listMaterials = () => data: { }, }); + +// 附带的物料列表 +export const materialListBySourceId = (sourceId: any) => + request({ + url: Api.MtListBySourceId, + method: 'get', + data: { sourceId }, + }); diff --git a/Web/src/views/inventoryManagement/invoice/component/editDialog.vue b/Web/src/views/inventoryManagement/invoice/component/editDialog.vue index 36d0cbc..a94811a 100644 --- a/Web/src/views/inventoryManagement/invoice/component/editDialog.vue +++ b/Web/src/views/inventoryManagement/invoice/component/editDialog.vue @@ -1,13 +1,13 @@