feat(领料): 添加原材料领料功能接口

实现原材料领料功能,包括:
1. 在IMmRecordInboundService接口添加TakeMaterial方法
2. 新增TakeMaterialRequestDto请求参数类
3. 在MmRecordInboundController添加领料API接口
4. 实现领料业务逻辑,包括工单校验和出库单生成
This commit is contained in:
2026-01-27 15:56:10 +08:00
parent 69da20ba42
commit a43550ab28
5 changed files with 123 additions and 3 deletions

View File

@@ -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;
}
}
}
}