Quellcode durchsuchen

升级.net版本
调整数据推送

lcl vor 2 Monaten
Ursprung
Commit
19c62939fc

+ 2 - 2
.vscode/launch.json

@@ -8,7 +8,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/MySystem.dll",
+            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/MySystem.dll",
             "args": [],
             "cwd": "${workspaceFolder}",
             "stopAtEntry": false,
@@ -28,7 +28,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/MySystem.dll",
+            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/MySystem.dll",
             "args": [],
             "cwd": "${workspaceFolder}",
             "stopAtEntry": false,

+ 4 - 2
AppStart/StartHelper.cs

@@ -24,8 +24,10 @@
             }
             else
             {
-                PosPushHelper.Instance.Start(); //推送机具数据
-                PosPushHelper.Instance.StartTest(); //推送机具数据
+                // PosPushHelper.Instance.Start(); //推送机具数据
+                // PosPushHelper.Instance.StartTest(); //推送机具数据
+                // SourceHelper.Instance.Start(); //获取原始数据队列
+                // PushHelper.Instance.Start(); //推送队列
             }
         }
     }

+ 1 - 0
Config/Base.cs

@@ -9,6 +9,7 @@ namespace AppConfig
         public static string SqlConnStr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
         public static string SourceSqlConnStr = ConfigurationManager.AppSettings["SourceSqlConnStr"].ToString();
         public static string RmSourceSqlConnStr = ConfigurationManager.AppSettings["RmSourceSqlConnStr"].ToString();
+        public static string JavaStatSqlConnStr = ConfigurationManager.AppSettings["JavaStatSqlConnStr"].ToString();
         public static string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
         public static string SourceHost = Library.ConfigurationManager.AppSettings["SourceHost"].ToString();
         public static string Database = Library.ConfigurationManager.AppSettings["Database"].ToString();

+ 1 - 0
Models/Push/SourceData.cs

@@ -16,5 +16,6 @@ namespace MySystem.Models.Push
         public string Title { get; set; }
         public string TargetFieldList { get; set; }
         public int QueryId { get; set; }
+        public string Month { get; set; }
     }
 }

+ 7 - 0
Models/Push/WebCMSEntities.cs

@@ -543,6 +543,13 @@ namespace MySystem.Models.Push
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.Month)
+                    .HasColumnName("month")
+                    .HasColumnType("varchar(6)")
+                    .HasComment("标题说明")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.QueryId)
                     .HasColumnType("int(11)")
                     .HasComment("查询数据表Id");

+ 2 - 2
MySystem.csproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <Project Sdk="Microsoft.NET.Sdk.Web">
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>
   <ItemGroup>
     <DotNetCliToolReference Include="dotnet-svcutil" Version="1.0.*" />
@@ -67,7 +67,7 @@
     </PackageReference>
     <PackageReference Include="GraphQL" Version="2.4.0" />
     <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
-    <PackageReference Include="MySql.Data" Version="8.0.18" />
+    <PackageReference Include="MySql.Data" Version="9.1.0" />
     <PackageReference Include="CSRedisCore" Version="3.6.5" />
   </ItemGroup>
   <ItemGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 1.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 10.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 11.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 12.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 13.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 14.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 15.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 16.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 17.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 2.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 3.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 4.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 5.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 6.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 7.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 8.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile 9.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Properties/PublishProfiles/FolderProfile.pubxml

@@ -4,9 +4,9 @@
     <WebPublishMethod>FileSystem</WebPublishMethod>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>AnyCPU</LastUsedPlatform>
-    <publishUrl>bin/Release/netcoreapp3.0/publish</publishUrl>
+    <publishUrl>bin/Release/netcoreapp3.1/publish</publishUrl>
     <DeleteExistingFiles>false</DeleteExistingFiles>
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <SelfContained>false</SelfContained>
     <_IsPortable>true</_IsPortable>
   </PropertyGroup>

+ 2 - 2
Startup.cs

@@ -102,8 +102,8 @@ namespace MySystem
                     pattern: "{controller=Home}/{action=Index}/{Id?}");
             });
 
-            // StartHelper.Instance.Start(); //开启线程
-            TestHelper.Instance.Start();
+            StartHelper.Instance.Start(); //开启线程
+            // TestHelper.Instance.Start();
         }
         
     }

+ 1 - 0
Util/Queue/PushHelper.cs

@@ -52,6 +52,7 @@ namespace MySystem
                 {
                     string FieldList = pushItem.FieldList;
                     string TableName = pushItem.TableName;
+                    TableName = SourceHelper.Instance.MatchExpressionVal(TableName);
                     int EncryptMode = pushItem.EncryptMode;
                     string NoticeUrl = pushItem.NoticeUrl;
                     string Title = pushItem.Title;

+ 114 - 9
Util/Queue/SourceHelper.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Data;
 using System.Linq;
+using System.Text.RegularExpressions;
 using System.Threading;
 using Library;
 using LitJson;
@@ -40,8 +41,11 @@ namespace MySystem
             {
                 string Title = source.Title; //说明
                 string TableName = source.TableName; //数据表
+                TableName = MatchExpressionVal(TableName);
                 string FieldList = source.FieldList; //原始数据字段
                 string FlagField = source.TargetFieldList; //原始标记字段
+                int StartId = source.QueryId;
+                string Month = source.Month;
                 string QueryField = "";
                 JsonData fieldJson = JsonMapper.ToObject(FieldList);
                 for (int i = 0; i < fieldJson.Count; i++)
@@ -50,7 +54,19 @@ namespace MySystem
                     string source_name = item["source_name"].ToString();
                     if(source_name.StartsWith("v("))
                     {
-                        QueryField += source_name.Replace("v(", "").Replace(")", "") + ",";
+                        if(source_name.Contains(" from "))
+                        {
+                            string sqlString = source_name.Replace("v(", "").Replace(")", "");
+                            Match m = Regex.Match(sqlString, "\\$\\{.*?\\}");
+                            if(m.Success)
+                            {
+                                QueryField += m.Value.Replace("${", "").Replace("}", "") + ",";
+                            }
+                        }
+                        else
+                        {
+                            QueryField += source_name.Replace("v(", "").Replace(")", "") + ",";
+                        }
                     }
                     else
                     {
@@ -59,9 +75,8 @@ namespace MySystem
                 }
 
                 //构造抓取数据
-                int StartId = source.QueryId;
                 string sql = "select " + QueryField.TrimEnd(',') + " from " + TableName + " where 1=1";
-                var condiList = db.SourceCondition.Where(m => m.SourceId == source.Id).ToList();
+                var condiList = db.SourceCondition.Where(m => m.SourceId == source.Id && m.Status == 1).ToList();
                 foreach(var condi in condiList)
                 {
                     int QueryCondition = condi.QueryCondition;
@@ -122,6 +137,7 @@ namespace MySystem
                 }
 
                 //创建原始数据表
+                if(TableName.Contains(".")) TableName = TableName.Split('.')[1];
                 var sourceEdit = db.SourceData.FirstOrDefault(m => m.Id == source.Id && m.Version == 0);
                 if(sourceEdit != null)
                 {
@@ -140,8 +156,8 @@ namespace MySystem
                 }
                 string insertSql = "";
                 sql = sql.Replace("${QueryId}$", StartId.ToString());
-                sql += " order by Id limit 10";
-                DataTable dt = CustomerSqlConn.dtable(sql, AppConfig.Base.SourceSqlConnStr);
+                sql += " order by id limit 10";
+                DataTable dt = CustomerSqlConn.dtable(sql, AppConfig.Base.JavaStatSqlConnStr);
                 foreach(DataRow dr in dt.Rows)
                 {
                     string values = "";
@@ -154,7 +170,36 @@ namespace MySystem
                         {
                             if(source_name.StartsWith("v("))
                             {
-                                values += source_name.Replace("v(", "").Replace(")", "") + ",";
+                                if(source_name.Contains(" from "))
+                                {
+                                    string sqlString = source_name.Replace("v(", "").Replace(")", "").Trim('\'');
+                                    Match m = Regex.Match(sqlString, "\\$\\{.*?\\}");
+                                    if(m.Success)
+                                    {
+                                        string sourceVal = m.Value.Replace("${", "").Replace("}", "");
+                                        sqlString = sqlString.Replace(m.Value, dr[sourceVal].ToString());
+                                        DataTable dataTable = CustomerSqlConn.dtable(sqlString, AppConfig.Base.JavaStatSqlConnStr);
+                                        if(dataTable.Rows.Count > 0)
+                                        {
+                                            if(field_type == "int" || field_type == "numeric")
+                                            {
+                                                values += "" + dataTable.Rows[0][0].ToString() + ",";
+                                            }
+                                            else if(field_type == "datetime")
+                                            {
+                                                values += "'" + DateTime.Parse(dataTable.Rows[0][0].ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "',";
+                                            }
+                                            else
+                                            {
+                                                values += "'" + dataTable.Rows[0][0].ToString() + "',";
+                                            }
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    values += source_name.Replace("v(", "").Replace(")", "") + ",";
+                                }
                             }
                             else
                             {
@@ -174,13 +219,22 @@ namespace MySystem
                         }
                     }
                     insertSql += "insert into u_" + TableName + " (" + TargetQueryField.TrimEnd(',') + ") values (" + values.TrimEnd(',') + ");";
-                    StartId = int.Parse(dr["Id"].ToString());
-                    CustomerSqlConn.op("update " + TableName + " set " + FlagField + "=1 where Id=" + StartId, AppConfig.Base.RmSourceSqlConnStr);
+                    StartId = int.Parse(dr["id"].ToString());
+                    // CustomerSqlConn.op("update " + TableName + " set " + FlagField + "=1 where Id=" + StartId, AppConfig.Base.RmSourceSqlConnStr);
                 }
                 var edit = db.SourceData.FirstOrDefault(m => m.Id == source.Id);
                 if(edit != null)
                 {
-                    edit.QueryId = StartId;
+                    if(Month != DateTime.Now.ToString("yyyyMM"))
+                    {
+                        edit.Month = DateTime.Now.ToString("yyyyMM");
+                        edit.QueryId = 0;
+                    }
+                    else
+                    {
+                        edit.QueryId = StartId;
+                        if(edit.Month != Month) edit.Month = Month;
+                    }
                     db.SaveChanges();
                 }
                 if(!string.IsNullOrEmpty(insertSql))
@@ -242,5 +296,56 @@ namespace MySystem
             sql += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='" + Title + "';";
             CustomerSqlConn.op(sql, AppConfig.Base.SqlConnStr);
         }
+
+        public string GetExpressionVal(string str)
+        {
+            if(str == "#{now}#") return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            if(str == "#{today}#") return DateTime.Now.ToString("yyyy-MM-dd");
+            if(str == "#{this_month}#") return DateTime.Now.ToString("yyyy-MM");
+            if(str.StartsWith("#{now") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
+            if(str.StartsWith("#{now") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
+            if(str.StartsWith("#{today") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
+            if(str.StartsWith("#{today") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
+            if(str.StartsWith("#{this_month") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
+            if(str.StartsWith("#{this_month") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
+            if(str.StartsWith("#{") && str.EndsWith("DAY}#")) return DateTime.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[0]).AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
+            if(str.StartsWith("#{") && str.EndsWith("MONTH}#")) return DateTime.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[0]).AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
+            if(str.StartsWith("#{split") && str.EndsWith("}#"))
+            {
+                string[] data = str.Replace("#{", "").Replace("}#", "").Split(',');
+                string text = data[1];
+                string splitTag = data[2];
+                string index = data[3];
+                return text.Split(new string[]{ splitTag }, StringSplitOptions.None)[int.Parse(index)];
+            }
+            else if(str.StartsWith("#{") && str.EndsWith("}#"))
+            {
+                string[] data = str.Replace("#{", "").Replace("}#", "").Split(',');
+                string tag = data[0];
+                string format = data[data.Length - 1];
+                if(tag == "now" && format.StartsWith("yyyy"))
+                {
+                    if(data.Length == 2)
+                    {
+                        return DateTime.Now.ToString(format);
+                    }
+                    else if(data.Length == 4)
+                    {
+                        if(data[2] == "DAY") return DateTime.Now.AddDays(int.Parse(data[1])).ToString(format);
+                        if(data[2] == "MONTH") return DateTime.Now.AddMonths(int.Parse(data[1])).ToString(format);
+                    }
+                }
+            }
+            return str;
+        }
+        public string MatchExpressionVal(string str)
+        {
+            MatchCollection mc = Regex.Matches(str, "#\\{.*?\\}#");
+            foreach(Match m in mc)
+            {
+                str = str.Replace(m.Value, GetExpressionVal(m.Value));
+            }
+            return str;
+        }
     }
 }

+ 1 - 0
appsettings.Development.json

@@ -15,6 +15,7 @@
     "SqlConnStr": "server=47.108.62.166;port=3306;user=KxsPushServer;password=0j3sEGdlvOsgGbat;database=KxsPushServer;charset=utf8;",
     "SourceSqlConnStr": "server=47.108.62.166;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=KxsMainServer;charset=utf8;",
     "RmSourceSqlConnStr": "server=47.108.62.166;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=KxsMainServer;charset=utf8;",
+    "JavaStatSqlConnStr": "server=47.109.61.191;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=kxs_stat;charset=utf8mb4;",
     "RedisConnStr": "47.108.62.166:6379,password=klm@redis,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",

+ 1 - 1
global.json

@@ -1,5 +1,5 @@
 {
   "sdk": {
-    "version": "3.0.100"
+    "version": "3.1.426"
   }
 }