Compare commits
	
		
			No commits in common. "4623d4780ed28fb129086d34a2dac148127fcd15" and "6cf4381c534d05496d9842b06e0460af333fc0ac" have entirely different histories. 
		
	
	
		
			4623d4780e
			...
			6cf4381c53
		
	
		| 
						 | 
				
			
			@ -24,21 +24,21 @@ public class Invoice  : EntityTenant
 | 
			
		|||
    /// </summary>
 | 
			
		||||
    [Required]
 | 
			
		||||
    [SugarColumn(ColumnName = "BusinessType", ColumnDescription = "业务类型", Length = 32)]
 | 
			
		||||
    public string? BusinessType { get; set; }
 | 
			
		||||
    public string BusinessType { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 客户
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required]
 | 
			
		||||
    [SugarColumn(ColumnName = "Custom", ColumnDescription = "客户", Length = 32)]
 | 
			
		||||
    public string? Custom { get; set; }
 | 
			
		||||
    public string Custom { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 仓库
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required]
 | 
			
		||||
    [SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 32)]
 | 
			
		||||
    public string? Warehouse { get; set; }
 | 
			
		||||
    public string Warehouse { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 部门
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,40 +0,0 @@
 | 
			
		|||
using Admin.NET.Core;
 | 
			
		||||
namespace Admin.NET.Application.Entity;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 物料列表
 | 
			
		||||
/// </summary>
 | 
			
		||||
[SugarTable("MaterialList","物料列表")]
 | 
			
		||||
public class MaterialList  : EntityBaseId
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料ID
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")]
 | 
			
		||||
    public long? MaterialsId { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 单位
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnName = "Unit", ColumnDescription = "单位", Length = 32)]
 | 
			
		||||
    public string? Unit { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 数量
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnName = "Count", ColumnDescription = "数量")]
 | 
			
		||||
    public int? Count { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 来源ID
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnName = "SourceId", ColumnDescription = "来源ID")]
 | 
			
		||||
    public long? SourceId { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 备注
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)]
 | 
			
		||||
    public string? Remarks { get; set; }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -21,17 +21,17 @@ public class InvoiceBaseInput
 | 
			
		|||
    /// <summary>
 | 
			
		||||
    /// 业务类型
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual string? BusinessType { get; set; }
 | 
			
		||||
    public virtual string BusinessType { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 客户
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual string? Custom { get; set; }
 | 
			
		||||
    public virtual string Custom { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 仓库
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual string? Warehouse { get; set; }
 | 
			
		||||
    public virtual string Warehouse { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 仓库ID
 | 
			
		||||
| 
						 | 
				
			
			@ -220,16 +220,30 @@ public class InvoiceInput : BasePageInput
 | 
			
		|||
/// </summary>
 | 
			
		||||
public class AddInvoiceInput : InvoiceBaseInput
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 业务类型
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required(ErrorMessage = "业务类型不能为空")]
 | 
			
		||||
    public override string BusinessType { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 客户
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required(ErrorMessage = "客户不能为空")]
 | 
			
		||||
    public override string Custom { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 仓库
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required(ErrorMessage = "仓库不能为空")]
 | 
			
		||||
    public override string Warehouse { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 软删除
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Required(ErrorMessage = "软删除不能为空")]
 | 
			
		||||
    public override bool IsDelete { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public List<AddMaterialListInput> TableData { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -250,10 +264,6 @@ public class UpdateInvoiceInput : InvoiceBaseInput
 | 
			
		|||
    [Required(ErrorMessage = "主键Id不能为空")]
 | 
			
		||||
    public long Id { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public List<AddMaterialListInput> TableData { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,6 @@ using Admin.NET.Application.Const;
 | 
			
		|||
using Admin.NET.Application.Entity;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using NewLife.Reflection;
 | 
			
		||||
using Nest;
 | 
			
		||||
 | 
			
		||||
namespace Admin.NET.Application;
 | 
			
		||||
/// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -19,15 +18,13 @@ public class InvoiceService : IDynamicApiController, ITransient
 | 
			
		|||
    private readonly OutboundService _outboundService;
 | 
			
		||||
    private readonly OutboundDetailService _outboundDetailService;
 | 
			
		||||
    private readonly UserManager _userManager;
 | 
			
		||||
    private readonly MaterialListService _materialListService;
 | 
			
		||||
    public InvoiceService(SqlSugarRepository<Invoice> rep,
 | 
			
		||||
        UserManager userManager,
 | 
			
		||||
        PrintCodeDetailService codeDetailService,
 | 
			
		||||
        ReportTableService reportTableService,
 | 
			
		||||
        OutboundService outboundService,
 | 
			
		||||
        OutboundDetailService outboundDetailService,
 | 
			
		||||
        ProductRetrospectService productRetrospect,
 | 
			
		||||
        MaterialListService materialListService)
 | 
			
		||||
        ProductRetrospectService productRetrospect)
 | 
			
		||||
    {
 | 
			
		||||
        _rep = rep;
 | 
			
		||||
        _userManager = userManager;
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +33,6 @@ public class InvoiceService : IDynamicApiController, ITransient
 | 
			
		|||
        _reportTableService = reportTableService;
 | 
			
		||||
        _outboundService = outboundService;
 | 
			
		||||
        _outboundDetailService = outboundDetailService;
 | 
			
		||||
        _materialListService = materialListService;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -106,16 +102,7 @@ public class InvoiceService : IDynamicApiController, ITransient
 | 
			
		|||
    {
 | 
			
		||||
        var entity = input.Adapt<Invoice>();
 | 
			
		||||
        await _rep.InsertAsync(entity);
 | 
			
		||||
        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;
 | 
			
		||||
        return entity.Id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -143,22 +130,6 @@ public class InvoiceService : IDynamicApiController, ITransient
 | 
			
		|||
    {
 | 
			
		||||
        var entity = input.Adapt<Invoice>();
 | 
			
		||||
        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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -283,34 +254,32 @@ 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);
 | 
			
		||||
 | 
			
		||||
            await _productRetrospect.AddRetrospect(item.Adapt<PrintCodeDetail>(), report, "发货通知单", addOutbound.Consignee, outbound, input.WarehousingTableId);
 | 
			
		||||
            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);
 | 
			
		||||
| 
						 | 
				
			
			@ -344,16 +313,5 @@ public class InvoiceService : IDynamicApiController, ITransient
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取物料列表列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpGet]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "MaterialListById")]
 | 
			
		||||
    public async Task<List<MaterialListOutput>> MaterialListById(long? id)
 | 
			
		||||
    {
 | 
			
		||||
        return await _materialListService.ListBySourceId(id);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,38 +0,0 @@
 | 
			
		|||
namespace Admin.NET.Application;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表输出参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class MaterialListDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 主键Id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long Id { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 物料ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long? MaterialsId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 单位
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? Unit { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 数量
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int? Count { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 来源ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long? SourceId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 备注
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? Remarks { get; set; }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,108 +0,0 @@
 | 
			
		|||
using Admin.NET.Core;
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
 | 
			
		||||
namespace Admin.NET.Application;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表基础输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class MaterialListBaseInput
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 物料ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual long? MaterialsId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 单位
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual string? Unit { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 数量
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual int? Count { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 来源ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual long? SourceId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 备注
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual string? Remarks { get; set; }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表分页查询输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class MaterialListInput : BasePageInput
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 关键字查询
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? SearchKey { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 物料ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long? MaterialsId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 单位
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? Unit { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 数量
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int? Count { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 来源ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long? SourceId { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 备注
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string? Remarks { get; set; }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表增加输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class AddMaterialListInput : MaterialListBaseInput
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表删除输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class DeleteMaterialListInput : BaseIdInput
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表更新输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UpdateMaterialListInput : MaterialListBaseInput
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 主键Id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Required(ErrorMessage = "主键Id不能为空")]
 | 
			
		||||
        public long Id { get; set; }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料列表主键查询输入参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class QueryByIdMaterialListInput : DeleteMaterialListInput
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,40 +0,0 @@
 | 
			
		|||
namespace Admin.NET.Application;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 物料列表输出参数
 | 
			
		||||
/// </summary>
 | 
			
		||||
public class MaterialListOutput
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 主键Id
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public long Id { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 物料ID
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public long? MaterialsId { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 单位
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string? Unit { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 数量
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public int? Count { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 来源ID
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public long? SourceId { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 备注
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string? Remarks { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,120 +0,0 @@
 | 
			
		|||
using Admin.NET.Core.Service;
 | 
			
		||||
using Admin.NET.Application.Const;
 | 
			
		||||
using Admin.NET.Application.Entity;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
namespace Admin.NET.Application;
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 物料列表服务
 | 
			
		||||
/// </summary>
 | 
			
		||||
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
 | 
			
		||||
public class MaterialListService : IDynamicApiController, ITransient
 | 
			
		||||
{
 | 
			
		||||
    private readonly SqlSugarRepository<MaterialList> _rep;
 | 
			
		||||
    public MaterialListService(SqlSugarRepository<MaterialList> rep)
 | 
			
		||||
    {
 | 
			
		||||
        _rep = rep;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 分页查询物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpPost]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "Page")]
 | 
			
		||||
    public async Task<SqlSugarPagedList<MaterialListOutput>> 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<MaterialListOutput>();
 | 
			
		||||
        return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 增加物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpPost]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "Add")]
 | 
			
		||||
    public async Task<long> Add(AddMaterialListInput input)
 | 
			
		||||
    {
 | 
			
		||||
        var entity = input.Adapt<MaterialList>();
 | 
			
		||||
        await _rep.InsertAsync(entity);
 | 
			
		||||
        return entity.Id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 删除物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [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);   //真删除
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 更新物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpPost]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "Update")]
 | 
			
		||||
    public async Task Update(UpdateMaterialListInput input)
 | 
			
		||||
    {
 | 
			
		||||
        var entity = input.Adapt<MaterialList>();
 | 
			
		||||
        await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取物料列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpGet]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "Detail")]
 | 
			
		||||
    public async Task<MaterialList> Detail([FromQuery] QueryByIdMaterialListInput input)
 | 
			
		||||
    {
 | 
			
		||||
        return await _rep.GetFirstAsync(u => u.Id == input.Id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取物料列表列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpGet]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "List")]
 | 
			
		||||
    public async Task<List<MaterialListOutput>> List()
 | 
			
		||||
    {
 | 
			
		||||
        return await _rep.AsQueryable().Select<MaterialListOutput>().ToListAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取物料列表列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpGet]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "ListBySourceId")]
 | 
			
		||||
    public async Task<List<MaterialListOutput>> ListBySourceId(long? sourceId)
 | 
			
		||||
    {
 | 
			
		||||
        return await _rep.AsQueryable().WhereIF(sourceId > 0, u => u.SourceId == sourceId).Select<MaterialListOutput>().ToListAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -163,6 +163,5 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient
 | 
			
		|||
    {
 | 
			
		||||
        return await _rep.GetFirstAsync(a => a.Code == productCode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -151,7 +151,6 @@ public class ProductRetrospectService : IDynamicApiController, ITransient
 | 
			
		|||
        return await _rep.AsQueryable().Select<ProductRetrospectOutput>().Where(a => !a.IsDelete).ToListAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取商品追溯列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -164,42 +163,7 @@ public class ProductRetrospectService : IDynamicApiController, ITransient
 | 
			
		|||
        return await _rep.AsQueryable().Where(u => !u.IsDelete && u.Code == productCode).Select<ProductRetrospectOutput>().ToListAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 查询打印条码状态
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="productCode"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    [HttpGet]
 | 
			
		||||
    [ApiDescriptionSettings(Name = "CheckCodeStatus")]
 | 
			
		||||
    public async Task<int> CheckCodeStatus(string? productCode)
 | 
			
		||||
    {
 | 
			
		||||
        var codeEnt = await _rep.AsQueryable().Where(u => !u.IsDelete && u.Code == productCode).Select<ProductRetrospectOutput>().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)
 | 
			
		||||
    public async Task AddRetrospect(PrintCodeDetail item ,ReportTable report,string receipt, string location ,long? sourceId)
 | 
			
		||||
    {
 | 
			
		||||
        var userId = _userManager.UserId;
 | 
			
		||||
        var userName = _userManager.RealName;
 | 
			
		||||
| 
						 | 
				
			
			@ -212,7 +176,7 @@ public class ProductRetrospectService : IDynamicApiController, ITransient
 | 
			
		|||
            CodeType = item.CodeName,
 | 
			
		||||
            Location = location,
 | 
			
		||||
            Department = report.ProductionLine,
 | 
			
		||||
            WarehouseID = warehousingId,
 | 
			
		||||
            //WarehouseID = input.WarehouseId,
 | 
			
		||||
            WarehousingDate = DateTime.Now,
 | 
			
		||||
            Count = 1,
 | 
			
		||||
            CreateTime = DateTime.Now,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -190,40 +190,6 @@ 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<AddPrintCodeDetailInput, long> list = new Dictionary<AddPrintCodeDetailInput, long>();
 | 
			
		||||
        foreach (var item in topDatas)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +199,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
 | 
			
		|||
 | 
			
		||||
            var detail = new AddPrintCodeDetailInput()
 | 
			
		||||
            {
 | 
			
		||||
                ReportTableId = reprotId,
 | 
			
		||||
                ReportTableId = input.WarehousingTableId,
 | 
			
		||||
                Code = code,
 | 
			
		||||
                CodeName = codeType,
 | 
			
		||||
                ChildCount = unit.ChildUnitCount,
 | 
			
		||||
| 
						 | 
				
			
			@ -255,7 +221,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
 | 
			
		|||
                var unit2 = units.Find(a => a.Name == child.PackageName);
 | 
			
		||||
                var detail2 = new AddPrintCodeDetailInput()
 | 
			
		||||
                {
 | 
			
		||||
                    ReportTableId = reprotId,
 | 
			
		||||
                    ReportTableId = input.WarehousingTableId,
 | 
			
		||||
                    Code = code2,
 | 
			
		||||
                    CodeName = codeType,
 | 
			
		||||
                    ChildCount = unit2.ChildUnitCount,
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +245,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
 | 
			
		|||
                    var unit3 = units.Find(a => a.Name == child3.PackageName);
 | 
			
		||||
                    var detail3 = new AddPrintCodeDetailInput()
 | 
			
		||||
                    {
 | 
			
		||||
                        ReportTableId = reprotId,
 | 
			
		||||
                        ReportTableId = input.WarehousingTableId,
 | 
			
		||||
                        Code = code3,
 | 
			
		||||
                        CodeName = codeType,
 | 
			
		||||
                        ChildCount = unit3.ChildUnitCount,
 | 
			
		||||
| 
						 | 
				
			
			@ -304,7 +270,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
 | 
			
		|||
                            var unit4 = units.Find(a => a.Name == child4.PackageName);
 | 
			
		||||
                            var detail4 = new AddPrintCodeDetailInput()
 | 
			
		||||
                            {
 | 
			
		||||
                                ReportTableId = reprotId,
 | 
			
		||||
                                ReportTableId = input.WarehousingTableId,
 | 
			
		||||
                                Code = code4,
 | 
			
		||||
                                CodeName = codeType,
 | 
			
		||||
                                ChildCount = unit4.ChildUnitCount,
 | 
			
		||||
| 
						 | 
				
			
			@ -329,7 +295,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
 | 
			
		|||
                                    var unit5 = units.Find(a => a.Name == child5.PackageName);
 | 
			
		||||
                                    var detail5 = new AddPrintCodeDetailInput()
 | 
			
		||||
                                    {
 | 
			
		||||
                                        ReportTableId = reprotId,
 | 
			
		||||
                                        ReportTableId = input.WarehousingTableId,
 | 
			
		||||
                                        Code = code5,
 | 
			
		||||
                                        CodeName = codeType,
 | 
			
		||||
                                        ChildCount = unit5.ChildUnitCount,
 | 
			
		||||
| 
						 | 
				
			
			@ -382,7 +348,14 @@ 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))
 | 
			
		||||
        //{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -229,5 +229,4 @@ public class UpdateReportTableInput : ReportTableBaseInput
 | 
			
		|||
public class QueryByIdReportTableInput : DeleteReportTableInput
 | 
			
		||||
{
 | 
			
		||||
    public string? Code { get; set; }
 | 
			
		||||
    public long? SourceId { get; set; }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ public class ReportTableService : IDynamicApiController, ITransient
 | 
			
		|||
                item.ReportTableId = entity.Id;
 | 
			
		||||
                var ent = item.Adapt<PrintCodeDetail>();
 | 
			
		||||
                await _codeDetailService.UpdateByEntity(ent);
 | 
			
		||||
                await _productRetrospectService.AddRetrospect(ent, entity, "汇报单", entity.ProductionLine, entity.Id, null);
 | 
			
		||||
                await _productRetrospectService.AddRetrospect(ent, entity, "汇报单", entity.ProductionLine, entity.Id);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ public class ReportTableService : IDynamicApiController, ITransient
 | 
			
		|||
    [ApiDescriptionSettings(Name = "Detail")]
 | 
			
		||||
    public async Task<ReportTable> Detail([FromQuery] QueryByIdReportTableInput input)
 | 
			
		||||
    {
 | 
			
		||||
        return await _rep.GetFirstAsync(u => u.Id == input.Id || (input.SourceId > 0 && u.SourceId == input.SourceId));
 | 
			
		||||
        return await _rep.GetFirstAsync(u => u.Id == input.Id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -261,9 +261,9 @@ public class ReportTableService : IDynamicApiController, ITransient
 | 
			
		|||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(unitGroup));
 | 
			
		||||
        }
 | 
			
		||||
        var unit = units.Find(a => a.Name == input.Package);
 | 
			
		||||
        var unit = units.Find(a => a.Name == input.Name);
 | 
			
		||||
        if (unit == null)
 | 
			
		||||
            throw new ArgumentNullException(nameof(unit));
 | 
			
		||||
            throw new ArgumentNullException(nameof(unitGroup));
 | 
			
		||||
 | 
			
		||||
        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,7 +292,6 @@ public class ReportTableService : IDynamicApiController, ITransient
 | 
			
		|||
                BaseUnit = baseUnit,
 | 
			
		||||
                PrintCodeTime = DateTime.Now,
 | 
			
		||||
                CreateUserId = userId,
 | 
			
		||||
                MaterialsId = input.MaterialsId,
 | 
			
		||||
                CreateUserName = userName
 | 
			
		||||
            };
 | 
			
		||||
            var detailId = await _codeDetailService.Add(detail);
 | 
			
		||||
| 
						 | 
				
			
			@ -308,7 +307,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, 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 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 detailId2 = await _codeDetailService.Add(detail2);
 | 
			
		||||
                var treeData2 = detail2.Adapt<PrintCodeTreeData>();
 | 
			
		||||
                if (tempUnits.Count > 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -319,7 +318,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, 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 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 detailId3 = await _codeDetailService.Add(detail3);
 | 
			
		||||
                        var treeData3 = detail3.Adapt<PrintCodeTreeData>();
 | 
			
		||||
                        if (tempUnits.Count > 2)
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +329,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, 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 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 treeData4 = detail4.Adapt<PrintCodeTreeData>();
 | 
			
		||||
                                treeData3.Children.Add(treeData4);
 | 
			
		||||
                            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,8 +2,6 @@
 | 
			
		|||
using Admin.NET.Application.Const;
 | 
			
		||||
using Admin.NET.Application.Entity;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using SqlSugar;
 | 
			
		||||
 | 
			
		||||
namespace Admin.NET.Application;
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 调库出库服务
 | 
			
		||||
| 
						 | 
				
			
			@ -132,7 +130,7 @@ public class WarehouseTransferService : IDynamicApiController, ITransient
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 商品调库
 | 
			
		||||
    /// 商品出货
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="input"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
| 
						 | 
				
			
			@ -229,8 +227,34 @@ public class WarehouseTransferService : IDynamicApiController, ITransient
 | 
			
		|||
        foreach (var item in list)
 | 
			
		||||
        {
 | 
			
		||||
            var report = await GetReport(item.ReportTableId);
 | 
			
		||||
            await _productRetrospect.AddRetrospect(item.Adapt<PrintCodeDetail>(), report, "调库出库单", "", item.ReportTableId, input.WarehousingTableId);
 | 
			
		||||
            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<long, ReportTable> reportDic = new Dictionary<long, ReportTable>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,8 +2,6 @@
 | 
			
		|||
using Admin.NET.Application.Const;
 | 
			
		||||
using Admin.NET.Application.Entity;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Mapster;
 | 
			
		||||
 | 
			
		||||
namespace Admin.NET.Application;
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 入库统计服务
 | 
			
		||||
| 
						 | 
				
			
			@ -15,12 +13,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<WarehousingStatistics> rep,
 | 
			
		||||
        UserManager userManager,
 | 
			
		||||
| 
						 | 
				
			
			@ -29,9 +27,8 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
        SysUnitService sysUnitService,
 | 
			
		||||
        PrintCodeDetailService codeDetailService,
 | 
			
		||||
        ProductRetrospectService productRetrospect,
 | 
			
		||||
        ReportDetailTableService reportDetailTable,
 | 
			
		||||
        ReportTableService reportTableService,
 | 
			
		||||
        WarehouseService warehouseService)
 | 
			
		||||
        MaterialClassifyService materialClassifyService,
 | 
			
		||||
        ReportDetailTableService reportDetailTable)
 | 
			
		||||
    {
 | 
			
		||||
        _rep = rep;
 | 
			
		||||
        _userManager = userManager;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,9 +37,9 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
        _sysUnitService = sysUnitService;
 | 
			
		||||
        _codeDetailService = codeDetailService;
 | 
			
		||||
        _productRetrospect = productRetrospect;
 | 
			
		||||
        _materialClassifyService = materialClassifyService;
 | 
			
		||||
        //_productWarehousing = productWarehousing;
 | 
			
		||||
        _reportDetailTable = reportDetailTable;
 | 
			
		||||
        _reportTableService = reportTableService;
 | 
			
		||||
        _warehouseService = warehouseService;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -179,9 +176,7 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
        var details = await _warehouseDetails.List();
 | 
			
		||||
        var userId = _userManager.UserId;
 | 
			
		||||
        var userName = _userManager.RealName;
 | 
			
		||||
        ReportTable reportTable = null;
 | 
			
		||||
        var warehouse = await _warehouseService.Detail(new QueryByIdWarehouseInput() { Id = input.WarehouseId.Value });
 | 
			
		||||
        var warehouseName = warehouse == null ? "" : warehouse.Name;
 | 
			
		||||
        ReportDetailTable reportTable = null;
 | 
			
		||||
        foreach (var item in input.CodeDatas)
 | 
			
		||||
        {
 | 
			
		||||
            var product = await _codeDetailService.GetByProductCode(item);
 | 
			
		||||
| 
						 | 
				
			
			@ -190,44 +185,16 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            //product.WarehouseID = input.WarehouseId;
 | 
			
		||||
            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
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            reportTable = await _reportDetailTable.Detail(new QueryByIdReportDetailTableInput() { Id = product.ReportTableId.Value });
 | 
			
		||||
            if (reportTable!=null)
 | 
			
		||||
            {
 | 
			
		||||
                var materials = await _materialsService.GetById(reportTable.MaterialsId);
 | 
			
		||||
                if (materials == null)
 | 
			
		||||
                    continue;
 | 
			
		||||
                var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId);
 | 
			
		||||
                var baseUnit = units.FirstOrDefault().Name;
 | 
			
		||||
                var baseUnit = units.LastOrDefault().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))
 | 
			
		||||
                {
 | 
			
		||||
                    
 | 
			
		||||
| 
						 | 
				
			
			@ -247,11 +214,36 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
                    newEnt.BaseCount = unit.Rate;
 | 
			
		||||
                    newEnt.WarehouseId = input.WarehouseId;
 | 
			
		||||
                    newEnt.GoodCode = item;
 | 
			
		||||
                    newEnt.MaterialsNum = materials.CodeNum;
 | 
			
		||||
                    newEnt.MaterialsNum = reportTable.ProductCodeNum;
 | 
			
		||||
                    var addId = await _warehouseDetails.Add(newEnt);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                await _productRetrospect.AddRetrospect(product, reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                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);
 | 
			
		||||
 | 
			
		||||
                var childs = codeDetails.FindAll(a => a.FatherCode == item);
 | 
			
		||||
                if (childs.Count>0)
 | 
			
		||||
| 
						 | 
				
			
			@ -259,7 +251,30 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
                    var currentUnit = units.FirstOrDefault(a => a.Name == childs.FirstOrDefault().Unit);
 | 
			
		||||
                    foreach (var c1 in childs)
 | 
			
		||||
                    {
 | 
			
		||||
                        await _productRetrospect.AddRetrospect(c1.Adapt<PrintCodeDetail>(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId);
 | 
			
		||||
                        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);
 | 
			
		||||
 | 
			
		||||
                        var childs3 = codeDetails.FindAll(a => a.FatherCode == c1.Code);
 | 
			
		||||
                        if (childs3.Count > 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -267,14 +282,61 @@ public class WarehousingStatisticsService : IDynamicApiController, ITransient
 | 
			
		|||
                            var currentUnit3 = units.FirstOrDefault(a => a.Name == childs3.FirstOrDefault().Unit);
 | 
			
		||||
                            foreach (var c3 in childs3)
 | 
			
		||||
                            {
 | 
			
		||||
                                await _productRetrospect.AddRetrospect(c3.Adapt<PrintCodeDetail>(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId);
 | 
			
		||||
                                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);
 | 
			
		||||
 | 
			
		||||
                                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)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        await _productRetrospect.AddRetrospect(c4.Adapt<PrintCodeDetail>(), reportTable, "入库单", warehouseName, reportTable.Id, input.WarehouseId);
 | 
			
		||||
                                        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);
 | 
			
		||||
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
| 
						 | 
				
			
			@ -286,11 +348,34 @@ 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<WarehouseDetails>());
 | 
			
		||||
        //}
 | 
			
		||||
        //else
 | 
			
		||||
        //{
 | 
			
		||||
        //    var newEnt = warehousing.Adapt<AddWarehouseDetailsInput>();
 | 
			
		||||
        //    newEnt.SourceId = warehousing.Id;
 | 
			
		||||
        //    var addId = await _warehouseDetails.Add(newEnt);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        var newDetail = reportTable.Adapt<AddWarehousingStatisticsInput>();
 | 
			
		||||
        if (reportTable!=null)
 | 
			
		||||
        {
 | 
			
		||||
            newDetail.SourceId = reportTable?.Id;
 | 
			
		||||
        }
 | 
			
		||||
        newDetail.SourceId = reportTable.Id;
 | 
			
		||||
        await Add(newDetail);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,6 @@ enum Api {
 | 
			
		|||
  PageMaterials = '/api/materials/page',
 | 
			
		||||
  DetailMaterials = '/api/materials/detail',
 | 
			
		||||
  ListMaterials = '/api/materials/list',
 | 
			
		||||
  MtListBySourceId = '/api/materialList/listBySourceId'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 增加物料
 | 
			
		||||
| 
						 | 
				
			
			@ -57,11 +56,3 @@ export const listMaterials = () =>
 | 
			
		|||
			data: { },
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 附带的物料列表
 | 
			
		||||
export const materialListBySourceId = (sourceId: any) => 
 | 
			
		||||
	request({
 | 
			
		||||
			url: Api.MtListBySourceId,
 | 
			
		||||
			method: 'get',
 | 
			
		||||
			data: { sourceId },
 | 
			
		||||
		});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
<template>
 | 
			
		||||
	<div class="invoice-container">
 | 
			
		||||
		<el-dialog v-model="isShowDialog" :width="860" draggable="">
 | 
			
		||||
		<el-dialog v-model="isShowDialog" :width="800" draggable="">
 | 
			
		||||
			<template #header>
 | 
			
		||||
				<div style="color: #fff">
 | 
			
		||||
					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
 | 
			
		||||
					<span>{{ props.title }}</span>
 | 
			
		||||
				</div>
 | 
			
		||||
			</template>
 | 
			
		||||
			<el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" >
 | 
			
		||||
			<el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
 | 
			
		||||
				<el-row :gutter="35">
 | 
			
		||||
					<el-form-item v-show="false">
 | 
			
		||||
						<el-input v-model="ruleForm.id" />
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,7 @@
 | 
			
		|||
						</el-form-item>
 | 
			
		||||
					</el-col>
 | 
			
		||||
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 | 
			
		||||
						<el-form-item label="业务类型" prop="businessType" :rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
 | 
			
		||||
						<el-form-item label="业务类型" prop="businessType">
 | 
			
		||||
						<el-select v-model="ruleForm.businessType" placeholder="请选择" clearable>
 | 
			
		||||
                            <el-option label="销售出库" value="销售出库" />
 | 
			
		||||
                            <el-option label="其他出库" value="其他出库" />
 | 
			
		||||
| 
						 | 
				
			
			@ -39,9 +39,9 @@
 | 
			
		|||
						</el-form-item>
 | 
			
		||||
					</el-col>
 | 
			
		||||
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 | 
			
		||||
						<el-form-item label="仓库" prop="warehouseId" :rules="[{ required: true, message: '仓库不能为空', trigger: 'blur' }]">
 | 
			
		||||
                            <el-select v-model="ruleForm.warehouseId" placeholder="请选择" clearable  @change="warehouseChange">
 | 
			
		||||
                                <el-option :label="item.name" :value="item.id" v-for="item, index in warehouses"
 | 
			
		||||
						<el-form-item label="仓库" prop="warehouse" :rules="[{ required: true, message: '仓库不能为空', trigger: 'blur' }]">
 | 
			
		||||
                            <el-select v-model="ruleForm.warehouse" placeholder="请选择" clearable >
 | 
			
		||||
                                <el-option :label="item.name" :value="item.name" v-for="item, index in warehouses"
 | 
			
		||||
                                    :key="index" />
 | 
			
		||||
                            </el-select>
 | 
			
		||||
						</el-form-item>
 | 
			
		||||
| 
						 | 
				
			
			@ -97,52 +97,6 @@
 | 
			
		|||
						</el-form-item>
 | 
			
		||||
					</el-col>
 | 
			
		||||
				</el-row>
 | 
			
		||||
 | 
			
		||||
				<el-card class="full-table" shadow="hover" style="margin-top: 5px">
 | 
			
		||||
      <el-table
 | 
			
		||||
				:data="ruleForm.tableData"
 | 
			
		||||
				style="width: 100%"
 | 
			
		||||
				v-loading="loading"
 | 
			
		||||
				tooltip-effect="light"
 | 
			
		||||
				row-key="id"
 | 
			
		||||
				border="">
 | 
			
		||||
        <el-table-column prop="materialsId" label="物料" width="180" align="center">
 | 
			
		||||
			<template #default="scope">
 | 
			
		||||
				<el-select v-model="scope.row.materialsId" placeholder="请选择" autocomplete="off" controls-position="right" clearable @change="materialsChange">
 | 
			
		||||
                     <el-option :label="item.name" :value="item.id" v-for="item, index in materials" :key="index" />
 | 
			
		||||
                </el-select>
 | 
			
		||||
			</template>
 | 
			
		||||
		</el-table-column>
 | 
			
		||||
        <el-table-column prop="unit" label="单位" width="120"  show-overflow-tooltip="" >
 | 
			
		||||
            <template #default="scope">
 | 
			
		||||
				<el-select v-model="scope.row.unit" placeholder="请选择" clearable autocomplete="off" >
 | 
			
		||||
                       <el-option :label="item.name" :value="item.name" v-for="item, index in units" :key="index" />
 | 
			
		||||
                </el-select>
 | 
			
		||||
			</template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
		<el-table-column prop="count" label="数量" width="100"  show-overflow-tooltip="" >
 | 
			
		||||
            <template #default="scope">
 | 
			
		||||
				<el-input-number v-model="scope.row.count" autocomplete="off" controls-position="right"/>
 | 
			
		||||
			</template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column prop="remarks" label="备注" width="140"  show-overflow-tooltip="" >
 | 
			
		||||
			<template #default="scope">
 | 
			
		||||
				<el-input v-model="scope.row.remarks" autocomplete="off" />
 | 
			
		||||
			</template>
 | 
			
		||||
		</el-table-column>
 | 
			
		||||
        <el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" >
 | 
			
		||||
            <template #default="scope">
 | 
			
		||||
				<el-button link type="primary" icon="el-icon-delete" @click.prevent="handleColDelete(scope.$index)">删除</el-button>
 | 
			
		||||
			</template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
      </el-table>
 | 
			
		||||
        <div style="text-align: left; margin-top: 10px">
 | 
			
		||||
			<el-button icon="ele-Plus" @click="addColumn">新增物料</el-button>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
    </el-card>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			</el-form>
 | 
			
		||||
			<template #footer>
 | 
			
		||||
				<span class="dialog-footer">
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +114,7 @@
 | 
			
		|||
}
 | 
			
		||||
</style>
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
	import { ref, onMounted, reactive } from 'vue';
 | 
			
		||||
	import { ref,onMounted } from "vue";
 | 
			
		||||
	import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
 | 
			
		||||
	import { ElMessage } from "element-plus";
 | 
			
		||||
	import type { FormRules } from "element-plus";
 | 
			
		||||
| 
						 | 
				
			
			@ -168,9 +122,6 @@
 | 
			
		|||
	import { listWarehouse } from '/@/api/main/warehouse';
 | 
			
		||||
	import { listSupplier } from '/@/api/main/supplier';
 | 
			
		||||
	import { listCustom } from '/@/api/main/custom';
 | 
			
		||||
	import { listMaterials, detailMaterials, materialListBySourceId } from '/@/api/main/materials';
 | 
			
		||||
	import { listUnitGroup } from '/@/api/main/unit';
 | 
			
		||||
	import { getCurrentDate } from '/@/utils/formatTime';
 | 
			
		||||
 | 
			
		||||
	//父级传递来的参数
 | 
			
		||||
	var props = defineProps({
 | 
			
		||||
| 
						 | 
				
			
			@ -187,36 +138,23 @@
 | 
			
		|||
	const warehouses = ref<any>([]);
 | 
			
		||||
	const suppliers = ref<any>([]);
 | 
			
		||||
	const customs = ref<any>([]);
 | 
			
		||||
	const loading = ref(false);
 | 
			
		||||
	var colIndex = 0;
 | 
			
		||||
	const materials = ref<any>([]);
 | 
			
		||||
	const units = ref<any>([]);
 | 
			
		||||
	const tableData = ref<any>([]);
 | 
			
		||||
 | 
			
		||||
	//自行添加其他规则
 | 
			
		||||
	const rules = ref<FormRules>({
 | 
			
		||||
		// businessType: [{required: true, message: '请输入业务类型!', trigger: 'blur',},],
 | 
			
		||||
		// custom: [{required: true, message: '请输入客户!', trigger: 'blur',},],
 | 
			
		||||
		// warehouse: [{required: true, message: '请输入仓库!', trigger: 'blur',},],
 | 
			
		||||
		businessType: [{required: true, message: '请输入业务类型!', trigger: 'blur',},],
 | 
			
		||||
		custom: [{required: true, message: '请输入客户!', trigger: 'blur',},],
 | 
			
		||||
		warehouse: [{required: true, message: '请输入仓库!', trigger: 'blur',},],
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	// 打开弹窗
 | 
			
		||||
	const openDialog = async (row: any) => {
 | 
			
		||||
		// ruleForm = JSON.parse(JSON.stringify(row));
 | 
			
		||||
		// ruleForm.value = JSON.parse(JSON.stringify(row));
 | 
			
		||||
		// 改用detail获取最新数据来编辑
 | 
			
		||||
		let rowData = JSON.parse(JSON.stringify(row));
 | 
			
		||||
		if (rowData.id)
 | 
			
		||||
		{
 | 
			
		||||
			ruleForm.value = (await detailInvoice(rowData.id)).data.result;
 | 
			
		||||
			ruleForm.value.tableData = (await materialListBySourceId(rowData.id)).data.result;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			ruleForm.value = rowData;
 | 
			
		||||
			ruleForm.value.codeNum = getCurrentDate();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		materials.value = (await listMaterials()).data.result;
 | 
			
		||||
		isShowDialog.value = true;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +173,6 @@
 | 
			
		|||
	const submit = async () => {
 | 
			
		||||
		ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
 | 
			
		||||
			if (isValid) {
 | 
			
		||||
				console.log('true');
 | 
			
		||||
				let values = ruleForm.value;
 | 
			
		||||
				if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
 | 
			
		||||
					await addInvoice(values);
 | 
			
		||||
| 
						 | 
				
			
			@ -244,7 +181,6 @@
 | 
			
		|||
				}
 | 
			
		||||
				closeDialog();
 | 
			
		||||
			} else {
 | 
			
		||||
				console.log('flase');
 | 
			
		||||
				ElMessage({
 | 
			
		||||
					message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
 | 
			
		||||
					type: "error",
 | 
			
		||||
| 
						 | 
				
			
			@ -253,37 +189,11 @@
 | 
			
		|||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 * 物料值变更
 | 
			
		||||
 * @param clearBindUserId 是否清空
 | 
			
		||||
 */
 | 
			
		||||
 const materialsChange = async (value : any) => {
 | 
			
		||||
	//ruleForm.value.materialsId=value.id;
 | 
			
		||||
	let material = (await detailMaterials(value)).data.result;
 | 
			
		||||
	//console.log(material);
 | 
			
		||||
	if(material.id){
 | 
			
		||||
		var res = await listUnitGroup(material.unitGroupId ?? 0);
 | 
			
		||||
		units.value = res.data.result ?? [];
 | 
			
		||||
	}
 | 
			
		||||
    
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 增加列
 | 
			
		||||
function addColumn() {
 | 
			
		||||
	//console.log('object');	
 | 
			
		||||
	tableData.value.push({
 | 
			
		||||
		materialsId: 0,
 | 
			
		||||
		unit: '箱',
 | 
			
		||||
		count:1,
 | 
			
		||||
		remarks: '',
 | 
			
		||||
		sourceId:0,
 | 
			
		||||
		index: tableData.value.length+1,
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	ruleForm.value.tableData = tableData.value;
 | 
			
		||||
	colIndex++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// 页面加载时
 | 
			
		||||
	onMounted(async () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -292,43 +202,6 @@ function addColumn() {
 | 
			
		|||
		customs.value = (await listCustom()).data.result;
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	const warehouseChange = async (value : any) => {
 | 
			
		||||
	//ruleForm.value.materialsId=value.id;
 | 
			
		||||
	let dir = warehouses.value.find((item) => item.id === value);
 | 
			
		||||
	// console.log(dir.name);
 | 
			
		||||
    ruleForm.value.warehouse = dir.name;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	function handleColDelete(index: number) {
 | 
			
		||||
		tableData.value.splice(index, 1);
 | 
			
		||||
		ruleForm.value.tableData = tableData.value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 上移
 | 
			
		||||
function handleColUp(record: any, index: number) {
 | 
			
		||||
	if (record) {
 | 
			
		||||
		var data1 = ChangeExForArray(index, index - 1, ruleForm.value.tableData);
 | 
			
		||||
		return data1;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 下移
 | 
			
		||||
function handleColDown(record: any, index: number) {
 | 
			
		||||
	if (record) {
 | 
			
		||||
		return ChangeExForArray(index, index + 1, ruleForm.value.tableData);
 | 
			
		||||
	}
 | 
			
		||||
	//console.log(record);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function ChangeExForArray(index1: number, index2: number, array: Array<any>) {
 | 
			
		||||
	//console.log(array);
 | 
			
		||||
	let temp = array[index1];
 | 
			
		||||
	array[index1] = array[index2];
 | 
			
		||||
	array[index2] = temp;
 | 
			
		||||
	return array;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	//将属性或者函数暴露给父组件
 | 
			
		||||
	defineExpose({ openDialog });
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue