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.
125 lines
5.3 KiB
125 lines
5.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.Wms.DataExchange.Application.Contracts.Iac.Qad;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Iac.Qad;
|
|
using Win_in.Sfs.Wms.DataExchange.Publics;
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts;
|
|
using ISaleOrderAppService = Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Qad.ISaleOrderAppService;
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Application.Iac.Qad;
|
|
|
|
/// <summary>
|
|
/// QAD销售订单(Sale order)
|
|
/// </summary>
|
|
//[Authorize(IncomingToWmsPermissions.Default)]
|
|
[Microsoft.AspNetCore.Components.Route($"{DataExchangeConsts.RouteRoot}so")]
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.WmsWebApi)]
|
|
public class SaleOrderAppService : ApplicationService, ISaleOrderAppService
|
|
{
|
|
private readonly Store.Application.Contracts.ISaleOrderAppService _saleOrderAppService;
|
|
|
|
private readonly ISod_detRepository _sod_detRepository;
|
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public SaleOrderAppService(
|
|
Store.Application.Contracts.ISaleOrderAppService saleOrderAppService,
|
|
ISod_detRepository sod_detRepository,
|
|
IConfiguration configuration
|
|
)
|
|
{
|
|
_saleOrderAppService = saleOrderAppService;
|
|
_sod_detRepository = sod_detRepository;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 销售订单(SaleOrder)
|
|
/// </summary>
|
|
/// <param name="input">QAD销售订单(SaleOrder)</param>
|
|
/// <returns></returns>
|
|
[HttpPost("")]
|
|
[Volo.Abp.Uow.UnitOfWork(isTransactional: false)]
|
|
public virtual async Task<ActionResult<SodDetDto>> AddAsync(SodDetInput input)
|
|
{
|
|
|
|
var entityObj = ObjectMapper.Map<SodDetInput, SodDet>(input);
|
|
try
|
|
{
|
|
//调用业务接口前,先做业务数据校验
|
|
//数据格式校验使用ABP提供的校验模块(Application.Contract.XXXInputValidator),不需要在这里实现
|
|
Validator.CheckSite(_configuration, entityObj.Site);
|
|
Validator.CheckCompany(_configuration, entityObj.Company);
|
|
|
|
SaleOrderEditInput targetObj = new SaleOrderEditInput();
|
|
targetObj.Details = new List<SaleOrderDetailInput>();
|
|
targetObj.Number = entityObj.SoNbr; //订单号
|
|
targetObj.CustomerCode = entityObj.CustCode; //客户代码
|
|
targetObj.SoType = "0"; //订单类型
|
|
//targetObj.Status = ; //订单状态
|
|
//targetObj.IsConsignment = ; //是否寄存订单
|
|
//targetObj.OrderDate = ; //订单日期
|
|
//targetObj.DueDate = ; //截止日期
|
|
//targetObj.Version = ; //版本
|
|
//targetObj.TaxRate = ; //税率
|
|
//targetObj.Contacts.Name = ; //联系人
|
|
//targetObj.Contacts.Phone = ; //联系人
|
|
//targetObj.Contacts.Email = ; //联系人
|
|
//targetObj.Worker = ; //操作员
|
|
targetObj.Remark = entityObj.Remark; //
|
|
|
|
SaleOrderDetailInput detailObj = new SaleOrderDetailInput();
|
|
detailObj.SoLine = entityObj.SoLine.ToString(); //订单行
|
|
//detailObj.CustomerPack.PackQty = ; //客户计量单位
|
|
//detailObj.CustomerPack.PackUom = ; //客户计量单位
|
|
//detailObj.ConvertRate = ; //转换率
|
|
//detailObj.LineStatus = ; //订单行状态 0:无效1:有效
|
|
detailObj.Qty = entityObj.Qty; //到货数量
|
|
//detailObj.Qty.Uom = ; //到货数量
|
|
detailObj.StdPackQty = entityObj.StdPackQty.TryToDecimalZero(); //标准包装
|
|
detailObj.ItemCode = entityObj.PartCode; //物品代码
|
|
//detailObj.Item.Name = ; //物品
|
|
targetObj.Details.Add(detailObj);
|
|
|
|
//var targetObj = ObjectMapper.Map<SodDet, SaleOrderCreateInput>(entityObj);
|
|
//var targetDtl = ObjectMapper.Map<SodDet, SaleOrderDetailInput>(entityObj); //??一个源对象,转换成包含明细列表的目标对象
|
|
//if (targetObj.Details == null) { targetObj.Details = new System.Collections.Generic.List<SaleOrderDetailInput>(); }
|
|
//targetObj.Details.Add(targetDtl);
|
|
//#region 特殊转换
|
|
//if (targetObj.Details[0].StdPack == null) { targetObj.Details[0].StdPack = new Shared.Domain.PackInfo(); }
|
|
//targetObj.Details[0].StdPack.PackUom = entityObj.Um;
|
|
//targetObj.Details[0].StdPack.PackQty = entityObj.StdPackQty.TryToDecimalZero();
|
|
//#endregion
|
|
|
|
await _saleOrderAppService.UpsertAsync(targetObj).ConfigureAwait(false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var baseEx = ex.GetBaseException();
|
|
entityObj.ErrorCode = 1;
|
|
entityObj.ErrorMessage = baseEx.Message;
|
|
}
|
|
|
|
_ = await _sod_detRepository.InsertAsync(entityObj, true).ConfigureAwait(false);
|
|
|
|
var dto = ObjectMapper.Map<SodDet, SodDetDto>(entityObj);
|
|
dto.CreationTime = Clock.Now;
|
|
if (dto.ErrorCode != 0)
|
|
{
|
|
throw new AbpValidationException(new List<ValidationResult>
|
|
{
|
|
new(dto.ErrorMessage)
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return new OkObjectResult(dto);
|
|
}
|
|
}
|
|
}
|
|
|