You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
4.2 KiB
115 lines
4.2 KiB
2 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel.DataAnnotations;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Volo.Abp.Application.Services;
|
||
|
using Volo.Abp.Validation;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Qad;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Domain.Iac.Qad;
|
||
|
using Win_in.Sfs.Wms.Store.Application.Contracts;
|
||
|
using ISupplierAsnAppService = Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Qad.ISupplierAsnAppService;
|
||
|
|
||
|
namespace Win_in.Sfs.Wms.DataExchange.Application.Iac.Qad;
|
||
|
|
||
|
/// <summary>
|
||
|
/// QAD发货单(ASN Master)
|
||
|
/// </summary>
|
||
|
//[Authorize(IncomingToWmsPermissions.Default)]
|
||
|
[Microsoft.AspNetCore.Components.Route($"{DataExchangeConsts.RouteRoot}asn")]
|
||
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.WmsWebApi)]
|
||
|
public class SupplierAsnAppService : ApplicationService, ISupplierAsnAppService
|
||
|
{
|
||
|
private readonly Store.Application.Contracts.ISupplierAsnAppService _supplierAsnAppService;
|
||
|
|
||
|
private readonly IAsn_mstrRepository _asn_mstrRepository;
|
||
|
|
||
|
private readonly IConfiguration _configuration;
|
||
|
|
||
|
public SupplierAsnAppService(
|
||
|
Store.Application.Contracts.ISupplierAsnAppService supplierAsnAppService,
|
||
|
IAsn_mstrRepository asn_mstrRepository,
|
||
|
IConfiguration configuration
|
||
|
)
|
||
|
{
|
||
|
_supplierAsnAppService = supplierAsnAppService;
|
||
|
_asn_mstrRepository = asn_mstrRepository;
|
||
|
_configuration = configuration;
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 发货单(ASN)
|
||
|
/// </summary>
|
||
|
/// <param name="input">QAD发货单(ASN)</param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost("")]
|
||
|
[Volo.Abp.Uow.UnitOfWork(isTransactional: false)]
|
||
|
public virtual async Task<ActionResult<AsnMstrDto>> AddAsync(AsnMstrInput input)
|
||
|
{
|
||
|
|
||
|
var entityObj = ObjectMapper.Map<AsnMstrInput, AsnMstr>(input);
|
||
|
try
|
||
|
{
|
||
|
//调用业务接口前,先做业务数据校验
|
||
|
//数据格式校验使用ABP提供的校验模块(Application.Contract.XXXInputValidator),不需要在这里实现
|
||
|
Validator.CheckSite(_configuration, entityObj.Site);
|
||
|
Validator.CheckCompany(_configuration, entityObj.Company);
|
||
|
var targetObj = ObjectMapper.Map<AsnMstr, SupplierAsnEditInput>(entityObj); //包含明细列表
|
||
|
|
||
|
#region 特殊转换
|
||
|
foreach (var srcDtlObj in entityObj.Details)
|
||
|
{
|
||
|
var tarDtlObj = targetObj.Details.FirstOrDefault(itm => itm.PoLine == srcDtlObj.PoLine.ToString());
|
||
|
if (tarDtlObj != null)
|
||
|
{
|
||
|
|
||
|
tarDtlObj.Uom = srcDtlObj.PoUm;
|
||
|
tarDtlObj.Qty = srcDtlObj.Qty;
|
||
|
|
||
|
tarDtlObj.StdPackQty = srcDtlObj.StdPackQty;
|
||
|
|
||
|
tarDtlObj.SupplierBatch = srcDtlObj.Supplierlot;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
targetObj.ContactName = entityObj.Contacts;
|
||
|
targetObj.ContactPhone = entityObj.Phone;
|
||
|
targetObj.ContactEmail = "";
|
||
|
targetObj.DockCode = targetObj.DockCode ?? String.Empty;
|
||
|
targetObj.RpNumber = targetObj.RpNumber ?? String.Empty;
|
||
|
//??为了屏蔽错误Unable to cast object of type 'Win_in.Sfs.Shared.Domain.Person' to type 'System.String' lyf at 2022-05-07。 5-24日解决
|
||
|
//targetObj.Contacts = null;
|
||
|
#endregion
|
||
|
|
||
|
await _supplierAsnAppService.UpsertAsync(targetObj).ConfigureAwait(false);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
var baseEx = ex.GetBaseException();
|
||
|
entityObj.ErrorCode = 1;
|
||
|
entityObj.ErrorMessage = baseEx.Message;
|
||
|
}
|
||
|
|
||
|
entityObj.SetIdAndDetailId(GuidGenerator);
|
||
|
|
||
|
var ret = await _asn_mstrRepository.InsertAsync(entityObj, true).ConfigureAwait(false);
|
||
|
|
||
|
var dto = ObjectMapper.Map<AsnMstr, AsnMstrDto>(entityObj);
|
||
|
dto.CreationTime = Clock.Now;
|
||
|
if (dto.ErrorCode != 0)
|
||
|
{
|
||
|
throw new AbpValidationException(new List<ValidationResult>
|
||
|
{
|
||
|
new(dto.ErrorMessage)
|
||
|
});
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return new OkObjectResult(dto);
|
||
|
}
|
||
|
}
|
||
|
}
|