diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs index c41af99e..698881c0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs @@ -40,5 +40,10 @@ public partial class WmsCarryCode /// [SugarColumn(IsIgnore = true)] public int check_conclusion { get; set; } + /// + /// 出库需求量(临时) + /// + [SugarColumn(IsIgnore = true)] + public decimal pr_qty { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index 3532785c..a4166499 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -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 _stroageMap = new(StringComparer.OrdinalIgnoreCase); + private static Lazy> _stroageMap; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); private readonly ChannelWriter _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>(() => { - var callerName = serviceType.GetCustomAttribute()?.Name ?? string.Empty; - if (!callerName.IsNullOrEmpty()) + Dictionary 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()?.Name ?? string.Empty; + if (!callerName.IsNullOrEmpty()) + { + var obj = Activator.CreateInstance(serviceType) as IWHStorageService; + if (obj == null) continue; + map[callerName] = obj; + } } - } + return map; + }); + + } protected Task GetUserIdentity() @@ -112,6 +121,9 @@ namespace Tnb.WarehouseMgr } return Task.FromResult(isMatch); } + + + /// /// 发布消息 /// @@ -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] diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs index 3fca4882..817be66e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs @@ -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().FirstAsync(it => it.location_id == endLocations[0].id); } - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true); await _runService.Create(templateEntity, input); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index c45821f5..00ee9dfe 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -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 carryMats = new(); List carryCodes = new(); + List 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? carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) + carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) .Where(whereExp) .Select() + .MergeTable() + .OrderBy(it=>it.create_time) .ToListAsync(); if (carryCodesPart?.Count > 0) @@ -214,7 +218,7 @@ namespace Tnb.WarehouseMgr var sortingOutIds = new List(); 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().SingleAsync(it => it.id == carryId); if (carry != null) { - + var otds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); var outStatus = carry.out_status.ToEnum(); if (outStatus == EnumOutStatus.全部出) @@ -658,7 +662,7 @@ namespace Tnb.WarehouseMgr var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); var outStockCodes = carryCodes.Adapt>(); - + 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().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); - await _db.Deleteable().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); } if (delBarcodes.Count > 0) { await _db.Deleteable().Where(it => delBarcodes.Contains(it.barcode)).ExecuteCommandAsync(); } + var row = await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); + await _db.Deleteable().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); //载具移入 var outStockH = await _db.Queryable().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); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs index 0dd8a177..96211641 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs @@ -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 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().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); + // } + // if (endLocations?.Count > 0) + // { + // var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + // var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + // var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + // if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + // ePoint = await _db.Queryable().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>(); + // preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); + // //根据载具移入Id,回更单据状态 + // await _db.Updateable().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().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>(); - 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().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) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 1281bcf7..aa2258b8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -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 _dicBizType = new(); - public WmsSignForDeliveryService(ISqlSugarRepository repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService, IWmsCarryMoveInStockService wmsCarryMoveInStockService) + private readonly IUserManager _userManager; + public WmsSignForDeliveryService(ISqlSugarRepository repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService, IWmsCarryMoveInStockService wmsCarryMoveInStockService, IUserManager userManager) { _db = repository.AsSugarClient(); _wareCarryService = wareCarryService; _dictionaryDataService = dictionaryDataService; _wmsCarryMoveInStockService = wmsCarryMoveInStockService; + _userManager = userManager; } /// /// 根据载具ID获取,对应的执行任务记录 diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index 5f8b9d74..2d5ed531 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -115,8 +115,8 @@ public class Startup : AppStartup SnowflakeIdHelper.InitYitIdWorker(); - //bool isStartTimeJob = App.GetConfig("IsStartTimeJob"); - //if (isStartTimeJob) - // serviceProvider.GetRequiredService().StartTimerJob(); + bool isStartTimeJob = App.GetConfig("IsStartTimeJob"); + if (isStartTimeJob) + serviceProvider.GetRequiredService().StartTimerJob(); } } \ No newline at end of file diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.cs b/common/Tnb.Common.Core/Manager/User/UserManager.cs index bc1e0a60..72cfb692 100644 --- a/common/Tnb.Common.Core/Manager/User/UserManager.cs +++ b/common/Tnb.Common.Core/Manager/User/UserManager.cs @@ -70,12 +70,13 @@ public partial class UserManager : IUserManager, IScoped } } + /// /// 用户信息. /// public UserEntity User { - get => _repository.GetSingle(u => u.Id == UserId); + get =>_repository.GetSingle(u => u.Id == UserId); } /// diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.part.cs b/common/Tnb.Common.Core/Manager/User/UserManager.part.cs index 75597582..18b70051 100644 --- a/common/Tnb.Common.Core/Manager/User/UserManager.part.cs +++ b/common/Tnb.Common.Core/Manager/User/UserManager.part.cs @@ -21,7 +21,8 @@ namespace JNPF.Common.Core.Manager; /// /// 用户管理 . /// -public partial class UserManager +public partial class UserManager { public static string AsscessToken { get; set; } + } \ No newline at end of file diff --git a/system/Tnb.Systems.Interfaces/Permission/IOrganizeService.cs b/system/Tnb.Systems.Interfaces/Permission/IOrganizeService.cs index 2f5aa59d..92a02c9b 100644 --- a/system/Tnb.Systems.Interfaces/Permission/IOrganizeService.cs +++ b/system/Tnb.Systems.Interfaces/Permission/IOrganizeService.cs @@ -78,4 +78,12 @@ public interface IOrganizeService /// /// Task> GetChildOrgId(string id); + + /// + /// 根据工位id获取其任意上级 + /// + /// + /// + /// + Task GetAnyParentByWorkstationId(string id,string type); } \ No newline at end of file diff --git a/system/Tnb.Systems/Permission/OrganizeService.cs b/system/Tnb.Systems/Permission/OrganizeService.cs index fd02a5a2..e2a7bf88 100644 --- a/system/Tnb.Systems/Permission/OrganizeService.cs +++ b/system/Tnb.Systems/Permission/OrganizeService.cs @@ -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 GetAnyParentByWorkstationId(string id, string type) + { + return await _repository.AsQueryable() + .LeftJoin((a,b)=>a.OrganizeIdTree.Contains(b.Id) && b.Category==type) + .Where((a,b)=>a.Id==id) + .Select((a,b)=>b).FirstAsync(); + } + /// /// 处理组织树 名称. /// diff --git a/taskschedule/Tnb.TaskScheduler.Interfaces/ITimeTaskService.cs b/taskschedule/Tnb.TaskScheduler.Interfaces/ITimeTaskService.cs index 765ae574..88626728 100644 --- a/taskschedule/Tnb.TaskScheduler.Interfaces/ITimeTaskService.cs +++ b/taskschedule/Tnb.TaskScheduler.Interfaces/ITimeTaskService.cs @@ -1,4 +1,6 @@ -namespace JNPF.TaskScheduler.Interfaces.TaskScheduler; +using JNPF.TaskScheduler.Entitys; + +namespace JNPF.TaskScheduler.Interfaces.TaskScheduler; ///     /// 定时任务 @@ -13,4 +15,6 @@ public interface ITimeTaskService /// 启动自启动任务. /// void StartTimerJob(); + + List GetTasks(); } diff --git a/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs index ea0da118..64648af6 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs @@ -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 repository => App.GetService>(); + private ITimeTaskService timeTaskService => App.GetService(); [SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)] public async void CreateTask(SpareTimer timer, long count) { try { - var timeTaskEntity = await repository.AsSugarClient().Queryable().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(); diff --git a/taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs index 00b15904..84aab7fe 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs @@ -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 repository => App.GetService>(); - + private ITimeTaskService timeTaskService => App.GetService(); [SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)] public async void CreateTask(SpareTimer timer, long count) { try { - var timeTaskEntity = await repository.AsSugarClient().Queryable().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(); diff --git a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs index 9b62e4c1..3390256d 100644 --- a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs +++ b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs @@ -136,6 +136,12 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie #endregion #region Post + public List GetTasks() + { + var list= _repository.AsQueryable().ToList(); + return list; + } + /// /// 新建. diff --git a/visualdev/Tnb.Vengine/AppService/VmodelAppService.cs b/visualdev/Tnb.Vengine/AppService/VmodelAppService.cs index 2f1f71d9..de030730 100644 --- a/visualdev/Tnb.Vengine/AppService/VmodelAppService.cs +++ b/visualdev/Tnb.Vengine/AppService/VmodelAppService.cs @@ -4,7 +4,6 @@ ///////////////////////////////////////////////////////////////////////////////// using JNPF.Common.Configuration; -using JNPF.Systems.Entitys.Dto.Database; using JNPF; using Mapster; using Microsoft.AspNetCore.Mvc; diff --git a/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs b/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs index a62b4cd9..61468d79 100644 --- a/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs +++ b/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs @@ -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; }