Commit 51d5561c authored by 黄奎's avatar 黄奎

文件导入修改

parent abe1623c
......@@ -254,21 +254,18 @@ namespace Mall.Common.Plugin
/// <returns></returns>
private List<Tuple<int, int, string>> FindPicCell()
{
string _file = Path.Combine(RootPath, "xl/drawings/drawing1.xml"); // 图片信息文件
List<Tuple<int, int, string>> PictureInfo = new List<Tuple<int, int, string>> { }; // 存放返回的图片信息格式(row, column, path)
List<Tuple<string, string>> PictureTargetList = new List<Tuple<string, string>> { }; // 存放图片ID和路径对应关系的List
string _file = Path.Combine(RootPath, "xl/drawings/drawing1.xml"); // 图片信息文件
if (System.IO.File.Exists(_file))
{
// 先获取图片文件的路径信息
FindPicPathByID(ref PictureTargetList);
// 默认xml命名空间
XNamespace xdr = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
XNamespace a = "http://schemas.openxmlformats.org/drawingml/2006/main";
XNamespace r;
//string xml = Read(_file);
XDocument xDoc = XDocument.Load(_file);
// 给xml命名空间赋文件中的当前值
var root = xDoc.Root;
foreach (var item in root.Attributes())
......@@ -310,6 +307,7 @@ namespace Mall.Common.Plugin
}
PictureInfo.Add(new Tuple<int, int, string>(int.Parse(StartRow), int.Parse(StartCol), PicPath));
}
}
return PictureInfo;
}
......@@ -321,9 +319,10 @@ namespace Mall.Common.Plugin
private void FindPicPathByID(ref List<Tuple<string, string>> PictureTargetList, int _id = 1)
{
string _file = Path.Combine(RootPath, $"xl/drawings/_rels/drawing{_id}.xml.rels"); // 图片对应关系文件
if (System.IO.File.Exists(_file))
{
XDocument xDoc = XDocument.Load(_file);
var root = xDoc.Root;
foreach (XElement node in root.Nodes())
{
var attrs = node.Attributes();
......@@ -335,7 +334,6 @@ namespace Mall.Common.Plugin
{
Id = attr.Value.ToString();
}
else if (attr.Name == "Target")
{
Target = attr.Value.ToString();
......@@ -345,4 +343,5 @@ namespace Mall.Common.Plugin
}
}
}
}
}
......@@ -46,7 +46,24 @@ namespace Mall.DataHelper.Import
/// <returns></returns>
public static RB_Brand_Enterprise_Extend DataRowToModel(DataRow dr)
{
RB_Brand_Enterprise_Extend model = new RB_Brand_Enterprise_Extend();
RB_Brand_Enterprise_Extend model = new RB_Brand_Enterprise_Extend()
{
BrandName = "",
Logo = "",
Banner = "",
VideoUrl = "",
CategoryName = "",
Introduce = "",
ShopNum = 0,
AreaRequirement = 0,
CustomerType = "",
BrandType = "",
Cooperation = "",
PropertyDemand = "",
Complementary = "",
ContactName = "",
ContactPhone = "",
};
if (dr != null)
{
if (dr.Table.Columns.Contains("品牌名称") && !string.IsNullOrEmpty(dr["品牌名称"].ToString().Trim()))
......@@ -153,7 +170,29 @@ namespace Mall.DataHelper.Import
/// <returns></returns>
public static RB_Building_Carrier_Extend DataRowToModel(DataRow dr)
{
RB_Building_Carrier_Extend model = new RB_Building_Carrier_Extend();
RB_Building_Carrier_Extend model = new RB_Building_Carrier_Extend()
{
CategoryName = "",
Logo = "",
Address = "",
LatAndLon = "",
OpeningStatus = 0,
CarrierSize = 0,
LayersNum = "",
CarNum = 0,
BuiltUpArea = 0,
AreaRequirement = 0,
VisitorsFlowrate = "",
SupportingFacilities = "",
ManagementCompany = "",
Developers = "",
Ascription = "",
CarrierPlan = "",
BrandDemand = "",
Location = "",
ContactName = "",
ContactPhone = ""
};
if (dr != null)
{
if (dr.Table.Columns.Contains("项目名称") && !string.IsNullOrEmpty(dr["项目名称"].ToString().Trim()))
......@@ -296,7 +335,35 @@ namespace Mall.DataHelper.Import
/// <returns></returns>
public static RB_Building_Extend DataRowToModel(DataRow dr)
{
RB_Building_Extend model = new RB_Building_Extend();
RB_Building_Extend model = new RB_Building_Extend()
{
BuildId = 0,
Name = "",
Banner = "",
Address = "",
LatAndLon = "",
OperationTime = "",
CategoryName = "",
Areas = "",
BuildingNum = "",
FloorNum = "",
ElevatorNum = "",
FloorHeight = 0,
Developers = "",
PropertyComp = "",
SaleOrSelf = "",
IsAllOperate = 0,
ConstructionTime = "",
PropertyFee = 0,
RentFee = 0,
IndustryDirection = "",
BrandDemand = "",
Other = "",
ContactName = "",
ContactPhone = "",
QIds = "",
BannerList = new List<string>()
};
if (dr != null)
{
if (dr.Table.Columns.Contains("楼宇名称") && !string.IsNullOrEmpty(dr["楼宇名称"].ToString().Trim()))
......@@ -442,7 +509,27 @@ namespace Mall.DataHelper.Import
/// <returns></returns>
public static RB_EnterpriseServices_Extend DataRowToModel(DataRow dr)
{
RB_EnterpriseServices_Extend model = new RB_EnterpriseServices_Extend();
RB_EnterpriseServices_Extend model = new RB_EnterpriseServices_Extend()
{
Name = "",
Banner = "",
Introduction = "",
DevIntention = "",
ETypeName = "",
Address = "",
LatAndLon = "",
OperationTime = "",
CategoryName = "",
Renovation = "",
Payment = "",
HandoverDate = "",
IntentionalFloor = "",
ElevatorNum = "",
PropertyFee = 0,
RentFee = 0,
ContactName = "",
ContactPhone = "",
};
if (dr != null)
{
if (dr.Table.Columns.Contains("企业名称") && !string.IsNullOrEmpty(dr["企业名称"].ToString().Trim()))
......
......@@ -42,19 +42,23 @@ namespace TestCore
static void Main(string[] args)
{
Console.WriteLine("开始.." );
int Type = 4;
int Type = 3;
//品牌
if (Type == 1)
{
BrandImport();
}
//载体
else if (Type == 2)
{
CarrierImport();
}
//楼宇
else if (Type == 3)
{
BuildingImport();
}
//企业服务
else
{
EnterpriseImport();
......@@ -181,9 +185,12 @@ namespace TestCore
string buildingFile = rootPath + @"\活力楼宇导入.xlsx";
var buildingList = BuildingHelper.ImportYBuildingData(buildingFile, tempPath);
var categoryList = brandClassRepository.GetBrandClassListRepository(new Mall.Model.Extend.TradePavilion.RB_BrandClass_Extend() { });
var oldBuildList = buildingRepository.GetBuildingRepository(new Mall.Model.Extend.TradePavilion.RB_Building_Extend() { TenantId = 30, MallBaseId = 20 });
Console.WriteLine("End 解析楼宇文件...");
Console.WriteLine("开始导入楼宇数据...");
foreach (var item in buildingList)
{
if (!string.IsNullOrEmpty(item.Name))
{
if (!string.IsNullOrEmpty(item.Banner))
{
......@@ -210,6 +217,8 @@ namespace TestCore
var tempCategory = categoryList.FirstOrDefault(qitem => qitem.ClassName.Trim() == item.CategoryName.Trim());
item.CategoryId = tempCategory?.ID ?? 0;
}
var tempBuild = oldBuildList?.FirstOrDefault(qitem => qitem.Name == item.Name);
item.BuildId = tempBuild?.BuildId ?? 0;
item.TenantId = 30;
item.MallBaseId = 20;
item.CreateBy = 30;
......@@ -217,10 +226,14 @@ namespace TestCore
item.UpdateBy = 30;
item.UpdateDate = DateTime.Now;
}
}
bool flag = false;
string str = Mall.Common.Plugin.JsonHelper.Serialize(buildingList);
if (buildingList != null && buildingList.Count > 0)
{
flag= buildingRepository.InsertBatch(buildingList);
//buildingRepository.UpdateBatch
}
Console.WriteLine("BuildingImport::Flag_{0} params:{1}", flag, Mall.Common.Plugin.JsonHelper.Serialize(buildingList));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment