|
|
@ -2,8 +2,9 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
|
|
|
|
using io = System.IO; |
|
|
|
namespace BBWY.Test |
|
|
|
{ |
|
|
|
internal class Program |
|
|
@ -12,30 +13,30 @@ namespace BBWY.Test |
|
|
|
|
|
|
|
static void Main(string[] args) |
|
|
|
{ |
|
|
|
IDictionary<int, string> deliverySelfDic = new Dictionary<int, string>() |
|
|
|
{ |
|
|
|
{2 , "1274"} //厂家自送
|
|
|
|
}; |
|
|
|
var wayBillNoResponse = JObject.Parse("{\"LogisticsCompanyId\":\"101\",\"LogisticsCompanyName\":\"圆通速递(YTO)\",\"WayBillNo\":\"YT8150425043862\"}"); |
|
|
|
var logisticsCompanyList = JArray.Parse("[{\"Id\":\"2087\",\"Name\":\"京东快递\"},{\"Id\":\"463\",\"Name\":\"圆通快递\"},{\"Id\":\"2170\",\"Name\":\"邮政快递包裹\"},{\"Id\":\"1327\",\"Name\":\"韵达快递\"},{\"Id\":\"680414\",\"Name\":\"中通快运\"},{\"Id\":\"467\",\"Name\":\"顺丰快递\"},{\"Id\":\"256122\",\"Name\":\"UPS\"},{\"Id\":\"1747\",\"Name\":\"优速快递\"},{\"Id\":\"3046\",\"Name\":\"德邦快递\"},{\"Id\":\"465\",\"Name\":\"邮政EMS\"},{\"Id\":\"1665004\",\"Name\":\"云仓速递\"},{\"Id\":\"4832\",\"Name\":\"安能物流\"},{\"Id\":\"1499\",\"Name\":\"中通速递\"}]"); |
|
|
|
|
|
|
|
var companyId = ConvertLogisticsCompanyId(wayBillNoResponse.Value<string>("LogisticsCompanyName"), logisticsCompanyList, 2, deliverySelfDic); |
|
|
|
Console.WriteLine(companyId); |
|
|
|
Console.ReadKey(); |
|
|
|
} |
|
|
|
|
|
|
|
var rootPath = @"C:\Users\pengcong001\Desktop"; |
|
|
|
var resultList = new List<string>(); |
|
|
|
var minDate = 11; var maxDate = 25; |
|
|
|
rootPath = @"C:\Users\pengcong001\Desktop\test"; |
|
|
|
|
|
|
|
private static string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<JToken> targetLogisticsList, int tagetLogisticsPlatform, IDictionary<int, string> deliverySelfDic) |
|
|
|
for (var i = minDate; i <= maxDate; i++) |
|
|
|
{ |
|
|
|
var content = io.File.ReadAllText(io.Path.Combine(rootPath, $"2022-05-{i}.txt"), Encoding.UTF8); |
|
|
|
var matches = Regex.Matches(content, @"""logisticsCompanyName"":\s*""(.+)"","); |
|
|
|
foreach (Match match in matches) |
|
|
|
{ |
|
|
|
var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); |
|
|
|
if (match.Success) |
|
|
|
{ |
|
|
|
var sname = match.Groups[1].Value; |
|
|
|
var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Value<string>("Name").Contains(sname)); |
|
|
|
if (targetLogistics != null) |
|
|
|
return targetLogistics.Value<string>("Id"); |
|
|
|
var _1688logisticsCompanyName = match.Groups[1].Value; |
|
|
|
if (!resultList.Any(s => s.Equals(_1688logisticsCompanyName))) |
|
|
|
resultList.Add(_1688logisticsCompanyName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return deliverySelfDic[tagetLogisticsPlatform]; |
|
|
|
Console.WriteLine(resultList.Count()); |
|
|
|
|
|
|
|
foreach (var s in resultList) |
|
|
|
Console.WriteLine(s); |
|
|
|
Console.ReadKey(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|