ソースを参照

省市区数据导入

新疆警官学校中职
dao 1ヶ月前
コミット
d50520d608
3個のファイルの変更14861行の追加1行の削除
  1. +61
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
  2. +3
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  3. +14797
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/ChinaCitys.json

+ 61
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs ファイルの表示

@@ -46,6 +46,9 @@ namespace Learun.Application.Web.Controllers
WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL();
private VisitorInfoIBLL visitorInfoIBLL = new VisitorInfoBLL();
private DIC_PROVINCEIBLL dicPro=new DIC_PROVINCEBLL();
private DIC_CITYIBLL dicCity=new DIC_CITYBLL();
private DIC_AREAIBLL dicArea=new DIC_AREABLL();
#endregion
private readonly ISms _aliyunSms = new AliyunSms();
CacheByRedis _redis = new CacheByRedis();
@@ -1187,6 +1190,64 @@ namespace Learun.Application.Web.Controllers
}
#endregion

#region
public ActionResult SyncProData()
{
// 读取JSON文件内容
string json = System.IO.File.ReadAllText(Server.MapPath("/XmlConfig/ChinaCitys.json")); //File.ReadAllText("data.json");

// 反序列化JSON到C#对象
var pro = JsonConvert.DeserializeObject<List<Province>>(json);
if (pro.Any())
{
foreach (var province in pro)
{
var prov = new DIC_PROVINCEEntity { PCODE = province.code, PNAME = province.province };
dicPro.SaveEntity("", prov);
if(province.citys.Any())
{
foreach (var item in province.citys)
{
var city = new DIC_CITYEntity { CCODE = item.code.Substring(0,6), CNAME = item.city, CPARENT = province.code };
dicCity.SaveEntity("", city);
if(item.areas.Any())
{
foreach(var area in item.areas)
{
var ar = new DIC_AREAEntity { ACODE = area.code.Substring(0, 6), ANAME = area.area, APARENT = item.code.Substring(0, 6) };
dicArea.SaveEntity("", ar);
}
}
}
}
}
}

return Content(json);
}
private class Province
{
public string province { get; set; }

public string code { get; set; }
public List<City> citys { get; set; }
}
private class City
{
public string city { get; set; }

public string code { get; set; }
public List<Area> areas { get; set; }
}
private class Area
{
public string area { get; set; }

public string code { get; set; }
}
#endregion

/// <summary>
/// 访客注册
/// </summary>


+ 3
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj ファイルの表示

@@ -23,7 +23,8 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<UseGlobalApplicationHostFile />
<Use64BitIISExpress>false</Use64BitIISExpress>
<Use64BitIISExpress>
</Use64BitIISExpress>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
@@ -7107,6 +7108,7 @@
<Content Include="Areas\EducationalAdministration\Views\HistoryStuScore\Index.js" />
<Content Include="Areas\EducationalAdministration\Views\HistoryStuScore\Form.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\HistoryStuScore\Form.js" />
<Content Include="XmlConfig\ChinaCitys.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\EducationalAdministration\Views\OpenLessonPlanOfElectivePre\" />


+ 14797
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/ChinaCitys.json
ファイル差分が大きすぎるため省略します
ファイルの表示


読み込み中…
キャンセル
保存