From 0ad3ac3f5d7bae08e37df4194092f3698a34cc5d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 4 Sep 2023 16:32:03 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=93=BE=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E7=8A=B6=E6=80=81=E6=96=B0=E5=A2=9E=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=88=B0=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/DeviceProviderService.cs | 44 +++++++++++++++++-- .../Tnb.WarehouseMgr/WareHouseService.cs | 2 +- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index f2a5437b..47c8cbaa 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -3,11 +3,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using JNPF; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; +using JNPF.Common.Manager; +using JNPF.Common.Net; +using JNPF.Common.Security; +using JNPF.EventBus; +using JNPF.EventHandler; using JNPF.FriendlyException; using JNPF.Logging; +using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -33,12 +40,22 @@ namespace Tnb.WarehouseMgr { private readonly ISqlSugarClient _db; private readonly IWareHouseService _wareHouseService; - + private readonly ICacheManager _cacheManager; + private readonly IEventPublisher _eventPublisher; + private readonly IUserManager _userManager; - public DeviceProviderService(ISqlSugarRepository repository, IWareHouseService wareHouseService) + + public DeviceProviderService(ISqlSugarRepository repository, IWareHouseService wareHouseService, + ICacheManager cacheManager, + IEventPublisher eventPublisher, + IUserManager userManger + ) { _db = repository.AsSugarClient(); _wareHouseService = wareHouseService; + _cacheManager = cacheManager; + _eventPublisher = eventPublisher; + _userManager = userManger; } /// @@ -101,7 +118,7 @@ namespace Tnb.WarehouseMgr /// 任务链状态上报 /// /// - [HttpPost, NonUnify,AllowAnonymous] + [HttpPost, NonUnify, AllowAnonymous] public async Task TaskChainCallBack(TaskChainCallBackInput input) { try @@ -110,8 +127,9 @@ namespace Tnb.WarehouseMgr switch (input.status) { case "CREATED": break; - case "ALLOCATED":break; + case "ALLOCATED": break; case "PROCESSING": + if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break; if (input.taskChainCode.Trim().IsNullOrEmpty()) break; var disTasks = await _db.Queryable().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync(); var eps = await _db.Queryable().Where(it => it.code.Contains(input.deviceID)).ToListAsync(); @@ -127,6 +145,24 @@ namespace Tnb.WarehouseMgr case "FINISHED": break; default: break; } + //写入redis + await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}"); + var opts = App.GetOptions(); + UserAgent userAgent = new(App.HttpContext); + //写系统日志 + await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", opts, new SysLogEntity + { + Id = SnowflakeIdHelper.NextId(), + Category = 4, + UserId = _userManager.UserId, + UserName = _userManager.User.RealName, + IPAddress = NetHelper.Ip, + RequestURL = App.HttpContext.Request.Path, + RequestMethod = App.HttpContext.Request.Method, + Json = $"任务链状态上报,任务链编号:{input.taskChainCode},上报状态:{input.status},设备编号:{input.deviceID}", + PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue), + CreatorTime = DateTime.Now + })); } catch (Exception) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index d5434dd6..09471778 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -360,7 +360,7 @@ namespace Tnb.WarehouseMgr { dynamic reqBody = new ExpandoObject(); reqBody.taskChainCode = k; - reqBody.type = (int)EnumTaskChainType.KIVA; + reqBody.type = (int)EnumTaskChainType.AGV; reqBody.sequential = false; reqBody.taskChainPriority = 0; reqBody.taskList = v; From ef246e47202309ce095498193c24ce10d651573b Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 4 Sep 2023 16:32:07 +0800 Subject: [PATCH 2/9] 1 --- WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 47c8cbaa..dac9ce55 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -129,7 +129,7 @@ namespace Tnb.WarehouseMgr case "CREATED": break; case "ALLOCATED": break; case "PROCESSING": - if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break; + //if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break; if (input.taskChainCode.Trim().IsNullOrEmpty()) break; var disTasks = await _db.Queryable().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync(); var eps = await _db.Queryable().Where(it => it.code.Contains(input.deviceID)).ToListAsync(); @@ -146,7 +146,7 @@ namespace Tnb.WarehouseMgr default: break; } //写入redis - await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}"); + //await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}"); var opts = App.GetOptions(); UserAgent userAgent = new(App.HttpContext); //写系统日志 From b573a49f4bf6cb0e938a9b04576d6b1eeaae958e Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Mon, 4 Sep 2023 17:22:47 +0800 Subject: [PATCH 3/9] =?UTF-8?q?PDA=E8=AE=BE=E5=A4=87=E7=82=B9=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=20=E4=BF=9D=E5=85=BB=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.EquipMgr/EquMaintainRecordService.cs | 29 ++++++++++++++++++- .../Tnb.EquipMgr/EquSpotInsRecordService.cs | 27 +++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs index e69aad04..d80b10d1 100644 --- a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -129,7 +129,7 @@ namespace Tnb.EquipMgr foreach (var item in input.details) { await db.Updateable() - .SetColumns(x => x.repeat_descrip == item["repeat_descrip"]) + .SetColumnsIF(item.ContainsKey("repeat_descrip"),x => x.repeat_descrip == item["repeat_descrip"]) .SetColumns(x => x.repeat_result == item["repeat_result"]) .Where(x => x.id == item["id"]).ExecuteCommandAsync(); } @@ -187,5 +187,32 @@ namespace Tnb.EquipMgr return PageResult.SqlSugarPageResult(result); } + + /// + /// 根据id获取保养相关信息 + /// + /// + [HttpPost] + public async Task GetEqpMaintainRecordInfoById(Dictionary dic) + { + string id = dic.ContainsKey("id") ? dic["id"] : ""; + if (string.IsNullOrEmpty(id)) return null; + var db = _repository.AsSugarClient(); + return await db.Queryable() + .LeftJoin((a, b) => a.equip_id==b.id) + .Where((a, b) => a.id == id) + .Select((a, b) => new + { + id = a.id, + equip_id = a.equip_id, + equip_code = b.code, + equip_name = b.name, + create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + result_remark = a.result_remark, + result = a.result, + status = a.status, + }).FirstAsync(); + + } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs index fad3138d..ad2106a0 100644 --- a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs @@ -162,5 +162,32 @@ namespace Tnb.EquipMgr return PageResult.SqlSugarPageResult(result); } + + /// + /// 根据id获取点巡检相关信息 + /// + /// + [HttpPost] + public async Task GetEqpSpotInsRecordInfoById(Dictionary dic) + { + string id = dic.ContainsKey("id") ? dic["id"] : ""; + if (string.IsNullOrEmpty(id)) return null; + var db = _repository.AsSugarClient(); + return await db.Queryable() + .LeftJoin((a, b) => a.equip_id==b.id) + .Where((a, b) => a.id == id) + .Select((a, b) => new + { + id = a.id, + equip_id = a.equip_id, + equip_code = b.code, + equip_name = b.name, + create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + result_remark = a.result_remark, + result = a.result, + status = a.status, + }).FirstAsync(); + + } } } \ No newline at end of file From 11141f7e1bb92f6599a147c4a6e14b78dcae5eed Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 5 Sep 2023 15:47:52 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/GenericEnumDicionary.cs | 35 +++++++++++++++++++ .../Mapper/Mapper.cs | 3 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/GenericEnumDicionary.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/GenericEnumDicionary.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/GenericEnumDicionary.cs new file mode 100644 index 00000000..c8183b00 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/GenericEnumDicionary.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Extension; +using Spire.Pdf.Widget; +using Tnb.WarehouseMgr.Entities.Enums; + +namespace Tnb.WarehouseMgr.Entities.Consts +{ + + public class GenericEnumDicionary where T : Enum + { + private static string tn = typeof(T).Name; + private static ConcurrentDictionary> enumDescMap = new(); + private static ConcurrentDictionary enumMemberMap = new(); + + static GenericEnumDicionary() + { + enumMemberMap.GetOrAdd(tn, f => typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static)); + if (enumMemberMap[tn]?.All(f => f.GetCustomAttribute() != null) ?? false) + { + enumDescMap.GetOrAdd(tn, dic => typeof(T).GetEnumDescDictionary()); + } + } + public static string GetEnumDesc(int enumVal) + { + return enumDescMap.ContainsKey(tn) ? enumDescMap[tn]?[enumVal] ?? string.Empty : string.Empty; + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Mapper/Mapper.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Mapper/Mapper.cs index 1deef1ac..832fb911 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Mapper/Mapper.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Mapper/Mapper.cs @@ -6,6 +6,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.Common; using JNPF.Common.Extension; using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Entities.Consts; namespace Tnb.WarehouseMgr.Entities.Mapper { @@ -23,7 +24,7 @@ namespace Tnb.WarehouseMgr.Entities.Mapper config.ForType() .Map(dest => dest.qc_status, src => src.is_check == 0 ? "不合格" : "合格"); config.ForType() - .Map(dest => dest.check_conclusion, src => src.check_conclusion.ToEnum().GetDescription()); + .Map(dest => dest.check_conclusion, src => GenericEnumDicionary.GetEnumDesc(src.check_conclusion)); } } } \ No newline at end of file From 36e4944e5e5bbfbc91b582f50f0af023ae172df8 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Tue, 5 Sep 2023 16:15:18 +0800 Subject: [PATCH 5/9] 1 --- .../Entity/ToolMoldMaintainPlanRelation.cs | 3 + .../Entity/ToolMoldMaintainRunRecordD.cs | 2 + EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj | 1 + .../ToolMoldMaintainRuleService.cs | 77 ++++++++++++++++++- .../ToolMoldMaintainRunService.cs | 31 +++++++- .../Listener/MoldMaintainTask.cs | 66 ++++++++++++++++ 6 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs index 7218b75f..4a0ec1b5 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs @@ -26,6 +26,9 @@ public partial class ToolMoldMaintainPlanRelation : BaseEntity /// public string mold_id { get; set; } = string.Empty; + public string group_id { get; set; } = string.Empty; + + } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs index 04a23a42..20f684dc 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs @@ -39,4 +39,6 @@ public partial class ToolMoldMaintainRunRecordD : BaseEntity /// public string? check_item_name { get; set; } + public string? mainid { get; set; } + } diff --git a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj index 94325618..ad5c6e86 100644 --- a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj +++ b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj @@ -11,6 +11,7 @@ + diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs index c39705c9..9490814b 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs @@ -2,11 +2,14 @@ using System.Collections.Generic; using System.Dynamic; using System.Linq; +using System.Reactive; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Aop.Api.Domain; using Aspose.Cells.Drawing; using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; @@ -14,11 +17,18 @@ using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Logging; using JNPF.Systems.Interfaces.System; +using JNPF.TaskScheduler; +using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler; +using JNPF.TaskScheduler.Entitys.Model; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis.CSharp.Syntax; using SqlSugar; using Tnb.BasicData; +using Tnb.BasicData.Entities; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; @@ -30,17 +40,78 @@ namespace Tnb.EquipMgr /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - public class ToolMoldMaintainRuleService : IToolMoldMaintainRuleService, IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class ToolMoldMaintainRuleService : IOverideVisualDevService, IToolMoldMaintainRuleService, IDynamicApiController, ITransient { + + private const string ModuleId = "26164864904981"; private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private readonly IDictionaryDataService _dictionaryDataService; - - public ToolMoldMaintainRuleService(ISqlSugarRepository repository, IUserManager userManager, IDictionaryDataService dictionaryDataService) + private readonly TimeTaskService _timeTaskService; + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public ToolMoldMaintainRuleService(ISqlSugarRepository repository, IUserManager userManager, IDictionaryDataService dictionaryDataService, TimeTaskService timeTaskService, IVisualDevService visualDevService, IRunService runService) { _db = repository.AsSugarClient(); _userManager = userManager; _dictionaryDataService = dictionaryDataService; + _timeTaskService = timeTaskService; + _visualDevService = visualDevService; + _runService = runService; + OverideFuncs.DeleteAsync = Delete; + OverideFuncs.CreateAsync = Create; + } + private async Task Create(VisualDevModelDataCrInput input) + { + int cycle = int.Parse(input.data["cycle"].ToString()!); + var startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(long.Parse(input.data["startandend_date"].ToString()!)); + ToolMoldMaintainRule toolMoldMaintainRule = new ToolMoldMaintainRule(); + toolMoldMaintainRule.id = SnowflakeIdHelper.NextId(); + toolMoldMaintainRule.mode = input.data["mode"].ToString(); + toolMoldMaintainRule.cycle = cycle; + toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss"); + await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync(); + if (toolMoldMaintainRule.mode == "27118635748885") + { + string id = toolMoldMaintainRule.id; + var comtentModel = new ContentModel(); + comtentModel.cron = "0 0 9 "+ startTime.Day + "/"+ toolMoldMaintainRule.cycle + " * ?"; + comtentModel.interfaceId = ""; + comtentModel.interfaceName = ""; + comtentModel.parameter = new List(); + comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" }); + comtentModel.localHostTaskId = "MoldMaintainTask/CreateTask"; + comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + comtentModel.TenantId = _userManager?.TenantId!; + comtentModel.TenantDbName = _userManager?.TenantDbName!; + comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!; + comtentModel.Token = _userManager?.ToKen!; + TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput() + { + enCode = DateTime.Now.ToString("yyyyMMddHHmmss"), + fullName = "生成模具保养任务" + id, + executeType = "3", + executeContent = comtentModel.ToJsonString(), + description = "", + sortCode = 99, + enabledMark = 1, + }; + await _timeTaskService.DeleteByName(timeTaskCrInput.fullName); + await _timeTaskService.Create(timeTaskCrInput, false); + } + return await Task.FromResult(true); + } + private async Task Delete(string id) + { + var ToolMoldMaintainRule = await _db.Queryable().Where(p => p.id == id).FirstAsync(); + var ToolMoldMaintainRuleRelations = await _db.Queryable().Where(p => p.rule_id == id).ToListAsync(); + await _timeTaskService.DeleteByName("生成模具保养任务" + id); + await _db.Ado.BeginTranAsync(); + await _db.Deleteable(ToolMoldMaintainRule).ExecuteCommandAsync(); + await _db.Deleteable(ToolMoldMaintainRuleRelations).ExecuteCommandAsync(); + await _db.Ado.CommitTranAsync(); } /// /// 根据规则Id获取匹配的模具列表 diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index f9b3691d..72038c0d 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -135,6 +135,10 @@ namespace Tnb.EquipMgr item_name = e.name, }) .ToListAsync(); + //新增功能 + var ToolMoldMaintainPlanRelation= _db.Queryable().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id&& !string.IsNullOrEmpty(a.group_id)).First(); + if (ToolMoldMaintainPlanRelation != null) + items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList(); var checkItems = await _db.Queryable().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new { plan_id = it.plan_id, @@ -183,7 +187,7 @@ namespace Tnb.EquipMgr var isOk = await _db.Updateable(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync(); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); var plan = await _db.Queryable().LeftJoin((a, b) => a.maintain_plan_id == b.id) - .Where(a => a.mold_id == input.mold_id).Select((a, b) => b).FirstAsync(); + .Where(a => a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).Select((a, b) => b).FirstAsync(); if (plan is not null) { @@ -200,6 +204,10 @@ namespace Tnb.EquipMgr var row = await _db.Insertable(record).ExecuteCommandAsync(); if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + + var groupids = _db.Queryable().Where(a => !string.IsNullOrEmpty(a.group_id) && a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).ToList().Select(p => p.group_id); + + /* var maintainInfos = await _db.Queryable() .LeftJoin((a, b) => a.item_group_id == b.id) .LeftJoin((a, b, c) => b.id == c.item_group_id) @@ -213,12 +221,27 @@ namespace Tnb.EquipMgr check_item_name = d.name }) .ToListAsync(); + */ + var maintainInfos = await _db.Queryable() + .LeftJoin((a, b) => a.item_group_id == b.id) + .LeftJoin((a, b, c) => b.id == c.item_group_id) + .LeftJoin((a, b, c, d) => c.item_id == d.id) + .WhereIF(groupids.Count() > 0, (a) => groupids.Contains(a.item_group_id)) + .Where(a => a.mold_id == input.mold_id) + .Select((a, b, c, d) => new + { + group_id = b.id, + group_name = b.name, + check_item_id = d.id, + check_item_name = d.name + }).ToListAsync(); if (maintainInfos?.Count > 0) { List recordDs = new(); foreach (var info in maintainInfos) { ToolMoldMaintainRunRecordD record_d = new(); + record_d.mainid = record.id; record_d.group_id = info.group_id; record_d.group_name = info.group_name; record_d.check_item_id = info.check_item_id; @@ -253,6 +276,7 @@ namespace Tnb.EquipMgr record.mold_id = input.mold_id; record.item_group_id = item.item_group_id; record.item_id = item.item_id; + record.status = 1; records.Add(record); } var row = await _db.Insertable(records).ExecuteCommandAsync(); @@ -283,6 +307,11 @@ namespace Tnb.EquipMgr item_name = e.name, }) .ToListAsync(); + //新增功能 + var ToolMoldMaintainPlanRelation = _db.Queryable().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id && !string.IsNullOrEmpty(a.group_id)).First(); + if (ToolMoldMaintainPlanRelation != null) + items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList(); + var checkItems = await _db.Queryable().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new { plan_id = it.plan_id, diff --git a/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs new file mode 100644 index 00000000..6bcbd9ff --- /dev/null +++ b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF; +using JNPF.Common.Security; +using JNPF.Systems.Entitys.System; +using JNPF.TaskScheduler; +using JNPF.TaskScheduler.Entitys.Model; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.QcMgr.Entities; +using Tnb.QcMgr.Entities.Entity; + +namespace Tnb.TaskScheduler.Listener +{ + internal class MoldMaintainTask : ISpareTimeWorker + { + private ISqlSugarRepository repository => 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(); + if (timeTaskEntity == null) + return; + ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject(); + var ToolMoldMaintainRule = await repository.AsSugarClient().Queryable().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync(); + if (ToolMoldMaintainRule == null) + return; + var ToolMoldMaintainRuleRelations= await repository.AsSugarClient().Queryable().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync(); + if (ToolMoldMaintainRuleRelations.Count() > 0) + { + var now = DateTime.Now; + Random rNum = new Random(); + ToolMoldMaintainPlan toolMoldMaintainPlan=new ToolMoldMaintainPlan(); + toolMoldMaintainPlan.id = SnowflakeIdHelper.NextId(); + toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString(); + toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode; + toolMoldMaintainPlan.status = "UnMaintain"; + toolMoldMaintainPlan.plan_start_date = now; + toolMoldMaintainPlan.plan_end_date = now.AddDays((double)ToolMoldMaintainRule.cycle!); + List toolMoldMaintainPlanRelations = new List(); + foreach (var ToolMoldMaintainRuleRelation in ToolMoldMaintainRuleRelations) + { + ToolMoldMaintainPlanRelation toolMoldMaintainPlanRelation = new ToolMoldMaintainPlanRelation(); + toolMoldMaintainPlanRelation.id= SnowflakeIdHelper.NextId(); + toolMoldMaintainPlanRelation.maintain_plan_id = toolMoldMaintainPlan.id; + toolMoldMaintainPlanRelation.mold_id = ToolMoldMaintainRuleRelation.mold_id; + toolMoldMaintainPlanRelation.group_id = ToolMoldMaintainRuleRelation.item_group_id; + toolMoldMaintainPlanRelations.Add(toolMoldMaintainPlanRelation); + } + await repository.AsSugarClient().Insertable(toolMoldMaintainPlanRelations).ExecuteCommandAsync(); + await repository.AsSugarClient().Insertable(toolMoldMaintainPlan).ExecuteCommandAsync(); + } + } + catch (Exception) + { + } + + } + } +} From d0af0552a36ba502385c0c04b15e6963595f0029 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 5 Sep 2023 16:36:57 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=8E=92=E4=BA=A7=E8=87=B3=E5=B7=A5?= =?UTF-8?q?=E4=BD=8D=20pc=E7=AB=AF=E6=B3=A8=E5=A1=91=E6=8C=A4=E5=87=BA?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86=20=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E4=BD=8D=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IBasQrcodeService.cs | 23 +++++ BasicData/Tnb.BasicData/BasQrcodeService.cs | 84 +++++++++++++++++++ BasicData/Tnb.BasicData/Tnb.BasicData.csproj | 1 + .../Dto/PrdManage/PrdPackReportQueryInput.cs | 4 + .../Tnb.ProductionMgr/PrdMoTaskService.cs | 17 ++++ .../Tnb.ProductionMgr/PrdPackReportService.cs | 18 ++-- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 8 ++ 7 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs create mode 100644 BasicData/Tnb.BasicData/BasQrcodeService.cs diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs new file mode 100644 index 00000000..d47f3649 --- /dev/null +++ b/BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs @@ -0,0 +1,23 @@ +namespace Tnb.BasicData.Interfaces +{ + + /// + /// 二维码 + /// + public interface IBasQrcodeService + { + /// + /// 根据code获取qrcode + /// + /// + /// + public Task GetQrcodeByCode(Dictionary dic); + + /// + /// 根据code获取工位信息 + /// + /// + /// + public Task GetWorkStationByCode(Dictionary dic); + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/BasQrcodeService.cs b/BasicData/Tnb.BasicData/BasQrcodeService.cs new file mode 100644 index 00000000..0c51d040 --- /dev/null +++ b/BasicData/Tnb.BasicData/BasQrcodeService.cs @@ -0,0 +1,84 @@ +using JNPF.Common.Core.Manager; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Interfaces.System; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData.Entities.Dto; +using Tnb.BasicData.Entitys.Dto.BasProcess; +using Tnb.BasicData.Interfaces; +using Tnb.EquipMgr.Entities; + +namespace Tnb.BasicData +{ + /// + /// 二维码 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)] + [Route("api/[area]/[controller]/[action]")] + public class BasQrcodeService : IBasQrcodeService,IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly DataBaseManager _dbManager; + private readonly IDictionaryDataService _dictionaryDataService; + + public BasQrcodeService( + ISqlSugarRepository repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService) + { + _repository = repository; + _dbManager = dbManager; + _dictionaryDataService = dictionaryDataService; + } + + [HttpPost] + public async Task GetQrcodeByCode(Dictionary dic) + { + string code = dic.ContainsKey("code") ? dic["code"] : ""; + if (string.IsNullOrEmpty(code)) return null; + var result = await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.source_id == b.Id) + .LeftJoin((a, b, c) => a.source_id == c.id) + .LeftJoin((a, b, c, d) => a.source_id == d.id) + .Where((a, b, c, d) => a.code == code) + .Select((a, b, c, d) => new + { + id = a.id, + source_id = a.source_id, + source_name = a.source_name, + org_code = b.EnCode, + org_name = b.FullName, + equip_code = a.code, + equip_name = c.name, + tool_location_code = d.location_code, + }).FirstAsync(); + return result; + } + + [HttpPost] + public async Task GetWorkStationByCode(Dictionary dic) + { + string code = dic.ContainsKey("code") ? dic["code"] : ""; + if (string.IsNullOrEmpty(code)) return null; + var result = await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.source_id == b.Id) + .LeftJoin((a,b,c)=>a.source_id==c.ObjectId && c.ObjectType=="Eqp") + .LeftJoin((a,b,c,d)=>c.OrganizeId==d.Id) + .Where((a, b, c) => a.code == code) + .Select((a, b, c,d) => new + { + id = a.id, + source_id = a.source_id, + source_name = a.source_name, + org_id = b.Id, + org_code = b.EnCode, + org_name = b.FullName, + org_id2 = d.Id, + org_code2 = d.EnCode, + org_name2 = d.FullName, + }).FirstAsync(); + return result; + } + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj index 5ce642a8..b53e3d81 100644 --- a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj +++ b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj @@ -9,6 +9,7 @@ + diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs index 99c5bcb4..736f3fe4 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs @@ -31,5 +31,9 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 工序 /// public string process { get; set; } + /// + /// 工位id + /// + public string stationId { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 0158bfca..dca6214a 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -678,6 +678,13 @@ namespace Tnb.ProductionMgr moTask.scheduled_qty = input.scheduled_qty; moTask.unit_id = mo.unit_id; + if (!string.IsNullOrEmpty(input.eqp_id)) + { + OrganizeRelationEntity organizeRelationEntity = await db.Queryable() + .Where(x => x.ObjectId == input.eqp_id && x.ObjectType == "Eqp").FirstAsync(); + moTask.workstation_id = organizeRelationEntity?.OrganizeId ?? ""; + } + var moCode = mo?.mo_code; var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE); moTask.mo_task_code = taskCode; @@ -944,10 +951,19 @@ namespace Tnb.ProductionMgr .ToListAsync(); if (subTaskList?.Count > 0) { + List workstationIds = await _db.Queryable().Where(x => + x.Category == DictConst.RegionCategoryStationCode && + x.OrganizeIdTree.Contains(input.workline_id)).Select(x=>x.Id).ToListAsync(); + + List subMoTasks = new(); List subMoTaskLogs = new(); foreach (var item in subTaskList) { + BasMbomProcess basMbomProcess = await _db.Queryable().SingleAsync(x=>x.id==item.mbom_process_id); + List mbomProcessStationIds = JsonConvert.DeserializeObject(basMbomProcess.station).Select(x=>x[x.Length-1]).ToList(); + List? resultList = workstationIds.Intersect(mbomProcessStationIds).ToList(); + PrdMoTask subMoTask = new(); subMoTask.mo_id = input.mo_id; subMoTask.material_id = item.material_id; @@ -956,6 +972,7 @@ namespace Tnb.ProductionMgr subMoTask.bom_id = input.bom_id; subMoTask.process_id = item.process_id; subMoTask.mbom_process_id = item.mbom_process_id; + subMoTask.workstation_id = resultList?.FirstOrDefault() ?? ""; subMoTask.mo_task_status = DictConst.ToBeScheduledEncode; subMoTask.workroute_id = item.route_id; subMoTask.workline_id = input.workline_id; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 62cf4e1d..91ccecbf 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -49,6 +49,8 @@ namespace Tnb.ProductionMgr public async Task GetList(PrdPackReportQueryInput input) { if (input == null) throw new ArgumentNullException("input"); + if (string.IsNullOrEmpty(input.stationId)) return Array.Empty(); + List trees = new(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync(); @@ -75,13 +77,17 @@ namespace Tnb.ProductionMgr endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]); } - var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id) + var items = await _db.Queryable() + .LeftJoin((a, b) => a.process_id == b.id) + .LeftJoin((a, b, c) => a.mo_id == c.id) + .LeftJoin((a,b,c,d)=>a.id==d.parent_id) .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim()) // .WhereIF(start, a => a.estimated_start_date != null&& startTimes[0] <= a.estimated_start_date && startTimes[1] >= a.estimated_start_date) // .WhereIF(end, a => a.estimated_end_date != null && endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date) .WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!)) .Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled") - .OrderByDescending(a=>a.create_time) + .Where((a,b,c,d)=>d.workstation_id==input.stationId) + .OrderByDescending(a=>a.create_time) .Select((a, b, c) => new PrdMoTask { id = a.id, @@ -122,7 +128,7 @@ namespace Tnb.ProductionMgr } node.plan_start_date = item.plan_start_date.HasValue ? item.plan_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; node.plan_end_date = item.plan_end_date.HasValue ? item.plan_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; - await GetChild(item.id, trees, dic); + await GetChild(item.id, trees, dic,input.stationId); trees.Add(node); } } @@ -170,13 +176,13 @@ namespace Tnb.ProductionMgr return dt; } - private async Task GetChild(string parentId, List nodes, Dictionary dic) + private async Task GetChild(string parentId, List nodes, Dictionary dic,string stationId) { var items = await _db.Queryable() .LeftJoin((a, b) => a.process_id == b.id) .LeftJoin((a, b, c) => a.mo_id == c.id) .LeftJoin((a, b, c, d) => a.mbom_process_id == d.id) - .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled") + .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled" && a.workstation_id==stationId) .OrderBy((a, b, c, d) => d.ordinal) .Select((a, b, c) => new PrdMoTask { @@ -222,7 +228,7 @@ namespace Tnb.ProductionMgr nodes.AddRange(nsChild); foreach (var item in items) { - await GetChild(item.id, nodes, dic); + await GetChild(item.id, nodes, dic,stationId); } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index d3903b74..341427ce 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -119,6 +119,13 @@ namespace Tnb.ProductionMgr var db = _repository.AsSugarClient(); Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string stationId = queryJson!=null && queryJson.ContainsKey("stationId") ? queryJson["stationId"].ToString() : ""; + + if (string.IsNullOrEmpty(stationId)) + { + return Array.Empty(); + } + Dictionary dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus); DateTime[] planStartDateArr = null; @@ -142,6 +149,7 @@ namespace Tnb.ProductionMgr .WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode)) .WhereIF(planStartDateArr!=null, (a, b, c, d) => a.estimated_start_date>=planStartDateArr[0] && a.estimated_start_date<=planStartDateArr[1]) .WhereIF(planEndDateArr!=null, (a, b, c, d) => a.estimated_end_date>=planEndDateArr[0] && a.estimated_end_date<=planEndDateArr[1]) + .Where((a,b,c,d)=>a.workstation_id==stationId) .OrderByDescending((a, b, c, d) => a.create_time) .Select((a, b, c, d) => new PrdTaskManageListOutput() { From a6fdf646819b075b9fc08eaa48696f10ba562b98 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 5 Sep 2023 17:40:35 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=EF=BC=8C=E7=BB=88=E6=AD=A2=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsOutstockH.cs | 13 ++++- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 47 +++++++++++++++++-- .../Tnb.WarehouseMgr/WmsPDAInStockService.cs | 1 + .../Entity/Permission/OrganizeEntity.cs | 2 +- .../Entity/Permission/OrganizeEntity.part.cs | 14 ++++++ 5 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.part.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutstockH.cs index bea1851e..6416d598 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutstockH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutstockH.cs @@ -158,5 +158,16 @@ public partial class WmsOutstockH : BaseEntity /// 修改时间 /// public DateTime modify_time { get; set; } = DateTime.Now; - + /// + /// 工位Id + /// + public string station_id { get; set; } + /// + /// 工位编码 + /// + public string station_code { get; set; } + /// + /// 载具Id + /// + public string carry_id { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index d5fcf14a..63423169 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using Aop.Api.Domain; @@ -10,12 +11,14 @@ using JNPF.Common.Dtos.VisualDev; 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; using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; using SqlSugar; using SqlSugar.DbConvert; using Tnb.BasicData.Entities; @@ -101,10 +104,15 @@ namespace Tnb.WarehouseMgr code_batch = os.code_batch, }; var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput); - var carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) - .Where((a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id)) - .Select() - .ToListAsync(); + Expression> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id)) + ? (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) + .Where(whereExp) + .Select() + .ToListAsync(); ; + if (carryCodesPart?.Count > 0) { var codeQty = carryCodesPart.Sum(x => x.codeqty); @@ -199,6 +207,37 @@ namespace Tnb.WarehouseMgr { ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); } + else if (input.data.ContainsKey(nameof(WmsOutstockH.station_id))) + { + //多个投料库位 + /* + * 潍柴 + * 1、那个库位状态是空的出那个 + * 1.1、没有空位直接抛异常 + * + * 天益 + * 2、不管库位是否为空, 获取到所有库位 A B + * 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9 + * 2.2 哪个最少给哪个 + */ + var org = await _db.Queryable().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString()); + if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false) + { + var fLocIds = JArray.Parse(org.FeedingLocationId).Values(); + var minTaskNumLoc = await _db.Queryable().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id)) + .GroupBy(it => it.endlocation_id) + .Select(it => new + { + it.endlocation_id, + count = SqlFunc.AggregateCount(it.endlocation_id) + }) + .MergeTable() + .OrderBy(it => it.count) + .FirstAsync(); + ePoint = await _db.Queryable().FirstAsync(it => it.location_id == minTaskNumLoc.endlocation_id); + } + } + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index 178daf7c..776bd53b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -83,6 +83,7 @@ namespace Tnb.WarehouseMgr if (input.data.ContainsKey("tablefield115")) { jArr = JArray.Parse(input.data["tablefield115"].ToString()!); + } //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; diff --git a/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.cs b/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.cs index 2506c3c4..774b8a81 100644 --- a/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.cs +++ b/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.cs @@ -10,7 +10,7 @@ namespace JNPF.Systems.Entitys.Permission; /// 日 期:2017.09.20. /// [SugarTable("BASE_ORGANIZE")] -public class OrganizeEntity : CLDEntityBase +public partial class OrganizeEntity : CLDEntityBase { /// /// 机构上级. diff --git a/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.part.cs b/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.part.cs new file mode 100644 index 00000000..6602eeae --- /dev/null +++ b/system/Tnb.Systems.Entitys/Entity/Permission/OrganizeEntity.part.cs @@ -0,0 +1,14 @@ +using JNPF.Common.Contracts; +using SqlSugar; + +namespace JNPF.Systems.Entitys.Permission; + +public partial class OrganizeEntity +{ + /// + /// + /// + [SugarColumn(ColumnName = "F_FEEDING_LOCATIONID")] + public string FeedingLocationId { get; set; } + +} \ No newline at end of file From b5feba2109e27f790f16cb4e6fa86ee229c04aa1 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 5 Sep 2023 17:40:39 +0800 Subject: [PATCH 8/9] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 63423169..ba6e9562 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -111,7 +111,7 @@ namespace Tnb.WarehouseMgr List? carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) .Where(whereExp) .Select() - .ToListAsync(); ; + .ToListAsync(); if (carryCodesPart?.Count > 0) { From 6bf8f27658595646a52bfc7fbdcb0af97b37fc79 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 5 Sep 2023 17:43:33 +0800 Subject: [PATCH 9/9] bug --- ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs | 9 ++++++++- ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 91ccecbf..81854de2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -49,7 +49,14 @@ namespace Tnb.ProductionMgr public async Task GetList(PrdPackReportQueryInput input) { if (input == null) throw new ArgumentNullException("input"); - if (string.IsNullOrEmpty(input.stationId)) return Array.Empty(); + if (string.IsNullOrEmpty(input.stationId)) + { + return new + { + pagination = new PageResult(), + list = Array.Empty() + }; + } List trees = new(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 341427ce..62eee87e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -123,7 +123,11 @@ namespace Tnb.ProductionMgr if (string.IsNullOrEmpty(stationId)) { - return Array.Empty(); + return new + { + pagination = new PageResult(), + list = Array.Empty() + }; } Dictionary dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);