diff --git a/Admin.NET/Admin.NET.Application/Entity/PrintData.cs b/Admin.NET/Admin.NET.Application/Entity/PrintData.cs index f78be65..065b3e1 100644 --- a/Admin.NET/Admin.NET.Application/Entity/PrintData.cs +++ b/Admin.NET/Admin.NET.Application/Entity/PrintData.cs @@ -18,7 +18,17 @@ public class PrintData : EntityBaseId /// [SugarColumn(ColumnName = "QrCode", ColumnDescription = "二维码数据", Length = 128)] public string? QrCode { get; set; } - + + /// + /// 包装名称 + /// + public string PackageName { get; set; } + + /// + /// 父条码 + /// + public string FatherCode { get; set; } + /// /// 备注 /// diff --git a/Admin.NET/Admin.NET.Application/Entity/ProductRetrospect.cs b/Admin.NET/Admin.NET.Application/Entity/ProductRetrospect.cs new file mode 100644 index 0000000..501373f --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Entity/ProductRetrospect.cs @@ -0,0 +1,131 @@ +using Admin.NET.Core; +namespace Admin.NET.Application.Entity; + +/// +/// 商品追溯 +/// +[SugarTable("productretrospect","商品追溯")] +public class ProductRetrospect : EntityBase +{ + /// + /// 单号 + /// + [SugarColumn(ColumnName = "OddNumber", ColumnDescription = "单号", Length = 32)] + public string? OddNumber { get; set; } + + /// + /// 条码类型 + /// + [SugarColumn(ColumnName = "CodeType", ColumnDescription = "条码类型", Length = 32)] + public string? CodeType { get; set; } + + /// + /// 扫码时间 + /// + [SugarColumn(ColumnName = "ScanCodeTime", ColumnDescription = "扫码时间")] + public DateTime? ScanCodeTime { get; set; } + + /// + /// 业务类型 + /// + [SugarColumn(ColumnName = "BusinessType", ColumnDescription = "业务类型", Length = 32)] + public string? BusinessType { get; set; } + + /// + /// 收货/供货单位 + /// + [SugarColumn(ColumnName = "Destination", ColumnDescription = "收货/供货单位", Length = 32)] + public string? Destination { get; set; } + + /// + /// 所在地区 + /// + [SugarColumn(ColumnName = "Location", ColumnDescription = "所在地区", Length = 32)] + public string? Location { get; set; } + + /// + /// 仓库ID + /// + [SugarColumn(ColumnName = "WarehouseID", ColumnDescription = "仓库ID")] + public long? WarehouseID { get; set; } + + /// + /// 单据类型 + /// + [SugarColumn(ColumnName = "Receipt", ColumnDescription = "单据类型", Length = 32)] + public string? Receipt { get; set; } + + /// + /// 部门 + /// + [SugarColumn(ColumnName = "Department", ColumnDescription = "部门", Length = 32)] + public string? Department { get; set; } + + /// + /// 批次 + /// + [SugarColumn(ColumnName = "Batch", ColumnDescription = "批次", Length = 32)] + public string? Batch { get; set; } + + /// + /// 数量 + /// + [SugarColumn(ColumnName = "Count", ColumnDescription = "数量")] + public int? Count { get; set; } + + /// + /// 单位 + /// + [SugarColumn(ColumnName = "Unit", ColumnDescription = "单位", Length = 32)] + public string? Unit { get; set; } + + /// + /// 基本数量 + /// + [SugarColumn(ColumnName = "BaseCount", ColumnDescription = "基本数量")] + public int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + [SugarColumn(ColumnName = "BaseUnit", ColumnDescription = "基本单位", Length = 32)] + public string? BaseUnit { get; set; } + + /// + /// 业务日期 + /// + [SugarColumn(ColumnName = "WarehousingDate", ColumnDescription = "业务日期")] + public DateTime? WarehousingDate { get; set; } + + /// + /// 物料ID + /// + [SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")] + public long? MaterialsId { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)] + public string? Remarks { get; set; } + + /// + /// 源ID + /// + [SugarColumn(ColumnName = "SourceId", ColumnDescription = "源ID")] + public long? SourceId { get; set; } + + /// + /// 名称 + /// + [SugarColumn(ColumnName = "Name", ColumnDescription = "名称", Length = 32)] + public string? Name { get; set; } + + /// + /// 条码 + /// + [Required] + [SugarColumn(ColumnName = "Code", ColumnDescription = "条码", Length = 32)] + public string Code { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Service/Materials/MaterialsService.cs b/Admin.NET/Admin.NET.Application/Service/Materials/MaterialsService.cs index 0761c34..9945fd6 100644 --- a/Admin.NET/Admin.NET.Application/Service/Materials/MaterialsService.cs +++ b/Admin.NET/Admin.NET.Application/Service/Materials/MaterialsService.cs @@ -131,7 +131,7 @@ public class MaterialsService : IDynamicApiController, ITransient /// [HttpGet] [ApiDescriptionSettings(Name = "GetById")] - public async Task GetById(long materialsId) + public async Task GetById(long? materialsId) { var model = await _rep.GetFirstAsync(u => u.Id == materialsId); if (model!=null) @@ -148,7 +148,7 @@ public class MaterialsService : IDynamicApiController, ITransient /// [HttpGet] [ApiDescriptionSettings(Name = "PackageList")] - public async Task> GetPackageList(long materialsId) + public async Task> GetPackageList(long? materialsId) { return await _repPackage.List(materialsId); } diff --git a/Admin.NET/Admin.NET.Application/Service/PackageInfo/Dto/PackageInfoInput.cs b/Admin.NET/Admin.NET.Application/Service/PackageInfo/Dto/PackageInfoInput.cs index cebebad..7913beb 100644 --- a/Admin.NET/Admin.NET.Application/Service/PackageInfo/Dto/PackageInfoInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/PackageInfo/Dto/PackageInfoInput.cs @@ -11,7 +11,7 @@ namespace Admin.NET.Application; /// /// 物料Id /// - public virtual long MaterialsId { get; set; } + public virtual long? MaterialsId { get; set; } /// /// 是否启用 @@ -151,7 +151,7 @@ namespace Admin.NET.Application; /// 物料Id /// [Required(ErrorMessage = "物料Id不能为空")] - public override long MaterialsId { get; set; } + public override long? MaterialsId { get; set; } /// /// 是否启用 diff --git a/Admin.NET/Admin.NET.Application/Service/PackageInfo/PackageInfoService.cs b/Admin.NET/Admin.NET.Application/Service/PackageInfo/PackageInfoService.cs index c730794..1580ca9 100644 --- a/Admin.NET/Admin.NET.Application/Service/PackageInfo/PackageInfoService.cs +++ b/Admin.NET/Admin.NET.Application/Service/PackageInfo/PackageInfoService.cs @@ -116,7 +116,7 @@ public class PackageInfoService : IDynamicApiController, ITransient /// [HttpGet] [ApiDescriptionSettings(Name = "List")] - public async Task> List(long materialsId) + public async Task> List(long? materialsId) { var list = await _rep.AsQueryable().Where(u =>!u.IsDelete && u.MaterialsId == materialsId)?.Select().ToListAsync(); if (list != null && list.Count > 5) diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs index bc359ab..5d44862 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs @@ -170,7 +170,6 @@ public class PrintCodeDetailInput : BasePageInput /// public int? ChildCount { get; set; } - /// /// 打印单ID /// diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs index 7ff65e8..6f7c4ec 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs @@ -135,6 +135,17 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync(); } + /// + /// 获取打印条码详情 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "GetByProductCode")] + public async Task GetByProductCode(string? productCode) + { + return await _rep.GetFirstAsync(a => a.Code == productCode); + } } diff --git a/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectDto.cs b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectDto.cs new file mode 100644 index 0000000..bc6acc9 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectDto.cs @@ -0,0 +1,148 @@ +namespace Admin.NET.Application; + +/// +/// 商品追溯输出参数 +/// +public class ProductRetrospectDto +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 单号 + /// + public string? OddNumber { get; set; } + + /// + /// 条码类型 + /// + public string? CodeType { get; set; } + + /// + /// 扫码时间 + /// + public DateTime? ScanCodeTime { get; set; } + + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 收货/供货单位 + /// + public string? Destination { get; set; } + + /// + /// 所在地区 + /// + public string? Location { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseID { get; set; } + + /// + /// 单据类型 + /// + public string? Receipt { get; set; } + + /// + /// 部门 + /// + public string? Department { get; set; } + + /// + /// 批次 + /// + public string? Batch { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 基本数量 + /// + public int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + public string? BaseUnit { get; set; } + + /// + /// 业务日期 + /// + public DateTime? WarehousingDate { get; set; } + + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 源ID + /// + public long? SourceId { get; set; } + + /// + /// 名称 + /// + public string? Name { get; set; } + + /// + /// 条码 + /// + public string Code { get; set; } + + /// + /// 备注 + /// + public string? Remarks { 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/ProductRetrospect/Dto/ProductRetrospectInput.cs b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectInput.cs new file mode 100644 index 0000000..c71d54b --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectInput.cs @@ -0,0 +1,305 @@ +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + +/// +/// 商品追溯基础输入参数 +/// +public class ProductRetrospectBaseInput +{ + /// + /// 单号 + /// + public virtual string? OddNumber { get; set; } + + /// + /// 条码类型 + /// + public virtual string? CodeType { get; set; } + + /// + /// 扫码时间 + /// + public virtual DateTime? ScanCodeTime { get; set; } + + /// + /// 业务类型 + /// + public virtual string? BusinessType { get; set; } + + /// + /// 收货/供货单位 + /// + public virtual string? Destination { get; set; } + + /// + /// 所在地区 + /// + public virtual string? Location { get; set; } + + /// + /// 仓库ID + /// + public virtual long? WarehouseID { get; set; } + + /// + /// 单据类型 + /// + public virtual string? Receipt { get; set; } + + /// + /// 部门 + /// + public virtual string? Department { get; set; } + + /// + /// 批次 + /// + public virtual string? Batch { get; set; } + + /// + /// 数量 + /// + public virtual int? Count { get; set; } + + /// + /// 单位 + /// + public virtual string? Unit { get; set; } + + /// + /// 基本数量 + /// + public virtual int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + public virtual string? BaseUnit { get; set; } + + /// + /// 业务日期 + /// + public virtual DateTime? WarehousingDate { get; set; } + + /// + /// 物料ID + /// + public virtual long? MaterialsId { get; set; } + + /// + /// 源ID + /// + public virtual long? SourceId { get; set; } + + /// + /// 名称 + /// + public virtual string? Name { get; set; } + + /// + /// 条码 + /// + public virtual string Code { get; set; } + /// + /// 备注 + /// + public virtual string? Remarks { 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 ProductRetrospectInput : BasePageInput +{ + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 单号 + /// + public string? OddNumber { get; set; } + + /// + /// 条码类型 + /// + public string? CodeType { get; set; } + + /// + /// 扫码时间 + /// + public DateTime? ScanCodeTime { get; set; } + + /// + /// 扫码时间范围 + /// + public List ScanCodeTimeRange { get; set; } + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 收货/供货单位 + /// + public string? Destination { get; set; } + + /// + /// 所在地区 + /// + public string? Location { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseID { get; set; } + + /// + /// 单据类型 + /// + public string? Receipt { get; set; } + + /// + /// 部门 + /// + public string? Department { get; set; } + + /// + /// 批次 + /// + public string? Batch { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 基本数量 + /// + public int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + public string? BaseUnit { get; set; } + + /// + /// 业务日期 + /// + public DateTime? WarehousingDate { get; set; } + + /// + /// 业务日期范围 + /// + public List WarehousingDateRange { get; set; } + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 名称 + /// + public virtual string? Name { get; set; } + + /// + /// 条码 + /// + public virtual string Code { get; set; } + /// + /// 源ID + /// + public long? SourceId { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + +} + +/// +/// 商品追溯增加输入参数 +/// +public class AddProductRetrospectInput : ProductRetrospectBaseInput +{ + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + +} + +/// +/// 商品追溯删除输入参数 +/// +public class DeleteProductRetrospectInput : BaseIdInput +{ +} + +/// +/// 商品追溯更新输入参数 +/// +public class UpdateProductRetrospectInput : ProductRetrospectBaseInput +{ + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + +} + +/// +/// 商品追溯主键查询输入参数 +/// +public class QueryByIdProductRetrospectInput : DeleteProductRetrospectInput +{ + +} diff --git a/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectOutput.cs b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectOutput.cs new file mode 100644 index 0000000..7ab3652 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/Dto/ProductRetrospectOutput.cs @@ -0,0 +1,149 @@ +namespace Admin.NET.Application; + +/// +/// 商品追溯输出参数 +/// +public class ProductRetrospectOutput +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 单号 + /// + public string? OddNumber { get; set; } + + /// + /// 条码类型 + /// + public string? CodeType { get; set; } + + /// + /// 扫码时间 + /// + public DateTime? ScanCodeTime { get; set; } + + /// + /// 业务类型 + /// + public string? BusinessType { get; set; } + + /// + /// 收货/供货单位 + /// + public string? Destination { get; set; } + + /// + /// 所在地区 + /// + public string? Location { get; set; } + + /// + /// 仓库ID + /// + public long? WarehouseID { get; set; } + + /// + /// 单据类型 + /// + public string? Receipt { get; set; } + + /// + /// 部门 + /// + public string? Department { get; set; } + + /// + /// 批次 + /// + public string? Batch { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 基本数量 + /// + public int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + public string? BaseUnit { get; set; } + + /// + /// 业务日期 + /// + public DateTime? WarehousingDate { get; set; } + + /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + + /// + /// 名称 + /// + public virtual string? Name { get; set; } + + /// + /// 条码 + /// + public virtual string Code { get; set; } + /// + /// 源ID + /// + public long? SourceId { get; set; } + + /// + /// 备注 + /// + public string? Remarks { 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/ProductRetrospect/ProductRetrospectService.cs b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs new file mode 100644 index 0000000..6c3eb85 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ProductRetrospect/ProductRetrospectService.cs @@ -0,0 +1,161 @@ +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 ProductRetrospectService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _rep; + private readonly PrintCodeDetailService _codeDetailService; + public ProductRetrospectService(SqlSugarRepository rep, + PrintCodeDetailService codeDetailService) + { + _rep = rep; + _codeDetailService = codeDetailService; + } + + /// + /// 分页查询商品追溯 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(ProductRetrospectInput input) + { + var query = _rep.AsQueryable().Where(a => !a.IsDelete) + .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u => + u.OddNumber.Contains(input.SearchKey.Trim()) + || u.CodeType.Contains(input.SearchKey.Trim()) + || u.BusinessType.Contains(input.SearchKey.Trim()) + || u.Destination.Contains(input.SearchKey.Trim()) + || u.Location.Contains(input.SearchKey.Trim()) + || u.Receipt.Contains(input.SearchKey.Trim()) + || u.Department.Contains(input.SearchKey.Trim()) + || u.Batch.Contains(input.SearchKey.Trim()) + || u.Unit.Contains(input.SearchKey.Trim()) + || u.BaseUnit.Contains(input.SearchKey.Trim()) + || u.Remarks.Contains(input.SearchKey.Trim()) + ) + .WhereIF(!string.IsNullOrWhiteSpace(input.OddNumber), u => u.OddNumber.Contains(input.OddNumber.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.CodeType), u => u.CodeType.Contains(input.CodeType.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.BusinessType), u => u.BusinessType.Contains(input.BusinessType.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Destination), u => u.Destination.Contains(input.Destination.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Location), u => u.Location.Contains(input.Location.Trim())) + .WhereIF(input.WarehouseID>0, u => u.WarehouseID == input.WarehouseID) + .WhereIF(!string.IsNullOrWhiteSpace(input.Receipt), u => u.Receipt.Contains(input.Receipt.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Department), u => u.Department.Contains(input.Department.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Batch), u => u.Batch.Contains(input.Batch.Trim())) + .WhereIF(input.Count>0, u => u.Count == input.Count) + .WhereIF(!string.IsNullOrWhiteSpace(input.Unit), u => u.Unit.Contains(input.Unit.Trim())) + .WhereIF(input.BaseCount>0, u => u.BaseCount == input.BaseCount) + .WhereIF(!string.IsNullOrWhiteSpace(input.BaseUnit), u => u.BaseUnit.Contains(input.BaseUnit.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim())) + .Select(); + if(input.ScanCodeTimeRange != null && input.ScanCodeTimeRange.Count >0) + { + DateTime? start= input.ScanCodeTimeRange[0]; + query = query.WhereIF(start.HasValue, u => u.ScanCodeTime > start); + if (input.ScanCodeTimeRange.Count >1 && input.ScanCodeTimeRange[1].HasValue) + { + var end = input.ScanCodeTimeRange[1].Value.AddDays(1); + query = query.Where(u => u.ScanCodeTime < end); + } + } + if(input.WarehousingDateRange != null && input.WarehousingDateRange.Count >0) + { + DateTime? start= input.WarehousingDateRange[0]; + query = query.WhereIF(start.HasValue, u => u.WarehousingDate > start); + if (input.WarehousingDateRange.Count >1 && input.WarehousingDateRange[1].HasValue) + { + var end = input.WarehousingDateRange[1].Value.AddDays(1); + query = query.Where(u => u.WarehousingDate < end); + } + } + return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加商品追溯 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Add")] + public async Task Add(AddProductRetrospectInput input) + { + var entity = input.Adapt(); + await _rep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 删除商品追溯 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Delete")] + public async Task Delete(DeleteProductRetrospectInput 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(UpdateProductRetrospectInput input) + { + var entity = input.Adapt(); + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 获取商品追溯 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "Detail")] + public async Task Detail([FromQuery] QueryByIdProductRetrospectInput 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(); + } + + /// + /// 获取商品追溯列表 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "RetrospectByProductCode")] + public async Task> RetrospectByProductCode(string? productCode) + { + return await _rep.AsQueryable().Where(u => !u.IsDelete && u.Code == productCode).Select().ToListAsync(); + } + + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/Dto/AddProductCodeInput.cs b/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/Dto/AddProductCodeInput.cs new file mode 100644 index 0000000..ea71302 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/Dto/AddProductCodeInput.cs @@ -0,0 +1,24 @@ +using Admin.NET.Application.Entity; +using Admin.NET.Core; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application; + +/// +/// 产品入库输入参数 +/// +public class AddProductCodeInput +{ + + /// + /// 入库单ID + /// + public long? WarehousingTableId { get; set; } + + /// + /// 条码数据 + /// + public List CodeDatas { get; set; } + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/ProductWarehousingService.cs b/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/ProductWarehousingService.cs index 780629b..27b6689 100644 --- a/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/ProductWarehousingService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ProductWarehousing/ProductWarehousingService.cs @@ -2,6 +2,10 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types; +using RazorEngine.Compilation.ImpromptuInterface.InvokeExt; +using AngleSharp.Dom; + namespace Admin.NET.Application; /// /// 产品入库服务 @@ -15,17 +19,26 @@ public class ProductWarehousingService : IDynamicApiController, ITransient private readonly SysUnitService _sysUnitService; private readonly MaterialClassifyService _materialClassifyService; private readonly WarehousingStatisticsService _warehousingStatisticsService; + private readonly PrintCodeDetailService _codeDetailService; + private readonly ProductRetrospectService _productRetrospect; + private readonly UserManager _userManager; public ProductWarehousingService(SqlSugarRepository rep, + UserManager userManager, WarehouseDetailsService warehouseDetails, MaterialsService materialsService, SysUnitService sysUnitService, + PrintCodeDetailService codeDetailService, + ProductRetrospectService productRetrospect, MaterialClassifyService materialClassifyService, WarehousingStatisticsService warehousingStatisticsService) { _rep = rep; + _userManager = userManager; _warehouseDetails = warehouseDetails; _materialsService = materialsService; _sysUnitService = sysUnitService; + _codeDetailService = codeDetailService; + _productRetrospect = productRetrospect; _materialClassifyService = materialClassifyService; _warehousingStatisticsService = warehousingStatisticsService; } @@ -123,6 +136,226 @@ public class ProductWarehousingService : IDynamicApiController, ITransient return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); } + /// + /// 产品入库 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "ProductWarehousing")] + public async Task ProductWarehousing(AddProductCodeInput input) + { + if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var warehousing = await Detail(new QueryByIdProductWarehousingInput() { Id = input.WarehousingTableId.Value }); + if (warehousing == null) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var materials = await _materialsService.GetById(warehousing.MaterialsId); + if (materials == null) + { + throw Oops.Oh(ErrorCodeEnum.xg1002); + } + var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId); + var baseUnit = units.LastOrDefault().Name; + var userId = _userManager.UserId; + var userName = _userManager.RealName; + var topDatas = input.CodeDatas.FindAll(a => string.IsNullOrEmpty(a.FatherCode)); + Dictionary list = new Dictionary(); + foreach (var item in topDatas) + { + var code = string.IsNullOrEmpty(item.BarCode) ? item.QrCode : item.BarCode; + var codeType = string.IsNullOrEmpty(item.BarCode) ? "二维码" : "条码"; + var unit = units.Find(a => a.Name == item.PackageName); + + var detail = new AddPrintCodeDetailInput() + { + ReportTableId = input.WarehousingTableId, + Code = code, + CodeName = codeType, + ChildCount = unit.ChildUnitCount, + Count = 1, + Unit = item.PackageName, + BaseCount = unit.Rate, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName + }; + var detailId = await _codeDetailService.Add(detail); + list.Add(detail, detailId); + + var childs = input.CodeDatas.FindAll(a => a.FatherCode == code); + foreach (var child in childs) + { + var code2 = string.IsNullOrEmpty(child.BarCode) ? child.QrCode : child.BarCode; + var unit2 = units.Find(a => a.Name == child.PackageName); + var detail2 = new AddPrintCodeDetailInput() + { + ReportTableId = input.WarehousingTableId, + Code = code2, + CodeName = codeType, + ChildCount = unit2.ChildUnitCount, + Count = 1, + Unit = child.PackageName, + BaseCount = unit2.Rate, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + FatherCode = code, + FatherId = detailId + }; + var detailId2 = await _codeDetailService.Add(detail2); + list.Add(detail2, detailId2); + + var childs3 = input.CodeDatas.FindAll(a => a.FatherCode == code2); + foreach (var child3 in childs) + { + var code3 = string.IsNullOrEmpty(child3.BarCode) ? child3.QrCode : child3.BarCode; + var unit3 = units.Find(a => a.Name == child3.PackageName); + var detail3 = new AddPrintCodeDetailInput() + { + ReportTableId = input.WarehousingTableId, + Code = code3, + CodeName = codeType, + ChildCount = unit3.ChildUnitCount, + Count = 1, + Unit = child3.PackageName, + BaseCount = unit3.Rate, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + FatherCode = code2, + FatherId = detailId2 + }; + var detailId3 = await _codeDetailService.Add(detail3); + list.Add(detail3, detailId3); + if (input.CodeDatas.Any(a => a.FatherCode == code3)) + { + var childs4 = input.CodeDatas.FindAll(a => a.FatherCode == code3); + foreach (var child4 in childs) + { + var code4 = string.IsNullOrEmpty(child4.BarCode) ? child4.QrCode : child4.BarCode; + var unit4 = units.Find(a => a.Name == child4.PackageName); + var detail4 = new AddPrintCodeDetailInput() + { + ReportTableId = input.WarehousingTableId, + Code = code4, + CodeName = codeType, + ChildCount = unit4.ChildUnitCount, + Count = 1, + Unit = child4.PackageName, + BaseCount = unit4.Rate, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + FatherCode = code3, + FatherId = detailId3 + }; + var detailId4 = await _codeDetailService.Add(detail4); + list.Add(detail4, detailId4); + if (input.CodeDatas.Any(a => a.FatherCode == code4)) + { + var childs5 = input.CodeDatas.FindAll(a => a.FatherCode == code4); + foreach (var child5 in childs) + { + var code5 = string.IsNullOrEmpty(child5.BarCode) ? child5.QrCode : child5.BarCode; + var unit5 = units.Find(a => a.Name == child5.PackageName); + var detail5 = new AddPrintCodeDetailInput() + { + ReportTableId = input.WarehousingTableId, + Code = code5, + CodeName = codeType, + ChildCount = unit5.ChildUnitCount, + Count = 1, + Unit = child5.PackageName, + BaseCount = unit5.Rate, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName, + FatherCode = code4, + FatherId = detailId4 + }; + var detailId5 = await _codeDetailService.Add(detail5); + list.Add(detail5, detailId5); + } + } + } + } + + } + } + + } + + 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, + Destination = warehousing.Supplier, + WarehouseID = warehousing.WarehouseId, + WarehousingDate = DateTime.Now, + Count = 1, + CreateTime = DateTime.Now, + ScanCodeTime = DateTime.Now, + Location = warehousing.WarehouseLocation, + CreateUserId = userId, + CreateUserName = userName, + MaterialsId = dic.Value, + OddNumber = warehousing.OddNumber, + Receipt = "入库单", + SourceId = warehousing.Id, + Unit = item.Unit, + Name = materials.Name, + Code = item.Code + }; + await _productRetrospect.Add(retrospect1); + } + + + + + 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 = warehousing.Adapt(); + newDetail.SourceId = warehousing.Id; + await _warehousingStatisticsService.Add(newDetail); + + } + + + /// /// 增加产品入库 /// @@ -168,34 +401,13 @@ public class ProductWarehousingService : IDynamicApiController, ITransient { } - + input.CreateUserId = _userManager.UserId; + input.CreateUserName = _userManager.RealName; var entity = input.Adapt(); await _rep.InsertAsync(entity); - var details = await _warehouseDetails.List(); - if (details != null && details.Any(a => a.MaterialsId == input.MaterialsId && a.Unit == input.Unit)) - { - var detail = details.Find(a => a.MaterialsId == input.MaterialsId && a.Unit == input.Unit); - detail.Count += input.Count; - if (unit != null) - { - detail.BaseCount = detail.Count * unit.Rate; - } - await _warehouseDetails.UpdateByEntity(detail.Adapt()); - } - else - { - var newEnt = input.Adapt(); - newEnt.SourceId = entity.Id; - var addId = await _warehouseDetails.Add(newEnt); - } - - var newDetail = input.Adapt(); - newDetail.SourceId = entity.Id; - await _warehousingStatisticsService.Add(newDetail); - return entity.Id; } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs index bd9b5dd..516c174 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs @@ -125,6 +125,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient return entity.Id; } + + /// /// 删除汇报单详情 /// diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs index 7471e87..2234038 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs @@ -230,7 +230,20 @@ public class ReportTableService : IDynamicApiController, ITransient { var code = string.IsNullOrEmpty(item.BarCode) ? item.QrCode : item.BarCode; var codeType = string.IsNullOrEmpty(item.BarCode) ? "二维码" : "条码"; - var detail = new AddPrintCodeDetailInput() { TempListId = addReport, Code = code, CodeName = codeType, ChildCount = unit.ChildUnitCount, Count = 1, Unit = unit.Name, BaseCount = toltalCount, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detail = new AddPrintCodeDetailInput() + { + TempListId = addReport, + Code = code, + CodeName = codeType, + ChildCount = unit.ChildUnitCount, + Count = 1, + Unit = unit.Name, + BaseCount = toltalCount, + BaseUnit = baseUnit, + PrintCodeTime = DateTime.Now, + CreateUserId = userId, + CreateUserName = userName + }; var detailId = await _codeDetailService.Add(detail); var treeData1 = detail.Adapt(); if (others.Count < 1) diff --git a/Web/src/api/main/productRetrospect.ts b/Web/src/api/main/productRetrospect.ts new file mode 100644 index 0000000..628ad77 --- /dev/null +++ b/Web/src/api/main/productRetrospect.ts @@ -0,0 +1,59 @@ +import request from '/@/utils/request'; +enum Api { + AddProductRetrospect = '/api/productRetrospect/add', + DeleteProductRetrospect = '/api/productRetrospect/delete', + UpdateProductRetrospect = '/api/productRetrospect/update', + PageProductRetrospect = '/api/productRetrospect/page', + DetailProductRetrospect = '/api/productRetrospect/detail', + ListProductRetrospect = '/api/productRetrospect/list', +} + +// 增加商品追溯 +export const addProductRetrospect = (params?: any) => + request({ + url: Api.AddProductRetrospect, + method: 'post', + data: params, + }); + +// 删除商品追溯 +export const deleteProductRetrospect = (params?: any) => + request({ + url: Api.DeleteProductRetrospect, + method: 'post', + data: params, + }); + +// 编辑商品追溯 +export const updateProductRetrospect = (params?: any) => + request({ + url: Api.UpdateProductRetrospect, + method: 'post', + data: params, + }); + +// 分页查询商品追溯 +export const pageProductRetrospect = (params?: any) => + request({ + url: Api.PageProductRetrospect, + method: 'post', + data: params, + }); + +// 列表商品追溯 +export const listProductRetrospect = () => + request({ + url: Api.ListProductRetrospect, + method: 'get', + data: { }, + }); + +// 详情商品追溯 +export const detailProductRetrospect = (id: any) => + request({ + url: Api.DetailProductRetrospect, + method: 'get', + data: { id }, + }); + + diff --git a/Web/src/views/main/productRetrospect/component/editDialog.vue b/Web/src/views/main/productRetrospect/component/editDialog.vue new file mode 100644 index 0000000..1cfa11a --- /dev/null +++ b/Web/src/views/main/productRetrospect/component/editDialog.vue @@ -0,0 +1,233 @@ + + + + + + + diff --git a/Web/src/views/main/productRetrospect/index.vue b/Web/src/views/main/productRetrospect/index.vue new file mode 100644 index 0000000..4dfb8a9 --- /dev/null +++ b/Web/src/views/main/productRetrospect/index.vue @@ -0,0 +1,284 @@ + + + + + diff --git a/Web/src/views/productionCenter/reportDetailTable/index.vue b/Web/src/views/productionCenter/reportDetailTable/index.vue index 66ed52a..9534f4b 100644 --- a/Web/src/views/productionCenter/reportDetailTable/index.vue +++ b/Web/src/views/productionCenter/reportDetailTable/index.vue @@ -307,8 +307,8 @@ // 打开查看详情页面 const readReportDetailTable = (row: any) => { - printDetailTableTitle.value = '打印详情'; - console.log(row); + printDetailTableTitle.value = '条码详情'; + //console.log(row); printDetailDialogRef.value.openDialog(row); }; diff --git a/Web/src/views/warehouseManagement/warehousingStatistics/index.vue b/Web/src/views/warehouseManagement/warehousingStatistics/index.vue index 2d53e63..11e6318 100644 --- a/Web/src/views/warehouseManagement/warehousingStatistics/index.vue +++ b/Web/src/views/warehouseManagement/warehousingStatistics/index.vue @@ -150,6 +150,7 @@ @@ -187,11 +188,13 @@ import printDialog from '/@/views/labelPrinting/print/component/hiprint/preview.vue' + import printDetailDialog from '/@/views/labelPrinting/printDataDetail/component/editDialog.vue' import editDialog from '/@/views/warehouseManagement/warehousingStatistics/component/editDialog.vue' import { pageWarehousingStatistics, deleteWarehousingStatistics } from '/@/api/main/warehousingStatistics'; const showAdvanceQueryUI = ref(false); + const printDetailDialogRef = ref(); const printDialogRef = ref(); const editDialogRef = ref(); const loading = ref(false); @@ -205,6 +208,7 @@ const printWarehousingStatisticsTitle = ref(""); const editWarehousingStatisticsTitle = ref(""); + const printDetailTableTitle = ref(""); // 改变高级查询的控件显示状态 const changeAdvanceQueryUI = () => { @@ -245,6 +249,14 @@ editDialogRef.value.openDialog(row); }; + // 打开查看详情页面 + const readReportDetailTable = (row: any) => { + printDetailTableTitle.value = '条码详情'; + //console.log(row); + printDetailDialogRef.value.openDialog(row); + }; + + // 删除 const delWarehousingStatistics = (row: any) => { ElMessageBox.confirm(`确定要删除吗?`, "提示", {