From bc1dda419b3cef845ed90f6c31c6bda82743e19a Mon Sep 17 00:00:00 2001 From: yangle <admin@YINMOU> Date: 星期四, 07 三月 2024 10:19:16 +0800 Subject: [PATCH] 器具档案列表 增加 左边树形 器具分类,点击分类,根据分类来过滤,方便选择 器具档案里,增加字段 HMouldClass varchar(50) 器具类型 下拉框 (模具、工装、夹具、刀具、检具、周转器具、其他) --- WebAPI/Controllers/Sc_AssemblyBillController.cs | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 169 insertions(+), 3 deletions(-) diff --git a/WebAPI/Controllers/Sc_AssemblyBillController.cs b/WebAPI/Controllers/Sc_AssemblyBillController.cs index fa2cfa4..c06489a 100644 --- a/WebAPI/Controllers/Sc_AssemblyBillController.cs +++ b/WebAPI/Controllers/Sc_AssemblyBillController.cs @@ -1,4 +1,6 @@ -锘縰sing System; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Data; using System.Linq; @@ -193,7 +195,7 @@ } if (HICMOBillNo == "" || HICMOBillNo == null) { - ds = oCN.RunProcReturn(@"select b.FMUSTQTY,a.FMOBILLNO,FERPCLSID,t5.FNAME HMaterName_z,t5.FSPECIFICATION HMaterModel_z ,m.HItemID,b.FMATERIALID,m.HName HMaterName,m.HNumber HMaterNumber,m.HModel HMaterModel,m1.HItemID HMaterID + ds = oCN.RunProcReturn(@"select bard.HSourceInterID,bard.HSourceEntryID,b.FMUSTQTY,a.FMOBILLNO,FERPCLSID,t5.FNAME HMaterName_z,t5.FSPECIFICATION HMaterModel_z ,m.HItemID,b.FMATERIALID,m.HName HMaterName,m.HNumber HMaterNumber,m.HModel HMaterModel,m1.HItemID HMaterID from AIS20210811135644..T_PRD_PPBOM a join AIS20210811135644..T_PRD_PPBOMENTRY b on a.FID = b.FID join AIS20210811135644..T_BD_MATERIAL t3 on a.FMATERIALID = t3.FMATERIALID @@ -208,7 +210,7 @@ { objjson.code = "0"; objjson.count = 0; - objjson.Message = "鏃犳簮鍗曪紒"; + objjson.Message = "璇峰厛鎵骇鍝佹潯鐮侊紒"; objjson.data = null; return objjson; } @@ -261,8 +263,172 @@ } #endregion + #region 浜х嚎缁勮杩芥函鍗曚繚瀛� + [Route("Sc_AssemblyBill/AddBill")] + [HttpPost] + public object AddBill([FromBody] JObject sMainSub) + { + var _value = sMainSub["sMainSub"].ToString(); + string msg1 = _value.ToString(); + oCN.BeginTran(); + //淇濆瓨涓昏〃 + objjson = AddBillMain(msg1); + if (objjson.code == "0") + { + oCN.RollBack(); + objjson.code = "0"; + objjson.count = 0; + objjson.Message = objjson.Message; + objjson.data = null; + return objjson; + } + oCN.Commit(); + objjson.code = "1"; + objjson.count = 1; + objjson.Message = "鏂板鍗曟嵁鎴愬姛锛�"; + objjson.data = null; + return objjson; + } + Models.ClsSc_AssemblyBillMain omodel = new Models.ClsSc_AssemblyBillMain();//鍩烘湰璧勬枡 + public json AddBillMain(string msg1) + { + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string msg2 = sArray[0].ToString(); + string msg3 = sArray[1].ToString(); + int OperationType = int.Parse(sArray[2].ToString());//绫诲瀷 + string user = sArray[3].ToString();//鐢ㄦ埛鍚� + try + { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_AssemblyBill_Edit", 1, false, user)) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鏃犳潈闄愮紪杈�!"; + objjson.data = null; + return objjson; + } + omodel = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_AssemblyBillMain>(msg2); + //JSON搴忓垪鍖栬浆鎹㈠瓧鍏搁泦鍚� + List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); + List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3); + foreach (JObject item in jb) + { + Dictionary<string, string> dic = new Dictionary<string, string>(); + foreach (var itm in item.Properties()) + { + dic.Add(itm.Name, itm.Value.ToString()); + } + list.Add(dic); + } + if (OperationType == 1)//鏂板涓存椂琛ㄦ簮鍗曡〃 + { + for (int i = 0; i < list.Count; i++) + { + //涓存椂閰嶄欢琛� + oCN.RunProc("Insert Into Sc_AssemblyBill_BindSourceTemp " + + "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HMaterID" + + ",HQtyMust,HProdOrgID,HSourceEntryID,HSourceBillType,HAuxPropID,HProcID,HQty,HBatchNo,HMTONo,HPlanMode) " + + " values(" + omodel.HInterID.ToString() + "," + (i+1) + ",'" + omodel.HBillNo.ToString() + "','" + omodel.HICMOBillNo.ToString() + "',0," + list[i]["HMaterID"].ToString() + + ",'" + list[i]["HQty"].ToString() + "','" + list[i]["HPRDORGID"].ToString() + "',0,'',0,0,0,'','','') "); + } + } + else if (OperationType == 2)//鏂板閰嶄欢鎵爜琛� + { + for (int i = 0; i < list.Count; i++) + { + if (list[i]["HBarCode"].ToString() != "") + { + ds = oCN.RunProcReturn("select * from Sc_AssemblyBill_BindBarCodeTemp where HSourceBillNo='" + omodel.HICMOBillNo.ToString() + "' and HBarCode='" + list[i]["HBarCode"].ToString() + "' and HBillNo_bak='" + omodel.HBillNo.ToString() + "'", "Sc_AssemblyBill_BindBarCodeTemp"); + if (ds.Tables[0].Rows.Count > 0) { + objjson.code = "0"; + objjson.count = 0; + objjson.Message ="璇ユ潯鐮佸凡鎵叆,鏃犻』鍐嶆壂!"; + objjson.data = null; + return objjson; + } + //涓存椂璁板綍琛� + oCN.RunProc("Insert Into Sc_AssemblyBill_BindBarCodeTemp " + + "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HMaterID" + + ",HBarCode,HQty,HProdOrgID,HSourceEntryID,HSourceBillType,HAuxPropID,HProcID,HBatchNo,HMTONo,HPlanMode) " + + " values(" + omodel.HInterID.ToString() + "," + (i + 1) + ",'" + omodel.HBillNo.ToString() + "','" + omodel.HICMOBillNo.ToString() + "',0," + list[i]["HMaterID"].ToString() + + ",'" + list[i]["HBarCode"].ToString() + "','" + list[i]["HEQty"].ToString() + "','" + list[i]["HPRDORGID"].ToString() + "',0,'',0,0,'','','') "); + } + } + } + else if (OperationType == 3)//鏂板涓诲瓙琛� + { + //淇濆瓨鐢熶骇缁勮鍗曚富琛� + string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate +,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo +,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID) +values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{omodel.HInterID.ToString()},getdate() +,'{omodel.HBillNo.ToString()}','1','{user}',getdate(),{omodel.HICMOInterID.ToString()},{omodel.HICMOEntryID.ToString()},'{omodel.HICMOBillNo.ToString()}' +,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{omodel.HBarCode_P.ToString()}',{omodel.HMaterID},0,'{omodel.HAssemblyStatus}',{omodel.HProdOrgID})"; + oCN.RunProc(sql); + + ds = oCN.RunProcReturn("select * from Sc_AssemblyBill_BindBarCodeTemp where HSourceBillNo='" + omodel.HICMOBillNo.ToString() + "' and HInterID='" + omodel.HInterID + "' and HBillNo_bak='" + omodel.HBillNo.ToString() + "'", "Sc_AssemblyBill_BindBarCodeTemp"); + + for (int i = 0; i < ds.Tables[0].Rows.Count; i++) + { + int HMaterID = int.Parse(ds.Tables[0].Rows[i]["HMaterID"].ToString()); + double HQty = double.Parse(ds.Tables[0].Rows[i]["HQty"].ToString()); + string HBarCode = ds.Tables[0].Rows[i]["HBarCode"].ToString(); + string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo +,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty +,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber) +values({omodel.HInterID},'{omodel.HBillNo}',{(i + 1)},0,0,'' +,'',{HMaterID},0,0,0,{HQty} +,0,0,getdate(),'{HBarCode}','{omodel.HBarCode_P}','') "; + oCN.RunProc(sq2); + } + } + + objjson.code = "1"; + objjson.count = 1; + objjson.Message = null; + objjson.data = null; + return objjson; + } + catch (Exception e) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "Exception锛�" + e.ToString(); + objjson.data = null; + return objjson; + } + } + #endregion + + #region 浜х嚎缁勮杩芥函鍗� 鏌ヨ + [Route("Sc_AssemblyBill/Sc_AssemblyBillAddList")] + [HttpGet] + public object Sc_AssemblyBillAddList(string sWhere) + { + try + { + ds = oCN.RunProcReturn(@"select * from h_v_Sc_AssemblyBillList where 1=1 " + sWhere, "h_v_Sc_AssemblyBillList"); + + objjson.code = "1"; + objjson.count = 1; + objjson.Message = ""; + objjson.data = ds.Tables[0]; + return objjson; + } + catch (Exception e) + { + + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString(); + objjson.data = null; + return objjson; + } + } + #endregion [Route("Assembly/Delete_Json")] [HttpGet] -- Gitblit v1.9.1