Browse Source

op完善时间生成

yuanrf 11 months ago
parent
commit
fd73bb2540

+ 2 - 2
OASystem/OASystem.Domain/Dtos/Groups/CarTouristGuideGroundDto.cs

@@ -98,7 +98,7 @@ namespace OASystem.Domain.Dtos.Groups
         public string Remark { get; set; }
         public string Remark { get; set; }
     }
     }
 
 
-    public class CarTouristGuideGroundContentDto
+    public class CarTouristGuideGroundContentDto : PortDtoBase
     {
     {
         public int UserId { get; set; }
         public int UserId { get; set; }
 
 
@@ -182,7 +182,7 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// <summary>
         /// 单位
         /// 单位
         /// </summary>
         /// </summary>
-        public int? Units { get; set; }
+        public int Units { get; set; }
 
 
 
 
         ///// <summary>
         ///// <summary>

+ 1 - 1
OASystem/OASystem.Domain/Entities/Groups/Grp_CarTouristGuideGroundReservationsContent.cs

@@ -59,6 +59,6 @@ namespace OASystem.Domain.Entities.Groups
         /// 单位
         /// 单位
         /// </summary>
         /// </summary>
         [SugarColumn(ColumnDescription = "单位", IsNullable = true, ColumnDataType = "int")]
         [SugarColumn(ColumnDescription = "单位", IsNullable = true, ColumnDataType = "int")]
-        public int? Units { get; set; }
+        public int Units { get; set; }
     }
     }
 }
 }

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/CarTouristCreditCardPaymentView.cs

@@ -86,6 +86,6 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// <summary>
         /// 单位
         /// 单位
         /// </summary>
         /// </summary>
-        public int? Units { get; set; }
+        public int Units { get; set; }
     }
     }
 }
 }

+ 136 - 29
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -1,5 +1,7 @@
-using AutoMapper;
+using Aspose.Words.Tables;
+using AutoMapper;
 using NPOI.SS.UserModel;
 using NPOI.SS.UserModel;
+using NPOI.Util;
 using OASystem.Domain;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Financial;
@@ -168,8 +170,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
 
                 //列表初始化
                 //列表初始化
                 List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
                 List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
-                //List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
-                //_TableInitialization= _TableInitialization.OrderBy(a=>a.Name).ToList();
+                List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
 
 
                 List<Sys_SetData> ssd = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.STid == 78).ToList();
                 List<Sys_SetData> ssd = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.STid == 78).ToList();
                 List<SetDataInfoView> ssdv = _mapper.Map<List<Sys_SetData>,List<SetDataInfoView>>(ssd);
                 List<SetDataInfoView> ssdv = _mapper.Map<List<Sys_SetData>,List<SetDataInfoView>>(ssd);
@@ -190,31 +191,87 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         });
                         });
                     }
                     }
                 }
                 }
-
+                
                 var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x => x.Key, x => x.ToList());
                 var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x => x.Key, x => x.ToList());
                 foreach (var item in groupResult.Keys)
                 foreach (var item in groupResult.Keys)
                 {
                 {
-                    while (groupResult[item].Count <= day)
+                    #region 倒推初始化逻辑
+                    //while (groupResult[item].Count <= day)
+                    //{
+                    //    groupResult[item] = groupResult[item].OrderByDescending(x => x.DatePrice).ToList();
+                    //    if (groupResult[item][0]?.DatePrice is not null)
+                    //    {
+                    //        groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
+                    //        {
+                    //            DatePrice = groupResult[item][0].DatePrice.ObjToDate().AddDays(1),
+                    //            SId = item,
+                    //            Count = 1,
+                    //        });
+                    //    }
+                    //    else
+                    //    {
+                    //        groupResult[item][0].DatePrice = start;
+                    //    }
+                    //}
+                    #endregion
+
+                    var startForTime = start;
+
+                    var dayResult = new List<CarTouristGuideGroundReservationsContentView>();
+
+                    for (var i = 0; i <= day; i++)
                     {
                     {
-                        groupResult[item] = groupResult[item].OrderByDescending(x => x.DatePrice).ToList();
-                        if (groupResult[item][0]?.DatePrice is not null)
+                        dayResult.Add(new CarTouristGuideGroundReservationsContentView
                         {
                         {
-                            groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
+                            Count = 1,
+                            DatePrice = startForTime,
+                            SId = item,
+                        });
+                        startForTime = startForTime.AddDays(1);
+                    }
+
+                    if (groupResult[item].Count != day)
+                    {
+
+                        for (var m = 0; m< groupResult[item].Count; m++)
+                        {
+                            for (var m1 = 0; m1 < dayResult.Count; m1++)
                             {
                             {
-                                DatePrice = groupResult[item][0].DatePrice.ObjToDate().AddDays(1),
-                                SId = item,
-                                Count = 1,
-                            });
+                                if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
+                                {
+                                    dayResult[m1] = groupResult[item][m];
+                                }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        groupResult[item] = groupResult[item].OrderBy(x => x.DatePrice).ToList();
+
+                        if (groupResult[item][0].DatePrice == dayResult[0].DatePrice && groupResult[item][day - 1].DatePrice == dayResult[day - 1].DatePrice)
+                        {
+                            dayResult = groupResult[item];
                         }
                         }
                         else
                         else
                         {
                         {
-                            groupResult[item][0].DatePrice = start;
+                            for (var m = 0; m < groupResult[item].Count; m++)
+                            {
+                                for (var m1 = 0; m1 < dayResult.Count; m1++)
+                                {
+                                    if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
+                                    {
+                                        dayResult[m1] = groupResult[item][m];
+                                    }
+                                }
+                            }
                         }
                         }
                     }
                     }
+
+                    groupResult[item] = dayResult;
                 }
                 }
 
 
-                carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).OrderBy(x=>x.SId).ThenBy(x=>x.DatePrice).ToList();
-                foreach (var item in carTouristGuides.Where(x=>string.IsNullOrWhiteSpace(x.SidName)).ToList())
+                carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).OrderBy(x => x.SId).ThenBy(x => x.DatePrice).ToList();
+                foreach (var item in carTouristGuides.Where(x => string.IsNullOrWhiteSpace(x.SidName)).ToList())
                 {
                 {
                     item.SidName = TableInitialization.Find(x => x.Id == item.SId)?.Name;
                     item.SidName = TableInitialization.Find(x => x.Id == item.SId)?.Name;
                 }
                 }
@@ -252,6 +309,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 };
                 };
 
 
                 var checkedItem = new List<string>();
                 var checkedItem = new List<string>();
+                var checkedItemId = new List<int>();
 
 
                 if (string.IsNullOrWhiteSpace(grpCarOp.SelectCheck))
                 if (string.IsNullOrWhiteSpace(grpCarOp.SelectCheck))
                 {
                 {
@@ -274,6 +332,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                 else
                                 else
                                 {
                                 {
                                     checkedItem.Add(soureKey);
                                     checkedItem.Add(soureKey);
+                                    checkedItemId.Add(_TableInitialization.Find(x=>x.Name == soureKey)!.Id);
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -282,23 +341,52 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 else
                 else
                 {
                 {
                     checkedItem = grpCarOp.SelectCheck.Split(",").ToList<string>();
                     checkedItem = grpCarOp.SelectCheck.Split(",").ToList<string>();
+                    int number = 0;
+                    foreach (var item in checkedItem)
+                    {
+                        if (!int.TryParse(item,out number))
+                        {
+                            checkedItemId.Add(_TableInitialization.Find(x => x.Name == item)!.Id);
+                        }
+                        else
+                        {
+                            checkedItemId.Add(number);
+                        }
+                    }
                 }
                 }
 
 
-                var data = new
+                if(dto.PortType == 1)
                 {
                 {
-                    Payment = _Payment,
-                    Delegations = grp_Delegations,
-                    carTouristGuides = carTouristGuides,
-                    CreditCardPayment = _CreditCardPayment,
-                    start,
-                    end,
-                    ssdv,
-                    checkedItem
-                };
-
-                return result = new Result() { Code = 0, Msg = "查询成功",Data=data };
+                    var data = new
+                    {
+                        Payment = _Payment,
+                        Delegations = grp_Delegations,
+                        carTouristGuides = carTouristGuides,
+                        CreditCardPayment = _CreditCardPayment,
+                        start,
+                        end,
+                        ssdv,
+                        checkedItem
+                    };
+
+                    return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
+
+                } else if(dto.PortType == 2)
+                {
+                    var data = new
+                    {
+                        Payment = _Payment,
+                        TableInitialization = _TableInitialization,
+                        carTouristGuides = carTouristGuides,
+                        CreditCardPayment = _CreditCardPayment,
+                        ssdv,
+                        checkedItemId
+                    };
+                    return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
+                }
 
 
-            }
+                return result = new Result() { Code = -1, Msg = "请传入有效portType" };
+}
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 return result = new Result() { Code = -2, Msg = "未知错误" };
                 return result = new Result() { Code = -2, Msg = "未知错误" };
@@ -506,7 +594,26 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     DatePrice = item.DatePrice,
                     DatePrice = item.DatePrice,
                     Count = item.Count,
                     Count = item.Count,
                 }).ToList();
                 }).ToList();
-                
+
+                //车超时费
+                //餐费和三公经费那个表做完匹配后也放进超支表里
+                //DataTable tb = new DataTable();
+                //tb.Columns.Add("日期",typeof(DateTime));
+                //tb.Columns.Add("费用", typeof(decimal));
+                //var addsTourClientList = new List<Grp_TourClientList>();
+                //var carExtraList = carTouristList.Where(x => x.SId == 982).ToList();
+                //var mealPriceList = carTouristList.Where(x => x.SId == 93 || x.SId == 988 || x.SId == 989).GroupBy(x => x.DatePrice).ToList();
+                //mealPriceList.ForEach(x =>
+                //{
+                //    var row = tb.NewRow();
+                //    row["日期"] = x.Key;
+                //    row["费用"] = x.Sum(x => x.Price);
+                //});
+
+                //三公费用
+                //var cityPrice = carTouristList.Where(x=>)
+
+
                 foreach (var item in carTouristList)
                 foreach (var item in carTouristList)
                 {
                 {
                    
                    

+ 13 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -625,6 +625,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     MealSpecialNeeds = item.MealSpecialNeeds,
                     MealSpecialNeeds = item.MealSpecialNeeds,
                     Remark = item.Remark
                     Remark = item.Remark
                 };
                 };
+
+
+                //判断现有团组客户名单是否存在该客户
+                var QuerFirstClient = _sqlSugar.Queryable<Grp_TourClientList>().First(x => x.ClientId == _TourClientList.ClientId && x.DiId == _TourClientList.DiId && x.IsDel == 0);
+                if (QuerFirstClient != null)
+                {
+                    QuerFirstClient.IsDel = 1;
+                    QuerFirstClient.DeleteUserId = dto.UserId;
+                    QuerFirstClient.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                    var UpdateTrue = _sqlSugar.Updateable(QuerFirstClient).UpdateColumns(x => new { x.IsDel,x.DeleteUserId,x.DeleteTime}).ExecuteCommand() > 0;
+                }
+
+
                 var tourClientAdd = await _sqlSugar.Insertable(_TourClientList).ExecuteReturnIdentityAsync();
                 var tourClientAdd = await _sqlSugar.Insertable(_TourClientList).ExecuteReturnIdentityAsync();
                 if (tourClientAdd < 0)
                 if (tourClientAdd < 0)
                 {
                 {