173 lines
6.7 KiB
C#
173 lines
6.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using DOAN.Model.Dto;
|
||
using DOAN.Service.MES.product.IService;
|
||
using DOAN.Service.MES.product;
|
||
using DOAN.Admin.WebApi.Filters;
|
||
using DOAN.Model.MES.product.Dto;
|
||
using DOAN.Model.MES.product;
|
||
|
||
//创建时间:2025-10-16
|
||
namespace DOAN.Admin.WebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 日计划达成率 版本2
|
||
/// </summary>
|
||
[Verify]
|
||
|
||
[Route("mes/productManagement/ProPlanAchievementrateVersion2")]
|
||
public class ProPlanAchievementrateVersion2Controller : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 日计划达成率接口
|
||
/// </summary>
|
||
private readonly IProPlanAchievementrateVersion2Service _ProPlanAchievementrateVersion2Service;
|
||
|
||
public ProPlanAchievementrateVersion2Controller(IProPlanAchievementrateVersion2Service ProPlanAchievementrateService)
|
||
{
|
||
_ProPlanAchievementrateVersion2Service = ProPlanAchievementrateService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询日计划达成率列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
||
public IActionResult QueryProPlanAchievementrate([FromQuery] ProPlanAchievementrateQueryDto parm)
|
||
{
|
||
var response = _ProPlanAchievementrateVersion2Service.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
//TODO 月度统计分类聚合
|
||
[HttpPost("month_list")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
||
public IActionResult QueryProPlanAchievementrateByMonth([FromQuery] ProPlanAchievementrateQueryDto2 parm)
|
||
{
|
||
var response = _ProPlanAchievementrateVersion2Service.GetListByMonth(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询日计划达成率详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:query")]
|
||
public IActionResult GetProPlanAchievementrate(int Id)
|
||
{
|
||
var response = _ProPlanAchievementrateVersion2Service.GetInfo(Id);
|
||
|
||
var info = response.Adapt<ProPlanAchievementrateVersion2>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加日计划达成率
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:add")]
|
||
[Log(Title = "日计划达成率", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddProPlanAchievementrate([FromBody] ProPlanAchievementrateDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProPlanAchievementrateVersion2>().ToCreate(HttpContext);
|
||
|
||
var response = _ProPlanAchievementrateVersion2Service.AddProPlanAchievementrate(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新日计划达成率
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:edit")]
|
||
[Log(Title = "日计划达成率", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateProPlanAchievementrate([FromBody] ProPlanAchievementrateDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProPlanAchievementrateVersion2>().ToUpdate(HttpContext);
|
||
var response = _ProPlanAchievementrateVersion2Service.UpdateProPlanAchievementrate(modal);
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除日计划达成率
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpDelete("{ids}")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:delete")]
|
||
[Log(Title = "日计划达成率", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteProPlanAchievementrate(string ids)
|
||
{
|
||
int[] idsArr = Tools.SpitIntArrary(ids);
|
||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||
|
||
var response = _ProPlanAchievementrateVersion2Service.Delete(idsArr);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
|
||
|
||
//TODO 根据日期和工单 生成日计划达成率
|
||
[HttpPost("dayofplanachievementrate")]
|
||
public IActionResult DayofplanAchievementRate([FromBody] ProPlanAchievementrateQueryDto3 parm)
|
||
{
|
||
var response = _ProPlanAchievementrateVersion2Service.DayofplanAchievementRate(parm);
|
||
return SUCCESS(response);
|
||
|
||
}
|
||
|
||
//TODO 导出模板
|
||
[HttpGet("importTemplate")]
|
||
[Log(Title = "计划达成率模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||
[AllowAnonymous]
|
||
public IActionResult ImportTemplateExcel()
|
||
{
|
||
(string, string) result = DownloadImportTemplate("PlanAchievementRate");
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
//TODO 导入excel 某天
|
||
[HttpPost("importData")]
|
||
[Log(Title = "计划达成率导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
||
[AllowAnonymous]
|
||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile, [FromForm(Name = "importDate")] DateTime importDate)
|
||
{
|
||
|
||
if (formFile == null)
|
||
{
|
||
return SUCCESS(null);
|
||
}
|
||
int response = _ProPlanAchievementrateVersion2Service.ImportData(formFile, HttpContext.GetName(), importDate);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
//TODO 导出excel 某天
|
||
[HttpGet("exportData")]
|
||
[Log(Title = "计划达成率导出", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||
[AllowAnonymous]
|
||
public IActionResult ExportData([FromQuery] DateTime exportDate)
|
||
{
|
||
if(exportDate == null || exportDate == DateTime.MinValue)
|
||
{
|
||
return ToResponse(ApiResult.Error("导出失败,日期不能为空"));
|
||
}
|
||
var excelBytes = _ProPlanAchievementrateVersion2Service.ExportData(exportDate);
|
||
string fileName = $"PlanAchievementRate_{exportDate:yyyyMMdd}.xlsx";
|
||
return File(
|
||
excelBytes,
|
||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||
fileName
|
||
);
|
||
|
||
}
|
||
}
|
||
} |