feat: 添加工单管理服务及相关测试

refactor: 重构工单服务接口和实现
test: 添加工单服务的单元测试和集成测试
This commit is contained in:
2026-01-28 17:54:15 +08:00
parent 4d5893d124
commit 4f91390d01
21 changed files with 2379 additions and 1481 deletions

View File

@@ -36,8 +36,6 @@ namespace DOAN.Admin.WebApi.Controllers
[ActionPermissionFilter(Permission = "productManagement:proworkorder:list")]
public IActionResult QueryProWorkorder([FromBody] ProWorkorderQueryDto parm)
{
var response = _ProWorkorderService.GetList(parm);
return SUCCESS(response);
}
@@ -52,13 +50,12 @@ namespace DOAN.Admin.WebApi.Controllers
public IActionResult QueryProWorkorder_NOCheck([FromBody] ProWorkorderQueryDto parm)
{
parm.WorkorderDate[0] = DOANConvertDate.ConvertLocalDate(parm.WorkorderDate[0]);
parm.WorkorderDate[1]= DOANConvertDate.ConvertLocalDate(parm.WorkorderDate[1]);
parm.WorkorderDate[1] = DOANConvertDate.ConvertLocalDate(parm.WorkorderDate[1]);
var response = _ProWorkorderService.GetList_NOCheck(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询生产工单详情
/// </summary>
@@ -75,7 +72,7 @@ namespace DOAN.Admin.WebApi.Controllers
}
/// <summary>
/// 添加生产工单
/// 添加生产工单
/// </summary>
/// <returns></returns>
[HttpPost]
@@ -115,7 +112,10 @@ namespace DOAN.Admin.WebApi.Controllers
public IActionResult DeleteProWorkorder(string ids)
{
string[] idsArr = Tools.SpitStrArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
if (idsArr.Length <= 0)
{
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
}
var response = _ProWorkorderService.Delete(idsArr);
@@ -140,7 +140,6 @@ namespace DOAN.Admin.WebApi.Controllers
// return SUCCESS(response);
//}
/// <summary>
/// 插入工单/或者新增工单 启用9/14
/// </summary>
@@ -159,8 +158,6 @@ namespace DOAN.Admin.WebApi.Controllers
var response = _ProWorkorderService.Insert_workOrder(newparm, parm.next_id);
return SUCCESS(response);
}
/// <summary>
@@ -186,7 +183,12 @@ namespace DOAN.Admin.WebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "生产工单导入模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
[Log(
Title = "生产工单导入模板",
BusinessType = BusinessType.EXPORT,
IsSaveRequestData = true,
IsSaveResponseData = false
)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
@@ -200,11 +202,15 @@ namespace DOAN.Admin.WebApi.Controllers
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns>导入成功数 若-1 则excel读取异常</returns>
[HttpPost("importData")]
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[Log(
Title = "生产工单导入",
BusinessType = BusinessType.IMPORT,
IsSaveRequestData = false,
IsSaveResponseData = true
)]
[AllowAnonymous]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
if (formFile == null)
{
return SUCCESS(null);
@@ -212,18 +218,19 @@ namespace DOAN.Admin.WebApi.Controllers
int response = _ProWorkorderService.ImportData(formFile, HttpContext.GetName());
return SUCCESS(response);
}
//TODO 分批导入工单,追加工单
[HttpPost("importData_append")]
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[Log(
Title = "生产工单导入",
BusinessType = BusinessType.IMPORT,
IsSaveRequestData = false,
IsSaveResponseData = true
)]
[AllowAnonymous]
public IActionResult ImportDataAppend([FromForm(Name = "file")] IFormFile formFile)
{
if (formFile == null)
{
return SUCCESS(null);
@@ -231,12 +238,8 @@ namespace DOAN.Admin.WebApi.Controllers
int response = _ProWorkorderService.ImportDataAppend(formFile, HttpContext.GetName());
return SUCCESS(response);
}
/// <summary>
/// 工单导出 启用9/14
/// </summary>
@@ -251,9 +254,9 @@ namespace DOAN.Admin.WebApi.Controllers
{
return SUCCESS(null);
}
var list = _ProWorkorderService.WorkOrderExport(extportDate, new PagerInfo(1, 10000));
var list = _ProWorkorderService.WorkOrderExport(extportDate);
var result = ExportExcelMini(list.Result, "workorder", "工单列表");
var result = ExportExcelMini(list, "workorder", "工单列表");
return ExportExcel(result.Item2, result.Item1);
}
@@ -267,10 +270,8 @@ namespace DOAN.Admin.WebApi.Controllers
}
var response = _ProWorkorderService.GetMaterialInfo(query);
return SUCCESS(response);
}
//TODO 获取客户
[HttpPost("get_custom")]
public IActionResult GetCustomInfo([FromBody] BaseCustomQueryDto2 parm)
@@ -283,7 +284,6 @@ namespace DOAN.Admin.WebApi.Controllers
return SUCCESS(response);
}
//TODO 获取指定日期工艺路线
[HttpGet("get_process_route")]
public IActionResult GetProcessRoute(DateTime dateTime)
@@ -291,7 +291,6 @@ namespace DOAN.Admin.WebApi.Controllers
if (dateTime == DateTime.MinValue)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetProcessRoute(dateTime);
@@ -338,37 +337,44 @@ namespace DOAN.Admin.WebApi.Controllers
[HttpGet("search_BOM_num")]
public IActionResult SearchBOMNum(string workorder_num)
{
if (string.IsNullOrEmpty(workorder_num)) { return SUCCESS(null); }
if (string.IsNullOrEmpty(workorder_num))
{
return SUCCESS(null);
}
var response = _ProWorkorderService.SearchBOMNum(workorder_num);
return SUCCESS(response);
}
//TODO 工单变更日志
[HttpGet("workorder_log")]
public IActionResult WorkOrderLog(string workorder, string log)
{
if (string.IsNullOrEmpty(workorder)) { return SUCCESS(null); }
if (string.IsNullOrEmpty(workorder))
{
return SUCCESS(null);
}
var response = _ProWorkorderService.WorkOrderLog(workorder, log, HttpContext.GetName());
return SUCCESS(response);
}
//TODO 获取工单进度追溯
[HttpPost("get_workorder_trace_progress")]
public IActionResult GetWorkorderTraceProgressList([FromBody]ProWorkorderQueryDto query)
public IActionResult GetWorkorderTraceProgressList([FromBody] ProWorkorderQueryDto query)
{
query.WorkorderDate[0] = DOANConvertDate.ConvertLocalDate(query.WorkorderDate[0]);
query.WorkorderDate[1] = DOANConvertDate.ConvertLocalDate(query.WorkorderDate[1]);
if (query == null) { throw new Exception("query为空"); }
var response= _ProWorkorderService.GetWorkorderTraceProgressList(query);
if (query == null)
{
throw new Exception("query为空");
}
var response = _ProWorkorderService.GetWorkorderTraceProgressList(query);
return SUCCESS(response);
}
//TODO 打印机打印工单
[HttpPost("print")]
[AllowAnonymous]
public async Task<IActionResult> ExportWorkorderPDF([FromBody] ProWorkorderExportDto param)
@@ -390,12 +396,6 @@ namespace DOAN.Admin.WebApi.Controllers
{
return ToResponse(500, ex.Message);
}
}
}
}