2025-10-16 19:51:53 +08:00
|
|
|
|
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>
|
|
|
|
|
|
/// 日计划达成率
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Verify]
|
|
|
|
|
|
[Route("mes/productManagement/ProPlanAchievementrate")]
|
|
|
|
|
|
public class ProPlanAchievementrateController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 日计划达成率接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IProPlanAchievementrateService _ProPlanAchievementrateService;
|
|
|
|
|
|
|
|
|
|
|
|
public ProPlanAchievementrateController(IProPlanAchievementrateService ProPlanAchievementrateService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_ProPlanAchievementrateService = ProPlanAchievementrateService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询日计划达成率列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
|
|
|
|
|
public IActionResult QueryProPlanAchievementrate([FromQuery] ProPlanAchievementrateQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.GetList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-17 17:55:35 +08:00
|
|
|
|
//TODO 月度统计分类聚合
|
|
|
|
|
|
[HttpPost("month_list")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
|
|
|
|
|
public IActionResult QueryProPlanAchievementrateByMonth([FromQuery] ProPlanAchievementrateQueryDto2 parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.GetListByMonth(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-16 19:51:53 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询日计划达成率详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{Id}")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:query")]
|
|
|
|
|
|
public IActionResult GetProPlanAchievementrate(int Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.GetInfo(Id);
|
2025-10-23 18:42:23 +08:00
|
|
|
|
|
2025-10-16 19:51:53 +08:00
|
|
|
|
var info = response.Adapt<ProPlanAchievementrate>();
|
|
|
|
|
|
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<ProPlanAchievementrate>().ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.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<ProPlanAchievementrate>().ToUpdate(HttpContext);
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.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 = _ProPlanAchievementrateService.Delete(idsArr);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-23 17:35:22 +08:00
|
|
|
|
//TODO 根据日期和工单 生成日计划达成率
|
|
|
|
|
|
[HttpPost("dayofplanachievementrate")]
|
|
|
|
|
|
public IActionResult DayofplanAchievementRate([FromBody] ProPlanAchievementrateQueryDto3 parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _ProPlanAchievementrateService.DayofplanAchievementRate(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-23 18:42:23 +08:00
|
|
|
|
//TODO 导出模板
|
|
|
|
|
|
[HttpGet("importTemplate")]
|
2025-10-23 20:12:40 +08:00
|
|
|
|
[Log(Title = "计划达成率模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
2025-10-23 18:42:23 +08:00
|
|
|
|
[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]
|
2025-10-23 19:13:49 +08:00
|
|
|
|
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile, [FromForm(Name = "importDate")] DateTime importDate)
|
2025-10-23 18:42:23 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (formFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2025-10-23 21:00:39 +08:00
|
|
|
|
int response = _ProPlanAchievementrateService.ImportData(formFile, HttpContext.GetName(), importDate);
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 18:42:23 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 18:42:23 +08:00
|
|
|
|
//TODO 导出excel 某天
|
2025-10-23 20:12:40 +08:00
|
|
|
|
[HttpGet("exportData")]
|
|
|
|
|
|
[Log(Title = "计划达成率导出", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ExportData([FromQuery] DateTime exportDate)
|
|
|
|
|
|
{
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 21:00:39 +08:00
|
|
|
|
var excelBytes = _ProPlanAchievementrateService.ExportData(exportDate);
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 20:12:40 +08:00
|
|
|
|
string fileName = $"PlanAchievementRate_{exportDate:yyyyMMdd}.xlsx";
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 20:12:40 +08:00
|
|
|
|
return File(
|
2025-10-23 21:00:39 +08:00
|
|
|
|
excelBytes,
|
2025-10-23 20:12:40 +08:00
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
|
fileName
|
|
|
|
|
|
);
|
2025-10-23 17:35:22 +08:00
|
|
|
|
|
2025-10-23 20:12:40 +08:00
|
|
|
|
}
|
2025-10-16 19:51:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|