diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonCascaderOptionsOuput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonCascaderOptionsOuput.cs new file mode 100644 index 00000000..861d6a70 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonCascaderOptionsOuput.cs @@ -0,0 +1,10 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class AndonCascaderOptionsOuput + { + public string label { get; set; } + public string value { get; set; } + public bool disabled { get; set; } = false; + public List children { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs index 31e453dc..c7b815cc 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs @@ -11,5 +11,11 @@ namespace Tnb.ProductionMgr.Interfaces { Task GetPrdTask(string stationId); Task SaveData(AndonRecordInput AndonRecordInput); + + /// + /// 获取andon级联选择项数据 + /// + /// + Task GetAndonCascaderOptions(); } } diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs index 37acd24f..38cbd25a 100644 --- a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs @@ -24,6 +24,7 @@ using Tnb.ProductionMgr.Interfaces; using Tnb.BasicData.Entities; using JNPF.Systems.Entitys.System; using JNPF.Message.Entitys.Entity; +using Tnb.BasicData.Interfaces; using MessageTemplateEntity = JNPF.Message.Entitys.Entity.MessageTemplateEntity; namespace Tnb.ProductionMgr @@ -35,16 +36,19 @@ namespace Tnb.ProductionMgr private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private SendMessageService _sendMessageService; + private readonly IBasPushRuleLogService _basPushRuleLogService; private readonly TimeTaskService _timeTaskService; public AndonRecordService(ISqlSugarRepository repository, SendMessageService sendMessageService, TimeTaskService timeTaskService, + IBasPushRuleLogService basPushRuleLogService, IUserManager userManager) { _userManager = userManager; _sendMessageService = sendMessageService; _timeTaskService = timeTaskService; + _basPushRuleLogService = basPushRuleLogService; _db = repository.AsSugarClient(); } @@ -119,6 +123,8 @@ namespace Tnb.ProductionMgr } } + await _db.Insertable(andonRecords).ExecuteCommandAsync(); + }); if (result.IsSuccess) @@ -206,6 +212,11 @@ namespace Tnb.ProductionMgr .SetColumns(x => x.repair_id == _userManager.UserId) .SetColumns(x=>x.response_time==DateTime.Now) .ExecuteCommandAsync(); + Dictionary postData = new Dictionary() + { + ["id"] = andonRecords.id + }; + await _basPushRuleLogService.Stop(postData); return true; } } @@ -224,6 +235,7 @@ namespace Tnb.ProductionMgr { await _db.Updateable() .SetColumns(x=>x.start_repair_time==DateTime.Now) + .Where(x=>x.id==id) .ExecuteCommandAsync(); return true; } @@ -242,6 +254,7 @@ namespace Tnb.ProductionMgr { await _db.Updateable() .SetColumns(x=>x.end_repair_time==DateTime.Now) + .Where(x=>x.id==id) .ExecuteCommandAsync(); return true; } @@ -260,6 +273,7 @@ namespace Tnb.ProductionMgr { await _db.Updateable() .SetColumns(x=>x.confirm_time==DateTime.Now) + .Where(x=>x.id==id) .ExecuteCommandAsync(); return true; } diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonService.cs index 24c38703..e8ca5a9e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/AndonService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/AndonService.cs @@ -16,6 +16,7 @@ using JNPF.Systems.Interfaces.System; using JNPF.TaskScheduler; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.EquipMgr.Interfaces; @@ -83,5 +84,44 @@ namespace Tnb.ProductionMgr andonRecord.create_id = _userManager.UserId; await _db.Insertable(andonRecord).ExecuteCommandAsync(); } + + [HttpPost] + public async Task GetAndonCascaderOptions() + { + Dictionary result = new Dictionary(); + List andonTypes = await _db.Queryable().ToListAsync(); + List andonInfos = await _db.Queryable().ToListAsync(); + List andonBreakDowns = await _db.Queryable().ToListAsync(); + List options = new List(); + foreach (var andonType in andonTypes) + { + options.Add(new AndonCascaderOptionsOuput() + { + label = andonType.name, + value = andonType.id, + children = andonInfos.Where(x=>x.andon_type==andonType.id).Select(x=>new AndonCascaderOptionsOuput() + { + label = x.name, + value = x.id, + children = andonBreakDowns.Where(y=>x.breakdown_id.Contains(y.id)).Select(y=>new AndonCascaderOptionsOuput() + { + label = y.name, + value = y.id + }).ToList() + }).ToList() + }); + } + + string defaultValue = ""; + if (!string.IsNullOrEmpty(andonInfos.FirstOrDefault()?.breakdown_id)) + { + string[] breakdownIdArr = JsonConvert.DeserializeObject(andonInfos.FirstOrDefault()?.breakdown_id); + defaultValue = breakdownIdArr[0]; + } + + result.Add("options",options); + result.Add("defaultValue",defaultValue); + return result; + } } }