重写预任务申请,任务执行删除功能
This commit is contained in:
@@ -48,7 +48,7 @@ public class ModuleConsts
|
||||
/// 模块标识-PDA空载具入库
|
||||
/// </summary>
|
||||
public const string MODULE_WMSEMPTYINSTKPDA_ID = "26475795363877";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 模块标识-PDA载具更换
|
||||
/// </summary>
|
||||
@@ -144,5 +144,13 @@ public class ModuleConsts
|
||||
/// 模块标识-空载具入库
|
||||
/// </summary>
|
||||
public const string MODULE_WMSEMPTYINSTOCK_ID = "26120915344165";
|
||||
/// <summary>
|
||||
/// 模块标识-预任务申请
|
||||
/// </summary>
|
||||
public const string MODULE_WMSPRETASK_ID = "26126898582309";
|
||||
/// <summary>
|
||||
/// 模块标识-任务执行
|
||||
/// </summary>
|
||||
public const string MODULE_WMSDISTASK_ID = "26128621455141";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity
|
||||
{
|
||||
public interface ITaskManagerDel
|
||||
{
|
||||
string startlocation_id { get; set; }
|
||||
string endlocation_id { get; set; }
|
||||
string carry_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 任务执行主表
|
||||
/// </summary>
|
||||
public partial class WmsDistaskH
|
||||
public partial class WmsDistaskH : ITaskManagerDel
|
||||
{
|
||||
/// <summary>
|
||||
/// 载具状态
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 预任务申请主表
|
||||
/// </summary>
|
||||
public partial class WmsPretaskH
|
||||
public partial class WmsPretaskH : ITaskManagerDel
|
||||
{
|
||||
/// <summary>
|
||||
/// 单次搬运数量
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,6 +488,9 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成预任务
|
||||
/// </summary>
|
||||
|
||||
52
WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
Normal file
52
WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.VisualDev;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSDISTASK_ID)]
|
||||
public class WmsDistaskService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
public WmsDistaskService(ISqlSugarRepository<WmsDistaskH> repository)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
OverideFuncs.DeleteAsync = Delete;
|
||||
}
|
||||
|
||||
private async Task Delete(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var disTask = await _db.Queryable<WmsDistaskH>().SingleAsync(it => it.id == id);
|
||||
if (disTask != null)
|
||||
{
|
||||
var preTask = await _db.Queryable<WmsPretaskH>().SingleAsync(it => it.id == disTask.pretask_id);
|
||||
if (preTask != null)
|
||||
{
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
await _db.Updateable(preTask).UpdateColumns(it => it.status).ExecuteCommandAsync();
|
||||
}
|
||||
await _db.Deleteable(disTask).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,12 +221,12 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
||||
if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||
{
|
||||
//如果是自动单据,需要回更上层系统
|
||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } };
|
||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
||||
instock.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
||||
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
||||
}
|
||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
@@ -348,22 +348,22 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
WmsPretaskH preTask = new();
|
||||
preTask.org_id = _userManager.User.OrganizeId;
|
||||
preTask.startlocation_id = sPoint?.location_id!;
|
||||
preTask.startlocation_code = sPoint?.location_code!;
|
||||
preTask.endlocation_id = ePoint?.location_id!;
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.startlocation_id = sPoint?.location_id ?? string.Empty;
|
||||
preTask.startlocation_code = sPoint?.location_code ?? string.Empty;
|
||||
preTask.endlocation_id = ePoint?.location_id ?? string.Empty;
|
||||
preTask.endlocation_code = ePoint?.location_code ?? string.Empty;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = instock.biz_type;
|
||||
preTask.biz_type = instock?.biz_type ?? string.Empty;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||
preTask.carry_id = instock.carry_id!;
|
||||
preTask.carry_code = instock.carry_code!;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.carry_id = instock?.carry_id ?? string.Empty;
|
||||
preTask.carry_code = instock?.carry_code ?? string.Empty;
|
||||
preTask.area_id = sPoint?.area_id ?? string.Empty;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = instock.id;
|
||||
preTask.require_code = instock.bill_code;
|
||||
preTask.require_id = instock?.id ?? string.Empty;
|
||||
preTask.require_code = instock?.bill_code ?? string.Empty;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
|
||||
23
WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
Normal file
23
WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.VisualDev;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSPRETASK_ID)]
|
||||
public class WmsPretaskService : TaskManagerDelBase<WmsPretaskH>
|
||||
{
|
||||
public WmsPretaskService(ISqlSugarRepository<WmsPretaskH> repository) : base(repository.AsSugarClient())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ namespace Tnb.WarehouseMgr
|
||||
// isOk = row > 0;
|
||||
//}
|
||||
//判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据,
|
||||
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
|
||||
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && carryMIds?.Count > 0)
|
||||
{
|
||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryMIds.Contains(it.id)).ToListAsync();
|
||||
carrys.Add(carry);
|
||||
@@ -325,7 +325,7 @@ namespace Tnb.WarehouseMgr
|
||||
public async Task<dynamic> MESKittingOutStk(List<MESKittingOutStkInput> input)
|
||||
{
|
||||
var isSuccessFul = false;
|
||||
if (input.IsNull()) throw new ArgumentNullException("input");
|
||||
if (input.IsNull()) throw new ArgumentNullException(nameof(input));
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user