feat(工单管理): 新增工单物料查询及生产进度功能
新增工单物料服务接口及实现,包括领料清单、成品入库清单和出货清单查询 添加工单生产进度查询功能及相关DTO定义 完善工单修改日志记录功能 规范工单号字段使用,区分原材料工单号和当前工单号
This commit is contained in:
@@ -370,9 +370,118 @@ namespace DOAN.Service.BZFM
|
||||
TransactionType = it.TransactionType,
|
||||
OrderNo = it.OrderNo,
|
||||
Operator = it.Operator,
|
||||
WorkorderRaw = it.WorkorderRaw
|
||||
});
|
||||
|
||||
return query.ToPage(pager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化出库记录数据
|
||||
/// </summary>
|
||||
/// <param name="outboundRecord">出库记录对象</param>
|
||||
/// <param name="currentWorkorder">当前操作工单号</param>
|
||||
/// <param name="rawMaterialWorkorder">原材料工单号(如果有)</param>
|
||||
/// <returns>初始化后的出库记录对象</returns>
|
||||
/// <exception cref="ArgumentException">参数验证异常</exception>
|
||||
public MmRecordOutbound InitializeShipmentRecord(MmRecordOutbound outboundRecord, string currentWorkorder, string rawMaterialWorkorder = null)
|
||||
{
|
||||
// 参数验证
|
||||
if (outboundRecord == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(outboundRecord), "出库记录对象不能为空");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(currentWorkorder))
|
||||
{
|
||||
throw new ArgumentException("当前操作工单号不能为空", nameof(currentWorkorder));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(outboundRecord.MaterialCode))
|
||||
{
|
||||
throw new ArgumentException("物料编码不能为空");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(outboundRecord.WarehouseCode))
|
||||
{
|
||||
throw new ArgumentException("仓库编码不能为空");
|
||||
}
|
||||
|
||||
if (outboundRecord.Quantity <= 0)
|
||||
{
|
||||
throw new ArgumentException("出库数量必须大于0");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(outboundRecord.TransactionType))
|
||||
{
|
||||
throw new ArgumentException("出库类型不能为空");
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
if (string.IsNullOrWhiteSpace(outboundRecord.OutboundNo))
|
||||
{
|
||||
// 生成出库单号:OUT + 年月日时分秒
|
||||
outboundRecord.OutboundNo = "OUT" + DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
if (outboundRecord.CreatedTime == null)
|
||||
{
|
||||
outboundRecord.CreatedTime = DateTime.Now;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(outboundRecord.Unit))
|
||||
{
|
||||
outboundRecord.Unit = "个";
|
||||
}
|
||||
|
||||
// 字段使用规范:
|
||||
// WorkorderRaw:永久性记录原材料最初关联的工单号信息,保持不变
|
||||
// Workorder:动态记录当前操作环节所对应的工单号,根据实际业务操作场景实时更新
|
||||
if (!string.IsNullOrWhiteSpace(rawMaterialWorkorder))
|
||||
{
|
||||
// 如果提供了原材料工单号,设置为WorkorderRaw
|
||||
outboundRecord.WorkorderRaw = rawMaterialWorkorder;
|
||||
}
|
||||
else if (string.IsNullOrWhiteSpace(outboundRecord.WorkorderRaw))
|
||||
{
|
||||
// 如果没有提供原材料工单号且WorkorderRaw为空,则使用当前工单号作为初始值
|
||||
outboundRecord.WorkorderRaw = currentWorkorder;
|
||||
}
|
||||
// 注意:如果WorkorderRaw已经有值,保持不变,确保其在整个生命周期中保持恒定
|
||||
|
||||
// 更新当前操作工单号
|
||||
outboundRecord.Workorder = currentWorkorder;
|
||||
|
||||
return outboundRecord;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建并初始化出库记录
|
||||
/// </summary>
|
||||
/// <param name="outboundRecord">出库记录对象</param>
|
||||
/// <param name="currentWorkorder">当前操作工单号</param>
|
||||
/// <param name="rawMaterialWorkorder">原材料工单号(如果有)</param>
|
||||
/// <returns>创建的出库记录对象</returns>
|
||||
public MmRecordOutbound CreateAndInitializeShipmentRecord(MmRecordOutbound outboundRecord, string currentWorkorder, string rawMaterialWorkorder = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 初始化出库记录数据
|
||||
var initializedRecord = InitializeShipmentRecord(outboundRecord, currentWorkorder, rawMaterialWorkorder);
|
||||
|
||||
// 保存到数据库
|
||||
return Insertable(initializedRecord).ExecuteReturnEntity();
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
// 处理参数验证异常
|
||||
throw new Exception($"出库记录初始化失败:{ex.Message}", ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 处理其他异常
|
||||
throw new Exception($"创建出库记录失败:{ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user