wangxinhui
2026-03-26 ad05ef2341fe19a4220f7ada1987636f9ec4a1a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
using AutoMapper;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITaskInfo_HtyRepository;
using WIDESEAWCS_ITaskInfo_HtyService;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_TaskInfo_HtyService
{
    public partial class Task_HtyService : ServiceBase<Dt_Task_Hty, ITask_HtyRepository>, ITask_HtyService
    {
        public Task_HtyService(ITask_HtyRepository BaseDal) : base(BaseDal)
        {
        }
        public override WebResponseContent Export(PageDataOptions options)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport";
 
                // 确保目录存在
                if (!Directory.Exists(savePath))
                    Directory.CreateDirectory(savePath);
 
                // 获取数据
                ISugarQueryable<Dt_Task_Hty> query = BaseDal.Db.Queryable<Dt_Task_Hty>();
                var dataList = query.ToList();
                var properties = typeof(Dt_Task_Hty).GetProperties();
                string filePath = TExportHelper.GetExport(savePath, properties, dataList);
                return WebResponseContent.Instance.OK(data: filePath);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
    }
}