调整盘点单

This commit is contained in:
18942506660
2023-11-01 11:08:59 +08:00
parent 9dd32beba4
commit 54b894c5dd
3 changed files with 75 additions and 28 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text; using System.Text;
using WMS.Web.Core; using WMS.Web.Core;
using WMS.Web.Domain.Values;
namespace WMS.Web.Domain.Entitys namespace WMS.Web.Domain.Entitys
{ {
@@ -40,9 +41,55 @@ namespace WMS.Web.Domain.Entitys
[Column("SuccessSync")] [Column("SuccessSync")]
public bool? SuccessSync { get; set; } public bool? SuccessSync { get; set; }
/// <summary> /// <summary>
/// 明细 /// 箱Id
/// </summary> /// </summary>
public List<TakeStockDetails> Details = new List<TakeStockDetails>(); [Column("BoxId")]
public int BoxId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[Column("MaterialId")]
public int MaterialId { get; set; }
/// <summary>
/// 单位ID
/// </summary>
[Column("UnitId")]
public int UnitId { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
[Column("StockId")]
public int StockId { get; set; }
/// <summary>
/// 仓位ID
/// </summary>
[Column("SubStockId")]
public int SubStockId { get; set; }
/// <summary>
/// 盘点前数量wms系统数量
/// </summary>
[Column("BeforeQty")]
public decimal BeforeQty { get; set; }
/// <summary>
/// 盘点实际数量(实际仓库数量)
/// </summary>
[Column("AfterQty")]
public decimal AfterQty { get; set; }
/// <summary>
/// 盘点后数量
/// </summary>
[Column("FinalQty")]
public decimal FinalQty { get; set; }
/// <summary>
/// 盘点结果类型1为盘盈2位盘亏
/// </summary>
[Column("ResultType")]
public TakeStockType ResultType { get; set; } = TakeStockType.Profit;
/// <summary>
/// 备注
/// </summary>
[Column("Remark")]
public string Remark { get; set; }
/// <summary> /// <summary>
/// 创建 /// 创建
/// </summary> /// </summary>

View File

@@ -91,10 +91,10 @@ namespace WMS.Web.Repositories.Configuration
ent.ToTable("t_wms_takestock"); ent.ToTable("t_wms_takestock");
ent.HasKey(x => x.Id); ent.HasKey(x => x.Id);
ent.HasMany(p => p.Details) //ent.HasMany(p => p.Details)
.WithOne() // .WithOne()
.HasForeignKey(p => p.Fid) // .HasForeignKey(p => p.Fid)
.OnDelete(DeleteBehavior.Cascade); // .OnDelete(DeleteBehavior.Cascade);
}); });
builder.Entity<TakeStockDetails>(ent => builder.Entity<TakeStockDetails>(ent =>
{ {

View File

@@ -77,40 +77,40 @@ namespace WMS.Web.Repositories
/// <returns></returns> /// <returns></returns>
public async Task<(List<TakeStockQueryInfoResponse> list, int total)> GetListAsync(TakeStockQueryRequest dto) public async Task<(List<TakeStockQueryInfoResponse> list, int total)> GetListAsync(TakeStockQueryRequest dto)
{ {
var query = _context.TakeStockDetails var query = _context.TakeStock
.GroupJoin(_context.TakeStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) //.GroupJoin(_context.TakeStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) //.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.OrderByDescending(o => o.order.Id) .OrderByDescending(o => o.Id)
.Where(adv => 1 == 1); .Where(adv => 1 == 1);
if (dto.ResultType != null) if (dto.ResultType != null)
query = query.Where(w => w.detail.ResultType == (TakeStockType)dto.ResultType); query = query.Where(w => w.ResultType == (TakeStockType)dto.ResultType);
if (!string.IsNullOrEmpty(dto.BillNo)) if (!string.IsNullOrEmpty(dto.BillNo))
query = query.Where(w => EF.Functions.Like(w.order.BillNo, "%" + dto.BillNo + "%")); query = query.Where(w => EF.Functions.Like(w.BillNo, "%" + dto.BillNo + "%"));
if (dto.StockId != null) if (dto.StockId != null)
query = query.Where(w => w.detail.StockId == dto.StockId); query = query.Where(w => w.StockId == dto.StockId);
if (dto.DateBeginDate != null) if (dto.DateBeginDate != null)
query = query.Where(w => w.order.Date >= dto.DateBeginDate); query = query.Where(w => w.Date >= dto.DateBeginDate);
if (dto.DateEndDate != null) if (dto.DateEndDate != null)
query = query.Where(w => w.order.Date <= dto.DateEndDate); query = query.Where(w => w.Date <= dto.DateEndDate);
//组装 //组装
int total = await query.CountAsync(); int total = await query.CountAsync();
var list = await query.Select(s => new TakeStockQueryInfoResponse() var list = await query.Select(s => new TakeStockQueryInfoResponse()
{ {
#region dto组装 #region dto组装
Id = s.order.Id, Id = s.Id,
BillNo = s.order.BillNo, BillNo = s.BillNo,
Unit = _singleDataService.GetSingleData(SingleAction.Units, _loginRepositories.CompanyId, s.detail.UnitId), Unit = _singleDataService.GetSingleData(SingleAction.Units, _loginRepositories.CompanyId, s.UnitId),
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId), Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.StockId),
SubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.detail.SubStockId), SubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.SubStockId),
BeforeQty = s.detail.BeforeQty, BeforeQty = s.BeforeQty,
AfterQty = s.detail.AfterQty, AfterQty = s.AfterQty,
FinalQty = s.detail.FinalQty, FinalQty = s.FinalQty,
ResultType = s.detail.ResultType.GetRemark(), ResultType = s.ResultType.GetRemark(),
Remark = s.detail.Remark, Remark = s.Remark,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId), Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.CreatorId),
Date = s.order.Date.DateToStringSeconds(), Date = s.Date.DateToStringSeconds(),
SuccessSync = s.order.SuccessSync SuccessSync = s.SuccessSync
#endregion #endregion
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();