Browse Source

部分代码调整

yuanrf 7 months ago
parent
commit
7e3d718815
1 changed files with 48 additions and 20 deletions
  1. 48 20
      travelExport/Home.cs

+ 48 - 20
travelExport/Home.cs

@@ -163,7 +163,7 @@ namespace travelExport
                         db.SaveChanges();
 
                         var NewListTravel = new List<Grp_TravelList>();
-                        var index = 0;
+                        var index = 1;
                         var stopCity = string.Empty;
 
                         foreach (var item in timeArr)
@@ -411,6 +411,7 @@ namespace travelExport
 
                                 if (index == timeArr.Count - 1)
                                 {
+                                    trip += "圆满结束此次访问之行!";
                                     NewListTravel.Add(new Grp_TravelList
                                     {
                                         CreateTime = DateTime.Now,
@@ -419,7 +420,7 @@ namespace travelExport
                                         Date = Convert.ToDateTime(item).ToString("M月d日"),
                                         Trip = trip,
                                         WeekDay = weekDay,
-                                        Days = index + 1,
+                                        Days = index,
                                         Traffic_First = "飞机",
                                         Traffic_Second = "汽车",
                                         Diffgroup = 1,
@@ -439,7 +440,7 @@ namespace travelExport
                                         Date = Convert.ToDateTime(item).ToString("M月d日"),
                                         Trip = trip,
                                         WeekDay = weekDay,
-                                        Days = index + 1,
+                                        Days = index,
                                         Traffic_First = "飞机",
                                         Traffic_Second = "汽车",
                                         Diffgroup = 1,
@@ -526,7 +527,7 @@ namespace travelExport
                                 Date = Convert.ToDateTime(item).ToString("M月d日"),
                                 Trip = trip,
                                 WeekDay = weekDay,
-                                Days = index + 1,
+                                Days = index,
                                 Traffic_First = traffic[0],
                                 Traffic_Second = traffic[1],
                                 Diffgroup = 1,
@@ -633,7 +634,7 @@ namespace travelExport
                         db.SaveChanges();
 
                         var NewListTravel = new List<Grp_TravelList>();
-                        var index = 0;
+                        var index = 1;
                         var stopCity = string.Empty;
 
                         //本团车导地接信息
@@ -896,6 +897,7 @@ namespace travelExport
 
                                 if (index == timeArr.Count - 1)
                                 {
+                                    trip += "圆满结束此次访问之行!";
                                     NewListTravel.Add(new Grp_TravelList
                                     {
                                         CreateTime = DateTime.Now,
@@ -904,7 +906,7 @@ namespace travelExport
                                         Date = Convert.ToDateTime(item).ToString("M月d日"),
                                         Trip = trip,
                                         WeekDay = weekDay,
-                                        Days = index + 1,
+                                        Days = index,
                                         Traffic_First = "飞机",
                                         Traffic_Second = "汽车",
                                         Diffgroup = 1,
@@ -924,7 +926,7 @@ namespace travelExport
                                         Date = Convert.ToDateTime(item).ToString("M月d日"),
                                         Trip = trip,
                                         WeekDay = weekDay,
-                                        Days = index + 1,
+                                        Days = index,
                                         Traffic_First = "飞机",
                                         Traffic_Second = "汽车",
                                         Diffgroup = 1,
@@ -936,8 +938,8 @@ namespace travelExport
 
                                 if (time.Hour < 9)  // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
                                 {
-                                    var nineTime =  GetTimeGwInfo(ref listgw, new DateTime(time.Year,time.Month,time.Day,09,00,00));
-                                    var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00));
+                                    var nineTime =  GetTimeGwInfo(ref listgw, new DateTime(time.Year,time.Month,time.Day,09,00,00),null);
+                                    var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00), null);
                                     trip += @"
 09:00 公务活动;
 10:30 公务活动;";
@@ -953,7 +955,7 @@ namespace travelExport
                                 }
                                 else if (time.Hour < 10)
                                 {
-                                    var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00));
+                                    var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00), null);
                                     trip += @"
 10:30 公务活动;";
                                     if (!string.IsNullOrWhiteSpace(halfPasTen))
@@ -969,8 +971,8 @@ namespace travelExport
 
                                 if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
                                 {
-                                    var twoPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 14, 00, 00));
-                                    var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00));
+                                    var twoPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 14, 00, 00), null);
+                                    var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00), null);
                                     trip += @"
 14:00 公务活动;
 16:00 公务活动;";
@@ -985,7 +987,7 @@ namespace travelExport
                                 }
                                 else if (time.Hour < 16)
                                 {
-                                    var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00));
+                                    var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00), null);
                                     trip += @"
 16:00 公务活动;";
                                     if (!string.IsNullOrWhiteSpace(fourPointsPM))
@@ -1027,10 +1029,10 @@ namespace travelExport
 18:00 晚餐于当地餐厅;
 19:00 入住酒店休息;";
 
-                                var nineTime = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 09, 00, 00));
-                                var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00));
-                                var twoPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 14, 00, 00));
-                                var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00));
+                                var nineTime = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 09, 00, 00), end_Object.City);
+                                var halfPasTen = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 10, 30, 00), end_Object.City);
+                                var twoPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 14, 00, 00), end_Object.City);
+                                var fourPointsPM = GetTimeGwInfo(ref listgw, new DateTime(time.Year, time.Month, time.Day, 16, 00, 00), end_Object.City);
                                 if (!string.IsNullOrWhiteSpace(nineTime))
                                 {
                                     trip = trip.Replace("09:00 公务活动", nineTime);
@@ -1087,7 +1089,7 @@ namespace travelExport
                                 Date = Convert.ToDateTime(item).ToString("M月d日"),
                                 Trip = trip,
                                 WeekDay = weekDay,
-                                Days = index + 1,
+                                Days = index,
                                 Traffic_First = traffic[0],
                                 Traffic_Second = traffic[1],
                                 Diffgroup = 1,
@@ -1121,7 +1123,6 @@ namespace travelExport
             threadExec.Start();
         }
 
-
         private delegate void ChildThreadExceptionHandler(string message);
 
         private void btnOutput_Click(object sender, EventArgs e)
@@ -1935,7 +1936,7 @@ namespace travelExport
         }
 
 
-        string GetTimeGwInfo(ref List<Res_OfficialActivities> listgw, DateTime gwTime)
+        string GetTimeGwInfo(ref List<Res_OfficialActivities> listgw, DateTime gwTime, string nowCity)
         {
             List<Res_OfficialActivitiesFormat> formatResGw = listgw.Select(x => new Res_OfficialActivitiesFormat
             {
@@ -1965,12 +1966,20 @@ namespace travelExport
                 Translators = x.Translators,
                 Trip = x.Trip,
                 Type = x.Type,
+                Area = x.Area,
+                Country = x.Country,
+                Field = x.Field,
+                ReqSample = x.ReqSample,
             }).ToList();
 
             string info = string.Empty;
 
             List<Res_OfficialActivitiesFormat> dayArr = new List<Res_OfficialActivitiesFormat>();
 
+            Res_OfficialActivitiesFormat gl = null;
+
+            DateTime newGwTime = DateTime.Now;
+
             foreach (var g in formatResGw)
             {
                 var parseTime = g.GetDateTime;
@@ -1987,9 +1996,11 @@ namespace travelExport
                 if (thisData.Hour == gwTime.Hour && thisData.Minute == gwTime.Hour)
                 {
                     isFindTimeGw = true;
+                    newGwTime = thisData;
                     info += $"{thisData.ToString("HH:mm")} 拜访{g.Client},联系人{g.Contact},电话{g.Tel}, 地址{g.Address}" +
                    $"着装要求{g.Dresscode},是否需要翻译{(g.IsNeedTrans == null || g.IsNeedTrans == 0 ? "不需要翻译人员" : "需要翻译人员翻译语种为" + g.language)},议题:- ";
                     listgw.Remove(listgw.Find(x => x.Id == g.Id));
+                    gl = g;
                     break;
                 }
             }
@@ -2007,13 +2018,30 @@ namespace travelExport
                     var thisData = g.GetDateTime;
                     if ((thisData - gwTime) <  new TimeSpan(1,30,0))
                     {
+                        isFindTimeGw = true;
+                        newGwTime = thisData;
                         info += $"{thisData.ToString("HH:mm")} 拜访{g.Client},联系人{g.Contact},电话{g.Tel}, 地址{g.Address}" +
                     $"着装要求{g.Dresscode},是否需要翻译{(g.IsNeedTrans == null || g.IsNeedTrans == 0 ? "不需要翻译人员" : "需要翻译人员翻译语种为" + g.language)},议题:- ";
                         listgw.Remove(listgw.Find(x => x.Id == g.Id));
+                        gl = g;
                     }
                 }
             }
 
+            //判断是否在一个城市
+            if (isFindTimeGw && gl != null && !string.IsNullOrEmpty(gl.Area))
+            {
+                if (gl.Area.Contains(nowCity))
+                {
+
+                }
+                else
+                {
+                    var ApiResult = GetDirectionByGoogleApiFormat(nowCity + "市区", gl.Area);
+                    info = info.Insert(0, $"{newGwTime.AddHours(-1).ToString("HH:mm")} 搭乘专车前往{gl.Area}(路程约{ApiResult.Distance},距离约{ApiResult.Time})\r\n");
+                }
+            }
+
             return info;
         }
     }