Browse Source

优化数据库同步和团组信息处理功能

在 `Program.cs` 中添加数据库结构同步完成的输出信息,并设置字符串默认长度和备份表的初始化。
在 `GroupsController.cs` 中添加多个命名空间引用,修改 `CityByCountry` 方法以优化城市数据查询,新增 `GroupOrderPreInfoFileDownload` 方法用于下载团组前期信息文件,并调整 `OriginVal` 的处理逻辑,将布尔值转换为中文的“是”或“否”。
LEIYI 1 month ago
parent
commit
cb69c2a289

+ 1 - 1
OASystem/EntitySync/Program.cs

@@ -154,4 +154,4 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     typeof(Grp_OrderPreInfo), //团组下单前信息
     typeof(Grp_OrderPreItem), //团组下单前信息Item
 }); 
-Console.WriteLine("数据库结构同步完成!");
+Console.WriteLine("数据库结构同步完成!");

+ 94 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4,8 +4,10 @@ using Aspose.Words.Drawing;
 using Aspose.Words.Tables;
 using DiffMatchPatch;
 using Microsoft.AspNetCore.SignalR;
+using Microsoft.IdentityModel.Tokens;
 using Microsoft.VisualBasic;
 using MySqlX.XDevAPI.Relational;
+using NetTaste;
 using NPOI.HSSF.UserModel;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
@@ -31,11 +33,13 @@ using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.QiYeWeChat;
+using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Infrastructure.Tools;
 using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Utilities;
 using Quartz.Util;
 using SqlSugar.Extensions;
 using System.Collections;
@@ -44,6 +48,8 @@ using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
 using System.Text.Json;
+using System.Web;
+using System.Xml.Linq;
 using TencentCloud.Ocr.V20181119.Models;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
@@ -420,17 +426,27 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> CityByCountry(string countryLabel)
         {
+
+            countryLabel=HttpUtility.UrlDecode(countryLabel);
             var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
             var citys = Array.Empty<string?>();
             if (countryList.Any())
             {
                 var cityDatas = await _sqlSugar
                     .Queryable<Grp_NationalTravelFee>()
-                    .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City) && !x.City.Contains("城市"))
-                    .Select(x => new { x.Country,x.City })
-                    .OrderBy(x => x.Country)
+                    .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
                     .ToArrayAsync();
-                citys = cityDatas.Select(x => x.City).ToArray();
+
+                foreach (var item in cityDatas)
+                {
+                    if (item.City.Contains("城市"))
+                    {
+                        item.City = item.Country + "-所有城市";
+                    }
+                }
+                var cityDatas1 = cityDatas.OrderBy(x => x.Country);
+
+                citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
             }
             
             return Ok(JsonView(citys));
@@ -461,6 +477,80 @@ namespace OASystem.API.Controllers
             return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
         }
 
+        /// <summary>
+        ///  团组前期信息 文件下载
+        /// </summary>
+        /// <param name="id">Id</param>
+        /// <param name="tempId">Id</param>
+        /// <returns></returns>
+        [HttpGet("{id}/{tempId}")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
+        {
+            var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
+
+            var data = view.Data as GrpOrderPreInfoView;
+
+            #region Excel
+            var tempPath = AppSettingsHelper.Get("ExcelTempPath");
+            var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
+            var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
+            var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
+            var fileNamePrefix = string.Empty;
+
+            if (tempId == 1405)
+            {
+                tempPath += $"无商邀版Temp.xlsx";
+                fileNamePrefix = $"{data.Name}_无商邀版";
+
+            }
+            else if (tempId == 1406)
+            {
+                tempPath += $"有商邀版Temp.xlsx";
+                fileNamePrefix = $"{data.Name}_有商邀版";
+            }
+            else
+            { 
+                //tempId == 1404 默认下载
+                tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
+                fileNamePrefix = $"{data.Name}_单接送机";
+            }
+
+            foreach (var item in data.Items)
+            {
+                var obj = item.NewValue;
+                if (obj is bool || obj is bool?)
+                {
+                    if ((bool)obj == true) item.OriginVal = "是";
+                    else item.OriginVal = "否";
+                }
+            }
+
+            var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
+
+            fileName = CommonFun.ValidFileName(fileName);
+
+            //载入模板
+            WorkbookDesigner designer = new WorkbookDesigner();
+            designer.Workbook = new Workbook(tempPath);
+            designer.SetDataSource("View", data.Items);
+            designer.Process();
+
+            if (!Directory.Exists(savePath))
+            {
+                Directory.CreateDirectory(savePath);
+            }
+
+            string serverPath = $"{savePath}{fileName}";
+            designer.Workbook.Save(serverPath);
+            string rst = $"{servicePath}{ftpPath}{fileName}";
+
+            #endregion
+
+            return Ok(JsonView(new { url = rst }));
+        }
+
+
         #endregion
 
         #region 团组基本信息
@@ -5687,7 +5777,6 @@ FROM
                     peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
                 }
 
-
                 var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
                 var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
                 var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()

+ 2 - 2
OASystem/OASystem.Domain/ViewModels/Groups/OrderPreInfoView.cs

@@ -55,8 +55,8 @@ namespace OASystem.Domain.ViewModels.Groups
                 }
                 else if (FieldTypeName.Equals("单选按钮"))
                 {
-                    if (OriginVal.ToUpper().Equals("TRUE")) return true;
-                    return false;
+                    if (OriginVal.ToUpper().Equals("TRUE")) return "是";
+                    return "否";
                 }
                 return null;
             }