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.
101 lines
3.4 KiB
101 lines
3.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
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物料(Part)
|
|
/// </summary>
|
|
//[Authorize(IncomingToWmsPermissions.Default)]
|
|
[Authorize]
|
|
[Microsoft.AspNetCore.Components.Route($"{DataExchangeConsts.RouteRoot}part")]
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.WmsWebApi)]
|
|
public class PartAppService : ApplicationService, IPartAppService
|
|
{
|
|
private readonly IItemBasicAppService _itemBasicAppService;
|
|
private readonly IPartRepository _partRepository;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public PartAppService(
|
|
IItemBasicAppService itemBasicAppService,
|
|
IPartRepository partRepository,
|
|
IConfiguration configuration
|
|
)
|
|
{
|
|
_itemBasicAppService = itemBasicAppService;
|
|
_partRepository = partRepository;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 物料(Part)
|
|
/// </summary>
|
|
/// <param name="input">QAD物料(Part)</param>
|
|
/// <returns></returns>
|
|
[HttpPost("")]
|
|
[Volo.Abp.Uow.UnitOfWork(isTransactional: false)]
|
|
public virtual async Task<ActionResult<PartDto>> AddAsync(PartInput input)
|
|
{
|
|
|
|
var entity = ObjectMapper.Map<PartInput, Part>(input);
|
|
|
|
try
|
|
{
|
|
//调用业务接口前,先做业务数据校验
|
|
//数据格式校验使用ABP提供的校验模块(Application.Contract.PartInputValidator),不需要在这里实现
|
|
Validator.CheckCompany(_configuration, entity.Company);
|
|
Validator.CheckSite(_configuration, entity.Site);
|
|
|
|
//将接口实体转换为业务输入实体
|
|
var createInput = ObjectMapper.Map<Part, ItemBasicEditInput>(entity);
|
|
switch (entity.Status)
|
|
{
|
|
case "INACTIVE":
|
|
createInput.Status = Shared.Domain.Shared.EnumItemStatus.Disable;
|
|
break;
|
|
default:
|
|
createInput.Status = Shared.Domain.Shared.EnumItemStatus.Active;
|
|
break;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(createInput.AbcClass))
|
|
{
|
|
createInput.AbcClass = "Z";//客户要求逻辑
|
|
}
|
|
//调用业务接口,新增或更新业务数据
|
|
await _itemBasicAppService.UpsertAsync(createInput).ConfigureAwait(false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var baseEx = ex.GetBaseException();
|
|
entity.ErrorCode = 1;
|
|
entity.ErrorMessage = baseEx.Message;
|
|
}
|
|
|
|
var ret = await _partRepository.InsertAsync(entity, true).ConfigureAwait(false);
|
|
|
|
var dto = ObjectMapper.Map<Part, PartDto>(ret);
|
|
dto.CreationTime = Clock.Now;
|
|
if (dto.ErrorCode != 0)
|
|
{
|
|
throw new AbpValidationException(new List<ValidationResult>
|
|
{
|
|
new(dto.ErrorMessage)
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return new OkObjectResult(dto);
|
|
}
|
|
}
|
|
}
|
|
|