From 818e2592059368e2fc114315ecb906310b16cd78 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 20 Jul 2023 14:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83wms=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=88=90=E5=8A=9F=E5=90=8E=E5=86=8D=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/PerProcessStandardsH.cs | 5 ++ .../Dto/PrdManage/ReportRecordListOutput.cs | 2 + .../IPrdFeedingService.cs | 6 ++ .../Tnb.ProductionMgr/PrdFeedingService.cs | 79 +++++++++++++++++-- .../Tnb.ProductionMgr/PrdInstockService.cs | 64 +++++++++++---- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 37 +++++++++ .../Tnb.ProductionMgr/PrdOutstockService.cs | 10 ++- .../ProductionReportRecordService.cs | 3 +- 8 files changed, 177 insertions(+), 29 deletions(-) diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs index feee5438..2c3cf474 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs +++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs @@ -103,5 +103,10 @@ public partial class PerProcessStandardsH : BaseEntity /// 流程引擎Id /// public string? f_flowid { get; set; } + + /// + /// 成型周期 + /// + public decimal? moulding_cycle { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs index d337b189..b060203a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs @@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto public string? create_id { get; set; } = string.Empty; public string? create_id_id { get; set; } = string.Empty; public string? create_time { get; set; } = string.Empty; + + public string? batch { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs index c719944a..17e095c4 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs @@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task SaveDataNew(MaterialReceiptNewInput input); + + /// + /// 投料记录 + /// + /// + public Task GetFeedingRecordTree(); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 2a0d6aec..32bc5917 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -4,10 +4,13 @@ using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev.Entitys; using Microsoft.AspNetCore.Mvc; using Microsoft.ClearScript.Util.Web; using Newtonsoft.Json; @@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr public async Task SaveDataNew(MaterialReceiptNewInput input) { var db = _repository.AsSugarClient(); + PrdFeedingH prdFeedingH = null; + List list = new List(); + DbResult result2 = new DbResult(); DbResult result = await db.Ado.UseTranAsync(async () => { var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id); @@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr .ToListAsync(); - string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); - PrdFeedingH prdFeedingH = new PrdFeedingH() + prdFeedingH = new PrdFeedingH() { code = code, station_id = input.station_id, @@ -195,8 +200,7 @@ namespace Tnb.ProductionMgr create_time = DateTime.Now, org_id = _userManager.GetUserInfo().Result.organizeId }; - - List list = new List(); + if (input.details != null && input.details.Count > 0) { foreach (var item in input.details) @@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr } - await db.Insertable(prdFeedingH).ExecuteCommandAsync(); - await db.Insertable(list).ExecuteCommandAsync(); + // await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + // await db.Insertable(list).ExecuteCommandAsync(); }); @@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + else + { + result2 = await db.Ado.UseTranAsync(async () => + { + await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + await db.Insertable(list).ExecuteCommandAsync(); + }); + + } } - if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); - return result.IsSuccess ? "签收成功" : result.ErrorMessage; + if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage); + return result2.IsSuccess ? "签收成功" : result2.ErrorMessage; + } + + [HttpPost] + public async Task GetFeedingRecordTree() + { + var db = _repository.AsSugarClient(); + var result = await db.Queryable() + .Where(a => a.schedule_type == 2 && a.parent_id!=null) + .Select(a => new FeedingRecordTreeOutput() + { + mo_task_code = a.mo_task_code, + children = SqlFunc.Subqueryable().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren() + { + id = b.id, + code = b.code, + // children = SqlFunc.Subqueryable().LeftJoin((c,d)=>c.material_id==d.id) + // .Where((c,d)=>SqlFunc.IIF(b==null,"0",b.id)==c.feeding_id).ToList((c,d)=>new FeedingRecordMaterialChildren() + // { + // // material_code = d.code, + // // material_name = d.name, + // }) + // children = new List(), + // children = b!=null ? SqlFunc.Subqueryable() + // .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren() + // { + // // material_code = d.code, + // // material_name = d.name, + // }) : new List() + }) + }).Mapper(x => + { + foreach (var item in x.children) + { + item.children = db.Queryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => item.id == c.feeding_id).Select((c,d) => new FeedingRecordMaterialChildren() + { + material_code = d.code, + material_name = d.name, + }).ToList(); + } + }) + .ToListAsync(); + return result; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 4f2ededd..c56832e0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.RemoteRequest; using JNPF.Systems.Interfaces.System; using Mapster; @@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr var db = _repository.AsSugarClient(); var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code); PrdInstockH prdInstockH = null; + List prdInstockDs = new List() { }; + DbResult result2 = new DbResult(); DbResult result = await db.Ado.UseTranAsync(async () => { prdInstockH = new PrdInstockH() @@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr status = 0, }; - List prdInstockDs = new List() { }; foreach (var item in input.details) { prdInstockDs.Add(new PrdInstockD() @@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr }); } - await _repository.InsertAsync(prdInstockH); - - if (prdInstockDs.Count > 0) - { - await db.Insertable(prdInstockDs).ExecuteCommandAsync(); - } + // await _repository.InsertAsync(prdInstockH); + // + // if (prdInstockDs.Count > 0) + // { + // await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + // } }); @@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); - Console.WriteLine(sendResult); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + else + { + result2 = await db.Ado.UseTranAsync(async () => + { + await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + }); + + } } - if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); - return result.IsSuccess ? "保存成功" : result.ErrorMessage; + if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result2.IsSuccess ? "保存成功" : result2.ErrorMessage; } /// @@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr public async Task SyncInstock(Dictionary dic) { string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : ""; - if (!string.IsNullOrEmpty(sourceId)) + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => { - return await _repository.UpdateAsync(x => new PrdInstockH() + if (!string.IsNullOrEmpty(sourceId)) { - status = 1 - }, x => x.id == sourceId); - } + await _repository.UpdateAsync(x => new PrdInstockH() + { + status = 1 + }, x => x.id == sourceId); + var details = await db.Queryable().Where(x => x.instock_id == sourceId).ToListAsync(); - return false; + foreach (var item in details) + { + await db.Updateable().SetColumns(x => x.status == 1) + .Where(x => x.id == item.report_id).ExecuteCommandAsync(); + } + } + }); + + return result.IsSuccess; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b73e6164..45287ded 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web; using Newtonsoft.Json; using Tnb.BasicData.Entities.Dto; using NPOI.SS.Formula.Functions; +using Tnb.PerMgr.Entities; + +// using Tnb.PerMgr.Entities; namespace Tnb.ProductionMgr { @@ -1711,5 +1714,39 @@ namespace Tnb.ProductionMgr { return await _db.Queryable().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync(); } + + [HttpPost] + public async Task GetEstimatedEndTime(CountEstimatedEndTimeInput input) + { + var db = _repository.AsSugarClient(); + if (input.type == 1) + { + PerProcessStandardsH processStandardsH = await db.Queryable() + .Where(x => x.equip_id == input.equip_id && x.molds_id == input.molds_id && + x.output_material_id == input.material_id && x.enabled == 1) + .OrderByDescending(x => x.create_time).FirstAsync(); + + ToolMolds toolMolds = await db.Queryable().SingleAsync(x => x.id == input.molds_id); + if(toolMolds==null) throw Oops.Bah("没找到模具"); + if(toolMolds?.mold_cavity<=0) throw Oops.Bah("模穴数错误"); + if (processStandardsH == null) throw Oops.Bah("工艺标准成型周期错误"); + if (processStandardsH?.moulding_cycle <= 0) throw Oops.Bah("工艺标准成型周期错误"); + + decimal? addTime = (input.scheduled_qty * toolMolds.mold_cavity - 1) / processStandardsH?.moulding_cycle + 1; + return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss"); + } + else + { + var list = await db.Queryable() + .LeftJoin((a,b)=>a.process_id==b.process_id) + .Where((a,b)=>a.mbom_id==input.mbom_id).Select((a,b)=>b).ToListAsync(); + + decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x); + decimal? addTime = input.scheduled_qty * max; + return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss"); + } + + } + } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index 87cd0810..91be4166 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -56,9 +56,6 @@ namespace Tnb.ProductionMgr try { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - await _runService.Create(templateEntity, visualDevModelDataCrInput); - MESCreateOutstockInput input = new MESCreateOutstockInput(); input.outstock = new MESWmsOutstockHInput(); @@ -100,7 +97,12 @@ namespace Tnb.ProductionMgr if (authResponse.code != 200) { throw Oops.Bah(authResponse.msg); - } + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + } return await Task.FromResult(true); } catch (Exception e) diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs index 78493934..40f896d0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr reported_qty = x.reported_qty, create_id = y.RealName, create_id_id = x.create_id, - create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm") + create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm"), + batch = x.batch }) }).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result);