feat(领料): 添加原材料领料功能接口
实现原材料领料功能,包括: 1. 在IMmRecordInboundService接口添加TakeMaterial方法 2. 新增TakeMaterialRequestDto请求参数类 3. 在MmRecordInboundController添加领料API接口 4. 实现领料业务逻辑,包括工单校验和出库单生成
This commit is contained in:
@@ -100,6 +100,34 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
||||
return ToResponse(_MmRecordInboundService.Delete(idArr));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 领料接口(临时)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("TakeMaterial")]
|
||||
[ActionPermissionFilter(Permission = "mmrecordinbound:takematerial")]
|
||||
[Log(Title = "10线领料", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult TakeMaterial([FromBody] TakeMaterialRequestDto parm)
|
||||
{
|
||||
try
|
||||
{
|
||||
string response = _MmRecordInboundService.TakeMaterial(parm);
|
||||
if (response == "ok")
|
||||
{
|
||||
return ToResponse(new ApiResult(200, "ok"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ToResponse(new ApiResult(500, response));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
|
||||
@@ -206,4 +206,21 @@ namespace DOAN.Model.BZFM.Dto
|
||||
[SugarColumn(ColumnName = "workorder_raw")]
|
||||
public string WorkorderRaw { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 领料请求参数
|
||||
/// </summary>
|
||||
public class TakeMaterialRequestDto
|
||||
{
|
||||
[Required(ErrorMessage = "记录ID不能为空")]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string InboundNo { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "成品工单号不能为空")]
|
||||
public string WorkorderRow { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "领料人不能为空")]
|
||||
public string Operator { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,12 @@ namespace DOAN.Service.BZFM.IBZFMService
|
||||
ImportResultDto ImportRecordinbound(IFormFile formFile, string username);
|
||||
|
||||
public PagedInfo<MmRecordinboundExcelDto> SelectRecordinboundList(MmRecordInboundQueryDto recordinbound, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 领料接口
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
string TakeMaterial(TakeMaterialRequestDto parm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +272,7 @@ namespace DOAN.Service.BZFM
|
||||
Unit = parm.Unit,
|
||||
ProductionDate = parm.ProductionDate,
|
||||
Workorder = parm.Workorder,
|
||||
WorkorderRaw = parm.WorkorderRaw,
|
||||
ExpiryDate = parm.ExpiryDate,
|
||||
CreatedTime = nowDate,
|
||||
TransactionType = parm.TransactionType,
|
||||
@@ -384,6 +385,7 @@ namespace DOAN.Service.BZFM
|
||||
CreatedTime = nowDate,
|
||||
TransactionType = parm.TransactionType,
|
||||
Workorder = parm.Workorder,
|
||||
WorkorderRaw = parm.WorkorderRaw,
|
||||
OrderNo = parm.OrderNo,
|
||||
Remarks = parm.Remarks,
|
||||
};
|
||||
@@ -828,6 +830,7 @@ namespace DOAN.Service.BZFM
|
||||
SupplierCode = recordInbound.SupplierCode,
|
||||
StoveCode = recordInbound.StoveCode,
|
||||
Workorder = recordInbound.Workorder,
|
||||
WorkorderRaw = recordInbound.WorkorderRaw,
|
||||
Operator = recordInbound.Operator,
|
||||
Quantity = recordInbound.Quantity,
|
||||
TransactionType = "入库红单",
|
||||
@@ -869,6 +872,7 @@ namespace DOAN.Service.BZFM
|
||||
WarehouseCode = recordOutbound.WarehouseCode,
|
||||
OrderNo = recordOutbound.OrderNo,
|
||||
Workorder = recordOutbound.Workorder,
|
||||
WorkorderRaw = recordOutbound.WorkorderRaw,
|
||||
Operator = recordOutbound.Operator,
|
||||
Quantity = recordOutbound.Quantity,
|
||||
TransactionType = "出库红单",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using DOAN.Model.BZFM;
|
||||
using DOAN.Model.BZFM.Dto;
|
||||
using DOAN.Model.MES.product;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.BZFM.IBZFMService;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Converter;
|
||||
using Infrastructure.Extensions;
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using NPOI.SS.UserModel;
|
||||
@@ -375,5 +377,67 @@ namespace DOAN.Service.BZFM
|
||||
|
||||
return query.ToPage(pager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 领料接口(临时)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public string TakeMaterial(TakeMaterialRequestDto parm)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var inboundInfo = Queryable().Where(x => x.Id == parm.Id).First();
|
||||
if (inboundInfo == null)
|
||||
{
|
||||
return "该入库记录不存在!";
|
||||
}
|
||||
if (inboundInfo.Remarks == "已撤销")
|
||||
{
|
||||
return "该记录已撤销,无法领料";
|
||||
}
|
||||
var workorderInfo = Context.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == inboundInfo.Workorder)
|
||||
.First();
|
||||
if (workorderInfo == null)
|
||||
{
|
||||
return "该入库记录对应的工单不存在!";
|
||||
}
|
||||
Context.Ado.BeginTran();
|
||||
inboundInfo.WorkorderRaw = parm.WorkorderRow;
|
||||
inboundInfo.Remarks += "[已领料]";
|
||||
Context.Updateable(inboundInfo).ExecuteCommand();
|
||||
// 填写出库单
|
||||
//做出库红单
|
||||
OutboundReceiptDto revokeRecepitDto = new()
|
||||
{
|
||||
ReceiptType = 1,
|
||||
MaterialCode = inboundInfo.MaterialCode,
|
||||
BatchNo = inboundInfo.BatchNo,
|
||||
LocationCode = inboundInfo.LocationCode,
|
||||
WarehouseCode = inboundInfo.WarehouseCode,
|
||||
OrderNo = workorderInfo.CustomerOrder,
|
||||
// 原材料工单号
|
||||
Workorder = inboundInfo.Workorder,
|
||||
// 产成品工单号
|
||||
WorkorderRaw = parm.WorkorderRow,
|
||||
Operator = parm.Operator,
|
||||
Quantity = inboundInfo.Quantity,
|
||||
TransactionType = "领料出库",
|
||||
Remarks = $"领料出库,产成品领料出库,原材料工单{inboundInfo.Workorder},产成品工单{parm.WorkorderRow}",
|
||||
};
|
||||
MmInventoryService mmInventoryService = new MmInventoryService();
|
||||
string result = mmInventoryService.CreateOutboundReceipt(revokeRecepitDto);
|
||||
Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
return e.Message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user