通用修改业务函数代码提交
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -15,8 +20,36 @@ namespace Tnb.WarehouseMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
private static Dictionary<string, BaseWareHouseService> _serviceMap = new Dictionary<string, BaseWareHouseService>();
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
|
||||
static BaseWareHouseService()
|
||||
{
|
||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
|
||||
foreach (var serviceType in serviceTypes)
|
||||
{
|
||||
var bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
|
||||
if (!bizTypeId.IsNullOrEmpty())
|
||||
{
|
||||
_serviceMap[bizTypeId!] = (BaseWareHouseService)Activator.CreateInstance(serviceType)!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Task this[WareHouseUpInput input]
|
||||
{
|
||||
set
|
||||
{
|
||||
if (_serviceMap.ContainsKey(input.bizTypeId))
|
||||
{
|
||||
_serviceMap[input.bizTypeId].ModifyAsync(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,14 +393,35 @@ namespace Tnb.WarehouseMgr
|
||||
//更新任务执行表,单据状态为 完成
|
||||
await _db.Updateable<WmsDistaskH>().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
//更新预任务申请表,单据状态为 已完成
|
||||
var preTaskIds = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.pretask_id).ToListAsync();
|
||||
if(preTaskIds?.Count > 0)
|
||||
var disTasks = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).ToListAsync();
|
||||
if (disTasks?.Count > 0)
|
||||
{
|
||||
var preTaskIds = disTasks.Select(x => x.pretask_id).ToList();
|
||||
await _db.Updateable<WmsPretaskH>().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID }).Where(it => preTaskIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
//更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位
|
||||
if (disTasks?.Count > 0)
|
||||
{
|
||||
var multiList = disTasks.Select(it => (it.carry_id, it.endlocation_id)).ToList();
|
||||
for (int i = 0; i < multiList.Count; i++)
|
||||
{
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { is_lock = 0, location_id = multiList[i].endlocation_id }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
//更新库位信息,使用状态为 使用,锁定状态为未锁定
|
||||
if (disTasks?.Count > 0)
|
||||
{
|
||||
var destLocIds = disTasks.Select(it => it.endlocation_id).ToList();
|
||||
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = "1", is_lock = 0 }).Where(it => destLocIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
//更新业务主表的单据状态
|
||||
if (disTasks?.Count > 0)
|
||||
{
|
||||
foreach (var dt in disTasks)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -456,7 +477,6 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
#region PrivateMethods
|
||||
|
||||
private bool isArrivedEpoint = false;
|
||||
private async Task<List<WmsPointH>> LocPathCalcAlgorithms(string pStartId, string pEndId, List<WmsRoad> roads)
|
||||
{
|
||||
var points = await _db.Queryable<WmsPointH>().ToListAsync();
|
||||
|
||||
@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
@@ -28,8 +29,10 @@ namespace Tnb.WarehouseMgr
|
||||
/// 载具移入
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleId)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
public class WmsCarryMoveInStockService : BaseWareHouseService
|
||||
{
|
||||
private const string BizTypeId = "26121988909861";
|
||||
private const string ModuleId = "26122102481957";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
@@ -137,5 +140,12 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
var isOk = await _db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 空载具入库
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleId)]
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class WmsEmptyInstockService : BaseWareHouseService
|
||||
{
|
||||
private const string ModuleId = "26120915344165";
|
||||
|
||||
Reference in New Issue
Block a user