😎增加民政部官网行政区域同步及升级依赖
This commit is contained in:
parent
c4e98b2b1a
commit
7b4b5d0c09
@ -42,11 +42,11 @@
|
||||
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.6.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.9.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.171" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.9" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1136" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1137" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -185,6 +185,10 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var tableOutputList = new List<TableOutput>();
|
||||
foreach (var item in entityInfos)
|
||||
{
|
||||
var tbConfigId = item.Type.GetCustomAttribute<TenantAttribute>()?.configId as string ?? SqlSugarConst.MainConfigId;
|
||||
if (item.Type.IsDefined(typeof(LogTableAttribute))) tbConfigId = SqlSugarConst.LogConfigId;
|
||||
if (tbConfigId != configId) continue;
|
||||
|
||||
var dbTableName = item.DbTableName;
|
||||
int bracketIndex = dbTableName.IndexOf('{');
|
||||
if (bracketIndex != -1)
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using NewLife.Remoting;
|
||||
using NewLife.Serialization;
|
||||
|
||||
namespace Admin.NET.Core.Service;
|
||||
|
||||
@ -150,6 +151,88 @@ public class SysRegionService : IDynamicApiController, ITransient
|
||||
await _sysRegionRep.DeleteAsync(u => regionIdList.Contains(u.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步行政区划(民政部) 🔖
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisplayName("同步行政区划(民政部)")]
|
||||
public async Task SyncRegionMzb()
|
||||
{
|
||||
var syncLevel = await _sysConfigService.GetConfigValueByCode<int>(ConfigConst.SysRegionSyncLevel);
|
||||
if (syncLevel is < 1 or > 5) syncLevel = 3; // 默认区县级
|
||||
|
||||
var html = await "http://xzqh.mca.gov.cn/map".GetAsStringAsync();
|
||||
var municipalityList = new List<string> { "北京", "天津", "上海", "重庆" };
|
||||
var provList = Regex.Match(html, @"(?<=var json = )(\[\{.*?\}\])(?=;)").Value.ToJsonEntity<List<Dictionary<string, string>>>();
|
||||
foreach (var dict1 in provList)
|
||||
{
|
||||
var list = new List<SysRegion>();
|
||||
var provName = dict1.GetValueOrDefault("shengji");
|
||||
var province = new SysRegion
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Name = Regex.Replace(provName, "[((].*?[))]", ""),
|
||||
Code = dict1.GetValueOrDefault("quHuaDaiMa"),
|
||||
CityCode = dict1.GetValueOrDefault("quhao"),
|
||||
Level = 1,
|
||||
Pid = 0,
|
||||
};
|
||||
if (municipalityList.Any(m => province.Name.StartsWith(m))) province.Name += "(省)";
|
||||
list.Add(province);
|
||||
|
||||
if (syncLevel <= 1) continue;
|
||||
|
||||
var prefList = await GetSelectList(provName);
|
||||
foreach (var dict2 in prefList)
|
||||
{
|
||||
var prefName = dict2.GetValueOrDefault("diji");
|
||||
var city = new SysRegion
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Code = dict2.GetValueOrDefault("quHuaDaiMa"),
|
||||
CityCode = dict2.GetValueOrDefault("quhao"),
|
||||
Pid = province.Id,
|
||||
Name = prefName,
|
||||
Level = 2
|
||||
};
|
||||
if (municipalityList.Any(m => city.Name.StartsWith(m))) city.Name += "(地)";
|
||||
list.Add(city);
|
||||
|
||||
if (syncLevel <= 2) continue;
|
||||
|
||||
var countyList = await GetSelectList(provName, prefName);
|
||||
foreach (var dict3 in countyList)
|
||||
{
|
||||
var countyName = dict3.GetValueOrDefault("xianji");
|
||||
var county = new SysRegion
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Code = dict3.GetValueOrDefault("quHuaDaiMa"),
|
||||
CityCode = dict3.GetValueOrDefault("quhao"),
|
||||
Name = countyName,
|
||||
Pid = city.Id,
|
||||
Level = 3
|
||||
};
|
||||
list.Add(county);
|
||||
}
|
||||
}
|
||||
|
||||
await _sysRegionRep.AsDeleteable().ExecuteCommandAsync();
|
||||
await _sysRegionRep.Context.Fastest<SysRegion>().BulkCopyAsync(list);
|
||||
}
|
||||
|
||||
// 获取选择数据
|
||||
async Task<List<Dictionary<string, string>>> GetSelectList(string prov, string prefecture = null)
|
||||
{
|
||||
var json = await "http://xzqh.mca.gov.cn/selectJson".SetQueries(new
|
||||
{
|
||||
shengji = prov,
|
||||
diji = prefecture,
|
||||
}).PostAsStringAsync();
|
||||
return json.ToJsonEntity<List<Dictionary<string, string>>>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步行政区划(高德) 🔖
|
||||
/// </summary>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.12.06",
|
||||
"lastBuildTime": "2024.12.08",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -74,7 +74,7 @@
|
||||
"vue-router": "^4.5.0",
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.3.19",
|
||||
"vxe-pc-ui": "^4.3.21",
|
||||
"vxe-table": "^4.8.10",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||
@ -82,7 +82,7 @@
|
||||
"xlsx-js-style": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/vue": "^4.1.2",
|
||||
"@iconify/vue": "^4.2.0",
|
||||
"@plugin-web-update-notification/vite": "^1.7.1",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.17.9",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user