From a04831bbaecfe87ab7fe2f653073d5d24078fe2b Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Sun, 29 Sep 2024 16:03:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=A4=E5=87=BA=E6=89=B9=E5=8F=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20erp=E6=8E=A5=E5=8F=A3=E5=8F=A6=E8=B5=B7=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IThirdApiRecordService.cs | 2 +- .../Tnb.BasicData/ThirdApiRecordService.cs | 24 ++++++-- .../Entity/PrdReport.cs | 10 ++++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 55 +++++++++++++------ .../Entity/WmsPurchaseH.cs | 5 ++ .../Tnb.WarehouseMgr/WmsInStockService.cs | 1 + .../Tnb.WarehouseMgr/WmsPrdInstockHService.cs | 6 +- .../Tnb.WarehouseMgr/WmsPurchaseDService.cs | 1 + 8 files changed, 76 insertions(+), 28 deletions(-) diff --git a/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs b/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs index 62b6b3c0..4a7a0ffd 100644 --- a/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs @@ -11,6 +11,6 @@ namespace Tnb.BasicData.Interfaces /// /// 手动 自动 /// - Task Send(List records, string send_type,ISqlSugarClient db=null); + Task Send(List records, string send_type,ISqlSugarClient db=null,bool ThreadFlag = true); } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 2bcd0724..ea304e86 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -44,7 +44,7 @@ namespace Tnb.BasicData public async Task Send(string id) { ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id); - ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动"); + ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动",null,false); return thirdResult.msgResult; } @@ -89,7 +89,25 @@ namespace Tnb.BasicData return "失败"; } - public async Task Send(List records, string send_type,ISqlSugarClient db=null) + public async Task Send(List records, string send_type,ISqlSugarClient db=null,bool threadFlag=true) + { + ThirdResult thirdResult = new ThirdResult(); + if (threadFlag) + { + Task.Run(() => + { + Send(records, send_type, db); + }); + } + else + { + thirdResult = await Send(records, send_type, db); + } + + return thirdResult; + } + + private async Task Send(List records, string send_type, ISqlSugarClient db = null) { ThirdResult thirdResult = null; bool tranFlag = true; @@ -273,8 +291,6 @@ namespace Tnb.BasicData Log.Error(e.Message,e); if(tranFlag) await db.Ado.RollbackTranAsync(); } - - return thirdResult; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index e4657c2b..65c8c09f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -169,4 +169,14 @@ public partial class PrdReport : BaseEntity /// public string erp_pk_wr_product { get; set; } + /// + /// 合格数 + /// + public decimal? pqty { get; set; } + /// + /// 不合格数 + /// + public decimal? rqty { get; set; } + + } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index fc41e357..ded5e525 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2092,22 +2092,12 @@ namespace Tnb.ProductionMgr }else if (mo.mo_type == DictConst.PrdMoTypeJC) { - if (changeBatchFlag) - { - EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); - ToolMolds toolMolds = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); - batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{prdMoTask.act_start_date.Value.ToString("yyMMdd")}"; - await db.Updateable() - .SetColumns(x => x.batch == batch) - .SetColumns(x=>x.change_batch_count_by_day==changeCountNumByDay) - .SetColumns(x=>x.change_batch_count_by_qty==changeCountNumByQty) - .Where(x => x.id == prdMoTask.id) - .ExecuteCommandAsync(); - } - else - { - batch = prdMoTask.batch; - } + ToolMolds toolMolds = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); + batch = $"6{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 4, 2)}{DateTime.Now.ToString("yyMMdd")}"; + await db.Updateable() + .SetColumns(x => x.batch == batch) + .Where(x => x.id == prdMoTask.id) + .ExecuteCommandAsync(); }else { // OrganizeEntity organizeEntity = await _db.Queryable().SingleAsync(x => x.Id == prdMoTask.workline_id); @@ -2496,6 +2486,12 @@ namespace Tnb.ProductionMgr throw Oops.Bah(result1.msg); } + await _db.Updateable() + .SetColumns(x => x.pqty == input.pqty) + .SetColumns(x => x.rqty == input.rqty) + .Where(x => x.id == report.id) + .ExecuteCommandAsync(); + WmsPrdInstockInput wmsPrdInstockInput = new WmsPrdInstockInput(); wmsPrdInstockInput.prd_bill_code = prdMo.mo_code; wmsPrdInstockInput.material_id = prdMoTask.material_id; @@ -2627,8 +2623,8 @@ namespace Tnb.ProductionMgr // ["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "", ["cbunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", ["cbastunitid"] = erpExtendFields.Find(x =>x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["nbplanwrnum"] = report.reported_qty, - ["nbwrnum"] = report.reported_qty, + ["nbplanwrnum"] = input.pqty, + ["nbwrnum"] = input.pqty, ["tbendtime"] = nowStr, ["tbstarttime"] = prdMoTask.act_start_date != null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", ["vbinbatchcode"] = report.batch, @@ -2751,6 +2747,29 @@ namespace Tnb.ProductionMgr } + [HttpPost] + public async Task DelPrdReport(string id) + { + PrdReport prdReport = await _db.Queryable().SingleAsync(x => x.id == id); + PrdMoTask prdMoTask = await _db.Queryable().SingleAsync(x => x.id == prdReport.mo_task_id); + DbResult result = await _db.Ado.UseTranAsync(async () => + { + await _db.Updateable() + .SetColumns(x => x.reported_work_qty == x.reported_work_qty - prdReport.reported_qty) + .Where(x => x.id == prdMoTask.id) + .ExecuteCommandAsync(); + + await _db.Updateable() + .SetColumns(x => x.reported_work_qty == x.reported_work_qty - prdReport.reported_qty) + .Where(x => x.id == prdMoTask.mo_id) + .ExecuteCommandAsync(); + + await _db.Deleteable().Where(x => x.id == id).ExecuteCommandAsync(); + }); + + return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "保存成功" : result.ErrorMessage); + } + /// /// 自检报废提交 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs index a044e45e..f00ce4d6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs @@ -164,4 +164,9 @@ public partial class WmsPurchaseH : BaseEntity, IPurchaseAndSaleAuitEnti /// 制单方式(自制 同步) /// public string make_method { get; set; } + + /// + /// erp流水号 + /// + public string service_num { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 115f79ad..3cbb2f10 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -402,6 +402,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("vbillcode", instock.bill_code); erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? ""); erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? ""); + erpRequestData.Add("vdef3", wmsPurchaseH?.service_num ?? ""); List> erpRequestDataDetails = new List>(); foreach (WmsInstockD item in allInstockDetails) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs index 75241466..7f4ceb76 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs @@ -479,11 +479,7 @@ namespace Tnb.WarehouseMgr BasFactoryConfig callErp = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP); if(callErp.value=="1") { - Thread thread = new(() => - { - _thirdApiRecordService.Send(new List { thirdWebapiRecord }, "自动", _db); - }); - thread.Start(); + _thirdApiRecordService.Send(new List { thirdWebapiRecord }, "自动", _db); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseDService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseDService.cs index a967d1d9..e1774ab4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseDService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseDService.cs @@ -183,6 +183,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("vbillcode", instock.bill_code); erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? ""); erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? ""); + erpRequestData.Add("vdef3", wmsPurchaseH?.service_num ?? ""); List> erpRequestDataDetails = new List>(); foreach (WmsInstockD item in allInstockDetails)