155 lines
4.9 KiB
C#
155 lines
4.9 KiB
C#
using Infrastructure.Extensions;
|
||
using JinianNet.JNTemplate;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.IdentityModel.Tokens;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.Text.Json;
|
||
using ZR.Admin.WebApi.Extensions;
|
||
using ZR.Admin.WebApi.Filters;
|
||
using ZR.Model.mes.md;
|
||
using ZR.Model.mes.pro;
|
||
using ZR.Model.MES.pro.DTO;
|
||
using ZR.Service.mes.pro;
|
||
using ZR.Service.mes.pro.IService;
|
||
using ZR.Service.MES.md;
|
||
|
||
|
||
namespace ZR.Admin.WebApi.Controllers.MES.pro
|
||
{
|
||
|
||
[Route("mes/pro/workorder")]
|
||
public class ProWorkorderController : BaseController
|
||
{
|
||
private readonly IProWorkorderService proWorkorderService;
|
||
|
||
public ProWorkorderController(IProWorkorderService proWorkorderService)
|
||
{
|
||
this.proWorkorderService = proWorkorderService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取所有非排产工单
|
||
/// </summary>
|
||
/// <param name="pageNum"></param>
|
||
/// <param name="pageSize"></param>
|
||
/// <param name="year"></param>
|
||
/// <param name="week"></param>
|
||
/// <param name="date"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("getworkorderListwithoutschedule")]
|
||
public IActionResult GetWorkorderListWithoutSchedule(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||
{
|
||
(List<ProWorkorder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 甘特图
|
||
/// </summary>
|
||
/// <param name="year"></param>
|
||
/// <param name="week"></param>
|
||
/// <param name="date"></param>
|
||
/// <returns></returns>
|
||
|
||
[HttpGet("GetGanttList")]
|
||
public IActionResult GetGanttList(int year = -1, int week = -1, int date = -1)
|
||
{
|
||
GanttTaskDTO data = proWorkorderService.GetGanttList(year, week, date);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 获取所有排产工单
|
||
/// </summary>
|
||
/// <param name="pageNum"></param>
|
||
/// <param name="pageSize"></param>
|
||
/// <param name="year"></param>
|
||
/// <param name="week"></param>
|
||
/// <param name="date"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("getworkorderListwithschedule")]
|
||
public IActionResult GetWorkorderListWithSchedule(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||
{
|
||
(List<ProWorkorder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 1);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据工单ID,设置为排产状态
|
||
/// </summary>
|
||
/// <param name="id">工单ID</param>
|
||
/// <param name="arrange_starttime">预计开始时间</param>
|
||
/// <param name="arrange_endtime">预计结束时间</param>
|
||
/// <returns></returns>
|
||
[HttpGet("setschedule")]
|
||
public IActionResult SetSchedule(string id, DateTime arrange_starttime, DateTime arrange_endtime)
|
||
{
|
||
|
||
|
||
int data = proWorkorderService.SetWorkorderSechedule(id, arrange_starttime, arrange_endtime);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据工单ID,设置为非排产状态
|
||
/// </summary>
|
||
/// <param name="id">工单ID</param>
|
||
/// <returns></returns>
|
||
[HttpGet("resetschedule/{id}")]
|
||
public IActionResult ResetSchedule(string id)
|
||
{
|
||
|
||
int data = proWorkorderService.ResetWorkorderSechedule(id);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 下达开始领料指令
|
||
/// </summary>
|
||
/// <param name="id">工单ID</param>
|
||
/// <returns></returns>
|
||
[HttpGet("releaseProduction/{id}")]
|
||
public IActionResult ReleaseProduction(string id)
|
||
{
|
||
|
||
int data = proWorkorderService.ReleaseProduction(id, HttpContext);
|
||
|
||
return ToResponse(new ApiResult(200, "success", data));
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 对当前的,排产工单排序
|
||
/// </summary>
|
||
/// <param name="parameter">列表参数,一个是工单ID,一个是排序号</param>
|
||
/// <returns></returns>
|
||
[HttpPost("sortschedule")]
|
||
public IActionResult SortSchedule([FromBody] List<ProWorkorderSortDTO> parameter)
|
||
{
|
||
int sum = 0;
|
||
foreach (ProWorkorderSortDTO item in parameter)
|
||
{
|
||
if(!string.IsNullOrEmpty(item.id))
|
||
{
|
||
int data = proWorkorderService.SortWorkorderSchedule(item.id, item.order);
|
||
sum += data;
|
||
}
|
||
}
|
||
|
||
return ToResponse(new ApiResult(200, "success", sum));
|
||
}
|
||
}
|
||
}
|