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.
89 lines
3.3 KiB
89 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
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.Basedata.Application.Contracts;
|
|
using Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Qad;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Iac.Qad;
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Application.Iac.Qad;
|
|
|
|
/// <summary>
|
|
/// QAD生产线(Production line)
|
|
/// </summary>
|
|
//[Authorize(IncomingToWmsPermissions.Default)]
|
|
[Microsoft.AspNetCore.Components.Route($"{DataExchangeConsts.RouteRoot}production-line")]
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.WmsWebApi)]
|
|
public class ProductLineAppService : ApplicationService, IProductLineAppService
|
|
{
|
|
private readonly Basedata.Application.Contracts.IProductionLineAppService _productionLineAppService;
|
|
|
|
private readonly IProd_lineRepository _prod_lineRepository;
|
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public ProductLineAppService(
|
|
Basedata.Application.Contracts.IProductionLineAppService productionLineAppService,
|
|
IProd_lineRepository prod_lineRepository,
|
|
IConfiguration configuration
|
|
)
|
|
{
|
|
_productionLineAppService = productionLineAppService;
|
|
_prod_lineRepository = prod_lineRepository;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
/// <summary>
|
|
///生产线(Production Line)
|
|
/// </summary>
|
|
/// <param name="input">QAD生产线(Production line)</param>
|
|
/// <returns></returns>
|
|
[HttpPost("")]
|
|
[Volo.Abp.Uow.UnitOfWork(isTransactional: false)]
|
|
public virtual async Task<ActionResult<ProdLineDto>> AddAsync(ProdLineInput input)
|
|
{
|
|
|
|
var entityObj = ObjectMapper.Map<ProdLineInput, ProdLine>(input);
|
|
try
|
|
{
|
|
//调用业务接口前,先做业务数据校验
|
|
//数据格式校验使用ABP提供的校验模块(Application.Contract.XXXInputValidator),不需要在这里实现
|
|
Validator.CheckSite(_configuration, entityObj.Site);
|
|
Validator.CheckCompany(_configuration, entityObj.Company);
|
|
var targetObj = ObjectMapper.Map<ProdLine, ProductionLineEditInput>(entityObj);
|
|
//if (targetObj.Type == null) { targetObj.Type = 0; }
|
|
if (targetObj.WorkshopCode == null) { targetObj.WorkshopCode = "_"; }
|
|
if (targetObj.RawLocationCode == null) { targetObj.RawLocationCode = "_"; }
|
|
if (targetObj.ProductLocationCode == null) { targetObj.ProductLocationCode = "_"; }
|
|
|
|
await _productionLineAppService.UpsertAsync(targetObj).ConfigureAwait(false);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var baseEx = ex.GetBaseException();
|
|
entityObj.ErrorCode = 1;
|
|
entityObj.ErrorMessage = baseEx.Message;
|
|
}
|
|
|
|
_ = await _prod_lineRepository.InsertAsync(entityObj, true).ConfigureAwait(false);
|
|
|
|
var dto = ObjectMapper.Map<ProdLine, ProdLineDto>(entityObj);
|
|
dto.CreationTime = Clock.Now;
|
|
if (dto.ErrorCode != 0)
|
|
{
|
|
throw new AbpValidationException(new List<ValidationResult>
|
|
{
|
|
new(dto.ErrorMessage)
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return new OkObjectResult(dto);
|
|
}
|
|
}
|
|
}
|
|
|