|
|
@@ -2144,7 +2144,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
// 4. 获取当前文件列表
|
|
|
var currentFilePaths = groupInfo.FrFilePaths ?? new List<string>();
|
|
|
- var groupDir = @$"{groupInfo.TeamName}({groupInfo.Id})";
|
|
|
+ var groupDir = @$"{groupInfo.TeamName}_{groupInfo.Id}";
|
|
|
|
|
|
// 5. 检查要删除的文件是否存在
|
|
|
if (!currentFilePaths.Contains(groupDir + @"/" + fileName))
|
|
|
@@ -4141,7 +4141,7 @@ namespace OASystem.API.Controllers
|
|
|
int rowNumber = 1;
|
|
|
foreach (var subItem in item.childList)
|
|
|
{
|
|
|
- string remaksDescription = $"{rowNumber}、【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.0000")}(单价:{subItem.Price.ToString("#0.0000")} * {subItem.Quantity.ToString("#0.0000")})";
|
|
|
+ string remaksDescription = $"{rowNumber}、【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.0000")}(单价:{subItem.Price.ToString("#0.0000")} * {subItem.Quantity.ToString("#0.0000")})【备注:{subItem.Remark ?? " - "}】】";
|
|
|
subItem.RemaksDescription = remaksDescription;
|
|
|
string excelRemaksDescription = $"【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.0000")}(单价:{subItem.Price.ToString("#0.0000")} * {subItem.Quantity.ToString("#0.0000")})【申请人:{item.CreateUser} 申请时间:{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}】";
|
|
|
subItem.ExcelRemaksDescription = excelRemaksDescription;
|
|
|
@@ -4657,6 +4657,14 @@ namespace OASystem.API.Controllers
|
|
|
// return Ok(JsonView(false, "参数ConpanyId不可使用!"));
|
|
|
//}
|
|
|
|
|
|
+
|
|
|
+ var designer = new WorkbookDesigner
|
|
|
+ {
|
|
|
+ Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/付款申请书.xls")
|
|
|
+ };
|
|
|
+
|
|
|
+ #region 数据处理
|
|
|
+
|
|
|
string _requestPaymentDt = DateTime.Now.ToString("yyyy-MM-dd"),//申请付款日期
|
|
|
_appliedAmount = "", //申请付款金额
|
|
|
_GZStr = "", //公转价格描述
|
|
|
@@ -4666,8 +4674,6 @@ namespace OASystem.API.Controllers
|
|
|
decimal dailyGZAmout = 0.00M, dailySZAmout = 0.00M;
|
|
|
string dailyGZStr = "", dailySZStr = "", groupGZStr = "", groupSZStr = "";
|
|
|
|
|
|
- #region 数据处理
|
|
|
-
|
|
|
//团组费用相关
|
|
|
foreach (var item in _GroupData)
|
|
|
{
|
|
|
@@ -4679,12 +4685,17 @@ namespace OASystem.API.Controllers
|
|
|
if (subItem.TransferMark.Equals("公转"))
|
|
|
{
|
|
|
groupGZAmout += subItem.CNYSubTotalAmount;
|
|
|
- groupGZSubStr += $"{subItem.RemaksDescription}\r\n";
|
|
|
+
|
|
|
+ groupGZSubStr += subItem.IsBgColorShown
|
|
|
+ ? $"[ORANGE]{subItem.RemaksDescription}[/ORANGE]\r\n"
|
|
|
+ : $"{subItem.RemaksDescription}\r\n";
|
|
|
}
|
|
|
else if (subItem.TransferMark.Equals("私转"))
|
|
|
{
|
|
|
groupSZAmout += subItem.CNYSubTotalAmount;
|
|
|
- groupSZSubStr += $"{subItem.RemaksDescription}\r\n";
|
|
|
+ groupSZSubStr += subItem.IsBgColorShown
|
|
|
+ ? $"[ORANGE]{subItem.RemaksDescription}[/ORANGE]\r\n"
|
|
|
+ : $"{subItem.RemaksDescription}\r\n";
|
|
|
}
|
|
|
|
|
|
//groupGZSubStr += $"\t";
|
|
|
@@ -4721,10 +4732,8 @@ namespace OASystem.API.Controllers
|
|
|
_appliedAmount = $"公转:CNY {(groupGZAmout + dailyGZAmout).ToString("#0.00")}\r\n私转:CNY {(groupSZAmout + dailySZAmout).ToString("#0.00")}";
|
|
|
#endregion
|
|
|
|
|
|
- var designer = new WorkbookDesigner
|
|
|
- {
|
|
|
- Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/付款申请书.xls")
|
|
|
- };
|
|
|
+ //FillExcelWithMarkedText(designer.Workbook.Worksheets[0], _GZStr, 3);
|
|
|
+
|
|
|
designer.SetDataSource("Date", _requestPaymentDt);
|
|
|
designer.SetDataSource("Price", _appliedAmount);
|
|
|
designer.SetDataSource("Content", _GZStr);
|
|
|
@@ -4733,6 +4742,9 @@ namespace OASystem.API.Controllers
|
|
|
//根据数据源处理生成报表内容
|
|
|
designer.Process();
|
|
|
|
|
|
+ // 直接处理工作表中的合并单元格
|
|
|
+ SimplifyProcessOrangeTags(designer.Workbook);
|
|
|
+
|
|
|
string fileName = ("PayRequest/付款申请(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
|
|
|
designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
@@ -4747,6 +4759,121 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 简化版本的处理方法
|
|
|
+ /// </summary>
|
|
|
+ private void SimplifyProcessOrangeTags(Workbook workbook)
|
|
|
+ {
|
|
|
+ Color orangeColor = Color.FromArgb(255, 140, 0);
|
|
|
+
|
|
|
+ Worksheet worksheet = workbook.Worksheets[0];
|
|
|
+
|
|
|
+ // 处理所有合并区域
|
|
|
+ foreach (CellArea mergedArea in worksheet.Cells.MergedCells)
|
|
|
+ {
|
|
|
+ Cell firstCell = worksheet.Cells[mergedArea.StartRow, mergedArea.StartColumn];
|
|
|
+ string cellValue = firstCell.StringValue;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(cellValue) && cellValue.Contains("[ORANGE]"))
|
|
|
+ {
|
|
|
+ // 简单替换并应用颜色
|
|
|
+ ProcessCellSimple(firstCell, cellValue, orangeColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理普通单元格
|
|
|
+ for (int row = 0; row <= worksheet.Cells.MaxDataRow; row++)
|
|
|
+ {
|
|
|
+ for (int col = 0; col <= worksheet.Cells.MaxDataColumn; col++)
|
|
|
+ {
|
|
|
+ if (IsCellInMergedRange(worksheet, row, col))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ Cell cell = worksheet.Cells[row, col];
|
|
|
+ if (cell.StringValue != null && cell.StringValue.Contains("[ORANGE]"))
|
|
|
+ {
|
|
|
+ ProcessCellSimple(cell, cell.StringValue, orangeColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检查单元格是否在合并区域内
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="worksheet">工作表</param>
|
|
|
+ /// <param name="row">行索引(0-based)</param>
|
|
|
+ /// <param name="col">列索引(0-based)</param>
|
|
|
+ /// <returns>如果在合并区域内返回true,否则返回false</returns>
|
|
|
+ private bool IsCellInMergedRange(Worksheet worksheet, int row, int col)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 获取工作表中的所有合并区域
|
|
|
+ ArrayList mergedAreas = worksheet.Cells.MergedCells;
|
|
|
+
|
|
|
+ if (mergedAreas == null || mergedAreas.Count == 0)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ // 遍历所有合并区域
|
|
|
+ foreach (object areaObj in mergedAreas)
|
|
|
+ {
|
|
|
+ if (areaObj is CellArea area)
|
|
|
+ {
|
|
|
+ // 检查单元格是否在该合并区域内
|
|
|
+ if (row >= area.StartRow && row <= area.EndRow &&
|
|
|
+ col >= area.StartColumn && col <= area.EndColumn)
|
|
|
+ {
|
|
|
+ // 如果是要找的单元格,但不是第一个单元格(左上角),也返回true
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ // 出错时记录日志,默认返回false
|
|
|
+ Console.WriteLine($"检查合并区域失败: {ex.Message}");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ProcessCellSimple(Cell cell, string text, Color orangeColor)
|
|
|
+ {
|
|
|
+ // 简单的标记处理
|
|
|
+ string plainText = text.Replace("[ORANGE]", "").Replace("[/ORANGE]", "");
|
|
|
+ cell.PutValue(plainText);
|
|
|
+
|
|
|
+ // 找到所有橙色部分并应用颜色
|
|
|
+ int startIndex = 0;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ int orangeStart = text.IndexOf("[ORANGE]", startIndex);
|
|
|
+ if (orangeStart < 0) break;
|
|
|
+
|
|
|
+ int orangeEnd = text.IndexOf("[/ORANGE]", orangeStart);
|
|
|
+ if (orangeEnd < 0) break;
|
|
|
+
|
|
|
+ string orangeContent = text.Substring(orangeStart + "[ORANGE]".Length,
|
|
|
+ orangeEnd - orangeStart - "[ORANGE]".Length);
|
|
|
+
|
|
|
+ // 计算在纯文本中的位置
|
|
|
+ string beforeOrange = text.Substring(0, orangeStart);
|
|
|
+ int plainPosition = beforeOrange.Replace("[ORANGE]", "").Replace("[/ORANGE]", "").Length;
|
|
|
+
|
|
|
+ if (plainPosition >= 0 && plainPosition < plainText.Length)
|
|
|
+ {
|
|
|
+ FontSetting fontSetting = cell.Characters(plainPosition, orangeContent.Length);
|
|
|
+ fontSetting.Font.Color = orangeColor;
|
|
|
+ fontSetting.Font.IsBold = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ startIndex = orangeEnd + "[/ORANGE]".Length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 超支费用
|