static void Main(string[] args) { //string filepath = "EQ_CinemaInfo.txt"; //string json = GetFileJson(filepath); //var eQCin_Cinemas = (List<EQCin_Cinema>)JsonToObject(json, new List<EQCin_Cinema>()); //filepath = "EQCin_ForwardInfo.txt"; //json = GetFileJson(filepath); //var eQCin_ForwardInfos = (List<EQCin_ForwardInfo>)JsonToObject(json, new List<EQCin_ForwardInfo>()); // string sql1 = " select EQ_CinemaCode, EQ_CinemaName,EQ_GroupName,EQ_AreaCode,EQ_Adress from EQCin_Cinema where EQ_CinemaCode<>'' "; // string sql2 = @"select a.SystemNum,a.EQ_CinemaName,a.EQ_GroupName,a.EQ_CityCode,a.EQ_ForAddress,a.ReEQ_CinemaCode as EQ_CinemaCode // from [test].[dbo].[EQCin_ForwardInfo20190215] a inner join [test].[dbo].EQCin_ForwardInfo20190222 b on b.SystemNum=a.SystemNum where a.ReEQ_CinemaCode is not null "; string sql1 = @"SELECT [专资编码] as EQ_CinemaCode ,[影院名称] as Forward_CinemaName ,[硬盘接收地址] as Forward_Adress ,[专资编码] as EQ_CinemaCode ,[标准影院名称] as EQ_CinemaName ,[专资影院名称] as EQ_ZZCinemaName ,[平台应原地址] as EQ_Adress FROM [test].[dbo].[Sheet4$] a inner join [HyFilmCopyForZyNew].[dbo].[EQCin_Cinema] b on a.[专资编码]=b.[EQ_CinemaCode] where a.[专资编码] is not null and b.[EQ_CinemaCode] is not null and a.[专资编码] not in ('院线影管','转万达','不是奥斯卡','不是时代院线','机动硬盘') and a.[专资编码] <>'' and a.[发运方式] is null and a.[地址相似度] is null "; var dt = GetDataTableBySql(sql1); var eQCin_Cinemas = DataTableSerializer.ToList <Forward_Cinema>(dt); //dt = GetDataTableBySql(sql2); //var eQCin_ForwardInfos = DataTableSerializer.ToList<EQCin_ForwardInfo>(dt); var x = 0; Console.WriteLine(DateTime.Now.ToLongTimeString()); List <MatchResult> reslut = new List <MatchResult>(); float maxRate; float tempRate; string EQ_CinemaCode; string matchType = ""; float maxRate2; float tempRate2; float tempRate3; string EQ_CinemaCode2; string matchType2 = ""; string remark = ""; string remark2 = ""; for (var i = 0; i < eQCin_Cinemas.Count; i++) { tempRate = 0; maxRate = 0; EQ_CinemaCode = ""; tempRate2 = 0; maxRate2 = 0; EQ_CinemaCode2 = ""; remark = ""; remark2 = ""; tempRate3 = 0; //EQCin_Cinema eq = eQCin_Cinemas.Where(re => re.EQ_CinemaCode == eQCin_ForwardInfos[i].EQ_CinemaCode).FirstOrDefault(); //if (eq == null) continue; tempRate = levenshtein(eQCin_Cinemas[i].EQ_Adress, eQCin_Cinemas[i].Forward_Adress); tempRate2 = levenshtein(eQCin_Cinemas[i].EQ_CinemaName, eQCin_Cinemas[i].Forward_CinemaName); if (eQCin_Cinemas[i].EQ_ZZCinemaName != null) { tempRate3 = levenshtein(eQCin_Cinemas[i].EQ_ZZCinemaName, eQCin_Cinemas[i].Forward_CinemaName); } InsertCinameMatchInfoBySql("update [test].[dbo].[Sheet4$] set [标准影院名称相似度]=" + tempRate2 + ",[专资影院名称相似度]=" + tempRate3 + ",[地址相似度]=" + tempRate + " where [专资编码]='" + eQCin_Cinemas[i].EQ_CinemaCode + "' and [发运方式] is null"); //reslut.Add(option); } Console.WriteLine(DateTime.Now.ToLongTimeString()); Console.WriteLine(x); Console.ReadLine(); }
static void Main0(string[] args) { //string filepath = "EQ_CinemaInfo.txt"; //string json = GetFileJson(filepath); //var eQCin_Cinemas = (List<EQCin_Cinema>)JsonToObject(json, new List<EQCin_Cinema>()); //filepath = "EQCin_ForwardInfo.txt"; //json = GetFileJson(filepath); //var eQCin_ForwardInfos = (List<EQCin_ForwardInfo>)JsonToObject(json, new List<EQCin_ForwardInfo>()); string sql1 = "select * from v_EQCin_CinemaFilter where EQ_CinemaCode<>''"; string sql2 = "select * from v_EQCin_ForwardInfoFilter "; var dt = Program.GetDataTableBySql(sql1); var eQCin_Cinemas = DataTableSerializer.ToList <EQCin_Cinema>(dt); dt = Program.GetDataTableBySql(sql2); var eQCin_ForwardInfos = DataTableSerializer.ToList <EQCin_ForwardInfo>(dt); var x = 0; Console.WriteLine(DateTime.Now.ToLongTimeString()); List <MatchResult> reslut = new List <MatchResult>(); float maxRate; float tempRate; string EQ_CinemaCode; string matchType = ""; float maxRate2; float tempRate2; string EQ_CinemaCode2; string matchType2 = ""; string remark = ""; string remark2 = ""; for (var i = 0; i < eQCin_ForwardInfos.Count; i++) { tempRate = 0; maxRate = 0; EQ_CinemaCode = ""; tempRate2 = 0; maxRate2 = 0; EQ_CinemaCode2 = ""; remark = ""; remark2 = ""; var cinemaEnity = eQCin_Cinemas.Where(re => re.EQ_CinemaCode == eQCin_ForwardInfos[i].EQ_CinemaCode).FirstOrDefault(); if (cinemaEnity != null) { tempRate = Program.levenshtein(cinemaEnity.EQ_Adress, eQCin_ForwardInfos[i].EQ_ForAddress); tempRate2 = Program.levenshtein(cinemaEnity.EQ_CinemaName, eQCin_ForwardInfos[i].EQ_CinemaName); maxRate = tempRate; EQ_CinemaCode = eQCin_ForwardInfos[i].EQ_CinemaCode; matchType = "EQ_Adress"; remark = (tempRate2 * 100).ToString(); //sysnum = eQCin_ForwardInfos[j].SystemNum; maxRate2 = tempRate2; EQ_CinemaCode2 = eQCin_ForwardInfos[i].EQ_CinemaCode; matchType2 = "EQ_CinemaName"; remark2 = (tempRate * 100).ToString(); //sysnum = eQCin_ForwardInfos[j].SystemNum; Program.InsertCinameMatchInfoBySql("insert into [CinameMatchInfoSync3] values(" + eQCin_ForwardInfos[i].SystemNum + ",'" + EQ_CinemaCode + "','" + cinemaEnity.EQ_CinemaName + "','" + cinemaEnity.EQ_Adress + "','',1," + eQCin_Cinemas.Where(re => re.EQ_CinemaCode == eQCin_ForwardInfos[i].EQ_CinemaCode).Count() + ",'EQ_Adress','" + maxRate + "','EQ_CinemaName','" + maxRate2 + "')"); //Console.WriteLine(eQCin_Cinemas[i].EQ_CinemaCode + " : " + sysnum + " ,相似度最高" + maxRate); //Console.WriteLine(eQCin_Cinemas[i].EQ_CinemaCode + " : " + sysnum + " ,相似度最高" + maxRate); } else { EQ_CinemaCode = eQCin_ForwardInfos[i].EQ_CinemaCode; Program.InsertCinameMatchInfoBySql("insert into CinameMatchInfoSync3 values(" + eQCin_ForwardInfos[i].SystemNum + ",'" + EQ_CinemaCode + "','','','未找到相应专资编码',4,0,null,null,null,null)"); } //reslut.Add(option); } Console.WriteLine(DateTime.Now.ToLongTimeString()); Console.WriteLine(x); Console.ReadLine(); }