改箱服务调整

This commit is contained in:
18942506660
2023-10-31 15:08:35 +08:00
parent 1eafbc8503
commit ba2d1e6723
9 changed files with 81 additions and 52 deletions

View File

@@ -118,17 +118,17 @@ namespace WMS.Web.Api.Controllers
/// <param name="billNo">必填</param>
/// <returns></returns>
[HttpGet]
[Route("GetBoxDetails")]
public async Task<ResultList<BoxDetailResponse>> GetBoxDetails([FromQuery] string billNo)
[Route("GetBox")]
public async Task<Result<BoxResponse>> GetBox([FromQuery] string billNo)
{
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
if (loginInfo == null || loginInfo.UserInfo == null)
return ResultList<BoxDetailResponse>.ReFailure(ResultCodes.Token_Invalid_Error);
if(string.IsNullOrEmpty(billNo))
return ResultList<BoxDetailResponse>.ReSuccess(new List<BoxDetailResponse>());
return Result<BoxResponse>.ReFailure(ResultCodes.Token_Invalid_Error);
if (string.IsNullOrEmpty(billNo))
return Result<BoxResponse>.ReSuccess(null);
var r = await _boxRepositories.GetDetails(billNo);
return ResultList<BoxDetailResponse>.ReSuccess(r);
var r = await _boxRepositories.GetBox(billNo);
return Result<BoxResponse>.ReSuccess(r);
}
}
}

View File

@@ -9,14 +9,6 @@ namespace WMS.Web.Core.Dto
/// </summary>
public class BoxDetailResponse
{
/// <summary>
/// 单据头ID
/// </summary>
public int Fid { get; set; }
/// <summary>
/// 箱Id
/// </summary>
public int BoxId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
@@ -44,6 +36,6 @@ namespace WMS.Web.Core.Dto
/// <summary>
/// 序列号集
/// </summary>
public string SerialNumbers { get; set; }
public List<string> SerialNumbers { get; set; } = new List<string>();
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WMS.Web.Core.Dto
{
/// <summary>
/// 箱信息(头部)
/// </summary>
public class BoxResponse
{
/// <summary>
/// 单据头ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 箱Id
/// </summary>
public int BoxId { get; set; }
/// <summary>
/// 明细信息
/// </summary>
public List<BoxDetailResponse> Details = new List<BoxDetailResponse>();
}
}

View File

@@ -16,11 +16,6 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
[Required(ErrorMessage = "物料不能为空")]
public int MaterialId { get; set; }
/// <summary>
/// 仓库Id
/// </summary>
[Required(ErrorMessage = "仓库不能为空")]
public int StockId { get; set; }
/// <summary>
/// 原箱子ID
/// </summary>
[Required(ErrorMessage = "原箱子不能为空")]
@@ -31,14 +26,10 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
[Required(ErrorMessage = "目标箱子不能为空")]
public int DestBoxId { get; set; }
/// <summary>
/// 原仓位ID
/// </summary>
[Required(ErrorMessage = "原仓位不能为空")]
public int SrcSubStockId { get; set; }
/// <summary>
/// 目标仓位ID
/// </summary>
[Required(ErrorMessage = "目标仓位不能为空")]
public int DestSubStockId { get; set; }
/// 数量
///</summary>
[Required(ErrorMessage = "数量不能为空")]
public decimal Qty { get; set; }
}
}

View File

@@ -37,6 +37,6 @@ namespace WMS.Web.Domain.Entitys
/// <summary>
/// 序列号集
/// </summary>
public string SerialNumbers { get; set; }
public List<string> SerialNumbers { get; set; } = new List<string>();
}
}

View File

@@ -33,13 +33,18 @@ namespace WMS.Web.Domain.Entitys
/// 序列号
/// </summary>
[Column("SerialNumbers")]
public string SerialNumbers { get; set; }
public List<string> SerialNumbers { get; set; } = new List<string>();
/// <summary>
/// 原箱子ID
/// </summary>
[Column("SrcBoxId")]
public int SrcBoxId { get; set; }
/// <summary>
/// 数量
///</summary>
[Column("Qty")]
public decimal Qty { get; set; }
/// <summary>
/// 目标箱子ID
/// </summary>
[Column("DestBoxId")]

View File

@@ -13,7 +13,7 @@ namespace WMS.Web.Domain.Infrastructure
public interface IBoxRepositories
{
Task<Box> Get(string BoxBillNo);
//根据箱号查询物料信息
Task<List<BoxDetailResponse>> GetDetails(string BoxBillNo);
//根据箱号查询明细信息
Task<BoxResponse> GetBox(string BoxBillNo);
}
}

View File

@@ -45,25 +45,31 @@ namespace WMS.Web.Repositories
/// </summary>
/// <param name="BoxBillNo"></param>
/// <returns></returns>
public async Task<List<BoxDetailResponse>> GetDetails(string BoxBillNo)
public async Task<BoxResponse> GetBox(string BoxBillNo)
{
return await _context.BoxDetails
.GroupJoin(_context.Box, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(w => w.order.BoxBillNo.Equals(BoxBillNo))
.Select(s => new BoxDetailResponse()
{
Fid = s.detail.Fid,
BoxId = s.order.OpsBoxId,
MaterialId = s.detail.MaterialId,
MaterialName = "",
MaterialNumber = "",
Specifications = "",
SerialNumbers = s.detail.SerialNumbers,
SupplierId = s.detail.SupplierId,
Qty = s.detail.Qty
})
.ToListAsync();
var entity = await _context.Box.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(BoxBillNo));
if (entity == null) return null;
BoxResponse result = new BoxResponse()
{
Id = entity.Id,
BoxId = entity.OpsBoxId
};
result.Details = await _context.BoxDetails
.GroupJoin(_context.Box, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(w => w.order.BoxBillNo.Equals(BoxBillNo))
.Select(s => new BoxDetailResponse()
{
MaterialId = s.detail.MaterialId,
MaterialName = "",
MaterialNumber = "",
Specifications = "",
SerialNumbers = s.detail.SerialNumbers,
SupplierId = s.detail.SupplierId,
Qty = s.detail.Qty
})
.ToListAsync();
return result;
}
}
}

View File

@@ -1,9 +1,11 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using WMS.Web.Domain.Entitys;
using WMS.Web.Repositories.Configuration.Log;
@@ -35,6 +37,10 @@ namespace WMS.Web.Repositories.Configuration
{
ent.ToTable("t_wms_changebox_record");
ent.HasKey(x => x.Id);
ent.Property(f => f.SerialNumbers).HasConversion(
v => JsonConvert.SerializeObject(v),
v => JsonConvert.DeserializeObject<List<string>>(v));
});
//移箱
builder.Entity<MoveBoxRecord>(ent =>
@@ -197,6 +203,10 @@ namespace WMS.Web.Repositories.Configuration
{
ent.ToTable("t_ops_box_details");
ent.HasKey(x => x.Id);
ent.Property(f => f.SerialNumbers).HasConversion(
v => JsonConvert.SerializeObject(v),
v => JsonConvert.DeserializeObject<List<string>>(v));
});
#endregion