From 2923b57174c59c6b07e3ac7502c41fa60e32ae33 Mon Sep 17 00:00:00 2001 From: 如洲 陈 <1278080563@qq.com> Date: 星期五, 09 五月 2025 17:49:20 +0800 Subject: [PATCH] 入库、首检、巡检 --- MES.Service/service/WomcaaWWManager.cs | 92 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 79 insertions(+), 13 deletions(-) diff --git a/MES.Service/service/WomcaaWWManager.cs b/MES.Service/service/WomcaaWWManager.cs index 2acad32..692661b 100644 --- a/MES.Service/service/WomcaaWWManager.cs +++ b/MES.Service/service/WomcaaWWManager.cs @@ -35,33 +35,96 @@ switch (womErpCaa.Type) { case "3": - return UpdateData(db, mesWomcaa, mesWomcabs) ? 1 : 0; + return DeleteData(db, mesWomcaa, mesWomcabs) ? 1 : 0; case "1": case "2": case "4": - case "5": return SaveOrUpdateDataWw(db, mesWomcaa, mesWomcabs) ? 1 : 0; + case "5": + return UpdateData(db, mesWomcaa, mesWomcabs) ? 1 : 0; default: throw new NotImplementedException( $"type娌℃湁{womErpCaa.Type}杩欎釜绫诲瀷"); } }) > 0; } - - private bool SaveOrUpdateDataWw(SqlSugarScope db, Womcaa mesWomcaa, List<Womcab> mesWomcabss) + private bool UpdateData(SqlSugarScope db, Womcaa mesWomcaa, List<Womcab> mesWomcabs) { - if (mesWomcaa.Id != null) base.DeleteById(mesWomcaa.Id); - - if (mesWomcabss.Count > 0) + if (mesWomcaa.Id != null) + { + base.DeleteById(mesWomcaa.Id); + } + if (mesWomcabs.Count > 0) + { db.Deleteable<Womcab>().Where(s => s.Eid == mesWomcaa.Erpid).ExecuteCommand(); - + } var orUpdate = base.Insert(mesWomcaa); - var baOrUpdate = _womcabWWManager.InsertRange(mesWomcabss); - if (orUpdate && baOrUpdate) return true; + var baOrUpdate = _womcabWWManager.InsertRange(mesWomcabs); + if (orUpdate && baOrUpdate) + { + //瀹氫箟杈撳叆鍙傛暟 + var inputParam1 = new SugarParameter("P_WORK_NO", mesWomcaa.Caa001); + // 瀹氫箟杈撳嚭鍙傛暟 + var outParam1 = new SugarParameter("c_Result", null, true); + var outParam2 = new SugarParameter("C_MSG", null, true); + // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ + Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2); + // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� + int result = int.Parse((string)outParam1.Value); + string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; + if (result == 1) + { + //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊� + db.Ado.RollbackTran(); + throw new Exception(message); + } + // 鎻愪氦浜嬪姟 + db.Ado.CommitTran(); + return true; + } throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�"); } - private bool UpdateData(SqlSugarScope db, Womcaa mesWomcaa,List<Womcab> mesWomcabs) + private bool SaveOrUpdateDataWw(SqlSugarScope db, Womcaa mesWomcaa, List<Womcab> mesWomcabss) + { + if (mesWomcaa.Id != null) + { + base.DeleteById(mesWomcaa.Id); + } + if (mesWomcabss.Count > 0) + { + db.Deleteable<Womcab>().Where(s => s.Eid == mesWomcaa.Erpid).ExecuteCommand(); + } + var orUpdate = base.Insert(mesWomcaa); + var baOrUpdate = _womcabWWManager.InsertRange(mesWomcabss); + + if (orUpdate && baOrUpdate) + { + //瀹氫箟杈撳叆鍙傛暟 + var inputParam1 = new SugarParameter("P_WORK_NO", mesWomcaa.Caa001); + // 瀹氫箟杈撳嚭鍙傛暟 + var outParam1 = new SugarParameter("c_Result", null, true); + var outParam2 = new SugarParameter("C_MSG", null, true); + // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ + Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2); + // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� + int result = int.Parse((string)outParam1.Value); + string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; + if (result == 1) + { + //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊� + db.Ado.RollbackTran(); + throw new Exception(message); + } + // 鎻愪氦浜嬪姟 + db.Ado.CommitTran(); + return true; + } + + throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�"); + } + + private bool DeleteData(SqlSugarScope db, Womcaa mesWomcaa,List<Womcab> mesWomcabs) { if (mesWomcaa.Id != null) { @@ -93,6 +156,7 @@ Caa012 = Convert.ToDecimal(dto.FQty), Caa013 = dto.FBomId, Caa015 = dto.FXSHTH, + Caa015Head = dto.FSaleOrderEntrySeq, Caa016 = dto.FDescription, Caa017 = 0, Caa018 = Convert.ToDecimal(dto.PLAN_ID), @@ -117,7 +181,7 @@ SrcBillType = dto.FSrcBillType, SrcBillNo = dto.FSrcBillNo, SrcBillentryseq = dto.FSrcBillEntrySeq, - SaleOrderNo = dto.FSaleOrderNo, + SaleOrderNo = dto.FXSHTH, SaleOrderEntryseq = dto.FSaleOrderEntrySeq, ForceCloserid = dto.FForceCloserId, CloseType = dto.FCloseType, @@ -132,7 +196,9 @@ FPURORDERENTRYSEQ = Convert.ToDecimal(dto.FPurOrderEntrySeq), FSUBENTRYID = Convert.ToDecimal(dto.fsubentryid), FSTOCKINQTY = Convert.ToDecimal(dto.Caa024), - FNOSTOCKINQTY = Convert.ToDecimal(dto.Caa025) + FNOSTOCKINQTY = Convert.ToDecimal(dto.Caa025), + SupplierId = dto.SupplierId, + FinishedProduct = dto.FinishedProduct }; if (dto.Type == "5") { -- Gitblit v1.9.3