@@ -1,3 +1,4 @@
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Threading.Tasks ;
@@ -16,8 +17,7 @@ namespace YhCore.WebApi.Controllers.Api.DocPrint
{
/// <summary>
/// 审核角色 + 流程配置控制器(对应旧 Areas/DocPrint/WYSHRoleController,路由 api/docprint/wyshrole)。
/// 45 action 中本批落地 39 个;Excel 导入导出(ExceltotalListSHRole/WYRDExceldaochu/UpfileExcelSHRole/
/// downMBOfSHRole/downUpfileSHRoleFK)与审批单 PDF( DwonWYSQD)依赖 NPOI/PdfHelper,延后迁移。
/// 45 action 全部落地(Excel 导入导出 5 个走 NPOI/EPPlus,审批单 PDF 走 wkhtmltopdf)。
/// POST 动作一律 [FromForm]:前端 api/index.js 固定 x-www-form-urlencoded 提交([FromForm] 会 415);
/// 老契约"表单字段塞 JSON"的动作(WYSHRole/SHTeaTxt/listXxxTxt/data/docdata/docnumdata)
/// 以 [FromForm] string 接收后手动反序列化。
@@ -297,8 +297,74 @@ namespace YhCore.WebApi.Controllers.Api.DocPrint
return await _role . ShenheOkSHRoleAsync ( model ) ;
}
// 延后:ExceltotalListSHRole / WYRDExceldaochu / UpfileExcelSHRole / downMBOfSHRole / downUpfileSHRoleFK( Excel, NPOI)
// 延后:DwonWYSQD(审批单 PDF, PdfHelper + Server.MapPath)
#region Excel 导 入 导 出 / 审 批 单 PDF
/// <summary>全部文印导出(旧 ExceltotalListSHRole, NPOI .xls)。</summary>
[HttpGet("ExceltotalListSHRole")]
public async Task < IActionResult > ExceltotalListSHRole (
[FromQuery] string Name ,
[FromQuery] string stateid ,
[FromQuery] string starttime ,
[FromQuery] string endtime )
{
var ( content , fileName ) = await _role . ExceltotalListSHRoleAsync ( SchSerID ( ) , Name , stateid , starttime , endtime ) ;
return File ( content , ContentType ( fileName ) , fileName ) ;
}
/// <summary>文印记录导出(旧 WYRDExceldaochu, flag=page 简版 / 完整版,EPPlus)。</summary>
[HttpGet("WYRDExceldaochu")]
public async Task < IActionResult > WYRDExceldaochu (
[FromQuery] int flowid ,
[FromQuery] int DWid ,
[FromQuery] string Name ,
[FromQuery] string stateid ,
[FromQuery] string starttime ,
[FromQuery] string endtime ,
[FromQuery] string flag )
{
var ( content , fileName ) = await _role . WYRDExceldaochuAsync ( SchSerID ( ) , flowid , DWid , Name , stateid , starttime , endtime , flag ) ;
return File ( content , ContentType ( fileName ) , fileName ) ;
}
/// <summary>Excel 批量导入审核角色(旧 UpfileExcelSHRole, multipart 文件字段名不敏感取第一个)。</summary>
[HttpPost("UpfileExcelSHRole")]
public async Task < string > UpfileExcelSHRole ( )
{
var file = Request . Form . Files . Count > 0 ? Request . Form . Files [ 0 ] : null ;
return await _role . UpfileExcelSHRoleAsync ( SchSerID ( ) , UserId ( ) , file ) ;
}
/// <summary>下载导入模板(旧 downMBOfSHRole,代码生成)。</summary>
[HttpGet("downMBOfSHRole")]
public async Task < IActionResult > DownMBOfSHRole ( )
{
var content = await _role . DownMBOfSHRoleAsync ( ) ;
return File ( content , "application/vnd.ms-excel" , "批量导入审核角色.xls" ) ;
}
/// <summary>下载最近一次导入的反馈 Excel(旧 downUpfileSHRoleFK)。</summary>
[HttpGet("downUpfileSHRoleFK")]
public async Task < IActionResult > DownUpfileSHRoleFK ( )
{
var content = await _role . DownUpfileSHRoleFKAsync ( UserId ( ) ) ;
return File ( content , "application/vnd.ms-excel" , "批量导入审核角色反馈.xls" ) ;
}
/// <summary>审批单 PDF 下载(旧 DwonWYSQD, IDS 逗号分隔的 WY_DocPrint.SerID;依赖服务器安装 wkhtmltopdf)。</summary>
[HttpGet("DwonWYSQD")]
public async Task < IActionResult > DwonWYSQD ( [ FromQuery ] string IDS )
{
var ( content , fileName ) = await _role . DwonWYSQDAsync ( SchSerID ( ) , UserId ( ) , IDS ) ;
return File ( content , "application/pdf" , fileName ) ;
}
/// <summary>按扩展名取下载 Content-Type(对齐 CommonController.GetContentType 约定)。</summary>
private static string ContentType ( string fileName )
= > fileName ! = null & & fileName . EndsWith ( ".pdf" , StringComparison . OrdinalIgnoreCase )
? "application/pdf"
: "application/vnd.ms-excel" ;
#endregion
#endregion