|
@@ -27,6 +27,8 @@ using System.Globalization;
|
|
|
using System.IO.Compression;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using Org.BouncyCastle.Asn1.X509.Qualified;
|
|
|
+using MathNet.Numerics;
|
|
|
+using static OASystem.API.OAMethodLib.JWTHelper;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -46,9 +48,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>
|
|
@@ -85,7 +87,11 @@ namespace OASystem.API.Controllers
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
|
|
|
{
|
|
|
- var result = await _daiRep.GetPagePriceTypeData(dto);
|
|
|
+ var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
|
|
|
+ if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
|
|
|
+
|
|
|
+
|
|
|
+ var result = await _daiRep.GetPagePriceTypeData(dto,currUserInfo.UserId);
|
|
|
|
|
|
if (result == null || result.Code != 0)
|
|
|
{
|
|
@@ -840,6 +846,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 +873,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 +981,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 +1092,6 @@ namespace OASystem.API.Controllers
|
|
|
* 458 公务舱
|
|
|
* 460 经济舱
|
|
|
*/
|
|
|
-
|
|
|
decimal airPrice = 0.00M;
|
|
|
string airName = string.Empty;
|
|
|
if (client.AirType == 457)
|
|
@@ -1077,7 +1111,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 +1160,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 +1210,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 +1260,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 +1346,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元
|
|
@@ -1290,7 +1360,7 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
//MemoryStream outSteam = new MemoryStream();
|
|
|
- string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key.Replace("\n", "")}.docx";
|
|
|
+ string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key.Replace("\n", "")}_{_DelegationInfo.VisitCountry.Replace("|","、")}.docx";
|
|
|
//去水印
|
|
|
new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
|
|
|
doc.Save(filsPath);
|
|
@@ -1329,6 +1399,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开始
|
|
@@ -4266,7 +4375,7 @@ Group by PriceType ", dto.diId);
|
|
|
#region 信用卡对账
|
|
|
|
|
|
/// <summary>
|
|
|
- ///将指定的Excel的文件转换成DataTable (Excel的第一个sheet)
|
|
|
+ ///将指定的Excel的文件转换成DataTable(Excel的第一个sheet)
|
|
|
/// </summary>
|
|
|
/// <param name="fullFielPath">文件的绝对路径</param>
|
|
|
/// <returns></returns>
|
|
@@ -4430,11 +4539,13 @@ Group by PriceType ", dto.diId);
|
|
|
|
|
|
//读取ExcelFile
|
|
|
DataTable dt = ExcelFileToDataTable(file);
|
|
|
- dt.TableName = "TB";
|
|
|
+
|
|
|
if (dt == null)
|
|
|
{
|
|
|
return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
|
|
|
}
|
|
|
+
|
|
|
+ dt.TableName = "TB";
|
|
|
//信用卡信息
|
|
|
string sql = string.Format($"Select * From Grp_CreditCardPayment Where Isdel = 0 And CTDId = {cardType} And ConsumptionDate between '{beginDt}' and '{endDt}' ");
|
|
|
var List_ccp = await _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql).ToListAsync();
|
|
@@ -4537,8 +4648,6 @@ Group by PriceType ", dto.diId);
|
|
|
dt.AcceptChanges(); //提交
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
{
|
|
|
#region 匹配的金额
|
|
@@ -5057,7 +5166,7 @@ Group by PriceType ", dto.diId);
|
|
|
/// <param name="sheetName">工作表名</param>
|
|
|
/// <param name="tbContainer">将数据存入的DataTable</param>
|
|
|
/// <returns></returns>
|
|
|
- public static DataTable ExcelToDataTable(string pathName, string sheetName)
|
|
|
+ public static DataTable ExcelToDataTable(string pathName, string sheetName="")
|
|
|
{
|
|
|
DataTable tbContainer = new DataTable();
|
|
|
string strConn = string.Empty;
|