Browse Source

已收账单 --> 汇款通知 更改 汇率数据源

LEIYI 4 months ago
parent
commit
21727d4099

+ 113 - 9
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -27,6 +27,7 @@ using System.Globalization;
 using System.IO.Compression;
 using NPOI.SS.Formula.Functions;
 using Org.BouncyCastle.Asn1.X509.Qualified;
+using MathNet.Numerics;
 
 namespace OASystem.API.Controllers
 {
@@ -46,9 +47,9 @@ namespace OASystem.API.Controllers
         private readonly DailyFeePaymentRepository _daiRep;    //日付申请仓库
         private readonly TeamRateRepository _teamRateRep;      //团组汇率仓库
         private readonly ForeignReceivablesRepository _ForForeignReceivablesRep;  //对外收款账单仓库
-        private readonly ProceedsReceivedRepository _proceedsReceivedRep;  //已收款项仓库
+        private readonly ProceedsReceivedRepository _proceedsReceivedRep;         //已收款项仓库
         private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
-        private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
+        private readonly DelegationInfoRepository _delegationInfoRep;             //团组信息 仓库
         private readonly ForeignReceivablesRepository _foreignReceivablesRepository;
 
         /// <summary>
@@ -840,6 +841,13 @@ namespace OASystem.API.Controllers
             ));
         }
 
+        private class EnterExitCostCurrency 
+        {
+            public string Name { get; set; }
+            public string Code { get; set; }
+            public decimal Rate { get; set; }
+        }
+
         /// <summary>
         /// 已收账单 
         /// File Downloasd
@@ -860,7 +868,7 @@ namespace OASystem.API.Controllers
                 {
                     return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川)  2 生成收款单(北京)  3 汇款账单"));
                 }
-
+                var _currencyDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
                 var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
                 if (_DelegationInfo == null)
                 {
@@ -968,6 +976,28 @@ namespace OASystem.API.Controllers
                         return Ok(JsonView(false, "该团组未填写出入境费用;"));
                     }
 
+                    var _EnterExitCostCurrencys = new List<EnterExitCostCurrency>();
+
+                    if (!string.IsNullOrEmpty(_EnterExitCosts.CurrencyRemark))
+                    { 
+                        var currency1 = _EnterExitCosts.CurrencyRemark.Split("|");
+                        foreach (var item in currency1)
+                        {
+                            var currency2 = item.Split(":");
+                            var currency3 = currency2[0].Split("(");
+                            var currencyName = currency3[0].ToString();
+                            var currencyCode = currency3[1].Split(")")[0].ToString();
+
+                            _EnterExitCostCurrencys.Add(new EnterExitCostCurrency
+                            {
+                                Name = currencyName,
+                                Code = currencyCode,
+                                Rate = Convert.ToDecimal(currency2[1] ?? "0")
+                            });
+
+                        }
+                    }
+
                     var _cityFee = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
 
                     foreach (var item in _DayAndCosts)
@@ -1057,7 +1087,6 @@ namespace OASystem.API.Controllers
                              *  458	公务舱
                              *  460	经济舱
                              */
-
                             decimal airPrice = 0.00M;
                             string airName = string.Empty;
                             if (client.AirType == 457)
@@ -1077,7 +1106,6 @@ namespace OASystem.API.Controllers
                             }
 
                             //计算费用总和
-
                             decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
                                                dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
                                                +_EnterExitCosts.YiMiao + _EnterExitCosts.YiMiao + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
@@ -1127,7 +1155,20 @@ namespace OASystem.API.Controllers
 
                                     string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
                                     SetCells(ChildTable, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/晚");
-                                    SetCells(ChildTable, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
+
+                                    var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
+                                    var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
+                                    if (sys_currencyInfo != null)
+                                    {
+                                        var sys_currencyCode = sys_currencyInfo.Name;
+                                        var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
+                                        if (eec_currencyInfo != null)
+                                        {
+                                            currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
+                                        }
+                                    }
+
+                                    SetCells(ChildTable, doc, rowIndex, 3, "汇率" + currencyRate);
                                     SetCells(ChildTable, doc, rowIndex, 4, "CNY " + item.SubTotal + "\r\n");
                                     rowIndex++;
                                     zsinfo += item.Place + "  " + days + "晚 " + item.Cost.ToString("#0.00") + currencyCode + "/晚" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + "   CNY " + item.SubTotal * days + "\r\n";
@@ -1164,7 +1205,20 @@ namespace OASystem.API.Controllers
 
                                     string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
                                     SetCells(ChildTable1, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
-                                    SetCells(ChildTable1, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
+
+                                    var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
+                                    var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
+                                    if (sys_currencyInfo != null)
+                                    {
+                                        var sys_currencyCode = sys_currencyInfo.Name;
+                                        var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
+                                        if (eec_currencyInfo != null)
+                                        {
+                                            currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
+                                        }
+                                    }
+
+                                    SetCells(ChildTable1, doc, rowIndex, 3, "汇率" + currencyRate);
                                     SetCells(ChildTable1, doc, rowIndex, 4, "CNY " + item.SubTotal);
                                     rowIndex++;
                                     hsinfo += item.Place + "  " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + "   CNY " + item.SubTotal * days + "\r\n";
@@ -1201,7 +1255,19 @@ namespace OASystem.API.Controllers
 
                                     string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
                                     SetCells(ChildTable2, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
-                                    SetCells(ChildTable2, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
+
+                                    var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
+                                    var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
+                                    if (sys_currencyInfo != null)
+                                    {
+                                        var sys_currencyCode = sys_currencyInfo.Name;
+                                        var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
+                                        if (eec_currencyInfo != null)
+                                        {
+                                            currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
+                                        }
+                                    }
+                                    SetCells(ChildTable2, doc, rowIndex, 3, "汇率" + currencyRate);
                                     SetCells(ChildTable2, doc, rowIndex, 4, "CNY " + item.SubTotal + "\r\n");
                                     rowIndex++;
                                     gzinfo += item.Place + "  " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + "   CNY " + item.SubTotal * days + "\r\n";
@@ -1275,7 +1341,6 @@ namespace OASystem.API.Controllers
                             TeableBookmarkArr.Clear();
                         }
 
-
                         bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
                         bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
                         bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用  付辰同志出访费用为¥73,604.8元
@@ -1329,6 +1394,45 @@ namespace OASystem.API.Controllers
             }
         }
 
+         /// <summary>
+         /// decimal保留指定位数小数
+         /// </summary>
+         /// <param name="num">原始数量</param>
+         /// <param name="scale">保留小数位数</param>
+         /// <returns>截取指定小数位数后的数量字符串</returns>
+         private static string DecimalToString(decimal num, int scale)
+         {
+             string numToString = num.ToString();
+
+             int index = numToString.IndexOf(".");
+             int length = numToString.Length;
+
+             if (index != -1)
+             {
+                 return string.Format("{0}.{1}",
+                     numToString.Substring(0, index),
+                     numToString.Substring(index + 1, Math.Min(length - index - 1, scale)));
+             }
+             else
+             {
+                 return num.ToString();
+             }
+         }
+
+        /// <summary>
+        /// 保留小数位数
+        /// </summary>
+        /// <param name="n">待处理的值</param>
+        /// <param name="d">保留位数</param>
+        /// <param name="isEnter">是否四舍五入</param>
+        /// <returns></returns>
+        private static decimal Round(decimal n, int d, bool isEnter = false)
+        {
+            if (isEnter)
+                return decimal.Round(n, d, MidpointRounding.AwayFromZero);
+            return Math.Truncate(n * (decimal)Math.Pow(10, d)) / (decimal)Math.Pow(10, d);
+        }
+
         private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
         {
             //获取table中的某个单元格,从0开始

+ 137 - 6
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -43,6 +43,7 @@ using System.IO.Compression;
 using System.Net.Http;
 using System.Reflection.PortableExecutable;
 using Ubiety.Dns.Core;
+using static NPOI.POIFS.Crypt.CryptoFunctions;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
 using Bookmark = Aspose.Words.Bookmark;
@@ -15626,23 +15627,153 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        [HttpDelete("{diId}")]
+        [HttpGet("{diId}")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OpinionaireUserList(int diId)
         {
             if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
 
-            var data = await _opinionaireRep.Query(x => x.DiId == diId)
-                .Select(x => new {
-                
-                })
-                .ToListAsync();
 
+            var sql = string.Format(@"
+SELECT
+  o.Id,
+  o.DiId,
+  di.TeamName AS 'GroupName',
+  di.VisitPNumber AS 'PeopleNumber',
+  di.ClientName AS 'LeadGroup',
+  di.VisitCountry AS 'Travel',
+  di.VisitDays AS 'Days',
+  o.CityName,
+  o.TourGuideName,
+  o.Catering,
+  o.CateringReason,
+  o.Stay,
+  o.StayReason,
+  o.[Route],
+  o.RouteReason,
+  o.OfficialActivity,
+  o.OfficialActivityReason,
+  o.TourGuide,
+  o.TourGuideReason,
+  o.[Translate],
+  o.TranslateReason,
+  o.Trip,
+  o.TripReason,
+  o.ESFileName,
+  o.SignatureDate,
+  o.Remark
+FROM
+  Grp_Opinionaire o
+  LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
+WHERE
+  o.IsDel = 0
+  AND o.DiId = {0}
+ORDER BY
+  o.Id ASC", diId);
+
+            var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
+
+            if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
 
             return Ok(JsonView(data));
         }
 
+        /// <summary>
+        /// 团组接待意见调查 - 用户
+        /// 保存
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OpinionaireUserSave(OpinionaireUserSaveInfo[] dto)
+        {
+            if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
+
+            foreach (var item in dto)
+            {
+                if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
+                if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
+                if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
+                if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
+                if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
+                if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
+                if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
+                if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
+            }
+
+            var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
+            if (!Directory.Exists(filePathBase))
+            {
+                Directory.CreateDirectory(filePathBase);
+            }
+
+            #region 上传文件
+
+            var filePaths = new List<string>();
+            foreach (var item in dto)
+            {
+                var file = item.File;
+
+                // 将文件保存到指定位置
+                var filePath = Path.Combine(filePathBase, file.FileName);
+                using (var stream = new FileStream(filePath, FileMode.Create))
+                {
+                    await file.CopyToAsync(stream);
+                }
+
+                //验证文件是否上传成功
+                if (!System.IO.File.Exists(filePath))
+                {
+                    foreach (var filePathStr in filePaths)
+                    {
+                        System.IO.File.Delete(filePathStr);
+                    }
+                    return Ok(JsonView(false, "文件上传失败!"));
+                }
+                item.ESFileName = file.FileName;
+            }
+
+            #endregion
+
+            var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
+
+            var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
+                .UpdateColumns(x => new
+                {
+                    x.Catering,
+                    x.CateringReason,
+                    x.Stay,
+                    x.StayReason,
+                    x.Route,
+                    x.RouteReason,
+                    x.OfficialActivity,
+                    x.OfficialActivityReason,
+                    x.TourGuide,
+                    x.TourGuideReason,
+                    x.Translate,
+                    x.TranslateReason,
+                    x.Trip,
+                    x.TripReason,
+                    x.ESFileName,
+                    x.SignatureDate,
+                    x.Remark
+                })
+                .WhereColumns(x => new { x.Id })
+                .ExecuteCommandAsync();
+
+            if (upd < 1)
+            {
+                foreach (var filePathStr in filePaths)
+                {
+                    System.IO.File.Delete(filePathStr);
+                }
+                return Ok(JsonView(false));
+            }
+
 
+            return Ok(JsonView(true));
+        }
 
         #endregion
 

+ 2 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -175,6 +175,8 @@ namespace OASystem.Domain.AutoMappers
 
             #region  团组接待意见调查
             CreateMap<OpinionaireManageInfo, Grp_Opinionaire>();
+            CreateMap<Grp_Opinionaire, OpinionaireUserListView>();
+            CreateMap<OpinionaireUserSaveInfo, Grp_Opinionaire>();
             #endregion
             #endregion
 

+ 14 - 1
OASystem/OASystem.Domain/Dtos/Groups/OpinionaireDto.cs

@@ -1,4 +1,6 @@
-using System;
+using Microsoft.AspNetCore.Http;
+using OASystem.Domain.ViewModels.Groups;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -27,4 +29,15 @@ namespace OASystem.Domain.Dtos.Groups
         public string TourGuideName { get; set; }
         public string CityName { get; set; }
     }
+
+
+    public class OpinionaireUserSaveInfo : OpinionaireUser_Content
+    {
+        public IFormFile File { get; set; }
+    }
+
+    public class OpinionaireUserSaveDto
+    {
+        public OpinionaireUserSaveInfo[] Items { get; set; }
+    }
 }

+ 136 - 0
OASystem/OASystem.Domain/ViewModels/Groups/OpinionaireView.cs

@@ -13,4 +13,140 @@ namespace OASystem.Domain.ViewModels.Groups
     public class OpinionaireView:Grp_Opinionaire
     {
     }
+
+
+    public class OpinionaireUser_Content
+    {
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 餐饮评分(A、B、C、D)
+        /// </summary>
+        public string? Catering { get; set; }
+
+        /// <summary>
+        /// 餐饮评分-原因(餐饮==C||D 有值)
+        /// </summary>
+        public string? CateringReason { get; set; }
+
+        /// <summary>
+        /// 住宿评分(A、B、C、D)
+        /// </summary>
+        public string? Stay { get; set; }
+
+        /// <summary>
+        /// 住宿评分-原因(住宿==C||D 有值)
+        /// </summary>
+        public string? StayReason { get; set; }
+
+        /// <summary>
+        /// 行程评分(A、B、C、D)
+        /// </summary>
+        public string? Route { get; set; }
+
+        /// <summary>
+        /// 行程评分-原因(行程==C||D 有值)
+        /// </summary>
+        public string? RouteReason { get; set; }
+
+        /// <summary>
+        /// 公务活动评分(A、B、C、D)
+        /// </summary>
+        public string? OfficialActivity { get; set; }
+
+        /// <summary>
+        /// 公务活动评分-原因(行程==C||D 有值)
+        /// </summary>
+        public string? OfficialActivityReason { get; set; }
+
+        /// <summary>
+        /// 导游评分(A、B、C、D)
+        /// </summary>
+        public string? TourGuide { get; set; }
+
+        /// <summary>
+        /// 导游评分-原因(行程==C||D 有值)
+        /// </summary>
+        public string? TourGuideReason { get; set; }
+
+        /// <summary>
+        /// 翻译评分(A、B、C、D)
+        /// </summary>
+        public string? Translate { get; set; }
+
+        /// <summary>
+        /// 翻译评分-原因(行程==C||D 有值)
+        /// </summary>
+        public string? TranslateReason { get; set; }
+
+        /// <summary>
+        /// 出行评分(A、B、C、D)
+        /// </summary>
+        public string? Trip { get; set; }
+
+        /// <summary>
+        /// 出行评分-原因(行程==C||D 有值)
+        /// </summary>
+        public string? TripReason { get; set; }
+
+        /// <summary>
+        /// 电子签名文件名称
+        /// </summary>
+        public string? ESFileName { get; set; }
+
+        /// <summary>
+        /// 签名日期(2024-10-08 15:00:00)
+        /// </summary>
+        public string? SignatureDate { get; set; }
+
+        public string Remark { get; set; }
+    }
+
+
+    public class OpinionaireUserListView: OpinionaireUser_Content
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// 团组名称
+        /// </summary>
+        public string GroupName { get; set; }
+
+        /// <summary>
+        /// 人数
+        /// </summary>
+        public int PeopleNumber { get; set; }
+
+        /// <summary>
+        /// 领队
+        /// </summary>
+        public string LeadGroup { get; set; }
+
+        /// <summary>
+        /// 行程
+        /// </summary>
+        public string Travel { get; set; }
+
+        /// <summary>
+        /// 天数
+        /// </summary>
+        public int Days { get; set; }
+
+        /// <summary>
+        /// 城市名称
+        /// </summary>
+        public string? CityName { get; set; }
+
+        /// <summary>
+        /// 导游名称
+        /// </summary>
+        public string? TourGuideName { get; set; }
+    }
+
 }