From a5866353a9160dc906e67e9d220804a7633a6280 Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期五, 03 二月 2023 10:28:23 +0800 Subject: [PATCH] 单据子类型 --- WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs | 243 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 202 insertions(+), 41 deletions(-) diff --git a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs index 5f84dac..d354a67 100644 --- a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs +++ b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs @@ -26,6 +26,7 @@ public DAL.ClsSc_MESMaterToSourceBill BillOld = new DAL.ClsSc_MESMaterToSourceBill(); //瀵瑰簲鍗曟嵁绫� + #region 涓婃枡鏀鹃敊鍗昗eb鍒楄〃鏌ヨ /// <summary> /// 杩斿洖鐢熶骇涓婃枡鍗曞垪琛� ///鍙傛暟锛歴tring sql銆� @@ -39,27 +40,27 @@ { if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillList " + sWhere, "h_v_Sc_MaterToSourceBillList"); + ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillMain " + sWhere, "h_v_Sc_MaterToSourceBillMain"); } else { - string sql1 = "select * from h_v_Sc_MaterToSourceBillList where 1 = 1 "; + string sql1 = "select * from h_v_Sc_MaterToSourceBillMain where 1 = 1 "; string sql = sql1 + sWhere; - ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillList"); + ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillMain"); } if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; - objJsonResult.data = null; + objJsonResult.data = ds.Tables[0]; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; + objJsonResult.Message = "鏌ヨ鏁版嵁鎴愬姛锛�"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } @@ -73,8 +74,148 @@ return objJsonResult; } } + #endregion - // + #region 涓婃枡闃查敊鍗曠紪杈戞椂鑾峰彇琛ㄥご鏁版嵁 + [Route("Sc_MaterToSourceBill/Sc_MaterToSourceBillListCheckDetai")] + [HttpGet] + public ApiResult<DataSet> Sc_MaterToSourceBillListCheckDetai(string HID) + { + if (string.IsNullOrEmpty(HID)) + return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" }; + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MaterToSourceBillMain where hmainid= " + HID + " ", "h_v_Sc_MaterToSourceBillMain"); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ笂鏂欓槻閿欏崟鏁版嵁" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + #endregion + + #region 涓婃枡闃查敊鍗曠紪杈戞椂鑾峰彇琛ㄤ綋鏁版嵁(閰嶆枡璁板綍銆佹不鍏疯褰�) + [Route("Sc_MaterToSourceBill/Sc_MaterToSourceBillListProjectDetai")] + [HttpGet] + public object Sc_MaterToSourceBillListProjectDetai(string HInterID) + { + + DataSet ds, ds1; + List<object> list = new List<object>(); + string Swhere = ""; + try + { + if (HInterID != "" || HInterID != null) + { + Swhere = " and hmainid='" + HInterID + "'"; + } + else + { + Swhere = HInterID; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + //鑾峰彇閰嶆枡璁板綍缂栬緫鏁版嵁 + string sql = "select 鏉″舰鐮� HBarCode,HMaterID,鐗╂枡浠g爜 HNumber,鐗╂枡鍚嶇О HName,瑙勬牸鍨嬪彿 HModel,HUnitID,璁¢噺鍗曚綅鍚嶇О HUnitName,鏁伴噺 HQty from h_v_Sc_MaterToSourceBillSub where 1 = 1 " + Swhere + ""; + ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillSub"); + //鑾峰彇娌诲叿璁板綍缂栬緫鏁版嵁 + //string sql1 = "select HMaterID, 閰嶄欢浠g爜 HMaterNumber,閰嶄欢鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HUnitID,鍗曚綅浠g爜 HUnitNumber,鍗曚綅鍚嶇О HUnitName,瀹為檯鐢ㄩ噺 HQty,鏍囧噯鐢ㄩ噺 HQtyMust,HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜� HManagerName,琛ㄤ綋澶囨敞 HRemark from h_v_Sc_MouldMaintainBillList where 1 = 1 " + Swhere + ""; + //ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainBillList"); + list.Add(ds.Tables[0]); + //list.Add(ds1.Tables[0]); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�"; + objJsonResult.list = list; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString(); + objJsonResult.data = null; + } + return objJsonResult; + } + #endregion + + #region [涓婃枡闃查敊鍗曞垹闄ゅ姛鑳絔 + /// <summary> + /// 寮�宸ュ崟鍒犻櫎鍔熻兘 + /// </summary> + /// <returns></returns> + [Route("Sc_MaterToSourceBill/DeltetMaterToSourceBill")] + [HttpGet] + public object DeltetMaterToSourceBill(string HInterID, string UserName) + { + DBUtility.ClsPub.CurUserName = UserName; + //缂栬緫鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("MES_MaterToSourceBill_Delete", 1, false, DBUtility.ClsPub.CurUserName)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); + if (lngBillKey == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + DAL.ClsSc_MESMaterToSourceBill oBill = new DAL.ClsSc_MESMaterToSourceBill(); + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) + { + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + if (IsDete) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + else + { + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈壘鍒�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鎶ュ伐骞冲彴涓婃枡闃查敊鍗曞脊绐楁煡鎵炬暟鎹� [Route("Sc_MaterToSourceBill/GetMESMaterToSourceFrom")] @@ -140,11 +281,14 @@ else { //2.鍖归厤鐢ㄦ枡娓呭崟鐨勭墿鏂欑紪鐮佹槸鍚︿竴鑷� - string sql = string.Format(@"select b.HMaterID,m.HNumber,m.HName,m.HModel,a.HQty HMQty, b.HQty,b.HUnitID,u.HName HUnitName from sc_PPbomBillMain a - inner join Sc_PPBomBillSub b on a.HInterID=b.HInterID - left join Gy_Material m on b.HMaterID=m.HItemID - left join Gy_Unit u on b.HUnitID=u.HItemID - where a.HICMOInterID='" + HICMOInterID + "' and a.HICMOEntryID='"+ HICMOEntryID + "'"); + string sql = @"select '{0}' HBarCode,b.HMaterID,m.HNumber,m.HName,m.HModel,a.HQty HMQty, b.HQty,b.HUnitID,u.HName HUnitName from sc_PPbomBillMain a + inner join Sc_PPBomBillSub b on a.HInterID = b.HInterID + left join Gy_Material m on b.HMaterID = m.HItemID + left join Gy_Unit u on b.HUnitID = u.HItemID + where a.HICMOInterID = '{1}' and a.HICMOEntryID = '{2}'"; + sql = string.Format(sql,HBarCode, HICMOInterID, HICMOEntryID); + + ds = oCN.RunProcReturn(sql, "Sc_PPBomBillSub"); if (ds.Tables[0].Rows.Count > 0) //鏈夌敤鏂欐竻鍗曡褰� { @@ -275,7 +419,7 @@ string refSav = sArray[2].ToString(); //淇濆瓨鏉冮檺 - //if (!DBUtility.ClsPub.Security_Log("MES_MaterToSourceBill_Edit", 1, true, DBUtility.ClsPub.CurUserName)) + //if (!DBUtility.ClsPub.Security_Log("MES_MaterToSourceBill_Edit", 1, false, DBUtility.ClsPub.CurUserName)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; @@ -301,11 +445,24 @@ ListModels oListModels = new ListModels(); try { + //琛ㄥご鏁版嵁瀹炰緥鍖� DAL.ClsSc_MESMaterToSourceBill oBill = new DAL.ClsSc_MESMaterToSourceBill(); List<Model.ClsSc_MaterToSourceBillMain> lsmain = new List<Model.ClsSc_MaterToSourceBillMain>(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Sc_MaterToSourceBillMain(msg2); + + //閰嶆枡璁板綍琛ㄤ綋鏁版嵁瀹炰緥鍖� + //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆� + msg3 = msg3.Substring(1, msg3.Length - 2); + msg3 = msg3.Replace("\\", ""); + msg3 = msg3.Replace("\n", ""); //\n + //msg2 = msg2.Replace("'", "鈥�"); + List<Model.ClsSc_MaterToSourceBillSub> ls = new List<Model.ClsSc_MaterToSourceBillSub>(); + ls = oListModels.getObjectByJson_Sc_MaterToSourceBillSub(msg3); + + //閰嶄欢椤硅〃浣撴暟鎹疄渚嬪寲 + foreach (Model.ClsSc_MaterToSourceBillMain oItem in lsmain) { if (refSav == "Add") @@ -369,6 +526,11 @@ oItem.HProcExchInterID = 0; //娴佽浆鍗′富鍐呯爜 oItem.HProcExchEntryID = 0; //娴佽浆鍗″瓙鍐呯爜 oItem.HProcID = 0; //宸ュ簭ID + oItem.HMainSourceBillNo =oItem.HSourceBillNo; + oItem.HMainSourceBillType = oItem.HSourceBillType; + oItem.HMainSourceInterID = oItem.HSourceInterID; + oItem.HMainSourceEntryID = oItem.HSourceEntryID; + if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { @@ -378,36 +540,34 @@ objJsonResult.data = 1; return objJsonResult; } + + //寰幆閰嶆枡淇℃伅瀛愯〃 + int i = 0; + foreach (Model.ClsSc_MaterToSourceBillSub oItemSub in ls) + { + + i++; + oItemSub.HEntryID = i; + //oItemSub.HCloseMan = ""; //琛屽叧闂� + oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); + oItemSub.HCloseType = false; //鍏抽棴绫诲瀷 + //oItemSub.HRemark = ""; //澶囨敞 + oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� + oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� + //oItemSub.HSourceBillNo = ""; //婧愬崟鍗曞彿 + //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷 + oItemSub.HRelationQty = 0; //鍏宠仈鏁伴噺 + oItemSub.HScanDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));// --鎵爜鏃堕棿 + oItemSub.HSourceBillNo = oItem.HSourceBillNo; + oItemSub.HSourceBillType = oItem.HSourceBillType; + oItemSub.HSourceInterID = oItem.HSourceInterID; + oItemSub.HSourceEntryID = oItem.HSourceEntryID; + oBill.DetailColl.Add(oItemSub); + + } oBill.omodel = oItem; } - //閰嶆枡璁板綍琛ㄤ綋鏁版嵁 - //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆� - msg3 = msg3.Substring(1, msg3.Length - 2); - msg3 = msg3.Replace("\\", ""); - msg3 = msg3.Replace("\n", ""); //\n - //msg2 = msg2.Replace("'", "鈥�"); - List<Model.ClsSc_MaterToSourceBillSub> ls = new List<Model.ClsSc_MaterToSourceBillSub>(); - ls = oListModels.getObjectByJson_Sc_MaterToSourceBillSub(msg3); - int i = 0; - foreach (Model.ClsSc_MaterToSourceBillSub oItemSub in ls) - { - - i++; - oItemSub.HEntryID = i; - //oItemSub.HCloseMan = ""; //琛屽叧闂� - oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); - oItemSub.HCloseType = false; //鍏抽棴绫诲瀷 - //oItemSub.HRemark = ""; //澶囨敞 - oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� - oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� - //oItemSub.HSourceBillNo = ""; //婧愬崟鍗曞彿 - //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷 - oItemSub.HRelationQty = 0; //鍏宠仈鏁伴噺 - oBill.DetailColl.Add(oItemSub); - - } - //閰嶄欢椤硅〃浣撴暟鎹� - + //淇濆瓨 //淇濆瓨瀹屾瘯鍚庡鐞� @@ -436,6 +596,7 @@ else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //杩斿洖涓籌D objJsonResult.Verify = "N"; } if (bResult) @@ -484,7 +645,7 @@ try { //瀹℃牳鏉冮檺 - //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) + //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; -- Gitblit v1.9.1