renmingwang
2026-03-25 6d56bf4daf08c4c7c6d193d98ed0b547dc473451
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
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEA_Core;
using WIDESEA_Core.BaseController;
using WIDESEA_DTO.Stock;
using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
 
namespace WIDESEA_WMSServer.Controllers.TaskInfo
{
    /// <summary>
    /// 任务历史
    /// </summary>
    [Route("api/Task_Hty")]
    [ApiController]
    public class Task_HtyController : ApiBaseController<ITask_HtyService, Dt_Task_Hty>
    {
        public Task_HtyController(ITask_HtyService service) : base(service)
        {
        }
 
        /// <summary>
        /// 删除旧的历史任务数据
        /// </summary>
        /// <param name="keepMonths">保留的月数,默认为3个月(本月+后两个月)</param>
        /// <returns>删除的记录数</returns>
        [HttpGet, Route("DeleteOldHistory")]
        [AllowAnonymous]
        public IActionResult DeleteOldHistory(int keepMonths = 3)
        {
            try
            {
                int result = Service.DeleteOldTaskHistory(keepMonths);
                return Ok(new { Success = true, Message = "历史任务删除成功", DeletedCount = result });
            }
            catch (Exception ex)
            {
                return Ok(new { Success = false, Message = "历史任务删除失败: " + ex.Message });
            }
        }
    }
}