lss
2025-05-30 38eff4fc0100131b180ffa872009b502629743f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using NongFuWebApi.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NongFuWebApi.Controllers.AMSModel;
 
namespace NongFuWebApi.Services
{
    [AttributeUsage(AttributeTargets.Class, Inherited = true)]
    class STAttribute : SugarTable
    {
        public static Dictionary<string, string> TableModelName = new Dictionary<string, string>();
 
        public STAttribute(string tableName) : base(tableName)
        {
            string value = "";
            if (TableModelName.TryGetValue(TableName, out value))
            {
                TableName = value;
            }
        }
 
        /// <summary>
        /// 初始化表名
        /// </summary>
        public static void InitTableName()
        {
            LogHelper.Info($"StartUp Init CreateTable...");
            var order = new SqlHelper<ChunAnCacheData>().CreateTable();//车体状态信息表
            LogHelper.Info($"StartUp Init CreateTable Complete!");
 
            LogHelper.Info($"StartUp Init TableName...");
            string[] table = ConfigurationManager.AppSettings.AllKeys;
            if (table.Length > 0)
            {
                List<string> tableName = new List<string>();
                for (int i = 0; i < table.Length; i++)
                {
                    if (table[i].Contains("表")) tableName.Add(table[i]);
                }
                if (tableName.Count > 0)
                {
                    tableName.ForEach(a =>
                    {
                        string tableSqlName = ConfigurationManager.AppSettings[a].ToString();
                        if (!TableModelName.Keys.Contains(a))
                        {
                            LogHelper.Info($"StartUp Init TableName Add:tableName:{a},tableSqlName:{tableSqlName}");
                            TableModelName.Add(a, tableSqlName);
                        }
                    });
                }
            }
            LogHelper.Info($"StartUp Init TableName Complete!");
        }
        /// <summary>
        /// 创建数据中间表表
        /// </summary>
        /// <returns></returns>
        public static void CreateMiddleTable()
        {
            //var order = new SqlHelper<HangChaAGV>().CreateTable();//车体状态信息表
        }
    }
}