fix(生产管理): 修复工单数量类型及完善出货逻辑
将工单数量字段从可空类型改为非可空类型并添加默认值 添加成品入库数量字段并完善相关业务逻辑 修复出货失败时的错误响应 完善撤销入库/出库操作时的工单数量调整 增加出货数量与成品入库数量的校验
This commit is contained in:
@@ -171,7 +171,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception($"原材料工单无成品入库记录:{workorderRaw}");
|
||||
}
|
||||
int newShipmentNum = (proWorkorderRawInfo.ShipmentNum ?? 0) + finish_num;
|
||||
int newShipmentNum = (proWorkorderRawInfo.ShipmentNum) + finish_num;
|
||||
if (newShipmentNum > inboundRecord.Quantity)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
@@ -341,12 +341,6 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
}
|
||||
if (process == 70)
|
||||
{
|
||||
MmRecordInbound inboundRecord = Context
|
||||
.Queryable<MmRecordInbound>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.Where(it => it.TransactionType == "生产入库")
|
||||
.Where(it => it.Remarks != "已撤销")
|
||||
.First();
|
||||
MmMaterial mmMaterial = Context
|
||||
.Queryable<MmMaterial>()
|
||||
.Where(it => it.MaterialCode == proWorkorder.productionCode)
|
||||
@@ -358,7 +352,9 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
$"物料档案不存在,无法成品入库:{proWorkorder.productionCode}"
|
||||
);
|
||||
}
|
||||
if (inboundRecord == null)
|
||||
|
||||
proWorkorder.ProductNum += finish_num;
|
||||
if (proWorkorder.PlanNum >= proWorkorder.ProductNum)
|
||||
{
|
||||
//做生产入库单
|
||||
// 暂时默认成品入库与出库批次号都为000
|
||||
@@ -387,11 +383,12 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception(createReceiptresult);
|
||||
}
|
||||
Context.Updateable(proWorkorder).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("重新成品入库前请先撤销已有物料生产入库记录!");
|
||||
throw new Exception("成品入库数超出计划数!");
|
||||
}
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
@@ -503,13 +500,9 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
}
|
||||
|
||||
// XXX 成品库出库
|
||||
MmRecordOutbound outboundDto = Context
|
||||
.Queryable<MmRecordOutbound>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.Where(it => it.TransactionType == "出货出库")
|
||||
.Where(it => it.Remarks != "已撤销")
|
||||
.First();
|
||||
if (outboundDto == null)
|
||||
// 需要保证已入库数大于等于已出货数+现在要出货的数量
|
||||
workorderInfo.ShipmentNum += finish_num;
|
||||
if (workorderInfo.ProductNum >= workorderInfo.ShipmentNum)
|
||||
{
|
||||
// Todo找还有库存的成品库
|
||||
|
||||
@@ -541,23 +534,16 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
else
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("重新出货前请先撤销物料出货出库记录");
|
||||
throw new Exception("出货数超出工单成品入库数!");
|
||||
}
|
||||
|
||||
workorderInfo.CustomerOrder = customer_order;
|
||||
// 修改工单信息
|
||||
Context
|
||||
.Updateable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.ShipmentNum == finish_num)
|
||||
.SetColumns(it => it.CustomerOrder == customer_order)
|
||||
.ExecuteCommand();
|
||||
Context.Updateable(workorderInfo).ExecuteCommand();
|
||||
// 修改采购订单是否完成
|
||||
int newQuantity =
|
||||
Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.CustomerOrder == customer_order)
|
||||
.Sum(it => it.ShipmentNum)
|
||||
?? 0;
|
||||
int newQuantity = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.CustomerOrder == customer_order)
|
||||
.Sum(it => it.ShipmentNum);
|
||||
orderPurchase.DeliveryQuantity = newQuantity;
|
||||
if (orderPurchase.DeliveryQuantity > orderPurchase.DemandQuantity)
|
||||
{
|
||||
@@ -577,10 +563,10 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
Context.Ado.CommitTran();
|
||||
return result > 0 ? 1 : 0;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw;
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user