main
liangzongpeng 2024-06-14 18:08:48 +08:00
parent 45150bfe78
commit 7281564696
39 changed files with 3359 additions and 734 deletions

View File

@ -0,0 +1,46 @@
using Admin.NET.Core;
namespace Admin.NET.Application.Entity;
/// <summary>
/// 分销出库
/// </summary>
[SugarTable("DistributorInvoice","分销出库")]
public class DistributorInvoice : EntityTenant
{
/// <summary>
/// 仓库ID
/// </summary>
[SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")]
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
[SugarColumn(ColumnName = "TargetWarehouseId", ColumnDescription = "目标仓库ID")]
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 分销商ID
/// </summary>
[SugarColumn(ColumnName = "DistributorId", ColumnDescription = "分销商ID")]
public long? DistributorId { get; set; }
/// <summary>
/// 分销商
/// </summary>
[SugarColumn(ColumnName = "Distributor", ColumnDescription = "分销商", Length = 32)]
public string? Distributor { get; set; }
/// <summary>
/// 业务日期
/// </summary>
[SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")]
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)]
public string? Remarks { get; set; }
}

View File

@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity;
/// <summary>
/// 发货通知单
/// </summary>
[SugarTable("Invoice","发货通知单")]
[SugarTable("invoice","发货通知单")]
public class Invoice : EntityTenant
{
/// <summary>
@ -22,18 +22,21 @@ public class Invoice : EntityTenant
/// <summary>
/// 业务类型
/// </summary>
[Required]
[SugarColumn(ColumnName = "BusinessType", ColumnDescription = "业务类型", Length = 32)]
public string BusinessType { get; set; }
/// <summary>
/// 客户
/// </summary>
[Required]
[SugarColumn(ColumnName = "Custom", ColumnDescription = "客户", Length = 32)]
public string Custom { get; set; }
/// <summary>
/// 仓库
/// </summary>
[Required]
[SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 32)]
public string Warehouse { get; set; }
@ -97,4 +100,10 @@ public class Invoice : EntityTenant
[SugarColumn(ColumnName = "SendOutExpand", ColumnDescription = "发货拓展", Length = 32)]
public string? SendOutExpand { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
[SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")]
public long? WarehouseId { get; set; }
}

View File

@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity;
/// <summary>
/// 出库单
/// </summary>
[SugarTable("Outbound","出库单")]
[SugarTable("outbound","出库单")]
public class Outbound : EntityTenant
{
/// <summary>
@ -16,15 +16,10 @@ public class Outbound : EntityTenant
/// <summary>
/// 来源单号
/// </summary>
[Required]
[SugarColumn(ColumnName = "SourceCodeNum", ColumnDescription = "来源单号", Length = 32)]
public string SourceCodeNum { get; set; }
/// <summary>
/// 业务日期
/// </summary>
[SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期", Length = 32)]
public string? StartDate { get; set; }
/// <summary>
/// 状态
/// </summary>
@ -40,15 +35,10 @@ public class Outbound : EntityTenant
/// <summary>
/// 收货单位
/// </summary>
[Required]
[SugarColumn(ColumnName = "Consignee", ColumnDescription = "收货单位", Length = 32)]
public string Consignee { get; set; }
/// <summary>
/// 仓库
/// </summary>
[SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库")]
public string? Warehouse { get; set; }
/// <summary>
/// 审核人ID
/// </summary>
@ -67,4 +57,22 @@ public class Outbound : EntityTenant
[SugarColumn(ColumnName = "OutboundExpandString", ColumnDescription = "出库单字符串拓展字段", Length = 64)]
public string? OutboundExpandString { get; set; }
/// <summary>
/// 仓库
/// </summary>
[SugarColumn(ColumnName = "Warehouse", ColumnDescription = "仓库", Length = 255)]
public string? Warehouse { get; set; }
/// <summary>
/// 业务日期
/// </summary>
[SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")]
public DateTime? StartDate { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
[SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "仓库ID")]
public long? WarehouseId { get; set; }
}

View File

@ -0,0 +1,23 @@
using Admin.NET.Core;
namespace Admin.NET.Application.Entity;
/// <summary>
/// 出库详细
/// </summary>
[SugarTable("OutboundDetail","出库详细")]
public class OutboundDetail : EntityBaseId
{
/// <summary>
/// 出库单ID
/// </summary>
[SugarColumn(ColumnName = "OutboundId", ColumnDescription = "出库单ID")]
public long? OutboundId { get; set; }
/// <summary>
/// 条码ID列表
/// </summary>
[SugarColumn(ColumnName = "CodeTableIds", ColumnDescription = "条码ID列表", ColumnDataType = StaticConfig.CodeFirst_BigString)]
[Required]
public string? CodeTableIds { get; set; }
}

View File

@ -4,7 +4,7 @@ namespace Admin.NET.Application.Entity;
/// <summary>
/// 打印条码详情
/// </summary>
[SugarTable("PrintCodeDetail","打印条码详情")]
[SugarTable("printcodedetail","打印条码详情")]
public class PrintCodeDetail : EntityBase
{
/// <summary>
@ -97,4 +97,10 @@ public class PrintCodeDetail : EntityBase
[SugarColumn(ColumnName = "FatherId", ColumnDescription = "父节点ID")]
public long? FatherId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")]
public long? MaterialsId { get; set; }
}

View File

@ -0,0 +1,34 @@
using Admin.NET.Core;
namespace Admin.NET.Application.Entity;
/// <summary>
/// 调库出库
/// </summary>
[SugarTable("warehousetransfer","调库出库")]
public class WarehouseTransfer : EntityTenant
{
/// <summary>
/// 原仓库ID
/// </summary>
[SugarColumn(ColumnName = "WarehouseId", ColumnDescription = "原仓库ID")]
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
[SugarColumn(ColumnName = "TargetWarehouseId", ColumnDescription = "目标仓库ID")]
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
[SugarColumn(ColumnName = "StartDate", ColumnDescription = "业务日期")]
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 32)]
public string? Remarks { get; set; }
}

View File

@ -114,10 +114,12 @@ public class DistributorService : IDynamicApiController, ITransient
[ApiDescriptionSettings(Name = "List")]
public async Task<List<DistributorOutput>> List()
{
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<DistributorOutput>().ToListAsync();
return await _rep.AsQueryable().Select<DistributorOutput>().Where(a => !a.IsDelete).ToListAsync();
}
}

View File

@ -0,0 +1,286 @@
using Admin.NET.Core.Service;
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
namespace Admin.NET.Application;
/// <summary>
/// 分销出库服务
/// </summary>
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
public class DistributorInvoiceService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<DistributorInvoice> _rep;
private readonly PrintCodeDetailService _codeDetailService;
private readonly ProductRetrospectService _productRetrospect;
private readonly ReportTableService _reportTableService;
private readonly OutboundService _outboundService;
private readonly OutboundDetailService _outboundDetailService;
private readonly UserManager _userManager;
public DistributorInvoiceService(SqlSugarRepository<DistributorInvoice> rep,
UserManager userManager,
PrintCodeDetailService codeDetailService,
ReportTableService reportTableService,
OutboundService outboundService,
OutboundDetailService outboundDetailService,
ProductRetrospectService productRetrospect)
{
_rep = rep;
_userManager = userManager;
_codeDetailService = codeDetailService;
_productRetrospect = productRetrospect;
_reportTableService = reportTableService;
_outboundService = outboundService;
_outboundDetailService = outboundDetailService;
}
/// <summary>
/// 分页查询分销出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Page")]
public async Task<SqlSugarPagedList<DistributorInvoiceOutput>> Page(DistributorInvoiceInput input)
{
var query = _rep.AsQueryable().Where(a => !a.IsDelete)
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
u.Distributor.Contains(input.SearchKey.Trim())
|| u.Remarks.Contains(input.SearchKey.Trim())
)
.WhereIF(input.WarehouseId>0, u => u.WarehouseId == input.WarehouseId)
.WhereIF(input.TargetWarehouseId>0, u => u.TargetWarehouseId == input.TargetWarehouseId)
.WhereIF(input.DistributorId>0, u => u.DistributorId == input.DistributorId)
.WhereIF(!string.IsNullOrWhiteSpace(input.Distributor), u => u.Distributor.Contains(input.Distributor.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim()))
.Select<DistributorInvoiceOutput>();
if(input.StartDateRange != null && input.StartDateRange.Count >0)
{
DateTime? start= input.StartDateRange[0];
query = query.WhereIF(start.HasValue, u => u.StartDate > start);
if (input.StartDateRange.Count >1 && input.StartDateRange[1].HasValue)
{
var end = input.StartDateRange[1].Value.AddDays(1);
query = query.Where(u => u.StartDate < end);
}
}
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
}
/// <summary>
/// 增加分销出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Add")]
public async Task<long> Add(AddDistributorInvoiceInput input)
{
var entity = input.Adapt<DistributorInvoice>();
await _rep.InsertAsync(entity);
return entity.Id;
}
/// <summary>
/// 删除分销出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Delete")]
public async Task Delete(DeleteDistributorInvoiceInput input)
{
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
await _rep.FakeDeleteAsync(entity); //假删除
//await _rep.DeleteAsync(entity); //真删除
}
/// <summary>
/// 更新分销出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Update")]
public async Task Update(UpdateDistributorInvoiceInput input)
{
var entity = input.Adapt<DistributorInvoice>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
/// <summary>
/// 获取分销出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "Detail")]
public async Task<DistributorInvoice> Detail([FromQuery] QueryByIdDistributorInvoiceInput input)
{
return await _rep.GetFirstAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取分销出库列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "List")]
public async Task<List<DistributorInvoiceOutput>> List()
{
return await _rep.AsQueryable().Select<DistributorInvoiceOutput>().Where(a => !a.IsDelete).ToListAsync();
}
/// <summary>
/// 商品出货
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "ShipmentProduct")]
public async Task ShipmentProduct(AddProductCodeInput input)
{
if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var invoice = await Detail(new QueryByIdDistributorInvoiceInput() { Id = input.WarehousingTableId.Value });
if (invoice == null)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode);
var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode));
var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList();
if (repeatCodes == null || repeatCodes.Count < 1)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var userId = _userManager.UserId;
var userName = _userManager.RealName;
var addOutbound = new AddOutboundInput()
{
//BusinessType = invoice.BusinessType,
//CodeNum = invoice.CodeNum,
//Consignee = invoice.Consignee,
CreateTime = invoice.CreateTime,
CreateUserId = userId,
CreateUserName = userName,
SourceCodeNum = invoice.Id.ToString(),
StartDate = invoice.StartDate,
State = 0,
//Warehouse = invoice.Warehouse,
WarehouseId = invoice.WarehouseId,
TenantId = invoice.TenantId,
};
var outbound = await _outboundService.Add(addOutbound);
var codeIds = new List<long>();
var list = new List<PrintCodeDetailOutput>();
foreach (var c1 in repeatCodes)
{
codeIds.Add(c1.Id);
c1.WarehouseID = null;
//c1.FatherCode = null;
//c1.FatherId = null;
await _codeDetailService.UpdateByEntity(c1.Adapt<PrintCodeDetail>());
list.Add(c1);
var child1 = details.Find(a => a.FatherCode == c1.Code);
if (child1 != null)
{
child1.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child1.Adapt<PrintCodeDetail>());
list.Add(child1);
var child2 = details.Find(a => a.FatherCode == c1.Code);
if (child2 != null)
{
child2.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child2.Adapt<PrintCodeDetail>());
list.Add(child2);
var child3 = details.Find(a => a.FatherCode == c1.Code);
if (child3 != null)
{
child3.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child3.Adapt<PrintCodeDetail>());
list.Add(child3);
var child4 = details.Find(a => a.FatherCode == c1.Code);
if (child4 != null)
{
child4.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child4.Adapt<PrintCodeDetail>());
list.Add(child4);
}
}
}
}
}
var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound };
await _outboundDetailService.Add(addOutboundDetail);
foreach (var item in list)
{
var report = await GetReport(item.ReportTableId);
var retrospect1 = new AddProductRetrospectInput()
{
BaseCount = item.BaseCount,
BaseUnit = item.BaseUnit,
//Batch = report.Batch,
BusinessType = report.ProductType,
CodeType = item.CodeName,
Location = addOutbound.Consignee,
Department = report.ProductionLine,
//WarehouseID = input.WarehouseId,
WarehousingDate = DateTime.Now,
Count = 1,
CreateTime = DateTime.Now,
ScanCodeTime = DateTime.Now,
CreateUserId = userId,
CreateUserName = userName,
MaterialsId = report.MaterialsId,
OddNumber = report.OddNumber,
Receipt = "分销出库单",
SourceId = outbound,
Unit = item.Unit,
Name = item.CodeName,
Code = item.Code,
//Destination = invoice.Consignee
};
await _productRetrospect.Add(retrospect1);
}
}
static Dictionary<long, ReportTable> reportDic = new Dictionary<long, ReportTable>();
private async Task<ReportTable> GetReport(long? reportId)
{
if (reportId == null)
{
return new ReportTable();
}
if (reportDic.ContainsKey(reportId.Value))
{
return reportDic[reportId.Value];
}
var report = await _reportTableService.GetBySource(reportId);
if (report == null)
{
return new ReportTable();
}
else
{
return report;
}
}
}

View File

@ -0,0 +1,83 @@
namespace Admin.NET.Application;
/// <summary>
/// 分销出库输出参数
/// </summary>
public class DistributorInvoiceDto
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 分销商ID
/// </summary>
public long? DistributorId { get; set; }
/// <summary>
/// 分销商
/// </summary>
public string? Distributor { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDelete { get; set; }
}

View File

@ -0,0 +1,168 @@
using Admin.NET.Core;
using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application;
/// <summary>
/// 分销出库基础输入参数
/// </summary>
public class DistributorInvoiceBaseInput
{
/// <summary>
/// 仓库ID
/// </summary>
public virtual long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public virtual long? TargetWarehouseId { get; set; }
/// <summary>
/// 分销商ID
/// </summary>
public virtual long? DistributorId { get; set; }
/// <summary>
/// 分销商
/// </summary>
public virtual string? Distributor { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public virtual DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public virtual string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public virtual long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public virtual DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public virtual DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public virtual long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public virtual string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public virtual long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public virtual string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public virtual bool IsDelete { get; set; }
}
/// <summary>
/// 分销出库分页查询输入参数
/// </summary>
public class DistributorInvoiceInput : BasePageInput
{
/// <summary>
/// 关键字查询
/// </summary>
public string? SearchKey { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 分销商ID
/// </summary>
public long? DistributorId { get; set; }
/// <summary>
/// 分销商
/// </summary>
public string? Distributor { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 业务日期范围
/// </summary>
public List<DateTime?> StartDateRange { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
}
/// <summary>
/// 分销出库增加输入参数
/// </summary>
public class AddDistributorInvoiceInput : DistributorInvoiceBaseInput
{
/// <summary>
/// 软删除
/// </summary>
[Required(ErrorMessage = "软删除不能为空")]
public override bool IsDelete { get; set; }
}
/// <summary>
/// 分销出库删除输入参数
/// </summary>
public class DeleteDistributorInvoiceInput : BaseIdInput
{
}
/// <summary>
/// 分销出库更新输入参数
/// </summary>
public class UpdateDistributorInvoiceInput : DistributorInvoiceBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 分销出库主键查询输入参数
/// </summary>
public class QueryByIdDistributorInvoiceInput : DeleteDistributorInvoiceInput
{
}

View File

@ -0,0 +1,85 @@
namespace Admin.NET.Application;
/// <summary>
/// 分销出库输出参数
/// </summary>
public class DistributorInvoiceOutput
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 分销商ID
/// </summary>
public long? DistributorId { get; set; }
/// <summary>
/// 分销商
/// </summary>
public string? Distributor { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDelete { get; set; }
}

View File

@ -1,10 +1,10 @@
namespace Admin.NET.Application;
/// <summary>
/// 发货通知单输出参数
/// </summary>
public class InvoiceDto
{
/// <summary>
/// 发货通知单输出参数
/// </summary>
public class InvoiceDto
{
/// <summary>
/// 主键Id
/// </summary>
@ -35,6 +35,12 @@
/// </summary>
public string Warehouse { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 部门
/// </summary>
@ -125,4 +131,4 @@
/// </summary>
public bool IsDelete { get; set; }
}
}

View File

@ -3,11 +3,11 @@ using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application;
/// <summary>
/// 发货通知单基础输入参数
/// </summary>
public class InvoiceBaseInput
{
/// <summary>
/// 发货通知单基础输入参数
/// </summary>
public class InvoiceBaseInput
{
/// <summary>
/// 单号
/// </summary>
@ -33,6 +33,11 @@ namespace Admin.NET.Application;
/// </summary>
public virtual string Warehouse { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 部门
/// </summary>
@ -123,13 +128,13 @@ namespace Admin.NET.Application;
/// </summary>
public virtual bool IsDelete { get; set; }
}
}
/// <summary>
/// 发货通知单分页查询输入参数
/// </summary>
public class InvoiceInput : BasePageInput
{
/// <summary>
/// 发货通知单分页查询输入参数
/// </summary>
public class InvoiceInput : BasePageInput
{
/// <summary>
/// 关键字查询
/// </summary>
@ -164,6 +169,11 @@ namespace Admin.NET.Application;
/// </summary>
public string? Warehouse { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 部门
/// </summary>
@ -203,13 +213,13 @@ namespace Admin.NET.Application;
/// </summary>
public string? DeliveryAddress { get; set; }
}
}
/// <summary>
/// 发货通知单增加输入参数
/// </summary>
public class AddInvoiceInput : InvoiceBaseInput
{
/// <summary>
/// 发货通知单增加输入参数
/// </summary>
public class AddInvoiceInput : InvoiceBaseInput
{
/// <summary>
/// 业务类型
/// </summary>
@ -234,32 +244,32 @@ namespace Admin.NET.Application;
[Required(ErrorMessage = "软删除不能为空")]
public override bool IsDelete { get; set; }
}
}
/// <summary>
/// 发货通知单删除输入参数
/// </summary>
public class DeleteInvoiceInput : BaseIdInput
{
}
/// <summary>
/// 发货通知单删除输入参数
/// </summary>
public class DeleteInvoiceInput : BaseIdInput
{
}
/// <summary>
/// 发货通知单更新输入参数
/// </summary>
public class UpdateInvoiceInput : InvoiceBaseInput
{
/// <summary>
/// 发货通知单更新输入参数
/// </summary>
public class UpdateInvoiceInput : InvoiceBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
}
/// <summary>
/// 发货通知单主键查询输入参数
/// </summary>
public class QueryByIdInvoiceInput : DeleteInvoiceInput
{
/// <summary>
/// 发货通知单主键查询输入参数
/// </summary>
public class QueryByIdInvoiceInput : DeleteInvoiceInput
{
}
}

View File

@ -35,6 +35,11 @@ public class InvoiceOutput
/// </summary>
public string Warehouse { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 部门
/// </summary>

View File

@ -2,6 +2,8 @@
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
using NewLife.Reflection;
namespace Admin.NET.Application;
/// <summary>
/// 发货通知单服务
@ -10,27 +12,27 @@ namespace Admin.NET.Application;
public class InvoiceService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Invoice> _rep;
private readonly MaterialsService _materialsService;
private readonly SysUnitService _sysUnitService;
private readonly PrintCodeDetailService _codeDetailService;
private readonly ProductRetrospectService _productRetrospect;
private readonly ReportTableService _reportTableService;
private readonly OutboundService _outboundService;
private readonly OutboundDetailService _outboundDetailService;
private readonly UserManager _userManager;
public InvoiceService(SqlSugarRepository<Invoice> rep,
UserManager userManager,
MaterialsService materialsService,
SysUnitService sysUnitService,
PrintCodeDetailService codeDetailService,
ReportTableService reportTableService,
OutboundService outboundService,
OutboundDetailService outboundDetailService,
ProductRetrospectService productRetrospect)
{
_rep = rep;
_userManager = userManager;
_materialsService = materialsService;
_sysUnitService = sysUnitService;
_codeDetailService = codeDetailService;
_productRetrospect = productRetrospect;
_reportTableService = reportTableService;
_outboundService = outboundService;
_outboundDetailService = outboundDetailService;
}
/// <summary>
@ -168,50 +170,117 @@ public class InvoiceService : IDynamicApiController, ITransient
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var repeatCodes = await _codeDetailService.GetRepeat(input.CodeDatas);
var invoice = await Detail(new QueryByIdInvoiceInput() { Id = input.WarehousingTableId.Value });
if (invoice == null)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode);
var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode));
var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList();
if (repeatCodes == null || repeatCodes.Count < 1)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var userId = _userManager.UserId;
var userName = _userManager.RealName;
var addOutbound = new AddOutboundInput()
{
BusinessType = invoice.BusinessType,
CodeNum = invoice.CodeNum,
Consignee = invoice.Consignee,
CreateTime = invoice.CreateTime,
CreateUserId = userId,
CreateUserName = userName,
SourceCodeNum = invoice.Id.ToString(),
StartDate = invoice.StartDate,
State = 0,
Warehouse = invoice.Warehouse,
WarehouseId = invoice.WarehouseId,
TenantId = invoice.TenantId,
};
var outbound = await _outboundService.Add(addOutbound);
var codeIds = new List<long>();
var list = new List<PrintCodeDetailOutput>();
foreach (var c1 in repeatCodes)
{
codeIds.Add(c1.Id);
c1.WarehouseID = null;
//c1.FatherCode = null;
//c1.FatherId = null;
await _codeDetailService.UpdateByEntity(c1.Adapt<PrintCodeDetail>());
list.Add(c1);
var child1 = details.Find(a => a.FatherCode == c1.Code);
if (child1!=null)
{
child1.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child1.Adapt<PrintCodeDetail>());
list.Add(child1);
//var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId);
//var baseUnit = units.FirstOrDefault().Name;
//var userId = _userManager.UserId;
//var userName = _userManager.RealName;
//var topDatas = input.CodeDatas.FindAll(a => string.IsNullOrEmpty(a.FatherCode));
var child2 = details.Find(a => a.FatherCode == c1.Code);
if (child2 != null)
{
child2.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child2.Adapt<PrintCodeDetail>());
list.Add(child2);
//foreach (var dic in list)
//{
// var item = dic.Key;
// var retrospect1 = new AddProductRetrospectInput()
// {
// BaseCount = item.BaseCount,
// BaseUnit = baseUnit,
// Batch = warehousing.Batch,
// BusinessType = "生产任务单",
// CodeType = item.CodeName,
// Department = warehousing.ProductionLine,
// //WarehouseID = input.WarehouseId,
// WarehousingDate = DateTime.Now,
// Count = 1,
// CreateTime = DateTime.Now,
// ScanCodeTime = DateTime.Now,
// CreateUserId = userId,
// CreateUserName = userName,
// MaterialsId = dic.Value,
// OddNumber = warehousing.OddNumber,
// Receipt = "汇报单",
// SourceId = warehousing.Id,
// Unit = item.Unit,
// Name = materials.Name,
// Code = item.Code
// };//Destination = warehousing.Supplier,
// await _productRetrospect.Add(retrospect1);
//}
var child3 = details.Find(a => a.FatherCode == c1.Code);
if (child3 != null)
{
child3.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child3.Adapt<PrintCodeDetail>());
list.Add(child3);
var child4 = details.Find(a => a.FatherCode == c1.Code);
if (child4 != null)
{
child4.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child4.Adapt<PrintCodeDetail>());
list.Add(child4);
}
}
}
}
}
var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound };
await _outboundDetailService.Add(addOutboundDetail);
foreach (var item in list)
{
var report = await GetReport(item.ReportTableId);
var retrospect1 = new AddProductRetrospectInput()
{
BaseCount = item.BaseCount,
BaseUnit = item.BaseUnit,
//Batch = report.Batch,
BusinessType = report.ProductType,
CodeType = item.CodeName,
Location=addOutbound.Consignee,
Department = report.ProductionLine,
//WarehouseID = input.WarehouseId,
WarehousingDate = DateTime.Now,
Count = 1,
CreateTime = DateTime.Now,
ScanCodeTime = DateTime.Now,
CreateUserId = userId,
CreateUserName = userName,
MaterialsId = report.MaterialsId,
OddNumber = report.OddNumber,
Receipt = "发货通知单",
SourceId = outbound,
Unit = item.Unit,
Name = item.CodeName,
Code = item.Code,
Destination = invoice.Consignee
};
await _productRetrospect.Add(retrospect1);
}
//var report = await _reportTableService.GetBySource(input.WarehousingTableId);
//if (report == null)
@ -222,8 +291,27 @@ public class InvoiceService : IDynamicApiController, ITransient
}
static Dictionary<long, ReportTable> reportDic = new Dictionary<long, ReportTable>();
private async Task<ReportTable> GetReport(long? reportId)
{
if (reportId == null)
{
return new ReportTable();
}
if (reportDic.ContainsKey(reportId.Value))
{
return reportDic[reportId.Value];
}
var report = await _reportTableService.GetBySource(reportId);
if (report == null)
{
return new ReportTable();
}
else
{
return report;
}
}
}

View File

@ -1,10 +1,10 @@
namespace Admin.NET.Application;
/// <summary>
/// 出库单输出参数
/// </summary>
public class OutboundDto
{
/// <summary>
/// 出库单输出参数
/// </summary>
public class OutboundDto
{
/// <summary>
/// 主键Id
/// </summary>
@ -23,7 +23,7 @@
/// <summary>
/// 业务日期
/// </summary>
public string? StartDate { get; set; }
public DateTime? StartDate { get; set; }
/// <summary>
/// 状态
@ -100,4 +100,8 @@
/// </summary>
public string? Warehouse { get; set; }
}
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
}

View File

@ -3,11 +3,11 @@ using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application;
/// <summary>
/// 出库单基础输入参数
/// </summary>
public class OutboundBaseInput
{
/// <summary>
/// 出库单基础输入参数
/// </summary>
public class OutboundBaseInput
{
/// <summary>
/// 单号
/// </summary>
@ -21,7 +21,7 @@ namespace Admin.NET.Application;
/// <summary>
/// 业务日期
/// </summary>
public virtual string? StartDate { get; set; }
public virtual DateTime? StartDate { get; set; }
/// <summary>
/// 状态
@ -98,13 +98,17 @@ namespace Admin.NET.Application;
/// </summary>
public virtual string? Warehouse { get; set; }
}
/// <summary>
/// 出库单分页查询输入参数
/// 仓库ID
/// </summary>
public class OutboundInput : BasePageInput
{
public long? WarehouseId { get; set; }
}
/// <summary>
/// 出库单分页查询输入参数
/// </summary>
public class OutboundInput : BasePageInput
{
/// <summary>
/// 关键字查询
/// </summary>
@ -123,7 +127,7 @@ namespace Admin.NET.Application;
/// <summary>
/// 业务日期
/// </summary>
public string? StartDate { get; set; }
public DateTime? StartDate { get; set; }
/// <summary>
/// 状态
@ -144,13 +148,13 @@ namespace Admin.NET.Application;
/// 审核人ID
/// </summary>
public long? ExaminerId { get; set; }
}
}
/// <summary>
/// 出库单增加输入参数
/// </summary>
public class AddOutboundInput : OutboundBaseInput
{
/// <summary>
/// 出库单增加输入参数
/// </summary>
public class AddOutboundInput : OutboundBaseInput
{
/// <summary>
/// 来源单号
/// </summary>
@ -169,32 +173,32 @@ namespace Admin.NET.Application;
[Required(ErrorMessage = "软删除不能为空")]
public override bool IsDelete { get; set; }
}
}
/// <summary>
/// 出库单删除输入参数
/// </summary>
public class DeleteOutboundInput : BaseIdInput
{
}
/// <summary>
/// 出库单删除输入参数
/// </summary>
public class DeleteOutboundInput : BaseIdInput
{
}
/// <summary>
/// 出库单更新输入参数
/// </summary>
public class UpdateOutboundInput : OutboundBaseInput
{
/// <summary>
/// 出库单更新输入参数
/// </summary>
public class UpdateOutboundInput : OutboundBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
}
/// <summary>
/// 出库单主键查询输入参数
/// </summary>
public class QueryByIdOutboundInput : DeleteOutboundInput
{
/// <summary>
/// 出库单主键查询输入参数
/// </summary>
public class QueryByIdOutboundInput : DeleteOutboundInput
{
}
}

View File

@ -23,7 +23,7 @@ public class OutboundOutput
/// <summary>
/// 业务日期
/// </summary>
public string? StartDate { get; set; }
public DateTime? StartDate { get; set; }
/// <summary>
/// 状态
@ -100,6 +100,11 @@ public class OutboundOutput
/// </summary>
public string? Warehouse { get; set; }
}
/// <summary>
/// 仓库ID
/// </summary>
public long? WarehouseId { get; set; }
}

View File

@ -2,6 +2,8 @@
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
using Nest;
namespace Admin.NET.Application;
/// <summary>
/// 出库单服务
@ -10,9 +12,13 @@ namespace Admin.NET.Application;
public class OutboundService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Outbound> _rep;
public OutboundService(SqlSugarRepository<Outbound> rep)
private readonly OutboundDetailService _outboundDetailService;
private readonly PrintCodeDetailService _codeDetailService;
public OutboundService(SqlSugarRepository<Outbound> rep, OutboundDetailService outboundDetailService, PrintCodeDetailService codeDetailService)
{
_rep = rep;
_outboundDetailService = outboundDetailService;
_codeDetailService = codeDetailService;
}
/// <summary>
@ -28,13 +34,11 @@ public class OutboundService : IDynamicApiController, ITransient
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
u.CodeNum.Contains(input.SearchKey.Trim())
|| u.SourceCodeNum.Contains(input.SearchKey.Trim())
|| u.StartDate.Contains(input.SearchKey.Trim())
|| u.BusinessType.Contains(input.SearchKey.Trim())
|| u.Consignee.Contains(input.SearchKey.Trim())
)
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeNum), u => u.CodeNum.Contains(input.CodeNum.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.SourceCodeNum), u => u.SourceCodeNum.Contains(input.SourceCodeNum.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.StartDate), u => u.StartDate.Contains(input.StartDate.Trim()))
.WhereIF(input.State>0, u => u.State == input.State)
.WhereIF(!string.IsNullOrWhiteSpace(input.BusinessType), u => u.BusinessType.Contains(input.BusinessType.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Consignee), u => u.Consignee.Contains(input.Consignee.Trim()))
@ -108,7 +112,74 @@ public class OutboundService : IDynamicApiController, ITransient
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<OutboundOutput>().ToListAsync();
}
/// <summary>
/// 获取出库单
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "GetOutboundDetail")]
public async Task<List<PrintCodeTreeData>> GetOutboundDetail([FromQuery] QueryByIdOutboundInput input)
{
var outbound = await _outboundDetailService.GetByOutboundId(input.Id);
if (string.IsNullOrEmpty(outbound.CodeTableIds))
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var result = new List<PrintCodeTreeData>();
var details = await _codeDetailService.List();
if (details == null || details.Count < 1)
{
return result;
}
var ids = outbound.CodeTableIds.Split(',').Select(a => Convert.ToInt64(a)).ToList();
//var printDetails = details.FindAll(a => ids.Contains(a.Id));
//if (printDetails.Count < 1)
//{
// return result;
//}
var father = details.FindAll(a => ids.Contains(a.Id));
foreach (var item in father)
{
var treeData1 = item.Adapt<PrintCodeTreeData>();
var list1 = details.FindAll(a => a.FatherId == item.Id);
if (list1.Count > 0)
{
treeData1.Children = new List<PrintCodeTreeData>();
treeData1.HasChildren = false;
foreach (var dt in list1)
{
var list2 = details.FindAll(a => a.FatherId == dt.Id);
var treeData2 = dt.Adapt<PrintCodeTreeData>();
if (list2.Count > 0)
{
treeData2.Children = new List<PrintCodeTreeData>();
treeData2.HasChildren = false;
foreach (var dt3 in list2)
{
var list3 = details.FindAll(a => a.FatherId == dt3.Id);
var treeData3 = dt3.Adapt<PrintCodeTreeData>();
if (list3.Count > 0)
{
treeData3.Children = new List<PrintCodeTreeData>();
treeData3.HasChildren = false;
foreach (var dt4 in list3)
{
var treeData4 = dt4.Adapt<PrintCodeTreeData>();
treeData3.Children.Add(treeData4);
}
}
treeData2.Children.Add(treeData3);
}
}
treeData1.Children.Add(treeData2);
}
}
result.Add(treeData1);
}
return result;
}

View File

@ -0,0 +1,23 @@
namespace Admin.NET.Application;
/// <summary>
/// 出库详细输出参数
/// </summary>
public class OutboundDetailDto
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 出库单ID
/// </summary>
public long? OutboundId { get; set; }
/// <summary>
/// 条码ID列表
/// </summary>
public string? CodeTableIds { get; set; }
}

View File

@ -0,0 +1,78 @@
using Admin.NET.Core;
using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application;
/// <summary>
/// 出库详细基础输入参数
/// </summary>
public class OutboundDetailBaseInput
{
/// <summary>
/// 出库单ID
/// </summary>
public virtual long? OutboundId { get; set; }
/// <summary>
/// 条码ID列表
/// </summary>
public virtual string? CodeTableIds { get; set; }
}
/// <summary>
/// 出库详细分页查询输入参数
/// </summary>
public class OutboundDetailInput : BasePageInput
{
/// <summary>
/// 关键字查询
/// </summary>
public string? SearchKey { get; set; }
/// <summary>
/// 出库单ID
/// </summary>
public long? OutboundId { get; set; }
/// <summary>
/// 条码ID列表
/// </summary>
public string? CodeTableIds { get; set; }
}
/// <summary>
/// 出库详细增加输入参数
/// </summary>
public class AddOutboundDetailInput : OutboundDetailBaseInput
{
}
/// <summary>
/// 出库详细删除输入参数
/// </summary>
public class DeleteOutboundDetailInput : BaseIdInput
{
}
/// <summary>
/// 出库详细更新输入参数
/// </summary>
public class UpdateOutboundDetailInput : OutboundDetailBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 出库详细主键查询输入参数
/// </summary>
public class QueryByIdOutboundDetailInput : DeleteOutboundDetailInput
{
}

View File

@ -0,0 +1,25 @@
namespace Admin.NET.Application;
/// <summary>
/// 出库详细输出参数
/// </summary>
public class OutboundDetailOutput
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 出库单ID
/// </summary>
public long? OutboundId { get; set; }
/// <summary>
/// 条码ID列表
/// </summary>
public string? CodeTableIds { get; set; }
}

View File

@ -0,0 +1,117 @@
using Admin.NET.Core.Service;
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
namespace Admin.NET.Application;
/// <summary>
/// 出库详细服务
/// </summary>
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
public class OutboundDetailService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<OutboundDetail> _rep;
public OutboundDetailService(SqlSugarRepository<OutboundDetail> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询出库详细
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Page")]
public async Task<SqlSugarPagedList<OutboundDetailOutput>> Page(OutboundDetailInput input)
{
var query = _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
u.CodeTableIds.Contains(input.SearchKey.Trim())
)
.WhereIF(input.OutboundId>0, u => u.OutboundId == input.OutboundId)
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeTableIds), u => u.CodeTableIds.Contains(input.CodeTableIds.Trim()))
.Select<OutboundDetailOutput>();
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(AddOutboundDetailInput input)
{
var entity = input.Adapt<OutboundDetail>();
await _rep.InsertAsync(entity);
return entity.Id;
}
/// <summary>
/// 删除出库详细
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Delete")]
public async Task Delete(DeleteOutboundDetailInput input)
{
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
//await _rep.FakeDeleteAsync(entity); //假删除
await _rep.DeleteAsync(entity); //真删除
}
/// <summary>
/// 更新出库详细
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Update")]
public async Task Update(UpdateOutboundDetailInput input)
{
var entity = input.Adapt<OutboundDetail>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
/// <summary>
/// 获取出库详细
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "Detail")]
public async Task<OutboundDetail> Detail([FromQuery] QueryByIdOutboundDetailInput input)
{
return await _rep.GetFirstAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取出库详细列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "List")]
public async Task<List<OutboundDetailOutput>> List()
{
return await _rep.AsQueryable().Select<OutboundDetailOutput>().ToListAsync();
}
/// <summary>
/// 获取出库详细
/// </summary>
/// <param name="outboundId"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "GetByOutboundId")]
public async Task<OutboundDetail> GetByOutboundId(long? outboundId)
{
return await _rep.GetFirstAsync(u => u.OutboundId == outboundId);
}
}

View File

@ -70,6 +70,11 @@ public class PrintCodeDetailOutput
/// </summary>
public long? FatherId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
public long? MaterialsId { get; set; }
/// <summary>
/// 打码时间
/// </summary>

View File

@ -10,9 +10,18 @@ namespace Admin.NET.Application;
public class WarehouseDetailsService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<WarehouseDetails> _rep;
public WarehouseDetailsService(SqlSugarRepository<WarehouseDetails> rep)
private readonly PrintCodeDetailService _codeDetailService;
private readonly MaterialsService _materialsService;
private readonly SysUnitService _sysUnitService;
public WarehouseDetailsService(SqlSugarRepository<WarehouseDetails> rep,
PrintCodeDetailService codeDetailService,
MaterialsService materialsService,
SysUnitService sysUnitService)
{
_rep = rep;
_codeDetailService = codeDetailService;
_materialsService = materialsService;
_sysUnitService = sysUnitService;
}
/// <summary>
@ -153,6 +162,21 @@ public class WarehouseDetailsService : IDynamicApiController, ITransient
return await _rep.AsQueryable().Select<WarehouseDetailsOutput>().ToListAsync();
}
/// <summary>
/// 获取仓库库存
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "GetInventory")]
public async Task<Warehousing> GetInventory([FromQuery] QueryByIdWarehousingInput input)
{
var codeDetails = await _codeDetailService.List();
var warehousingCodes = codeDetails.FindAll(a => a.WarehouseID == null || a.WarehouseID < 1);
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,73 @@
namespace Admin.NET.Application;
/// <summary>
/// 调库出库输出参数
/// </summary>
public class WarehouseTransferDto
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 原仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDelete { get; set; }
}

View File

@ -0,0 +1,148 @@
using Admin.NET.Core;
using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application;
/// <summary>
/// 调库出库基础输入参数
/// </summary>
public class WarehouseTransferBaseInput
{
/// <summary>
/// 原仓库ID
/// </summary>
public virtual long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public virtual long? TargetWarehouseId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public virtual DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public virtual string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public virtual long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public virtual DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public virtual DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public virtual long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public virtual string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public virtual long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public virtual string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public virtual bool IsDelete { get; set; }
}
/// <summary>
/// 调库出库分页查询输入参数
/// </summary>
public class WarehouseTransferInput : BasePageInput
{
/// <summary>
/// 关键字查询
/// </summary>
public string? SearchKey { get; set; }
/// <summary>
/// 原仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 业务日期范围
/// </summary>
public List<DateTime?> StartDateRange { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
}
/// <summary>
/// 调库出库增加输入参数
/// </summary>
public class AddWarehouseTransferInput : WarehouseTransferBaseInput
{
/// <summary>
/// 软删除
/// </summary>
[Required(ErrorMessage = "软删除不能为空")]
public override bool IsDelete { get; set; }
}
/// <summary>
/// 调库出库删除输入参数
/// </summary>
public class DeleteWarehouseTransferInput : BaseIdInput
{
}
/// <summary>
/// 调库出库更新输入参数
/// </summary>
public class UpdateWarehouseTransferInput : WarehouseTransferBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 调库出库主键查询输入参数
/// </summary>
public class QueryByIdWarehouseTransferInput : DeleteWarehouseTransferInput
{
}

View File

@ -0,0 +1,75 @@
namespace Admin.NET.Application;
/// <summary>
/// 调库出库输出参数
/// </summary>
public class WarehouseTransferOutput
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 原仓库ID
/// </summary>
public long? WarehouseId { get; set; }
/// <summary>
/// 目标仓库ID
/// </summary>
public long? TargetWarehouseId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remarks { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long? CreateUserId { get; set; }
/// <summary>
/// 创建者姓名
/// </summary>
public string? CreateUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
public long? UpdateUserId { get; set; }
/// <summary>
/// 修改者姓名
/// </summary>
public string? UpdateUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDelete { get; set; }
}

View File

@ -0,0 +1,284 @@
using Admin.NET.Core.Service;
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
namespace Admin.NET.Application;
/// <summary>
/// 调库出库服务
/// </summary>
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
public class WarehouseTransferService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<WarehouseTransfer> _rep;
private readonly PrintCodeDetailService _codeDetailService;
private readonly ProductRetrospectService _productRetrospect;
private readonly ReportTableService _reportTableService;
private readonly OutboundService _outboundService;
private readonly OutboundDetailService _outboundDetailService;
private readonly UserManager _userManager;
public WarehouseTransferService(SqlSugarRepository<WarehouseTransfer> rep,
UserManager userManager,
PrintCodeDetailService codeDetailService,
ReportTableService reportTableService,
OutboundService outboundService,
OutboundDetailService outboundDetailService,
ProductRetrospectService productRetrospect)
{
_rep = rep;
_userManager = userManager;
_codeDetailService = codeDetailService;
_productRetrospect = productRetrospect;
_reportTableService = reportTableService;
_outboundService = outboundService;
_outboundDetailService = outboundDetailService;
}
/// <summary>
/// 分页查询调库出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Page")]
public async Task<SqlSugarPagedList<WarehouseTransferOutput>> Page(WarehouseTransferInput input)
{
var query = _rep.AsQueryable().Where(a => !a.IsDelete)
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
u.Remarks.Contains(input.SearchKey.Trim())
)
.WhereIF(input.WarehouseId>0, u => u.WarehouseId == input.WarehouseId)
.WhereIF(input.TargetWarehouseId>0, u => u.TargetWarehouseId == input.TargetWarehouseId)
.WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim()))
.Select<WarehouseTransferOutput>();
if(input.StartDateRange != null && input.StartDateRange.Count >0)
{
DateTime? start= input.StartDateRange[0];
query = query.WhereIF(start.HasValue, u => u.StartDate > start);
if (input.StartDateRange.Count >1 && input.StartDateRange[1].HasValue)
{
var end = input.StartDateRange[1].Value.AddDays(1);
query = query.Where(u => u.StartDate < end);
}
}
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
}
/// <summary>
/// 增加调库出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Add")]
public async Task<long> Add(AddWarehouseTransferInput input)
{
var entity = input.Adapt<WarehouseTransfer>();
await _rep.InsertAsync(entity);
return entity.Id;
}
/// <summary>
/// 删除调库出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Delete")]
public async Task Delete(DeleteWarehouseTransferInput input)
{
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
await _rep.FakeDeleteAsync(entity); //假删除
//await _rep.DeleteAsync(entity); //真删除
}
/// <summary>
/// 更新调库出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "Update")]
public async Task Update(UpdateWarehouseTransferInput input)
{
var entity = input.Adapt<WarehouseTransfer>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
/// <summary>
/// 获取调库出库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "Detail")]
public async Task<WarehouseTransfer> Detail([FromQuery] QueryByIdWarehouseTransferInput input)
{
return await _rep.GetFirstAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取调库出库列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "List")]
public async Task<List<WarehouseTransferOutput>> List()
{
return await _rep.AsQueryable().Select<WarehouseTransferOutput>().Where(a => !a.IsDelete).ToListAsync();
}
/// <summary>
/// 商品出货
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "ShipmentProduct")]
public async Task ShipmentProduct(AddProductCodeInput input)
{
if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var invoice = await Detail(new QueryByIdWarehouseTransferInput() { Id = input.WarehousingTableId.Value });
if (invoice == null)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var codes = string.IsNullOrEmpty(input.CodeDatas[0].BarCode) ? input.CodeDatas.ConvertAll(a => a.QrCode) : input.CodeDatas.ConvertAll(a => a.BarCode);
var details = (await _codeDetailService.List()).FindAll(a => !string.IsNullOrEmpty(a.FatherCode));
var repeatCodes = details.Where(a => !a.IsDelete && codes.Any(b => b == a.Code)).ToList();
if (repeatCodes == null || repeatCodes.Count < 1)
{
throw Oops.Oh(ErrorCodeEnum.xg1002);
}
var userId = _userManager.UserId;
var userName = _userManager.RealName;
var addOutbound = new AddOutboundInput()
{
//BusinessType = invoice.BusinessType,
//CodeNum = invoice.CodeNum,
//Consignee = invoice.Consignee,
CreateTime = invoice.CreateTime,
CreateUserId = userId,
CreateUserName = userName,
SourceCodeNum = invoice.Id.ToString(),
StartDate = invoice.StartDate,
State = 0,
//Warehouse = invoice.Warehouse,
WarehouseId = invoice.WarehouseId,
TenantId = invoice.TenantId,
};
var outbound = await _outboundService.Add(addOutbound);
var codeIds = new List<long>();
var list = new List<PrintCodeDetailOutput>();
foreach (var c1 in repeatCodes)
{
codeIds.Add(c1.Id);
c1.WarehouseID = null;
//c1.FatherCode = null;
//c1.FatherId = null;
await _codeDetailService.UpdateByEntity(c1.Adapt<PrintCodeDetail>());
list.Add(c1);
var child1 = details.Find(a => a.FatherCode == c1.Code);
if (child1 != null)
{
child1.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child1.Adapt<PrintCodeDetail>());
list.Add(child1);
var child2 = details.Find(a => a.FatherCode == c1.Code);
if (child2 != null)
{
child2.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child2.Adapt<PrintCodeDetail>());
list.Add(child2);
var child3 = details.Find(a => a.FatherCode == c1.Code);
if (child3 != null)
{
child3.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child3.Adapt<PrintCodeDetail>());
list.Add(child3);
var child4 = details.Find(a => a.FatherCode == c1.Code);
if (child4 != null)
{
child4.WarehouseID = null;
await _codeDetailService.UpdateByEntity(child4.Adapt<PrintCodeDetail>());
list.Add(child4);
}
}
}
}
}
var addOutboundDetail = new AddOutboundDetailInput() { CodeTableIds = string.Join(",", codeIds), OutboundId = outbound };
await _outboundDetailService.Add(addOutboundDetail);
foreach (var item in list)
{
var report = await GetReport(item.ReportTableId);
var retrospect1 = new AddProductRetrospectInput()
{
BaseCount = item.BaseCount,
BaseUnit = item.BaseUnit,
//Batch = report.Batch,
BusinessType = report.ProductType,
CodeType = item.CodeName,
Location = addOutbound.Consignee,
Department = report.ProductionLine,
//WarehouseID = input.WarehouseId,
WarehousingDate = DateTime.Now,
Count = 1,
CreateTime = DateTime.Now,
ScanCodeTime = DateTime.Now,
CreateUserId = userId,
CreateUserName = userName,
MaterialsId = report.MaterialsId,
OddNumber = report.OddNumber,
Receipt = "调库出库单",
SourceId = outbound,
Unit = item.Unit,
Name = item.CodeName,
Code = item.Code,
//Destination = invoice.Consignee
};
await _productRetrospect.Add(retrospect1);
}
}
static Dictionary<long, ReportTable> reportDic = new Dictionary<long, ReportTable>();
private async Task<ReportTable> GetReport(long? reportId)
{
if (reportId == null)
{
return new ReportTable();
}
if (reportDic.ContainsKey(reportId.Value))
{
return reportDic[reportId.Value];
}
var report = await _reportTableService.GetBySource(reportId);
if (report == null)
{
return new ReportTable();
}
else
{
return report;
}
}
}

View File

@ -105,7 +105,6 @@ public class WarehousingService : IDynamicApiController, ITransient
/// <summary>
/// 获取入库单列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "List")]
@ -116,7 +115,5 @@ public class WarehousingService : IDynamicApiController, ITransient
}

View File

@ -2,4 +2,4 @@
ENV = development
# 本地环境接口地址http://localhost:5005 http://139.199.191.197:9005
VITE_API_URL = http://139.199.191.197:9005
VITE_API_URL = http://localhost:5005

View File

@ -5,6 +5,7 @@ enum Api {
UpdateDistributor = '/api/distributor/update',
PageDistributor = '/api/distributor/page',
DetailDistributor = '/api/distributor/detail',
ListDistributor = '/api/distributor/list',
}
// 增加分销商
@ -39,6 +40,14 @@ export const pageDistributor = (params?: any) =>
data: params,
});
// 列表分销商
export const listDistributor = () =>
request({
url: Api.ListDistributor,
method: 'get',
data: { },
});
// 详情分销商
export const detailDistributor = (id: any) =>
request({

View File

@ -0,0 +1,59 @@
import request from '/@/utils/request';
enum Api {
AddDistributorInvoice = '/api/distributorInvoice/add',
DeleteDistributorInvoice = '/api/distributorInvoice/delete',
UpdateDistributorInvoice = '/api/distributorInvoice/update',
PageDistributorInvoice = '/api/distributorInvoice/page',
DetailDistributorInvoice = '/api/distributorInvoice/detail',
ListDistributorInvoice = '/api/distributorInvoice/list',
}
// 增加分销出库
export const addDistributorInvoice = (params?: any) =>
request({
url: Api.AddDistributorInvoice,
method: 'post',
data: params,
});
// 删除分销出库
export const deleteDistributorInvoice = (params?: any) =>
request({
url: Api.DeleteDistributorInvoice,
method: 'post',
data: params,
});
// 编辑分销出库
export const updateDistributorInvoice = (params?: any) =>
request({
url: Api.UpdateDistributorInvoice,
method: 'post',
data: params,
});
// 分页查询分销出库
export const pageDistributorInvoice = (params?: any) =>
request({
url: Api.PageDistributorInvoice,
method: 'post',
data: params,
});
// 列表分销出库
export const listDistributorInvoice = () =>
request({
url: Api.ListDistributorInvoice,
method: 'get',
data: { },
});
// 详情分销出库
export const detailDistributorInvoice = (id: any) =>
request({
url: Api.DetailDistributorInvoice,
method: 'get',
data: { id },
});

View File

@ -0,0 +1,59 @@
import request from '/@/utils/request';
enum Api {
AddWarehouseTransfer = '/api/warehouseTransfer/add',
DeleteWarehouseTransfer = '/api/warehouseTransfer/delete',
UpdateWarehouseTransfer = '/api/warehouseTransfer/update',
PageWarehouseTransfer = '/api/warehouseTransfer/page',
DetailWarehouseTransfer = '/api/warehouseTransfer/detail',
ListWarehouseTransfer = '/api/warehouseTransfer/list',
}
// 增加调库出库
export const addWarehouseTransfer = (params?: any) =>
request({
url: Api.AddWarehouseTransfer,
method: 'post',
data: params,
});
// 删除调库出库
export const deleteWarehouseTransfer = (params?: any) =>
request({
url: Api.DeleteWarehouseTransfer,
method: 'post',
data: params,
});
// 编辑调库出库
export const updateWarehouseTransfer = (params?: any) =>
request({
url: Api.UpdateWarehouseTransfer,
method: 'post',
data: params,
});
// 分页查询调库出库
export const pageWarehouseTransfer = (params?: any) =>
request({
url: Api.PageWarehouseTransfer,
method: 'post',
data: params,
});
// 列表调库出库
export const listWarehouseTransfer = () =>
request({
url: Api.ListWarehouseTransfer,
method: 'get',
data: { },
});
// 详情调库出库
export const detailWarehouseTransfer = (id: any) =>
request({
url: Api.DetailWarehouseTransfer,
method: 'get',
data: { id },
});

View File

@ -0,0 +1,156 @@
<template>
<div class="distributorInvoice-container">
<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" :rules="rules">
<el-row :gutter="35">
<el-form-item v-show="false">
<el-input v-model="ruleForm.id" />
</el-form-item>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="仓库ID" prop="warehouseId">
<el-input v-model="ruleForm.warehouseId" placeholder="请输入仓库ID" maxlength="20" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="目标仓库ID" prop="targetWarehouseId">
<el-input v-model="ruleForm.targetWarehouseId" placeholder="请输入目标仓库ID" maxlength="20" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="分销商ID" prop="distributorId">
<el-input v-model="ruleForm.distributorId" placeholder="请输入分销商ID" maxlength="20" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="分销商" prop="distributor">
<el-input v-model="ruleForm.distributor" placeholder="请输入分销商" maxlength="32" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="业务日期" prop="startDate">
<el-date-picker v-model="ruleForm.startDate" type="date" placeholder="业务日期" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="备注" prop="remarks">
<el-input v-model="ruleForm.remarks" placeholder="请输入备注" maxlength="32" show-word-limit clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<style scoped>
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
</style>
<script lang="ts" setup>
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";
import { addDistributorInvoice, updateDistributorInvoice, detailDistributorInvoice } from "/@/api/main/distributorInvoice";
//
var props = defineProps({
title: {
type: String,
default: "",
},
});
//
const emit = defineEmits(["reloadTable"]);
const ruleFormRef = ref();
const isShowDialog = ref(false);
const ruleForm = ref<any>({});
//
const rules = ref<FormRules>({
});
//
const openDialog = async (row: any) => {
// ruleForm.value = JSON.parse(JSON.stringify(row));
// detail
let rowData = JSON.parse(JSON.stringify(row));
if (rowData.id)
ruleForm.value = (await detailDistributorInvoice(rowData.id)).data.result;
else
ruleForm.value = rowData;
isShowDialog.value = true;
};
//
const closeDialog = () => {
emit("reloadTable");
isShowDialog.value = false;
};
//
const cancel = () => {
isShowDialog.value = false;
};
//
const submit = async () => {
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
if (isValid) {
let values = ruleForm.value;
if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
await addDistributorInvoice(values);
} else {
await updateDistributorInvoice(values);
}
closeDialog();
} else {
ElMessage({
message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
type: "error",
});
}
});
};
//
onMounted(async () => {
});
//
defineExpose({ openDialog });
</script>

View File

@ -0,0 +1,212 @@
<template>
<div class="distributorInvoice-container">
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
<el-form :model="queryParams" ref="queryForm" labelWidth="90">
<el-row>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
<el-form-item label="关键字">
<el-input v-model="queryParams.searchKey" clearable="" placeholder="请输入模糊查询关键字"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="仓库ID">
<el-input v-model="queryParams.warehouseId" clearable="" placeholder="请输入仓库ID"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="目标仓库ID">
<el-input v-model="queryParams.targetWarehouseId" clearable="" placeholder="请输入目标仓库ID"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="分销商ID">
<el-input v-model="queryParams.distributorId" clearable="" placeholder="请输入分销商ID"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="分销商">
<el-input v-model="queryParams.distributor" clearable="" placeholder="请输入分销商"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="业务日期">
<el-date-picker placeholder="请选择业务日期" value-format="YYYY/MM/DD" type="daterange" v-model="queryParams.startDateRange" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="备注">
<el-input v-model="queryParams.remarks" clearable="" placeholder="请输入备注"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6" class="mb10">
<el-form-item>
<el-button-group style="display: flex; align-items: center;">
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'distributorInvoice:page'"> </el-button>
<el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
<el-button icon="ele-ZoomIn" @click="changeAdvanceQueryUI" v-if="!showAdvanceQueryUI" style="margin-left:5px;"> </el-button>
<el-button icon="ele-ZoomOut" @click="changeAdvanceQueryUI" v-if="showAdvanceQueryUI" style="margin-left:5px;"> </el-button>
<el-button type="primary" style="margin-left:5px;" icon="ele-Plus" @click="openAddDistributorInvoice" v-auth="'distributorInvoice:add'"> </el-button>
</el-button-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<el-table
:data="tableData"
style="width: 100%"
v-loading="loading"
tooltip-effect="light"
row-key="id"
@sort-change="sortChange"
border="">
<el-table-column type="index" label="序号" width="55" align="center"/>
<el-table-column prop="warehouseId" label="仓库ID" width="140" show-overflow-tooltip="" />
<el-table-column prop="targetWarehouseId" label="目标仓库ID" width="90" show-overflow-tooltip="" />
<el-table-column prop="distributorId" label="分销商ID" width="140" show-overflow-tooltip="" />
<el-table-column prop="distributor" label="分销商" width="140" show-overflow-tooltip="" />
<el-table-column prop="startDate" label="业务日期" width="140" show-overflow-tooltip="" />
<el-table-column prop="remarks" label="备注" width="140" show-overflow-tooltip="" />
<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" v-if="auth('distributorInvoice:update') || auth('distributorInvoice:delete')">
<template #default="scope">
<el-button icon="ele-Edit" size="small" text="" type="primary" @click="openEditDistributorInvoice(scope.row)" v-auth="'distributorInvoice:update'"> </el-button>
<el-button icon="ele-Delete" size="small" text="" type="primary" @click="delDistributorInvoice(scope.row)" v-auth="'distributorInvoice:delete'"> </el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-model:currentPage="tableParams.page"
v-model:page-size="tableParams.pageSize"
:total="tableParams.total"
:page-sizes="[10, 20, 50, 100, 200, 500]"
small=""
background=""
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
/>
<printDialog
ref="printDialogRef"
:title="printDistributorInvoiceTitle"
@reloadTable="handleQuery" />
<editDialog
ref="editDialogRef"
:title="editDistributorInvoiceTitle"
@reloadTable="handleQuery"
/>
</el-card>
</div>
</template>
<script lang="ts" setup="" name="distributorInvoice">
import { ref } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
import { auth } from '/@/utils/authFunction';
import printDialog from '/@/views/labelPrinting/print/component/hiprint/preview.vue'
import editDialog from '/@/views/distributionManagement/distributorInvoice/component/editDialog.vue'
import { pageDistributorInvoice, deleteDistributorInvoice } from '/@/api/main/distributorInvoice';
const showAdvanceQueryUI = ref(false);
const printDialogRef = ref();
const editDialogRef = ref();
const loading = ref(false);
const tableData = ref<any>([]);
const queryParams = ref<any>({});
const tableParams = ref({
page: 1,
pageSize: 10,
total: 0,
});
const printDistributorInvoiceTitle = ref("");
const editDistributorInvoiceTitle = ref("");
//
const changeAdvanceQueryUI = () => {
showAdvanceQueryUI.value = !showAdvanceQueryUI.value;
}
//
const handleQuery = async () => {
loading.value = true;
var res = await pageDistributorInvoice(Object.assign(queryParams.value, tableParams.value));
tableData.value = res.data.result?.items ?? [];
tableParams.value.total = res.data.result?.total;
loading.value = false;
};
//
const sortChange = async (column: any) => {
queryParams.value.field = column.prop;
queryParams.value.order = column.order;
await handleQuery();
};
//
const openAddDistributorInvoice = () => {
editDistributorInvoiceTitle.value = '添加分销出库';
editDialogRef.value.openDialog({});
};
//
const openPrintDistributorInvoice = async (row: any) => {
printDistributorInvoiceTitle.value = '打印分销出库';
}
//
const openEditDistributorInvoice = (row: any) => {
editDistributorInvoiceTitle.value = '编辑分销出库';
editDialogRef.value.openDialog(row);
};
//
const delDistributorInvoice = (row: any) => {
ElMessageBox.confirm(`确定要删除吗?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
await deleteDistributorInvoice(row);
handleQuery();
ElMessage.success("删除成功");
})
.catch(() => {});
};
//
const handleSizeChange = (val: number) => {
tableParams.value.pageSize = val;
handleQuery();
};
//
const handleCurrentChange = (val: number) => {
tableParams.value.page = val;
handleQuery();
};
handleQuery();
</script>
<style scoped>
:deep(.el-ipnut),
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
</style>

View File

@ -0,0 +1,142 @@
<template>
<div class="warehouseTransfer-container">
<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" :rules="rules">
<el-row :gutter="35">
<el-form-item v-show="false">
<el-input v-model="ruleForm.id" />
</el-form-item>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="原仓库ID" prop="warehouseId">
<el-input v-model="ruleForm.warehouseId" placeholder="请输入原仓库ID" maxlength="20" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="目标仓库ID" prop="targetWarehouseId">
<el-input v-model="ruleForm.targetWarehouseId" placeholder="请输入目标仓库ID" maxlength="20" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="业务日期" prop="startDate">
<el-date-picker v-model="ruleForm.startDate" type="date" placeholder="业务日期" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="备注" prop="remarks">
<el-input v-model="ruleForm.remarks" placeholder="请输入备注" maxlength="32" show-word-limit clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<style scoped>
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
</style>
<script lang="ts" setup>
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";
import { addWarehouseTransfer, updateWarehouseTransfer, detailWarehouseTransfer } from "/@/api/main/warehouseTransfer";
//
var props = defineProps({
title: {
type: String,
default: "",
},
});
//
const emit = defineEmits(["reloadTable"]);
const ruleFormRef = ref();
const isShowDialog = ref(false);
const ruleForm = ref<any>({});
//
const rules = ref<FormRules>({
});
//
const openDialog = async (row: any) => {
// ruleForm.value = JSON.parse(JSON.stringify(row));
// detail
let rowData = JSON.parse(JSON.stringify(row));
if (rowData.id)
ruleForm.value = (await detailWarehouseTransfer(rowData.id)).data.result;
else
ruleForm.value = rowData;
isShowDialog.value = true;
};
//
const closeDialog = () => {
emit("reloadTable");
isShowDialog.value = false;
};
//
const cancel = () => {
isShowDialog.value = false;
};
//
const submit = async () => {
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
if (isValid) {
let values = ruleForm.value;
if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
await addWarehouseTransfer(values);
} else {
await updateWarehouseTransfer(values);
}
closeDialog();
} else {
ElMessage({
message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
type: "error",
});
}
});
};
//
onMounted(async () => {
});
//
defineExpose({ openDialog });
</script>

View File

@ -0,0 +1,198 @@
<template>
<div class="warehouseTransfer-container">
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
<el-form :model="queryParams" ref="queryForm" labelWidth="90">
<el-row>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
<el-form-item label="关键字">
<el-input v-model="queryParams.searchKey" clearable="" placeholder="请输入模糊查询关键字"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="原仓库ID">
<el-input v-model="queryParams.warehouseId" clearable="" placeholder="请输入原仓库ID"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="目标仓库ID">
<el-input v-model="queryParams.targetWarehouseId" clearable="" placeholder="请输入目标仓库ID"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="业务日期">
<el-date-picker placeholder="请选择业务日期" value-format="YYYY/MM/DD" type="daterange" v-model="queryParams.startDateRange" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
<el-form-item label="备注">
<el-input v-model="queryParams.remarks" clearable="" placeholder="请输入备注"/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6" class="mb10">
<el-form-item>
<el-button-group style="display: flex; align-items: center;">
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'warehouseTransfer:page'"> </el-button>
<el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
<el-button icon="ele-ZoomIn" @click="changeAdvanceQueryUI" v-if="!showAdvanceQueryUI" style="margin-left:5px;"> </el-button>
<el-button icon="ele-ZoomOut" @click="changeAdvanceQueryUI" v-if="showAdvanceQueryUI" style="margin-left:5px;"> </el-button>
<el-button type="primary" style="margin-left:5px;" icon="ele-Plus" @click="openAddWarehouseTransfer" v-auth="'warehouseTransfer:add'"> </el-button>
</el-button-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<el-table
:data="tableData"
style="width: 100%"
v-loading="loading"
tooltip-effect="light"
row-key="id"
@sort-change="sortChange"
border="">
<el-table-column type="index" label="序号" width="55" align="center"/>
<el-table-column prop="warehouseId" label="原仓库ID" width="140" show-overflow-tooltip="" />
<el-table-column prop="targetWarehouseId" label="目标仓库ID" width="90" show-overflow-tooltip="" />
<el-table-column prop="startDate" label="业务日期" width="140" show-overflow-tooltip="" />
<el-table-column prop="remarks" label="备注" width="140" show-overflow-tooltip="" />
<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" v-if="auth('warehouseTransfer:update') || auth('warehouseTransfer:delete')">
<template #default="scope">
<el-button icon="ele-Edit" size="small" text="" type="primary" @click="openEditWarehouseTransfer(scope.row)" v-auth="'warehouseTransfer:update'"> </el-button>
<el-button icon="ele-Delete" size="small" text="" type="primary" @click="delWarehouseTransfer(scope.row)" v-auth="'warehouseTransfer:delete'"> </el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-model:currentPage="tableParams.page"
v-model:page-size="tableParams.pageSize"
:total="tableParams.total"
:page-sizes="[10, 20, 50, 100, 200, 500]"
small=""
background=""
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
/>
<printDialog
ref="printDialogRef"
:title="printWarehouseTransferTitle"
@reloadTable="handleQuery" />
<editDialog
ref="editDialogRef"
:title="editWarehouseTransferTitle"
@reloadTable="handleQuery"
/>
</el-card>
</div>
</template>
<script lang="ts" setup="" name="warehouseTransfer">
import { ref } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
import { auth } from '/@/utils/authFunction';
import printDialog from '/@/views/labelPrinting/print/component/hiprint/preview.vue'
import editDialog from '/@/views/inventoryManagement/warehouseTransfer/component/editDialog.vue'
import { pageWarehouseTransfer, deleteWarehouseTransfer } from '/@/api/main/warehouseTransfer';
const showAdvanceQueryUI = ref(false);
const printDialogRef = ref();
const editDialogRef = ref();
const loading = ref(false);
const tableData = ref<any>([]);
const queryParams = ref<any>({});
const tableParams = ref({
page: 1,
pageSize: 10,
total: 0,
});
const printWarehouseTransferTitle = ref("");
const editWarehouseTransferTitle = ref("");
//
const changeAdvanceQueryUI = () => {
showAdvanceQueryUI.value = !showAdvanceQueryUI.value;
}
//
const handleQuery = async () => {
loading.value = true;
var res = await pageWarehouseTransfer(Object.assign(queryParams.value, tableParams.value));
tableData.value = res.data.result?.items ?? [];
tableParams.value.total = res.data.result?.total;
loading.value = false;
};
//
const sortChange = async (column: any) => {
queryParams.value.field = column.prop;
queryParams.value.order = column.order;
await handleQuery();
};
//
const openAddWarehouseTransfer = () => {
editWarehouseTransferTitle.value = '添加调库出库';
editDialogRef.value.openDialog({});
};
//
const openPrintWarehouseTransfer = async (row: any) => {
printWarehouseTransferTitle.value = '打印调库出库';
}
//
const openEditWarehouseTransfer = (row: any) => {
editWarehouseTransferTitle.value = '编辑调库出库';
editDialogRef.value.openDialog(row);
};
//
const delWarehouseTransfer = (row: any) => {
ElMessageBox.confirm(`确定要删除吗?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
await deleteWarehouseTransfer(row);
handleQuery();
ElMessage.success("删除成功");
})
.catch(() => {});
};
//
const handleSizeChange = (val: number) => {
tableParams.value.pageSize = val;
handleQuery();
};
//
const handleCurrentChange = (val: number) => {
tableParams.value.page = val;
handleQuery();
};
handleQuery();
</script>
<style scoped>
:deep(.el-ipnut),
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
</style>

View File

@ -183,8 +183,6 @@
import { ref } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
import { auth } from '/@/utils/authFunction';
import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
import { formatDate } from '/@/utils/formatTime';
import printDialog from '/@/views/labelPrinting/print/component/hiprint/preview.vue'