From 24d83630966c27338960397fe1813a20d7adcc34 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 23 Nov 2023 09:58:41 +0800 Subject: [PATCH] 1 --- .../Tnb.EquipMgr.Entities/Entity/EqpDaq.cs | 5 + .../Dto/PrdManage/PrdReportCrInput.cs | 9 +- .../Entity/PrdReport.cs | 2 +- .../IPrdInstockService.cs | 10 +- .../Tnb.ProductionMgr/PrdInstockService.cs | 160 +++++++++++++++++- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 8 +- 6 files changed, 185 insertions(+), 9 deletions(-) diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs index 638794b3..172fe79d 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs @@ -88,5 +88,10 @@ public partial class EqpDaq : BaseEntity /// 流程引擎Id /// public string? f_flowid { get; set; } + + /// + /// 库位号 + /// + public string? location_code { get; set; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs index f1e0e6e0..61778c15 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs @@ -99,9 +99,14 @@ public string? station { get; set; } /// - /// 料箱二维码 + /// 料箱编码 /// - public string material_box_qrcode { get; set; } + public string material_box_code { get; set; } + + /// + /// 入库库位 + /// + public string location_code { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index a24b070f..70c6719b 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -131,7 +131,7 @@ public partial class PrdReport : BaseEntity public string material_box_code { get; set; } /// - /// 长管挤出入库库位 + /// 入库库位 /// public string location_code { get; set; } diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs index 3ee25438..da2405dd 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs @@ -30,12 +30,20 @@ namespace Tnb.ProductionMgr.Interfaces /// public Task InstockTypeOne(InstockInput input); + // /// + // /// 短管挤出入库申请 + // /// + // /// + // /// + // public Task InstockTubeOne(PrdReport prdReport); + + /// /// 短管挤出入库申请 /// /// /// - public Task InstockTubeOne(PrdReport prdReport); + public Task InstockTubeOne(InstockInput input); /// /// 长管管挤出入库申请 diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index dcd9a6e6..84d3d343 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -422,16 +422,172 @@ namespace Tnb.ProductionMgr return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "申请成功" : result2.ErrorMessage); } + // [HttpPost] + // public async Task InstockTubeOne(PrdReport prdReport) + // { + // ISqlSugarClient db = _repository.AsSugarClient(); + // string location_code = "ZCR01";//todo 短管挤出件目标库位之后改 + // string warehouse_id = "2"; + // + // PrdInstockH? prdInstockH = null; + // List prdInstockDs = new() { }; + // DbResult result2 = new(); + // BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdReport.material_id); + // string create_id = prdReport.create_id; + // UserEntity user = await db.Queryable().SingleAsync(x => x.Id == create_id); + // string org_id = user.OrganizeId; + // DbResult result = await db.Ado.UseTranAsync(async () => + // { + // OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); + // OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode); + // + // prdInstockH = new PrdInstockH() + // { + // bill_type = DictConst.CHANCHENGPINRUKUDAN, + // bill_date = DateTime.Now, + // create_id = create_id, + // location_code = location_code, + // carry_code = prdReport.material_box_code, + // is_check = 1, + // station_id = prdReport.station, + // workline_id = workline?.Id ?? "", + // workshop_id = workshop?.Id ?? "", + // org_id = org_id, + // warehouse_id = warehouse_id, + // status = 0, + // }; + // + // prdInstockDs.Add(new PrdInstockD() + // { + // instock_id = prdInstockH.id, + // report_id = prdReport.create_id, + // material_id = prdReport.material_id, + // material_code = basMaterial.code, + // unit_id = prdReport.unit_id, + // barcode = prdReport.barcode, + // code_batch = prdReport.mo_task_code, + // quantity = (int)prdReport.reported_qty, + // }); + // }); + // + // if (result.IsSuccess) + // { + // MESCreateInstockInput mesCreateInstockInput = new() + // { + // instock = new MESWmsInstockHInput() + // { + // org_id = org_id, + // bill_date = DateTime.Now, + // bill_type = DictConst.CHANCHENGPINRUKUDAN, + // warehouse_id = warehouse_id, + // source_id = prdInstockH.id, + // create_id = create_id, + // carry_code = prdReport.material_box_code, + // location_code = location_code, + // is_check = 1, + // }, + // instockds = new List(), + // instockcodes = new List() + // }; + // mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput() + // { + // material_id = prdReport.material_id, + // material_code = basMaterial.code, + // unit_id = prdReport.unit_id, + // code_batch = prdReport.barcode, + // pr_qty = (int)prdReport.reported_qty, + // }); + // + // mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput() + // { + // material_id = prdReport.material_id, + // material_code = basMaterial.code, + // unit_id = prdReport.unit_id, + // barcode = prdReport.barcode, + // code_batch = prdReport.mo_task_code, + // codeqty = (int)prdReport.reported_qty, + // }); + // // string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + // string domain = "http://tnb.tuotong-tech.com"; + // Dictionary header = new() + // { + // // ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + // }; + // string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header); + // Log.Information(sendResult); + // AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + // result2 = authResponse.code != 200 || !(bool)authResponse.data + // ? throw Oops.Bah(authResponse.msg) + // : await db.Ado.UseTranAsync(async () => + // { + // _ = await _repository.InsertAsync(prdInstockH); + // + // if (prdInstockDs.Count > 0) + // { + // _ = await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + // } + // }); + // } + // + // return result2.IsSuccess ? "true" : "false"; + // } + + [HttpPost] - public async Task InstockTubeOne(PrdReport prdReport) + public async Task InstockTubeOne(InstockInput input) { + string equip_code = input.equip_code; + string label_code = input.label_code; + if (string.IsNullOrEmpty(equip_code)) + { + throw Oops.Bah("请传机台号"); + } + + if (string.IsNullOrEmpty(label_code)) + { + throw Oops.Bah("请传标签号"); + } + ISqlSugarClient db = _repository.AsSugarClient(); - string location_code = "ZCR01";//todo 短管挤出件目标库位之后改 + // string location_code = "ZCR01";//todo 短管挤出件目标库位之后改 string warehouse_id = "2"; PrdInstockH? prdInstockH = null; List prdInstockDs = new() { }; DbResult result2 = new(); + EqpEquipment equipment = null; + try + { + equipment = await db.Queryable() + .LeftJoin((x,y)=>x.id==y.equip_id) + .Where((x,y) => y.equip_code==equip_code && y.label_name==label_code && y.label_point=="提报装箱称重点位") + .Select((x,y)=>x) + .FirstAsync(); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + if (equipment == null) + { + throw Oops.Bah("未找到机台"); + } + + EqpDaq daq = await db.Queryable().Where(x => + x.equip_id == equipment.id && x.label_name == label_code && x.label_point == "提报装箱称重点位").FirstAsync(); + + if (daq == null) + { + throw Oops.Bah("未找到数采信号"); + } + + string location_code = daq.location_code; + + PrdReport prdReport = await db.Queryable() + .Where(x => x.equip_id == equipment.id && x.status == 0).OrderByDescending(x => x.create_time) + .FirstAsync(); + BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdReport.material_id); string create_id = prdReport.create_id; UserEntity user = await db.Queryable().SingleAsync(x => x.Id == create_id); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 68c9993b..b1dde9b2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1500,7 +1500,8 @@ namespace Tnb.ProductionMgr report = input.Adapt(); report.id = SnowflakeIdHelper.NextId(); report.reported_qty = input.reported_qty; - report.material_box_code = input.material_box_qrcode; + report.material_box_code = input.material_box_code; + report.location_code = input.location_code; report.create_id = _userManager.UserId; report.create_time = DateTime.Now; // report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); @@ -1730,8 +1731,9 @@ namespace Tnb.ProductionMgr string[] arr = JsonConvert.DeserializeObject(basMaterial.category_id); if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请 { - string resultMsg = await _prdInstockService.InstockTubeOne(report); - return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); + // string resultMsg = await _prdInstockService.InstockTubeOne(report); + // return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); + return true; } if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请