This commit is contained in:
FanLian
2023-09-08 08:18:56 +08:00
17 changed files with 219 additions and 41 deletions

View File

@@ -40,5 +40,10 @@ public partial class WmsCarryCode
/// </summary>
[SugarColumn(IsIgnore = true)]
public int check_conclusion { get; set; }
/// <summary>
/// 出库需求量(临时)
/// </summary>
[SugarColumn(IsIgnore = true)]
public decimal pr_qty { get; set; }
}

View File

@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using Aspose.Cells.Drawing;
using JavaScriptEngineSwitcher.Core.Extensions;
using JNPF;
using JNPF.Common.Contracts;
using JNPF.Common.Core.Manager;
@@ -27,6 +28,7 @@ using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Dml;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using SqlSugar;
@@ -46,7 +48,7 @@ namespace Tnb.WarehouseMgr
[Route("api/[area]/[controller]/[action]")]
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
{
private static Dictionary<string, IWHStorageService> _stroageMap = new(StringComparer.OrdinalIgnoreCase);
private static Lazy<Dictionary<string, IWHStorageService>> _stroageMap;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
private readonly ChannelWriter<NotifyMessage> _channelWriter;
@@ -57,17 +59,24 @@ namespace Tnb.WarehouseMgr
static BaseWareHouseService()
{
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
foreach (var serviceType in serviceTypes)
_stroageMap = new Lazy<Dictionary<string, IWHStorageService>>(() =>
{
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
if (!callerName.IsNullOrEmpty())
Dictionary<string, IWHStorageService> map = new(StringComparer.OrdinalIgnoreCase);
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
foreach (var serviceType in serviceTypes)
{
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
if (obj == null) continue;
_stroageMap[callerName] = obj;
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
if (!callerName.IsNullOrEmpty())
{
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
if (obj == null) continue;
map[callerName] = obj;
}
}
}
return map;
});
}
protected Task<ClaimsPrincipal> GetUserIdentity()
@@ -112,6 +121,9 @@ namespace Tnb.WarehouseMgr
}
return Task.FromResult(isMatch);
}
/// <summary>
/// 发布消息
/// </summary>
@@ -128,9 +140,9 @@ namespace Tnb.WarehouseMgr
[NonAction]
protected async Task DoUpdate(WareHouseUpInput input)
{
if (_stroageMap.ContainsKey(input.loginType))
if (_stroageMap.Value.ContainsKey(input.loginType))
{
await _stroageMap[input.loginType].Do(input);
await _stroageMap.Value[input.loginType].Do(input);
}
}
[NonAction]

View File

@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
@@ -90,7 +93,6 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true);
await _runService.Create(templateEntity, input);

View File

@@ -32,6 +32,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
using System.Reflection;
namespace Tnb.WarehouseMgr
{
@@ -145,6 +146,7 @@ namespace Tnb.WarehouseMgr
{
List<WmsCarryMat> carryMats = new();
List<WmsCarryCode> carryCodes = new();
List<WmsCarryCode> carryCodesPart = new();
foreach (var os in outStockDList)
{
var OutStockStrategyInput = new OutStockStrategyQuery
@@ -159,9 +161,11 @@ namespace Tnb.WarehouseMgr
? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
: (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
List<WmsCarryCode>? carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
.Where(whereExp)
.Select<WmsCarryCode>()
.MergeTable()
.OrderBy(it=>it.create_time)
.ToListAsync();
if (carryCodesPart?.Count > 0)
@@ -214,7 +218,7 @@ namespace Tnb.WarehouseMgr
var sortingOutIds = new List<string>();
foreach (var pair in dic)
{
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
var codes = carryCodesPart.FindAll(x => x.carry_id == pair.Key);
if (codes?.Count > 0)
{
if (pair.Value == codes.Sum(d => d.codeqty))
@@ -644,12 +648,12 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
var curUser = await GetUserIdentity();
var carryId = input.carryIds[^input.carryIds.Count];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
if (carry != null)
{
var otds = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
var outStatus = carry.out_status.ToEnum<EnumOutStatus>();
if (outStatus == EnumOutStatus.)
@@ -658,7 +662,7 @@ namespace Tnb.WarehouseMgr
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
var outStockCodes = carryCodes.Adapt<List<WmsOutstockCode>>();
outStockCodes.ForEach(x =>
{
var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
@@ -669,8 +673,8 @@ namespace Tnb.WarehouseMgr
x.id = SnowflakeIdHelper.NextId();
x.bill_id = input.requireId;
x.bill_d_id = billDId!;
x.org_id = _userManager.User?.OrganizeId ?? curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value ?? string.Empty;
x.create_id = _userManager.UserId ?? curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value ?? string.Empty; ;
x.org_id = _userManager.User.OrganizeId;
x.create_id = _userManager.UserId;
x.create_time = DateTime.Now;
});
await _db.Insertable(outStockCodes).ExecuteCommandAsync();
@@ -721,8 +725,8 @@ namespace Tnb.WarehouseMgr
x.id = SnowflakeIdHelper.NextId();
x.bill_id = input.requireId;
x.bill_d_id = billDId!;
x.org_id = _userManager.User?.OrganizeId ?? curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value ?? string.Empty;
x.create_id = _userManager.UserId?? curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value ?? string.Empty;
x.org_id = _userManager.User?.OrganizeId;
x.create_id = _userManager.UserId;
x.create_time = DateTime.Now;
});
await _db.Insertable(osCodes).ExecuteCommandAsync();
@@ -787,13 +791,13 @@ namespace Tnb.WarehouseMgr
await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync();
}
}
var row = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync();
}
if (delBarcodes.Count > 0)
{
await _db.Deleteable<WmsCarryCode>().Where(it => delBarcodes.Contains(it.barcode)).ExecuteCommandAsync();
}
var row = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync();
//载具移入
var outStockH = await _db.Queryable<WmsOutstockH>().SingleAsync(it => it.id == input.requireId);
var visulDevInput = new VisualDevModelDataCrInput();
@@ -809,6 +813,7 @@ namespace Tnb.WarehouseMgr
[nameof(WmsMoveInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
[nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(),
};
await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput);
}

View File

@@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
@@ -63,6 +65,107 @@ namespace Tnb.WarehouseMgr
private async Task<dynamic> PDACarryMoveIn(VisualDevModelDataCrInput input)
{
#region old
//try
//{
// await _db.Ado.BeginTranAsync();
// //入库取终点 //出库起点
// var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
// var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
// WmsPointH sPoint = null!;
// WmsPointH ePoint = null!;
// if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
// {
// sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
// }
// if (endLocations?.Count > 0)
// {
// var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
// var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
// var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
// if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
// ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
// }
// VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
// await _runService.Create(templateEntity, input);
// if (sPoint != null && ePoint != null)
// {
// var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
// //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
// if (points?.Count > 0)
// {
// if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
// var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
// {
// var sPoint = it.FirstOrDefault();
// var ePoint = it.LastOrDefault();
// 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.start_floor = sPoint?.floor.ToString();
// preTask.end_floor = ePoint?.floor.ToString();
// preTask.startpoint_id = sPoint?.id!;
// preTask.startpoint_code = sPoint?.point_code!;
// preTask.endpoint_id = ePoint?.id!;
// preTask.endpoint_code = ePoint?.point_code!;
// preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
// preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
// preTask.biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID;
// preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
// preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!;
// preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!;
// preTask.area_id = sPoint?.area_id!;
// preTask.area_code = it.Key;
// preTask.require_id = input.data["ReturnIdentity"].ToString();
// preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
// preTask.create_id = _userManager.UserId;
// preTask.create_time = DateTime.Now;
// return preTask;
// }).ToList();
// var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
// if (isOk)
// {
// var preTaskUpInput = new GenPreTaskUpInput();
// preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
// preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
// preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
// preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
// preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
// preTaskUpInput.PreTaskRecords = preTasks.Adapt<List<WmsHandleH>>();
// preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
// //根据载具移入Id回更单据状态
// await _db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
// await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
// it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
// it => new BasLocation { is_lock = 1 });
// }
// }
// }
// await _db.Ado.CommitTranAsync();
//}
//catch (Exception)
//{
// await _db.Ado.RollbackTranAsync();
// throw;
//}
//finally
//{
// await Publish(nameof(IWareHouseService.GenTaskExecute));
//}
//return Task.FromResult(true);
#endregion
try
{
await _db.Ado.BeginTranAsync();
@@ -85,9 +188,11 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true);
await _runService.Create(templateEntity, input);
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
@@ -101,7 +206,7 @@ namespace Tnb.WarehouseMgr
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.org_id = _userManager.User.OrganizeId!;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
@@ -135,18 +240,28 @@ namespace Tnb.WarehouseMgr
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
preTaskUpInput.PreTaskRecords = preTasks.Adapt<List<WmsHandleH>>();
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
WmsHandleH handleH = new();
handleH.org_id = _userManager.User.OrganizeId;
handleH.startlocation_id = input.data[nameof(WmsPointH.location_id)]?.ToString()!;
handleH.endlocation_id = endLocations![0].id;
handleH.bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
handleH.biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!;
handleH.carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!;
handleH.carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!;
handleH.require_id = input.data["ReturnIdentity"].ToString();
handleH.require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
handleH.create_id = _userManager.UserId ;
handleH.create_time = DateTime.Now;
preTaskUpInput.PreTaskRecord = handleH;
//根据载具移入Id回更单据状态
await _db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
it => new BasLocation { is_lock = 1 });
}
}
}
await _db.Ado.CommitTranAsync();
@@ -158,9 +273,11 @@ namespace Tnb.WarehouseMgr
}
finally
{
//向队列写入消息
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}
public override async Task ModifyAsync(WareHouseUpInput input)

View File

@@ -5,6 +5,7 @@ using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Contracts;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.FriendlyException;
@@ -33,12 +34,14 @@ namespace Tnb.WarehouseMgr
private readonly IDictionaryDataService _dictionaryDataService;
private readonly IWmsCarryMoveInStockService _wmsCarryMoveInStockService;
private static Dictionary<string, object> _dicBizType = new();
public WmsSignForDeliveryService(ISqlSugarRepository<WmsDistaskH> repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService, IWmsCarryMoveInStockService wmsCarryMoveInStockService)
private readonly IUserManager _userManager;
public WmsSignForDeliveryService(ISqlSugarRepository<WmsDistaskH> repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService, IWmsCarryMoveInStockService wmsCarryMoveInStockService, IUserManager userManager)
{
_db = repository.AsSugarClient();
_wareCarryService = wareCarryService;
_dictionaryDataService = dictionaryDataService;
_wmsCarryMoveInStockService = wmsCarryMoveInStockService;
_userManager = userManager;
}
/// <summary>
/// 根据载具ID获取对应的执行任务记录

View File

@@ -115,8 +115,8 @@ public class Startup : AppStartup
SnowflakeIdHelper.InitYitIdWorker();
//bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob");
//if (isStartTimeJob)
// serviceProvider.GetRequiredService<ITimeTaskService>().StartTimerJob();
bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob");
if (isStartTimeJob)
serviceProvider.GetRequiredService<ITimeTaskService>().StartTimerJob();
}
}

View File

@@ -70,12 +70,13 @@ public partial class UserManager : IUserManager, IScoped
}
}
/// <summary>
/// 用户信息.
/// </summary>
public UserEntity User
{
get => _repository.GetSingle(u => u.Id == UserId);
get =>_repository.GetSingle(u => u.Id == UserId);
}
/// <summary>

View File

@@ -21,7 +21,8 @@ namespace JNPF.Common.Core.Manager;
/// <summary>
/// 用户管理 .
/// </summary>
public partial class UserManager
public partial class UserManager
{
public static string AsscessToken { get; set; }
}

View File

@@ -78,4 +78,12 @@ public interface IOrganizeService
/// <param name="id"></param>
/// <returns></returns>
Task<List<string>> GetChildOrgId(string id);
/// <summary>
/// 根据工位id获取其任意上级
/// </summary>
/// <param name="id"></param>
/// <param name="type"></param>
/// <returns></returns>
Task<OrganizeEntity> GetAnyParentByWorkstationId(string id,string type);
}

View File

@@ -19,6 +19,7 @@ using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData;
using Yitter.IdGenerator;
namespace JNPF.Systems;
@@ -835,6 +836,14 @@ public class OrganizeService : IOrganizeService, IDynamicApiController, ITransie
return (await _repository.GetListAsync(x => x.OrganizeIdTree.Contains(id) && x.EnabledMark == 1 && x.DeleteMark == null)).Select(x => x.Id).ToList();
}
public async Task<OrganizeEntity> GetAnyParentByWorkstationId(string id, string type)
{
return await _repository.AsQueryable()
.LeftJoin<OrganizeEntity>((a,b)=>a.OrganizeIdTree.Contains(b.Id) && b.Category==type)
.Where((a,b)=>a.Id==id)
.Select((a,b)=>b).FirstAsync();
}
/// <summary>
/// 处理组织树 名称.
/// </summary>

View File

@@ -1,4 +1,6 @@
namespace JNPF.TaskScheduler.Interfaces.TaskScheduler;
using JNPF.TaskScheduler.Entitys;
namespace JNPF.TaskScheduler.Interfaces.TaskScheduler;
/// <summary>
    /// 定时任务
@@ -13,4 +15,6 @@ public interface ITimeTaskService
/// 启动自启动任务.
/// </summary>
void StartTimerJob();
List<TimeTaskEntity> GetTasks();
}

View File

@@ -8,6 +8,7 @@ using JNPF.Common.Security;
using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
@@ -19,12 +20,14 @@ namespace Tnb.TaskScheduler.Listener
public class MoldMaintainTask : ISpareTimeWorker
{
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
private ITimeTaskService timeTaskService => App.GetService<ITimeTaskService>();
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void CreateTask(SpareTimer timer, long count)
{
try
{
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
var TimeTasks = timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();

View File

@@ -9,6 +9,7 @@ using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
@@ -25,13 +26,14 @@ namespace Tnb.TaskScheduler.Listener
public class QcTaskTimeWorker : ISpareTimeWorker
{
private ISqlSugarRepository<QcCheckPlanH> repository => App.GetService<ISqlSugarRepository<QcCheckPlanH>>();
private ITimeTaskService timeTaskService => App.GetService<ITimeTaskService>();
[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void CreateTask(SpareTimer timer, long count)
{
try
{
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
var TimeTasks = timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();

View File

@@ -136,6 +136,12 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
#endregion
#region Post
public List<TimeTaskEntity> GetTasks()
{
var list= _repository.AsQueryable().ToList();
return list;
}
/// <summary>
/// 新建.

View File

@@ -4,7 +4,6 @@
/////////////////////////////////////////////////////////////////////////////////
using JNPF.Common.Configuration;
using JNPF.Systems.Entitys.Dto.Database;
using JNPF;
using Mapster;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using JNPF.Common.Configuration;
using Tnb.Core;
namespace Tnb.Vengine;
@@ -26,7 +27,7 @@ public class TemplateContext
#if DEBUG
BasePath = CodeHelper.GetSolutionDirectoryPath(false)!;
#else
BasePath = EApp.Options.App.AcmenBasePath;
BasePath = FileVariable.GenerateCodePath;
#endif
ModuleCode = moduleCode;
}