WebAPI/Controllers/BarCodeController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/POInStockController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/POOrderController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/WebAPIController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/Xt_grdAlignment_WMESController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/DLL/DAL.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/DLL/Model.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/JsonResult.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/json.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Utility/HttpHelper.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/WebAPI.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/bin.7z | 补丁 | 查看 | 原始文档 | blame | 历史 | |
全部客户在运用.txt | 补丁 | 查看 | 原始文档 | blame | 历史 |
WebAPI/Controllers/BarCodeController.cs
@@ -13,6 +13,8 @@ using System.Web.Script.Serialization; using WebAPI.Code; using WebAPI.Models; using WebAPI.Utility; namespace WebAPI.Controllers { @@ -21,7 +23,8 @@ private JsonResult objJsonResult = new JsonResult(); private json objjson = new json(); public new ClsCNSRM oCn = new ClsCNSRM(); //è·åç³»ç»åæ° Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public T ScriptDeserialize<T>(string strJson) { JavaScriptSerializer js = new JavaScriptSerializer(); @@ -494,6 +497,7 @@ /// <returns></returns> public object GetBarcodeSaveBill_Box([FromBody] JObject msg) { string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); @@ -525,33 +529,9 @@ foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { //if (oBill.CheckBarCode(oItemSub.HSourceInterID, oItemSub.HSourceEntryID) == false) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "å·²å卿¡ç ï¼ä¸å 许éå¤çæï¼"; // objJsonResult.data = null; // return objJsonResult; //} if (msg2 != string.Empty) { if (oItemSub.HBQty == 0 || oItemSub.HMinQty == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å ç®±å è£ æ°ä¸è½ä¸º0ï¼"; objJsonResult.data = null; return objJsonResult; } if (oItemSub.HWBQty == 0 || oItemSub.HWXQty == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å¤ç®±å è£ æ°ä¸è½ä¸º0ï¼"; objJsonResult.data = null; return objJsonResult; } } //æ°é为0 è·³è¿ if (oItemSub.HQty == 0 || oItemSub.HMinQty == 0 || oItemSub.HWXQty == 0) continue; } long linterid = Pub_Class.ClsPub.CreateBillID_SRMProd("8888", ref DBUtility.ClsPub.sExeReturnInfo); int LSHlen = 6; //æµæ°´å·é¿åº¦ @@ -733,6 +713,7 @@ } } } string HBarCode = ""; string HBarCodeType = ""; Int64 HMaterID = 0; @@ -752,6 +733,11 @@ string HWei = ""; string HMTONO = ""; oCn.BeginTran(); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { //æ´æ°æ¡ç æ¡£æ¡ è¯¥æºåå ¶å®æ¡ç é»è®¤å·²ç»æå°è¿ä¸æ¬¡ oCn.RunProc($"update Gy_BarCodeBill set HPrintQty += 1 where HPrintQty = 0 and HSourceInterID={oItemSub.HSourceInterID} and HSourceEntryID = {oItemSub.HSourceEntryID}"); } foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub in ls2) { //LogService.Write("循ç¯ç¬¬äºæ¬¡:" + oItemSub.HSupID); @@ -774,6 +760,11 @@ HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); if (FCusName.Contains("å¤å®")) { HBarCode = $"{oItemSub.HMaterID}"; HBarCodeType = "åç§ç _å¤ç®±"; } string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + @@ -809,6 +800,11 @@ HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); if (FCusName.Contains("å¤å®")) { HBarCode = $"{oItemSub.HMaterID}"; HBarCodeType = "åç§ç "; } string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + @@ -873,6 +869,7 @@ /// <returns></returns> public object GetBarcodeSaveBillOnlyInnerBox([FromBody] JObject msg) { string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); @@ -900,30 +897,6 @@ List<Model.ClsGy_MaterialList_WMS_Model> ls = new List<Model.ClsGy_MaterialList_WMS_Model>(); List<Model.ClsGy_BarCodeBill_WMS_Model> ls2 = new List<Model.ClsGy_BarCodeBill_WMS_Model>(); ls = oListModels.getObjectByJson_MaterialList(msg3); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { if (CheckBarCode(oItemSub.HSourceInterID, oItemSub.HSourceEntryID) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å·²å卿¡ç ï¼ä¸å 许éå¤çæï¼"; objJsonResult.data = null; return objJsonResult; } if (msg2 != string.Empty) { if (oItemSub.HBQty == 0 || oItemSub.HMinQty == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å ç®±å è£ æ°ä¸è½ä¸º0ï¼"; objJsonResult.data = null; return objJsonResult; } } } long linterid = Pub_Class.ClsPub.CreateBillID_SRMProd("8888", ref DBUtility.ClsPub.sExeReturnInfo); int LSHlen = 6; //æµæ°´å·é¿åº¦ int SumLen = 10; //æ»é¿åº¦ @@ -940,6 +913,20 @@ LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { //æ°é为0 è·³è¿ if (oItemSub.HQty == 0) continue; //æ£éªæå°æ°éï¼HQTYï¼åæªæå°æ°é string sql = $"select HQty -HBarcodeCount as HNotBarcodeCount ,* from Cg_POOrderBillSub where HEntryID = {oItemSub.HSourceEntryID}"; DataSet ds = oCn.RunProcReturn(sql, "tables"); if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) < oItemSub.HQty) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"ç©æç¼ç {oItemSub.HMaterNumber}ï¼æ¬æ¬¡çææ¡ç æ°éä¸è½è¶ åºæªçææ¡ç æ°é"; objJsonResult.data = null; return objJsonResult; } //å ç®± if (ClsPub.isLong(oItemSub.HMaterID) != 0) { @@ -999,6 +986,11 @@ oCn.BeginTran(); foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub in ls2) { //æ´æ°æ¡ç æ¡£æ¡ è¯¥æºåå ¶å®æ¡ç é»è®¤å·²ç»æå°è¿ä¸æ¬¡ oCn.RunProc($"update Gy_BarCodeBill set HPrintQty += 1 where HPrintQty = 0 and HSourceInterID={oItemSub.HSourceInterID} and HSourceEntryID = {oItemSub.HSourceEntryID}"); } foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub in ls2) { if (ClsPub.isLong(oItemSub.HMaterID) != 0) { HBarCode = oItemSub.HBarCode.ToString(); @@ -1031,8 +1023,27 @@ } } //ææ¶åªåå¡«å ³èæ°é string _sql = "exec H_p_SRM_BarCodeBill_Update_UpdateBillRelateData " + linterid.ToString(); oCn.RunProc(_sql); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { if (oItemSub.HQty == 0) continue; //æ´æ°æ¡ç æ¡£æ¡ è¯¥æºåå ¶å®æ¡ç é»è®¤å·²ç»æå°è¿ä¸æ¬¡ //æ´æ° å·²æå°æ°é if (oItemSub.HSourceBillType == "1102") { string _HBarCodeType = "ç®±å·æ¡ç "; if (FCusName.Contains("å¤å®")) _HBarCodeType = "åç§ç "; string sql = string.Empty; sql = string.Format(@" update t1 set t1.HBarcodeCount = isnull((select sum(HQty)from Gy_BarCodeBill where HSourceInterID = t1.HInterID and HSourceEntryID = t1.HEntryID and HBarCodeType ='{2}'),0) from Cg_POOrderBillSub t1 where t1.HInterID = {0} and t1.HEntryID ={1}", oItemSub.HSourceInterID, oItemSub.HSourceEntryID, _HBarCodeType); oCn.RunProc(sql); } } oCn.Commit(); } catch (Exception e) @@ -1447,15 +1458,12 @@ /// <summary> /// æ¡ç çæè¡¨ä½ï¼éè´è®¢åï¼ /// </summary> /// <param name="sMsg"></param> /// <param name="sMsg">éè´è®¢åHinterID</param> /// <returns></returns> public object GetHBarCodeShowBillSubBycg(string sMsg) { try { DataSet ds; string s = ""; string ShowItem = " * ";//æ¾ç¤ºçåæ®µ if (DBUtility.ClsPub.isLong(sMsg) == 0) { objjson.code = "0"; @@ -1464,9 +1472,18 @@ objjson.data = null; return objjson; } //é¢å¤ç ä¿®æ¹éè´è®¢åçéææ°é var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName"); string sql = $@"update t1 set t1.HMrbQty = t2.FMRBQTY from Cg_POOrderBillSub t1 join {kdTbaleName}..T_PUR_POORDERENTRY_R t2 on t1.HEntryID = t2.FENTRYID where t1.HInterID = {sMsg} ";//sMsg éè´è®¢åhinterid oCn.RunProc(sql); DAL.ClsWeb_BarCodeBill oClsWeb_BarCodeBill = new DAL.ClsWeb_BarCodeBill(); string sql = string.Format(@"select * from h_v_Cg_POOrderBillSub_ForWeb2 where HInterID = " + sMsg); ds = oCn.RunProcReturn(sql, "h_v_Cg_POOrderBillSub_ForWeb2"); sql = string.Format(@"select * from h_v_Cg_POOrderBillSub_ForWeb2 where HInterID = " + sMsg); DataSet ds = oCn.RunProcReturn(sql, "h_v_Cg_POOrderBillSub_ForWeb2"); //ds = oClsWeb_BarCodeBill.ShowBillSub(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo); if (ds == null || ds.Tables[0].Rows.Count == 0) { @@ -1505,11 +1522,12 @@ /// <returns></returns> public object GetBarcodeSaveBillBoxBycg([FromBody] JObject msg) { string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg2 = sArray[0].ToString();// string msg3 = sArray[1].ToString();// string UserName = ""; ListModels oListModels = new ListModels(); try @@ -1523,46 +1541,15 @@ UserName = oItem.HMaker; } DAL.ClsWeb_BarCodeBill oBill = new DAL.ClsWeb_BarCodeBill(); msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n List<Model.ClsGy_MaterialList_WMS_Model> ls = new List<Model.ClsGy_MaterialList_WMS_Model>(); List<Model.ClsGy_BarCodeBill_WMS_Model> ls2 = new List<Model.ClsGy_BarCodeBill_WMS_Model>(); List<Model.ClsGy_BarCodeBill_WMS_Model> ls3 = new List<Model.ClsGy_BarCodeBill_WMS_Model>(); ls = oListModels.getObjectByJson_MaterialList(msg3); List<Model.ClsGy_BarCodeBill_WMS_Model> ls2 = new List<Model.ClsGy_BarCodeBill_WMS_Model>();//å¤ç®±model List<Model.ClsGy_BarCodeBill_WMS_Model> ls3 = new List<Model.ClsGy_BarCodeBill_WMS_Model>();//å ç®±model foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { if (oBill.CheckBarCode(oItemSub.HSourceInterID, oItemSub.HSourceEntryID) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å·²å卿¡ç ï¼ä¸å 许éå¤çæï¼"; objJsonResult.data = null; return objJsonResult; } if (msg2 != string.Empty) { if (oItemSub.HBQty == 0 || oItemSub.HMinQty == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å ç®±å è£ æ°ä¸è½ä¸º0ï¼"; objJsonResult.data = null; return objJsonResult; } if (oItemSub.HWBQty == 0 || oItemSub.HWXQty == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "å¤ç®±å è£ æ°ä¸è½ä¸º0ï¼"; objJsonResult.data = null; return objJsonResult; } } } ls = oListModels.getObjectByJson_MaterialList(msg3);//åè¡¨æ°æ®model long linterid = Pub_Class.ClsPub.CreateBillID_SRMProd("8888", ref DBUtility.ClsPub.sExeReturnInfo); int LSHlen = 6; //æµæ°´å·é¿åº¦ int SumLen = 10; //æ»é¿åº¦ @@ -1581,12 +1568,47 @@ string WeiShu = ""; //å°¾æ° DataSet Ds; SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); oCn.BeginTran(); Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH"); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { //æ°é为0 è·³è¿ if (oItemSub.HQty == 0 || oItemSub.HMinQty == 0 || oItemSub.HWXQty == 0) continue; //æ£éªæå°æ°éï¼HQTYï¼åæªæå°æ°é string sql = $"select HQty + isnull(HMrbQty,0) - HBarcodeCount as HNotBarcodeCount ,* from Cg_POOrderBillSub where HEntryID = {oItemSub.HSourceEntryID}"; DataSet ds = oCn.RunProcReturn(sql, "tables"); if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) < oItemSub.HQty) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"ç©æç¼ç {oItemSub.HMaterNumber}ï¼æ¬æ¬¡çææ¡ç æ°éä¸è½è¶ åºæªçææ¡ç æ°é"; objJsonResult.data = null; return objJsonResult; } //æ ¡éªæ¹å· å çäº§æ¥æ sql = $"select top 1 HKFDate from Gy_BarCodeBill where HSupID = '{oItemSub.HSupID}' and HBatchNo = '{oItemSub.HBatchNo.TrimStart().TrimEnd()}' and HMaterID ={oItemSub.HMaterID} and isnull(HKFDate, '') <> ''"; LogService.Write($"sql:{sql}"); DataTable dt = oCn.RunProcReturn(sql, "tables").Tables[0]; if (dt.Rows.Count > 0) { LogService.Write($"HKFDate:{dt.Rows[0][0]}"); sql = $"select DATEDIFF(D,{dt.Rows[0][0]},{oItemSub.HKFDate})"; ds = oCn.RunProcReturn(sql, "tables2"); LogService.Write($"DATEDIFF:{Convert.ToInt32(ds.Tables[0].Rows[0][0])}"); if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"ç©æç¼ç {oItemSub.HMaterNumber}ï¼æ¹å·{oItemSub.HBatchNo.TrimStart().TrimEnd()},çäº§æ¥æä¸º{dt.Rows[0][0]},è¯·æ ¸å¯¹"; objJsonResult.data = null; return objJsonResult; } } if (ClsPub.isLong(oItemSub.HMaterID) != 0) { HNumber = oItemSub.HMaterID.ToString(); //HNumber = HNumber.Replace(".", ""); //HQty = Math.Ceiling(HBQty + ClsPub.isDoule(oItemSub.HWBQty)); @@ -1596,8 +1618,8 @@ HSumQty = ClsPub.isDoule(oItemSub.HQty); //äº§åæ°é for (int i = 0; i < HBQty; i++) { // å®çæ¡ç è§åï¼ç©æç¼ç ï¼ç³»ç»ä»£å ¥ï¼@ç©æåç§°ï¼ç³»ç»ä»£å ¥ï¼@è§æ ¼åå·ï¼ç³»ç»ä»£å ¥ï¼@çäº§æ¥æï¼æå·¥è¾å ¥ï¼@æ°éï¼æå·¥è¾å ¥ï¼@å¤±ææ¥æï¼æå·¥è¾å ¥ï¼@æ¹æ¬¡å·ï¼æå·¥ä»£å ¥ï¼@ä¾åºååç§°ï¼ç³»ç»ä»£å ¥ï¼@éè´è®¢åå·ï¼ç³»ç»ä»£å ¥ï¼ TM = $"{oItemSub.HMaterNumber}@{oItemSub.HMaterName}@{oItemSub.HMaterModel}@{oItemSub.HKFDate}@{oItemSub.HQty}@{oItemSub.HKFDQDate}@{oItemSub.HBatchNo}@{oItemSub.HSupName}@{oItemSub.HSourceBillNo}"; //// å®çæ¡ç è§åï¼ç©æç¼ç ï¼ç³»ç»ä»£å ¥ï¼@ç©æåç§°ï¼ç³»ç»ä»£å ¥ï¼@è§æ ¼åå·ï¼ç³»ç»ä»£å ¥ï¼@çäº§æ¥æï¼æå·¥è¾å ¥ï¼@æ°éï¼æå·¥è¾å ¥ï¼@å¤±ææ¥æï¼æå·¥è¾å ¥ï¼@æ¹æ¬¡å·ï¼æå·¥ä»£å ¥ï¼@ä¾åºååç§°ï¼ç³»ç»ä»£å ¥ï¼@éè´è®¢åå·ï¼ç³»ç»ä»£å ¥ï¼ //TM = $"{oItemSub.HMaterNumber}@{oItemSub.HMaterName}@{oItemSub.HMaterModel}@{oItemSub.HKFDate}@{oItemSub.HQty}@{oItemSub.HKFDQDate}@{oItemSub.HBatchNo}@{oItemSub.HSupName}@{oItemSub.HSourceBillNo}"; if (HSumQty - HMinQty > 0) { @@ -1617,7 +1639,36 @@ HMinQty = HSumQty; } //å®çæ¡ç è§åï¼ç©æç¼ç ï¼ç³»ç»ä»£å ¥ï¼@ç©æåç§°ï¼ç³»ç»ä»£å ¥ï¼@è§æ ¼åå·ï¼ç³»ç»ä»£å ¥ï¼@çäº§æ¥æï¼æå·¥è¾å ¥ï¼@æ°éï¼æå·¥è¾å ¥ï¼@å¤±ææ¥æï¼æå·¥è¾å ¥ï¼@æ¹æ¬¡å·ï¼æå·¥ä»£å ¥ï¼@ä¾åºååç§°ï¼ç³»ç»ä»£å ¥ï¼@éè´è®¢åå·ï¼ç³»ç»ä»£å ¥ï¼ TM = $"{oItemSub.HMaterNumber}@{oItemSub.HMaterName}@{oItemSub.HMaterModel}@{oItemSub.HKFDate}@{HMinQty}@{oItemSub.HKFDQDate}@{oItemSub.HBatchNo.TrimStart().TrimEnd()}@{oItemSub.HSupName}@{oItemSub.HSourceBillNo}"; Model.ClsGy_BarCodeBill_WMS_Model bar = new Model.ClsGy_BarCodeBill_WMS_Model(); var HBarCode_verify = TM.Split('@'); //æ ¡éªæ¡ç ä¿¡æ¯ var HMaterNumber_verify = HBarCode_verify[0]; //æ ¡éªç©æç¼ç var HMaterName_verify = HBarCode_verify[1]; //æ ¡éªç©æåç§° var HMaterModel_verify = HBarCode_verify[2]; //æ ¡éªè§æ ¼åå· var HSupName_verify = HBarCode_verify[7]; //æ ¡éªä¾åºå var HSourceBillNo_verify = HBarCode_verify[8]; //æ ¡éªéè´è®¢åå· sql = $"select * from Gy_Material where HNumber = '{HMaterNumber_verify}' and HName = '{HMaterName_verify}' and HModel = '{HMaterModel_verify}'"; DataSet verifyMatInfo = oCn.RunProcReturn(sql, "tables"); sql = $"select * from Cg_POOrderBillMain where HBillNo = '{HSourceBillNo_verify}'"; DataSet verifyBillInfo = oCn.RunProcReturn(sql, "tables"); sql = $"select * from Gy_Supplier where HName = '{HSupName_verify}'"; DataSet verifySupInfo = oCn.RunProcReturn(sql, "tables"); if (verifyMatInfo.Tables[0].Rows.Count <= 0 || verifyBillInfo.Tables[0].Rows.Count <= 0 || verifySupInfo.Tables[0].Rows.Count <= 0) { oCn.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"æ¡ç ä¿¡æ¯æ ¡éªåºéï¼è¯·éæ°çææ¡ç "; objJsonResult.data = null; return objJsonResult; } bar.HBarCode = TM; bar.HMaterID = oItemSub.HMaterID; //bar.HMaterNumber = oItemSub.HMaterNumber; @@ -1644,6 +1695,7 @@ } } } oCn.Commit(); foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub2 in ls2) { if (ClsPub.isLong(oItemSub2.HMaterID) != 0) @@ -1654,6 +1706,7 @@ int SumLen2 = 4; string TM2 = ""; double HWXQty = 0; double HBarcodeQty = ClsPub.isDoule(oItemSub2.HQty); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; // @@ -1705,10 +1758,7 @@ TM2 = "0" + TM2; } bar2.HMaterID = oItemSub2.HMaterID; bar2.HBarCode = oItemSub2.HBarCode + "-" + TM2; bar2.HBarCode = oItemSub2.HBarCode.Replace(HBarcodeQty.ToString(), HWXQty.ToString()); bar2.HUnitID = oItemSub2.HUnitID; bar2.HQty = HWXQty; bar2.HBatchNo = DBUtility.ClsPub.isStrNull(oItemSub2.HBatchNo); @@ -1745,68 +1795,122 @@ string HWei = ""; string HMTONO = ""; oCn.BeginTran(); foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub in ls2) foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { if (ClsPub.isLong(oItemSub.HMaterID) != 0) //æ´æ°æ¡ç æ¡£æ¡ è¯¥æºåå ¶å®æ¡ç é»è®¤å·²ç»æå°è¿ä¸æ¬¡ oCn.RunProc($"update Gy_BarCodeBill set HPrintQty += 1 where HPrintQty = 0 and HSourceInterID={oItemSub.HSourceInterID} and HSourceEntryID = {oItemSub.HSourceEntryID}"); } //å¤ç®± var oItemSubGroup = ls2.GroupBy(x => new { x.HSourceEntryID }).Select(y => new Model.ClsGy_BarCodeBill_WMS_Model { HSourceEntryID = y.Key.HSourceEntryID }); foreach (var oitem in oItemSubGroup) { var SubModel = ls2.Where(x => x.HSourceEntryID == oitem.HSourceEntryID).ToList(); int count = 1; foreach (var oItemSub in SubModel) { HBarCode = oItemSub.HBarCode.ToString(); HMTONO = ClsPub.isStrNull(oItemSub.HMTONO); HBarCodeType = "ç®±å·æ¡ç "; HMaterID = ClsPub.isLong(oItemSub.HMaterID); HUnitID = ClsPub.isLong(oItemSub.HUnitID); HQty2 = ClsPub.isDoule(oItemSub.HQty); HBatchNo = ClsPub.isStrNull(oItemSub.HBatchNo); HSupID = oItemSub.HSupID; HKFPeriod = ClsPub.isInt(oItemSub.HKFPeriod); HKFDate = ClsPub.isStrNull(oItemSub.HKFDate); HKFDQDate = ClsPub.isStrNull(oItemSub.HKFDQDate); HSourceInterID = ClsPub.isLong(oItemSub.HSourceInterID); HSourceEntryID = ClsPub.isLong(oItemSub.HSourceEntryID); HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); oCn.RunProc("insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + ") values (" + linterid.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1" + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "')"); oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); if (ClsPub.isLong(oItemSub.HMaterID) != 0) { HBarCode = oItemSub.HBarCode.ToString(); HMTONO = ClsPub.isStrNull(oItemSub.HMTONO); HBarCodeType = "ç®±å·æ¡ç "; HMaterID = ClsPub.isLong(oItemSub.HMaterID); HUnitID = ClsPub.isLong(oItemSub.HUnitID); HQty2 = ClsPub.isDoule(oItemSub.HQty); HBatchNo = ClsPub.isStrNull(oItemSub.HBatchNo); HSupID = oItemSub.HSupID; HKFPeriod = ClsPub.isInt(oItemSub.HKFPeriod); HKFDate = ClsPub.isStrNull(oItemSub.HKFDate); HKFDQDate = ClsPub.isStrNull(oItemSub.HKFDQDate); HSourceInterID = ClsPub.isLong(oItemSub.HSourceInterID); HSourceEntryID = ClsPub.isLong(oItemSub.HSourceEntryID); HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); if (FCusName.Contains("å¤å®")) { HBarCode = $"{oItemSub.HMaterID}"; HBarCodeType = "åç§ç _å¤ç®±"; } string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HBarcodeQtys,HBarcodeNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + ") values (" + linterid.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate + "','" + HBatchNo + "','" + SubModel.Count + "','" + count + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1" + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "')"; oCn.RunProc(sql); oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); count++; } } } foreach (Model.ClsGy_BarCodeBill_WMS_Model oItemSub in ls3) //å ç®± var _oItemSubGroup = ls3.GroupBy(x => new { x.HSourceEntryID }).Select(y => new Model.ClsGy_BarCodeBill_WMS_Model { HSourceEntryID = y.Key.HSourceEntryID }); foreach (var oitem in _oItemSubGroup) { if (ClsPub.isLong(oItemSub.HMaterID) != 0) var SubModel = ls3.Where(x => x.HSourceEntryID == oitem.HSourceEntryID).ToList(); int _count = 1; foreach (var oItemSub in SubModel) { HBarCode = oItemSub.HBarCode.ToString(); HMTONO = ClsPub.isStrNull(oItemSub.HMTONO); HBarCodeType = "ç®±å·å æ¡ç "; HMaterID = ClsPub.isLong(oItemSub.HMaterID); HUnitID = ClsPub.isLong(oItemSub.HUnitID); HQty2 = ClsPub.isDoule(oItemSub.HQty); HBatchNo = ClsPub.isStrNull(oItemSub.HBatchNo); HSupID = oItemSub.HSupID; HKFPeriod = ClsPub.isInt(oItemSub.HKFPeriod); HKFDate = ClsPub.isStrNull(oItemSub.HKFDate); HKFDQDate = ClsPub.isStrNull(oItemSub.HKFDQDate); HSourceInterID = ClsPub.isLong(oItemSub.HSourceInterID); HSourceEntryID = ClsPub.isLong(oItemSub.HSourceEntryID); HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); oCn.RunProc("insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + ") values (" + linterid.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1" + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "')"); if (ClsPub.isLong(oItemSub.HMaterID) != 0) { HBarCode = oItemSub.HBarCode.ToString(); HMTONO = ClsPub.isStrNull(oItemSub.HMTONO); HBarCodeType = "ç®±å·å æ¡ç "; HMaterID = ClsPub.isLong(oItemSub.HMaterID); HUnitID = ClsPub.isLong(oItemSub.HUnitID); HQty2 = ClsPub.isDoule(oItemSub.HQty); HBatchNo = ClsPub.isStrNull(oItemSub.HBatchNo); HSupID = oItemSub.HSupID; HKFPeriod = ClsPub.isInt(oItemSub.HKFPeriod); HKFDate = ClsPub.isStrNull(oItemSub.HKFDate); HKFDQDate = ClsPub.isStrNull(oItemSub.HKFDQDate); HSourceInterID = ClsPub.isLong(oItemSub.HSourceInterID); HSourceEntryID = ClsPub.isLong(oItemSub.HSourceEntryID); HSourceBillNo = ClsPub.isStrNull(oItemSub.HSourceBillNo); HSourceBillType = ClsPub.isStrNull(oItemSub.HSourceBillType); HWei = ClsPub.isStrNull(oItemSub.HEndQty); if (FCusName.Contains("å¤å®")) { HBarCode = $"{oItemSub.HMaterID}"; HBarCodeType = "åç§ç "; } string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + ",HBatchNo,HBarcodeQtys,HBarcodeNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO " + ") values (" + linterid.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate + "','" + HBatchNo + "','" + SubModel.Count + "','" + _count + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1" + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "')"; oCn.RunProc(sql); _count++; } } } //ææ¶åªåå¡«å ³èæ°é oCn.RunProc("exec H_p_SRM_BarCodeBill_Update_UpdateBillRelateData " + linterid.ToString()); foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls) { if (oItemSub.HQty == 0) continue; //æ´æ°æ¡ç æ¡£æ¡ è¯¥æºåå ¶å®æ¡ç é»è®¤å·²ç»æå°è¿ä¸æ¬¡ //æ´æ° å·²æå°æ°é if (oItemSub.HSourceBillType == "1102") { string _HBarCodeType = "ç®±å·æ¡ç "; if (FCusName.Contains("å¤å®")) _HBarCodeType = "åç§ç "; string sql = string.Empty; sql = string.Format(@" update t1 set t1.HBarcodeCount = isnull((select sum(HQty)from Gy_BarCodeBill where HSourceInterID = t1.HInterID and HSourceEntryID = t1.HEntryID and HBarCodeType ='{2}'),0) from Cg_POOrderBillSub t1 where t1.HInterID = {0} and t1.HEntryID ={1}", oItemSub.HSourceInterID, oItemSub.HSourceEntryID, _HBarCodeType); oCn.RunProc(sql); } } oCn.Commit(); } catch (Exception e) { @@ -1933,12 +2037,20 @@ } [Route("DeltetBarCodeBill")] [HttpGet] public object DeltetBarCodeBill(string HInterID, string HUserName) [HttpPost] public object DeltetBarCodeBill([FromBody] JObject oData) { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); try { var _value = oData["oData"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string HInter = sArray[0].ToString(); string HInterID = HInter.Replace("\"", ""); string HUserName = sArray[1].ToString(); string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); string sql = "select HItemID,HBarCode,HSourceInterID,HSourceEntryID,HQty,HBarCodeType,HSourceBillType from Gy_BarCodeBill where HItemID in(" + HInterID + ") "; //LogService.Write("å é¤sql:" + sql); oCN.BeginTran(); @@ -1947,9 +2059,12 @@ { foreach (DataRow dr in dt.Rows) { string _HBarCodeType = "ç®±å·æ¡ç "; if (FCusName.Contains("å¤å®")) _HBarCodeType = "åç§ç "; WebAPIController.Add_Log("æ¡ç æ¡£æ¡å é¤", HUserName, "åå·" + dr["HBarCode"].ToString()); //ååæå°æ°éå°éè´è®¢åå表 if (dr["HBarCodeType"].ToString() == "ç®±å·å æ¡ç " && dr["HSourceBillType"].ToString() == "1102") if (dr["HBarCodeType"].ToString() == _HBarCodeType && dr["HSourceBillType"].ToString() == "1102") oCN.RunProc($"update Cg_POOrderBillSub set HBarcodeCount -= {dr["HQty"]} where HInterID ={dr["HSourceInterID"]} and HEntryID ={dr["HSourceEntryID"]}"); //ååæå°æ°éå°å§å¤è®¢å if (dr["HBarCodeType"].ToString() == "ç®±å·å æ¡ç " && dr["HSourceBillType"].ToString() == "1601") @@ -1960,7 +2075,7 @@ //oCN.RunProc($"update WW_EntrustOrderBillSub set HBarcodeCount -= {dr["HQty"]} where HInterID ={dr["HSourceInterID"]} and HEntryID ={dr["HSourceEntryID"]}"); } } //oCN.RunProc("Delete From Gy_BarCodeBill where HItemID in(" + HInterID + ") "); oCN.RunProc("Delete From Gy_BarCodeBill where HItemID in(" + HInterID + ") "); oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; WebAPI/Controllers/POInStockController.cs
@@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; @@ -323,7 +324,7 @@ oItem.HMainSourceInterID = oItem.HInterID; oItem.HInterID = 0; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (FCusName == "å®çå»ç") //ç³»ç»åæ° å®¢æ·å®å¶ååç§° 空ç½ä¸ºéç¨ if (FCusName.Contains("å®ç")) //ç³»ç»åæ° å®¢æ·å®å¶ååç§° 空ç½ä¸ºéç¨ { if (DBUtility.ClsPub.isStrNull(oItem.HDHDate) == "") { @@ -425,6 +426,7 @@ return objJsonResult; } } /// <summary> /// éè´§åå表 /// </summary> @@ -440,13 +442,14 @@ string HSupNo = msg["HSupNo"].ToString(); string sqlWhere = msg["sqlWhere"].ToString(); try { Stopwatch sw = new Stopwatch(); sw.Start();//å¼å§è®¡æ¶ string VsWhere = ""; string PcWhere = ""; SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); DataSet ds; //å ¶ä»è¿æ»¤ string sql = " Where hsupid in (select HSupID from h_v_Gy_UserSupplierList where ç¨æ· =^^" + HSupNo.Trim() + "^^) " + sqlWhere; //转æ¢ç¹æ®å符 if (Common.SQLtoChange(sql, ref VsWhere, ref PcWhere) == false) { @@ -461,13 +464,13 @@ //è·åè¿åæ°æ® ds = oCn.RunProcReturn("exec H_p_SRM_POInStockBillList '" + PcWhere + "'", "H_p_SRM_POInStockBillList"); LogService.Write("éè´§åå表å è½½sql:exec H_p_SRM_POInStockBillList '" + PcWhere + "'"); LogService.Write("æ°æ®æ¥è¯¢è¿å" + sw.Elapsed); sw.Stop();//ç»æè®¡æ¶ objjson.code = "0"; objjson.count = 10000; objjson.Message = "è·åæå"; objjson.data = ds.Tables[0]; return objjson; } catch (Exception e) { @@ -614,170 +617,7 @@ string HValue = "Y"; if (HValue == "Y") { if (FCusName == "çä¸ç¥º" || FCusName == "" || FCusName.Contains("åç»´å°") || FCusName.Contains("å¯è´å¥ç¹")) { sql = string.Format(@" SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER ,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER AS FSETTLEORGNUMBER, E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID ,CU.FNUMBER AS FUNITNUMBER,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER FROM CG_POINSTOCKBILLSUB B JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID JOIN {0}..T_PUR_POORDERENTRY_D CD ON C.FENTRYID = CD.FENTRYID LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID JOIN {0}..T_PUR_POORDERENTRY_F CR ON C.FENTRYID = CR.FENTRYID LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID = 2052 LEFT JOIN {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID WHERE b.hinterid in ({1}) and M.HERPInterID = 0 ", kdTbaleName, HInterID); dt = oCn.RunProcReturn(sql, "sltz").Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { //éè´è®¢å䏿¨çæéè´§å æ¶å 夿æ¯å¦æçæéè´è®¢ååæ´å 妿æä¸åæ´åç¶æä¸ä¸ºå·²å®¡æ ¸ éå¶ä¸æ¨ objJsonResult = TestPOOrder(dr["FEntryID"].ToString()); if (objJsonResult.code == "0") return objJsonResult; } foreach (DataRow dr in dt.Rows) { if (fidList.Contains(dr["HINTERID"].ToString())) continue; else fidList.Add(dr["HINTERID"].ToString()); DataRow[] drs = dt.Select("HINTERID = " + dr["HINTERID"].ToString()); JObject model = new JObject(); string fTypeName = "SLD01_SYS";//æ åéè´è®¢åç±»å string ywTypeName = "CG";//æ åä¸å¡ç±»å if (dr["FTYPENAME"].ToString().Contains("å§å¤")) { fTypeName = "SLD03_SYS"; ywTypeName = "WW"; } if (dr["FTYPENAME"].ToString().Contains("èµäº§")) { fTypeName = "SLD04_SYS"; ywTypeName = "ZCCG"; } model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //åæ®ç±»å model.Add("FBusinessType", ywTypeName); //ä¸å¡ç±»å model.Add("FBILLNO", dr["HBillNo"].ToString()); //åæ®ç¼å· model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //éç¥æ¥æ model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // æ¶æç»ç» model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //éè´ç»ç» model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //ä¾åºå model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //éè´å model.Add("FOwnerTypeIdHead", "BD_Supplier");// 货主类å model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 ä¾åºå JArray Fentity = new JArray(); foreach (var item in drs) { JObject FentityModel = new JObject(); FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // ç©æç¼ç FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // åä½ FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //é¢è®¡å°è´§æ¥æ FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 计价åä½ FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // åºååä½ FentityModel.Add("FStockID", new JObject() { ["Fnumber"] = "BJCK-SH.01.005" }); // åºååä½ FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // ä¾åºåéè´§æ°éï¼ææè®¡åæ°é - å·²çæéè´§åæ°éï¼ FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类å FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//货主 FentityModel.Add("FSrcId", item["FID"].ToString());//æºåå ç FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//æºåç±»å FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//æºååå· FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//æºååå½å ç FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//æºååå· FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//æºååå½å ç FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid FentityModel.Add("FPrice", item["FPRICE"].ToString());//åä»· FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//å«ç¨åä»· FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//ç¨ç JArray Fentity2 = new JArray(); JObject FentityModel2 = new JObject(); FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill"); FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry"); FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString()); FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString()); Fentity2.Add(FentityModel2); FentityModel.Add("FDetailEntity_Link", Fentity2); Fentity.Add(FentityModel); } model.Add("FDetailEntity", Fentity); //æç»ä¿¡æ¯ JObject _FentityModel = new JObject(); _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); // ç»ç®ç»ç» _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); // ç»ç®å¸å« _FentityModel.Add("FPricePoint", 0); // å®ä»·æ¶ç¹ model.Add("FinanceEntity ", _FentityModel);//è´¢å¡ä¿¡æ¯ JObject jsonRoot = new JObject() { ["Creator"] = "", ["NeedUpDateFields"] = new JArray(), ["NeedReturnFields"] = new JArray(), ["IsDeleteEntry"] = "false", ["SubSystemId"] = "", ["IsVerifyBaseDataField"] = "false", ["Model"] = model }; var loginRet = InvokeHelper.Login(); var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); if (isSuccess == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = loginRet; objjson.data = null; return objjson; } //LogService.Write("jsonRoot:" + jsonRoot.ToString()); var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString()); //LogService.Write(result); if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE") { //æ´æ°éè´§å 主表 ERPåæ®å· ä»¥å ERP主å ç string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); string FID = JObject.Parse(result)["Result"]["Id"].ToString(); string updateSql = string.Format(@" update a set a.HERPInterID = {0} , a.HERPBillNO ='{1}' from Cg_POInStockBillMain a join Cg_POInStockBillSub b on a.hinterid = b.hinterid where b.HInterID = ({2}) and b. HSOURCEINTERID = {3} and a.HERPInterID = 0 ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString()); oCn.RunProc(updateSql); } else { objjson.code = "0"; objjson.count = 0; objjson.Message = result; objjson.data = null; return objjson; } } } else { LogService.Write("æ¶æéç¥åå®¡æ ¸æ æ°æ®ï¼" + sql); } } else if (FCusName == "å¤å®çµå¨") if (FCusName == "å¤å®çµå¨") { sql = string.Format(@" SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER @@ -932,7 +772,176 @@ } } } else { sql = string.Format(@" SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER ,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER AS FSETTLEORGNUMBER, E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID ,CU.FNUMBER AS FUNITNUMBER,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER FROM CG_POINSTOCKBILLSUB B JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID JOIN {0}..T_PUR_POORDERENTRY_D CD ON C.FENTRYID = CD.FENTRYID LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID JOIN {0}..T_PUR_POORDERENTRY_F CR ON C.FENTRYID = CR.FENTRYID LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID = 2052 LEFT JOIN {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID WHERE b.hinterid in ({1}) and M.HERPInterID = 0 ", kdTbaleName, HInterID); dt = oCn.RunProcReturn(sql, "sltz").Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { //éè´è®¢å䏿¨çæéè´§å æ¶å 夿æ¯å¦æçæéè´è®¢ååæ´å 妿æä¸åæ´åç¶æä¸ä¸ºå·²å®¡æ ¸ éå¶ä¸æ¨ objJsonResult = TestPOOrder(dr["FEntryID"].ToString()); if (objJsonResult.code == "0") return objJsonResult; } foreach (DataRow dr in dt.Rows) { if (fidList.Contains(dr["HINTERID"].ToString())) continue; else fidList.Add(dr["HINTERID"].ToString()); DataRow[] drs = dt.Select("HINTERID = " + dr["HINTERID"].ToString()); JObject model = new JObject(); string fTypeName = "SLD01_SYS";//æ åéè´è®¢åç±»å string ywTypeName = "CG";//æ åä¸å¡ç±»å if (dr["FTYPENAME"].ToString().Contains("å§å¤")) { fTypeName = "SLD03_SYS"; ywTypeName = "WW"; } if (dr["FTYPENAME"].ToString().Contains("èµäº§")) { fTypeName = "SLD04_SYS"; ywTypeName = "ZCCG"; } model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //åæ®ç±»å model.Add("FBusinessType", ywTypeName); //ä¸å¡ç±»å model.Add("FBILLNO", dr["HBillNo"].ToString()); //åæ®ç¼å· model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //éç¥æ¥æ model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // æ¶æç»ç» model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //éè´ç»ç» model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //ä¾åºå model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //éè´å model.Add("FOwnerTypeIdHead", "BD_Supplier");// 货主类å model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 ä¾åºå JArray Fentity = new JArray(); foreach (var item in drs) { JObject FentityModel = new JObject(); FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // ç©æç¼ç FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // åä½ FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //é¢è®¡å°è´§æ¥æ FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 计价åä½ FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // åºååä½ FentityModel.Add("FStockID", new JObject() { ["Fnumber"] = "BJCK-SH.01.005" }); // åºååä½ FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // ä¾åºåéè´§æ°éï¼ææè®¡åæ°é - å·²çæéè´§åæ°éï¼ FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类å FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//货主 FentityModel.Add("FSrcId", item["FID"].ToString());//æºåå ç FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//æºåç±»å FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//æºååå· FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//æºååå½å ç FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//æºååå· FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//æºååå½å ç FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid FentityModel.Add("FPrice", item["FPRICE"].ToString());//åä»· FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//å«ç¨åä»· FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//ç¨ç JArray Fentity2 = new JArray(); JObject FentityModel2 = new JObject(); FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill"); FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry"); FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString()); FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString()); Fentity2.Add(FentityModel2); FentityModel.Add("FDetailEntity_Link", Fentity2); Fentity.Add(FentityModel); } model.Add("FDetailEntity", Fentity); //æç»ä¿¡æ¯ JObject _FentityModel = new JObject(); _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); // ç»ç®ç»ç» _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); // ç»ç®å¸å« _FentityModel.Add("FPricePoint", 0); // å®ä»·æ¶ç¹ model.Add("FinanceEntity ", _FentityModel);//è´¢å¡ä¿¡æ¯ JObject jsonRoot = new JObject() { ["Creator"] = "", ["NeedUpDateFields"] = new JArray(), ["NeedReturnFields"] = new JArray(), ["IsDeleteEntry"] = "false", ["SubSystemId"] = "", ["IsVerifyBaseDataField"] = "false", ["Model"] = model }; var loginRet = InvokeHelper.Login(); var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); if (isSuccess == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = loginRet; objjson.data = null; return objjson; } //LogService.Write("jsonRoot:" + jsonRoot.ToString()); var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString()); //LogService.Write(result); if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE") { //æ´æ°éè´§å 主表 ERPåæ®å· ä»¥å ERP主å ç string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); string FID = JObject.Parse(result)["Result"]["Id"].ToString(); string updateSql = string.Format(@" update a set a.HERPInterID = {0} , a.HERPBillNO ='{1}' from Cg_POInStockBillMain a join Cg_POInStockBillSub b on a.hinterid = b.hinterid where b.HInterID = ({2}) and b. HSOURCEINTERID = {3} and a.HERPInterID = 0 ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString()); oCn.RunProc(updateSql); } else { objjson.code = "0"; objjson.count = 0; objjson.Message = result; objjson.data = null; return objjson; } } } else { LogService.Write("æ¶æéç¥åå®¡æ ¸æ æ°æ®ï¼" + sql); } } } ////æ´æ°ç©æµå段 ï¼çä¸çªï¼ //oCn.RunProc("exec h_p_Cg_LocalToKingDee_POInStock " + HBillNo + "," + HInterID); //æ´æ°ä¸»è¡¨ç¶æ å®¡æ ¸ sql = string.Format(@"update Cg_POInStockBillMain set HBillStatus = 2 , @@ -981,8 +990,8 @@ SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); int HInterID = 0; string sql = "select HInterID from CG_POINSTOCKBILLMAIN where HBILLNO = '" + HBillNo + "'"; if (type == "Print") sql += " and HBillStatus = '2' ";//æå°å¤ææ¯å¦å®¡æ ¸ //if (type == "Print") // sql += " and HBillStatus = '2' ";//æå°å¤ææ¯å¦å®¡æ ¸ DataTable dt = oCn.RunProcReturn(sql, "HInterID").Tables[0]; if (dt.Rows.Count > 0) HInterID = Convert.ToInt32(dt.Rows[0]["HInterID"]); @@ -1189,17 +1198,19 @@ var HinterID = mylist[i].ToString(); oCn.RunProc($"exec h_p_SRM_UpDatePPBomRelationQty {HinterID}"); } //夿æªå ³èæ°éæ¯å¦ä¸º0 DataSet ds = oCn.RunProcReturn($"select * from H_v_SRM_POOrderBillList where hsubid in ({string.Join(", ", entryList)}) ", "H_v_SRM_POOrderBillList"); //å®çï¼AIS20220914133941 çä¸çªï¼AIS20220308151944 DataSet ds = oCn.RunProcReturn($"select T1.hqty-T1.hrelationqty+q.FMRBQTY as hqty,åæ®å·,ç©æç¼ç from H_v_SRM_POOrderBillList t1 left join AIS20220914133941..T_PUR_POORDERENTRY_R q on q.FENTRYID=t1.HEntryID where hentryid in ({string.Join(", ", entryList)}) ", "H_v_SRM_POOrderBillList"); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select("æªå ³èæ°é = " + 0); DataRow[] dr = dt.Select("hqty <=" + 0); if (dr.Count() > 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"è¯·æ£æ¥æ°æ®ï¼åæ®å·ï¼{dr[0]["åæ®å·"]},ç©æä»£ç ï¼{dr[0]["ç©æä»£ç "]},æªå ³èæ°é为0ï¼å·²å ¨é¨çæéè´§åï¼"; objJsonResult.Message = $"è¯·æ£æ¥æ°æ®ï¼åæ®å·ï¼{dr[0]["åæ®å·"]},ç©æç¼ç ï¼{dr[0]["ç©æç¼ç "]},å¯ä»¥åè´§æ°é为0ï¼å·²å ¨é¨çæéè´§åï¼"; objJsonResult.data = null; return objJsonResult; } WebAPI/Controllers/POOrderController.cs
@@ -1,4 +1,5 @@ using DBUtility; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SQLHelper; using System; @@ -53,15 +54,25 @@ //è·åæ»è¡æ° //Int64 RowTotal = Common.GetRowTotal("H_v_SRM_POOrderBillList", VsWhere, ref DBUtility.ClsPub.sExeReturnInfo); //è·åè¿åæ°æ® //sql = "exec H_P_REALESEPOORDER"; //sql = "exec H_P_REALESEPOORDER"; //oCn.RunProc(sql); sql = "exec H_p_SRM_POOrderBillList '" + PcWhere + "'"; //LogService.WriteAsync(sql); ds = oCn.RunProcReturn("exec H_p_SRM_POOrderBillList '" + PcWhere + "'", "H_p_SRM_POOrderBillList"); //æ·»å åå List<object> columnNameList = new List<object>(); 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));//è·åå°DataColumnå对象çåå } objjson.code = "0"; objjson.count = 10000; objjson.Message = "è·åæå"; objjson.data = ds.Tables[0]; objjson.list = columnNameList; return objjson; } WebAPI/Controllers/WebAPIController.cs
@@ -15,6 +15,7 @@ using System.Web.Http; using WebAPI.BLL; using WebAPI.Models; using WebAPI.Utility; namespace WebAPI.Controllers { @@ -845,6 +846,29 @@ return objjson; ; } #endregion #region[æå°idSession] [Route("linteridSession")] [HttpPost] public object linteridSession([FromBody] JObject linterid) { var _linterid = linterid["linterid"].ToString(); var _huserName = linterid["HUserName"].ToString(); var postMesseege = _linterid + ";" + _huserName; //HttpHelper.PostData("http://localhost:8082/ZYMES/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); HttpHelper.PostData("http://60.191.21.115:9090/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); string sql = $"Update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0) + 1 where HItemID in ({_linterid})"; oCn.RunProc(sql); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = ""; objJsonResult.data = 1; return objJsonResult; //HttpContext.Current.Session["linterid"]; } #endregion } WebAPI/Controllers/Xt_grdAlignment_WMESController.cs
@@ -108,7 +108,7 @@ { var width = omdelsub[i].ColumnWidth; if (string.IsNullOrEmpty(width) || DBUtility.ClsPub.isLong(width) == 0) width = "120"; width = "80"; HGridString += $"{(i+1)}|{(omdelsub[i].IsHide == true ? 1 : 0)}|{omdelsub[i].Alignment}|{width},"; } HGridString = HGridString.Substring(0, HGridString.Length - 1); WebAPI/DLL/DAL.dllBinary files differ
WebAPI/DLL/Model.dllBinary files differ
WebAPI/Models/JsonResult.cs
@@ -11,5 +11,7 @@ public int count { get; set; } public string Message { get; set; } public object data { get; set; } public List<object> list { get; set; } } } WebAPI/Models/json.cs
@@ -11,5 +11,7 @@ public int count { get; set; } public string Message { get; set; } public object data { get; set; } public List<object> list { get; set; } } } WebAPI/Utility/HttpHelper.cs
New file @@ -0,0 +1,134 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace WebAPI.Utility { public class HttpHelper { public static string PostData(string url, string postData) { ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = Encoding.UTF8.GetBytes(postData); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream newStream = myRequest.GetRequestStream(); newStream.Write(data, 0, data.Length); newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); reader.Close(); return content; } public static string GetData(string url) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "GET"; HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); reader.Close(); return content; } /// <summary> /// FORM表åPOSTæ¹å¼ä¸ä¼ ä¸ä¸ªå¤åªä½æä»¶ /// </summary> /// <param name="url">API URL</param> /// <param name="typeName"></param> /// <param name="fileName"></param> /// <param name="fs"></param> /// <param name="encoding"></param> /// <returns></returns> public static string HttpRequestPost(string url, string typeName, string fileName, Stream fs, string encoding = "UTF-8") { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.Timeout = 10000; var postStream = new MemoryStream(); #region å¤çForm表åæä»¶ä¸ä¼ //éè¿è¡¨åä¸ä¼ æä»¶ string boundary = "----" + DateTime.Now.Ticks.ToString("x"); string formdataTemplate = "\r\n--" + boundary + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: application/octet-stream\r\n\r\n"; try { var formdata = string.Format(formdataTemplate, typeName, fileName); var formdataBytes = Encoding.ASCII.GetBytes(postStream.Length == 0 ? formdata.Substring(2, formdata.Length - 2) : formdata);//第ä¸è¡ä¸éè¦æ¢è¡ postStream.Write(formdataBytes, 0, formdataBytes.Length); //åå ¥æä»¶ byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) { postStream.Write(buffer, 0, bytesRead); } } catch (Exception ex) { throw ex; } //ç»å°¾ var footer = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n"); postStream.Write(footer, 0, footer.Length); request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary); #endregion request.ContentLength = postStream != null ? postStream.Length : 0; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; request.KeepAlive = true; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"; #region è¾å ¥äºè¿å¶æµ if (postStream != null) { postStream.Position = 0; //ç´æ¥åå ¥æµ Stream requestStream = request.GetRequestStream(); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) { requestStream.Write(buffer, 0, bytesRead); } postStream.Close();//å ³éæä»¶è®¿é® } #endregion HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) { using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding(encoding))) { string retString = myStreamReader.ReadToEnd(); return retString; } } } //public static string PostDataV2(string data, string url) //{ // WebClient wc = new WebClient(); // wc.Headers.Add("Content-Type", "application/json"); // byte[] postData = Encoding.ASCII.GetBytes(data); // byte[] responseData = wc.UploadData(url, "POST", postData); // return Encoding.UTF8.GetString(responseData); //} } } WebAPI/WebAPI.csproj
@@ -46,9 +46,9 @@ <Reference Include="BouncyCastle.Crypto, Version=1.8.9.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL"> <HintPath>..\packages\Portable.BouncyCastle.1.8.9\lib\net40\BouncyCastle.Crypto.dll</HintPath> </Reference> <Reference Include="DAL, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86"> <Reference Include="DAL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\SRM-MES\SRM-MES\DAL\bin\Debug\DAL.dll</HintPath> <HintPath>..\..\..\SRM-MES\SRM-MES\DAL\bin\Debug\DAL.dll</HintPath> </Reference> <Reference Include="DBUtility, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> @@ -240,6 +240,7 @@ <Compile Include="MyHub.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Startup.cs" /> <Compile Include="Utility\HttpHelper.cs" /> <Compile Include="Utility\Util.cs" /> </ItemGroup> <ItemGroup> WebAPI/bin.7zBinary files differ
È«²¿¿Í»§ÔÚÔËÓÃ.txt