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; /// /// QAD销售订单(Sale order) /// //[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; } /// /// 销售订单(SaleOrder) /// /// QAD销售订单(SaleOrder) /// [HttpPost("")] [Volo.Abp.Uow.UnitOfWork(isTransactional: false)] public virtual async Task> AddAsync(SodDetInput input) { var entityObj = ObjectMapper.Map(input); try { //调用业务接口前,先做业务数据校验 //数据格式校验使用ABP提供的校验模块(Application.Contract.XXXInputValidator),不需要在这里实现 Validator.CheckSite(_configuration, entityObj.Site); Validator.CheckCompany(_configuration, entityObj.Company); SaleOrderEditInput targetObj = new SaleOrderEditInput(); targetObj.Details = new List(); 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; //ERP料号 //detailObj.Item.Name = ; //物品 targetObj.Details.Add(detailObj); //var targetObj = ObjectMapper.Map(entityObj); //var targetDtl = ObjectMapper.Map(entityObj); //??一个源对象,转换成包含明细列表的目标对象 //if (targetObj.Details == null) { targetObj.Details = new System.Collections.Generic.List(); } //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(entityObj); dto.CreationTime = Clock.Now; if (dto.ErrorCode != 0) { throw new AbpValidationException(new List { new(dto.ErrorMessage) }); } else { return new OkObjectResult(dto); } } }