feat(IPQC): 完善报废和转用单处理流程
重构报废和转用单创建逻辑,使用DefectApproveDto作为参数 新增批次号、处理数量和操作人字段 实现不良品出库和报废/转用入库的完整流程
This commit is contained in:
@@ -194,7 +194,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
[HttpPost("scrapOrder/byWorkorder")]
|
[HttpPost("scrapOrder/byWorkorder")]
|
||||||
[ActionPermissionFilter(Permission = "qcscraprecords:add")]
|
[ActionPermissionFilter(Permission = "qcscraprecords:add")]
|
||||||
[Log(Title = "根据工单号创建报废单", BusinessType = BusinessType.INSERT)]
|
[Log(Title = "根据工单号创建报废单", BusinessType = BusinessType.INSERT)]
|
||||||
public IActionResult CreateScrapOrderByWorkorder([FromBody] QcScrapRecordsDto parm)
|
public IActionResult CreateScrapOrderByWorkorder([FromBody] DefectApproveDto parm)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -202,14 +202,20 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status400BadRequest, "工单号不能为空");
|
return ToResponse(StatusCodes.Status400BadRequest, "工单号不能为空");
|
||||||
}
|
}
|
||||||
|
var response = _QcScrapRecordsService.CreateScrapOrderByWorkorder(parm);
|
||||||
var modal = parm.Adapt<QcScrapRecords>().ToCreate(HttpContext);
|
if(response == "ok")
|
||||||
var response = _QcScrapRecordsService.CreateScrapOrderByWorkorder(modal);
|
{
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, response));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status500InternalServerError, ex.Message);
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +227,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
[HttpPost("transferOrder/byWorkorder")]
|
[HttpPost("transferOrder/byWorkorder")]
|
||||||
[ActionPermissionFilter(Permission = "qcscraprecords:add")]
|
[ActionPermissionFilter(Permission = "qcscraprecords:add")]
|
||||||
[Log(Title = "根据工单号创建转用单", BusinessType = BusinessType.INSERT)]
|
[Log(Title = "根据工单号创建转用单", BusinessType = BusinessType.INSERT)]
|
||||||
public IActionResult CreateTransferOrderByWorkorder([FromBody] QcScrapRecordsDto parm)
|
public IActionResult CreateTransferOrderByWorkorder([FromBody] DefectApproveDto parm)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -229,14 +235,19 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status400BadRequest, "工单号不能为空");
|
return ToResponse(StatusCodes.Status400BadRequest, "工单号不能为空");
|
||||||
}
|
}
|
||||||
|
var response = _QcScrapRecordsService.CreateTransferOrderByWorkorder(parm);
|
||||||
var modal = parm.Adapt<QcScrapRecords>().ToCreate(HttpContext);
|
if (response == "ok")
|
||||||
var response = _QcScrapRecordsService.CreateTransferOrderByWorkorder(modal);
|
{
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status500InternalServerError, ex.Message);
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +274,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status500InternalServerError, ex.Message);
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,15 +297,15 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ToResponse(
|
return ToResponse(new ApiResult(
|
||||||
StatusCodes.Status400BadRequest,
|
StatusCodes.Status400BadRequest,
|
||||||
"撤销不良品记录失败,可能记录已被审批或不存在"
|
"撤销不良品记录失败,可能记录已被审批或不存在"
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return ToResponse(StatusCodes.Status500InternalServerError, ex.Message);
|
return ToResponse(new ApiResult(StatusCodes.Status500InternalServerError, ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,17 @@ namespace DOAN.Model.BZFM.Dto
|
|||||||
/// 工单号
|
/// 工单号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Workorder { get; set; }
|
public string Workorder { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 处理批次号
|
||||||
|
/// </summary>
|
||||||
|
public string BatchNo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 处理数量
|
||||||
|
/// </summary>
|
||||||
|
public decimal ScrapQuantity { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 操作人
|
||||||
|
/// </summary>
|
||||||
|
public string Operator { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,18 +54,18 @@ namespace DOAN.Service.BZFM.IService
|
|||||||
PagedInfo<QcScrapRecordsDto> GetQcScrapRecordsByWorkorder(string workorder);
|
PagedInfo<QcScrapRecordsDto> GetQcScrapRecordsByWorkorder(string workorder);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据工单号填写报废单
|
/// 根据工单号填写报废单(入报废库)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">报废单数据</param>
|
/// <param name="parm">报废单数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
QcScrapRecords CreateScrapOrderByWorkorder(QcScrapRecords parm);
|
string CreateScrapOrderByWorkorder(DefectApproveDto parm);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据工单号填写转用单
|
/// 根据工单号填写转用单(入转用库)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">转用单数据</param>
|
/// <param name="parm">转用单数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
QcScrapRecords CreateTransferOrderByWorkorder(QcScrapRecords parm);
|
string CreateTransferOrderByWorkorder(DefectApproveDto parm);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据工单号填写不良品单
|
/// 根据工单号填写不良品单
|
||||||
|
|||||||
@@ -502,15 +502,92 @@ namespace DOAN.Service.BZFM
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">报废单数据</param>
|
/// <param name="parm">报废单数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public QcScrapRecords CreateScrapOrderByWorkorder(QcScrapRecords parm)
|
public string CreateScrapOrderByWorkorder(DefectApproveDto parm)
|
||||||
{
|
{
|
||||||
// 验证工单号
|
try
|
||||||
if (string.IsNullOrEmpty(parm.Workorder))
|
|
||||||
{
|
{
|
||||||
throw new Exception("工单号不能为空");
|
// 验证工单号
|
||||||
|
if (string.IsNullOrEmpty(parm.Workorder))
|
||||||
|
{
|
||||||
|
throw new Exception("工单号不能为空");
|
||||||
|
}
|
||||||
|
// 工单信息查看
|
||||||
|
var workorderInfo = Context
|
||||||
|
.Queryable<ProWorkorder>()
|
||||||
|
.Where(it => it.Workorder == parm.Workorder)
|
||||||
|
.First();
|
||||||
|
if (workorderInfo == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"工单信息为空{parm.Workorder}");
|
||||||
|
}
|
||||||
|
var inboundRecordInfo = Context
|
||||||
|
.Queryable<MmRecordInbound>()
|
||||||
|
.Where(it => it.Id == parm.Id)
|
||||||
|
.First();
|
||||||
|
if (inboundRecordInfo == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"入库记录不存在{parm.Id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不良出库
|
||||||
|
MmInventoryService mmInventoryService = new();
|
||||||
|
|
||||||
|
OutboundReceiptDto outboundRecepitDto = new()
|
||||||
|
{
|
||||||
|
ReceiptType = 1,
|
||||||
|
InventoryId = -1,
|
||||||
|
MaterialCode = inboundRecordInfo.MaterialCode,
|
||||||
|
SupplierCode = inboundRecordInfo.SupplierCode,
|
||||||
|
BatchNo = inboundRecordInfo.BatchNo,
|
||||||
|
StoveCode = inboundRecordInfo.StoveCode,
|
||||||
|
LocationCode = inboundRecordInfo.LocationCode,
|
||||||
|
WarehouseCode = inboundRecordInfo.WarehouseCode,
|
||||||
|
OrderNo = workorderInfo.CustomerOrder,
|
||||||
|
Workorder = inboundRecordInfo.Workorder,
|
||||||
|
WorkorderRaw = inboundRecordInfo.WorkorderRaw,
|
||||||
|
Operator = parm.Operator,
|
||||||
|
Quantity = parm.ScrapQuantity,
|
||||||
|
TransactionType = "不良出库",
|
||||||
|
Remarks = $"不良品报废出库,数量为{parm.ScrapQuantity}",
|
||||||
|
};
|
||||||
|
string outboundReceiptResult = mmInventoryService.CreateOutboundReceipt(
|
||||||
|
outboundRecepitDto
|
||||||
|
);
|
||||||
|
if (outboundReceiptResult != "ok")
|
||||||
|
{
|
||||||
|
throw new Exception(outboundReceiptResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 报废入库
|
||||||
|
InboundReceiptDto inboundRecepitDto = new()
|
||||||
|
{
|
||||||
|
ReceiptType = 1,
|
||||||
|
MaterialCode = inboundRecordInfo.MaterialCode,
|
||||||
|
BatchNo = parm.BatchNo,
|
||||||
|
LocationCode = "BFK001",
|
||||||
|
WarehouseCode = "WH006",
|
||||||
|
SupplierCode = inboundRecordInfo.SupplierCode,
|
||||||
|
StoveCode = inboundRecordInfo.StoveCode,
|
||||||
|
Workorder = inboundRecordInfo.Workorder,
|
||||||
|
WorkorderRaw = inboundRecordInfo.WorkorderRaw,
|
||||||
|
Operator = parm.Operator,
|
||||||
|
Quantity = parm.ScrapQuantity,
|
||||||
|
TransactionType = "报废入库",
|
||||||
|
Remarks = $"报废入库,来源不良单号:{inboundRecordInfo.InboundNo}",
|
||||||
|
};
|
||||||
|
string inboundReceiptresult = mmInventoryService.CreateInboundReceipt(inboundRecepitDto);
|
||||||
|
if (inboundReceiptresult != "ok")
|
||||||
|
{
|
||||||
|
throw new Exception(inboundReceiptresult);
|
||||||
|
}
|
||||||
|
inboundRecordInfo.Remarks += $"[已报废{parm.ScrapQuantity}]";
|
||||||
|
Context.Updateable(inboundRecordInfo).UpdateColumns(it => new { it.Remarks }).ExecuteCommand();
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
}
|
}
|
||||||
// 调用现有的创建报废单方法
|
|
||||||
return CreateScrapOrder(parm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -518,16 +595,91 @@ namespace DOAN.Service.BZFM
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">转用单数据</param>
|
/// <param name="parm">转用单数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public QcScrapRecords CreateTransferOrderByWorkorder(QcScrapRecords parm)
|
public string CreateTransferOrderByWorkorder(DefectApproveDto parm)
|
||||||
{
|
{
|
||||||
// 验证工单号
|
try
|
||||||
if (string.IsNullOrEmpty(parm.Workorder))
|
|
||||||
{
|
{
|
||||||
throw new Exception("工单号不能为空");
|
// 验证工单号
|
||||||
}
|
if (string.IsNullOrEmpty(parm.Workorder))
|
||||||
|
{
|
||||||
|
throw new Exception("工单号不能为空");
|
||||||
|
}
|
||||||
|
// 工单信息查看
|
||||||
|
var workorderInfo = Context
|
||||||
|
.Queryable<ProWorkorder>()
|
||||||
|
.Where(it => it.Workorder == parm.Workorder)
|
||||||
|
.First();
|
||||||
|
if (workorderInfo == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"工单信息为空{parm.Workorder}");
|
||||||
|
}
|
||||||
|
var inboundRecordInfo = Context
|
||||||
|
.Queryable<MmRecordInbound>()
|
||||||
|
.Where(it => it.Id == parm.Id)
|
||||||
|
.First();
|
||||||
|
if (inboundRecordInfo == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"入库记录不存在{parm.Id}");
|
||||||
|
}
|
||||||
|
// 不良出库
|
||||||
|
MmInventoryService mmInventoryService = new();
|
||||||
|
|
||||||
// 调用现有的创建转用单方法
|
OutboundReceiptDto outboundRecepitDto = new()
|
||||||
return CreateTransferOrder(parm);
|
{
|
||||||
|
ReceiptType = 1,
|
||||||
|
InventoryId = -1,
|
||||||
|
MaterialCode = inboundRecordInfo.MaterialCode,
|
||||||
|
SupplierCode = inboundRecordInfo.SupplierCode,
|
||||||
|
BatchNo = inboundRecordInfo.BatchNo,
|
||||||
|
StoveCode = inboundRecordInfo.StoveCode,
|
||||||
|
LocationCode = inboundRecordInfo.LocationCode,
|
||||||
|
WarehouseCode = inboundRecordInfo.WarehouseCode,
|
||||||
|
OrderNo = workorderInfo.CustomerOrder,
|
||||||
|
Workorder = inboundRecordInfo.Workorder,
|
||||||
|
WorkorderRaw = inboundRecordInfo.WorkorderRaw,
|
||||||
|
Operator = parm.Operator,
|
||||||
|
Quantity = parm.ScrapQuantity,
|
||||||
|
TransactionType = "不良出库",
|
||||||
|
Remarks = $"不良品报废出库,数量为{parm.ScrapQuantity}",
|
||||||
|
};
|
||||||
|
string outboundReceiptResult = mmInventoryService.CreateOutboundReceipt(
|
||||||
|
outboundRecepitDto
|
||||||
|
);
|
||||||
|
if (outboundReceiptResult != "ok")
|
||||||
|
{
|
||||||
|
throw new Exception(outboundReceiptResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 报废入库
|
||||||
|
InboundReceiptDto inboundRecepitDto = new()
|
||||||
|
{
|
||||||
|
ReceiptType = 1,
|
||||||
|
MaterialCode = inboundRecordInfo.MaterialCode,
|
||||||
|
BatchNo = parm.BatchNo,
|
||||||
|
LocationCode = "ZYK001",
|
||||||
|
WarehouseCode = "WH005",
|
||||||
|
SupplierCode = inboundRecordInfo.SupplierCode,
|
||||||
|
StoveCode = inboundRecordInfo.StoveCode,
|
||||||
|
Workorder = inboundRecordInfo.Workorder,
|
||||||
|
WorkorderRaw = inboundRecordInfo.WorkorderRaw,
|
||||||
|
Operator = parm.Operator,
|
||||||
|
Quantity = parm.ScrapQuantity,
|
||||||
|
TransactionType = "转用入库",
|
||||||
|
Remarks = $"转用入库,来源不良单号:{inboundRecordInfo.InboundNo}",
|
||||||
|
};
|
||||||
|
string inboundReceiptresult = mmInventoryService.CreateInboundReceipt(inboundRecepitDto);
|
||||||
|
if (inboundReceiptresult != "ok")
|
||||||
|
{
|
||||||
|
throw new Exception(inboundReceiptresult);
|
||||||
|
}
|
||||||
|
inboundRecordInfo.Remarks += $"[已转用{parm.ScrapQuantity}]";
|
||||||
|
Context.Updateable(inboundRecordInfo).UpdateColumns(it => new { it.Remarks }).ExecuteCommand();
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user