From 3a3c4dc098a85a32170eb728583622ea90759ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=BD=98=E5=BB=BA=E4=B8=9C?= <617601767@qq.com>
Date: Sun, 24 Mar 2024 13:14:34 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20+=3D=20=E5=92=8C=20-=3D?=
=?UTF-8?q?=E6=93=8D=E4=BD=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Hadoop/ZKLT.Hadoop.API/Program.cs | 28 ++++++++---------
.../Properties/launchSettings.json | 2 +-
Hadoop/ZKLT.Hadoop.Model/HDP_CommandAction.cs | 31 +++++++++++++++++++
Hadoop/ZKLT.Hadoop/TableService.cs | 3 +-
4 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/Hadoop/ZKLT.Hadoop.API/Program.cs b/Hadoop/ZKLT.Hadoop.API/Program.cs
index 3e2187e..38f3a30 100644
--- a/Hadoop/ZKLT.Hadoop.API/Program.cs
+++ b/Hadoop/ZKLT.Hadoop.API/Program.cs
@@ -40,34 +40,34 @@ namespace ZKLT.Hadoop.API
app.UseCors("all");
#endregion
+ app.UseHadoop((c) =>
+ {
+ c.Host = "127.0.0.1";
+ c.Account = "root";
+ c.PassWord = "root";
+ c.Key = "hadoopdb";
+ c.Port = 3306;
+ });
+
+
//app.UseHadoop((c) =>
//{
- // c.Host = "127.0.0.1";
+ // c.Host = "172.17.0.1";
// c.Account = "root";
// c.PassWord = "root";
- // c.Key = "hadoopdb";
- // c.Port = 3306;
+ // c.Key = "testdb";
+ // c.Port = 4000;
//});
-
//app.UseHadoop((c) =>
//{
- // c.Host = "172.17.0.1";
+ // c.Host = "118.195.165.218";
// c.Account = "root";
// c.PassWord = "root";
// c.Key = "testdb";
// c.Port = 4000;
//});
- app.UseHadoop((c) =>
- {
- c.Host = "118.195.165.218";
- c.Account = "root";
- c.PassWord = "root";
- c.Key = "testdb";
- c.Port = 4000;
- });
-
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
diff --git a/Hadoop/ZKLT.Hadoop.API/Properties/launchSettings.json b/Hadoop/ZKLT.Hadoop.API/Properties/launchSettings.json
index fb9f190..828e8ba 100644
--- a/Hadoop/ZKLT.Hadoop.API/Properties/launchSettings.json
+++ b/Hadoop/ZKLT.Hadoop.API/Properties/launchSettings.json
@@ -33,7 +33,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
- "applicationUrl": "http://localhost:59844",
+ "applicationUrl": "http://localhost:43666",
"sslPort": 0
}
}
diff --git a/Hadoop/ZKLT.Hadoop.Model/HDP_CommandAction.cs b/Hadoop/ZKLT.Hadoop.Model/HDP_CommandAction.cs
index c20d37c..0d3be48 100644
--- a/Hadoop/ZKLT.Hadoop.Model/HDP_CommandAction.cs
+++ b/Hadoop/ZKLT.Hadoop.Model/HDP_CommandAction.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Text.RegularExpressions;
namespace ZKLT.Hadoop.Model
{
@@ -42,5 +43,35 @@ namespace ZKLT.Hadoop.Model
return action;
}
}
+
+ ///
+ /// 列转换
+ ///
+ /// 列
+ /// 参数
+ /// 公式
+ ///
+ public static string ColConvert(HDP_Column column, Dictionary param,object value) {
+ string _guid;
+ if (value is string) {
+ string _action = value.ToString()!;
+ Regex _regex1 = new Regex(@"(?<=(\+\=))\d+");
+ if(_regex1.IsMatch(_action))
+ {
+ _guid = Guid.NewGuid().ToString("N");
+ param.Add(_guid,_regex1.Match(_action).Value);
+ return @$"`{column.Key}` + @{_guid}";
+ }
+ Regex _regex2 = new Regex(@"(?<=(\-\=))\d+");
+ if (_regex2.IsMatch(_action))
+ {
+ _guid = Guid.NewGuid().ToString("N");
+ param.Add(_guid, _regex2.Match(_action).Value);
+ return @$"`{column.Key}` - @{_guid}";
+ }
+ }
+ param.Add(column.Key!, value);
+ return $@"@{column.Key}";
+ }
}
}
diff --git a/Hadoop/ZKLT.Hadoop/TableService.cs b/Hadoop/ZKLT.Hadoop/TableService.cs
index c63230d..3d2850d 100644
--- a/Hadoop/ZKLT.Hadoop/TableService.cs
+++ b/Hadoop/ZKLT.Hadoop/TableService.cs
@@ -579,8 +579,7 @@ namespace ZKLT.Hadoop
var _column = table.Columns[i];
if (_row.ContainsKey(_column.Key!) && !_where.Any(x => x.ContainsKey(_column.Key!)))
{
- _colstr.Append($@"`{_column.Key!}`=@{_column.Key!},");
- _params.Add(_column.Key!, ((JValue)_row[_column.Key!]!).Value!);
+ _colstr.Append(@$"`{_column.Key!}`={HDP_CommandAction.ColConvert(_column,_params, ((JValue)_row[_column.Key!]!).Value!)},");
}
else if (!string.IsNullOrEmpty(_column.UpdateDefault))
{