逐个盘点接口

This commit is contained in:
hehaibing-1996
2025-01-24 10:22:18 +08:00
parent 9ee906d752
commit 71bb9acd0d
6 changed files with 64 additions and 15 deletions

View File

@ -69,7 +69,7 @@ namespace WCS.BLL.DbModels
/// 物料规格 /// 物料规格
/// </summary> /// </summary>
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")] [SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
public string MatSpec { get; set; } public string? MatSpec { get; set; }
/// <summary> /// <summary>
/// 物料数量(原始数量) /// 物料数量(原始数量)

View File

@ -72,6 +72,7 @@ namespace WCS.BLL.Manager
DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo) DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo)
, typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo) , typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo)
, typeof(MatDetailStocktakingInfo)
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail) , typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
, typeof(MatInfo), typeof(StoreInfo) , typeof(MatInfo), typeof(StoreInfo)
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord) , typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)

View File

@ -35,7 +35,7 @@ namespace WCS.BLL.Services.IService
#region #region
public Task<ResponseBase> stockTakingById(StockTakingByIdRequest request); public Task<ResponseCommon> stockTakingById(StockTakingByIdRequest request);
#endregion #endregion
} }
} }

View File

@ -1046,12 +1046,57 @@ namespace WCS.BLL.Services.Service
#region #region
public async Task<ResponseBase> stockTakingById(StockTakingByIdRequest request) public async Task<ResponseCommon> stockTakingById(StockTakingByIdRequest request)
{ {
//先查询有无这一条库存记录 //先查询有无这一条库存记录
var matDetailCurrentInfo = DbHelp.db.Queryable<MatDetailCurrentInfo>() var matDetailCurrentInfo = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
.Where(t => t.Id == request.MatDetailCurrentInfoId) .Where(t => t.Id == request.MatDetailCurrentInfoId)
.FirstAsync(); .FirstAsync();
if (matDetailCurrentInfo == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"操作失败:所选记录不存在!",
Data = null,
};
}
//查询是否已经存在未提交的盘点记录
var stocktakingInfo = await DbHelp.db.Queryable<MatDetailStocktakingInfo>()
.Where(t => t.MatDetailCurrentId == request.MatDetailCurrentInfoId)
.Where(t => t.StocktakingStatus == StocktakingStatusEnum.)
.FirstAsync();
//如果存在未提交的盘点记录 将上一次的记录更新即可
if (stocktakingInfo != null)
{
stocktakingInfo.StocktakingQty = request.StocktakingQty;
stocktakingInfo.StocktakingUser = request.UserName;
stocktakingInfo.StocktakingTime = DateTime.Now;
DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand();
}
//不存在盘点记录 新增即可
else
{
stocktakingInfo = new MatDetailStocktakingInfo()
{
MatDetailCurrentId = matDetailCurrentInfo.Id,
ShlefId = matDetailCurrentInfo.ShlefId,
ShelfCode = matDetailCurrentInfo.ShelfCode,
ShelfType = matDetailCurrentInfo.ShelfType,
ShelfArea = "",
MatCode = matDetailCurrentInfo.MatCode,
MatName = matDetailCurrentInfo.MatName,
MatSpec = matDetailCurrentInfo.MatSpec,
MatQty = matDetailCurrentInfo.MatQty,
StocktakingQty = request.StocktakingQty,
MatSupplier = matDetailCurrentInfo.MatSupplier,
StocktakingUser = request.UserName,
StocktakingTime = DateTime.Now,
StocktakingStatus = StocktakingStatusEnum.,
};
DbHelp.db.Insertable(stocktakingInfo).ExecuteCommand();
}
return new ResponseCommon() return new ResponseCommon()
{ {

View File

@ -8,6 +8,6 @@ namespace WCS.Model.ApiModel.Stocktaking
{ {
public int MatDetailCurrentInfoId { get; set; } public int MatDetailCurrentInfoId { get; set; }
public int MatQty { get; set; } public int StocktakingQty { get; set; }
} }
} }

View File

@ -19,11 +19,10 @@ namespace WCS.WebApi.Controllers
[Route("[controller]")] [Route("[controller]")]
public class PDAStocktakingController : ControllerBase public class PDAStocktakingController : ControllerBase
{ {
public IWarningService _warningService { get; set; } public IStockTakingService _stockTakingService { get; set; }
public PDAStocktakingController(IStockTakingService stockTakingService)
public PDAStocktakingController(IWarningService warningService)
{ {
_warningService = warningService; _stockTakingService = stockTakingService;
} }
[Route("stockTakingById")] [Route("stockTakingById")]
@ -44,14 +43,18 @@ namespace WCS.WebApi.Controllers
}; };
} }
if (request.StocktakingQty < 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"操作失败:数量应大于等于0!",
Data = null,
};
}
#endregion #endregion
return new ResponseCommon() return await _stockTakingService.stockTakingById(request);
{
Code = 200,
Message = "success",
Data = null,
};
} }
catch (Exception ex) catch (Exception ex)
{ {