hutongqing
2024-12-10 8d341db9d2d5699d527c88c935f0c4ce255a57a4
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/CodeAnalysisHelper.cs
@@ -1,4 +1,5 @@
锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -11,6 +12,7 @@
using WIDESEA_Core.DB;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Seed;
using WIDESEA_Core.Utilities;
namespace WIDESEA_Core.Helper
{
@@ -61,14 +63,37 @@
                                    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));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
@@ -76,6 +101,13 @@
            {
            }
            (bool, string, object?) validateResult = ModelValidate.ValidateModelData(result, type);
            if (!validateResult.Item1)
            {
                throw new Exception($"瑙f瀽閿欒,{validateResult.Item2}");
            }
            return result;
        }
@@ -134,9 +166,25 @@
                                            {
                                                int index = items.IndexOf($"[{analysisItemRule.AnalysisFormaType}]");
                                                if (index != -1)
                                                    propertyInfo.SetValue(result, codes[index].ChangeType(propertyInfo.PropertyType));
                                                {
                                                    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));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }