using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Json; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Commons; using Win_in.Sfs.Basedata.Domain; namespace Win_in.Sfs.Wms.Pda.Controllers.BaseDatas; /// /// 字典控制器 /// [ApiController] [Route($"{PdaHostConst.ROOT_ROUTE}split-packing-rec")] public class SplitPackingRecController : AbpController { private readonly ISplitPackingRecAppService _splitPackingRecApp; /// /// /// /// public SplitPackingRecController(ISplitPackingRecAppService splitPackingRecApp, IOptions options) { _splitPackingRecApp = splitPackingRecApp; var str = options.Value.DefaultDateTimeFormat; Console.WriteLine(str); } /// /// 取拆分记录列表 /// /// /// [HttpPost("get-all")] public virtual async Task> GetAllListByFilterAsync(SfsBaseDataRequestInputBase input) { return await _splitPackingRecApp.GetAllListByFilterAsync(input).ConfigureAwait(false); } /// /// 获取拆箱记录 /// /// 目标箱码列表 /// [HttpGet("get-split-packing-code")] public async Task GetSplitPackingCode(string toPackingCode) { return await _splitPackingRecApp.GetSplitPackingCode(toPackingCode).ConfigureAwait(false); } /// /// 根据to箱码取所有具有相同箱码的拆箱记录 /// /// /// [HttpGet("get-same-ponumber-list-by-topackingcode")] public async Task> GetSamePoNumberListByToPackingCode(string toPackingCode) { return await _splitPackingRecApp.GetSamePoNumberListByToPackingCode(toPackingCode).ConfigureAwait(false); } [HttpPost("batch-insert-test")] public async Task BatchInsertTestAsync(List inputs, int recordCount, int pageSize = 50) { Stopwatch sw = new Stopwatch(); sw.Start(); List operLst = new List(); var firstObj = inputs[0]; for (int i = 1; i <= recordCount; i++) { var newObj = CloneSplitPackingRec(firstObj); operLst.Add(newObj); } //分页 int pageTotal = PageHelper.GetTotalPages(operLst.Count, pageSize); for (int i = 1; i <= pageTotal; i++) { var curPage = PageHelper.GetPage(operLst, i, pageSize); bool ret = await _splitPackingRecApp.BatchInsertTestAsync(curPage).ConfigureAwait(false); } sw.Stop(); Console.WriteLine($"执行时间 = {sw.ElapsedMilliseconds} ms"); return true; } private static SplitPackingRecEditInput CloneSplitPackingRec(SplitPackingRecEditInput input) { SplitPackingRecEditInput entity = new SplitPackingRecEditInput(); entity.OprType = input.OprType; entity.FromPackingCode = input.FromPackingCode; //entity.FromTopPackingCode = input.FromTopPackingCode; entity.FromStdPackQty = input.FromStdPackQty; entity.FromUom = input.FromUom; entity.FromQty = input.FromQty; entity.ToPackingCode = input.ToPackingCode; //entity.ToTopPackingCode = input.ToTopPackingCode; entity.ToStdPackQty = input.ToStdPackQty; entity.ToUom = input.ToUom; entity.ToQty = input.ToQty; entity.ItemCode = input.ItemCode; entity.ItemName = input.ItemName; entity.ItemDesc1 = input.ItemDesc1; entity.ItemDesc2 = input.ItemDesc2; entity.FromLot = input.FromLot; entity.ToLot = input.ToLot; entity.PurchaseInfo_PoNumber = input.PurchaseInfo_PoNumber; entity.PurchaseInfo_AsnNumber = input.PurchaseInfo_AsnNumber; entity.ArrivalNoticNumber = input.ArrivalNoticNumber; entity.TaskOrderNumber = input.TaskOrderNumber; entity.ReceiptRecNumber = input.ReceiptRecNumber; entity.PutOnShelfNumber = input.PutOnShelfNumber; entity.LabelType = input.LabelType; //entity.CreationTime = input.CreationTime; //entity.CreatorId = input.CreatorId; //entity.LastModificationTime = input.LastModificationTime; //entity.LastModifierId = input.LastModifierId; entity.Remark = input.Remark; entity.ArriveDate = input.ArriveDate; //entity.ContainerCode = input.ContainerCode; entity.ExpireDate = input.ExpireDate; entity.FullBarcodeString = input.FullBarcodeString; entity.LabelStatus = input.LabelStatus; entity.LocationErpCode = input.LocationErpCode; entity.PlanArriveDate = input.PlanArriveDate; entity.ProduceDate = input.ProduceDate; //entity.ProdLine = input.ProdLine; //entity.Shift = input.Shift; //entity.Team = input.Team; entity.RpNumber = input.RpNumber; entity.SupplierCode = input.SupplierCode; //entity.QLevel = input.QLevel; //entity.QualityFile = input.QualityFile; entity.RecommendLocationCode = input.RecommendLocationCode; //entity.Specifications = input.Specifications; entity.SupplierBatch = input.SupplierBatch; entity.SupplierItemCode = input.SupplierItemCode; entity.SupplierItemName = input.SupplierItemName; entity.SupplierName = input.SupplierName; entity.SupplierSimpleName = input.SupplierSimpleName; return entity; } }