shgx_tz_mom/ZR.Admin.WebApi/Controllers/mes/wms/WmPolishInventoryController.cs

254 lines
9.2 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
2024-10-29 17:35:32 +08:00
using MiniExcelLibs;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
//创建时间2024-07-25
namespace ZR.Admin.WebApi.Controllers
{
/// <summary>
/// 工艺路线-抛光 库存表
/// </summary>
2024-08-27 09:14:57 +08:00
// [Verify]
[Route("/mes/wm/WmPolishInventory")]
public class WmPolishInventoryController : BaseController
{
/// <summary>
/// 工艺路线-抛光 库存表接口
/// </summary>
private readonly IWmPolishInventoryService _WmPolishInventoryService;
public WmPolishInventoryController(IWmPolishInventoryService WmPolishInventoryService)
{
_WmPolishInventoryService = WmPolishInventoryService;
}
/// <summary>
/// 查询工艺路线-抛光 库存表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:list")]
public IActionResult QueryWmPolishInventory([FromQuery] WmPolishInventoryQueryDto parm)
{
2025-03-24 14:27:35 +08:00
var response = _WmPolishInventoryService.GetListNew(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询工艺路线-抛光 库存表详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:query")]
public IActionResult GetWmPolishInventory(string Id)
{
var response = _WmPolishInventoryService.GetInfo(Id);
var info = response.Adapt<WmPolishInventory>();
return SUCCESS(info);
}
/// <summary>
/// 添加抛光 库存表
/// </summary>
/// <returns></returns>
[HttpPost]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:add")]
[Log(Title = "抛光 库存表", BusinessType = BusinessType.INSERT)]
public IActionResult AddWmPolishInventory([FromBody] WmPolishInventoryDto parm)
{
var modal = parm.Adapt<WmPolishInventory>().ToCreate(HttpContext);
var response = _WmPolishInventoryService.AddWmPolishInventory(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新抛光 库存表
/// </summary>
/// <returns></returns>
[HttpPut]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
[Log(Title = "抛光 库存表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateWmPolishInventory([FromBody] WmPolishInventoryDto parm)
{
var modal = parm.Adapt<WmPolishInventory>().ToUpdate(HttpContext);
var response = _WmPolishInventoryService.UpdateWmPolishInventory(modal);
return ToResponse(response);
}
/// <summary>
/// 删除抛光 库存表
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:delete")]
[Log(Title = "抛光 库存表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteWmPolishInventory(string ids)
{
string[] idsArr = ids.Split(",");
if (idsArr.Length <= 0)
{
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
}
var response = _WmPolishInventoryService.Delete(idsArr);
return ToResponse(response);
}
2024-10-16 17:26:12 +08:00
2024-07-26 17:34:01 +08:00
/// <summary>
/// 物料下拉菜单查看
/// </summary>
/// <returns></returns>
[HttpGet("getMaterialSelectOption")]
public IActionResult GetMaterialSelectOption([FromQuery] string query)
{
try
{
var response = _WmPolishInventoryService.GetMaterialSelectOption(query);
return ToResponse(new ApiResult(200, "获取成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "获取物料下拉菜单数据失败:" + e.Message, null));
}
}
/// <summary>
/// 抛光手动入库
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishWarehousing")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
2024-07-26 17:34:01 +08:00
[Log(Title = "抛光手动入库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmPolishWarehousing([FromBody] WmPolishInventoryDto parm)
{
try
{
2024-11-25 16:34:07 +08:00
var modal = parm.Adapt<WmPolishInventory>().ToUpdate(HttpContext);
var response = _WmPolishInventoryService.DoWmPolishWarehousing(modal);
return ToResponse(new ApiResult(200, "手动入库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message));
}
}
/// <summary>
2024-07-26 17:34:01 +08:00
/// 抛光手动出库
/// </summary>
/// <returns></returns>
2024-07-26 17:34:01 +08:00
[HttpPost("doWmPolishRetrieval")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
2024-07-26 17:34:01 +08:00
[Log(Title = "抛光手动出库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmPolishRetrieval([FromBody] WmPolishInventoryDto parm)
{
try
{
2024-11-25 16:34:07 +08:00
var modal = parm.Adapt<WmPolishInventory>().ToUpdate(HttpContext);
2024-07-26 17:34:01 +08:00
var response = _WmPolishInventoryService.DoWmPolishRetrieval(modal);
return ToResponse(new ApiResult(200, "手动出库成功", response));
}
catch (Exception e)
{
2024-07-26 17:34:01 +08:00
return ToResponse(new ApiResult(500, "手动出库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 抛光仓库盘点
/// </summary>
/// <returns></returns>
[HttpPost("doWmPolishStocktaking")]
2024-11-15 18:51:05 +08:00
// [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")]
2024-07-26 17:34:01 +08:00
[Log(Title = "抛光仓库盘点", BusinessType = BusinessType.INSERT)]
public IActionResult DoWmPolishStocktaking([FromBody] WmPolishInventoryDto parm)
{
try
{
2024-11-25 16:34:07 +08:00
var modal = parm.Adapt<WmPolishInventory>().ToUpdate(HttpContext);
2024-07-26 17:34:01 +08:00
var response = _WmPolishInventoryService.DoWmPolishStocktaking(modal);
return ToResponse(new ApiResult(200, "盘点成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "盘点异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 查询毛坯库存零件数
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("getPartNumber")]
public IActionResult GetPartNumber()
{
var response = _WmPolishInventoryService.GetPartNumber();
return SUCCESS(response);
}
2024-10-29 17:35:32 +08:00
/// <summary>
/// 抛光导入模板下载
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "抛光模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
2024-11-07 18:39:46 +08:00
string fileName = "抛光仓库盘点模板";
(string, string) result = DownloadImportTemplate(fileName);
2024-10-29 17:35:32 +08:00
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
/// 导入
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns></returns>
[HttpPost("importData")]
[Log(Title = "抛光盘点导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[AllowAnonymous]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
List<WmPolishInventoryExportDto> importList = new();
using (var stream = formFile.OpenReadStream())
{
importList = stream.Query<WmPolishInventoryExportDto>(startCell: "A1").ToList();
}
return SUCCESS(_WmPolishInventoryService.ImportExcel(importList));
}
2024-11-15 18:51:05 +08:00
/// <summary>
/// 抛光仓库数据导出
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "抛光仓库数据导出", BusinessType = BusinessType.EXPORT)]
public IActionResult Export([FromQuery] WmPolishInventoryQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 10000;
var list = _WmPolishInventoryService.GetExportList(parm);
var result = ExportExcelMini(list, "wm_polish_inventory", "抛光仓库数据");
return ExportExcel(result.Item2, result.Item1);
}
}
}