huanghongfeng
2025-01-24 829eabf256e29392ca63f6da48829dba3b075dfe
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoDetailService.cs
@@ -1,4 +1,5 @@
锘縰sing Magicodes.ExporterAndImporter.Core;
锘縰sing AutoMapper;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using SqlSugar;
using System;
@@ -7,16 +8,21 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_IRecordService;
using WIDESEA_IStockRepository;
using WIDESEA_IStockService;
using WIDESEA_ITaskInfoRepository;
using WIDESEA_Model.Models;
namespace WIDESEA_StockService
{
    public partial class StockInfoDetailService : ServiceBase<Dt_StockInfoDetail, IStockInfoDetailRepository>, IStockInfoDetailService
    {
        public bool ExistSerialNumber(string SerialNumber)
        {
            return BaseDal.QueryFirst(x => x.SerialNumber == SerialNumber) != null;
@@ -27,33 +33,6 @@
            return BaseDal.QueryFirst(x => SerialNumbers.Contains(x.SerialNumber)) != null;
        }
        //瀵煎嚭
        public override WebResponseContent Export(PageDataOptions options)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport";
                IExporter exporter = new ExcelExporter();
                //娣诲姞鏉′欢
                string wheres = options.ValidatePageOptions(TProperties);
                //鑾峰彇鎺掑簭瀛楁
                Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(TProperties);
                List<Dt_StockInfoDetail> entities = BaseDal.QueryData(wheres, orderbyDic);
                byte[] data = exporter.ExportAsByteArray(entities).Result;
                string fileName = "1.xlsx";
                FileHelper.WriteFile(savePath, fileName, data);
                content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
    }
}