diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs index 77744e16..e3f6a029 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs @@ -14,6 +14,7 @@ using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Logging; using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; @@ -40,6 +41,7 @@ namespace Tnb.ProductionMgr private readonly IToolMoldsService _moldService; private readonly IPrdMoTaskService _prdMoTaskService; private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; private static Dictionary _dicWorkStationAndShopRelacion = new Dictionary(); private static Dictionary _dicWorkShop = new Dictionary(); @@ -51,6 +53,7 @@ namespace Tnb.ProductionMgr IPrdMoTaskService prdMoTaskService, IToolMoldsService moldsService, IToolMoldMaintainTaskService maintainTaskService, + IBillRullService billRullService, IUserManager userManager ) { @@ -58,6 +61,7 @@ namespace Tnb.ProductionMgr _maintainTaskService = maintainTaskService; _moldService = moldsService; _userManager = userManager; + _billRullService = billRullService; _db = repository.AsSugarClient(); } /// @@ -226,6 +230,30 @@ namespace Tnb.ProductionMgr await _maintainTaskService.Create(maintaindTask); } + string reason = ""; + if (!string.IsNullOrEmpty(input.reason)) + { + List prdCancelClosedownReasons = await _db.Queryable().ToListAsync(); + string[] reasonArr = input.reason.Split(","); + var reasonList = prdCancelClosedownReasons.Where(x => reasonArr.Contains(x.id)).Select(x => x.reason).ToList(); + reason = string.Join(',', reasonList); + + } + string code = await _billRullService.GetBillNumber("EqpRepair"); + EqpRepairApply eqpRepairApply = new EqpRepairApply() + { + code = code, + name = eqp.name + "停机", + equip_id = input.eqp_id, + status = Tnb.EquipMgr.RepairApplyStatus.TOBEEXECUTED, + description = reason, + create_id = _userManager.UserId, + create_time = DateTime.Now, + remark = input.remark, + }; + + await _db.Insertable(eqpRepairApply).ExecuteCommandAsync(); + } else throw Oops.Oh(ErrorCode.COM1001); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 69c422d5..643340d9 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1318,6 +1318,9 @@ namespace Tnb.ProductionMgr } deductNum = deductNum - (detail.num - detail.use_num); + + if (deductNum <= 0) + break; } if (deductNum > 0) @@ -1329,9 +1332,9 @@ namespace Tnb.ProductionMgr { foreach (var detail in details) { - db.Updateable().SetColumns(x => x.use_num == x.num) + await db.Updateable().SetColumns(x => x.use_num == x.num) .SetColumns(x=>x.status=="2") - .Where(x => x.id == detail.id); + .Where(x => x.id == detail.id).ExecuteCommandAsync(); } } @@ -1341,6 +1344,10 @@ namespace Tnb.ProductionMgr } } + else + { + //throw new Exception("无投入物料"); + } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 8b47fbca..c884c791 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -147,6 +147,15 @@ namespace Tnb.ProductionMgr nsChild[i].process_id = $"{items[i].process_code}/{items[i].process_name}"; nsChild[i].plan_start_date = items[i].estimated_start_date.HasValue ? items[i].estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; nsChild[i].plan_end_date = items[i].estimated_end_date.HasValue ? items[i].estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; + + if (nsChild[i].workline_id.IsNotEmptyOrNull()) + { + var workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? (Tuple)_dicWorkLine[nsChild[i].workline_id] : null; + if (workLine != null) + { + nsChild[i].workline_id = $"{workLine.Item1}/{workLine.Item2}"; + } + } } nodes.AddRange(nsChild);