271 lines
9.6 KiB
C#
Raw Normal View History

2024-11-06 13:49:57 +08:00
using DOAN.Service.JobKanban.IService;
2024-11-07 10:58:06 +08:00
using Infrastructure.Converter;
2024-11-06 13:49:57 +08:00
using Microsoft.AspNetCore.Mvc;
namespace DOAN.WebApi.Controllers.JobKanban;
/// <summary>
2024-12-26 16:25:01 +08:00
/// 工单进度接口
2024-11-06 13:49:57 +08:00
/// </summary>
[AllowAnonymous]
[Route("kanban/workorderProgress")]
public class WorkOrderProgressController : BaseController
2024-09-19 09:34:54 +08:00
{
2024-11-06 13:49:57 +08:00
private readonly IWorkorderProgressService workorderProgressService;
public WorkOrderProgressController(IWorkorderProgressService workorderProgressService)
{
this.workorderProgressService = workorderProgressService;
}
//TODO 获取产线
[HttpGet("get_routes")]
public IActionResult GetRoutes()
{
var response = workorderProgressService.GetRoutes();
return SUCCESS(response);
}
//TODO 获取班组
[HttpGet("get_group")]
public IActionResult GetGroups()
{
var response = workorderProgressService.GetGroups();
return SUCCESS(response);
}
2024-12-26 16:25:01 +08:00
//TODO 根据班组,产线 和日期获取all报工记录
2024-11-07 10:58:06 +08:00
[HttpGet("get_report_record")]
public IActionResult GetReportWorkRecord(string group_code, string line_code, DateTime handleDate)
2024-11-06 13:49:57 +08:00
{
if (string.IsNullOrEmpty(group_code) || string.IsNullOrEmpty(line_code) || handleDate == DateTime.MinValue)
return SUCCESS(null);
2024-11-07 10:58:06 +08:00
handleDate= DOANConvertDateTime.ConvertLocalDate(handleDate);
var response = workorderProgressService.GetReportWorkRecord(group_code, line_code, handleDate);
2024-11-06 13:49:57 +08:00
return SUCCESS(response);
}
2024-09-19 09:34:54 +08:00
/// <summary>
2026-01-22 11:07:21 +08:00
/// 工单list (未完成的)
2024-09-19 09:34:54 +08:00
/// </summary>
2024-11-06 13:49:57 +08:00
/// <param name="today"></param>
/// <param name="LineCode"></param>
/// <returns></returns>
[HttpGet("get_workorder_nofinish")]
public IActionResult GetWorkOrderListNoFinish(DateTime today, string line_code, string group_code)
{
if (today == DateTime.MinValue || string.IsNullOrEmpty(line_code) || string.IsNullOrEmpty(group_code))
return SUCCESS(null);
var response = workorderProgressService.GetWorkOrderListNoFinish(today, line_code, group_code);
return SUCCESS(response);
}
2024-11-14 16:47:47 +08:00
2024-11-07 16:45:06 +08:00
//TODO 获取全部工单
//TODO 根据班组 ,产线 和日期获取all工单
[HttpGet("get_workorder_list")]
public IActionResult GetWorkOrderList(string group_code, string line_code, DateTime handleDate)
{
if (string.IsNullOrEmpty(group_code) || string.IsNullOrEmpty(line_code) || handleDate == DateTime.MinValue)
return SUCCESS(null);
var response = workorderProgressService.GetWorkOrderList(group_code, line_code, handleDate);
return SUCCESS(response);
}
2024-11-06 13:49:57 +08:00
// 获取工单详情
[HttpGet("get_workorder_detail")]
public IActionResult GetWorkOrderDetail(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = workorderProgressService.GetWorkOrderDetail(workorder);
return SUCCESS(response);
}
// 获取今日总任务数 ,剩余任务数
[HttpGet("get_num_list")]
public IActionResult GetKanbanNum(DateTime today, string line_code, string group_code)
{
if (today == DateTime.MinValue || string.IsNullOrEmpty(line_code) || string.IsNullOrEmpty(group_code))
return SUCCESS(null);
var response = workorderProgressService.GetKanbanNum(today, line_code, group_code);
return SUCCESS(response);
}
//TODO 开始某个工单
[HttpGet("start_workorder")]
2025-12-10 19:05:52 +08:00
public async Task<IActionResult> StartWorkOrder(string workorder)
2024-11-06 13:49:57 +08:00
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
2025-12-10 19:05:52 +08:00
var response = await workorderProgressService.StartWorkOrder(workorder);
2024-11-06 13:49:57 +08:00
return SUCCESS(response);
}
2026-01-22 11:07:21 +08:00
//TODO 暂停某个工单
[HttpGet("pause_workorder")]
public IActionResult PauseWorkOrder(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = workorderProgressService.PauseWorkOrder(workorder);
return SUCCESS(response);
}
//TODO 恢复某个工单
[HttpGet("recover_workorder")]
public IActionResult RecoverWorkOrder(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = workorderProgressService.RecoverWorkOrder(workorder);
return SUCCESS(response);
}
2024-11-06 13:49:57 +08:00
//TODO 完成某一个工单
[HttpGet("finish_workorder")]
public IActionResult FinishWorkOrder(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = workorderProgressService.FinishWorkOrder(workorder);
return SUCCESS(response);
}
2026-01-22 11:07:21 +08:00
/// <summary>
/// TODO 完成 工单
/// </summary>
/// <param name="workorder"></param>
/// <returns></returns.
[HttpGet("finish_workorder2")]
public IActionResult FinishWorkorder(string workorder, int finish_num)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = workorderProgressService.FinishWorkorder(workorder, finish_num);
return SUCCESS(response);
}
2024-11-06 13:49:57 +08:00
//TODO 获取某条产线 某个日期,某个班组的生产中的工单 上位机接口 (废弃)
[HttpGet("get_producting_workorder")]
public IActionResult GetProductingWorkorder(string line_code, DateTime handleDate)
{
if (string.IsNullOrEmpty(line_code) || handleDate < DateTime.MinValue.AddMonths(1))
return ToResponse(new ApiResult(210, "paramter is null", -1));
var response = workorderProgressService.GetProductingWorkorder(line_code, handleDate);
if (response == null)
return ToResponse(new ApiResult(210, "There is no ongoing any workorder, please contact doan",
2024-11-06 13:49:57 +08:00
"no_workorder"));
return SUCCESS(response);
}
//TODO 添加标签日志 上位机接口 (废弃)
[HttpGet("add_label_log")]
public IActionResult AddLabelLog(string labelContext, string workOrder)
2024-09-19 09:34:54 +08:00
{
2024-11-06 13:49:57 +08:00
if (string.IsNullOrEmpty(labelContext) || string.IsNullOrEmpty(workOrder))
return ToResponse(new ApiResult(210, "paramter is null", -1));
var response = workorderProgressService.AddLabelLog(labelContext, workOrder);
2024-11-06 13:49:57 +08:00
return SUCCESS(response);
}
2024-11-06 13:49:57 +08:00
//TODO 扫码校验判断标签是否与当前工单匹配 0 不匹配 1匹配 (废弃)
[HttpGet("label_workorder_match")]
public IActionResult LabelWorkOrderMatch(string LabelContext, string workOrder)
{
if (string.IsNullOrEmpty(LabelContext) || string.IsNullOrEmpty(workOrder)) return SUCCESS(null);
var response = workorderProgressService.LabelWorkOrderMatch(LabelContext, workOrder);
return SUCCESS(response);
2024-09-19 09:34:54 +08:00
}
2024-11-06 13:49:57 +08:00
//TODO 防错并且报工
/// <summary>
/// 防错并且报工
/// </summary>
/// <param name="workorder"></param>
/// <param name="labelContext"></param>
2025-01-07 11:37:15 +08:00
/// <returns> -1 此产品不属于此工单 -2 长度不是36个字符 0 报工失败 1 成功报工 </returns>
2024-11-06 13:49:57 +08:00
/// <exception cref="CustomException"></exception>
[HttpGet("errorProofingAndReportingWork")]
public IActionResult ErrorProofingAndReportingWork(string workorder, string labelContext)
{
if (string.IsNullOrEmpty(labelContext) || string.IsNullOrEmpty(workorder))
throw new CustomException("workorder或者labelContext为空");
var response = workorderProgressService.ErrorProofingAndReportingWork(workorder, labelContext);
return SUCCESS(response);
}
2024-09-19 09:34:54 +08:00
2024-11-14 16:47:47 +08:00
2026-01-22 11:07:21 +08:00
//TODO 获取工单进度
2024-11-06 15:10:26 +08:00
/// <summary>
///
/// </summary>
/// <param name="workorder"></param>
/// <returns> 1 是计算数量 2 完成数量</returns>
/// <exception cref="CustomException"></exception>
[HttpGet("get_workorder_progress")]
public IActionResult GetWorkOrderProgress(string workorder)
{
if (string.IsNullOrEmpty(workorder)) throw new CustomException("workorder is null");
var response = workorderProgressService.GetWorkOrderProgress(workorder);
2024-11-06 13:49:57 +08:00
return SUCCESS(response);
}
//TODO 获取工单开始时间 和计划耗时(分钟)
[HttpGet("get_workorder_time")]
public IActionResult GetWorkOrderTime(string workorder)
{
if (string.IsNullOrEmpty(workorder)) throw new CustomException("workorder is null");
var response = workorderProgressService.GetWorkOrderTime(workorder);
return SUCCESS(response);
}
2024-11-07 11:35:17 +08:00
//TODO 查询工单下的扫描条码信息
[HttpGet("get_scan_code_info")]
2024-11-07 11:35:17 +08:00
public IActionResult GetWorkOrderScanCodeInfo(string workorder)
{
if (string.IsNullOrEmpty(workorder)) throw new CustomException("workorder is null");
var response = workorderProgressService.GetWorkOrderScanCodeInfo(workorder);
return SUCCESS(response);
}
2025-04-10 16:51:14 +08:00
//TODO 切换工单时校验,前工单的末标签是否校验成功通过
[HttpGet("switch_workorder_checkLabel")]
public IActionResult SwitchWorkOrderCheckLabel(string pre_workorder)
{
if (string.IsNullOrEmpty(pre_workorder)) throw new CustomException("workorder is null");
var response = workorderProgressService.SwitchWorkOrderCheckLabel(pre_workorder);
return SUCCESS(response);
}
2025-04-10 17:46:08 +08:00
2026-01-22 11:07:21 +08:00
//TODO 当天每小时目标产量和实际产量
[HttpGet("get_hourly_production")]
public IActionResult GetHourlyProduction(string groupCode)
{
if (string.IsNullOrEmpty(groupCode)) throw new CustomException("groupCode is null");
var response = workorderProgressService.GetHourlyProduction(groupCode);
return SUCCESS(response);
}
2025-04-10 17:46:08 +08:00
2024-11-06 13:49:57 +08:00
}