2025-08-29 13:09:14 +08:00
|
|
|
|
using DOAN.Admin.WebApi.Filters;
|
2025-09-05 11:44:50 +08:00
|
|
|
|
using DOAN.Model;
|
2025-09-29 21:19:49 +08:00
|
|
|
|
using DOAN.Model.MES.product;
|
2025-09-05 11:38:27 +08:00
|
|
|
|
using DOAN.Model.MES.product.Dto;
|
2025-08-29 13:09:14 +08:00
|
|
|
|
using DOAN.Service.MES.group.IService;
|
|
|
|
|
|
using DOAN.Service.MES.product;
|
|
|
|
|
|
using DOAN.Service.MES.product.IService;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DOAN.WebApi.Controllers.MES.product
|
|
|
|
|
|
{
|
2025-09-10 16:19:55 +08:00
|
|
|
|
[Verify]
|
2025-09-10 15:47:17 +08:00
|
|
|
|
[Route("mes/productManagement/Proweekplan")]
|
2025-08-29 13:09:14 +08:00
|
|
|
|
public class ProweekplanManageController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 周计划表接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IProweekplanManageService _proweekplanManageService;
|
|
|
|
|
|
|
|
|
|
|
|
public ProweekplanManageController(IProweekplanManageService proweekplanManageService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_proweekplanManageService = proweekplanManageService;
|
|
|
|
|
|
}
|
2025-09-05 11:45:11 +08:00
|
|
|
|
|
2025-09-29 21:19:49 +08:00
|
|
|
|
//TODO 查询计划列表 年周零件号
|
2025-09-05 11:45:11 +08:00
|
|
|
|
[HttpPost("searchWeekplan")]
|
|
|
|
|
|
[Log(Title = "查询计划列表 年周零件号", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
|
|
|
|
|
public IActionResult SearchWeekplan([FromBody] WeekplanQueryDto weekplanQuery)
|
|
|
|
|
|
{
|
2025-09-09 15:51:35 +08:00
|
|
|
|
PagedInfo<ProWeeklyPlanChildDateDto> result = _proweekplanManageService.SearchWeekplan(weekplanQuery);
|
2025-09-05 11:45:11 +08:00
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
|
|
|
|
|
//TODO excel导入计划
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入周计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
|
|
|
|
|
/// <returns>导入成功数 若-1 则excel读取异常</returns>
|
|
|
|
|
|
[HttpPost("importWeekplan")]
|
|
|
|
|
|
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (formFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2025-09-09 15:51:35 +08:00
|
|
|
|
|
2025-09-05 11:44:50 +08:00
|
|
|
|
int result = _proweekplanManageService.ImportExcel(formFile, HttpContext.GetName());
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
2025-09-05 11:44:50 +08:00
|
|
|
|
return SUCCESS(result);
|
2025-08-29 13:09:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 21:19:49 +08:00
|
|
|
|
//TODO ERP导入
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入ERP
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>导入结果 1为有导入结果,0为无导入结果,-1为异常</returns>
|
|
|
|
|
|
[HttpPost("importERP")]
|
|
|
|
|
|
[Log(Title = "ERP导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ImportERP()
|
|
|
|
|
|
{
|
|
|
|
|
|
int result = _proweekplanManageService.ImportERP();
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 预览日计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datePlanRequest"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("previewDatePlan")]
|
|
|
|
|
|
[Log(Title = "预览日计划", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult PreviewDatePlan([FromBody] DatePlanRequest datePlanRequest)
|
|
|
|
|
|
{
|
|
|
|
|
|
PagedInfo<ProWorkorder> result = _proweekplanManageService.PreviewDatePlan(datePlanRequest);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 修改周计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="updateWeekPlanDto"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("importERP")]
|
|
|
|
|
|
[Log(Title = "修改周计划", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult UpdateWeekPlan(ProWeeklyPlanAndDateDto updateWeekPlanDto)
|
|
|
|
|
|
{
|
|
|
|
|
|
int result = _proweekplanManageService.UpdateWeekPlan(updateWeekPlanDto);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 是否关联
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否关联(库存、效率、箱标签)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inventory"></param>
|
|
|
|
|
|
/// <param name="efficiency"></param>
|
|
|
|
|
|
/// <param name="boxLabel"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("isAssociateOthers")]
|
|
|
|
|
|
[Log(Title = "是否关联(库存、效率、箱标签)", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult IsAssociateOthers(int inventory, int efficiency, int boxLabel)
|
|
|
|
|
|
{
|
|
|
|
|
|
int result = _proweekplanManageService.IsAssociateOthers(inventory, efficiency, boxLabel);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
|
|
|
|
|
//TODO 导出模板
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生产工单导入模板下载 workorder 启用(9/14)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("importTemplate")]
|
|
|
|
|
|
[Log(Title = "生产周计划导入模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ImportTemplateExcel()
|
|
|
|
|
|
{
|
|
|
|
|
|
(string, string) result = DownloadImportTemplate("weekplan");
|
|
|
|
|
|
return ExportExcel(result.Item2, result.Item1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-09 15:51:35 +08:00
|
|
|
|
//TODO 导出excel指定日计划
|
2025-09-10 10:04:40 +08:00
|
|
|
|
[HttpGet("ExportWeekDatePlan")]
|
2025-09-15 18:10:40 +08:00
|
|
|
|
[AllowAnonymous]
|
2025-09-10 10:04:40 +08:00
|
|
|
|
public IActionResult ExportWeekDatePlan(int year, int week, string dayofweek)
|
2025-09-09 15:51:35 +08:00
|
|
|
|
{
|
2025-09-10 10:04:40 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// 调用Service层方法获取Excel字节数组和文件名
|
|
|
|
|
|
var (fileBytes, fileName) = _proweekplanManageService.ExportWeekDatePlan(year, week, dayofweek);
|
|
|
|
|
|
|
|
|
|
|
|
// 在Controller中使用File方法返回文件下载响应
|
|
|
|
|
|
return File(
|
|
|
|
|
|
fileBytes,
|
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
|
fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
|
}
|
2025-09-09 15:51:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-18 17:58:08 +08:00
|
|
|
|
//TODO 导出excel周计划
|
|
|
|
|
|
[HttpGet("ExportWeekOrderPlan")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ExportWeekOrderPlan(int year, int week)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// 调用Service层方法获取Excel字节数组和文件名
|
|
|
|
|
|
var (fileBytes, fileName) = _proweekplanManageService.ExportWeekOrderPlan(year, week);
|
|
|
|
|
|
|
|
|
|
|
|
// 在Controller中使用File方法返回文件下载响应
|
|
|
|
|
|
return File(
|
|
|
|
|
|
fileBytes,
|
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
|
fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-08 15:21:43 +08:00
|
|
|
|
//TODO 更新本周实际装配数量进度 输入年,周,更新计划进度
|
|
|
|
|
|
[HttpGet("updateactualassemblyprogress")]
|
|
|
|
|
|
public IActionResult UpdateActualAssemblyProgress(int year, int week)
|
|
|
|
|
|
{
|
|
|
|
|
|
int result = _proweekplanManageService.UpdateActualAssemblyProgress(year, week);
|
|
|
|
|
|
return SUCCESS(result);
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
2025-09-08 15:21:43 +08:00
|
|
|
|
}
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
2025-09-29 21:19:49 +08:00
|
|
|
|
//TODO 导出日计划
|
|
|
|
|
|
[HttpGet("ExportDatePlan")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ExportDatePlan(string chooseDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// 调用Service层方法获取Excel字节数组和文件名
|
|
|
|
|
|
var (fileBytes, fileName) = _proweekplanManageService.ExportDatePlan(chooseDate);
|
2025-08-29 13:09:14 +08:00
|
|
|
|
|
2025-09-29 21:19:49 +08:00
|
|
|
|
// 在Controller中使用File方法返回文件下载响应
|
|
|
|
|
|
return File(
|
|
|
|
|
|
fileBytes,
|
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
|
fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-29 13:09:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|