From 009dfb43a1be6bd461fc5f8fe035c8113669664d Mon Sep 17 00:00:00 2001 From: yangle <admin@YINMOU> Date: 星期四, 31 三月 2022 11:25:14 +0800 Subject: [PATCH] 完善 --- WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs | 98 ++++++++++++++++++------ WebAPI/Controllers/SCGL/Sc_ComplementGoodBillController.cs | 2 WebAPI/WebAPI.csproj | 2 WebAPI/Controllers/CJGL/Cj_SendGoodsBillController.cs | 119 +++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+), 25 deletions(-) diff --git a/WebAPI/Controllers/CJGL/Cj_SendGoodsBillController.cs b/WebAPI/Controllers/CJGL/Cj_SendGoodsBillController.cs new file mode 100644 index 0000000..f4e8778 --- /dev/null +++ b/WebAPI/Controllers/CJGL/Cj_SendGoodsBillController.cs @@ -0,0 +1,119 @@ +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Pub_Class; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Web.Http; +using WebAPI.Models; + + +namespace WebAPI.Controllers.CJGL +{ + public class Cj_SendGoodsBillController : ApiController + { + private json objJsonResult = new json(); + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + DataSet ds; + + #region 杞﹂棿鏀舵枡鍒楄〃 鏌ヨ + //杩囨护鏉′欢 + public class JIT_SendGoodsBill + { + public DateTime HBeginDate; + public DateTime HEndDate; + public string HBillNo { get; set; } + public string HDeptName { get; set; } + public string MaterialCode { get; set; } + public string MaterialName { get; set; } + public string MaterialModel { get; set; } + public int? HOrgID; + } + + [Route("Cj_SendGoodsBill/Cj_SendGoodsBillList")] + [HttpGet] + public object Cj_SendGoodsBillList(string sWhere,string user) + { + try + { + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("JIT_SendGoodsBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = new DataTable(); + return objJsonResult; + } + + //鍙嶅簭鍒楀寲浼犻�掔殑鍊� + JIT_SendGoodsBill com = JsonConvert.DeserializeObject<JIT_SendGoodsBill>(sWhere.ToString()); + + ds = oCN.RunProcReturn($"exec h_p_JIT_DeptCheckGoodsBillList_Query '{com.HBeginDate}','{com.HEndDate.AddDays(1).AddSeconds(-1)}','{com.HBillNo}','{com.HDeptName}'," + + $"'{com.MaterialCode}','{com.MaterialName}','{com.MaterialModel}','{com.HOrgID}'", "h_p_JIT_DeptCheckGoodsBillList_Query"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 杞﹂棿鏀舵枡鍒楄〃 纭鏀舵枡 + [Route("Cj_SendGoodsBill/DeptCheckGoodsBillList_Check")] + [HttpGet] + public object DeptCheckGoodsBillList_Check(string HInterID,string HEntryID,string User) + { + try + { + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("JIT_SendGoodsBill_Check", 1, false, User)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲鏍告潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + ds = oCN.RunProcReturn($"exec h_p_JIT_DeptCheckGoodsBillList_Check '{HInterID}','{HEntryID}','{User}'", "h_p_JIT_DeptCheckGoodsBillList_Check"); + + objJsonResult.code = ds.Tables[0].Rows[0][0].ToString(); + objJsonResult.count = int.Parse(ds.Tables[0].Rows[0][0].ToString()); + objJsonResult.Message = ds.Tables[0].Rows[0][1].ToString(); + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + } +} \ No newline at end of file diff --git a/WebAPI/Controllers/SCGL/Sc_ComplementGoodBillController.cs b/WebAPI/Controllers/SCGL/Sc_ComplementGoodBillController.cs index 9c3e555..3bb1da8 100644 --- a/WebAPI/Controllers/SCGL/Sc_ComplementGoodBillController.cs +++ b/WebAPI/Controllers/SCGL/Sc_ComplementGoodBillController.cs @@ -69,7 +69,7 @@ ComplementGoodBill com = JsonConvert.DeserializeObject<ComplementGoodBill>(sWhere.ToString()); ds = oCN.RunProcReturn($"exec h_p_JIT_CallGoodsPlatForm_Query '{com.HSeOrderBillNo}','{com.DepartmentName}','{com.MaterialNumber}','{com.MaterialName}'," + - $"'{com.MaterialModel}','{com.HICMOBillNo}','{com.CPNumber}','{com.CPName}','{com.CPModel}','{com.HBeginDate}','{com.HEndDate}'," + + $"'{com.MaterialModel}','{com.HICMOBillNo}','{com.CPNumber}','{com.CPName}','{com.CPModel}','{com.HBeginDate}','{com.HEndDate.AddDays(1).AddSeconds(-1)}'," + $"{com.ps},{com.Organization},'{com.user}' ", "h_p_JIT_CallGoodsPlatForm_Query"); objJsonResult.code = "1"; diff --git a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs index 7ce0f36..2cc29ad 100644 --- a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs +++ b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs @@ -60,9 +60,9 @@ //鍙嶅簭鍒楀寲浼犻�掔殑鍊� ComplementGoods com = JsonConvert.DeserializeObject<ComplementGoods>(sWhere.ToString()); - + ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_Query '{com.MaterialNumber}','{com.MaterialName}','{com.MaterialModel}','{com.HGD}'," + - $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'" ,"h_p_JIT_ComplementGoodsBillList_Query"); + $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'", "h_p_JIT_ComplementGoodsBillList_Query"); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -84,7 +84,7 @@ #region 鎷f枡閰嶉�佸崟 鍒犻櫎 [Route("Sc_ComplementGoods/DelComplementGoodsList")] [HttpGet] - public object DelComplementGoodsList(string HInterID, string HEntryID,string HOrgID, string user) + public object DelComplementGoodsList(string HInterID, string HEntryID, string HOrgID, string user) { try { @@ -100,7 +100,7 @@ ds = oCN.RunProcReturn($"select HISCheck from JIT_SendGoodsBillMain where HMainSourceInterID={HInterID} ", "JIT_SendGoodsBillMain"); - if (ds.Tables[0].Rows.Count>0) + if (ds.Tables[0].Rows.Count > 0) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -202,7 +202,8 @@ #region 浠撳簱鍙戞枡 //鍙傛暟 - public class SendGoodsBill { + public class SendGoodsBill + { public int? 鏈嫞鏂欐暟閲� = 0; public int? 鏈�澶ф嫞鏂欐暟閲� = 0; public int? 鏈鎷f枡鏁伴噺 = 0; @@ -288,32 +289,53 @@ { oCN.BeginTran(); - oCN.RunProc($"delete from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}'"); + //oCN.RunProc($"delete from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}' and HBillStatus=1"); - oCN.RunProc($"delete from JIT_SendGoodsBillSub where HInterID in (select HInterID from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}')"); + //oCN.RunProc($"delete from JIT_SendGoodsBillSub where HInterID in (select HInterID from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}' and HBillStatus=1)"); + + ds = oCN.RunProcReturn($"select a.HMainSourceEntryID,b.HMaterID from JIT_SendGoodsBillMain a with(nolock) inner join JIT_SendGoodsBillSub b with(nolock) on a.HInterID = b.HInterID where a.HMainSourceInterID={SourceInterID} and a.HBillStatus=1", "JIT_SendGoodsBillMain"); for (int i = 0; i < listCa.Count; i++) { - long InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo); - string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true); + int a = -1; + for (int j = 0; j < ds.Tables[0].Rows.Count; j++) + { + if (ds.Tables[0].Rows[j]["HMaterID"].ToString() == listCa[i].HMaterID.ToString()&& ds.Tables[0].Rows[j]["HMainSourceEntryID"].ToString() == listCa[i].HEntryID.ToString()) + { + a = j; + break; + } + } - //娣诲姞涓昏〃鏁版嵁 - oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" + - ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" + - ", HMainSourceBillNo, HMainSourceBillType)" + - $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," + - $" 0,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')"); + //a=0 鍒欎唬琛ㄩ厤閫佸崟娌℃湁鏁版嵁 闇�瑕佹坊鍔犳暟鎹� + if (a == -1 ) + { + long InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true); - //娣诲姞瀛愯〃鏁版嵁 - oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" + - ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate)" + - $"values({InterID},'{HBillNo}',{i}, {listCa[i].HMaterID},{listCa[i].鏈鎷f枡鏁伴噺}," + - $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE())"); + //娣诲姞涓昏〃鏁版嵁 + oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" + + ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" + + ", HMainSourceBillNo, HMainSourceBillType)" + + $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," + + $" 1,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')"); + //娣诲姞瀛愯〃鏁版嵁 + oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" + + ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate)" + + $"values({InterID},'{HBillNo}',{i + 1}, {listCa[i].HMaterID},{listCa[i].鏈鎷f枡鏁伴噺}," + + $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE())"); + } + else + { + //淇敼閰嶉�佸崟鐨勯厤閫佹暟閲� + oCN.RunProc($"update b set b.HQty=b.HQty+{listCa[i].鏈鎷f枡鏁伴噺} from JIT_SendGoodsBillMain a with(nolock) inner join JIT_SendGoodsBillSub b with(nolock) on a.HInterID = b.HInterID " + + $"where HMainSourceInterID ={SourceInterID} and b.HMaterID ={listCa[i].HMaterID} and a.HBillStatus =1 "); + } //淇敼璋冩嫧鏁伴噺 - oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY={listCa[i].鏈鎷f枡鏁伴噺} where HMaterID={listCa[i].HMaterID} " + + oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{listCa[i].鏈鎷f枡鏁伴噺} where HMaterID={listCa[i].HMaterID} " + $" and HSourceInterID=(select top 1 HSourceInterID from JIT_ComplementGoodsBillSub_LK " + - $"where HMaterID={listCa[i].HMaterID} order by HSourceInterID ) and HInterID={SourceInterID}"); + $"where HMaterID={listCa[i].HMaterID} and HInterID={SourceInterID} order by HSourceInterID ) and HInterID={SourceInterID} "); } sReturn = "鏂板鍗曟嵁鎴愬姛锛�"; @@ -322,6 +344,7 @@ } catch (Exception e) { + oCN.RollBack(); sReturn = e.Message; throw (e); } @@ -331,12 +354,39 @@ #region 涓婃煡 [Route("Sc_ComplementGoods/ComplementGoodsList_Sc")] [HttpGet] - public object ComplementGoodsList_Sc(string HInterID,string HEntryID) + public object ComplementGoodsList_Sc(string HInterID, string HMaterID) { try { - ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HEntryID}", "h_p_JIT_ComplementGoodsBillList_UpQuery"); + ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_UpQuery"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嬫煡 + [Route("Sc_ComplementGoods/JIT_SendGoodsBillList_Xc")] + [HttpGet] + public object JIT_SendGoodsBillList_Xc(string HInterID, string HMaterID) + { + try + { + + ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_DownQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_DownQuery"); objJsonResult.code = "1"; objJsonResult.count = 1; diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj index 34d7495..3798f7b 100644 --- a/WebAPI/WebAPI.csproj +++ b/WebAPI/WebAPI.csproj @@ -353,6 +353,7 @@ <Compile Include="Controllers\CJGL\Cj_CallGoodsBillMainController.cs" /> <Compile Include="Controllers\CJGL\Cj_ComplementGoodsBillController.cs" /> <Compile Include="Controllers\CJGL\Cj_NoPassProcController.cs" /> + <Compile Include="Controllers\CJGL\Cj_SendGoodsBillController.cs" /> <Compile Include="Controllers\CJGL\Sc_ProcessExchangeBillController.cs" /> <Compile Include="Controllers\CJGL\Cj_StationOutBillController.cs" /> <Compile Include="Controllers\CJGL\Cj_StationInBillController.cs" /> @@ -784,6 +785,7 @@ <Folder Include="Views\Cj_CallGoodsBillBack\" /> <Folder Include="Views\Cj_CallGoodsBillMain\" /> <Folder Include="Views\Cj_ComplementGoodsBill\" /> + <Folder Include="Views\Cj_SendGoodsBill\" /> <Folder Include="Views\Gy_EquipType\" /> <Folder Include="Views\Gy_ICBomBill\" /> <Folder Include="Views\Gy_RoutingGroup\" /> -- Gitblit v1.9.1