using DOAN.Service.Mobile.IService;
using Infrastructure.Converter;
using Microsoft.AspNetCore.Mvc;
namespace DOAN.Admin.WebApi.Controllers.Mobile;
///
/// 工序流转卡
///
[AllowAnonymous]
[Route("mobile/reportflow")]
public class ReportFlowController : BaseController
{
//IReportFlowService
private readonly IReportFlowService _reportFlowService;
public ReportFlowController(IReportFlowService reportFlowService)
{
_reportFlowService = reportFlowService;
}
///
/// 根据指定日期获取工单列表
///
///
///
///
///
[HttpGet("get_workorders_by_date")]
public IActionResult GetWorkOrdersByDate(DateTime startDate, DateTime endDate)
{
startDate = DOANConvertDate.ConvertLocalDate(startDate);
endDate = DOANConvertDate.ConvertLocalDate(endDate);
if(startDate == DateTime.MinValue||endDate==DateTime.MinValue)
{
throw new CustomException("date is error");
}
var response = _reportFlowService.GetWorkOrdersByDate(startDate, endDate);
return SUCCESS(response);
}
//TODO 查询工单详情
///
/// 查询工单详情
///
/// 工单号
///
///
[HttpGet("get_workorder_detail")]
public IActionResult GetWorkOrderDetail(string workOrder)
{
if (string.IsNullOrEmpty(workOrder))
throw new CustomException("workOrderId 是空");
var response = _reportFlowService.GetWorkOrderDetail(workOrder);
if (response == null)
{
return ToResponse(ResultCode.SUCCESS, "工单不存在");
}
return SUCCESS(response);
}
//TODO 查询工序报工详情
///
/// 查询某个工序报工详情
///
///
///
///
///
[HttpGet("get_process_reportwork_detail")]
public IActionResult GetProcessReportWorkDetail(string workorder, int processId)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder is null");
}
return ToResponse(ResultCode.SUCCESS,_reportFlowService.GetProcessReportWorkDetail(workorder, processId));
}
//TODO 领料工序
[HttpGet("feed_process_reportwork")]
public IActionResult FeedProcessReportwork(string workorder, int processId, int finish_num,string stove_code,string feed_order,string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
return SUCCESS(_reportFlowService.FeedProcessReportwork(workorder, processId, finish_num, stove_code, feed_order, process_operator));
}
//TODO 工序报工
///
/// 工序报工
///
///
///
///
///
///
///
[HttpGet("process_reportwork")]
public IActionResult ProcessReportWork(string workorder, int processId, int finish_num,int bad_num,string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
return SUCCESS(_reportFlowService.ProcessReportWork(workorder, processId, finish_num,bad_num, process_operator));
}
//TODO 出货工序
[HttpGet("shipment_process_reportwork")]
public IActionResult ShipmentProcessReportwork(string workorder, int processId, int finish_num, int bad_num, string customer_order, string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
return SUCCESS(_reportFlowService.ShipmentProcessReportwork(workorder, processId, finish_num, bad_num, customer_order, process_operator));
}
//TODO 获取工单下的报工列表
[HttpGet("get_workorder_reportwork_list")]
public IActionResult GetWorkOrderReportWorkList(string workorder)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder is null");
}
return SUCCESS(_reportFlowService.GetWorkOrderReportWorkList(workorder));
}
//TODO 输入姓名拼音,查询此人今日报工记录
[HttpGet("get_report_info_by_name")]
public IActionResult GetReportInfoByName(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new CustomException("name is null");
}
var response= _reportFlowService.GetReportInfoByName(name);
return SUCCESS(response);
}
//TODO 根据工艺路线获取所有工序
[HttpGet("get_process_by_route")]
public IActionResult GetProcessByRoute(int route_id=32)
{
var response = _reportFlowService.GetProcessByRoute(route_id);
return SUCCESS(response);
}
//TODO 输入工序id 查询今天报工记录
[HttpGet("get_report_by_processid")]
public IActionResult GetReportByProcessId(int processId)
{
if (processId <= 0) {
throw new CustomException("processId is error");
}
var response = _reportFlowService.GetReportByProcessId(processId);
return SUCCESS(response);
}
}