From 392501b5e15c88ef8070bea9dab5f45e88b5053a Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Tue, 2 Jan 2024 02:41:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E4=B8=9A=E5=B8=A6=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DataRepairController.cs | 6 ++ .../DataRepair/DataRepairBusiness.cs | 72 +++++++++++++++---- .../Db/Purchaser/PurchaserExtendedInfo.cs | 11 +-- ...uanTan_Supplier_ProductCategoryResponse.cs | 2 + .../Client/Impl/OP_QuanTanClient.cs | 1 + .../Product/OP_ProductCategoryResponse.cs | 2 + 6 files changed, 78 insertions(+), 16 deletions(-) diff --git a/BBWYB.Server.API/Controllers/DataRepairController.cs b/BBWYB.Server.API/Controllers/DataRepairController.cs index dc85ffe..9d0640b 100644 --- a/BBWYB.Server.API/Controllers/DataRepairController.cs +++ b/BBWYB.Server.API/Controllers/DataRepairController.cs @@ -115,5 +115,11 @@ namespace BBWYB.Server.API.Controllers { dataRepairBusiness.SyncPurchaserCategory(); } + + [HttpGet] + public void Test() + { + dataRepairBusiness.Test(); + } } } diff --git a/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs b/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs index 12b90a7..991f37c 100644 --- a/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs +++ b/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs @@ -12,6 +12,7 @@ using SDKAdapter.OperationPlatform.Models; using SDKAdapter.PurchasePlatform.Client; using SDKAdapter.PurchasePlatform.Models; using System.Data; +using System.Text.RegularExpressions; using Yitter.IdGenerator; namespace BBWYB.Server.Business @@ -972,7 +973,7 @@ namespace BBWYB.Server.Business var request = new OP_QueryProductCategoryRequest() { PageIndex = 1, - PageSize = 50, + PageSize = 500, AppKey = "BBWYB2023022501", AppSecret = "3a1521deccc6819d61788a0d6baae49e9", AppToken = "9" @@ -985,19 +986,26 @@ namespace BBWYB.Server.Business //找出新增的类目 - var newCategoryList = qtCategoryList.Where(c => !dbCategoryList.Any(dc => dc.Id == long.Parse(c.CategoryId))).ToList(); - if (newCategoryList.Count() > 0) + //var newCategoryList = qtCategoryList.Where(c => !dbCategoryList.Any(dc => dc.Id == long.Parse(c.CategoryId))).ToList(); + //if (newCategoryList.Count() > 0) + //{ + insertList.AddRange(qtCategoryList.Select(c => new PurchaserExtendedInfo() { - insertList.AddRange(newCategoryList.Select(c => new PurchaserExtendedInfo() - { - Id = long.Parse(c.CategoryId), - Name = c.CategoryName, - CreateTime = DateTime.Now, - Type = Enums.PurchaserBasicInfoType.主营类目 - }).ToList()); - } + Id = long.Parse(c.CategoryId), + Name = c.CategoryName, + CreateTime = DateTime.Now, + Type = Enums.PurchaserBasicInfoType.主营类目, + ExtendInfo = c.CategoryPath + }).ToList()); + //} + + + fsql.Transaction(() => + { + fsql.Delete().Where(x => x.Type == Enums.PurchaserBasicInfoType.主营类目).ExecuteAffrows(); + fsql.Insert(insertList).ExecuteAffrows(); + }); - fsql.Insert(insertList).ExecuteAffrows(); //找出接口丢失的类目 @@ -1134,5 +1142,45 @@ namespace BBWYB.Server.Business } } + + public void Test(string location) + { + IDictionary> provinceDictionary = new Dictionary>() + { + { "省", new List() + { + "黑龙江","吉林","辽宁","河北","山西","陕西","甘肃","青海","河南","湖北","湖南","山东","江苏","安徽","浙江","江西","福建","台湾","贵州","四川","云南","广东","海南" + } + }, + { "自治区", new List(){ "内蒙古","西藏"}}, + { "回族自治区", new List(){"宁夏"}}, + { "维吾尔自治区", new List(){"新疆"}}, + { "壮族自治区", new List(){"广西"}}, + { "特别行政区",new List(){ "香港","澳门"}}, + { "市",new List(){ "重庆","北京","天津","上海"}} + }; + + foreach (var provincekey in provinceDictionary.Keys) + { + var province = provinceDictionary[provincekey].FirstOrDefault(p => location.StartsWith(p)); + } + + Console.WriteLine(); + } + + private string NormalizeLocationString(string input) + { + // 使用正则表达式移除多余的空格和省市之间的空格 + string normalizedString = Regex.Replace(input, @"\s+", ""); + + // 如果字符串中没有省市的分隔符,则添加一个 + if (!normalizedString.Contains("省") && !normalizedString.Contains("市")) + { + int index = normalizedString.Length / 2; + normalizedString = normalizedString.Insert(index, "省"); + } + + return normalizedString; + } } } diff --git a/BBWYB.Server.Model/Db/Purchaser/PurchaserExtendedInfo.cs b/BBWYB.Server.Model/Db/Purchaser/PurchaserExtendedInfo.cs index 73bd4ad..981499a 100644 --- a/BBWYB.Server.Model/Db/Purchaser/PurchaserExtendedInfo.cs +++ b/BBWYB.Server.Model/Db/Purchaser/PurchaserExtendedInfo.cs @@ -8,19 +8,22 @@ namespace BBWYB.Server.Model.Db { [Column(DbType = "bigint", IsPrimary = true)] - public long Id { get; set; } + public long Id { get; set; } [Column(DbType = "datetime")] - public DateTime? CreateTime { get; set; } + public DateTime? CreateTime { get; set; } [Column(StringLength = 50)] - public string Name { get; set; } + public string Name { get; set; } /// /// 类型 主营类目=0 标签=1 /// [Column(MapType = typeof(int?))] - public Enums.PurchaserBasicInfoType? Type { get; set; } + public Enums.PurchaserBasicInfoType? Type { get; set; } + + [Column(StringLength = 50)] + public string ExtendInfo { get; set; } } diff --git a/QuanTan.SDK/Models/Supplier/Response/Product/QuanTan_Supplier_ProductCategoryResponse.cs b/QuanTan.SDK/Models/Supplier/Response/Product/QuanTan_Supplier_ProductCategoryResponse.cs index 06a0caa..dc91e09 100644 --- a/QuanTan.SDK/Models/Supplier/Response/Product/QuanTan_Supplier_ProductCategoryResponse.cs +++ b/QuanTan.SDK/Models/Supplier/Response/Product/QuanTan_Supplier_ProductCategoryResponse.cs @@ -5,5 +5,7 @@ public string CategoryId { get; set; } public string CategoryName { get; set; } + + public string CategoryPath { get; set; } } } diff --git a/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs b/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs index b513adc..cb3cd6d 100644 --- a/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs +++ b/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs @@ -261,6 +261,7 @@ namespace SDKAdapter.OperationPlatform.Client { CategoryId = x.CategoryId, CategoryName = x.CategoryName, + CategoryPath = x.CategoryPath }).ToList() : null }; } diff --git a/SDKAdapter/OperationPlatform/Models/Response/Product/OP_ProductCategoryResponse.cs b/SDKAdapter/OperationPlatform/Models/Response/Product/OP_ProductCategoryResponse.cs index 999fa21..1363c36 100644 --- a/SDKAdapter/OperationPlatform/Models/Response/Product/OP_ProductCategoryResponse.cs +++ b/SDKAdapter/OperationPlatform/Models/Response/Product/OP_ProductCategoryResponse.cs @@ -5,5 +5,7 @@ public string CategoryId { get; set; } public string CategoryName { get; set; } + + public string CategoryPath { get; set; } } }