From b47b612c73cb98abf025bf3db30e1bd410666f41 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期二, 12 五月 2026 10:38:53 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/WebAPIController.cs | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 0d2b7ca..74829a7 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -24366,6 +24366,11 @@
}
#endregion
+
+ #region APP鏍规嵁璁惧id杩涜鑷姩鐧诲綍
+
+
+
[HttpGet]
[Route("Web/getSysParameter")]
public object getSysParameter(string HClientID)
@@ -24409,5 +24414,153 @@
return objJsonResult;
}
}
+ #endregion
+
+ #region 鏍规嵁琛ㄥ悕鑾峰彇sql璇彞
+ [HttpGet]
+ [Route("Web/getSQL")]
+ public object getSQL(string TableName, string ModeName, string OpertionType, string Identityid)
+ {
+ if (OpertionType == "insert")
+ {
+ string sql = $"select * from {TableName}";
+ DataSet ds = oCN.RunProcReturn(sql, TableName);
+
+ if (ds == null || ds.Tables[0].Rows.Count <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+ objJsonResult.data = 0;
+ return objJsonResult;
+ }
+
+ sql = $"exec h_p_sqlhelper '{TableName}'";
+ ds = oCN.RunProcReturn(sql, "h_p_sqlhelper");
+
+ if (ds == null || ds.Tables.Count < 2 || ds.Tables[1].Rows.Count <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+ objJsonResult.data = 0;
+ return objJsonResult;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ string columnsStr = ds.Tables[0].Rows[0][0].ToString();
+ sb.AppendLine($"sqlRes = $\"INSERT INTO [{TableName}] ({columnsStr})");
+ sb.AppendLine(" VALUES (");
+
+ // 2. 鎷兼帴 VALUES 閲岄潰鐨勫弬鏁�
+ int count = ds.Tables[1].Rows.Count;
+ for (int i = 0; i < count; i++)
+ {
+ string propName = ds.Tables[1].Rows[i][0].ToString();
+ string valueFormat = "";
+ if (propName == "HMakeDate")
+ {
+ valueFormat = "getdata()";
+ }
+ else if (propName == "HERPItemID")
+ {
+ valueFormat = "'{0}'";
+ }
+ else
+ {
+ valueFormat = $"'{{{ModeName}.{propName}}}'"; // 榛樿閫氱敤閫昏緫
+ }
+ sb.Append(" " + valueFormat);
+
+ if (i < count - 1)
+ {
+ sb.Append(",");
+ }
+ sb.AppendLine();
+ }
+ sb.AppendLine(" ); \";");
+ sb.Append(" oCN.RunProc(sqlRes);");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎴愬姛";
+ objJsonResult.data = sb;
+ return objJsonResult;
+ }
+ else
+ {
+ string whereKey = Identityid;
+ string sql = $"select * from {TableName}";
+ DataSet ds = oCN.RunProcReturn(sql, TableName);
+
+ if (ds == null || ds.Tables[0].Rows.Count <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+ objJsonResult.data = 0;
+ return objJsonResult;
+ }
+ sql = $"exec h_p_sqlhelper '{TableName}'";
+ ds = oCN.RunProcReturn(sql, "h_p_sqlhelper");
+
+ if (ds == null || ds.Tables.Count < 2 || ds.Tables[1].Rows.Count <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+ objJsonResult.data = 0;
+ return objJsonResult;
+ }
+ StringBuilder sb = new StringBuilder();
+
+ sb.Append($"sqlRes =$\"Update {TableName} set ");
+
+ int count = ds.Tables[1].Rows.Count;
+ int setFieldCount = 0;
+
+ for (int i = 0; i < count; i++)
+ {
+ string propName = ds.Tables[1].Rows[i][0].ToString();
+
+
+ if (propName == whereKey)
+ continue;
+
+
+ if (setFieldCount > 0)
+ {
+ sb.Append(",");
+ }
+ string valueFormat = "";
+ if (propName == "HModifyTime" || propName == "HUpDateDate")
+ {
+ valueFormat = $"{propName}=getdate()";
+ }
+ else
+ {
+ valueFormat = $"{propName}='{{{ModeName}.{propName}}}'";
+ }
+ sb.Append("\r\n " + valueFormat);
+
+ setFieldCount++;
+ }
+
+ sb.Append($" where {whereKey}='{{{ModeName}.{whereKey}}}'\"");
+ sb.AppendLine();
+ sb.Append("oCN.RunProc(sqlRes);");
+
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎴愬姛";
+ objJsonResult.data = sb;
+ return objJsonResult;
+ }
+ }
+ #endregion
}
+
+
}
+
--
Gitblit v1.9.1