dengjunjie
3 天以前 b52018589bf6c7ec1d51ce8ad000a7aa993b0ab5
´úÂë¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ProcessInfoService.cs
@@ -3,6 +3,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.BasicInfo;
using WIDESEAWCS_Model.Models;
@@ -10,46 +11,20 @@
{
    public class ProcessInfoService : ServiceBase<Dt_ProcessInfo, IRepository<Dt_ProcessInfo>>, IProcessInfoService
    {
        public ProcessInfoService(IRepository<Dt_ProcessInfo> BaseDal) : base(BaseDal)
        private readonly IFormulaService _formulaService;
        private readonly IFormulaDetailService _formulaDetailService;
        public ProcessInfoService(
            IRepository<Dt_ProcessInfo> BaseDal,
            IFormulaService formulaService,
            IFormulaDetailService formulaDetailService
            ) : base(BaseDal)
        {
            _formulaService = formulaService;
            _formulaDetailService = formulaDetailService;
        }
        public IRepository<Dt_ProcessInfo> Repository => BaseDal;
        /// <summary>
        /// ä¸‹è½½æµç¨‹å¡
        /// </summary>
        /// <param name="dt_ProcessInfo"></param>
        /// <returns></returns>
        public WebResponseContent ExportData(Dt_ProcessInfo dt_ProcessInfo)
        {
                string fileName = $"{DateTime.Now.ToString("yyyyMMddHHssmm")}.xlsx";
                string templatePath = $"{AppDomain.CurrentDomain.BaseDirectory}ExprotTemplate\\发电机弹性支撑信息化流程卡.xlsx";//模板路径
                string savePath = $"{AppDomain.CurrentDomain.BaseDirectory}Download\\{fileName}";//保存文件路径
                using Stream templateStream = new FileStream(templatePath, FileMode.Open);
                using Stream saveStream = new FileStream(savePath, FileMode.Create);
                using ExcelPackage package = new ExcelPackage(saveStream, templateStream);
                ExcelWorksheet worksheet = package.Workbook.Worksheets["流程卡"];
                worksheet.Cells[3, 5].Value = dt_ProcessInfo.ProductCode;//成品编号
                package.Save();
                string pdfFileName = $"{DateTime.Now.ToString("yyyyMMddHHssmm")}.pdf";
                string pdfPath = $"{AppDomain.CurrentDomain.BaseDirectory}Download\\{pdfFileName}";
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(savePath);
                // è½¬æ¢ç¬¬ä¸€ä¸ªå·¥ä½œè¡¨åˆ°PDF
                workbook.SaveToFile(pdfPath, FileFormat.PDF);
                return WebResponseContent.Instance.OK(data: new { path = pdfPath, fileName = pdfFileName });
            }
    }
}