feat: 支持ERP主动下发成品发货通知单并复用导入逻辑
This commit is contained in:
1 parent
80d1b201b0
commit
ede6d32608
9 files changed
+555
-103
No files matched your search
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using HHWMS.Web.Support;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
[Public]
|
||||
[ApiController]
|
||||
[Route("api/erp")]
|
||||
[ApiExplorerSettings(GroupName = "User")]
|
||||
[ActionDescription("ERP发货通知单下发")]
|
||||
public class ErpController : ApiController
|
||||
{
|
||||
private readonly DispatchImportService _import;
|
||||
private readonly ILogger<ErpController> _logger;
|
||||
|
||||
public ErpController(DispatchImportService import, ILogger<ErpController> logger)
|
||||
{
|
||||
_import = import;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost("dispatch-notices")]
|
||||
[RequestSizeLimit(10 * 1024 * 1024)]
|
||||
public async Task<IActionResult> ReceiveDispatch([FromBody] ReceiveDispatchRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = await _import.ImportAsync(request?.Data, "ERP");
|
||||
var codes = request.Data.Select(x => x.DLCode).Distinct().ToArray();
|
||||
_logger.LogInformation("ERP下发发货通知单成功,单号{Codes},明细数{Count}", string.Join(",", codes), count);
|
||||
return ApiResult(new { BillCount = codes.Length, DetailCount = count, DLCodes = codes }, "发货通知单接收成功");
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "ERP下发发货通知单校验失败");
|
||||
return ApiResultError(msg: ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "ERP下发发货通知单保存失败");
|
||||
return StatusCode(500, new ApiJsonResult<object> { Msg = "发货通知单保存失败,请联系WMS管理员或稍后重试" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user