调整出库操作
This commit is contained in:
@@ -21,6 +21,11 @@ namespace WMS.Web.Domain.Entitys
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 任务单ID
|
||||
/// </summary>
|
||||
[Column("TaskId")]
|
||||
public int TaskId { get; set; }
|
||||
/// <summary>
|
||||
/// 单据编号
|
||||
/// </summary>
|
||||
[Column("BillNo")]
|
||||
@@ -59,11 +64,14 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
public void Create(int creatorId,int taskId, OrderType type)
|
||||
{
|
||||
this.TaskId = taskId;
|
||||
this.Type = type;
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成单据号
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace WMS.Web.Domain.IService
|
||||
public interface IOutStockService
|
||||
{
|
||||
//出库单保存
|
||||
Task<Result> Save(List<SaveOutStockRequest> dto, LoginInDto loginInfo);
|
||||
Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo);
|
||||
// 同步金蝶
|
||||
Task<Result> Sync(OperateRequest dto);
|
||||
//出库任务作废
|
||||
|
||||
@@ -11,6 +11,10 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
// 新增
|
||||
Task<OutStock> Add(OutStock entity, bool isTransaction = true);
|
||||
//编辑
|
||||
Task<OutStock> Edit(OutStock entity, bool isTransaction = true);
|
||||
//根据任务单Id搜索
|
||||
Task<OutStock> GetByTaskId(int taskId);
|
||||
// 获取列表
|
||||
Task<(List<OutStockQueryInfoResponse> list, int total)> GetListAsync(OutStockQueryRequest dto);
|
||||
/// 查询实体集合
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
|
||||
/// 删除实体集合
|
||||
Task<bool> DeleteEntityList(List<int> ids, bool isTransaction = true);
|
||||
//获取实体
|
||||
Task<OutStockTask> Get(int id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace WMS.Web.Domain.Mappers
|
||||
public OutStockMapper()
|
||||
{
|
||||
CreateMap<SaveOutStockRequest, OutStockDetails>();
|
||||
|
||||
CreateMap<OutStockTaskDetails, OutStockDetails>()
|
||||
.ForMember(x => x.Id, ops => ops.Ignore())
|
||||
.ForMember(x => x.Fid, ops => ops.Ignore())
|
||||
.ForMember(x => x.Qty, ops => ops.Ignore());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,11 +44,28 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Save(List<SaveOutStockRequest> dto, LoginInDto loginInfo)
|
||||
public async Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
OutStock entity = new OutStock();
|
||||
entity.Details = _mapper.Map<List<OutStockDetails>>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
|
||||
OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
|
||||
|
||||
if (entity == null)
|
||||
entity = new OutStock();
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
|
||||
foreach (var d in dto.Details)
|
||||
{
|
||||
//任务单明细
|
||||
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
||||
if (tDetail == null) continue;
|
||||
//出库单明细
|
||||
OutStockDetails outd = entity.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
||||
if (outd == null)
|
||||
{
|
||||
outd = _mapper.Map<OutStockDetails>(tDetail);
|
||||
entity.Details.Add(outd);
|
||||
}
|
||||
outd.Qty = outd.Qty + d.Qty;
|
||||
}
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -57,7 +74,11 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
if (entity.Id > 0)
|
||||
entity = await _outStockRepositories.Edit(entity, false);
|
||||
else
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
|
||||
if (entity == null) isRollback = true;
|
||||
|
||||
//提交事务
|
||||
|
||||
Reference in New Issue
Block a user