|
@@ -15456,8 +15456,8 @@ FROM
|
|
|
{
|
|
{
|
|
|
Workbook = new Workbook(tempPath)
|
|
Workbook = new Workbook(tempPath)
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
- var worksheet = designer.Workbook.Worksheets[0];
|
|
|
|
|
|
|
+ Workbook workbook = designer.Workbook;
|
|
|
|
|
+ var worksheet = workbook.Worksheets[0];
|
|
|
|
|
|
|
|
// 日期格式化
|
|
// 日期格式化
|
|
|
var dateFormat = "yyyy年MM月dd日";
|
|
var dateFormat = "yyyy年MM月dd日";
|
|
@@ -15483,27 +15483,92 @@ FROM
|
|
|
// 数据整理
|
|
// 数据整理
|
|
|
// 住宿费
|
|
// 住宿费
|
|
|
var accomFees = dac1.GroupBy(x => x.NationalTravelFeeId)
|
|
var accomFees = dac1.GroupBy(x => x.NationalTravelFeeId)
|
|
|
- .Select(group => new
|
|
|
|
|
- {
|
|
|
|
|
- TravelFeeId = group.Key,
|
|
|
|
|
- TotalDays = group.Count(),
|
|
|
|
|
- group.First().Cost,
|
|
|
|
|
- TotalAmount = group.Sum(x => x.Cost),
|
|
|
|
|
- group.First().Currency,
|
|
|
|
|
- Details = group.ToList()
|
|
|
|
|
|
|
+ .Select(group =>
|
|
|
|
|
+ {
|
|
|
|
|
+ var currData = group.FirstOrDefault();
|
|
|
|
|
+
|
|
|
|
|
+ // 币种信息
|
|
|
|
|
+ var currencyInfo = _CurrDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
|
|
|
|
|
+ // 币种名称
|
|
|
|
|
+ string currencyName = currencyInfo?.Remark ?? "";
|
|
|
|
|
+ // 币种Code
|
|
|
|
|
+ string currencyCode = currencyInfo?.Name ?? "";
|
|
|
|
|
+ // 币种汇率信息
|
|
|
|
|
+ var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
|
|
|
|
|
+ // 币种汇率
|
|
|
|
|
+ decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
|
|
|
|
|
+
|
|
|
|
|
+ // 城市信息 Grp_NationalTravelFee
|
|
|
|
|
+ var placeName = GetEnterExitCostExportCity(placeData, group.Key);
|
|
|
|
|
+
|
|
|
|
|
+ // 天数
|
|
|
|
|
+ int totalDays = group.Count();
|
|
|
|
|
+
|
|
|
|
|
+ // 原始币种小计
|
|
|
|
|
+ decimal totalAmount = group.Sum(x => x.Cost);
|
|
|
|
|
+
|
|
|
|
|
+ // 人名币金额
|
|
|
|
|
+ decimal totalCNY = totalDays * totalAmount * currencyRate;
|
|
|
|
|
+
|
|
|
|
|
+ return new {
|
|
|
|
|
+ TravelFeeId = group.Key,
|
|
|
|
|
+ PlaceName = placeName,
|
|
|
|
|
+ TotalDays = totalDays,
|
|
|
|
|
+ currData.Cost,
|
|
|
|
|
+ TotalAmount = totalAmount,
|
|
|
|
|
+ currData.Currency,
|
|
|
|
|
+ CurrencyCode = currencyCode,
|
|
|
|
|
+ CurrencyName = currencyName,
|
|
|
|
|
+ CurrencyRate = currencyRate,
|
|
|
|
|
+ TotalCNY = totalCNY,
|
|
|
|
|
+ Details = group.ToList()
|
|
|
|
|
+ };
|
|
|
})
|
|
})
|
|
|
.ToList();
|
|
.ToList();
|
|
|
// 伙食费和公杂费
|
|
// 伙食费和公杂费
|
|
|
var foodSundCosts = _DayAndCosts.Where(x => x.Type == 2 || x.Type == 3)
|
|
var foodSundCosts = _DayAndCosts.Where(x => x.Type == 2 || x.Type == 3)
|
|
|
.GroupBy(x => x.NationalTravelFeeId)
|
|
.GroupBy(x => x.NationalTravelFeeId)
|
|
|
- .Select(group => new
|
|
|
|
|
- {
|
|
|
|
|
- TravelFeeId = group.Key,
|
|
|
|
|
- TotalDays = group.Count(),
|
|
|
|
|
- Cost = group.Sum(x => x.Cost) / group.Count() / 2,
|
|
|
|
|
- TotalAmount = group.Sum(x => x.Cost),
|
|
|
|
|
- group.First().Currency,
|
|
|
|
|
- Details = group.ToList()
|
|
|
|
|
|
|
+ .Select(group =>
|
|
|
|
|
+ {
|
|
|
|
|
+ var currData = group.FirstOrDefault();
|
|
|
|
|
+
|
|
|
|
|
+ // 币种信息
|
|
|
|
|
+ var currencyInfo = _CurrDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
|
|
|
|
|
+ // 币种名称
|
|
|
|
|
+ string currencyName = currencyInfo?.Remark ?? "";
|
|
|
|
|
+ // 币种Code
|
|
|
|
|
+ string currencyCode = currencyInfo?.Name ?? "";
|
|
|
|
|
+ // 币种汇率信息
|
|
|
|
|
+ var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
|
|
|
|
|
+ // 币种汇率
|
|
|
|
|
+ decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
|
|
|
|
|
+
|
|
|
|
|
+ // 城市信息 Grp_NationalTravelFee
|
|
|
|
|
+ var placeName = GetEnterExitCostExportCity(placeData, group.Key);
|
|
|
|
|
+
|
|
|
|
|
+ // 天数
|
|
|
|
|
+ int totalDays = group.Count() / 2;
|
|
|
|
|
+
|
|
|
|
|
+ // 原始币种小计
|
|
|
|
|
+ decimal totalAmount = group.Sum(x => x.Cost);
|
|
|
|
|
+
|
|
|
|
|
+ // 人名币金额
|
|
|
|
|
+ decimal totalCNY = totalDays * totalAmount * currencyRate;
|
|
|
|
|
+
|
|
|
|
|
+ return new
|
|
|
|
|
+ {
|
|
|
|
|
+ TravelFeeId = group.Key,
|
|
|
|
|
+ PlaceName = placeName,
|
|
|
|
|
+ TotalDays = totalDays,
|
|
|
|
|
+ currData.Cost,
|
|
|
|
|
+ TotalAmount = totalAmount,
|
|
|
|
|
+ currData.Currency,
|
|
|
|
|
+ CurrencyCode = currencyCode,
|
|
|
|
|
+ CurrencyName = currencyName,
|
|
|
|
|
+ CurrencyRate = currencyRate,
|
|
|
|
|
+ TotalCNY = totalCNY,
|
|
|
|
|
+ Details = group.ToList()
|
|
|
|
|
+ };
|
|
|
})
|
|
})
|
|
|
.ToList();
|
|
.ToList();
|
|
|
|
|
|
|
@@ -15558,112 +15623,81 @@ FROM
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
- designer.SetDataSource("TotalOtherFeeLabel", string.Join(";", otherFeestrs));
|
|
|
|
|
|
|
+ designer.SetDataSource("TotalOtherFeeLabel", $"5.其他费用({string.Join(";", otherFeestrs)})");
|
|
|
designer.SetDataSource("TotalOtherFee", $"{totalOtherFee:0.00}");
|
|
designer.SetDataSource("TotalOtherFee", $"{totalOtherFee:0.00}");
|
|
|
|
|
|
|
|
// 住宿费、伙食费和公杂费合计
|
|
// 住宿费、伙食费和公杂费合计
|
|
|
- //decimal grandTotalFee = foodSundCosts.Sum(x => )
|
|
|
|
|
-
|
|
|
|
|
- //decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
|
|
|
|
|
- //decimal s = dac1totalPrice + dac2totalPrice + totalAirJJC + totalOtherFee;
|
|
|
|
|
-
|
|
|
|
|
- //decimal pxFee = dac4.Sum(it => it.Cost);
|
|
|
|
|
- //decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
|
|
|
|
|
- //string celllastStr1 = "";
|
|
|
|
|
- //if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
|
|
|
|
|
- //if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
|
|
|
|
|
- //if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
|
|
|
|
|
- //celllastStr1 += $",国际旅费 元";
|
|
|
|
|
- //if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
|
|
|
|
|
|
|
+ decimal grandTotalFee = foodSundCosts.Sum(x => x.TotalCNY) + foodSundCosts.Sum(x => x.TotalCNY);
|
|
|
|
|
|
|
|
- //string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
|
|
|
|
|
|
|
+ //其他费用合计
|
|
|
|
|
+ decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
|
|
|
|
|
+ decimal totalPrice = grandTotalFee + totalAirJJC + totalOtherFee;
|
|
|
|
|
|
|
|
- //designer.SetDataSource("cell4Str", cell4Str);
|
|
|
|
|
- //designer.SetDataSource("cellStr", cellStr);
|
|
|
|
|
- //designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
|
|
|
|
|
- //designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
|
|
|
|
|
- //designer.SetDataSource("celllastStr", celllastStr);
|
|
|
|
|
|
|
+ designer.SetDataSource("TotalFeeLabel", $"大写 :{CommonFun.ToChinese(totalPrice)}"); // 合计金额中文大写
|
|
|
|
|
+ designer.SetDataSource("TotalFee", $"{totalPrice:0.00}"); // 合计金额
|
|
|
|
|
+ designer.SetDataSource("ActualAmount ", $"{totalPrice:0.00}元"); // 合计金额
|
|
|
|
|
|
|
|
- //模板文件名
|
|
|
|
|
- string strFileName = $"{_DelegationInfo.TeamName}-省级单位出国经费报销单{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
|
|
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
|
|
|
|
+ designer.Process();
|
|
|
|
|
|
|
|
#region 设置 住宿费、伙食费和公杂显示值
|
|
#region 设置 住宿费、伙食费和公杂显示值
|
|
|
// 开始行
|
|
// 开始行
|
|
|
- int startRow = 7;
|
|
|
|
|
|
|
+ int startRow = 8;
|
|
|
// 开始列
|
|
// 开始列
|
|
|
int startColumn = 1;
|
|
int startColumn = 1;
|
|
|
|
|
+ // 数据展示默认行 含小计行
|
|
|
|
|
+ int defualtRow = 4;
|
|
|
|
|
|
|
|
// 设置住宿费
|
|
// 设置住宿费
|
|
|
- for (int i = 0; i < foodSundCosts.Count; i++)
|
|
|
|
|
|
|
+ for (int i = 0; i < accomFees.Count; i++)
|
|
|
{
|
|
{
|
|
|
- var currData = foodSundCosts[i];
|
|
|
|
|
-
|
|
|
|
|
- // 币种信息
|
|
|
|
|
- var currencyInfo = _CurrDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
|
|
|
|
|
- // 币种名称
|
|
|
|
|
- string currencyName = currencyInfo?.Remark;
|
|
|
|
|
- // 币种Code
|
|
|
|
|
- string currencyCode = currencyInfo?.Name;
|
|
|
|
|
- // 币种汇率信息
|
|
|
|
|
- var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
|
|
|
|
|
- // 币种汇率
|
|
|
|
|
- decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
|
|
|
|
|
-
|
|
|
|
|
- // 城市信息 Grp_NationalTravelFee
|
|
|
|
|
- var placeName = GetEnterExitCostExportCity(placeData, currData.TravelFeeId);
|
|
|
|
|
-
|
|
|
|
|
- decimal totalCNY = currData.TotalDays * currData.TotalAmount * currencyRate;
|
|
|
|
|
- startRow += i;
|
|
|
|
|
|
|
+ var currData = accomFees[i];
|
|
|
|
|
+ int startRow1 = startRow + i;
|
|
|
|
|
|
|
|
// 插入数据到对应列
|
|
// 插入数据到对应列
|
|
|
- worksheet.Cells[startRow, startColumn].PutValue(placeName); // 国家(地区)/城市
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 1].PutValue(currencyName); // 币种
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 2].PutValue($"{currData.Cost:0.00}"); // 标准
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 3].PutValue("1"); // 人数
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 4].PutValue(currData.TotalDays); // 天数
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 5].PutValue($"{currData.TotalAmount:0.00}");// 小计
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 6].PutValue($"{currencyRate:0.0000}"); // 汇率
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 7].PutValue($"{totalCNY:0.00}"); // 折合人民币(元)
|
|
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn].PutValue(currData.PlaceName); // 国家(地区)/城市
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 1].PutValue(currData.CurrencyName); // 币种
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 2].PutValue($"{currData.Cost:0.00}"); // 标准
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 3].PutValue("1"); // 人数
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 4].PutValue(currData.TotalDays); // 天数
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 5].PutValue($"{currData.TotalAmount:0.00}"); // 小计
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 6].PutValue($"{currData.CurrencyRate:0.0000}"); // 汇率
|
|
|
|
|
+ worksheet.Cells[startRow1, startColumn + 7].PutValue($"{currData.TotalCNY:0.00}"); // 折合人民币(元)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //设置小计行 合计金额 固定单元格
|
|
|
|
|
+ worksheet.Cells[11, startColumn + 7].PutValue($"{accomFees.Sum(x => x.TotalCNY):0.00}"); // 折合人民币(元)
|
|
|
|
|
+
|
|
|
// 新增小计行
|
|
// 新增小计行
|
|
|
- startRow += 1;
|
|
|
|
|
|
|
+ if (accomFees.Count == (defualtRow - 1)) startRow += 1;
|
|
|
|
|
+ else startRow += defualtRow;
|
|
|
|
|
|
|
|
// 设置伙食费和公杂费行
|
|
// 设置伙食费和公杂费行
|
|
|
- for (int i = 0; i < accomFees.Count; i++)
|
|
|
|
|
|
|
+ for (int i = 0; i < foodSundCosts.Count; i++)
|
|
|
{
|
|
{
|
|
|
- var currData = accomFees[i];
|
|
|
|
|
-
|
|
|
|
|
- // 币种信息
|
|
|
|
|
- var currencyInfo = _CurrDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
|
|
|
|
|
- // 币种名称
|
|
|
|
|
- string currencyName = currencyInfo?.Remark;
|
|
|
|
|
- // 币种Code
|
|
|
|
|
- string currencyCode = currencyInfo?.Name;
|
|
|
|
|
- // 币种汇率信息
|
|
|
|
|
- var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
|
|
|
|
|
- // 币种汇率
|
|
|
|
|
- decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
|
|
|
|
|
-
|
|
|
|
|
- // 城市信息 Grp_NationalTravelFee
|
|
|
|
|
- var placeName = GetEnterExitCostExportCity(placeData, currData.TravelFeeId);
|
|
|
|
|
-
|
|
|
|
|
- decimal totalCNY = currData.TotalDays * currData.TotalAmount * currencyRate;
|
|
|
|
|
- startRow += i;
|
|
|
|
|
|
|
+ var currData = foodSundCosts[i];
|
|
|
|
|
+ int startRow2 = startRow + i;
|
|
|
|
|
|
|
|
// 插入数据到对应列
|
|
// 插入数据到对应列
|
|
|
- worksheet.Cells[startRow, startColumn].PutValue(placeName); // 国家(地区)/城市
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 1].PutValue(currencyName); // 币种
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 2].PutValue($"{currData.Cost:0.00}"); // 标准
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 3].PutValue("1"); // 人数
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 4].PutValue(currData.TotalDays); // 天数
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 5].PutValue($"{currData.TotalAmount:0.00}");// 小计
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 6].PutValue($"{currencyRate:0.0000}"); // 汇率
|
|
|
|
|
- worksheet.Cells[startRow, startColumn + 7].PutValue($"{totalCNY:0.00}"); // 折合人民币(元)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn].PutValue(currData.PlaceName); // 国家(地区)/城市
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 1].PutValue(currData.CurrencyName); // 币种
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 2].PutValue($"{currData.Cost:0.00}"); // 标准
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 3].PutValue("1"); // 人数
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 4].PutValue(currData.TotalDays); // 天数
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 5].PutValue($"{currData.TotalAmount:0.00}"); // 小计
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 6].PutValue($"{currData.CurrencyRate:0.0000}"); // 汇率
|
|
|
|
|
+ worksheet.Cells[startRow2, startColumn + 7].PutValue($"{currData.TotalCNY:0.00}"); // 折合人民币(元)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //设置小计行 合计金额 固定单元格
|
|
|
|
|
+ worksheet.Cells[11, startColumn + 7].PutValue($"{accomFees.Sum(x => x.TotalCNY):0.00}"); // 折合人民币(元)
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
+ workbook.CalculateFormula(true);
|
|
|
|
|
+
|
|
|
|
|
+ //模板文件名
|
|
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}-省级单位出国经费报销单{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
|
|
+
|
|
|
string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
|
|
if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
|
|
|
else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
|
|
else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
|