From f34c6a21dc58bc0d40a011d6d7366c5eb3f15f15 Mon Sep 17 00:00:00 2001 From: yxj <yxj@hz-kingdee.com> Date: 星期五, 20 九月 2024 13:59:34 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs | 651 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 627 insertions(+), 24 deletions(-) diff --git a/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs b/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs index 8eb1141..9ec52fb 100644 --- a/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs +++ b/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs @@ -1,4 +1,5 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; @@ -13,6 +14,8 @@ //鐢熶骇姹囨姤Controller public class Sc_ICMOReportBillController : ApiController { + //鑾峰彇绯荤粺鍙傛暟 + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛� private json objJsonResult = new json(); @@ -35,6 +38,7 @@ { try { + List<object> a = new List<object>(); //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 1, false, user)) { @@ -55,13 +59,19 @@ string sql = sql1 + sWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit"); } - + foreach (DataColumn col in ds.Tables[0].Columns)//閬嶅巻ds涓涓�涓〃锛圱ables[0]锛夌殑鎵�鏈夊垪锛圕olumns锛夋瘡娆″惊鐜腑锛宑ol鍙橀噺浼氭寔鏈夊綋鍓嶅垪鐨勫紩鐢� + { + Type dataType = col.DataType; //鑾峰彇褰撳墠鏁版嵁绫诲瀷浼犲叆 鑷畾涔夊彉閲廳atadataType + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //瀛楃涓叉嫾鎺� // 灏嗗垪鍚嶅拰鏁版嵁绫诲瀷淇℃伅鎷兼帴鎴愪竴涓狫SON鏍煎紡鐨勫瓧绗︿覆 + a.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess锛�"; objJsonResult.data = ds.Tables[0]; + objJsonResult.list = a; return objJsonResult; //} //else @@ -115,7 +125,9 @@ { ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,鐗╂枡浠g爜 HMaterCode,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec, HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,HSourceID,鐢熶骇璧勬簮浠g爜 HSourceCode,鐢熶骇璧勬簮 HSourceName, - HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 HRemark + HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 HRemark, + HICMOInterID,HICMOEntryID,HICMOBillNo,HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID, + HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,涓嶈壇鏁伴噺 HBadQty FROM h_v_IF_ICMOReportBillList_Edit"), "h_v_IF_ICMOReportBillList_Edit"); objJsonResult.code = "0"; @@ -129,7 +141,10 @@ //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; string sql1 = string.Format(@"SELECT HMaterID,鐗╂枡浠g爜 HMaterCode,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec, HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,HSourceID,鐢熶骇璧勬簮浠g爜 HSourceCode,鐢熶骇璧勬簮 HSourceName, - HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 HRemark + HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 + HRemark,HICMOInterID,HICMOEntryID,HICMOBillNo, + HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID, + HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,涓嶈壇鏁伴噺 HBadQty FROM h_v_IF_ICMOReportBillList_Edit where 1 = 1 "); string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit"); @@ -295,8 +310,8 @@ oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItemSub.HCloseType = false; //鍏抽棴绫诲瀷 //oItemSub.HRemark = ""; //澶囨敞 - oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� - oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� + //oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� + //oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� //oItemSub.HSourceBillNo = ""; //婧愬崟鍗曞彿 //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷 //oItemSub.HRelationQty = 0; //鍏宠仈鏁伴噺 @@ -310,7 +325,7 @@ //淇濆瓨 //淇濆瓨瀹屾瘯鍚庡鐞� bool bResult; - if (oBill.omodel.HInterID == 0) + if (refSav == "Add") { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); @@ -411,8 +426,7 @@ "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "','" + oSub.HOWNERTYPEID + "'," + oSub.HISENTRUST + "," + oSub.HSTOCKINORGID + "," + oSub.HOWNERID + "," + oSub.HCHECKPRODUCT + ",'" + oSub.HQAIP + "'," + oSub.HCOSTRATE + "," + oSub.HISBACKFLUSH + ",'" + oSub.HREQSRC + "','" + oSub.HREQBILLNO + "'," + oSub.HREQBILLID + "," + - oSub.HREQENTRYSEQ + "," + oSub.HREQENTRYID + "," + oSub.HMOMAINENTRYID + "," + oSub.HSTOCKINQUASELQTY + "," + oSub.HPRODUCTTYPE + ",'" + oSub.HPROJECTNO + "'," + oSub.HICMOENTRYSEQ + "," + oSub.HSEQ + ",'" + oSub.HPRODUCEDATE + "','" + oSub.HEXPIRYDATE + "'," + oSub.HBASEUNITID + "," + oSub.HDEPTID + "," + oSub.HGroupID + ",'" + oSub.HDESCRIPTION + "','" + oSub.HSourceNumber + "'," + oSub.HQPQty + "," + oSub.HICMOEntryID + "," + oSub.HWhID + "," + oSub.HSPID + ",'" + oSub.HBatChNo + "'," + oSub.HAuxPropID + ",'" + oSub.HMTONo + "'," + oSub.HPlanMode + "," + oSub.HERPInterID + "," + oSub.HERPEntryID + - ") "; + oSub.HREQENTRYSEQ + "," + oSub.HREQENTRYID + "," + oSub.HMOMAINENTRYID + "," + oSub.HSTOCKINQUASELQTY + "," + oSub.HPRODUCTTYPE + ",'" + oSub.HPROJECTNO + "'," + oSub.HICMOENTRYSEQ + "," + oSub.HSEQ + ",'" + oSub.HPRODUCEDATE + "','" + oSub.HEXPIRYDATE + "'," + oSub.HBASEUNITID + "," + oSub.HDEPTID + "," + oSub.HGroupID + ",'" + oSub.HDESCRIPTION + "','" + oSub.HSourceNumber + "'," + oSub.HQPQty + "," + oSub.HICMOEntryID + "," + oSub.HWhID + "," + oSub.HSPID + ",'" + oSub.HBatChNo + "'," + oSub.HAuxPropID + ",'" + oSub.HMTONo + "'," + oSub.HPlanMode + "," + oSub.HERPInterID + "," + oSub.HERPEntryID + ") "; oCN.RunProc(sql); } oCN.Commit(); @@ -491,9 +505,60 @@ objJsonResult.data = null; return objJsonResult; } - bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = ""; + oCN.BeginTran();//寮�濮嬩簨鍔� + ds = oCN.RunProcReturn("select * from Sc_ICMOReportBillMain where HInterID=" + lngBillKey, "Sc_ICMOReportBillMain"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; ; + } + else + { + HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); + } + + //鍒犻櫎鍓嶆帶鍒�========================================= + DataSet Ds; + + string sql1 = "exec h_p_Sc_ICMOReportBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'"; + Ds = oCN.RunProcReturn(sql1, "h_p_Sc_ICMOReportBill_BeforeDelCtrl"); + if (Ds == null || Ds.Tables.Count == 0 || Ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (Ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + Ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + + oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + "" + "','" + "鍒犻櫎鐢熶骇姹囨姤鍗曞崟鎹細" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','LMES-鐢熶骇姹囨姤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鍒犻櫎鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); + + + bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, HBillNo, "h_p_Sc_ICMOReportBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo); + + if (IsDete) { + oCN.Commit();//鎻愪氦浜嬪姟 + objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; @@ -502,11 +567,11 @@ } else { - objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; + oCN.RollBack(); return objJsonResult; } } @@ -516,6 +581,7 @@ objJsonResult.count = 0; objJsonResult.Message = "鍗曟嵁鏈壘鍒�"; objJsonResult.data = null; + oCN.RollBack(); return objJsonResult; } } @@ -535,6 +601,7 @@ { string ModRightNameCheck = "Sc_ICMOReportBill_Check"; DBUtility.ClsPub.CurUserName = CurUserName; + string sql = ""; try { //瀹℃牳鏉冮檺 @@ -609,8 +676,30 @@ } if (IsAudit == 0) //瀹℃牳鎻愪氦 { + //瀹℃牳鍓嶆帶鍒�===============================================Begin=================================================================== + sql = "exec h_p_Sc_ICMOReportBill_BeforeCheckCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //瀹℃牳鍓嶆帶鍒�===============================================End=================================================================== + //瀹℃牳鎻愪氦 - if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) + if (oBill.CheckBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_ICMOReportBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; @@ -620,8 +709,8 @@ } else { - objJsonResult.code = "1"; - objJsonResult.count = 1; + objJsonResult.code = "0"; + objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; @@ -629,8 +718,30 @@ } if (IsAudit == 1) //鍙嶅鏍告彁浜� { + //鍙嶅鏍稿墠鎺у埗===============================================Begin=================================================================== + sql = "exec h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅鏍稿墠鎺у埗===============================================End=================================================================== + //鍙嶅鏍告彁浜bandonCheck - if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) + if (oBill.AbandonCheck(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_ICMOReportBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; @@ -640,8 +751,8 @@ } else { - objJsonResult.code = "1"; - objJsonResult.count = 1; + objJsonResult.code = "0"; + objJsonResult.count = 0; objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; @@ -660,6 +771,113 @@ } #endregion + #region 鐢熶骇姹囨姤鍗曞叧闂�/鍙嶅叧闂姛鑳� + [Route("Sc_ICMOReportBill/CloseSc_ICMOReportBill")] + [HttpGet] + public object CloseSc_ICMOReportBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBill_Close", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "Sc_ICMOReportBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + } + //鍏抽棴鍗曟嵁 + if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插弽鍏抽棴!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + } + //鍙嶅叧闂崟鎹� + if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + oCN.Commit();//鎻愪氦浜嬪姟 + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion @@ -674,21 +892,406 @@ { try { - if (sWhere == null || sWhere.Equals("")) + List<object> columnNameList = new List<object>(); + + string sql1 = "select * from h_v_Sc_AssemblyBillList where 1 = 1 "; + string sql = sql1 + sWhere; + ds = oCN.RunProcReturn(sql, "h_v_Sc_AssemblyBillList"); + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) { - ds = oCN.RunProcReturn("select * from h_v_Sc_AssemblyBillList " + sWhere, "h_v_Sc_AssemblyBillList"); + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + #region [鍚屾鍗曟嵁] + [Route("Sc_ICMOReportBill/Sc_ICMOReportBillViewApi")] + [HttpGet] + public json Sc_ICMOReportBillViewApi(string BillNo, string BillType) + { + string sql = string.Empty; + string sReturn = ""; + if (oSystemParameter.ShowBill(ref sReturn) == true) + { + //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡 + if (oSystemParameter.omodel.WMS_CloudMode == "Y") + { + #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩 + try + { + oCN.BeginTran(); + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPSourceBillToLocal '" + BillNo + "','" + BillType + "'", "h_p_WMS_ERPSourceBillToLocal"); + if (DS == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍚屾澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ERP涓笉瀛樺湪璇ュ崟鎹彿"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + } + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + #endregion } else { - string sql1 = "select * from h_v_Sc_AssemblyBillList where 1 = 1 "; - string sql = sql1 + sWhere; - ds = oCN.RunProcReturn(sql, "h_v_Sc_AssemblyBillList"); + #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩 + var json = new + { + CreateOrgId = 0, + Number = BillNo, + Id = "" + }; + #region [閲戣澏閮ㄥ垎] + //鐧诲綍閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + //鍒ゆ柇鏄惁鐧诲綍鎴愬姛 + if (isSuccess < 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = loginRet; + objJsonResult.data = null; + return objJsonResult; + } + //鏌ョ湅 鑾峰彇鏁版嵁 + var _result = InvokeHelper.View("PRD_MORPT", JsonConvert.SerializeObject(json)); + var _saveObj = JObject.Parse(_result); + //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛 + if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "閲戣澏鐢熶骇姹囨姤鍗曞悓姝ュけ璐sonRoot锛�" + _result; + objJsonResult.data = null; + return objJsonResult; + } + + #endregion + //鑾峰彇涓昏〃鏁版嵁 + DataSet Ds; + Int64 InterID = 0; + Ds = oCN.RunProcReturn("select * from Sc_ICMOReportBillMain where HBillNo = '" + BillNo + "'", "Sc_ICMOReportBillMain"); + if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0) + { + InterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); + } + + #region [涓昏〃鏁版嵁璧嬪�糫 + var jsonData = new + { + HInterID = _saveObj["Result"]["Result"]["Id"], + HYear = DateTime.Now.Year, + HPeriod = DateTime.Now.Month, + HBillType = 3711, + HBillSubType = 3711, + HDate = _saveObj["Result"]["Result"]["Date"], + HBillNo = _saveObj["Result"]["Result"]["BillNo"], + HEmpID = 0, + HEmpNumber = "", + HGroupID = 0, + HDeptID = 0, + HDeptNumber = "", + HRemark = "CLD瀵煎叆", + HChecker = _saveObj["Result"]["Result"]["ApproverId"]["Name"], + HCheckDate = _saveObj["Result"]["Result"]["ApproveDate"], + HMaker = _saveObj["Result"]["Result"]["CreatorId"]["Name"], + HMakeDate = _saveObj["Result"]["Result"]["CreateDate"], + HUpDater = _saveObj["Result"]["Result"]["ModifierId"]["Name"], + HUpDateDate = _saveObj["Result"]["Result"]["ModifyDate"], + HDeleteMan = _saveObj["Result"]["Result"]["CANCELER_Id"], + HDeleteDate = _saveObj["Result"]["Result"]["CancelDate"], + HMainSourceBillType = "", + HMainSourceInterID = 0, + HMainSourceEntryID = 0, + HMainSourceBillNo = "", + HPrintQty = 0, + HCheckType = "", + HERPInterID = _saveObj["Result"]["Result"]["Id"], + HERPBillType = _saveObj["Result"]["Result"]["BillType_Id"], + HPRDORGID = _saveObj["Result"]["Result"]["PrdOrgId_Id"], + }; + #endregion + // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁 + sql = $"delete from Sc_ICMOReportBillMain where HInterID = " + InterID; + oCN.RunProc(sql); + + //鎻掑叆涓昏〃 + sql = $@" + insert into Sc_ICMOReportBillMain + (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HEmpID,HEmpNumber + ,HGroupID,HDeptID,HDeptNumber,HRemark,HChecker,HCheckDate,HMaker,HMakeDate + ,HUpDater,HUpDateDate,HDeleteMan,HDeleteDate + ,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HCheckType + ,HERPInterID,HERPBillType,HPRDORGID + ) + values + ({jsonData.HInterID},{jsonData.HYear},{jsonData.HPeriod},{jsonData.HBillType},{jsonData.HBillSubType}, + '{jsonData.HDate}','{jsonData.HBillNo}',{jsonData.HEmpID},'{jsonData.HEmpNumber}',{jsonData.HGroupID},{jsonData.HDeptID},'{jsonData.HDeptNumber}','{jsonData.HRemark}','{jsonData.HChecker}','{jsonData.HCheckDate}','{jsonData.HMaker}','{jsonData.HMakeDate}','{jsonData.HUpDater}','{jsonData.HUpDateDate}','{jsonData.HDeleteMan}','{jsonData.HDeleteDate}','{jsonData.HMainSourceBillType}',{jsonData.HMainSourceInterID},{jsonData.HMainSourceEntryID},'{jsonData.HMainSourceBillNo}',{jsonData.HPrintQty},'{jsonData.HCheckType}',{jsonData.HERPInterID},'{jsonData.HERPBillType}',{jsonData.HPRDORGID})"; + + oCN.RunProc(sql); + + #region [鐢宠瀛愯〃鍙橀噺] + var dataArr = _saveObj["Result"]["Result"]["PRD_MORPTENTRY"]; + + DataSet Cs; + double RelationQty = 0; + #endregion + int i = 0; + + // 鑾峰彇瀛愯〃鏁版嵁 + Cs = oCN.RunProcReturn("select * from Sc_ICMOReportBillSub where HInterID = " + InterID, "Sc_ICMOReportBillSub"); + // 鍒犻櫎瀛愯〃瀵瑰簲鏁版嵁 + sql = $"delete from Sc_ICMOReportBillSub where HInterID = " + InterID; + oCN.RunProc(sql); + + foreach (var oSub in dataArr) + { + #region [瀛愯〃鏁版嵁璧嬪�糫 + + if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HInterID"].ToString()) != 0) + { + RelationQty = ClsPub.isDoule(Cs.Tables[0].Rows[i]["HRelationQty"].ToString()); + + i++; + } + + var subData = new + { + HInterID = _saveObj["Result"]["Result"]["Id"], + HEntryID = oSub["Id"], + HMaterID = oSub["MaterialId_Id"], + HMaterNumber = "", + HUnitID = oSub["UnitID_Id"], + HUnitNumber = "", + HQtyMust = oSub["FinishQty"], + HQty = oSub["FinishQty"], + HWorkerID = 0, + HWorkerNumber = "", + HSourceID = 0, + HSourceNumber = "", + HTimes = oSub["StdManHour"], + HBadQty = oSub["FailQty"], + HBadCount = 0, + HQPQty = oSub["QuaQty"], + HWasterQty = 0, + HRemark = "CLOUD瀵煎叆", + HSourceInterID = oSub["SrcInterId"], + HSourceEntryID = oSub["SrcEntryId"], + HSourceBillNo = oSub["SrcBillNo"], + HSourceBillType = oSub["SrcBillType"], + HICMOInterID = oSub["MoId"], + HICMOEntryID = oSub["MoEntryId"], + HICMOBillNo = oSub["MoBillNo"], + HSeOrderInterID = 0, + HSeOrderEntryID = 0, + HSeOrderBillNo = "", + HRelationQty = oSub["BaseStockInQuaSelQty"], + HRelationMoney = 0, + HSplitNO = "", + HBarCode = "", + HWhID = oSub["StockId_Id"], + HSPID = oSub["StockLocId_Id"], + HBatChNo = oSub["Lot_Text"], + HAuxPropID = oSub["AuxPropId_Id"], + HMTONo = oSub["MtoNo"], + HPlanMode = 0, + HERPInterID = _saveObj["Result"]["Result"]["Id"], + HERPEntryID = oSub["Id"], + HOWNERTYPEID = oSub["OwnerTypeId"], + HISENTRUST = oSub["IsEntrust"] = false ? 0 : 1, + HSTOCKINORGID = oSub["StockInOrgId_Id"], + HOWNERID = oSub["OwnerId_Id"], + HCHECKPRODUCT = oSub["CheckProduct"] = false ? 0 : 1, + HQAIP = oSub["QAIP"], + HCOSTRATE = oSub["CostRate"], + HISBACKFLUSH = oSub["ISBACKFLUSH"], + HREQSRC = oSub["ReqSrc"], + HREQBILLNO = oSub["ReqBillNo"], + HREQBILLID = oSub["ReqBillId"], + HREQENTRYSEQ = oSub["ReqEntrySeq"], + HREQENTRYID = oSub["ReqEntryId"], + HMOMAINENTRYID = oSub["MoMainEntryId"], + HSTOCKINQUASELQTY = oSub["BaseStockInQuaSelQty"], + HPRODUCTTYPE = oSub["ProductType"], + HPROJECTNO = oSub["ProjectNo"], + HICMOENTRYSEQ = oSub["MoEntrySeq"], + HSEQ = oSub["Seq"], + HPRODUCEDATE = oSub["ProduceDate"], + HEXPIRYDATE = oSub["ExpiryDate"], + HBASEUNITID = oSub["BaseUnitId_Id"], + HDEPTID = oSub["WorkshopId_Id"], + HGroupID = oSub["ShiftGroupId_Id"], + HDESCRIPTION = "" + }; + #endregion + + //鎻掑叆瀛愯〃 + sql = $@" + insert into Sc_ICMOReportBillSub + (HInterID,HEntryID,HMaterID,HMaterNumber,HUnitID,HUnitNumber + ,HQtyMust,HQty,HWorkerID,HWorkerNumber,HSourceID,HSourceNumber,HTimes,HBadQty,HBadCount,HQPQty + ,HWasterQty,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HICMOInterID,HICMOEntryID,HICMOBillNo + ,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HRelationQty,HRelationMoney,HSplitNO,HBarCode + ,HWhID,HSPID,HBatChNo,HAuxPropID,HMTONo,HPlanMode,HERPInterID,HERPEntryID + ,HOWNERTYPEID,HISENTRUST,HSTOCKINORGID,HOWNERID,HCHECKPRODUCT,HQAIP,HCOSTRATE,HISBACKFLUSH,HREQSRC + ,HREQBILLNO,HREQBILLID,HREQENTRYSEQ,HREQENTRYID,HMOMAINENTRYID,HSTOCKINQUASELQTY,HPRODUCTTYPE,HPROJECTNO + ,HICMOENTRYSEQ,HSEQ,HPRODUCEDATE,HEXPIRYDATE,HBASEUNITID,HDEPTID,HGroupID,HDESCRIPTION + ) + values + ({subData.HInterID},{subData.HEntryID},{subData.HMaterID},'{subData.HMaterNumber}',{subData.HUnitID},'{subData.HUnitNumber}',{subData.HQtyMust},{subData.HQty},{subData.HWorkerID},'{subData.HWorkerNumber}',{subData.HSourceID},'{subData.HSourceNumber}',{subData.HTimes},{subData.HBadQty},{subData.HBadCount},{subData.HQPQty},{subData.HWasterQty},'{subData.HRemark}',{subData.HSourceInterID},{subData.HSourceEntryID},'{subData.HSourceBillNo}','{subData.HSourceBillType}',{subData.HICMOInterID},{subData.HICMOEntryID},'{subData.HICMOBillNo}',{subData.HSeOrderInterID},{subData.HSeOrderEntryID},'{subData.HSeOrderBillNo}',{subData.HRelationQty},{subData.HRelationMoney},'{subData.HSplitNO}','{subData.HBarCode}',{subData.HWhID},{subData.HSPID},'{subData.HBatChNo}',{subData.HAuxPropID},'{subData.HMTONo}','{subData.HPlanMode}',{subData.HERPInterID},{subData.HERPEntryID},'{subData.HOWNERTYPEID}','{subData.HISENTRUST}',{subData.HSTOCKINORGID},{subData.HOWNERID},'{subData.HCHECKPRODUCT}','{subData.HQAIP}',{subData.HCOSTRATE},'{subData.HISBACKFLUSH}','{subData.HREQSRC}','{subData.HREQBILLNO}',{subData.HREQBILLID},{subData.HREQENTRYSEQ},{subData.HREQENTRYID},{subData.HMOMAINENTRYID},{subData.HSTOCKINQUASELQTY},'{subData.HPRODUCTTYPE}','{subData.HPROJECTNO}',{subData.HICMOENTRYSEQ},{subData.HSEQ},'{subData.HPRODUCEDATE}','{subData.HEXPIRYDATE}',{subData.HBASEUNITID},{subData.HDEPTID},{subData.HGroupID},'{subData.HDESCRIPTION}' + )"; + + oCN.RunProc(sql); + } + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + + #endregion } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁璇诲彇澶辫触锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鐢熶骇姹囨姤鍗曡幏鍙栨簮鍗曚骇閲忔眹鎶ュ崟涓存椂琛ㄤ俊鎭� + /// <summary> + /// 鐢熶骇姹囨姤鍗曡幏鍙栨簮鍗曚骇閲忔眹鎶ュ崟涓存椂琛ㄤ俊鎭� + /// </summary> + /// <returns></returns> + [Route("Sc_ICMOReportBill/GetProdReportBillList")] + [HttpGet] + public object GetProdReportBillList(string HInterID, string user) + { + try + { + List<object> columnNameList = new List<object>(); + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浜ч噺姹囨姤鍗曞唴鐮佷负绌猴紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + + string sql = "exec h_p_Sc_ICMOBillWorkQtyStatus_TmpList '" + HInterID + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOBillWorkQtyStatus_TmpList"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + //if (ds.Tables[0].Rows.Count != 0 || ds != null) + //{ + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds; + objJsonResult.list = columnNameList; + return objJsonResult; + //} + //else + //{ + //objJsonResult.code = "0"; + //objJsonResult.count = 0; + //objJsonResult.Message = "鏃犳暟鎹�"; + //objJsonResult.data = null; + //return objJsonResult; + //} + } + catch (Exception ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + + #region 鐢熶骇姹囨姤鍗� 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栫敓浜ф眹鎶ュ崟鏁版嵁 + [Route("Sc_ICMOReportBill/loadSc_ICMOReportBill_Push")] + [HttpGet] + public object loadSc_ICMOReportBill_Push(long HInterID, long HSubID) + { + try + { + + ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList_Edit where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_ICMOReportBillList_Edit"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "false锛�"; + objJsonResult.Message = "鏈煡璇㈠埌婧愬崟淇℃伅锛�"; objJsonResult.data = null; return objJsonResult; } @@ -710,7 +1313,7 @@ return objJsonResult; } } + #endregion - // } } \ No newline at end of file -- Gitblit v1.9.1