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

246 lines
8.9 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 MiniExcelLibs;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms;
using ZR.Service.mes.wms.IService;
//创建时间2024-08-08
namespace ZR.Admin.WebApi.Controllers
{
/// <summary>
/// 一次合格品仓库
/// </summary>
[Route("/mes/wm/WmOneTimeInventory")]
public class WmOneTimeInventoryController : BaseController
{
/// <summary>
/// 一次合格品仓库接口
/// </summary>
private readonly IWmOneTimeInventoryService _WmOneTimeInventoryService;
public WmOneTimeInventoryController(IWmOneTimeInventoryService WmOneTimeInventoryService)
{
_WmOneTimeInventoryService = WmOneTimeInventoryService;
}
/// <summary>
/// 查询一次合格品仓库列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
// [ActionPermissionFilter(Permission = "business:wmonetimeinventory:list")]
public IActionResult QueryWmOneTimeInventory([FromQuery] WmOneTimeInventoryQueryDto parm)
{
var response = _WmOneTimeInventoryService.GetListNew(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询一次合格品仓库详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
// [ActionPermissionFilter(Permission = "business:wmonetimeinventory:query")]
public IActionResult GetWmOneTimeInventory(string Id)
{
var response = _WmOneTimeInventoryService.GetInfo(Id);
var info = response.Adapt<WmOneTimeInventory>();
return SUCCESS(info);
}
/// <summary>
/// 添加一次合格品仓库
/// </summary>
/// <returns></returns>
[HttpPost]
// [ActionPermissionFilter(Permission = "business:wmonetimeinventory:add")]
[Log(Title = "一次合格品仓库", BusinessType = BusinessType.INSERT)]
public IActionResult AddWmOneTimeInventory([FromBody] WmOneTimeInventoryDto parm)
{
var modal = parm.Adapt<WmOneTimeInventory>().ToCreate(HttpContext);
var response = _WmOneTimeInventoryService.AddWmOneTimeInventory(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新一次合格品仓库
/// </summary>
/// <returns></returns>
[HttpPut]
// [ActionPermissionFilter(Permission = "business:wmonetimeinventory:edit")]
[Log(Title = "一次合格品仓库", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateWmOneTimeInventory([FromBody] WmOneTimeInventoryDto parm)
{
var modal = parm.Adapt<WmOneTimeInventory>().ToUpdate(HttpContext);
var response = _WmOneTimeInventoryService.UpdateWmOneTimeInventory(modal);
return ToResponse(response);
}
/// <summary>
/// 删除一次合格品仓库
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
// [ActionPermissionFilter(Permission = "business:wmonetimeinventory:delete")]
[Log(Title = "一次合格品仓库", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteWmOneTimeInventory(string ids)
{
string[] idsArr = ids.Split(',');
if (idsArr.Length <= 0)
{
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
}
var response = _WmOneTimeInventoryService.Delete(idsArr);
return ToResponse(response);
}
/// <summary>
/// 一次合格品手动入库
/// </summary>
/// <returns></returns>
[HttpPost("doWmOneTimeWarehousing")]
[Log(Title = "一次合格品手动入库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmOneTimeWarehousing([FromBody] WmOneTimeInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmOneTimeInventory>().ToUpdate(HttpContext);
var response = _WmOneTimeInventoryService.DoWmOneTimeWarehousing(modal);
return ToResponse(new ApiResult(200, "手动入库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 一次合格品手动出库
/// </summary>
/// <returns></returns>
[HttpPost("doWmOneTimeRetrieval")]
[Log(Title = "一次合格品手动出库", BusinessType = BusinessType.UPDATE)]
public IActionResult DoWmOneTimeRetrieval([FromBody] WmOneTimeInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmOneTimeInventory>().ToUpdate(HttpContext);
var response = _WmOneTimeInventoryService.DoWmOneTimeRetrieval(modal);
return ToResponse(new ApiResult(200, "手动出库成功", response));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, "手动出库异常:" + e.Message, e.Message));
}
}
/// <summary>
/// 一次合格品仓库盘点
/// </summary>
/// <returns></returns>
[HttpPost("doWmOneTimeStocktaking")]
[Log(Title = "一次合格品仓库盘点", BusinessType = BusinessType.INSERT)]
public IActionResult DoWmOneTimeStocktaking([FromBody] WmOneTimeInventoryDto parm)
{
try
{
var modal = parm.Adapt<WmOneTimeInventory>().ToUpdate(HttpContext);
var response = _WmOneTimeInventoryService.DoWmOneTimeStocktaking(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 = _WmOneTimeInventoryService.GetPartNumber();
return SUCCESS(response);
}
/// <summary>
/// 抛光导入模板下载
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "一次合格模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
string fileName = "一次合格仓库盘点模板";
(string, string) result = DownloadImportTemplate(fileName);
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<WmOneTimeInventoryExportDto> importList = new();
using (var stream = formFile.OpenReadStream())
{
importList = stream.Query<WmOneTimeInventoryExportDto>(startCell: "A1").ToList();
}
return SUCCESS(_WmOneTimeInventoryService.ImportExcel(importList));
}
/// <summary>
/// 一次合格品仓库数据导出
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "一次合格品仓库数据导出", BusinessType = BusinessType.EXPORT)]
public IActionResult Export([FromQuery] WmOneTimeInventoryQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 10000;
var list = _WmOneTimeInventoryService.GetExportList(parm);
var result = ExportExcelMini(list, "wm_one_time_inventory", "一次合格品仓库数据");
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
/// 一次合格品仓库数据导出
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("ErrorCheck")]
[AllowAnonymous]
public IActionResult ErrorCheck()
{
var list = _WmOneTimeInventoryService.CheckErrorTable();
return SUCCESS(list);
}
}
}