330 lines
11 KiB
C#
Raw Normal View History

2024-07-16 14:40:02 +08:00
using Microsoft.AspNetCore.Mvc;
using DOAN.Model.MES.product;
using DOAN.Model.MES.product.Dto;
using DOAN.Service.MES.product.IService;
using DOAN.Service.MES.product;
using DOAN.Admin.WebApi.Filters;
2024-07-16 16:34:43 +08:00
using Org.BouncyCastle.Crypto;
2024-07-17 11:42:05 +08:00
using DOAN.Model.System;
using MiniExcelLibs;
2024-07-17 14:28:32 +08:00
using DOAN.Model.System.Dto;
using DOAN.Model;
2024-08-30 16:36:13 +08:00
using DOAN.Model.MES.base_.Dto;
using Microsoft.AspNetCore.Http;
2024-09-04 10:01:39 +08:00
using Aliyun.OSS;
2024-09-08 10:13:57 +08:00
using System;
2024-07-16 14:40:02 +08:00
//创建时间2024-07-16
namespace DOAN.Admin.WebApi.Controllers
{
/// <summary>
/// 生产工单
/// </summary>
[Verify]
2024-07-16 14:45:41 +08:00
[Route("mes/productManagement/ProWorkorder")]
2024-07-16 14:40:02 +08:00
public class ProWorkorderController : BaseController
{
/// <summary>
/// 生产工单接口
/// </summary>
private readonly IProWorkorderService _ProWorkorderService;
public ProWorkorderController(IProWorkorderService ProWorkorderService)
{
_ProWorkorderService = ProWorkorderService;
}
/// <summary>
2024-09-14 10:39:14 +08:00
/// 查询生产工单列表 启用9/14
2024-07-16 14:40:02 +08:00
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
2024-07-16 15:34:08 +08:00
[HttpPost("list")]
2024-07-16 14:40:02 +08:00
[ActionPermissionFilter(Permission = "productManagement:proworkorder:list")]
2024-07-16 15:34:08 +08:00
public IActionResult QueryProWorkorder([FromBody] ProWorkorderQueryDto parm)
2024-07-16 14:40:02 +08:00
{
var response = _ProWorkorderService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询生产工单详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:query")]
2024-09-04 10:01:39 +08:00
public IActionResult GetProWorkorder(string Id)
2024-07-16 14:40:02 +08:00
{
var response = _ProWorkorderService.GetInfo(Id);
2024-09-04 10:01:39 +08:00
2024-07-16 14:40:02 +08:00
var info = response.Adapt<ProWorkorder>();
return SUCCESS(info);
}
/// <summary>
2024-09-14 10:39:14 +08:00
/// 添加生产工单
2024-07-16 14:40:02 +08:00
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:add")]
[Log(Title = "生产工单", BusinessType = BusinessType.INSERT)]
public IActionResult AddProWorkorder([FromBody] ProWorkorderDto parm)
{
var modal = parm.Adapt<ProWorkorder>().ToCreate(HttpContext);
var response = _ProWorkorderService.AddProWorkorder(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新生产工单
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:edit")]
[Log(Title = "生产工单", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateProWorkorder([FromBody] ProWorkorderDto parm)
{
var modal = parm.Adapt<ProWorkorder>().ToUpdate(HttpContext);
var response = _ProWorkorderService.UpdateProWorkorder(modal);
return ToResponse(response);
}
/// <summary>
/// 删除生产工单
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:delete")]
[Log(Title = "生产工单", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteProWorkorder(string ids)
{
2024-07-16 15:00:28 +08:00
string[] idsArr = Tools.SpitStrArrary(ids);
2024-07-16 14:40:02 +08:00
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _ProWorkorderService.Delete(idsArr);
return ToResponse(response);
}
2024-09-14 08:45:11 +08:00
///// <summary>
///// 生成工单号
///// </summary>
///// <param name="parm"></param>
///// <returns>生成工单号 数量 </returns>
//[HttpPost("Generate_workorder")]
//public IActionResult Generate_workorder([FromBody] ProWorkorderQueryDto2 parm)
//{
// if (parm.WorkorderDate <= DateTime.MinValue)
// {
// SUCCESS(null);
// }
// var response = _ProWorkorderService.Generate_workorder(parm);
// return SUCCESS(response);
//}
2024-07-16 16:34:43 +08:00
2024-07-16 17:17:36 +08:00
/// <summary>
2024-08-30 16:36:13 +08:00
/// 插入工单/或者新增工单
2024-07-16 17:17:36 +08:00
/// </summary>
/// <param name="parm"></param>
/// <returns>1成功 0失败</returns>
[HttpPost("insert_workorder")]
2024-09-04 14:04:02 +08:00
[Log(Title = "插入工单/或者新增工单", BusinessType = BusinessType.INSERT)]
2024-09-04 10:01:39 +08:00
public IActionResult Insert_workOrder([FromBody] ProWorkorderDto2 parm)
2024-07-16 17:17:36 +08:00
{
2024-07-16 17:36:29 +08:00
if (parm == null)
2024-07-16 17:17:36 +08:00
{
return SUCCESS(null);
}
2024-09-14 08:45:11 +08:00
2024-09-04 10:01:39 +08:00
ProWorkorder newparm = parm.Adapt<ProWorkorder>().ToCreate(HttpContext);
var response = _ProWorkorderService.Insert_workOrder(newparm, parm.next_id);
2024-07-16 17:17:36 +08:00
return SUCCESS(response);
2024-07-16 16:34:43 +08:00
2024-07-16 14:40:02 +08:00
2024-07-16 17:17:36 +08:00
}
2024-07-16 19:27:20 +08:00
/// <summary>
/// 移动工单
/// </summary>
/// <param name="id"> 1上 2下</param>
/// <param name="type"></param>
/// <returns></returns>
[HttpGet("move_workorder")]
2024-09-04 14:04:02 +08:00
[Log(Title = "移动工单", BusinessType = BusinessType.INSERT)]
2024-09-04 10:01:39 +08:00
public IActionResult MoveWorkorder(string id, int type)
2024-07-16 19:27:20 +08:00
{
2024-09-04 10:01:39 +08:00
if (string.IsNullOrEmpty(id))
2024-07-16 19:27:20 +08:00
{
return SUCCESS(null);
}
var response = _ProWorkorderService.MoveWorkorder(id, type);
return SUCCESS(response);
}
2024-07-16 17:17:36 +08:00
2024-07-17 11:42:05 +08:00
/// <summary>
2024-09-14 10:39:14 +08:00
/// 生产工单导入模板下载 workorder 启用9/14
2024-07-17 11:42:05 +08:00
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "生产工单导入模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
(string, string) result = DownloadImportTemplate("workorder");
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
2024-09-14 10:39:14 +08:00
/// 导入 启用9/14
2024-07-17 11:42:05 +08:00
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
2024-07-17 14:02:54 +08:00
/// <returns>导入成功数 若-1 则excel读取异常</returns>
2024-07-17 11:42:05 +08:00
[HttpPost("importData")]
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
2024-07-17 15:16:15 +08:00
[AllowAnonymous]
2024-07-17 11:42:05 +08:00
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
2024-09-04 10:01:39 +08:00
2024-07-17 11:42:05 +08:00
if (formFile == null)
{
return SUCCESS(null);
}
2024-09-13 17:17:52 +08:00
int response = _ProWorkorderService.ImportData(formFile, HttpContext.GetName());
2024-07-17 11:42:05 +08:00
return SUCCESS(response);
2024-07-16 14:40:02 +08:00
2024-07-17 11:42:05 +08:00
}
2024-07-17 14:28:32 +08:00
/// <summary>
2024-09-14 10:39:14 +08:00
/// 工单导出 启用9/14
2024-07-17 14:28:32 +08:00
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "工单导出", BusinessType = BusinessType.EXPORT)]
2024-07-17 15:16:15 +08:00
[AllowAnonymous]
2024-07-17 14:28:32 +08:00
public IActionResult WorkOrderExport([FromQuery] DateTime extportDate)
{
2024-09-04 10:01:39 +08:00
if (extportDate == DateTime.MinValue)
2024-07-17 15:23:18 +08:00
{
2024-09-04 10:01:39 +08:00
return SUCCESS(null);
2024-07-17 15:23:18 +08:00
}
2024-07-17 14:28:32 +08:00
var list = _ProWorkorderService.WorkOrderExport(extportDate, new PagerInfo(1, 10000));
2024-07-17 14:57:01 +08:00
var result = ExportExcelMini(list.Result, "workorder", "工单列表");
2024-07-17 14:28:32 +08:00
return ExportExcel(result.Item2, result.Item1);
}
2024-08-30 16:36:13 +08:00
//TODO 获取物料
[HttpPost("get_material")]
2024-08-30 17:09:55 +08:00
public IActionResult GetMaterialInfo([FromBody] BaseMaterialListQueryDto5 query)
2024-08-30 16:36:13 +08:00
{
if (query == null)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetMaterialInfo(query);
return SUCCESS(response);
}
2024-08-30 17:05:08 +08:00
//TODO 获取客户
[HttpPost("get_custom")]
public IActionResult GetCustomInfo([FromBody] BaseCustomQueryDto2 parm)
{
if (parm == null)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetCustomInfo(parm);
return SUCCESS(response);
}
2024-09-04 10:01:39 +08:00
2024-09-04 10:04:19 +08:00
2024-09-08 10:13:57 +08:00
//TODO 获取指定日期工艺路线
2024-09-04 10:01:39 +08:00
[HttpGet("get_process_route")]
public IActionResult GetProcessRoute(DateTime dateTime)
{
if (dateTime == DateTime.MinValue)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetProcessRoute(dateTime);
return SUCCESS(response);
2024-09-08 10:13:57 +08:00
}
2024-09-14 10:39:14 +08:00
//TODO 获取全部工艺路线 启用9/14
2024-09-08 10:13:57 +08:00
[HttpGet("get_all_route")]
public IActionResult GetAllRoute()
{
var response = _ProWorkorderService.GetAllRoute();
return SUCCESS(response);
2024-09-04 10:01:39 +08:00
}
//TODO 获取组
2024-09-14 08:45:11 +08:00
//[HttpGet("get_groups")]
//public IActionResult GetGroupList(string route_code,DateTime dateTime)
//{
// if (string.IsNullOrEmpty(route_code)) { return SUCCESS(null); }
// if (dateTime == DateTime.MinValue)
// {
// return SUCCESS(null);
2024-09-07 11:00:04 +08:00
2024-09-14 08:45:11 +08:00
// }
2024-09-04 10:04:19 +08:00
2024-09-14 08:45:11 +08:00
// var response = _ProWorkorderService.GetGroupList(route_code, dateTime);
// return SUCCESS(response);
2024-09-04 10:01:39 +08:00
2024-09-14 08:45:11 +08:00
//}
2024-09-14 10:39:14 +08:00
// 启用9/14
2024-09-14 10:44:33 +08:00
[HttpGet("get_groups")]
2024-09-14 08:45:11 +08:00
public IActionResult GetGroupList()
{
var response = _ProWorkorderService.GetGroupList();
return SUCCESS(response);
2024-09-04 10:01:39 +08:00
}
2024-09-04 13:10:37 +08:00
//TODO 查询BOM 及其所需数量
/// <summary>
/// 查询BOM 及其所需数量
/// </summary>
/// <param name="workorder_num">工单号</param>
/// <returns></returns>
[HttpGet("search_BOM_num")]
2024-09-14 10:44:33 +08:00
public IActionResult SearchBOMNum(string workorder_num)
{
2024-09-04 13:10:37 +08:00
if (string.IsNullOrEmpty(workorder_num)) { return SUCCESS(null); }
var response = _ProWorkorderService.SearchBOMNum(workorder_num);
return SUCCESS(response);
}
2024-09-14 10:39:14 +08:00
//TODO 工单变更日志
[HttpGet("workorder_log")]
2024-09-14 10:44:33 +08:00
public IActionResult WorkOrderLog(string workorder, string log)
2024-09-14 10:39:14 +08:00
{
2024-09-14 10:44:33 +08:00
if (string.IsNullOrEmpty(workorder)) { return SUCCESS(null); }
var response = _ProWorkorderService.WorkOrderLog(workorder, log, HttpContext.GetName());
2024-09-14 10:39:14 +08:00
return SUCCESS(response);
}
2024-09-04 10:04:19 +08:00
}
2024-09-04 10:01:39 +08:00
}