265 lines
9.2 KiB
C#
265 lines
9.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
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.IService;
|
||
|
||
//创建时间:2024-05-13
|
||
namespace ZR.Admin.WebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 毛坯库存库存变动记录表
|
||
/// </summary>
|
||
[Verify]
|
||
[Route("/mes/wm/WmBlankRecord")]
|
||
public class WmBlankRecordController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 毛坯库存库存变动记录表接口
|
||
/// </summary>
|
||
private readonly IWmBlankRecordService _WmBlankRecordService;
|
||
|
||
public WmBlankRecordController(IWmBlankRecordService WmBlankRecordService)
|
||
{
|
||
_WmBlankRecordService = WmBlankRecordService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询毛坯库存库存变动记录表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "business:wmblankrecord:list")]
|
||
public IActionResult QueryWmBlankRecord([FromQuery] WmBlankRecordQueryDto parm)
|
||
{
|
||
var response = _WmBlankRecordService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询毛坯库存库存变动记录表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "business:wmblankrecord:query")]
|
||
public IActionResult GetWmBlankRecord(string Id)
|
||
{
|
||
var response = _WmBlankRecordService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<WmBlankRecord>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加毛坯库存库存变动记录表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "business:wmblankrecord:add")]
|
||
[Log(Title = "毛坯库存库存变动记录表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddWmBlankRecord([FromBody] WmBlankRecordDto parm)
|
||
{
|
||
var modal = parm.Adapt<WmBlankRecord>().ToCreate(HttpContext);
|
||
|
||
var response = _WmBlankRecordService.AddWmBlankRecord(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 1.增加库存(入库)
|
||
/// </summary>
|
||
/// <param name="fkBlankInventoryId">库存id</param>
|
||
/// <param name="blankNum">毛坯号</param>
|
||
/// <param name="changeQuantity">变动量</param>
|
||
/// <param name="actionTime">入库/出库时间</param>
|
||
/// <param name="remark">备注</param>
|
||
/// <returns></returns>
|
||
[HttpGet("add_inventory")]
|
||
public IActionResult AddInventory(
|
||
string fkBlankInventoryId,
|
||
string blankNum,
|
||
int changeQuantity,
|
||
string remark,
|
||
DateTime? actionTime
|
||
)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(fkBlankInventoryId))
|
||
{
|
||
return ToResponse(new ApiResult(500, "库存id为空!", "库存id为空!"));
|
||
}
|
||
if (string.IsNullOrEmpty(blankNum))
|
||
{
|
||
return ToResponse(new ApiResult(500, "毛坯号为空!", "毛坯号为空!"));
|
||
}
|
||
var response = _WmBlankRecordService.AddInventory(
|
||
fkBlankInventoryId,
|
||
blankNum,
|
||
changeQuantity,
|
||
HttpContext.GetName(),
|
||
remark,
|
||
actionTime
|
||
);
|
||
return SUCCESS(response);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ToResponse(new ApiResult(500, ex.Message, "添加入库记录失败"));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 2.减少库存(出库)
|
||
/// </summary>
|
||
/// <param name="fkBlankInventoryId">库存id</param>
|
||
/// <param name="blankNum">毛坯号</param>
|
||
/// <param name="changeQuantity">变动量</param>
|
||
/// <param name="actionTime">操作时间(出库时间)</param>
|
||
/// <param name="remark">备注</param>
|
||
/// <returns></returns>
|
||
[HttpGet("delete_inventory")]
|
||
public IActionResult DeleteInventory(
|
||
string fkBlankInventoryId,
|
||
string blankNum,
|
||
int changeQuantity,
|
||
string remark,
|
||
DateTime? actionTime
|
||
)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(fkBlankInventoryId))
|
||
{
|
||
return ToResponse(new ApiResult(500, "库存id为空!", "库存id为空!"));
|
||
}
|
||
if (string.IsNullOrEmpty(blankNum))
|
||
{
|
||
return ToResponse(new ApiResult(500, "毛坯号为空!", "毛坯号为空!"));
|
||
}
|
||
var response = _WmBlankRecordService.DeleteInventory(
|
||
fkBlankInventoryId,
|
||
blankNum,
|
||
changeQuantity,
|
||
HttpContext.GetName(),
|
||
remark,
|
||
actionTime
|
||
);
|
||
return SUCCESS(response);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ToResponse(new ApiResult(500, ex.Message, "添加出库记录失败"));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 3.盘点库存
|
||
/// </summary>
|
||
/// <param name="fkBlankInventoryId">库存id</param>
|
||
/// <param name="blankNum">毛坯号</param>
|
||
/// <param name="changeQuantity">变动量</param>
|
||
/// <param name="actionTime">操作时间(出库时间)</param>
|
||
/// <param name="remark">备注</param>
|
||
/// <returns></returns>
|
||
[HttpGet("doStocktakingBlankInventory")]
|
||
public IActionResult DoStocktakingBlankInventory(
|
||
string fkBlankInventoryId,
|
||
string blankNum,
|
||
int changeQuantity,
|
||
string remark,
|
||
DateTime? actionTime
|
||
)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(fkBlankInventoryId))
|
||
{
|
||
return ToResponse(new ApiResult(500, "库存id为空!", "库存id为空!"));
|
||
}
|
||
if (string.IsNullOrEmpty(blankNum))
|
||
{
|
||
return ToResponse(new ApiResult(500, "毛坯号为空!", "毛坯号为空!"));
|
||
}
|
||
var response = _WmBlankRecordService.DoStocktakingBlankInventory(
|
||
fkBlankInventoryId,
|
||
blankNum,
|
||
changeQuantity,
|
||
HttpContext.GetName(),
|
||
remark,
|
||
actionTime
|
||
);
|
||
return SUCCESS(response);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ToResponse(new ApiResult(500, ex.Message, "添加盘点记录失败"));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 4.根据工单号出库毛坯
|
||
/// </summary>
|
||
[HttpGet("doOutboundByWorkOrderId")]
|
||
public IActionResult DoOutboundByWorkOrderId(string workOrderId)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(workOrderId))
|
||
{
|
||
return ToResponse(new ApiResult(500, "工单id为空!", "工单id为空!"));
|
||
}
|
||
var response = _WmBlankRecordService.DoOutboundByWorkOrderId(
|
||
workOrderId,
|
||
0,
|
||
HttpContext.GetName()
|
||
);
|
||
return SUCCESS(response);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ToResponse(new ApiResult(500, ex.Message, "根据工单号出库毛坯失败"));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新毛坯库存库存变动记录表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "business:wmblankrecord:edit")]
|
||
[Log(Title = "毛坯库存库存变动记录表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateWmBlankRecord([FromBody] WmBlankRecordDto parm)
|
||
{
|
||
var modal = parm.Adapt<WmBlankRecord>().ToUpdate(HttpContext);
|
||
var response = _WmBlankRecordService.UpdateWmBlankRecord(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除毛坯库存库存变动记录表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpDelete("{ids}")]
|
||
[ActionPermissionFilter(Permission = "business:wmblankrecord:delete")]
|
||
[Log(Title = "毛坯库存库存变动记录表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteWmBlankRecord(string ids)
|
||
{
|
||
string[] idsArr = ids.Split(',');
|
||
if (idsArr.Length <= 0)
|
||
{
|
||
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
|
||
}
|
||
|
||
var response = _WmBlankRecordService.Delete(idsArr);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
}
|
||
}
|