From b32f934398ee9f957a583e5ff6c35e6fb465823e Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-1VKMM8S>
Date: 星期一, 15 三月 2021 20:44:42 +0800
Subject: [PATCH] 1.删除3月15号数据报表。

---
 P066.Data/Form1.cs | 1127 ++++++++++++++++++++++------------------------------------
 1 files changed, 435 insertions(+), 692 deletions(-)

diff --git a/P066.Data/Form1.cs b/P066.Data/Form1.cs
index d531351..df02e6e 100644
--- a/P066.Data/Form1.cs
+++ b/P066.Data/Form1.cs
@@ -8,6 +8,8 @@
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.IO;
+using Bro.Common;
+using Bro.Common.Util;
 
 namespace P066.Data
 {
@@ -15,10 +17,16 @@
     {
         DirectoryInfo directoryInfo1;
         DirectoryInfo directoryInfo2;
+        private P066RunParam runparam = new P066RunParam();
 
+        
         public Form1()
         {
             InitializeComponent();
+            //ConfigHelper.Save(@"D:\P066-Data\P066XML\1.xml", runparam);
+            runparam = ConfigHelper.Load<P066RunParam>(@"D:\P066-Data\P066XML\Jin_Mid.xml");
+            
+
         }
 
         private void btnLoadData1_Click(object sender, EventArgs e)
@@ -46,12 +54,33 @@
             var listSum = new List<ResultData>();
             var JudgeListSum = new List<ResultData>();
             string filename = "";
+            string filenameDir = "";
             int WhiteI = 0;
             int WhiteningI = 0;
+            int ChuNum = 0;
+            int FuNum = 0;
+            int GuaNum = 0;
+            #region//鑾峰彇鏃堕棿鎴冲苟鎺掑簭
+            var allLines1 = File.ReadAllLines(fileinfos1[0].FullName, Encoding.Default);
+            List<ResultData> dataList1 = new List<ResultData>();
+            if (allLines1.Length > 1)
+            {
+                dataList1 = GetData(allLines1);
+            }
+            var dataGroup111 = dataList1.GroupBy(a => a.TimeTip);
+            var dataListSum22 = new List<string>();
+            foreach (var item in dataGroup111)
+            {
+                dataListSum22.Add(item.Key);
+            }
+            dataListSum22 = dataListSum22.Distinct().ToList();
+            dataListSum22.Sort();
+            #endregion
+           
             for (int i = 0; i < fileinfos1.Length; i++)
             {
-                var list = CompareFile(fileinfos1[i], fileinfos2[i]);
-                var judgeList = JudgeCompareFile(fileinfos1[i], fileinfos2[i]);
+                var list = CompareFile(fileinfos1[i], fileinfos2[i],dataListSum22);
+                var judgeList = JudgeCompareFile(fileinfos1[i], fileinfos2[i],dataListSum22);
 
                 if (fileinfos1[i].Name.Contains("鐧界偣"))
                 {
@@ -71,305 +100,66 @@
 
                 }
 
-                var group = judgeList.GroupBy(a => a.TimeTip);
-   
-                foreach (var item in group)
-                {
-                    //璁$畻闀滃ご1缂洪櫡浣嶇疆鍙婅搴�
-                    var listLensnumber1 = judgeList.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 1);
-                    for (int k = 0; k < listLensnumber1.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber1[k].X, listLensnumber1[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber1[k].angle = lenAngle;
-
-                        var distance = GetDistance(1050, 1050, listLensnumber1[k].X, listLensnumber1[k].Y);
-
-                        if (distance <= 539.87)
-                        {
-                            listLensnumber1[k].location = "闀滃ご";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else if (539.87 < distance && distance <= 777.11)
-                        {
-                            listLensnumber1[k].location = "鏂滈潰";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else if (777.11 < distance && distance <= 919.88)
-                        {
-                            listLensnumber1[k].location = "骞抽潰";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber1[k].location = "鍖哄煙澶�";
-                            listLensnumber1[k].R = distance;
-                        }
-
-                    }
-                    //璁$畻闀滃ご2浣嶇疆鍙婅搴�
-                    var listLensnumber2 = judgeList.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 2);
-                    for (int k = 0; k < listLensnumber2.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber2[k].X, listLensnumber2[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber2[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber2[k].X, listLensnumber2[k].Y);
-                        if (distance <= 400)
-                        {
-                            listLensnumber2[k].location = "闀滃ご";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else if (400 < distance && distance <= 772.18)
-                        {
-                            listLensnumber2[k].location = "鏂滈潰";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else if (772.18 < distance && distance <= 873.38)
-                        {
-                            listLensnumber2[k].location = "骞抽潰";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber2[k].location = "鍖哄煙澶�";
-                            listLensnumber2[k].R = distance;
-                        }
-                    }
-                    //璁$畻闀滃ご3浣嶇疆鍙婅搴�
-                    var listLensnumber3 = judgeList.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 3);
-                    for (int k = 0; k < listLensnumber3.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber3[k].X, listLensnumber3[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber3[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber3[k].X, listLensnumber3[k].Y);
-                        if (distance <= 105.63)
-                        {
-                            listLensnumber3[k].location = "闀滃ご";
-                            listLensnumber3[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber3[k].location = "鏂滈潰";
-                            listLensnumber3[k].R = distance;
-                        }
-                    }
-                    //璁$畻闀滃ご4浣嶇疆鍙婅搴�
-                    var listLensnumber4 = judgeList.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 4);
-                    for (int k = 0; k < listLensnumber4.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber4[k].X, listLensnumber4[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber4[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber4[k].X, listLensnumber4[k].Y);
-                        if (distance <= 339.88)
-                        {
-                            listLensnumber4[k].location = "闀滃ご";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else if (339.88 < distance && distance <= 547.02)
-                        {
-                            listLensnumber4[k].location = "鏂滈潰";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else if (547.02 < distance && distance <= 614.73)
-                        {
-                            listLensnumber4[k].location = "骞抽潰";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber4[k].location = "鍖哄煙澶�";
-                            listLensnumber4[k].R = distance;
-                        }
-                    }
-
-                }
-
-
-
-                #region//缁欓暅澶村尯鍒嗕綅缃強瑙掑害
-                var group11 = list.GroupBy(a => a.TimeTip);
                 string currPath = "";
-                foreach (var item in group11)
-                {
-                    //璁$畻闀滃ご1缂洪櫡浣嶇疆鍙婅搴�
-                    var listLensnumber1 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 1);
-                    for (int k = 0; k < listLensnumber1.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber1[k].X, listLensnumber1[k].Y);
-                        if (lenAngle<0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber1[k].angle = lenAngle;
-
-                        var distance = GetDistance(1050, 1050, listLensnumber1[k].X, listLensnumber1[k].Y);
-
-                        if (distance <= 539.87)
-                        {
-                            listLensnumber1[k].location = "闀滃ご";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else if (539.87 < distance && distance <= 777.11)
-                        {
-                            listLensnumber1[k].location = "鏂滈潰";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else if (777.11 < distance && distance <= 919.88)
-                        {
-                            listLensnumber1[k].location = "骞抽潰";
-                            listLensnumber1[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber1[k].location = "鍖哄煙澶�";
-                            listLensnumber1[k].R = distance;
-                        }
-
-                    }
-                    //璁$畻闀滃ご2浣嶇疆鍙婅搴�
-                    var listLensnumber2 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 2);
-                    for (int k = 0; k < listLensnumber2.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber2[k].X, listLensnumber2[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber2[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber2[k].X, listLensnumber2[k].Y);
-                        if (distance <= 400)
-                        {
-                            listLensnumber2[k].location = "闀滃ご";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else if (400 < distance && distance <= 772.18)
-                        {
-                            listLensnumber2[k].location = "鏂滈潰";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else if (772.18 < distance && distance <= 873.38)
-                        {
-                            listLensnumber2[k].location = "骞抽潰";
-                            listLensnumber2[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber2[k].location = "鍖哄煙澶�";
-                            listLensnumber2[k].R = distance;
-                        }
-                    }
-                    //璁$畻闀滃ご3浣嶇疆鍙婅搴�
-                    var listLensnumber3 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 3);
-                    for (int k = 0; k < listLensnumber3.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber3[k].X, listLensnumber3[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber3[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber3[k].X, listLensnumber3[k].Y);
-                        if (distance <= 105.63)
-                        {
-                            listLensnumber3[k].location = "闀滃ご";
-                            listLensnumber3[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber3[k].location = "鏂滈潰";
-                            listLensnumber3[k].R = distance;
-                        }
-                    }
-                    //璁$畻闀滃ご4浣嶇疆鍙婅搴�
-                    var listLensnumber4 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 4);
-                    for (int k = 0; k < listLensnumber4.Count; k++)
-                    {
-                        var lenAngle = GetAngle(listLensnumber4[k].X, listLensnumber4[k].Y);
-                        if (lenAngle < 0)
-                        {
-                            lenAngle = 360 + lenAngle;
-                        }
-                        listLensnumber4[k].angle = lenAngle;
-                        var distance = GetDistance(1050, 1050, listLensnumber4[k].X, listLensnumber4[k].Y);
-                        if (distance <= 339.88)
-                        {
-                            listLensnumber4[k].location = "闀滃ご";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else if (339.88 < distance && distance <= 547.02)
-                        {
-                            listLensnumber4[k].location = "鏂滈潰";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else if (547.02 < distance && distance <= 614.73)
-                        {
-                            listLensnumber4[k].location = "骞抽潰";
-                            listLensnumber4[k].R = distance;
-                        }
-                        else
-                        {
-                            listLensnumber4[k].location = "鍖哄煙澶�";
-                            listLensnumber4[k].R = distance;
-                        }
-                    }
-
-                }
-                #endregion
                 #region//鍒ゆ柇鏄垵妫�鏂囦欢澶硅繕鏄妫�鏂囦欢澶�
-                if (fileinfos1[i].Name.Contains("鍒濇"))
+                if (fileinfos1[i].Name.Contains("鍒濇涓"))
                 {
-                    filename = "鍒濇";
+                    ChuNum++;
+                    filenameDir = "鍒濇涓鐧界偣";
+                    filename = "鍒濇涓鐧界偣" + ChuNum;
+                    judgeList = GetMidLocation(judgeList);
+                    //缁欓暅澶村尯鍒嗕綅缃強瑙掑害
+                    list = GetMidLocation(list);
                 }
-                if (fileinfos1[i].Name.Contains("澶嶆"))
+               else if (fileinfos1[i].Name.Contains("澶嶆涓")&& fileinfos1[i].Name.Contains("鐧界偣"))
                 {
-                    filename = "澶嶆";
+                    FuNum=FuNum+1;
+                    filenameDir = "澶嶆涓鐧界偣";
+                    filename = "澶嶆涓鐧界偣" + FuNum;
+                    judgeList = GetMidLocation(judgeList);
+                    //缁欓暅澶村尯鍒嗕綅缃強瑙掑害
+                    list = GetMidLocation(list);
                 }
-                if (fileinfos1[i].Name.Contains("鍒櫧"))
+                else if ( fileinfos1[i].Name.Contains("澶嶆涓") &&fileinfos1[i].Name.Contains("鍒櫧"))
+                    {
+                        GuaNum=GuaNum+1;
+                        filenameDir = "澶嶆涓鍒櫧";
+                        filename = "澶嶆涓鍒櫧" + GuaNum;
+                    judgeList = GetBkLocation(judgeList);
+                    //缁欓暅澶村尯鍒嗕綅缃強瑙掑害
+                    list = GetBkLocation(list);
+                }
+               else if (fileinfos1[i].Name.Contains("鍒濇鑳屾澘"))
                 {
-                    filename = "鍒櫧";
+                    ChuNum++;
+                    filenameDir = "鍒濇鑳屾澘鐧界偣";
+                    filename = "鍒濇鑳屾澘鐧界偣" + ChuNum;
+                    judgeList = GetBkLocation(judgeList);
+                    //缁欓暅澶村尯鍒嗕綅缃強瑙掑害
+                    list = GetBkLocation(list);
                 }
+                else if (fileinfos1[i].Name.Contains("澶嶆鑳屾澘") && fileinfos1[i].Name.Contains("鐧界偣"))
+                {
+                    FuNum = FuNum + 1;
+                    filenameDir = "澶嶆鑳屾澘鐧界偣";
+                    filename = "澶嶆鑳屾澘鐧界偣" + FuNum;
+                    judgeList = GetBkLocation(judgeList);
+                    //缁欓暅澶村尯鍒嗕綅缃強瑙掑害
+                    list = GetBkLocation(list);
+                }
+
                 currPath = directoryInfo1.Parent.Parent.FullName;
-                string subPath = currPath + "/" + filename + "鍚堝苟鍚�" + "/";
+                string subPath = currPath + "/" + filenameDir + "鍚堝苟鍚�" + "/";
                 if (false==Directory.Exists(subPath))
                 {
                     Directory.CreateDirectory(subPath);
                 }
 
                 #endregion  
-                #region//娴嬭瘯杈撳嚭璁惧鍒ゆ柇缁撴灉
 
-                //var title12 = $"鏃堕棿鎴�,璁惧鍒ゆ柇缁撴灉";
-                //var file12 = $"{directoryInfo1.Parent.FullName}\\{filename + (i + 111)}.csv";
-                //File.AppendAllText(file12, title12, Encoding.UTF8);
-                //File.AppendAllText(file12, "\r\n");
 
-                //foreach (var item in JudgeListSum)
-                //{
-          
-                //    var conrent12 = $"{item.TimeTip},{item.JudgmentResult}";
-                //    File.AppendAllText(file12, conrent12, Encoding.UTF8);
-                //    File.AppendAllText(file12, "\r\n");
-                //}
-
-                #endregion  
-
-                var title1 = $"鏃堕棿鎴�,鏂囦欢鍚�,鍒ゆ柇,鍙兘鎬�,涓嶇‘瀹氭��,楂�,瀹�,X,Y,鏈�澶у昂瀵�,浣嶇疆,R,瑙掑害,缂洪櫡绫诲瀷";
-                var file1 = $"{subPath}\\{filename + (i+1)}.csv";
+                var title1 = $"鏃堕棿鎴�,鏂囦欢鍚�,鍒ゆ柇,鍙兘鎬�,涓嶇‘瀹氭��,楂�,瀹�,X,Y,鏈�澶у昂瀵�,浣嶇疆,R,瑙掑害";
+                var file1 = $"{subPath}\\{filename}.csv";
                 File.AppendAllText(file1, title1, Encoding.UTF8);
                 File.AppendAllText(file1, "\r\n");
 
@@ -389,255 +179,64 @@
                 //    File.AppendAllText(file2, "\r\n");
                 //}
                 #endregion
-                foreach (var item in list)
+                  
+                foreach (var item in dataListSum22)
                 {
-                    string result = item.Result ? "OK" : "NG";
+                    var list11 = list.FindAll(a =>a.TimeTip==item&&!a.Result);
+                    for (int q = 0; q < list11.Count; q++)
+                    {
+                        string result = list11[q].Result ? "OK" : "NG";
 
-                    var content = $"{item.TimeTip},{item.ImageFileName},{result},{item.Probability},{item.Uncertainty},{item.Height},{item.Width},{item.X},{item.Y},{item.ex},{item.location},{ Convert.ToInt32(item.R)},{ Convert.ToInt32(item.angle)},{item.DefectType}";
+                        var content = $"{list11[q].TimeTip},{list11[q].ImageFileName},{result},{list11[q].Probability},{list11[q].Uncertainty},{list11[q].Height},{list11[q].Width},{list11[q].X},{list11[q].Y},{list11[q].ex},{list11[q].location},{ Convert.ToInt32(list11[q].R)},{ Convert.ToInt32(list11[q].angle)}";
 
-                    File.AppendAllText(file1, content, Encoding.UTF8);
-                    File.AppendAllText(file1, "\r\n");
+                        File.AppendAllText(file1, content, Encoding.UTF8);
+                        File.AppendAllText(file1, "\r\n");
+                    }
+
+
                 }
             }
 
 
-            var dataGroup1 = listSum.GroupBy(a => a.TimeTip);
-            var dataListSum = new List<string>();
-
-            foreach (var item in dataGroup1)
-            {
-                dataListSum.Add(item.Key);
-            }
-            dataListSum = dataListSum.Distinct().ToList();
-            dataListSum.Sort();
-            var dataList = new List<ResultData>();
-
-            var title12 = $"鏃堕棿鎴�,鐩告満搴忓彿,璁惧鍒ゆ柇缁撴灉,缂洪櫡绫诲瀷,X,Y,鏈�澶у昂瀵�,R,浣嶇疆,瑙掑害";
-            var file12 = $"{directoryInfo1.Parent.FullName}\\{filename+"璁惧鍒ゆ柇缁撴灉"}.csv";
-
+            #region//灏嗚澶囧垽鏂粨鏋滆緭鍑哄埌CSV鎶ヨ〃涓�
+            var title12 = $"鏃堕棿鎴�,鐩告満搴忓彿,璁惧鍒ゆ柇缁撴灉,缂洪櫡绫诲瀷,璁惧鍚庡鐞嗙粨鏋�,鏈�澶у昂瀵�,浣嶇疆,X,Y,R,瑙掑害";
+            var file12 = $"{directoryInfo1.Parent.FullName}\\{filenameDir + "璁惧鍒ゆ柇缁撴灉"}.csv";
             File.AppendAllText(file12, title12, Encoding.UTF8);
             File.AppendAllText(file12, "\r\n");
- 
-            foreach (var item in dataListSum)
+            foreach (var item in dataListSum22)
             {
-                var test11 = JudgeListSum.FindAll(a => a.TimeTip == item&&a.Lensnumber==1);
-                if (test11.Count==0)
-                {
+                var Lens1 = JudgeListSum.FindAll(a => a.TimeTip == item&&a.Lensnumber==1);
+                WriteJR(Lens1,item,1,file12);
+                var Lens2 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 2);
+                WriteJR(Lens2,"",2,file12);
+                var Lens3 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 3);
+                WriteJR(Lens3,"",3,file12);
+                var Lens4 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 4);
+                WriteJR(Lens4,"",4,file12);
 
-                    var content11 = $"{item},{1},{"OK"}";
-                    File.AppendAllText(file12, content11, Encoding.UTF8);
-                    File.AppendAllText(file12, "\r\n");
-                }
-                else
-                {
-                    if (test11[0].DefectType=="鍒櫧")
-                    {
-                        var content11 = $"{item},{1},{test11[0].JudgmentResult},{test11[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test11.Count; i++)
-                        {
-                            if (test11[i].DefectType=="鍒櫧")
-                            {
-                                var content111 = $"{""},{""},{""},{""},{test11[i].X},{test11[i].Y},{test11[i].ex},{(int)(test11[i].R)},{test11[i].location},{(int)(test11[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-                            else
-                            {
-                                var content111 = $"{""},{""},{""},{test11[i].DefectType},{test11[i].X},{test11[i].Y},{test11[i].ex},{(int)(test11[i].R)},{test11[i].location},{(int)(test11[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-
-                        }
-                    }
-                    else
-                    {
-                        var content11 = $"{item},{1},{test11[0].JudgmentResult},{test11[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test11.Count; i++)
-                        {
-                            var content111 = $"{""},{""},{""},{""},{test11[i].X},{test11[i].Y},{test11[i].ex},{(int)(test11[i].R)},{test11[i].location},{(int)(test11[i].angle)}";
-                            File.AppendAllText(file12, content111, Encoding.UTF8);
-                            File.AppendAllText(file12, "\r\n");
-                        }
-                    }
-
-                }
-                var test12 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 2);
-                if (test12.Count == 0)
-                {
-
-                    var content11 = $"{""},{2},{"OK"}";
-                    File.AppendAllText(file12, content11, Encoding.UTF8);
-                    File.AppendAllText(file12, "\r\n");
-                }
-                else
-                {
-                    if (test12[0].DefectType == "鍒櫧")
-                    {
-                        var content11 = $"{""},{2},{test12[0].JudgmentResult},{test12[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test12.Count; i++)
-                        {
-                            if (test12[i].DefectType == "鍒櫧")
-                            {
-                                var content111 = $"{""},{""},{""},{""},{test12[i].X},{test12[i].Y},{test12[i].ex},{(int)(test12[i].R)},{test12[i].location},{(int)(test12[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-                            else
-                            {
-                                var content111 = $"{""},{""},{""},{test12[i].DefectType},{test12[i].X},{test12[i].Y},{test12[i].ex},{(int)(test12[i].R)},{test12[i].location},{(int)(test12[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-
-                        }
-
-
-                    }
-                    else
-                    {
-                        var content11 = $"{""},{2},{test12[0].JudgmentResult},{test12[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test12.Count; i++)
-                        {
-                            var content111 = $"{""},{""},{""},{""},{test12[i].X},{test12[i].Y},{test12[i].ex},{(int)(test12[i].R)},{test12[i].location},{(int)(test12[i].angle)}";
-                            File.AppendAllText(file12, content111, Encoding.UTF8);
-                            File.AppendAllText(file12, "\r\n");
-                        }
-                    }
-                }
-                var test13 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 3);
-                if (test13.Count == 0)
-                {
-
-                    var content11 = $"{""},{3},{"OK"}";
-                    File.AppendAllText(file12, content11, Encoding.UTF8);
-                    File.AppendAllText(file12, "\r\n");
-                }
-                else
-                {
-                    if (test13[0].DefectType == "鍒櫧")
-                    {
-                        var content11 = $"{""},{3},{test13[0].JudgmentResult},{test13[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test13.Count; i++)
-                        {
-                            if (test13[i].DefectType == "鍒櫧")
-                            {
-                                var content111 = $"{""},{""},{""},{""},{test13[i].X},{test13[i].Y},{test13[i].ex},{(int)(test13[i].R)},{test13[i].location},{(int)(test13[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-                            else
-                            {
-                                var content111 = $"{""},{""},{""},{test13[i].DefectType},{test13[i].X},{test13[i].Y},{test13[i].ex},{(int)(test13[i].R)},{test13[i].location},{(int)(test13[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-
-                        }
-
-                        }
-                    else
-                    {
-                        var content11 = $"{""},{3},{test13[0].JudgmentResult},{test13[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test13.Count; i++)
-                        {
-                            var content111 = $"{""},{""},{""},{""},{test13[i].X},{test13[i].Y},{test13[i].ex},{(int)(test13[i].R)},{test13[i].location},{(int)(test13[i].angle)}";
-                            File.AppendAllText(file12, content111, Encoding.UTF8);
-                            File.AppendAllText(file12, "\r\n");
-                        }
-                    }
-                }
-                var test14 = JudgeListSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 4);
-                if (test14.Count == 0)
-                {
-
-                    var content11 = $"{""},{4},{"OK"}";
-                    File.AppendAllText(file12, content11, Encoding.UTF8);
-                    File.AppendAllText(file12, "\r\n");
-                }
-                else
-                {
-                    if (test14[0].DefectType == "鍒櫧")
-                    {
-                        var content11 = $"{""},{4},{test14[0].JudgmentResult},{test14[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test14.Count; i++)
-                        {
-                            if (test14[i].DefectType == "鍒櫧")
-                            {
-                                var content111 = $"{""},{""},{""},{""},{test14[i].X},{test14[i].Y},{test14[i].ex},{(int)(test14[i].R)},{test14[i].location},{(int)(test14[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-                            else
-                            {
-                                var content111 = $"{""},{""},{""},{test14[i].DefectType},{test14[i].X},{test14[i].Y},{test14[i].ex},{(int)(test14[i].R)},{test14[i].location},{(int)(test14[i].angle)}";
-                                File.AppendAllText(file12, content111, Encoding.UTF8);
-                                File.AppendAllText(file12, "\r\n");
-                            }
-
-                        }
-                    }
-                    else
-                    {
-                        var content11 = $"{""},{4},{test14[0].JudgmentResult},{test14[0].DefectType}";
-                        File.AppendAllText(file12, content11, Encoding.UTF8);
-                        File.AppendAllText(file12, "\r\n");
-                        for (int i = 0; i < test14.Count; i++)
-                        {
-                            var content111 = $"{""},{""},{""},{""},{test14[i].X},{test14[i].Y},{test14[i].ex},{(int)(test14[i].R)},{test14[i].location},{(int)(test14[i].angle)}";
-                            File.AppendAllText(file12, content111, Encoding.UTF8);
-                            File.AppendAllText(file12, "\r\n");
-                        }
-                    }
-                }
-                //var conrent12 = $"{item},{item}";
-                //File.AppendAllText(file12, conrent12, Encoding.UTF8);
-                //File.AppendAllText(file12, "\r\n");
             }
-
-
-
-
-
-
-
-
+            #endregion
 
 
 
 
             #region//鏍规嵁浜у搧缂栧彿杈撳嚭鎬荤己闄锋姤琛�
             var title = $"浜у搧缂栧彿,闀滃ご缂栧彿,鎬荤己闄锋暟閲�";
-            var file = $"{directoryInfo1.Parent.FullName}\\{filename+ "缂洪櫡鎬绘暟鎶ヨ〃"}.csv";
+            var file = $"{directoryInfo1.Parent.FullName}\\{filenameDir + "缂洪櫡鎬绘暟鎶ヨ〃"}.csv";
             File.AppendAllText(file, title, Encoding.UTF8);
             File.AppendAllText(file, "\r\n");
-            var listSumGroup = listSum.GroupBy(a => a.TimeTip);
-            foreach (var item in listSumGroup)
+            foreach (var item in dataListSum22)
             {
-                var listLensnumber1 = listSum.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 1);
+                var listLensnumber1 = listSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 1);
                 var listLensnumberCount1 = listLensnumber1.Count;
-                var listLensnumber2 = listSum.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 2);
+                var listLensnumber2 = listSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 2);
                 var listLensnumberCount2 = listLensnumber2.Count;
-                var listLensnumber3 = listSum.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 3);
+                var listLensnumber3 = listSum.FindAll(a => a.TimeTip == item && a.Lensnumber == 3);
                 var listLensnumberCount3 = listLensnumber3.Count;
-                var listLensnumber4 = listSum.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 4);
+                var listLensnumber4 = listSum.FindAll(a => a.TimeTip == item&& a.Lensnumber == 4);
                 var listLensnumberCount4 = listLensnumber4.Count;
                 //绗竴琛�
-                var content1 = $"{item.Key},{1},{listLensnumberCount1}";
+                var content1 = $"{item},{1},{listLensnumberCount1}";
                 File.AppendAllText(file, content1, Encoding.UTF8);
                 File.AppendAllText(file, "\r\n");
                 //绗簩琛�
@@ -660,7 +259,7 @@
         }
 
 
-        private List<ResultData> CompareFile(FileInfo fileInfo1, FileInfo fileInfo2)
+        private List<ResultData> CompareFile(FileInfo fileInfo1, FileInfo fileInfo2,List<string> DataTipsor)
         {
             var allLines1 = File.ReadAllLines(fileInfo1.FullName, Encoding.Default);
             var allLines2 = File.ReadAllLines(fileInfo2.FullName, Encoding.Default);
@@ -677,28 +276,10 @@
 
 
 
-            #region //灏嗘椂闂存埑鐩稿悓鐨勫垎涓轰竴缁勫苟鎺掑簭
-
-            var dataGroup1 = dataList1.GroupBy(a => a.TimeTip);
-            var dataGroup2 = dataList2.GroupBy(a => a.TimeTip);
-            var dataListSum = new List<string>();
-
-            foreach (var item in dataGroup1)
-            {
-                dataListSum.Add(item.Key);
-            }
-            foreach (var item in dataGroup2)
-            {
-                dataListSum.Add(item.Key);
-            }
-            dataListSum = dataListSum.Distinct().ToList();
-            dataListSum.Sort();
-            #endregion
-
             var dataList = new List<ResultData>();
             var dataList11 = new List<ResultData>();
             var dataList22 = new List<ResultData>();
-            foreach (var item in dataListSum)
+            foreach (var item in DataTipsor)
             {
                 var list1 = dataList1.FindAll(a => a.TimeTip == item && !a.Result);
                 var list2 = dataList2.FindAll(a => a.TimeTip == item && !a.Result);
@@ -740,6 +321,14 @@
                         if (distance < 20)
                         {
                             itemToRemove.Add(list2[j]);
+                            //if (list1[i].PostTreatmentResults=="")
+                            //{
+                            //    list1[i].PostTreatmentResults = list2[j].PostTreatmentResults;
+                            //}
+                            //else
+                            //{
+                            //    list2[j].PostTreatmentResults = list1[i].PostTreatmentResults;
+                            //}
                         }
                     }
                 }
@@ -749,90 +338,19 @@
                     list2.Remove(itemToRemove[i]);
                 }
 
-                dataList11.AddRange(list1);
-                dataList22.AddRange(list2);
+                dataList.AddRange(list1);
+                dataList.AddRange(list2);
             }
 
 
-            dataList.AddRange(dataList1);
-            dataList.AddRange(dataList2);
+            //dataList.AddRange(dataList1);
+            //dataList.AddRange(dataList2);
             return dataList;
         }
         //缁熻璁惧鍒ゆ柇缁撴灉
-        private List<ResultData> JudgeCompareFile(FileInfo fileInfo1, FileInfo fileInfo2)
+        private List<ResultData> JudgeCompareFile(FileInfo fileInfo1, FileInfo fileInfo2,List<string> DataTipsor)
         {
 
-            #region  //灞忚斀
-            //var allLines1 = File.ReadAllLines(fileInfo1.FullName,Encoding.Default);
-            //var allLines2 = File.ReadAllLines(fileInfo2.FullName, Encoding.Default);
-            ////var dataJudgeList1 = GetJudgeData(allLines1);
-            ////var dataJudgeList2 = GetJudgeData(allLines2);
-            //List<ResultData> dataJudgeList1 = new List<ResultData>();
-            //List<ResultData> dataJudgeList2 = new List<ResultData>();
-            //if (allLines1.Length > 1)
-            //{
-            //    dataJudgeList1 = GetData(allLines1);
-            //}
-            //if (allLines2.Length > 1)
-            //{
-
-            //     dataJudgeList2 = GetData(allLines2);
-            //}
-
-            //var dataGroup1 = dataJudgeList1.GroupBy(a => a.TimeTip);
-            //var dataGroup2 = dataJudgeList2.GroupBy(a => a.TimeTip);
-            //var dataListSum = new List<string>();
-
-            //foreach (var item in dataGroup1)
-            //{
-            //    dataListSum.Add(item.Key);
-            //}
-            //foreach (var item in dataGroup2)
-            //{
-            //    dataListSum.Add(item.Key);
-            //}
-            //dataListSum = dataListSum.Distinct().ToList();
-            //dataListSum.Sort();
-            //var dataList = new List<ResultData>();
-            //var itemToRemove = new List<ResultData>();
-            //foreach (var item in dataListSum)
-            //{
-
-            //        var list1 = dataJudgeList1.FindAll(a => a.TimeTip == item && a.JudgmentResult=="NG"&&!a.Result);
-            //        var list2 = dataJudgeList2.FindAll(a => a.TimeTip == item && a.JudgmentResult == "NG"&&!a.Result);
-            //    for (int i = 0; i < list1.Count; i++)
-            //    {
-            //        for (int j = 0; j < list2.Count; j++)
-            //        {
-            //            if (list1[i].JudgmentResult != list2[j].JudgmentResult)
-            //            {
-            //                list1[i].JudgmentResult = "NG";
-            //                list2[j].JudgmentResult = "NG";
-            //                itemToRemove.Add(list2[j]);
-            //            }
-            //            if (list1[i].JudgmentResult == list2[j].JudgmentResult)
-            //            {
-            //                itemToRemove.Add(list2[j]);
-            //            }
-            //        }
-            //    } 
-            //    //if (list1.Count ==0&&list2.Count==0)
-            //    //{
-            //    //    dataList.Add(new ResultData()
-            //    //    {
-            //    //        TimeTip = item,
-            //    //        JudgmentResult = "OK",
-
-            //    //         }); ; ;
-            //    //}
-            //    dataList.AddRange(list1);
-            //    dataList.AddRange(list2);
-            //}
-            //for (int i = 0; i < itemToRemove.Count; i++)
-            //{
-            //    dataList.Remove(itemToRemove[i]);
-            //}
-            #endregion  
 
             var allLines1 = File.ReadAllLines(fileInfo1.FullName, Encoding.Default);
             var allLines2 = File.ReadAllLines(fileInfo2.FullName, Encoding.Default);
@@ -849,28 +367,10 @@
 
 
 
-            #region //灏嗘椂闂存埑鐩稿悓鐨勫垎涓轰竴缁勫苟鎺掑簭
-
-            var dataGroup1 = dataList1.GroupBy(a => a.TimeTip);
-            var dataGroup2 = dataList2.GroupBy(a => a.TimeTip);
-            var dataListSum = new List<string>();
-
-            foreach (var item in dataGroup1)
-            {
-                dataListSum.Add(item.Key);
-            }
-            foreach (var item in dataGroup2)
-            {
-                dataListSum.Add(item.Key);
-            }
-            dataListSum = dataListSum.Distinct().ToList();
-            dataListSum.Sort();
-            #endregion
-
             var dataList = new List<ResultData>();
             var dataList11 = new List<ResultData>();
             var dataList22 = new List<ResultData>();
-            foreach (var item in dataListSum)
+            foreach (var item in DataTipsor)
             {
                 var list1 = dataList1.FindAll(a => a.TimeTip == item && !a.Result);
                 var list2 = dataList2.FindAll(a => a.TimeTip == item && !a.Result);
@@ -917,6 +417,14 @@
                                 list1[i].JudgmentResult = "NG";
                                 list2[j].JudgmentResult = "NG";
                             }
+                            //if (list1[i].PostTreatmentResults == "")
+                            //{
+                            //    list1[i].PostTreatmentResults = list2[j].PostTreatmentResults;
+                            //}
+                            //else
+                            //{
+                            //    list2[j].PostTreatmentResults = list1[i].PostTreatmentResults;
+                            //}
 
                         }
                     }
@@ -932,35 +440,15 @@
             }
 
             //var itemToRemove = new List<ResultData>();
-            foreach (var item in dataListSum)
+            foreach (var item in DataTipsor)
             {
 
                 var list1 = dataList11.FindAll(a => a.TimeTip == item/* && a.JudgmentResult == "NG"*/ );        //涓嶇OK銆丯G閮借杈撳嚭
                 var list2 = dataList22.FindAll(a => a.TimeTip == item /*&& a.JudgmentResult == "NG"*/);         //涓嶇OK銆丯G閮借杈撳嚭
-                //for (int i = 0; i < list1.Count; i++)
-                //{
-                //    for (int j = 0; j < list2.Count; j++)
-                //    {
-                //        if (list1[i].JudgmentResult != list2[j].JudgmentResult)
-                //        {
-                //            list1[i].JudgmentResult = "NG";
-                //            list2[j].JudgmentResult = "NG";
-                //            itemToRemove.Add(list2[j]);
-                //        }
-                //        if (list1[i].JudgmentResult == list2[j].JudgmentResult)
-                //        {
-                //            itemToRemove.Add(list2[j]);
-                //        }
-                //    }
-                //}
 
                 dataList.AddRange(list1);
                 dataList.AddRange(list2);
             }
-            //for (int i = 0; i < itemToRemove.Count; i++)
-            //{
-            //    dataList.Remove(itemToRemove[i]);
-            //}
 
             return dataList;
 
@@ -971,43 +459,66 @@
             var dataList = new List<ResultData>();
             var nametemp = allLines[1].Split(',')[0];
             var resulttemp = allLines[1].Split(',')[1];
-            //var Ptr = allLines[1].Split(',')[10];
+            string Ptr = "";
+            //if (allLines[1].Split(',')[10].Length>3)
+            //{
+            //     Ptr = allLines[1].Split(',')[10];
+            //}
+
+            string defectType = "";
+            string judgmentresult = "";
             for (int i = 1; i < allLines.Length; i++)
             {
 
-
                 var data = allLines[i].Split(',');
 
-                if (data[6]=="-")
-                {
-                    continue;
-                }
+                //if (data.Length>10)
+                //{
+                //    Ptr = data[10];
+                //}
 
-                string defectType = "";
-                string bbb = "";
-                string Ptr = "";
+
+
+                //string Ptr = "";
                 if (data[0] == "")
                 {
                     data[0] = nametemp;
                     data[1] = resulttemp;
-                    //data[10] = Ptr;
+                    if (data[3] != "鍒櫧")
+                    {
+                        data[10] = Ptr;
+                    }
 
                 }
-                if (data[1]== "鍒櫧")
+                if (data[3]== "鍒櫧")
                 {
                     defectType = "鍒櫧";
-                    bbb = "NG";
-                    Ptr = "";
+                    judgmentresult = "NG";
+                    Ptr = "鍒櫧";
                 }
                 else
                 {
                     defectType = "鐧界偣";
-                    bbb = data[1];
+                    judgmentresult = data[1];
                     
-                    if (data.Length>10)
+
+                }
+
+                if (data[6] == "-")
+                {
+                   
+                    dataList.Add(new ResultData()
                     {
-                        Ptr = data[10];
-                    }
+                        TimeTip = data[0].Split('-')[0],
+                        ImageFileName = data[0],
+                        JudgmentResult = data[1],
+                        Result = data[3] == "OK",
+                        DefectType = defectType,
+
+                    }); ; ;
+
+                    continue;
+
                 }
                 var data6 = data[6].Split('#').ToList();
                 data6.Remove("");
@@ -1032,12 +543,20 @@
                     }
                 }
                 data[7] = Convert.ToString(temp7);
+                if (data[3]=="NG")
+                {
+                    Ptr = data[10];
+                }
+                else
+                {
+                    Ptr = "";
+                }
 
                 dataList.Add(new ResultData()
                 {
                     TimeTip = data[0].Split('-')[0],
                     ImageFileName = data[0],
-                    JudgmentResult = bbb,
+                    JudgmentResult = judgmentresult,
                     Result = data[3] == "OK",
                     Probability = Convert.ToDouble(data[4]),
                     Uncertainty = Convert.ToDouble(data[5]),
@@ -1054,44 +573,268 @@
 
                 nametemp = data[0];
                 resulttemp= data[1];
+                //Ptr = data[10];
              
             }
 
             return dataList;
         }
-        //private List<ResultData> GetJudgeData(string[] allLines)
-        //{
-        //    var dataList = new List<ResultData>();
-        //    for (int i = 1; i < allLines.Length; i++)
-        //    {
-        //        var data = allLines[i].Split(',');
-        //        string defectType = "";
-        //        string aaa = "";
-        //        if (data[0] != "")
-        //        {
-        //            try
-        //            {
-        //                defectType = data[10];
-        //            }
-        //            catch (Exception)
-        //            {
+      
+        //鑾峰彇涓瑙掑害鍜屼綅缃�
+        private List<ResultData> GetMidLocation(List<ResultData> list)
+        {
+            var group = list.GroupBy(a => a.TimeTip);
+            foreach (var item in group)
+            {
+                //璁$畻闀滃ご1缂洪櫡浣嶇疆鍙婅搴�
+                var listLensnumber1 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 1);
+                for (int k = 0; k < listLensnumber1.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber1[k].X, listLensnumber1[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber1[k].angle = lenAngle;
 
-        //                defectType = "鍒櫧";
-        //                aaa = "NG";
-        //            }
-                    
-        //            dataList.Add(new ResultData()
-        //            {
-        //                TimeTip = data[0].Split('-')[0],
-        //                JudgmentResult = aaa,
-        //                DefectType= defectType,
-                      
-        //            }); ; ;
-        //        }
+                    var distance = GetDistance(1050, 1050, listLensnumber1[k].X, listLensnumber1[k].Y);
+                    if (distance <= runparam.MidLens1R1)
+                    {
+                        listLensnumber1[k].location = "闀滃ご";
+                    }
+                    else if (runparam.MidLens1R1 < distance && distance <= runparam.MidLens1R2)
+                    {
+                        listLensnumber1[k].location = "鏂滈潰";
+                    }
+                    else
+                    {
+                        listLensnumber1[k].location = "骞抽潰";
+                    }
 
-        //    }
-        //    return dataList;
-        //}
+                }
+                //璁$畻闀滃ご2浣嶇疆鍙婅搴�
+                var listLensnumber2 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 2);
+                for (int k = 0; k < listLensnumber2.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber2[k].X, listLensnumber2[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber2[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber2[k].X, listLensnumber2[k].Y);
+                    if (distance <= runparam.MidLens2R1)
+                    {
+                        listLensnumber2[k].location = "闀滃ご";
+                    }
+                    else if (runparam.MidLens2R1 < distance && distance <= runparam.MidLens2R2)
+                    {
+                        listLensnumber2[k].location = "鏂滈潰";
+                    }
+                    else
+                    {
+                        listLensnumber2[k].location = "骞抽潰";
+                    }
+                }
+                //璁$畻闀滃ご3浣嶇疆鍙婅搴�
+                var listLensnumber3 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 3);
+                for (int k = 0; k < listLensnumber3.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber3[k].X, listLensnumber3[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber3[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber3[k].X, listLensnumber3[k].Y);
+                    if (distance <= runparam.MidLens3R1)
+                    {
+                        listLensnumber3[k].location = "闀滃ご";
+                    }
+                    else if ( runparam.MidLens3R1< distance && distance <= runparam.MidLens3R2)
+                    {
+                        listLensnumber3[k].location = "鏂滈潰";
+                    }
+                    else
+                    {
+                        listLensnumber3[k].location = "骞抽潰";
+                    }
+                }
+                //璁$畻闀滃ご4浣嶇疆鍙婅搴�
+                var listLensnumber4 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 4);
+                for (int k = 0; k < listLensnumber4.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber4[k].X, listLensnumber4[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber4[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber4[k].X, listLensnumber4[k].Y);
+                    if (distance <= runparam.MidLens4R1)
+                    {
+                        listLensnumber4[k].location = "闀滃ご";
+                    }
+                    else if (runparam.MidLens4R1 < distance && distance <= runparam.MidLens4R2)
+                    {
+                        listLensnumber4[k].location = "鏂滈潰";
+                    }
+                    else
+                    {
+                        listLensnumber4[k].location = "骞抽潰";
+
+                    }
+                }
+
+            }
+            return list;
+        }
+        //鑾峰彇鑳屾澘瑙掑害鍜屼綅缃�
+        private List<ResultData> GetBkLocation(List<ResultData> list)
+        {
+            var group = list.GroupBy(a => a.TimeTip);
+            foreach (var item in group)
+            {
+                //璁$畻闀滃ご1缂洪櫡浣嶇疆鍙婅搴�
+                var listLensnumber1 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 1);
+                for (int k = 0; k < listLensnumber1.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber1[k].X, listLensnumber1[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber1[k].angle = lenAngle;
+
+                    var distance = GetDistance(1050, 1050, listLensnumber1[k].X, listLensnumber1[k].Y);
+                    if (distance <= runparam.BkLens1R1)
+                    {
+                        listLensnumber1[k].location = "鍙鍖�";
+                    }
+
+                    else
+                    {
+                        listLensnumber1[k].location = "闈炲彲瑙嗗尯";
+                    }
+
+                }
+                //璁$畻闀滃ご2浣嶇疆鍙婅搴�
+                var listLensnumber2 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 2);
+                for (int k = 0; k < listLensnumber2.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber2[k].X, listLensnumber2[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber2[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber2[k].X, listLensnumber2[k].Y);
+                    if (distance <= runparam.BkLens2R1)
+                    {
+                        listLensnumber2[k].location = "鍙鍖�";
+                    }
+                    else
+                    {
+                        listLensnumber2[k].location = "闈炲彲瑙嗗尯";
+                    }
+                }
+                //璁$畻闀滃ご3浣嶇疆鍙婅搴�
+                var listLensnumber3 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 3);
+                for (int k = 0; k < listLensnumber3.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber3[k].X, listLensnumber3[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber3[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber3[k].X, listLensnumber3[k].Y);
+                    if (distance <= runparam.BkLens3R1)
+                    {
+                        listLensnumber3[k].location = "鍙鍖�";
+                    }
+
+                    else
+                    {
+                        listLensnumber3[k].location = "闈炲彲瑙嗗尯";
+                    }
+                }
+                //璁$畻闀滃ご4浣嶇疆鍙婅搴�
+                var listLensnumber4 = list.FindAll(a => a.TimeTip == item.Key && a.Lensnumber == 4);
+                for (int k = 0; k < listLensnumber4.Count; k++)
+                {
+                    var lenAngle = GetAngle(listLensnumber4[k].X, listLensnumber4[k].Y);
+                    if (lenAngle < 0)
+                    {
+                        lenAngle = 360 + lenAngle;
+                    }
+                    listLensnumber4[k].angle = lenAngle;
+                    var distance = GetDistance(1050, 1050, listLensnumber4[k].X, listLensnumber4[k].Y);
+                    if (distance <= runparam.BkLens4R1)
+                    {
+                        listLensnumber4[k].location = "鍙鍖�";
+                    }
+                    else
+                    {
+                        listLensnumber4[k].location = "闈炲彲瑙嗗尯";
+
+                    }
+                }
+
+            }
+            return list;
+        }
+
+        private void WriteJR(List<ResultData> Lens,string item,int LensNumb, string file12)
+        {
+            if (Lens.Count == 0)
+            {
+
+                var content11 = $"{item},{LensNumb},{"OK"}";
+                File.AppendAllText(file12, content11, Encoding.UTF8);
+                File.AppendAllText(file12, "\r\n");
+            }
+            else
+            {
+                if (Lens[0].DefectType == "鍒櫧")
+                {
+                    var content11 = $"{item},{LensNumb},{Lens[0].JudgmentResult},{Lens[0].DefectType}";
+                    File.AppendAllText(file12, content11, Encoding.UTF8);
+                    File.AppendAllText(file12, "\r\n");
+                    for (int i = 0; i < Lens.Count; i++)
+                    {
+                        if (Lens[i].DefectType == "鍒櫧")
+                        {
+                            var content111 = $"{""},{""},{""},{""},{""},{Lens[i].ex},{Lens[i].location},{Lens[i].X},{Lens[i].Y},{(int)(Lens[i].R)},{(int)(Lens[i].angle)}";
+                            File.AppendAllText(file12, content111, Encoding.UTF8);
+                            File.AppendAllText(file12, "\r\n");
+                        }
+                        else
+                        {
+                            var content111 = $"{""},{""},{""},{Lens[i].DefectType},{""},{Lens[i].ex},{Lens[i].location},{Lens[i].X},{Lens[i].Y},{(int)(Lens[i].R)},{(int)(Lens[i].angle)}";
+                            File.AppendAllText(file12, content111, Encoding.UTF8);
+                            File.AppendAllText(file12, "\r\n");
+                        }
+
+                    }
+                }
+                else
+                {
+                    var content11 = $"{item},{LensNumb},{Lens[0].JudgmentResult},{Lens[0].DefectType},{Lens[0].PostTreatmentResults}";
+                    File.AppendAllText(file12, content11, Encoding.UTF8);
+                    File.AppendAllText(file12, "\r\n");
+                    for (int i = 0; i < Lens.Count; i++)
+                    {
+                        var content111 = $"{""},{""},{""},{""},{""},{Lens[i].ex},{Lens[i].location},{Lens[i].X},{Lens[i].Y},{(int)(Lens[i].R)},{(int)(Lens[i].angle)}";
+                        File.AppendAllText(file12, content111, Encoding.UTF8);
+                        File.AppendAllText(file12, "\r\n");
+                    }
+                }
+
+            }
+        }
+
+
 
         private double GetDistance(double x1, double y1, double x2, double y2)
         {

--
Gitblit v1.8.0