重写预任务申请,任务执行删除功能
This commit is contained in:
56
WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
Normal file
56
WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
public class TaskManagerDelBase<T> : BaseWareHouseService where T : BaseEntity<string>, ITaskManagerDel, new()
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
public TaskManagerDelBase(ISqlSugarClient db)
|
||||
{
|
||||
_db = db;
|
||||
OverideFuncs.DeleteAsync = UnLockLocationAndCarry;
|
||||
}
|
||||
private async Task UnLockLocationAndCarry(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var preTask = await _db.Queryable<T>().SingleAsync(it => it.id == id);
|
||||
if (preTask != null)
|
||||
{
|
||||
var locIds = new[] { preTask.startlocation_id, preTask.endlocation_id };
|
||||
var locs = await _db.Queryable<BasLocation>().Where(it => locIds.Contains(it.id)).ToListAsync();
|
||||
if (locs?.Count > 0)
|
||||
{
|
||||
locs.ForEach(it => { it.is_lock = 0; });
|
||||
await _db.Updateable(locs).UpdateColumns(it => it.is_lock).ExecuteCommandAsync();
|
||||
}
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == preTask.carry_id);
|
||||
if (carry != null)
|
||||
{
|
||||
carry.is_lock = 0;
|
||||
await _db.Updateable(carry).UpdateColumns(it => it.is_lock).ExecuteCommandAsync();
|
||||
}
|
||||
await _db.Deleteable(preTask).ExecuteCommandAsync();
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user