189 lines
6.3 KiB
C#
189 lines
6.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using RIZO.Model.Mes.Dto.GatherData;
|
||
using RIZO.Model.Mes.Dto.WorkOrderInfo;
|
||
using RIZO.Model.Mes.WorkOrderInfo;
|
||
using RIZO.Service.Mes.IMesService.WorkOrderInfo;
|
||
using RIZO.Service.Mes.WorkOrderInfo;
|
||
|
||
//创建时间:2025-11-12
|
||
namespace RIZO.Admin.WebApi.Controllers.Mes.WorkOrderInfo
|
||
{
|
||
/// <summary>
|
||
/// 工单主表
|
||
/// </summary>
|
||
[Route("mes/WorkOrder")]
|
||
[AllowAnonymous]
|
||
public class WorkOrderController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 工单主表接口
|
||
/// </summary>
|
||
private readonly IWorkOrderService _WorkOrderService;
|
||
|
||
public WorkOrderController(IWorkOrderService WorkOrderService)
|
||
{
|
||
_WorkOrderService = WorkOrderService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询工单主表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "workorder:list")]
|
||
public IActionResult QueryWorkOrder([FromQuery] WorkOrderQueryDto parm)
|
||
{
|
||
var response = _WorkOrderService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询工单主表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "workorder:query")]
|
||
public IActionResult GetWorkOrder(long Id)
|
||
{
|
||
var response = _WorkOrderService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<WorkOrderDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加工单主表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "workorder:add")]
|
||
[Log(Title = "工单主表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddWorkOrder([FromBody] WorkOrderDto parm)
|
||
{
|
||
var modal = parm.Adapt<WorkOrder>().ToCreate(HttpContext);
|
||
|
||
var response = _WorkOrderService.AddWorkOrder(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新工单主表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "workorder:edit")]
|
||
[Log(Title = "工单主表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateWorkOrder([FromBody] WorkOrderDto parm)
|
||
{
|
||
var modal = parm.Adapt<WorkOrder>().ToUpdate(HttpContext);
|
||
var response = _WorkOrderService.UpdateWorkOrder(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除工单主表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "workorder:delete")]
|
||
[Log(Title = "工单主表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteWorkOrder([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<long>(ids);
|
||
|
||
return ToResponse(_WorkOrderService.Delete(idArr));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 扫流卡码新增工单主表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("createWorkOrderBySacnCode")]
|
||
[Log(Title = "扫码新增工单主表", BusinessType = BusinessType.INSERT)]
|
||
public ApiResult CreateWorkOrderBySacnCode([FromBody] FlowCard flowCard)
|
||
{
|
||
var response = _WorkOrderService.CreateWorkOrderBySacnCode(flowCard);
|
||
return response;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 变更工单状态
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("changeWorkOrderState")]
|
||
[Log(Title = "变更工单状态(执行中/已完成)", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult ChangeWorkOrderState([FromBody] WorkOrderState parm)
|
||
{
|
||
var response = _WorkOrderService.ChangeWorkOrderState(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出工单数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("export")]
|
||
//[ActionPermissionFilter(Permission = "processinfo:export")]
|
||
[Log(Title = "工单数据", BusinessType = BusinessType.EXPORT)]
|
||
public IActionResult Export([FromQuery] WorkOrderQueryDto parm)
|
||
{
|
||
var list = _WorkOrderService.GetListExport(parm).Result;
|
||
if (list == null || list.Count <= 0)
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||
}
|
||
var (sFileName, sFilePath) = ExportExcelMini(list, "工单数据", "工单数据");
|
||
if (string.IsNullOrWhiteSpace(sFilePath))
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "Excel生成失败");
|
||
}
|
||
return PhysicalFile(
|
||
sFilePath,
|
||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||
sFileName,
|
||
true
|
||
);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询一周折线图
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("queryQualityLineChart")]
|
||
[ActionPermissionFilter(Permission = "workorder:list")]
|
||
public IActionResult QueryQualityLineChart()
|
||
{
|
||
var response = _WorkOrderService.QueryQualityLineChart();
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询一周柱状图
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("queryQualityBarChart")]
|
||
[ActionPermissionFilter(Permission = "workorder:list")]
|
||
public IActionResult QueryQualityBarChart()
|
||
{
|
||
var response = _WorkOrderService.QueryQualityBarChart();
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询一个月工单信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("queryWorkOrderMonth")]
|
||
[ActionPermissionFilter(Permission = "workorder:list")]
|
||
public IActionResult QueryWorkOrderMonth()
|
||
{
|
||
var response = _WorkOrderService.QueryWorkOrderMonth();
|
||
return SUCCESS(response);
|
||
}
|
||
}
|
||
} |