qianhao.xu 5578332cc3 1
2024-09-04 10:04:19 +08:00

277 lines
8.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
using Org.BouncyCastle.Crypto;
using DOAN.Model.System;
using MiniExcelLibs;
using DOAN.Model.System.Dto;
using DOAN.Model;
using DOAN.Model.MES.base_.Dto;
using Microsoft.AspNetCore.Http;
using Aliyun.OSS;
//创建时间2024-07-16
namespace DOAN.Admin.WebApi.Controllers
{
/// <summary>
/// 生产工单
/// </summary>
[Verify]
[Route("mes/productManagement/ProWorkorder")]
public class ProWorkorderController : BaseController
{
/// <summary>
/// 生产工单接口
/// </summary>
private readonly IProWorkorderService _ProWorkorderService;
public ProWorkorderController(IProWorkorderService ProWorkorderService)
{
_ProWorkorderService = ProWorkorderService;
}
/// <summary>
/// 查询生产工单列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpPost("list")]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:list")]
public IActionResult QueryProWorkorder([FromBody] ProWorkorderQueryDto parm)
{
var response = _ProWorkorderService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询生产工单详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "productManagement:proworkorder:query")]
public IActionResult GetProWorkorder(string Id)
{
var response = _ProWorkorderService.GetInfo(Id);
var info = response.Adapt<ProWorkorder>();
return SUCCESS(info);
}
/// <summary>
/// 添加生产工单
/// </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)
{
string[] idsArr = Tools.SpitStrArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _ProWorkorderService.Delete(idsArr);
return ToResponse(response);
}
/// <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);
}
/// <summary>
/// 插入工单/或者新增工单
/// </summary>
/// <param name="parm"></param>
/// <returns>1成功 0失败</returns>
[HttpPost("insert_workorder")]
public IActionResult Insert_workOrder([FromBody] ProWorkorderDto2 parm)
{
if (parm == null)
{
return SUCCESS(null);
}
ProWorkorder newparm = parm.Adapt<ProWorkorder>().ToCreate(HttpContext);
var response = _ProWorkorderService.Insert_workOrder(newparm, parm.next_id);
return SUCCESS(response);
}
/// <summary>
/// 移动工单
/// </summary>
/// <param name="id"> 1上 2下</param>
/// <param name="type"></param>
/// <returns></returns>
[HttpGet("move_workorder")]
public IActionResult MoveWorkorder(string id, int type)
{
if (string.IsNullOrEmpty(id))
{
return SUCCESS(null);
}
var response = _ProWorkorderService.MoveWorkorder(id, type);
return SUCCESS(response);
}
/// <summary>
/// 生产工单导入模板下载 workorder
/// </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>
/// 导入
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns>导入成功数 若-1 则excel读取异常</returns>
[HttpPost("importData")]
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[AllowAnonymous]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
if (formFile == null)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.ImportData(formFile, HttpContext.GetName());
return SUCCESS(response);
}
/// <summary>
/// 工单导出
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "工单导出", BusinessType = BusinessType.EXPORT)]
[AllowAnonymous]
public IActionResult WorkOrderExport([FromQuery] DateTime extportDate)
{
if (extportDate == DateTime.MinValue)
{
return SUCCESS(null);
}
var list = _ProWorkorderService.WorkOrderExport(extportDate, new PagerInfo(1, 10000));
var result = ExportExcelMini(list.Result, "workorder", "工单列表");
return ExportExcel(result.Item2, result.Item1);
}
//TODO 获取物料
[HttpPost("get_material")]
public IActionResult GetMaterialInfo([FromBody] BaseMaterialListQueryDto5 query)
{
if (query == null)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetMaterialInfo(query);
return SUCCESS(response);
}
//TODO 获取客户
[HttpPost("get_custom")]
public IActionResult GetCustomInfo([FromBody] BaseCustomQueryDto2 parm)
{
if (parm == null)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetCustomInfo(parm);
return SUCCESS(response);
}
//TODO 获取工艺路线
[HttpGet("get_process_route")]
public IActionResult GetProcessRoute(DateTime dateTime)
{
if (dateTime == DateTime.MinValue)
{
return SUCCESS(null);
}
var response = _ProWorkorderService.GetProcessRoute(dateTime);
return SUCCESS(response);
}
//TODO 获取组
[HttpGet("get_groups")]
public IActionResult GetGroupList(string route_code)
{
if (string.IsNullOrEmpty(route_code)) { return SUCCESS(null); }
var response = _ProWorkorderService.GetGroupList(route_code);
return SUCCESS(response);
}
}
}