|
@@ -74,6 +74,17 @@ using NPOI.XSSF.Model;
|
|
using NetTaste;
|
|
using NetTaste;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using EyeSoft.Collections.Generic;
|
|
using EyeSoft.Collections.Generic;
|
|
|
|
+using NPOI.HSSF.Util;
|
|
|
|
+using NPOI.HSSF.UserModel;
|
|
|
|
+using NPOI.SS.UserModel;
|
|
|
|
+using NPOI.XSSF.UserModel;
|
|
|
|
+using MySqlX.XDevAPI.Relational;
|
|
|
|
+using SqlSugar.Extensions;
|
|
|
|
+using Table = Aspose.Words.Tables.Table;
|
|
|
|
+using Aspose.Cells.Tables;
|
|
|
|
+using NPOI.SS.Util;
|
|
|
|
+using RestSharp.Extensions;
|
|
|
|
+using Microsoft.AspNetCore.WebUtilities;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
namespace OASystem.API.Controllers
|
|
{
|
|
{
|
|
@@ -5806,6 +5817,521 @@ namespace OASystem.API.Controllers
|
|
return Ok(jw);
|
|
return Ok(jw);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 导出地接费用明细
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost]
|
|
|
|
+ public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
|
|
|
|
+ {
|
|
|
|
+ var jw = JsonView(false);
|
|
|
|
+ if (dto.Diid < 1)
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "请输入正确的diid!";
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
|
|
|
|
+ if (group == null)
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "未找到团组信息!";
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
|
|
|
|
+ if (localGuideArr.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "该团组暂无地接信息!";
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
|
|
|
|
+
|
|
|
|
+ var overspendSoure = new Dictionary<int, int>
|
|
|
|
+ {
|
|
|
|
+ { 91, 982 }, //车
|
|
|
|
+ { 92 , 1059} ,//导游
|
|
|
|
+ { 994 , 1073}, //翻译
|
|
|
|
+ { 988 , 1074 }, //早餐
|
|
|
|
+ { 93 , 1075 }, //午餐
|
|
|
|
+ { 989 , 1076 }, //晚餐
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
|
|
|
|
+
|
|
|
|
+ foreach (var groupArr in localGroup)
|
|
|
|
+ {
|
|
|
|
+ var keyValue = groupArr.Key;
|
|
|
|
+ if (int.TryParse(keyValue, out int cityid))
|
|
|
|
+ {
|
|
|
|
+ var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
|
|
|
|
+ keyValue = city == null ? keyValue : city.Country + "-" + city.City;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
|
|
|
|
+
|
|
|
|
+ foreach (var item in groupArr)
|
|
|
|
+ {
|
|
|
|
+ var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a,b)=> a.SId == b.Id
|
|
|
|
+ ).Where((a,b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a,b)=>
|
|
|
|
+ new Grp_CarTouristGuideGroundReservationsContentExtend
|
|
|
|
+ {
|
|
|
|
+ Count = a.Count,
|
|
|
|
+ CreateTime = a.CreateTime,
|
|
|
|
+ CreateUserId = a.CreateUserId,
|
|
|
|
+ CTGGRId = a.CTGGRId,
|
|
|
|
+ Currency = a.Currency,
|
|
|
|
+ DatePrice = a.DatePrice,
|
|
|
|
+ DeleteTime = a.DeleteTime,
|
|
|
|
+ DeleteUserId = a.DeleteUserId,
|
|
|
|
+ DiId = a.DiId,
|
|
|
|
+ Id = a.Id,
|
|
|
|
+ IsDel = a.IsDel,
|
|
|
|
+ Price = a.Price,
|
|
|
|
+ PriceContent = a.PriceContent,
|
|
|
|
+ Remark = a.Remark,
|
|
|
|
+ SId = a.SId,
|
|
|
|
+ SidName = b.Name,
|
|
|
|
+ Units = a.Units,
|
|
|
|
+ }
|
|
|
|
+ ).ToList();
|
|
|
|
+ if (content.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ contentArr.Add(content);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //open excel
|
|
|
|
+ //set excel
|
|
|
|
+ //save excel
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
|
|
|
|
+ IWorkbook workbook;
|
|
|
|
+ if (Path.GetExtension(filePath).ToLower() == ".xls")
|
|
|
|
+ {
|
|
|
|
+ workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ISheet sheet = workbook.GetSheetAt(0);
|
|
|
|
+ var rowStartIndex = 2;
|
|
|
|
+ var clounmCount = 10;
|
|
|
|
+ var initStyleRow = sheet.GetRow(2);
|
|
|
|
+
|
|
|
|
+ var arr = contentArr.SelectMany(x => x).OrderBy(x=>x.SId).ToList();
|
|
|
|
+ //var overspendArrDetail =
|
|
|
|
+
|
|
|
|
+ var existsId = new List<CarCompare>();
|
|
|
|
+ var lastElem = arr.Last();
|
|
|
|
+ var thisSid = -1;
|
|
|
|
+
|
|
|
|
+ var curr = arr.Count > 0 ? arr[0].Currency : -1;
|
|
|
|
+ var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
|
|
|
|
+ {
|
|
|
|
+ Name = "未知币种!",
|
|
|
|
+ Remark = "未知币种!",
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
|
|
|
|
+
|
|
|
|
+ Action cloneRowFn = () =>
|
|
|
|
+ {
|
|
|
|
+ rowStartIndex++;
|
|
|
|
+
|
|
|
|
+ var cloneRow = sheet.CreateRow(rowStartIndex);
|
|
|
|
+
|
|
|
|
+ // 复制样式
|
|
|
|
+ for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
|
|
|
|
+ {
|
|
|
|
+ ICell sourceCell = initStyleRow.GetCell(i);
|
|
|
|
+ ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
|
|
|
|
+
|
|
|
|
+ // 确保单元格存在样式
|
|
|
|
+ if (sourceCell.CellStyle != null)
|
|
|
|
+ {
|
|
|
|
+ targetCell.CellStyle = sourceCell.CellStyle;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var mergeRow = () =>
|
|
|
|
+ {
|
|
|
|
+ for (int i = 2; i < sheet.LastRowNum; i++)
|
|
|
|
+ {
|
|
|
|
+ var row = sheet.GetRow(i);
|
|
|
|
+ var cellFirst = row.GetCell(0);
|
|
|
|
+ var thisIndex = i + 1;
|
|
|
|
+ while (thisIndex < sheet.LastRowNum)
|
|
|
|
+ {
|
|
|
|
+ var nextRow = sheet.GetRow(thisIndex);
|
|
|
|
+ var nextCellFirst = nextRow.GetCell(0);
|
|
|
|
+ if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
|
|
|
|
+ {
|
|
|
|
+ thisIndex++;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ thisIndex--;
|
|
|
|
+
|
|
|
|
+ if (thisIndex != i)
|
|
|
|
+ {
|
|
|
|
+ //合并row
|
|
|
|
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(
|
|
|
|
+ i, // 起始行索引(0-based)
|
|
|
|
+ thisIndex, // 结束行索引(0-based)
|
|
|
|
+ 0, // 起始列索引(0-based)
|
|
|
|
+ 0 // 结束列索引(0-based)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ sheet.AddMergedRegion(cellRangeAddress);
|
|
|
|
+
|
|
|
|
+ i = thisIndex;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var chaoshiNumber = 0;
|
|
|
|
+ var totalNumber = 0.00M;
|
|
|
|
+
|
|
|
|
+ string lastStr = "";
|
|
|
|
+
|
|
|
|
+ var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
|
|
|
|
+ .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x,b) => new
|
|
|
|
+ {
|
|
|
|
+ b.IsAuditGM,
|
|
|
|
+ x.Id,
|
|
|
|
+ x.Area,
|
|
|
|
+ b.PayPercentage,
|
|
|
|
+ b.PayMoney,
|
|
|
|
+ }).ToList();
|
|
|
|
+
|
|
|
|
+ string yesPayment = "", noPayment = "";
|
|
|
|
+ foreach (var item in queryCarArrByCityAndDiid)
|
|
|
|
+ {
|
|
|
|
+ if (item.IsAuditGM == 1)
|
|
|
|
+ {
|
|
|
|
+ yesPayment += $"已支付团款({item.PayPercentage}):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lastStr = yesPayment + noPayment;
|
|
|
|
+
|
|
|
|
+ foreach (var item in arr)
|
|
|
|
+ {
|
|
|
|
+ if (existsId.FirstOrDefault(x=>x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
|
|
|
|
+ {
|
|
|
|
+ if (thisSid != item.SId)
|
|
|
|
+ {
|
|
|
|
+ if (thisSid == -1)
|
|
|
|
+ {
|
|
|
|
+ thisSid = item.SId;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //合并小计行
|
|
|
|
+ //创建合并区域的实例
|
|
|
|
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(
|
|
|
|
+ rowStartIndex, // 起始行索引(0-based)
|
|
|
|
+ rowStartIndex, // 结束行索引(0-based)
|
|
|
|
+ 0, // 起始列索引(0-based)
|
|
|
|
+ 3 // 结束列索引(0-based)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ sheet.AddMergedRegion(cellRangeAddress);
|
|
|
|
+ var CellStyle = workbook.CreateCellStyle();
|
|
|
|
+ CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
|
|
|
|
+ CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
|
|
|
|
+ CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
|
|
|
|
+ for (int i = 0; i <= clounmCount; i++)
|
|
|
|
+ {
|
|
|
|
+ if (i > 6)
|
|
|
|
+ {
|
|
|
|
+ var CellStyle1 = workbook.CreateCellStyle();
|
|
|
|
+ CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
|
|
|
|
+ IFont Font = workbook.CreateFont(); // 创建字体
|
|
|
|
+ Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
|
|
|
|
+ Font.Color = IndexedColors.Red.Index; // 选择字体颜色
|
|
|
|
+ CellStyle1.SetFont(Font);
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x=>x.SId == thisSid).Sum(x=>x.Count * x.Price).ToString("F2"));
|
|
|
|
+
|
|
|
|
+ //超时合计
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
|
|
|
|
+ //超时数
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" :chaoshiNumber.ToString());
|
|
|
|
+ //超时合计费用
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
|
|
|
|
+
|
|
|
|
+ thisSid = item.SId;
|
|
|
|
+
|
|
|
|
+ cloneRowFn();
|
|
|
|
+
|
|
|
|
+ chaoshiNumber = 0;
|
|
|
|
+ totalNumber = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ IRow row = sheet.GetRow(rowStartIndex);
|
|
|
|
+ var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
|
|
|
|
+ var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
|
|
|
|
+ List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null ;
|
|
|
|
+ if (isOpenOverspendSoure)
|
|
|
|
+ {
|
|
|
|
+ overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
|
|
|
|
+ chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
|
|
|
|
+ totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i <= clounmCount; i++)
|
|
|
|
+ {
|
|
|
|
+ var cell = row.GetCell(i);
|
|
|
|
+ var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
|
|
|
|
+ if (cell == null)
|
|
|
|
+ {
|
|
|
|
+ cell = row.CreateCell(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
|
|
|
|
+ fontRed.CloneStyleFrom(cell.CellStyle);
|
|
|
|
+ IFont Font = workbook.CreateFont(); // 创建字体
|
|
|
|
+ Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
|
|
|
|
+ Font.Color = IndexedColors.Red.Index; // 选择字体颜色
|
|
|
|
+ fontRed.SetFont(Font);
|
|
|
|
+
|
|
|
|
+ byte[] rgb = new byte[3] { 255, 242, 204 };
|
|
|
|
+ var BackgroundColor255_242_204 = workbook.CreateCellStyle();
|
|
|
|
+ BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
|
|
|
|
+
|
|
|
|
+ byte[] rgb1 = new byte[3] { 189,215, 238 };
|
|
|
|
+
|
|
|
|
+ if (workbook is XSSFWorkbook)
|
|
|
|
+ {
|
|
|
|
+ BackgroundColor255_242_204.FillForegroundColor = 0;
|
|
|
|
+ ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
|
|
|
|
+ BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (i == 1 || i > 6)
|
|
|
|
+ {
|
|
|
|
+ if (i > 6)
|
|
|
|
+ {
|
|
|
|
+ fontRed.FillForegroundColor = 0;
|
|
|
|
+ ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
|
|
|
|
+ fontRed.FillPattern = FillPattern.SolidForeground;
|
|
|
|
+ }
|
|
|
|
+ cell.CellStyle = fontRed;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (i > 2 && i < 7)
|
|
|
|
+ {
|
|
|
|
+ cell.CellStyle = BackgroundColor255_242_204;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ cell.SetCellValue(setCellValue); //写入单元格
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (overspendSoure.ContainsKey(thisSid)) {
|
|
|
|
+ var overspendId = overspendSoure[thisSid];
|
|
|
|
+ whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cloneRowFn();
|
|
|
|
+
|
|
|
|
+ existsId.Add(new CarCompare
|
|
|
|
+ {
|
|
|
|
+ DataPrice = item.DatePrice.ObjToDate(),
|
|
|
|
+ Sid = item.SId
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (item.Equals(lastElem))
|
|
|
|
+ {
|
|
|
|
+ //合并小计行
|
|
|
|
+ //创建合并区域的实例
|
|
|
|
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(
|
|
|
|
+ rowStartIndex, // 起始行索引(0-based)
|
|
|
|
+ rowStartIndex, // 结束行索引(0-based)
|
|
|
|
+ 0, // 起始列索引(0-based)
|
|
|
|
+ 3 // 结束列索引(0-based)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ sheet.AddMergedRegion(cellRangeAddress);
|
|
|
|
+ var CellStyle = workbook.CreateCellStyle();
|
|
|
|
+ CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
|
|
|
|
+ CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
|
|
|
|
+ CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
|
|
|
|
+ for (int i = 0; i <= clounmCount; i++)
|
|
|
|
+ {
|
|
|
|
+ if (i > 6)
|
|
|
|
+ {
|
|
|
|
+ var CellStyle1 = workbook.CreateCellStyle();
|
|
|
|
+ CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
|
|
|
|
+ IFont Font = workbook.CreateFont(); // 创建字体
|
|
|
|
+ Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
|
|
|
|
+ Font.Color = IndexedColors.Red.Index; // 选择字体颜色
|
|
|
|
+ CellStyle1.SetFont(Font);
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
|
|
|
|
+
|
|
|
|
+ //超时合计
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
|
|
|
|
+ //超时数
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
|
|
|
|
+ //超时合计费用
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
|
|
|
|
+
|
|
|
|
+ cloneRowFn();
|
|
|
|
+
|
|
|
|
+ // 创建合并区域的实例
|
|
|
|
+ cellRangeAddress = new CellRangeAddress(
|
|
|
|
+ rowStartIndex, // 起始行索引(0-based)
|
|
|
|
+ rowStartIndex, // 结束行索引(0-based)
|
|
|
|
+ 0, // 起始列索引(0-based)
|
|
|
|
+ initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 添加合并区域
|
|
|
|
+ sheet.AddMergedRegion(cellRangeAddress);
|
|
|
|
+ sheet.GetRow(rowStartIndex).Height = 30 * 30;
|
|
|
|
+ sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mergeRow();
|
|
|
|
+
|
|
|
|
+ // 保存修改后的Excel文件到新文件
|
|
|
|
+ //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
|
|
|
|
+ // new FileStream(newFilePath, FileMode.CreateNew)
|
|
|
|
+
|
|
|
|
+ using (var stream = new MemoryStream())
|
|
|
|
+ {
|
|
|
|
+ workbook.Write(stream,true);
|
|
|
|
+ stream.Flush();
|
|
|
|
+ stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
+ MemoryStream memoryStream = new MemoryStream();
|
|
|
|
+ stream.CopyTo(memoryStream);
|
|
|
|
+ memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
+ Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ workbook.Close();
|
|
|
|
+ workbook.Dispose();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "出现异常!" + ex.Message;
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Zips.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ IOOperatorHelper io = new IOOperatorHelper();
|
|
|
|
+ var byts = io.ConvertZipStream(Zips);
|
|
|
|
+ io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + "\\ExportLocalGuidePriceDetail\\地接费用明细.zip");
|
|
|
|
+ //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
|
|
|
|
+ jw = JsonView(true, "success" , new { url = AppSettingsHelper.Get("OfficeBaseUrl") + "\\Office\\Excel\\ExportLocalGuidePriceDetail\\地接费用明细.zip" });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "暂无生成文件!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
|
|
|
|
+ {
|
|
|
|
+ string outStr = string.Empty;
|
|
|
|
+ switch (i)
|
|
|
|
+ {
|
|
|
|
+ case 0:
|
|
|
|
+ outStr = arr[0].SidName;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 1:
|
|
|
|
+ outStr = arr[0].DataPriceStr;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 2:
|
|
|
|
+ outStr = string.Join("-", arr.Select(x => x.PriceContent));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 4:
|
|
|
|
+ outStr = arr.Sum(x => x.Subtotal).ToString("F2");
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 7:
|
|
|
|
+ if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
|
|
|
|
+ var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
|
|
|
|
+ outStr = arrOverspendSoure.Sum(x=>x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 8:
|
|
|
|
+ if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 9:
|
|
|
|
+ if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 10:
|
|
|
|
+ if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return outStr;
|
|
|
|
+ }
|
|
|
|
+
|
|
#region OP行程单
|
|
#region OP行程单
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|