feat(物料管理): 新增物料库存相关功能及接口
- 在MmMaterial类中添加ParentMaterialCode字段支持物料层级关系 - 扩展MmRecordOutbound类增加供应商信息字段 - 重构FeedProcessReportwork方法支持原材料工单领料和库存ID指定 - 新增物料库存查询、领料、成品入库、出货等接口 - 完善库存操作逻辑,支持根据库存ID直接操作 - 添加相关DTO类支持新功能的数据传输
This commit is contained in:
@@ -14,7 +14,7 @@ public interface IReportFlowService: IBaseService<ProReportwork01>
|
||||
|
||||
ProReportwork01 GetProcessReportWorkDetail(string workorder, int process);
|
||||
|
||||
bool FeedProcessReportwork(string workorder, int processId, int finish_num, string stove_code, string feed_order, string Worker);
|
||||
bool FeedProcessReportwork(string workorder, int processId, int finish_num, string stove_code, string feed_order, string Worker, string workorderRaw = "", int inventoryId = -1);
|
||||
|
||||
bool ProcessReportWork(string workorder, int process, int finish_num,int bad_num,string Worker);
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
/// <param name="stove_code"></param>
|
||||
/// <param name="feed_order"></param>
|
||||
/// <param name="Worker"></param>
|
||||
/// <param name="workorderRaw">原材料工单号</param>
|
||||
/// <param name="inventoryId">领料库存id</param>
|
||||
/// <returns></returns>
|
||||
public bool FeedProcessReportwork(
|
||||
string workorder,
|
||||
@@ -58,12 +60,30 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
int finish_num,
|
||||
string stove_code,
|
||||
string feed_order,
|
||||
string Worker
|
||||
string Worker,
|
||||
string workorderRaw = "",
|
||||
int inventoryId = -1
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
ProWorkorder proWorkorder = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.First();
|
||||
if (proWorkorder == null)
|
||||
{
|
||||
throw new Exception($"工单不存在,原材料无法出库:{workorder}");
|
||||
}
|
||||
|
||||
int routeId = Context
|
||||
.Queryable<BaseWorkRoute>()
|
||||
.Where(it => it.Code == proWorkorder.RouteCode)
|
||||
.Select(it => it.Id)
|
||||
.First();
|
||||
|
||||
// 是否首次提交
|
||||
bool Exist = Context
|
||||
.Queryable<ProReportwork01>()
|
||||
@@ -72,7 +92,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
|
||||
string NickName = Context
|
||||
.Queryable<SysUser>()
|
||||
.Where(it => it.UserName == Worker)
|
||||
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
@@ -86,7 +106,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.SetColumns(it => it.FinishNum == finish_num)
|
||||
.SetColumns(it => it.Worker == Worker)
|
||||
.SetColumns(it => it.JobDateTime == DateTime.Now)
|
||||
.SetColumns(it => it.RouteId == 32)
|
||||
.SetColumns(it => it.RouteId == routeId)
|
||||
.SetColumns(it => it.UpdatedBy == Worker)
|
||||
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
||||
.ExecuteCommand();
|
||||
@@ -104,7 +124,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
proReportwork01.Workorder = workorder;
|
||||
proReportwork01.ProcessId = processId;
|
||||
proReportwork01.FinishNum = finish_num;
|
||||
proReportwork01.RouteId = 32;
|
||||
proReportwork01.RouteId = routeId;
|
||||
proReportwork01.Worker = Worker;
|
||||
proReportwork01.JobDateTime = DateTime.Now;
|
||||
proReportwork01.CreatedBy = Worker;
|
||||
@@ -124,30 +144,82 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.Where(it => it.TransactionType == "领料出库")
|
||||
.Where(it => it.Remarks != "已撤销")
|
||||
.First();
|
||||
ProWorkorder proWorkorder = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.First();
|
||||
if (proWorkorder == null)
|
||||
{
|
||||
throw new Exception($"工单异常,原材料无法出库:{workorder}");
|
||||
}
|
||||
|
||||
if (outRecordbound == null)
|
||||
if (outRecordbound == null || proWorkorder.RouteCode == "10")
|
||||
{
|
||||
// 根据原材料工单领料的
|
||||
if (!string.IsNullOrEmpty(workorderRaw))
|
||||
{
|
||||
// 需要实现累计领料,超出数量需要提示用户
|
||||
ProWorkorder proWorkorderRawInfo = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorderRaw)
|
||||
.First();
|
||||
if (proWorkorderRawInfo == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception($"原材料工单不存在,无法出库:{workorderRaw}");
|
||||
}
|
||||
MmRecordInbound inboundRecord = Context
|
||||
.Queryable<MmRecordInbound>()
|
||||
.Where(it => it.Workorder == workorderRaw)
|
||||
.Where(it => it.TransactionType == "生产入库")
|
||||
.Where(it => it.Remarks != "已撤销")
|
||||
.First();
|
||||
if (inboundRecord == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception($"原材料工单无成品入库记录:{workorderRaw}");
|
||||
}
|
||||
int newShipmentNum = (proWorkorderRawInfo.ShipmentNum ?? 0) + finish_num;
|
||||
if (newShipmentNum > inboundRecord.Quantity)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception(
|
||||
$"领料数量超出原始工单成品入库数量,请检查:{workorderRaw}"
|
||||
);
|
||||
}
|
||||
Context
|
||||
.Updateable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorderRaw)
|
||||
.SetColumns(it => it.ShipmentNum == newShipmentNum)
|
||||
.ExecuteCommand();
|
||||
inboundRecord.Remarks += $"[已领料{finish_num}]";
|
||||
Context.Updateable(inboundRecord).ExecuteCommand();
|
||||
}
|
||||
string supplierCode = string.Empty;
|
||||
if (inventoryId != -1)
|
||||
{
|
||||
supplierCode =
|
||||
Context
|
||||
.Queryable<MmInventory>()
|
||||
.Where(it => it.Id == inventoryId)
|
||||
.Select(it => it.SupplierCode)
|
||||
.First()
|
||||
?? string.Empty;
|
||||
if (string.IsNullOrEmpty(supplierCode))
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception($"库存信息获取异常,请检查库存是否存在:{inventoryId}");
|
||||
}
|
||||
}
|
||||
|
||||
OutboundReceiptDto revokeRecepitDto = new()
|
||||
{
|
||||
ReceiptType = 1,
|
||||
InventoryId = inventoryId,
|
||||
MaterialCode = proWorkorder.MaterialCode,
|
||||
SupplierCode = supplierCode,
|
||||
BatchNo = feed_order,
|
||||
LocationCode = "YCL001",
|
||||
WarehouseCode = "WH003",
|
||||
OrderNo = proWorkorder.CustomerOrder,
|
||||
Workorder = workorder,
|
||||
WorkorderRaw = workorderRaw,
|
||||
Operator = Worker,
|
||||
Quantity = finish_num,
|
||||
TransactionType = "领料出库",
|
||||
Remarks = $"生产领料,工单号:{workorder}",
|
||||
Remarks = $"生产领料,领取工单号:{workorder},原材料工单号{workorderRaw}",
|
||||
};
|
||||
MmInventoryService mmInventoryService = new();
|
||||
string createReceiptresult = mmInventoryService.CreateOutboundReceipt(
|
||||
@@ -202,13 +274,29 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
try
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
ProWorkorder proWorkorder = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.First();
|
||||
if (proWorkorder == null)
|
||||
{
|
||||
throw new Exception($"工单不存在,原材料无法出库:{workorder}");
|
||||
}
|
||||
|
||||
int routeId = Context
|
||||
.Queryable<BaseWorkRoute>()
|
||||
.Where(it => it.Code == proWorkorder.RouteCode)
|
||||
.Select(it => it.Id)
|
||||
.First();
|
||||
|
||||
bool Exist = Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.Where(it => it.Workorder == workorder && it.ProcessId == process)
|
||||
.Any();
|
||||
string NickName = Context
|
||||
.Queryable<SysUser>()
|
||||
.Where(it => it.UserName == Worker)
|
||||
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
@@ -222,7 +310,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.SetColumns(it => it.FinishNum == finish_num)
|
||||
.SetColumns(it => it.BadNum == bad_num)
|
||||
.SetColumns(it => it.Worker == Worker)
|
||||
.SetColumns(it => it.RouteId == 32)
|
||||
.SetColumns(it => it.RouteId == routeId)
|
||||
.SetColumns(it => it.JobDateTime == DateTime.Now)
|
||||
.SetColumns(it => it.UpdatedBy == Worker)
|
||||
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
||||
@@ -237,7 +325,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
proReportwork01.FinishNum = finish_num;
|
||||
proReportwork01.BadNum = bad_num;
|
||||
proReportwork01.Worker = Worker;
|
||||
proReportwork01.RouteId = 32;
|
||||
proReportwork01.RouteId = routeId;
|
||||
proReportwork01.JobDateTime = DateTime.Now;
|
||||
proReportwork01.CreatedBy = Worker;
|
||||
proReportwork01.CreatedTime = DateTime.Now;
|
||||
@@ -245,19 +333,14 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
}
|
||||
|
||||
// XXX TODO 成品入库(临时使用)
|
||||
|
||||
string workorder_raw = workorder;
|
||||
if (proWorkorder.RouteCode == "10")
|
||||
{
|
||||
//TODO 绑定原有工单
|
||||
workorder_raw = "";
|
||||
}
|
||||
if (process == 70)
|
||||
{
|
||||
// 成品入库
|
||||
ProWorkorder proWorkorder = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.First();
|
||||
if (proWorkorder == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception($"工单异常,无法成品入库:{workorder}");
|
||||
}
|
||||
MmRecordInbound inboundRecord = Context
|
||||
.Queryable<MmRecordInbound>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
@@ -278,16 +361,18 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
if (inboundRecord == null)
|
||||
{
|
||||
//做生产入库单
|
||||
// 暂时默认成品入库与出库批次号都为000
|
||||
InboundReceiptDto revokeRecepitDto = new()
|
||||
{
|
||||
ReceiptType = 1,
|
||||
MaterialCode = proWorkorder.productionCode,
|
||||
BatchNo = proWorkorder.FeedOrder,
|
||||
BatchNo = "000",
|
||||
LocationCode = "CP001",
|
||||
WarehouseCode = "WH001",
|
||||
SupplierCode = mmMaterial.SupplierCode,
|
||||
StoveCode = proWorkorder.StoveCode,
|
||||
Workorder = workorder,
|
||||
WorkorderRaw = workorder_raw,
|
||||
Operator = Worker,
|
||||
Quantity = finish_num,
|
||||
TransactionType = "生产入库",
|
||||
@@ -370,13 +455,17 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
|
||||
string NickName = Context
|
||||
.Queryable<SysUser>()
|
||||
.Where(it => it.UserName == Worker)
|
||||
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
|
||||
int result = 0;
|
||||
|
||||
int routeId = Context
|
||||
.Queryable<BaseWorkRoute>()
|
||||
.Where(it => it.Code == workorderInfo.RouteCode)
|
||||
.Select(it => it.Id)
|
||||
.First();
|
||||
// 判断报工信息是否存在
|
||||
Context.Ado.BeginTran();
|
||||
// 更新报工信息
|
||||
@@ -395,7 +484,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
FinishNum = finish_num,
|
||||
BadNum = bad_num,
|
||||
Worker = Worker,
|
||||
RouteId = 32,
|
||||
RouteId = routeId,
|
||||
JobDateTime = DateTime.Now,
|
||||
CreatedBy = Worker,
|
||||
CreatedTime = DateTime.Now,
|
||||
@@ -422,11 +511,14 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.First();
|
||||
if (outboundDto == null)
|
||||
{
|
||||
// Todo找还有库存的成品库
|
||||
|
||||
// 暂时默认成品入库与出库批次号都为000
|
||||
OutboundReceiptDto revokeRecepitDto = new()
|
||||
{
|
||||
ReceiptType = 1,
|
||||
MaterialCode = workorderInfo.productionCode,
|
||||
BatchNo = workorderInfo.FeedOrder,
|
||||
BatchNo = "000",
|
||||
LocationCode = "CP001",
|
||||
WarehouseCode = "WH001",
|
||||
OrderNo = customer_order,
|
||||
@@ -459,7 +551,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.SetColumns(it => it.ShipmentNum == finish_num)
|
||||
.SetColumns(it => it.CustomerOrder == customer_order)
|
||||
.ExecuteCommand();
|
||||
// 修改采购订单信息
|
||||
// 修改采购订单是否完成
|
||||
int newQuantity =
|
||||
Context
|
||||
.Queryable<ProWorkorder>()
|
||||
|
||||
Reference in New Issue
Block a user