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/ListModels.cs | 14 + DAL/系统公用/ClsXt_BillSubType_Ctl.cs | 104 +++++++++++++ DAL/DAL.csproj | 1 Model/系统公用/ClsXt_BillSubType_Model.cs | 22 ++ Model/Model.csproj | 1 WebAPI/WebAPI.csproj | 2 WebAPI/Controllers/BLL/Xt_BillSubTypeController.cs | 336 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 479 insertions(+), 1 deletions(-) diff --git a/DAL/DAL.csproj b/DAL/DAL.csproj index f092791..d40e497 100644 --- a/DAL/DAL.csproj +++ b/DAL/DAL.csproj @@ -611,6 +611,7 @@ <Compile Include="鐢熶骇绠$悊\璁惧绠$悊\璁惧鎶曚骇\ClsSb_EquipStockInCheckBill.cs" /> <Compile Include="鐢熶骇绠$悊\璁惧绠$悊\ClsSb_EquipStatusChangeBill.cs" /> <Compile Include="鐢熶骇绠$悊\璁惧绠$悊\璁惧鎶曚骇\ClsSb_EquipWorkBeforeCheckBill.cs" /> + <Compile Include="绯荤粺鍏敤\ClsXt_BillSubType_Ctl.cs" /> <Compile Include="璐ㄦ绠$悊\ClsQC_FirstPieceCheckBill.cs" /> <Compile Include="璐ㄦ绠$悊\ClsQC_LastPieceCheckBill.cs" /> <Compile Include="璐ㄦ绠$悊\ClsQC_NoPassProdCheckBill.cs" /> diff --git "a/DAL/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Ctl.cs" "b/DAL/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Ctl.cs" new file mode 100644 index 0000000..d5ee902 --- /dev/null +++ "b/DAL/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Ctl.cs" @@ -0,0 +1,104 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Data; + +namespace DAL +{ + public class ClsXt_BillSubType_Ctl : DBUtility.ClsGy_Base_Ctl + { + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + //鍘熶唬鐮� 鐢ㄤ簬 鏇挎崲瀛愰」鐩� + public string HOldNumber; + public Model.ClsXt_BillSubType_Model oModel = new Model.ClsXt_BillSubType_Model(); + //鏂板 + public override bool AddNew() + { + + try + { + oCn.BeginTran(); + oCn.RunProc($@"insert into Xt_BillSubType(HNumber ,HName ,HShortNumber ,HParentID ,HLevel + ,HEndFlag ,HStopflag ,HRemark ,HHelpCode ,HUseFlag + ,HMakeTime ,HMakeEmp ,HCheckEmp ,HCheckTime ,HModifyEmp + ,HModifyTime ,HStopEmp ,HStopTime ,HUSEORGID,HCREATEORGID ,HBillType ,HIsDefault ,HBillTypeID) + values('{oModel.HNumber}','{oModel.HName}','{oModel.HShortNumber}',{oModel.HParentID}, + {oModel.HLevel},{(oModel.HEndFlag == true ? 1 : 0)},{(oModel.HStopflag == true ? 1 : 0)}, + '{oModel.HRemark}','{oModel.HHelpCode}','{oModel.HUseFlag}',GETDATE(),'{oModel.HMakeEmp}','','','' + ,'','','',{oModel.HUSEORGID},{oModel.HCREATEORGID},{oModel.HBillType},{0},'')" + , ref DBUtility.ClsPub.sExeReturnInfo); + //淇敼涓婄骇涓洪潪鏈骇浠g爜 + oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); + oCn.Commit(); + return true; + } + catch (Exception e) + { + oCn.RollBack(); + throw (e); + } + } + + //淇敼 + public override bool ModifyByID(Int64 sItemID) + { + try + { + oCn.BeginTran(); + oCn.RunProc("Update " + MvarItemKey + " set " + + " HNumber='" + oModel.HNumber + "'" + + ",HName='" + oModel.HName + "'" + + ",HBillType='" + oModel.HBillType + "'" + + ",HShortNumber='" + oModel.HShortNumber + "'" + + ",HParentID=" + oModel.HParentID.ToString() + + ",HLevel=" + oModel.HLevel.ToString() + + ",HEndflag=" + Convert.ToString(oModel.HEndFlag ? 1 : 0) + + ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) + + ",HRemark= '" + oModel.HRemark + "'" + + ",HHelpCode='" + oModel.HHelpCode + "'" + + ",HModifyEmp ='" + oModel.HMakeEmp + "'" + + ",HModifyTime =getdate()" + + " Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo); + //淇敼瀛愰」鐩唬鐮� + //oCn.RunProc("exec h_p_Gy_UpdateNumber '" + MvarItemKey + "','" + oModel.HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); + //灏嗕笂绾� 涓洪潪鏈骇 + oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); + // + oCn.Commit(); + return true; + } + catch (Exception e) + { + oCn.RollBack(); + throw (e); + } + } + //鏍规嵁浠g爜鍒ゆ柇淇℃伅 + public override bool HavParentCode(string sCode, Int64 sItemID) + { + DataSet DS; + try + { + DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HStopflag=0 and HNumber='" + sCode + "' and HItemID<>" + sItemID, MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo); + if (DS.Tables[0].Rows.Count == 0) + return false; + else + { + oModel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]); + return true; + } + } + catch (Exception e) + { + throw (e); + } + } + //鏋勯�犲嚱鏁� + public ClsXt_BillSubType_Ctl() + { + MvarItemKey = "Xt_BillSubType"; + MvarReportTitle = "鍗曟嵁瀛愮被鍨�"; + oModel = new Model.ClsXt_BillSubType_Model(); + } + } +} diff --git a/Model/Model.csproj b/Model/Model.csproj index 0a816cb..959d818 100644 --- a/Model/Model.csproj +++ b/Model/Model.csproj @@ -619,6 +619,7 @@ <Compile Include="绯荤粺鍏敤\ClsOA_EmpMessageBillModSub.cs" /> <Compile Include="绯荤粺鍏敤\ClsOA_FieldToChangeMain.cs" /> <Compile Include="绯荤粺鍏敤\ClsOA_FieldToChangeSub.cs" /> + <Compile Include="绯荤粺鍏敤\ClsXt_BillSubType_Model.cs" /> <Compile Include="绯荤粺鍏敤\ClsXt_BillType_Model.cs" /> <Compile Include="绯荤粺鍏敤\ClsXt_ModuleParameterMain.cs" /> <Compile Include="绯荤粺鍏敤\ClsXt_ModuleParameterSub.cs" /> diff --git "a/Model/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Model.cs" "b/Model/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Model.cs" new file mode 100644 index 0000000..6cfc50a --- /dev/null +++ "b/Model/\347\263\273\347\273\237\345\205\254\347\224\250/ClsXt_BillSubType_Model.cs" @@ -0,0 +1,22 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Model +{ + public class ClsXt_BillSubType_Model : DBUtility.ClsGy_Base_Model + { + public DateTime HMakeTime; //寤虹珛鏃堕棿(getdate()) + public string HMakeEmp; //鍒涘缓浜� + public string HCheckEmp; //瀹℃牳浜� + public DateTime HCheckTime; //瀹℃牳鏃堕棿 + public string HModifyEmp; //淇敼浜� + public DateTime HModifyTime; //淇敼鏃堕棿 + public string HStopEmp; //绂佺敤浜� + public DateTime HStopTime; //绂佺敤鏃堕棿 + public Int64 HUSEORGID; //浣跨敤缁勭粐锛圶t_ORGANIZATIONS锛� + public Int64 HCREATEORGID; //鍒涘缓缁勭粐锛圶t_ORGANIZATIONS锛� + public string HBillType; + } +} diff --git a/WebAPI/Controllers/BLL/Xt_BillSubTypeController.cs b/WebAPI/Controllers/BLL/Xt_BillSubTypeController.cs new file mode 100644 index 0000000..4fa5ac1 --- /dev/null +++ b/WebAPI/Controllers/BLL/Xt_BillSubTypeController.cs @@ -0,0 +1,336 @@ +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using WebAPI.Models; + +namespace WebAPI.Controllers +{ + public class Xt_BillSubTypeController : ApiController + { + private json objJsonResult = new json(); + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + DataSet ds; + + #region 鍗曟嵁瀛愮被鍨� 鍒楄〃 + [Route("Xt_BillSubType/List")] + [HttpGet] + public object Xt_BillSubTypeList(string sWhere, string user, string Organization) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log_second("Xt_BillSubType_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + string sql1 = string.Format(@"select * from h_v_Xt_BillSubTypeList where 1='" + 1 + "'"); + + string sql = sql1 + sWhere; + ds = oCN.RunProcReturn(sql, "h_v_Xt_BillSubTypeList"); + + //娣诲姞鍒楀悕 + 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鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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("Xt_BillSubType/Edit")] + [HttpPost] + public object Xt_BillSubTypeEdit([FromBody] JObject msg) + { + DataSet ds; + var _value = msg["msg"].ToString(); + string msg3 = _value.ToString(); + string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string msg1 = sArray[0].ToString(); + string msg2 = sArray[1].ToString(); + //string msg_HUSEORGID = sArray[2].ToString(); + Int64 HItemID = 0; + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + + ////缂栬緫鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log_second("Xt_BillSubType_Edit", 1, false, msg2)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + ListModels oListModels = new ListModels(); + + try + { + DAL.ClsXt_BillSubType_Ctl oBill = new DAL.ClsXt_BillSubType_Ctl(); + List<Model.ClsXt_BillSubType_Model> lsmain = new List<Model.ClsXt_BillSubType_Model>(); + msg1 = msg1.Replace("\\", ""); + msg1 = msg1.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_Xt_BillSubType(msg1); + foreach (Model.ClsXt_BillSubType_Model oItem in lsmain) + { + if (oItem.HNumber.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷笉鑳戒负绌猴紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oItem.HName.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佸悕绉颁笉鑳戒负绌猴紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮� + ds = oCN.RunProcReturn("select * from Xt_BillSubType where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Xt_BillSubType"); + if (oItem.HItemID == 0) + { + if (ds.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + if (ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HItemID"].ToString() != oItem.HItemID.ToString()) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + + + //鏂板鏃跺垽鏂� + + if (oItem.HItemID == 0) + { + if (ds == null || ds.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦� + string sParent; + sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); + if (sParent.Trim() == "") + { + oBill.oModel.HParentID = 0; + } + else + { + if (oBill.HavParentCode(sParent.Trim(), HItemID)) + { + oBill.oModel.HParentID = oBill.oModel.HItemID; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + } + } + else//缂栬緫鏃跺垽鏂� + { + //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦� + string sParent; + sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); + if (sParent.Trim() == "") + { + oBill.oModel.HParentID = 0; + } + else + { + if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID)) + { + oBill.oModel.HParentID = oBill.oModel.HItemID; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + } + } + + //寰楀埌鐭唬鐮� + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); + if (sShortNumber.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + //oItem.HUSEORGID = Convert.ToInt32(msg_HUSEORGID); //缁勭粐id + oItem.HShortNumber = sShortNumber;//鐭唬鐮� + oItem.HEndFlag = true;//鏈骇鏍囧織 + oItem.HLevel = 1; //绛夌骇 DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()) + oBill.oModel = oItem; + } + //淇濆瓨 + //淇濆瓨瀹屾瘯鍚庡鐞� + bool bResult; + if (oBill.oModel.HItemID == 0) + { + bResult = oBill.AddNew(); + } + else + { + bResult = oBill.ModifyByID(oBill.oModel.HItemID); + } + if (bResult) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 鍗曟嵁瀛愮被鍨� 鍒犻櫎 + [Route("Xt_BillSubType/Delete")] + [HttpGet] + public object Delete(string HItemID, string user) + { + DataSet ds; + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + ////鍒犻櫎鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Xt_BillSubType_Drop", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犲垹闄ゆ潈闄�"; + // objJsonResult.data = null; + // return objJsonResult; + //} + if (string.IsNullOrWhiteSpace(HItemID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HItemID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + oCN.BeginTran();//寮�濮嬩簨鍔� + ds = oCN.RunProcReturn("select * from Xt_BillSubType where HItemID=" + HItemID, "Xt_BillSubType"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; + objJsonResult.data = null; + return objJsonResult; ; + } + var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]); + if (HStopflag) + { + oCN.RollBack();//鍥炴粴浜嬪姟 + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏁版嵁宸茬鐢ㄦ棤娉曞垹闄わ紒"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.RunProc("delete from Xt_BillSubType where HItemID=" + HItemID); + 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 + + } +} \ No newline at end of file diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs index 3c9a568..2e51f32 100644 --- a/WebAPI/ListModels.cs +++ b/WebAPI/ListModels.cs @@ -1123,7 +1123,19 @@ List<Model.ClsXt_BillType_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsXt_BillType_Model>>(jsonString); return list; } - + + /// <summary> + /// 澶勭悊鍗曟嵁瀛愮被鍨嬭〃鐨刯son + /// </summary> + /// <param name="jsonString"></param> + /// <returns></returns> + public List<Model.ClsXt_BillSubType_Model> getObjectByJson_Xt_BillSubType(string jsonString) + { + jsonString = "[" + jsonString.ToString() + "]"; + List<Model.ClsXt_BillSubType_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsXt_BillSubType_Model>>(jsonString); + return list; + } + /// <summary> /// 澶勭悊鏀舵鏉′欢琛ㄧ殑json /// </summary> diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj index d05c0b1..5825756 100644 --- a/WebAPI/WebAPI.csproj +++ b/WebAPI/WebAPI.csproj @@ -365,6 +365,7 @@ <Compile Include="Controllers\BaseSet\Xt_grdAlignment_WMESController.cs" /> <Compile Include="Controllers\BaseSet\Xt_ORGANIZATIONSController.cs" /> <Compile Include="Controllers\BLL\Xt_AccountPeriodController.cs" /> + <Compile Include="Controllers\BLL\Xt_BillSubTypeController.cs" /> <Compile Include="Controllers\BLL\Xt_BillTypeController.cs" /> <Compile Include="Controllers\BLL\Xt_UserGroupController.cs" /> <Compile Include="Controllers\BLL\Xt_XtgnbController.cs" /> @@ -974,6 +975,7 @@ <Folder Include="Views\Sc_WorkBillAutoSortBillMain\" /> <Folder Include="Views\Sc_WorkBillSortBill\" /> <Folder Include="Views\Sc_WorkDemandPlanBill\" /> + <Folder Include="Views\Xt_BillSubType\" /> <Folder Include="Views\Xt_CheckFlowBill\" /> <Folder Include="Views\Xt_CheckItem\" /> <Folder Include="Views\Xt_grdAlignment_WMES\" /> -- Gitblit v1.9.1