From 2da22fe69c1a48b719f8708dbe46b38c531bd4d2 Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期四, 15 十二月 2022 17:09:06 +0800
Subject: [PATCH] 优化
---
WebAPI/Models/JsonResult.cs | 2
WebAPI/Controllers/POOrderController.cs | 11 ++
WebAPI/Utility/HttpHelper.cs | 134 +++++++++++++++++++++++++++++++++
WebAPI/Controllers/WebAPIController.cs | 24 ++++++
WebAPI/WebAPI.csproj | 1
WebAPI/Controllers/Xt_grdAlignment_WMESController.cs | 2
WebAPI/Controllers/BarCodeController.cs | 11 ++
WebAPI/Models/json.cs | 2
8 files changed, 185 insertions(+), 2 deletions(-)
diff --git a/WebAPI/Controllers/BarCodeController.cs b/WebAPI/Controllers/BarCodeController.cs
index 2d97267..c34b028 100644
--- a/WebAPI/Controllers/BarCodeController.cs
+++ b/WebAPI/Controllers/BarCodeController.cs
@@ -1556,6 +1556,17 @@
//鏁伴噺涓�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 (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)
{
HNumber = oItemSub.HMaterID.ToString();
diff --git a/WebAPI/Controllers/POOrderController.cs b/WebAPI/Controllers/POOrderController.cs
index b9cacbd..8692984 100644
--- a/WebAPI/Controllers/POOrderController.cs
+++ b/WebAPI/Controllers/POOrderController.cs
@@ -1,4 +1,5 @@
锘縰sing DBUtility;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SQLHelper;
using System;
@@ -59,11 +60,19 @@
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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
objjson.code = "0";
objjson.count = 10000;
objjson.Message = "鑾峰彇鎴愬姛";
objjson.data = ds.Tables[0];
+ objjson.list = columnNameList;
return objjson;
}
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 222cebe..c4fde65 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/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
}
diff --git a/WebAPI/Controllers/Xt_grdAlignment_WMESController.cs b/WebAPI/Controllers/Xt_grdAlignment_WMESController.cs
index c0f49ba..86b7e5e 100644
--- a/WebAPI/Controllers/Xt_grdAlignment_WMESController.cs
+++ b/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);
diff --git a/WebAPI/Models/JsonResult.cs b/WebAPI/Models/JsonResult.cs
index 411f417..60b3982 100644
--- a/WebAPI/Models/JsonResult.cs
+++ b/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; }
+
}
}
\ No newline at end of file
diff --git a/WebAPI/Models/json.cs b/WebAPI/Models/json.cs
index 3a10890..4c72226 100644
--- a/WebAPI/Models/json.cs
+++ b/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; }
+
}
}
diff --git a/WebAPI/Utility/HttpHelper.cs b/WebAPI/Utility/HttpHelper.cs
new file mode 100644
index 0000000..1a09b27
--- /dev/null
+++ b/WebAPI/Utility/HttpHelper.cs
@@ -0,0 +1,134 @@
+锘縰sing 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);
+ //}
+ }
+}
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index b82c721..703ef15 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -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>
--
Gitblit v1.9.1