Browse Source

优化费用处理和数据结构

在 `FinancialController.cs` 中,将 `FoodCost` 从字符串类型改为十进制类型,并直接使用 `x.FoodCost` 进行计算。
在 `GroupsController.cs` 中,新增多个方法和 DTO 类,处理出入境费用的基础数据源和国家费用标准,并增加省份归属逻辑。
在 `EnterExitCostDto.cs` 中,新增 `EnterExitCostDataSourceDto` 和 `NationalTravelFeeDataDto` 类,增加省份 ID 属性。
在 `Grp_NationalTravelFee.cs` 中,修改多个费用字段类型为十进制,以便更好地进行数值计算。
在 `OrderPreInfoView.cs` 中,优化字符串拼接,使用 `StringBuilder` 提高性能。
在 `CommonFun.cs` 中,新增扩展方法 `HasValue`,检查 `StringBuilder` 是否有值。
更新多个方法的参数类型和返回类型,以适应新的数据结构和业务逻辑。
LEIYI 2 weeks ago
parent
commit
fb2673e736

+ 3 - 2
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -4163,8 +4163,9 @@ Group by PriceType ", dto.diId);
 
                     if (x.VisitPNumber > 0 && x.PriceDetailType != 1088)
                     {
-                        decimal.TryParse(x.FoodCost, out decimal cost);
-                        cost /= 2;
+                        decimal cost = x.FoodCost;
+                        //decimal.TryParse(x.FoodCost, out decimal cost);
+                         cost /= 2;
 
                         decimal oldPrice = costPirce;
                         costPirce *= x.Rate; //转换币种

+ 206 - 57
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -5578,13 +5578,43 @@ FROM
 
         #region 团组经理模块 出入境费用
 
+
+        /// <summary>
+        /// 团组模块 - 出入境费用 - 基础数据源 - 省份归属
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
+        {
+            var provData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 110).ToListAsync();
+
+            var view = provData.Select(x => {
+
+                int.TryParse(x.Remark, out int val);
+
+                var data = new SetDataSortView
+                {
+                    Id = x.Id,
+                    Name = x.Name,
+                    Index = val
+                };
+
+                return data;
+            }).OrderBy(x => x.Index).ToArray();
+
+
+            return Ok(JsonView(true, "查询成功!", view));
+        }
+
+
         /// <summary>
         /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
         /// </summary>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
+        public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
         {
             var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
 
@@ -5595,11 +5625,42 @@ FROM
             var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
             List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
 
-            var wordTypeData = dataSource.Where(it => it.STid == 72).ToList();  //三公费用-Word明细类型
-            List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
+            //验证城市归属并给默认值
+            int provinceId = dto.ProvinceId;
+            if (provinceId < 1) provinceId = 1408;
 
-            var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
-            List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
+            var wordTypeData = Array.Empty<SetDataInfoView>();
+            var excelTypeData = Array.Empty<SetDataInfoView>();
+
+            if (provinceId == 1408) //四川
+            {
+                //三公费用-Word明细类型
+                wordTypeData = dataSource
+                    .Where(it => it.STid == 72)
+                    .Select(x => new SetDataInfoView
+                    {
+                        Id = x.Id,
+                        Name = x.Name,
+                        Remark = x.Remark
+                    })
+                    .ToArray();
+
+                excelTypeData = dataSource
+                    .Where(it => it.STid == 73)
+                    .Select(x => new SetDataInfoView
+                    {
+                        Id = x.Id,
+                        Name = x.Name,
+                        Remark = x.Remark
+                    })
+                    .ToArray();
+            }
+            else if (provinceId == 1409) //贵州
+            { }
+            else if (provinceId == 1410) //重庆
+            { }
+            else if (provinceId == 1411) //昆明
+            { }
 
             var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
 
@@ -5608,8 +5669,8 @@ FROM
             {
                 GroupNameData = groupNameData.Data,
                 CurrencyData = _CurrencyData,
-                WordTypeData = _WordTypeData,
-                ExcelTypeData = _ExcelTypeData,
+                WordTypeData = wordTypeData,
+                ExcelTypeData = excelTypeData,
                 CurrencyInit = _currencyInfos,
                 ViewPermissionData = viewPermissionData
             }));
@@ -7487,38 +7548,38 @@ FROM
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
-        {
-            Stopwatch sw = new Stopwatch();
-            sw.Start();
-            string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
-                                                              Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
-                                                              Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id 
-                                                              Where gntf.Isdel = 0");
-            var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
-
-            //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
-
-            //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
-
-            //foreach (var item in nationalTravel)
-            //{
-            //    var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
-            //    var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
-            //    if (otherData != null)
-            //    {
-            //        cityData.Remove(otherData);
-            //        cityData.Add(otherData);
-            //    }
-            //    nationalTravelFeeData1.Add(new
-            //    {
-            //        Country = item.Country,
-            //        CityData = cityData
-            //    });
-            //}
-
-            sw.Stop();
-            return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
+        public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
+        {
+            int provinceId = dto.ProvinceId;
+            if (provinceId < 1) provinceId = 1408; //默认四川省数据
+
+            var nftData = await _sqlSugar
+                .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_SetData>((ntf, sd1, u, sd2) => new JoinQueryInfos(
+                    JoinType.Left, ntf.Currency == sd1.Id,
+                    JoinType.Left, ntf.LastUpdateUserId == u.Id,
+                    JoinType.Left, ntf.ProvinceId == sd2.Id
+                ))
+                .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
+                .Select((ntf, sd1, u, sd2) => new NationalTravelFeeInfoView {
+                    Id = ntf.Id,
+                    ProvinceId = ntf.ProvinceId,
+                    ProvinceName = sd2.Name,
+                    Continent = ntf.Continent,
+                    Country = ntf.Country,
+                    City = ntf.City,
+                    Currency = ntf.Currency,
+                    CurrencyCode = sd1.Name,
+                    CurrencyName = sd1.Remark,
+                    RoomCost = ntf.RoomCost,
+                    FoodCost = ntf.FoodCost,
+                    PublicCost = ntf.PublicCost,
+                    LastUpdateUserId = ntf.LastUpdateUserId,
+                    LastUpdateUserName = u.CnName,
+                    LastUpdateTime = ntf.LastUpdateTime
+                })
+                .ToListAsync();
+                
+            return Ok(JsonView(true, "查询成功!", nftData));
 
         }
 
@@ -7586,7 +7647,37 @@ FROM
                                              Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id 
                                              Where gntf.Isdel = 0 {0} ) temp ", whereSql);
             RefAsync<int> total = 0;
-            var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
+            var nationalTravelFeeData = await _sqlSugar
+                .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_SetData>((ntf, sd1, u, sd2) => new JoinQueryInfos(
+                    JoinType.Left, ntf.Currency == sd1.Id,
+                    JoinType.Left, ntf.LastUpdateUserId == u.Id,
+                    JoinType.Left, ntf.ProvinceId == sd2.Id
+                ))
+                .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
+                .WhereIF(dto.ProvinceId > 0 , (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
+                .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
+                .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
+                .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
+                .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
+                {
+                    RowNumber =  SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
+                    Id = ntf.Id,
+                    ProvinceId = ntf.ProvinceId,
+                    ProvinceName = sd2.Name,
+                    Continent = ntf.Continent,
+                    Country = ntf.Country,
+                    City = ntf.City,
+                    Currency = ntf.Currency,
+                    CurrencyCode = sd1.Name,
+                    CurrencyName = sd1.Remark,
+                    RoomCost = ntf.RoomCost,
+                    FoodCost = ntf.FoodCost,
+                    PublicCost = ntf.PublicCost,
+                    LastUpdateUserId = ntf.LastUpdateUserId,
+                    LastUpdateUserName = u.CnName,
+                    LastUpdateTime = ntf.LastUpdateTime
+                })
+                .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
             return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
 
@@ -12358,7 +12449,7 @@ FROM
             var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565);      //税费
 
             //获取模板
-            string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
+            string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
             var designer = new WorkbookDesigner();
             designer.Workbook = new Workbook(tempPath);
 
@@ -12372,19 +12463,34 @@ FROM
             {
                 var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
 
-                string label = string.Empty;
+                StringBuilder label = new StringBuilder();
                 var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
                 if (infos.Any())
                 {
-                    label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
+                    label.Append(infos.Sum(x => x.PplNum));
+                    label.Append("人全程机票:");
+                    label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
+                    label.AppendLine("元");
                 }
 
                 foreach (var item in intTravelCosts.Infos)
                 {
-                    label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
+                    label.Append(item.FeeName);
+                    label.Append(":");
+                    label.Append(item.UnitPrice.TruncDecimals(2));
+                    label.Append("元/人*");
+                    label.Append(item.PplNum);
+                    label.AppendLine("人");
                 }
-                label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
-                designer.SetDataSource("IntTravelLabel", label);
+
+                if (label.HasValue())
+                {
+                    label.Append("\r\n以上小计:");
+                    label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
+                    label.Append("元");
+                }
+
+                designer.SetDataSource("IntTravelLabel", label.ToString());
             }
             #endregion
             #region 住宿费 
@@ -12393,7 +12499,9 @@ FROM
             {
                 string currencyName = string.Empty;
                 decimal rate = 1.0000M;
-                string label = "全程五星酒店,每人1间房\r\n";
+
+                StringBuilder label = new StringBuilder();
+                label.AppendLine("全程五星酒店,每人1间房");
                 foreach (var item in accomCosts.Infos)
                 {
                     string hotelName = string.Empty;
@@ -12408,10 +12516,26 @@ FROM
                     currencyName = rateInfo?.CurrencyName ?? "UnKnow";
                     rate = rateInfo?.Rate ?? 1.0000M;
 
-                    label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
+                    label.Append(hotelName);
+                    label.Append(item.UnitPrice.TruncDecimals(2));
+                    label.Append(currencyName);
+                    label.Append("/间/晚*");
+                    label.Append(item.Quantity.ToString("#0"));
+                    label.AppendLine("人");
+
                 }
-                label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
-                designer.SetDataSource("AccomLabel", label);
+                if (label.HasValue())
+                {
+                    label.Append("\r\n以上小计:");
+                    label.Append(accomCosts.TotalAmt.TruncDecimals(2));
+                    label.Append("元(");
+                    label.Append(currencyName);
+                    label.Append("汇率:");
+                    label.Append(rate.TruncDecimals(4));
+                    label.Append(")");
+                }
+
+                designer.SetDataSource("AccomLabel", label.ToString());
             }
             #endregion
 
@@ -12421,7 +12545,10 @@ FROM
             {
                 string currencyName = string.Empty;
                 decimal rate = 1.0000M;
-                string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
+
+                StringBuilder label = new StringBuilder();
+                label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
+
                 foreach (var item in mealCosts.Infos)
                 {
                     string name = string.Empty;
@@ -12436,10 +12563,26 @@ FROM
                     currencyName = rateInfo?.CurrencyName ?? "UnKnow";
                     rate = rateInfo?.Rate ?? 1.0000M;
 
-                    label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
+                    label.Append(name);
+                    label.Append(item.UnitPrice.TruncDecimals(2));
+                    label.Append(currencyName);
+                    label.Append("/天*");
+                    label.Append(item.Quantity.ToString("#0"));
+                    label.Append("*");
+                    label.Append(item.PplNum);
+                    label.Append("人\r\n");
+                }
+                if (label.HasValue())
+                {
+
+                    label.Append("\r\n以上小计:");
+                    label.Append(accomCosts.TotalAmt.TruncDecimals(2));
+                    label.Append("元\r\n(");
+                    label.Append("汇率:");
+                    label.Append(rate.TruncDecimals(4));
+                    label.Append(")");
                 }
-                label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
-                designer.SetDataSource("MealLabel", label);
+                designer.SetDataSource("MealLabel", label.ToString());
             }
             #endregion
 
@@ -12449,13 +12592,19 @@ FROM
             {
                 string currencyName = string.Empty;
                 //decimal rate = 1.0000M;
-                string label = $"";
+                StringBuilder label = new StringBuilder();
                 foreach (var item in vehArranges.Infos)
                 {
-                    label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
+                    label.Append(item.Remark);
+                    label.AppendLine();
+                    label.AppendLine();
+                    label.Append(item.FeeName);
+                    label.Append("\r\n\r\n费用:");
+                    label.Append(item.FeeName);
+                    label.Append(item.TotalAmt.TruncDecimals(2));
                 }
 
-                designer.SetDataSource("VehArrangeLabel", label);
+                designer.SetDataSource("VehArrangeLabel", label.ToString());
             }
             #endregion
 

+ 21 - 0
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDto.cs

@@ -11,6 +11,11 @@ namespace OASystem.Domain.Dtos.Groups
     {
     }
 
+    public class EnterExitCostDataSourceDto : PortDtoBase
+    {
+        public int ProvinceId { get; set; } = 1408;
+    }
+
     /// <summary>
     /// 出入境费用详情 Dto
     /// </summary>
@@ -336,6 +341,11 @@ namespace OASystem.Domain.Dtos.Groups
     /// </summary>
     public class NationalTravelFeePageDto : DtoBase
     {
+        /// <summary>
+        /// 省份归属
+        /// </summary>
+        public int ProvinceId { get; set; } = 1408;
+
         /// <summary>
         /// 国家
         /// </summary>
@@ -371,6 +381,12 @@ namespace OASystem.Domain.Dtos.Groups
     public class EnterExitCostSubItemDelDto : DelBaseDto
     { }
 
+
+    public class NationalTravelFeeDataDto : PortDtoBase
+    {
+        public int ProvinceId { get; set; } = 1408;
+    }
+
     /// <summary>
     /// 团组模块 - 出入境国家费用标准 - Del
     /// </summary>
@@ -395,6 +411,11 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         public int UserId { get; set; }
 
+        /// <summary>
+        /// 身份归属Id
+        /// </summary>
+        public int ProvinceId { get; set; }
+
         /// <summary>
         /// 洲别
         /// </summary>

+ 10 - 4
OASystem/OASystem.Domain/Entities/Groups/Grp_NationalTravelFee.cs

@@ -13,6 +13,12 @@ namespace OASystem.Domain.Entities.Groups
     [SugarTable("Grp_NationalTravelFee")]
     public class Grp_NationalTravelFee : EntityBase
     {
+        /// <summary>
+        /// 归属省份
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int ProvinceId { get; set; }
+
         /// <summary>
         /// 洲别
         /// </summary>
@@ -42,25 +48,25 @@ namespace OASystem.Domain.Entities.Groups
         /// 住宿费
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
-        public string? RoomCost { get; set; }
+        public decimal RoomCost { get; set; }
 
         /// <summary>
         /// 伙食费
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
-        public string? FoodCost { get; set; }
+        public decimal FoodCost { get; set; }
 
         /// <summary>
         /// 公杂费 
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
-        public string? PublicCost { get; set; }
+        public decimal PublicCost { get; set; }
 
         /// <summary>
         /// 培训费 
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
-        public string? TrainCost { get; set; }
+        public decimal TrainCost { get; set; }
 
         /// <summary>
         /// 最后更新人 

+ 4 - 74
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -56,6 +56,9 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public int Id { get; set; }
 
+        public int ProvinceId { get; set; }
+        public string ProvinceName { get; set; }
+
         /// <summary>
         /// 洲别
         /// </summary>
@@ -126,86 +129,13 @@ namespace OASystem.Domain.ViewModels.Groups
     /// <summary>
     /// 出入境国家(城市)费用标准 Page Info  View
     /// </summary>
-    public class NationalTravelFeePageInfoView
+    public class NationalTravelFeePageInfoView : NationalTravelFeeInfoView
     {
         /// <summary>
         /// 行号
         /// </summary>
         public int RowNumber { get; set; }
 
-        public int Id { get; set; }
-
-        /// <summary>
-        /// 洲别
-        /// </summary>
-        public string? Continent { get; set; }
-
-        /// <summary>
-        /// 国家
-        /// </summary>
-        public string? Country { get; set; }
-
-        /// <summary>
-        /// 城市
-        /// </summary>
-        public string? City { get; set; }
-
-        /// <summary>
-        /// 币种
-        /// Sys_SetData STid=66
-        /// </summary>
-        public int Currency { get; set; }
-
-        /// <summary>
-        /// 币种code
-        /// </summary>
-        public string CurrencyCode { get; set; }
-
-        /// <summary>
-        /// 币种名称
-        /// </summary>
-        public string CurrencyName { get; set; }
-
-        /// <summary>
-        /// 住宿费
-        /// </summary>
-        public decimal RoomCost { get; set; }
-
-        /// <summary>
-        /// 伙食费
-        /// </summary>
-        public decimal FoodCost { get; set; }
-
-        /// <summary>
-        /// 公杂费 
-        /// </summary>
-        public decimal PublicCost { get; set; }
-
-        /// <summary>
-        /// 培训费
-        /// </summary>
-        public decimal TrainCost { get; set; }
-
-        /// <summary>
-        /// 备注
-        /// </summary>
-        public string Remark { get; set; }
-
-        /// <summary>
-        /// 最后更新人 
-        /// </summary>
-        public int LastUpdateUserId { get; set; }
-
-        /// <summary>
-        /// 最后更新人
-        /// </summary>
-        public string LastUpdateUserName { get; set; }
-
-        /// <summary>
-        /// 最后更新时间 
-        /// </summary>
-        public DateTime? LastUpdateTime { get; set; } = DateTime.Now;
-
     }
 
     /// <summary>

+ 3 - 19
OASystem/OASystem.Domain/ViewModels/Groups/OrderPreInfoView.cs

@@ -1,15 +1,6 @@
-using NetTaste;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
 using OASystem.Domain.Entities.Groups;
-using System;
 using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
 
 namespace OASystem.Domain.ViewModels.Groups
 {
@@ -17,11 +8,10 @@ namespace OASystem.Domain.ViewModels.Groups
     {
     }
 
-
     public class GroupOrderPreInfoListView
     {
         public int Id { get; set; }
-
+ 
         public string Name { get; set; }
 
         public string UnitName { get; set; }
@@ -36,7 +26,6 @@ namespace OASystem.Domain.ViewModels.Groups
 
                 try
                 {
-
                     var countryArr = JsonConvert.DeserializeObject<string[]>(VisitCountryVal);
 
                     if (countryArr.Any()) val = string.Join("、", countryArr);
@@ -68,7 +57,6 @@ namespace OASystem.Domain.ViewModels.Groups
         public int GroupId { get; set; }
 
         public GrpOrderPreItemView[] Items { get; set; }
-
     }
 
     public class GrpOrderPreItemView
@@ -83,6 +71,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public string OriginVal { get; set; }
 
         private object _newValue;
+
         public object NewValue
         {
             get
@@ -94,7 +83,6 @@ namespace OASystem.Domain.ViewModels.Groups
                     if (_newValue != null)
                     {
                         OriginVal = _newValue.ToString();
-
                     }
 
                     if (OriginVal.Equals("-")) return _newValue;
@@ -127,15 +115,11 @@ namespace OASystem.Domain.ViewModels.Groups
                     try
                     {
                         return JsonConvert.DeserializeObject<string[]>(OriginVal);
-
                     }
                     catch (Exception)
                     {
-
                         return val;
                     }
-
-
                 }
                 else if (FieldTypeName.Equals("下拉选择框") || FieldTypeName.Equals("复选框") || FieldTypeName.Equals("数字"))
                 {

+ 8 - 0
OASystem/OASystem.Domain/ViewModels/System/SetDataView.cs

@@ -232,4 +232,12 @@ namespace OASystem.Domain.ViewModels.System
         public string StName { get; set; }
         public string CnName { get;set; }
     }
+
+    public class SetDataSortView
+    {
+        public int Id { get; set; }
+        public string Name { get; set; }
+
+        public int Index { get; set; }
+    }
 }

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -864,7 +864,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                     cityPrice ??= new Grp_NationalTravelFee
                     {
-                        FoodCost = "0",
+                        FoodCost = 0.00M,
                         Id = 0,
                     };
 

+ 13 - 14
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostQuoteRepository.cs

@@ -19,7 +19,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
     /// </summary>
     public class EnterExitCostQuoteRepository : BaseRepository<Grp_EnterExitCostQuoteItem, EnterExitCostQuoteView>
     {
-        private readonly IMapper _mapper; 
+        private readonly IMapper _mapper;
+
         public EnterExitCostQuoteRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
         {
             _mapper = mapper;
@@ -42,11 +43,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }).ToListAsync();
 
             var newList = origList.Select(x => new InitBasicItemView
-                {
-                    Id = x.Id,
-                    Name = removeNl ? x.Name.Replace("\\r\\n", "") : x.Name,
-                    Index = int.TryParse(x.Index,out int index) ? index : -1
-                })
+            {
+                Id = x.Id,
+                Name = removeNl ? x.Name.Replace("\\r\\n", "") : x.Name,
+                Index = int.TryParse(x.Index, out int index) ? index : -1
+            })
                 .OrderBy(x => x.Index)
                 .ToList();
             return newList;
@@ -171,7 +172,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             if (basicItems.Any())
             {
-                viewInfo.FeeItems = basicItems.Select(x => new QuoteItemInfo { ItemId = x.Id, ItemName = x.Name,Index = x.Index }).OrderBy(x => x.Index).ToArray();
+                viewInfo.FeeItems = basicItems.Select(x => new QuoteItemInfo { ItemId = x.Id, ItemName = x.Name, Index = x.Index }).OrderBy(x => x.Index).ToArray();
             }
 
             var quoteInfo = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
@@ -200,7 +201,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 if (quoteItems.Any())
                 {
-                    viewInfo.FeeItems = viewInfo.FeeItems.Select(x => new QuoteItemInfo { Index = x.Index, QuoteId = dto.Id,ItemId = x.ItemId,ItemName=x.ItemName,Infos = quoteItems.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray() }).ToArray();
+                    viewInfo.FeeItems = viewInfo.FeeItems.Select(x => new QuoteItemInfo { Index = x.Index, QuoteId = dto.Id, ItemId = x.ItemId, ItemName = x.ItemName, Infos = quoteItems.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray() }).ToArray();
                 }
             }
 
@@ -283,7 +284,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 jw.Msg = "新增成功!";
             }
-            else if (!isNull) //编辑 
+            else if (!isNull) //编辑
             {
                 var quoteUpd = await _sqlSugar.Updateable(quoteInfo).IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.IsDel }).ExecuteCommandAsync();
                 if (quoteUpd < 1)
@@ -325,7 +326,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return jw;
         }
 
-
         /// <summary>
         /// ItemDel
         /// </summary>
@@ -349,7 +349,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 jw.Msg = MsgTips.Id;
                 return jw;
             }
-            var info = await _sqlSugar.Queryable<Grp_EnterExitCostQuoteItem>().FirstAsync(x => x.IsDel == 0 && x.Id  == id);
+            var info = await _sqlSugar.Queryable<Grp_EnterExitCostQuoteItem>().FirstAsync(x => x.IsDel == 0 && x.Id == id);
             if (info == null)
             {
                 jw.Msg = $"操作成功!";
@@ -367,7 +367,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 .ExecuteCommandAsync();
             if (del < 1)
             {
-                jw.Msg = $"删除失败!"; 
+                jw.Msg = $"删除失败!";
                 _sqlSugar.RollbackTran();
                 return jw;
             }
@@ -390,6 +390,5 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             return jw;
         }
-
     }
-}
+}

+ 12 - 12
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostRepository.cs

@@ -631,24 +631,24 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             var result = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败!" };
 
-            Grp_NationalTravelFee nationalTravelFee = _mapper.Map<Grp_NationalTravelFee>(dto);
-            nationalTravelFee.LastUpdateUserId = dto.UserId;
-            nationalTravelFee.CreateUserId = dto.UserId;
+            var info = _mapper.Map<Grp_NationalTravelFee>(dto);
+            info.LastUpdateUserId = dto.UserId;
+            info.CreateUserId = dto.UserId;
 
             if (dto.PortType == 1) //web
             {
 
-                var _nationalTravelFee = _sqlSugar.Storageable<Grp_NationalTravelFee>(nationalTravelFee).ToStorage();
+                var _nationalTravelFee = _sqlSugar.Storageable(info).ToStorage();
                 if (dto.Id == 0) //新增
                 {
-                    string selectSql = string.Format(@"Select * From Grp_NationalTravelFee 
-                                                   Where IsDel = 0 
-                                                   And Continent = '{0}' 
-                                                   And Country = '{1}'
-                                                   And City = '{2}'", dto.Continent, dto.Country, dto.City);
-                    Grp_NationalTravelFee nationalTravelFee1 = new Grp_NationalTravelFee();
-                    nationalTravelFee1 = await _sqlSugar.SqlQueryable<Grp_NationalTravelFee>(selectSql).FirstAsync();
-                    if (nationalTravelFee1 != null)
+                    var isNul = await _sqlSugar
+                        .Queryable<Grp_NationalTravelFee>()
+                        .FirstAsync(x => x.IsDel == 0 && 
+                            x.ProvinceId == info.ProvinceId &&
+                            info.Continent.Contains(dto.Continent) &&
+                            info.Country.Contains(dto.Country) &&
+                            info.City.Contains(dto.City));
+                    if (isNul != null)
                     {
                         result.Msg = "该国家 城市已存在,请勿重复添加!";
                         return result;

+ 13 - 0
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -680,4 +680,17 @@ public static class CommonFun
         return PinyinHelper.GetPinyin(chineseName, "").ToUpper();
     }
 
+    #region stringBuilder 扩展
+
+    /// <summary>
+    /// StringBuilder 验证是否有值
+    /// </summary>
+    /// <param name="sb"></param>
+    /// <returns></returns>
+    public static bool HasValue(this StringBuilder sb)
+    {
+        return sb != null && sb.Length > 0;
+    }
+    #endregion
+
 }