From 8fcd7a67e4391a5f1fbdb590c2a3f913aeb2a0a0 Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期二, 31 三月 2026 14:11:23 +0800
Subject: [PATCH] PP平库功能上线,PDA优化,部分问题点优化

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs |   86 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs"
index dd90e9b..a81c3b5 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs"
@@ -200,5 +200,91 @@
             }
             return list;
         }
+
+        public static T PPPKCodeAnalysis<T>(AnalysisCodeEnum analysisCode, string code)
+        {
+            Type type = typeof(T);
+            object? obj = Activator.CreateInstance(type);
+            if (obj == null)
+                throw new Exception("瀹炰緥鍖栧璞¢敊璇�");
+            T result = (T)obj;
+            try
+            {
+                AnalysisRuleAttribute? analysisRule = type.GetCustomAttribute<AnalysisRuleAttribute>();
+                if (analysisRule != null)
+                {
+                    SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
+                    {
+                        ConfigId = MainDb.CurrentDbConnId,
+                        ConnectionString = DBContext.GetMainConnectionDb().Connection,
+                        IsAutoCloseConnection = true,
+                        DbType = MainDb.DbType,
+                    });
+
+                    dynamic ruleConfig = sugarClient.Queryable(MainDb.AnalysisRuleConfig, "x").Where(MainDb.AnalysisCode, "=", analysisCode.ToString()).First();
+                    if (ruleConfig != null)
+                    {
+                        string format = ruleConfig.Format;
+                        string splitStr = ruleConfig.SplitStr;
+                        List<string> items = format.Split(splitStr).ToList();
+                        List<string> codes = code.Split(splitStr).ToList();
+                        if (items.Count == codes.Count)
+                        {
+                            PropertyInfo[] propertyInfos = type.GetProperties();
+                            if (AnalysisRuleEnum.Split == analysisRule.AnalysisRule)
+                            {
+                                for (int i = 0; i < propertyInfos.Length; i++)
+                                {
+                                    PropertyInfo propertyInfo = propertyInfos[i];
+                                    AnalysisItemRuleAttribute? analysisItemRule = propertyInfo.GetCustomAttribute<AnalysisItemRuleAttribute>();
+                                    if (analysisItemRule != null)
+                                    {
+                                        if (analysisItemRule.AnalysisFormaType == AnalysisFormatTypeEnum.BD)
+                                        {
+                                            propertyInfo.SetValue(result, code.ChangeType(propertyInfo.PropertyType));
+                                        }
+                                        else
+                                        {
+                                            int index = items.IndexOf($"[{analysisItemRule.AnalysisFormaType}]");
+                                            if (index != -1)
+                                            {
+                                                propertyInfo.SetValue(result, codes[index]);
+                                            }
+                                            else
+                                            {
+                                                string? codeItem = items.FirstOrDefault(x => x.Contains($"[{analysisItemRule.AnalysisFormaType}]"));
+                                                if (!string.IsNullOrEmpty(codeItem))
+                                                {
+                                                    index = items.IndexOf(codeItem);
+                                                    if (index != -1)
+                                                    {
+                                                        string value = codes[index];
+                                                        string replaceStr = codeItem.Replace($"[{analysisItemRule.AnalysisFormaType}]", "");
+
+                                                        propertyInfo.SetValue(result, value.Replace(replaceStr, "").ChangeType(propertyInfo.PropertyType));
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"瑙f瀽閿欒,{ex.Message}");
+            }
+
+            (bool, string, object?) validateResult = ModelValidate.ValidateModelData(result, type);
+            if (!validateResult.Item1)
+            {
+                throw new Exception($"瑙f瀽閿欒,{validateResult.Item2}");
+            }
+
+            return result;
+        }
     }
 }

--
Gitblit v1.9.3