123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Newtonsoft.Json;
- using NPOI.HPSF;
- using NPOI.SS.UserModel;
- using NPOI.Util;
- using NPOI.XWPF.UserModel;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Common.Helper;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Common;
- using Ropin.Inspection.Model.SearchModel;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service;
- using Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.IO.Compression;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api.Controllers
- {
- /// <summary>
- /// 巡检详细记录
- /// </summary>
- public class TispRecordItemController : BaseController
- {
- public ILogger<TispRecordItemController> _logger { get; }
- private readonly ITispRecordItemService _tispRecordItemService;
- private readonly ITispRecordImageService _tispRecordImageService;
- private readonly IReportService _reportService;
- /// <summary>
- ///
- /// </summary>
- /// <param name="tispRecordItemService"></param>
- /// <param name="tispRecordImageService"></param>
- /// <param name="logger"></param>
- public TispRecordItemController(ITispRecordItemService tispRecordItemService, IReportService reportService, ITispRecordImageService tispRecordImageService, ILogger<TispRecordItemController> logger)
- {
- _tispRecordItemService = tispRecordItemService;
- _tispRecordImageService = tispRecordImageService;
- _reportService = reportService;
- _logger = logger;
- }
- /// <summary>
- /// 通过巡检记录ID获取巡检信息
- /// </summary>
- /// <param name="recordId"></param>
- /// <returns></returns>
- [HttpGet("GetRecordItemsAsync/{recordId}")]
- public async Task<ApiResult> GetRecordItemsAsync(Guid recordId)
- {
- if (Guid.Empty == recordId)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- IEnumerable<TispRecordItemDetailViewModel> recordItems = await _tispRecordItemService.GetRecordsConditionAsync(recordId);
- return new ApiResult<IEnumerable<TispRecordItemDetailViewModel>>(recordItems);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过巡检记录ID获取巡检详细信息,通过内容分组
- /// </summary>
- /// <param name="recordId"></param>
- /// <returns></returns>
- [HttpGet("GetRecordItemsByRecordIdAsync/{recordId}")]
- [AllowAnonymous]
- public async Task<ApiResult> GetRecordItemsByRecordIdAsync(Guid recordId)
- {
- if (Guid.Empty == recordId)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- List<List<TispRecordItemDetailViewModel>> recordItems = await _tispRecordItemService.GetRecordItemsByRecordIdAsync(recordId);
- return new ApiResult<List<List<TispRecordItemDetailViewModel>>>(recordItems);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过详细记录ID获取巡检信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("GetRecordItemByIdAsync/{id}")]
- public async Task<ApiResult> GetRecordItemByIdAsync(Guid id)
- {
- if (Guid.Empty == id)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- IEnumerable<TispRecordItemDetailViewModel> recordItems = await _tispRecordItemService.GetRecordItemByIdAsync(id);
- return new ApiResult<IEnumerable<TispRecordItemDetailViewModel>>(recordItems);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取异常上报记录
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpPost("GetAlarmRecordsAsync")]
- public async Task<ApiResult> GetAlarmRecordsAsync(TispRecordAlarmSearchModel searchModel)
- {
- if (null == searchModel || string.IsNullOrEmpty(searchModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- IEnumerable<TispRecordItemDetailViewModel> recordItems = await _tispRecordItemService.GetAlarmRecordsAsync(searchModel);
- return new ApiResult<PagesModel<TispRecordItemDetailViewModel>>(new PagesModel<TispRecordItemDetailViewModel>(recordItems?.ToList(), searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 后台管理平台,获取异常上报记录
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpPost("GetAlarmRecordListAsync")]
- public async Task<ApiResult> GetAlarmRecordListAsync(TispRecordAlarmSearchModel searchModel)
- {
- if (null == searchModel || string.IsNullOrEmpty(searchModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- IEnumerable<TispRecordItemDetailViewModel> recordItems = await _tispRecordItemService.GetAlarmRecordListAsync(searchModel);
- return new ApiResult<PagesModel<TispRecordItemDetailViewModel>>(new PagesModel<TispRecordItemDetailViewModel>(recordItems?.ToList(), searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 扫巡检点二维码获取异常记录
- /// </summary>
- /// <param name="QRCode"></param>
- /// <param name="storeCode"></param>
- /// <returns></returns>
- [HttpGet("GetAlarmRecordsByQRCodeAsync/{QRCode}/{storeCode}")]
- //[AllowAnonymous]
- public async Task<ApiResult> GetAlarmRecordsByQRCodeAsync(string QRCode,string storeCode)
- {
- try
- {
- if (string.IsNullOrEmpty(QRCode)|| string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- IEnumerable<TispRecordItemAlarmDetailViewModel> recordItems = await _tispRecordItemService.GetAlarmRecordsByQRCodeAsync(QRCode, storeCode);
- return new ApiResult<IEnumerable<TispRecordItemAlarmDetailViewModel>>(recordItems?.ToList());
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 根据巡检点二维码获取最新巡检记录
- /// </summary>
- /// <param name="QRCode"></param>
- /// <param name="storeCode"></param>
- /// <returns></returns>
- [HttpGet("GetNewRecordByQRCodeAsync/{QRCode}/{storeCode}")]
- public async Task<ApiResult> GetNewRecordByQRCodeAsync(string QRCode,string storeCode)
- {
- try
- {
- if (string.IsNullOrEmpty(QRCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- IEnumerable<TispRecordItemAlarmDetailViewModel> recordItems = await _tispRecordItemService.GetNewRecordByQRCodeAsync(QRCode, storeCode);
- return new ApiResult<IEnumerable<TispRecordItemAlarmDetailViewModel>>(recordItems?.ToList());
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取异常上报记录数
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpGet("GetAlarmRecordsCountAsync")]
- public async Task<ApiResult> GetAlarmRecordsCountAsync([FromQuery] TispRecordAlarmSearchModel searchModel)
- {
- if (null == searchModel || string.IsNullOrEmpty(searchModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- int recordCount = await _tispRecordItemService.GetAlarmRecordsCountAsync(searchModel);
- return new ApiResult<int>(recordCount);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取异常处理记录
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpPost("GetAlarmRecoveryRecordsAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> GetAlarmRecoveryRecordsAsync(TispRecordAlarmSearchModel searchModel)
- {
- if (null == searchModel || string.IsNullOrEmpty(searchModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- IEnumerable<TispRecordItemDetailViewModel> recordItems = await _tispRecordItemService.GetAlarmRecoveryRecordsAsync(searchModel);
- //if (null == recordItems)
- // return new ApiResult<IEnumerable<TispRecordItemDetailViewModel>>(recordItems);
- //else
- return new ApiResult<PagesModel<TispRecordItemDetailViewModel>>(new PagesModel<TispRecordItemDetailViewModel>(recordItems?.ToList(), searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取异常处理记录数
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpGet("GetAlarmRecoveryRecordsCountAsync")]
- public async Task<ApiResult> GetAlarmRecoveryRecordsCountAsync([FromQuery] TispRecordAlarmSearchModel searchModel)
- {
- if (null == searchModel || string.IsNullOrEmpty(searchModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- int recordCount = await _tispRecordItemService.GetAlarmRecoveryRecordsCountAsync(searchModel);
- return new ApiResult<int>(recordCount);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 巡检异常恢复处理
- /// </summary>
- /// <param name="recordItemId"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("RecoveryRecordItemAlarmAsync/{recordItemId}")]
- public async Task<ApiResult> RecoveryRecordItemAlarmAsync(Guid recordItemId, TispRecoveryRecordItemAlarmUpdateViewModel updateModel)
- {
- if (Guid.Empty == recordItemId)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _tispRecordItemService.RecoveryRecordItemAlarmAsync(recordItemId, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 巡检异常确认处理
- /// </summary>
- /// <param name="recordItemId"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("ConfirmRecordItemAlarmAsync/{recordItemId}")]
- public async Task<ApiResult> ConfirmRecordItemAlarmAsync(Guid recordItemId, TispRecoveryRecordItemAlarmUpdateViewModel updateModel)
- {
- if (Guid.Empty == recordItemId)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _tispRecordItemService.ConfirmRecordItemAlarmAsync(recordItemId, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 巡检异常确认处理
- /// </summary>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPost("ConfirmAlarmAsync")]
- public async Task<ApiResult> ConfirmAlarmAsync(TispRecoveryAlarmUpdateViewModel updateModel)
- {
- if (string.IsNullOrEmpty(updateModel.recordItemId))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- Guid id = Guid.Parse(updateModel.recordItemId);
- try
- {
-
- await _tispRecordItemService.ConfirmRecordItemAlarmAsync(id, new TispRecoveryRecordItemAlarmUpdateViewModel { C_Remark = updateModel.C_Remark,FilePaths = updateModel.FilePaths });
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 巡检异常取消处理
- /// </summary>
- /// <param name="recordItemId"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("CancelRecordItemAlarmAsync/{recordItemId}")]
- public async Task<ApiResult> CancelRecordItemAlarmAsync(Guid recordItemId, TispRecoveryRecordItemAlarmUpdateViewModel updateModel)
- {
- if (Guid.Empty == recordItemId)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _tispRecordItemService.CancelRecordItemAlarmAsync(recordItemId, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 巡检记录修改
- /// </summary>
- /// <param name="recordItemId"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("UpdateRecordItemAsync/{recordItemId}")]
- public async Task<ApiResult> UpdateRecordItemAsync(Guid recordItemId, TispRecordItemUpdateViewModel updateModel)
- {
- if (Guid.Empty == recordItemId)
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _tispRecordItemService.UpdateRecordItemAsync(recordItemId, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 消防设施每周检查记录
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- [HttpGet("GetFireFightingFacilitiesAsync")]
- public async Task<ApiResult> GetFireFightingFacilitiesAsync(DateTime start, DateTime end, string storeCode)
- {
- if (start.Year < 2010 || end.Year < 2010 || string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- object o = await _tispRecordItemService.GetFireFightingFacilitiesAsync(start, end.AddDays(1), storeCode);
- ReportViewModel reportViewModel = new ReportViewModel
- {
- G_ID = Guid.NewGuid(),
- C_StoreCode = storeCode,
- I_Type = 3,
- C_GroupName = "设备设施检查",
- C_Name = "设备设施点检记录" + "(" + DateTime.Now.AddDays(1).ToString("yyyy/MM/dd HH:mm") + ")",
- C_Status = "1",
- D_CreateTime = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy/MM/dd HH:mm")),
- D_Start = start,
- D_End = end,
- C_Data = JsonConvert.SerializeObject(o)
- };
- await _reportService.CreateOneAsync(reportViewModel);
- return new ApiResult<object>(o);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
-
- }
- /// <summary>
- /// 防火巡检记录表
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- [HttpGet("GetFireInspectionRecordAsync")]
- public async Task<ApiResult> GetFireInspectionRecordAsync(DateTime start, DateTime end, string storeCode)
- {
- if (start.Year < 2010 || end.Year < 2010 || string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- var work = this.ActualWork(start, end.AddDays(1), storeCode);
- var timeout = this.Timeout(20000);
- object o = null;
- var finishedTask = await Task.WhenAny(timeout, work);
- if (finishedTask == timeout)
- {
- return new ApiResult(ReturnCode.GeneralError, "请求超时");
- }
- else
- {
- o = work.Result;
- }
-
- return new ApiResult<object>(o);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- private async Task<object> ActualWork(DateTime start, DateTime end, string storeCode)
- {
- return await _tispRecordItemService.GetFireInspectionRecordAsync(start, end, storeCode);
- }
- private async Task Timeout(int timeoutValue)
- {
- await Task.Delay(timeoutValue);
- }
- /// <summary>
- /// 防火检查记录(周)
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- [HttpGet("GetFirePreventionWeekRecordAsync")]
- public async Task<ApiResult> GetFirePreventionWeekRecordAsync(DateTime start, DateTime end, string storeCode)
- {
- if (start.Year < 2010 || end.Year < 2010 || string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- object o = await _tispRecordItemService.GetFirePreventionWeekRecordAsync(start, end.AddDays(1), storeCode);
- return new ApiResult<object>(o);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 隐患整改验收单
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- [HttpGet("HiddenDangerRectificationAcceptanceForm")]
- public async Task<ApiResult> HiddenDangerRectificationAcceptanceForm(DateTime start, DateTime end,string storeCode)
- {
- if (start.Year < 2010 || end.Year < 2010 || string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- object o = await _tispRecordItemService.HiddenDangerRectificationAcceptanceForm(start, end.AddDays(1), storeCode);
- return new ApiResult<object>(o);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 发送点检邮件【大屏-详情】
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpPost("SendEmilOrderItem")]
- [AllowAnonymous]
- public async Task<ApiResult> SendEmilOrderItem(SendRecordToEmailModel searchModel)
- {
- try
- {
- if (searchModel == null && searchModel.C_ID!=Guid.Empty)
- {
- return new ApiResult(ReturnCode.ArgsError, "请输入参数");
- }
- List<List<TispRecordItemDetailViewModel>> recordItems = await _tispRecordItemService.GetRecordItemsByRecordIdAsync(searchModel.C_ID);
- string zip = @"wwwroot\\ZipFile";
- if (!System.IO.Directory.Exists(zip))
- {
- Directory.CreateDirectory(zip);
- }
- string zipPaht = zip + $"\\{searchModel.C_ID}点检详情下载.zip";
- if (recordItems.Count > 0)
- {
- XWPFDocument doc = new XWPFDocument();
- var paragraph = doc.CreateParagraph();
- var run1 = paragraph.CreateRun();
- run1.FontSize = 18;
- int serialNum = 1;
- run1.SetText(searchModel.DevName);
- foreach (var itemList in recordItems)
- {
- if (itemList==null)
- {
- continue;
- }
- var p0 = doc.CreateParagraph();
- var run0 = p0.CreateRun();
- run0.FontSize = 16;
- run0.SetText(" " + serialNum.ToString() + "、" + itemList.FirstOrDefault()?.C_Name);
- int serialNum1 = 1;
- foreach (var item in itemList)
- {
- if (item == null) { continue; }
- var p1 = doc.CreateParagraph();
- var run = p1.CreateRun();
- run.FontSize = 14;
- string status = string.Empty;
- //1 = 正常;0 = 异常;2 = 恢复;3 = 确认异常;4 = 取消异常
- switch (item.C_Status)
- {
- case "1":
- status = "正常";
- break;
- case "2":
- status = "异常已处理";
- break;
- case "3":
- status = "确认异常";
- break;
- case "4":
- status = "取消异常";
- break;
- case "0":
- status = "巡检异常";
- break;
- }
- run.SetText(" " + serialNum.ToString() + "." + serialNum1.ToString());
- run.AddCarriageReturn();
- run.AppendText(" 操作时间:" + item.D_CreateOn.ToString("yyyy-MM-dd HH:mm"));
- run.AddCarriageReturn();
- run.AppendText(" 状态:" + status);
- run.AddCarriageReturn();
- run.AppendText(" 处理人员:" + item.ReportUserName);
- if (item.RecordImageList != null && item.RecordImageList.Count() > 0)
- {
- run.AddCarriageReturn();
- run.AppendText(" 现场拍照:");
- foreach (var path in item.RecordImageList)
- {
- string pathFile = path.C_ImageURL;
- if (pathFile != null)
- {
- if (pathFile[0].ToString() == @"/")
- {
- pathFile = pathFile.Substring(1);
- }
- if (!System.IO.File.Exists(pathFile))
- {
- pathFile = @"wwwroot/error.png";
- }
- FileStream fileStream = new FileStream(pathFile, FileMode.Open, FileAccess.Read);
- run.AddCarriageReturn();
- run.AddPicture(fileStream, 6, pathFile, Units.ToEMU(100), Units.ToEMU(100));
- }
- }
- }
- run.AddCarriageReturn();
- run.AppendText(" 现场描述:" + item.C_Remark);
- serialNum1++;
- }
- serialNum++;
- }
-
- using (var zipFile = new FileStream(zipPaht, FileMode.Create))
- {
- using (var memoryStream = new NpoiMemoryStream())
- {
- doc.Write(memoryStream);
- byte[] excelData = memoryStream.ToArray();
- using (var archive = new ZipArchive(zipFile, ZipArchiveMode.Update))
- {
- archive.CreateEntry($"{searchModel.C_ID}点检详情.docx").Open().Write(excelData, 0, excelData.Length);
- }
- }
- }
- }
- string emailName = $"{searchModel.DevName}-点检详情";
- using (var zipFile1 = new FileStream(zipPaht, FileMode.Open))
- {
- await Task.Run(() =>
- {
- EmailHelper.SendEmail(searchModel.Mails, emailName, "", "详情见附件", $"{emailName}.zip", "application/zip", zipFile1);
- });
- }
- System.IO.File.Delete(zipPaht);
- return new ApiResult(ReturnCode.Success);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- }
- }
|