/// <summary> /// Создаем TE и товар на финишном месте /// </summary> /// <param name="session"></param> /// <param name="teCode">Код TE</param> private void ProductData(ISession session, string placeCode = FinishCode, bool createProduct = true) { var place = session.Query <WmsPlace>().Single(i => i.PlaceCode == placeCode); var art = session.Query <WmsArt>().Single(i => i.ArtCode == TestName); var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == tstMandantCode); var te = new WmsTE { TECode = placeCode, TEType = session.Query <WmsTEType>().Single(i => i.TETypeCode == TestName), TECurrentPlace = place, TECreationPlace = place.PlaceCode, TELength = 1100, TEHeight = 1100, TEWeight = 1100, TEWidth = 1100, Status = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"), TEPackStatus = "TE_PKG_NONE", TEMaxWeight = 11000 }; session.Save(te); if (createProduct) { session.Save(new WmsProduct { TE = te, SKU = session.Query <WmsSKU>().Single(i => i.SKUName == TestName), ProductCountSKU = 1, ProductCount = 1, ProductTTEQuantity = 1, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), ProductInputDate = DateTime.Now, ProductInputDateMethod = art.ArtInputDateMethod, Art = art, Partner = tstMandant, ProductOwner = tstMandant, Status = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"), ProductTone = TestName, ProductLot = TestName }); } place.PlaceCapacity = place.PlaceCapacity - 1; session.Update(place); }
public void Test() { var sessionShareExtention = new SessionShareExtention(); var mockWfStorage = new Mock <IWorkflowStorage>(); mockWfStorage.Setup(i => i.Load(_wfIdentity)).Returns(_wf); var wfAppFactory = new WorkflowApplicationFactory(null as InstanceStore, mockWfStorage.Object); using (var childContainer = _container.CreateChildContainer()) { childContainer.RegisterInstance <IWorkflowApplicationFactory>(wfAppFactory); childContainer.RegisterInstance(sessionShareExtention, new ContainerControlledLifetimeManager()); using (var session = _sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { var sessionDecorator = new SessionDecorator(session) { DoNotDispose = true, ExternalTransaction = new TransactionDecorator(transaction) { DisableActions = true } }; var sessionFactoryMock = new Mock <ISessionFactory>(); sessionFactoryMock.Setup(i => i.OpenSession()).Returns(sessionDecorator); sessionFactoryMock.Setup(i => i.OpenSession(It.IsAny <IInterceptor>())).Returns(sessionDecorator); #region prepare data var mandant = session.Query <WmsMandant>().FirstOrDefault(o => o.PartnerCode == MandantCode); if (mandant == null) { throw new Exception(string.Format("Отсутствует тестовый мандант с кодом '{0}'", MandantCode)); } var eventKind = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == EventKindCode); if (eventKind == null) { throw new Exception(string.Format("Отсутствует вид события с кодом '{0}'", EventKindCode)); } var partner = new WmsPartner { PartnerCode = _testName, PartnerName = _testName, PartnerLink2Mandant = mandant, PartnerHostRef = _testName }; session.Save(partner); var owb = new WmsOWB { OWBName = _testName, OWBType = "OWBTYPENORMAL", OWBPriority = 500, Status = session.Query <WmsOWBStatus>().FirstOrDefault(o => o.StatusCode == "OWB_ACTIVATED"), Partner = mandant, OWBProductNeed = "NOACTIVATE", OWBCarrier = partner }; session.Save(owb); var iwb = new WmsIWB { IWBName = _testName, IWBType = "IWBTYPENORMAL", IWBPriority = 500, Status = session.Query <WmsIWBStatus>().FirstOrDefault(o => o.StatusCode == "IWB_COMPLETED"), Partner = mandant }; session.Save(iwb); #region Product var tetype = new WmsTEType { TETypeCode = _testName, TETypeName = _testName, TETypeLength = 1000, TETypeWidth = 1000, TETypeHeight = 1000, TETypeMaxWeight = 1000, }; session.Save(tetype); var placeType = new WmsPlaceType { PlaceTypeCode = _testName, PlaceTypeName = _testName, PlaceTypeCapacity = 100, PlaceTypeLength = 10000, PlaceTypeWidth = 10000, PlaceTypeHeight = 10000, PlaceTypeMaxWeight = 10000, }; session.Save(placeType); var placeClass = new WmsPlaceClass { PlaceClassCode = _testName, PlaceClassName = _testName }; session.Save(placeClass); var receiveArea = new WmsReceiveArea { ReceiveAreaCode = _testName, ReceiveAreaName = _testName }; session.Save(receiveArea); var supplyArea = new WmsSupplyArea { SupplyAreaCode = _testName, SupplyAreaName = _testName }; session.Save(supplyArea); var motionArea = new WmsMotionArea { MotionAreaCode = _testName, MotionAreaName = _testName }; session.Save(motionArea); var segmentType = new WmsSegmentType { SegmentTypeCode = _testName, SegmentTypeName = _testName }; session.Save(segmentType); var areaType = new WmsAreaType { AreaTypeCode = _testName, AreaTypeName = _testName }; session.Save(areaType); var warehouse = new WmsWarehouse { WarehouseCode = _testName, WarehouseName = _testName }; session.Save(warehouse); var area = new WmsArea { AreaCode = _testName, AreaName = _testName, AreaType = areaType, Warehouse = warehouse }; session.Save(area); var segment = new WmsSegment { SegmentCode = _testName, SegmentNumber = _testName, SegmentName = _testName, SegmentType = segmentType, Area = area }; session.Save(segment); var place = new WmsPlace { PlaceCode = _testName, Segment = segment, PlaceS = 1, PlaceX = 1, PlaceY = 1, PlaceZ = 1, PlaceCapacityMax = 100, PlaceCapacity = 100, Status = session.Query <WmsPlaceStatus>().FirstOrDefault(o => o.StatusCode == "PLC_FREE"), PlaceName = _testName, PlaceType = placeType, PlaceClass = placeClass, PlaceSortA = 1, PlaceSortB = 1, PlaceSortC = 1, PlaceSortD = 1, PlaceSortPick = 1, ReceiveArea = receiveArea, MotionArea = motionArea, SupplyArea = supplyArea, PlaceWeight = 10000, PlaceWeightGroup = 10000 }; session.Save(place); var te = new WmsTE { TECode = _testName, TEType = tetype, TECurrentPlace = place, TECreationPlace = place.PlaceCode, TELength = 1000, TEWidth = 1000, TEHeight = 1000, Status = session.Query <WmsTEStatus>().FirstOrDefault(o => o.StatusCode == "TE_FREE"), TEPackStatus = "TE_PKG_NONE", TEWeight = 1000, TEMaxWeight = 10000, TETareWeight = 1000, }; session.Save(te); var art = new WmsArt { ArtCode = _testName, ArtName = _testName, Partner = mandant, ArtABCD = 'A', ArtTempMin = 1, ArtTempMax = 1000, ArtDeleted = false, ArtManufacturer = mandant, ArtType = _testName }; session.Save(art); var measureType = new WmsMeasureType { MeasureTypeCode = _testName, MeasureTypeName = _testName }; session.Save(measureType); var measure = new WmsMeasure { MeasureCode = _testName, MeasureType = measureType, MeasurePrimary = true, MeasureFactor = 1, MeasureDefault = true, MeasureShortName = "Test", MeasureName = _testName, }; session.Save(measure); var sku = new WmsSKU { Art = art, Measure = measure, SKUCount = 1, SKUPrimary = true, SKUClient = false, SKUIndivisible = true, SKUParent = null, SKUName = _testName }; session.Save(sku); var qlfDetail = new WmsQLFDetail { QLFDetailCode = _testName, QLFDetailName = _testName }; session.Save(qlfDetail); var iwbPos = new WmsIWBPos { IWB = iwb, IWBPosNumber = 1, SKU = sku, IWBPosCount = 1, IWBPosCount2SKU = 1, Status = session.Query <WmsIWBPosStatus>().SingleOrDefault(o => o.StatusCode == "IWBPOS_CREATED"), QLF = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"), IWBPosOwner = mandant }; session.Save(iwbPos); var owbPos = new WmsOWBPos { OWB = owb, OWBPosNumber = 1, SKU = sku, OWBPosCount = 1, OWBPosCount2SKU = 1, OWBPosReserved = 1, Status = session.Query <WmsOWBPosStatus>().SingleOrDefault(o => o.StatusCode == "OWBPOS_ACTIVATED"), QLF = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"), OWBPosOwner = mandant }; session.Save(owbPos); var factory = new WmsFactory { FactoryCode = "TST", FactoryName = _testName, Partner = mandant, FactoryBatchCode = _testName }; session.Save(factory); var product = new WmsProduct { TE = te, SKU = sku, ProductCountSKU = 1, ProductCount = 2, ProductTTEQuantity = 3, QLF = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"), QLFDetail = qlfDetail, ProductInputDate = DateTime.Now, ProductInputDateMethod = session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"), ProductDate = DateTime.Now, ProductPack = "Pack", ProductPackCountSKU = 4, ProductExpiryDate = DateTime.Now, ProductBatch = "Batch", ProductLot = "Lot", ProductSerialNumber = "Number", ProductColor = "Color", ProductTone = "Tone", ProductSize = "Size", Art = art, Partner = mandant, ProductOwner = mandant, IWBPos = iwbPos, OWBPos = owbPos, Factory = factory, Status = session.Query <WmsProductStatus>().SingleOrDefault(i => i.StatusCode == "PRODUCT_BUSY"), ProductBatchCode = "BatchCode", ProductBoxNumber = "BoxNumber", ProductHostRef = "HostRef", ProductKitArtName = "KitArtName", ProductRoot = 5, ProductPriority = 6, Country = session.Query <IsoCountry>().SingleOrDefault(i => i.CountryCode == "RUS"), ProductGTD = "GTD", TransportTaskID_r = null }; session.Save(product); var ehPrd = new WmsEventHeader { Partner = mandant, EventKind = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == "PRD_INPUT"), Status = session.Query <WmsEventHeaderStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_CREATED"), ClientType = session.Query <SysClientType>().FirstOrDefault(o => o.ClientTypeCode == "DCL"), EventHeaderBillStatus = session.Query <EventHeaderBillStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_BILL_OPEN"), EventHeaderOperationBusiness = session.Query <SYSENUM_OPERATION_BUSINESS>().FirstOrDefault(p => p.EnumGroup == "OPERATION" && p.EnumKey == "BUSINESS"), Operation = session.Query <BillOperation>().First(), EventHeaderInstance = "none" }; var edPrd = new wmsEventDetailPRD { PARTNERID_R = mandant.PartnerID, PRODUCTID_R = product.ProductID, OLDPRODUCTID_R = product.ProductID, EVENTKINDCODE_R = "PRD_INPUT" }; #endregion session.Flush(); var eventHeader = new WmsEventHeader { Partner = mandant, EventKind = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == EventKindCode), Status = session.Query <WmsEventHeaderStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_CREATED"), ClientType = session.Query <SysClientType>().FirstOrDefault(o => o.ClientTypeCode == "DCL"), EventHeaderBillStatus = session.Query <EventHeaderBillStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_BILL_OPEN"), EventHeaderOperationBusiness = session.Query <SYSENUM_OPERATION_BUSINESS>().FirstOrDefault(p => p.EnumGroup == "OPERATION" && p.EnumKey == "BUSINESS"), Operation = session.Query <BillOperation>().First(), EventHeaderInstance = "none" }; var eventDetailOwb = new wmsEventDetailOWB { OWBID_r = owb.OWBID, OWBName = owb.OWBName }; var api = new WmsAPI(sessionFactoryMock.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>()); api.RegEvent(session.GetSession(EntityMode.Poco), ehPrd, edPrd, null); api.RegEvent(session.GetSession(EntityMode.Poco), eventHeader, eventDetailOwb, null); var array = session.Query <wmsEventDetailOWB>() .Where(i => i.EventHeader.Partner.PartnerCode == MandantCode && i.EventHeader.EventKind.EventKindCode == EventKindCode && i.EventHeader.Status.StatusCode == "EVENT_CREATED" && i.EventHeader.DateIns >= DateTime.Today.AddDays(-1) && !session.Query <IoLaunchControl>() .Any( j => j.EventHeader == i.EventHeader && j.QueueMessageType.Code == EventKindCode && j.Mandant.PartnerCode == MandantCode)) .ToArray(); if (!array.Any()) { throw new Exception("Нет данных для теста"); } #endregion sessionShareExtention.SharedSession = sessionDecorator; var inputs = new Dictionary <string, object> { { "ROUTE", "ROUTE=OMS" }, { "MandantCode", MandantCode }, { "BatchSize", "1" } }; var service = childContainer.Resolve <WorkflowService>(); service.Run(_wfIdentity, inputs); var lan = session.Query <IoLaunchControl>().FirstOrDefault(i => i.EventHeader != null && i.EventHeader.EventHeaderID == eventHeader.EventHeaderID); lan.Should().NotBeNull("Не создали LanchControl"); var qout = session.Query <IoQueueOut>() .Where(i => i.Uri == string.Format("ENTITYKEY={0}; ENTITY = OWB", owb.OWBName) && i.QueueMessageType.Code == QueueMessageTypeCode) .OrderByDescending(i => i.DateIns) .First(); var data = SerializationHelper.Deserialize <WHSOWBCommandMessage>(qout.Data); data.OWBList[0].ProductList.Count.ShouldBeEquivalentTo(1); data.OWBList[0].ProductList[0].ID.ShouldBeEquivalentTo(product.ProductID); data.OWBList[0].CargoSpaceList.Count().ShouldBeEquivalentTo(1); data.OWBList[0].CargoSpaceList[0].Code.ShouldBeEquivalentTo(te.TECode); transaction.Rollback(); } } }
public void Tes2() { using (var session = _sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { var fakeSession = new SessionDecorator(session) { DoNotDispose = true, ExternalTransaction = new TransactionDecorator(transaction) { DisableActions = true } }; var mockSessionFactory = new Mock <ISessionFactory>(); mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession); const string testName = "TestName"; var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST"); var owb = new WmsOWB { Partner = tstMandant, OWBName = "Owb for testing change owner", OWBProductNeed = "NOACTIVATE", OWBType = "OWBTYPENORMAL", OWBOwner = tstMandant, Status = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_ACTIVATED") }; session.Save(owb); #region data var warehouse = new WmsWarehouse { WarehouseCode = testName, WarehouseName = testName }; session.Save(warehouse); var areaType = new WmsAreaType { AreaTypeCode = testName, AreaTypeName = testName }; session.Save(areaType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "AREATYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "AreaDestination"), GParamValKey = areaType.AreaTypeCode, GParamValValue = "OUT" }); var area = new WmsArea { AreaCode = testName, AreaName = testName, Warehouse = warehouse, AreaType = areaType }; session.Save(area); var segmentType = new WmsSegmentType { SegmentTypeCode = testName, SegmentTypeName = testName }; session.Save(segmentType); var segment = new WmsSegment { SegmentCode = testName, SegmentName = testName, SegmentNumber = testName, Area = area, SegmentType = segmentType }; session.Save(segment); var placeType = new WmsPlaceType { PlaceTypeCode = testName, PlaceTypeName = testName, PlaceTypeMaxWeight = 200000, PlaceTypeHeight = 200000, PlaceTypeLength = 200000, PlaceTypeWidth = 200000, PlaceTypeCapacity = 200 }; session.Save(placeType); var placeClass = new WmsPlaceClass { PlaceClassCode = testName, PlaceClassName = testName }; session.Save(placeClass); var teType = new WmsTEType { TETypeCode = testName, TETypeName = testName, TETypeWidth = 10000, TETypeHeight = 10000, TETypeLength = 10000, TETypeMaxWeight = 100000 }; session.Save(teType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "TETYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "TETypeSequence2TENumber"), GParamValKey = teType.TETypeCode, GParamValValue = "SQ_TE" }); session.Save(new WmsTEType2Mandant { TEType = teType, Partner = tstMandant }); session.Save(new WmsTEType2PlaceClass { TEType = teType, PlaceClass = placeClass }); var truckType = new WmsTruckType { TruckTypeCode = testName, TruckTypeName = testName, TruckTypeWeightMax = 100000, TruckTypePickCount = 100 }; session.Save(truckType); session.Save(new WmsTeType2TruckType { TruckType = truckType, TEType = teType, TeType2TruckTypeCount = 100 }); var receiveArea = new WmsReceiveArea { ReceiveAreaCode = testName, ReceiveAreaName = testName }; session.Save(receiveArea); var placeStart = new WmsPlace { PlaceCode = testName, PlaceName = testName, Segment = segment, PlaceS = 1, PlaceX = 1, PlaceY = 1, PlaceZ = 1, PlaceType = placeType, PlaceClass = placeClass, PlaceCapacity = 9, PlaceCapacityMax = 10, PlaceWeight = 20000, PlaceHeight = 20000, PlaceLength = 20000, PlaceWidth = 20000, Status = session.Query <WmsPlaceStatus>().Single(i => i.StatusCode == "PLC_FREE"), }; session.Save(placeStart); var art = new WmsArt { Partner = tstMandant, ArtName = testName, ArtCode = testName, ArtInputDateMethod = session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"), ArtType = "PRODUCT", ArtABCD = 'A' }; session.Save(art); var measureType = new WmsMeasureType { MeasureTypeCode = testName }; session.Save(measureType); var measure = new WmsMeasure { MeasureCode = testName, MeasureType = measureType, MeasureFactor = 1 }; session.Save(measure); var sku = new WmsSKU { SKUName = testName, Measure = measure, SKUCount = 1, Art = art, SKUPrimary = true, SKUClient = true, SKUDefault = true, SKUIndivisible = true, SKUWeight = 10, SKUHeight = 10, SKULength = 10, SKUWidth = 10, SKUVolume = 10 }; session.Save(sku); session.Save(new WmsSKU2TTE { SKU = sku, TEType = teType, SKU2TTEDefault = true, SKU2TTEQuantity = 1000, SKU2TTEQuantityMax = 1000, SKU2TTEMaxWeight = 10000 }); var te = new WmsTE { TECode = testName, TEType = session.Query <WmsTEType>().Single(i => i.TETypeCode == testName), TECurrentPlace = placeStart, TECreationPlace = placeStart.PlaceCode, TELength = 1000, TEHeight = 1000, TEWeight = 1000, TEWidth = 1000, Status = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"), TEPackStatus = "TE_PKG_NONE", TEMaxWeight = 1000 }; session.Save(te); var owbPos = new WmsOWBPos { SKU = sku, OWBPosCount = 1, OWBPosCount2SKU = 1, OWBPosOwner = tstMandant, OWB = owb, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), Status = session.Query <WmsOWBPosStatus>().Single(i => i.StatusCode == "OWBPOS_CREATED") }; session.Save(owbPos); session.Save(new WmsProduct { TE = te, SKU = session.Query <WmsSKU>().Single(i => i.SKUName == testName), ProductCountSKU = 1, ProductCount = 1, ProductTTEQuantity = 1, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), ProductInputDate = DateTime.Now, ProductInputDateMethod = art.ArtInputDateMethod, Art = art, Partner = tstMandant, ProductOwner = tstMandant, Status = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"), ProductTone = testName, ProductLot = testName, OWBPos = owbPos }); #endregion data session.Flush(); // запускаем var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>()); Action action = () => { api.ChangeOwnerByOwb(owb.OWBID, "OP_OPERATOR_OWBPROCESSING", "TEST", null); }; action.ShouldThrow <Exception>().Which.Message.Should().Contain("смена владельца не требуется"); transaction.Rollback(); } }
/// <summary> /// Создаем топологию для тестов /// </summary> /// <param name="session"></param> private void GeneralData(ISession session) { var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == tstMandantCode); var warehouse = new WmsWarehouse { WarehouseCode = TestName, WarehouseName = TestName }; session.Save(warehouse); var areaType = new WmsAreaType { AreaTypeCode = TestName, AreaTypeName = TestName }; session.Save(areaType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "AREATYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "AreaDestination"), GParamValKey = areaType.AreaTypeCode, GParamValValue = "STORAGE" }); var area = new WmsArea { AreaCode = TestName, AreaName = TestName, Warehouse = warehouse, AreaType = areaType }; session.Save(area); var segmentType = new WmsSegmentType { SegmentTypeCode = TestName, SegmentTypeName = TestName }; session.Save(segmentType); var segment = new WmsSegment { SegmentCode = TestName, SegmentName = TestName, SegmentNumber = TestName, Area = area, SegmentType = segmentType }; session.Save(segment); var placeType = new WmsPlaceType { PlaceTypeCode = TestName, PlaceTypeName = TestName, PlaceTypeMaxWeight = 200000, PlaceTypeHeight = 200000, PlaceTypeLength = 200000, PlaceTypeWidth = 200000, PlaceTypeCapacity = 200 }; session.Save(placeType); var placeClass = new WmsPlaceClass { PlaceClassCode = TestName, PlaceClassName = TestName }; session.Save(placeClass); var teType = new WmsTEType { TETypeCode = TestName, TETypeName = TestName, TETypeWidth = 10000, TETypeHeight = 10000, TETypeLength = 10000, TETypeMaxWeight = 100000 }; session.Save(teType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "TETYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "TETypeSequence2TENumber"), GParamValKey = teType.TETypeCode, GParamValValue = "SQ_TE" }); session.Save(new WmsTEType2Mandant { TEType = teType, Partner = tstMandant }); session.Save(new WmsTEType2PlaceClass { TEType = teType, PlaceClass = placeClass }); var truckType = new WmsTruckType { TruckTypeCode = TestName, TruckTypeName = TestName, TruckTypeWeightMax = 100000, TruckTypePickCount = 100 }; session.Save(truckType); session.Save(new WmsTeType2TruckType { TruckType = truckType, TEType = teType, TeType2TruckTypeCount = 100 }); var receiveArea = new WmsReceiveArea { ReceiveAreaCode = TestName, ReceiveAreaName = TestName }; session.Save(receiveArea); var placeStart = new WmsPlace { PlaceCode = StartCode, PlaceName = StartCode, Segment = segment, PlaceS = 1, PlaceX = 1, PlaceY = 1, PlaceZ = 1, PlaceType = placeType, PlaceClass = placeClass, PlaceCapacity = 9, PlaceCapacityMax = 10, PlaceWeight = 20000, PlaceHeight = 20000, PlaceLength = 20000, PlaceWidth = 20000, Status = session.Query <WmsPlaceStatus>().Single(i => i.StatusCode == "PLC_FREE"), }; session.Save(placeStart); session.Save(new WmsPlace { PlaceCode = FinishCode, PlaceName = FinishCode, Segment = segment, PlaceS = 1, PlaceX = 2, PlaceY = 1, PlaceZ = 1, PlaceType = placeType, PlaceClass = placeClass, PlaceCapacity = 10, PlaceCapacityMax = 10, PlaceWeight = 20000, PlaceHeight = 20000, PlaceLength = 20000, PlaceWidth = 20000, Status = placeStart.Status, ReceiveArea = receiveArea }); var art = new WmsArt { Partner = tstMandant, ArtName = TestName, ArtCode = TestName, ArtInputDateMethod = session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"), ArtType = "PRODUCT", ArtABCD = 'A' }; session.Save(art); var measureType = new WmsMeasureType { MeasureTypeCode = TestName }; session.Save(measureType); var measure = new WmsMeasure { MeasureCode = TestName, MeasureType = measureType, MeasureFactor = 1 }; session.Save(measure); var sku = new WmsSKU { SKUName = TestName, Measure = measure, SKUCount = 1, Art = art, SKUPrimary = true, SKUClient = true, SKUDefault = true, SKUIndivisible = true, SKUWeight = 10, SKUHeight = 10, SKULength = 10, SKUWidth = 10, SKUVolume = 10 }; session.Save(sku); session.Save(new WmsSKU2TTE { SKU = sku, TEType = teType, SKU2TTEDefault = true, SKU2TTEQuantity = 1000, SKU2TTEQuantityMax = 1000, SKU2TTEMaxWeight = 10000 }); var te = new WmsTE { TECode = StartCode, TEType = session.Query <WmsTEType>().Single(i => i.TETypeCode == TestName), TECurrentPlace = placeStart, TECreationPlace = placeStart.PlaceCode, TELength = 1000, TEHeight = 1000, TEWeight = 1000, TEWidth = 1000, Status = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"), TEPackStatus = "TE_PKG_NONE", TEMaxWeight = 1000 }; session.Save(te); session.Save(new WmsProduct { TE = te, SKU = session.Query <WmsSKU>().Single(i => i.SKUName == TestName), ProductCountSKU = 1, ProductCount = 1, ProductTTEQuantity = 1, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), ProductInputDate = DateTime.Now, ProductInputDateMethod = art.ArtInputDateMethod, Art = art, Partner = tstMandant, ProductOwner = tstMandant, Status = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"), ProductTone = TestName, ProductLot = TestName }); }
public void Test6() { using (var session = _sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { var fakeSession = new SessionDecorator(session) { DoNotDispose = true }; var mockSessionFactory = new Mock <ISessionFactory>(); mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession); const string testName = "TestName"; const string mandantCode = "TST"; var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == mandantCode); // создаем маршрут var route = new YRoute { Partner = tstMandant, RouteDate = DateTime.Today.AddDays(3), // через 3 дня RouteNumber = "AutoTestRoute" }; session.Save(route); var cargo = new WmsCargoOWB { Route = route }; session.Save(cargo); // создаем накладную с плановой датой отгрузки var owb = new WmsOWB { Partner = tstMandant, OWBName = "Owb for testing routes", OWBProductNeed = "NOACTIVATE", OWBType = "OWBTYPENORMAL", OWBOutDatePlan = route.RouteDate, Status = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_NONE") }; owb.WmsCargoOWB_List.Add(cargo); session.Save(owb); #region . CreatePlaceProductTE . var warehouse = new WmsWarehouse { WarehouseCode = testName, WarehouseName = testName }; session.Save(warehouse); var areaType = new WmsAreaType { AreaTypeCode = testName, AreaTypeName = testName }; session.Save(areaType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "AREATYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "AreaDestination"), GParamValKey = areaType.AreaTypeCode, GParamValValue = "OUT" }); var area = new WmsArea { AreaCode = testName, AreaName = testName, Warehouse = warehouse, AreaType = areaType }; session.Save(area); var segmentType = new WmsSegmentType { SegmentTypeCode = testName, SegmentTypeName = testName }; session.Save(segmentType); var segment = new WmsSegment { SegmentCode = testName, SegmentName = testName, SegmentNumber = testName, Area = area, SegmentType = segmentType }; session.Save(segment); var placeType = new WmsPlaceType { PlaceTypeCode = testName, PlaceTypeName = testName, PlaceTypeMaxWeight = 200000, PlaceTypeHeight = 200000, PlaceTypeLength = 200000, PlaceTypeWidth = 200000, PlaceTypeCapacity = 200 }; session.Save(placeType); var placeClass = new WmsPlaceClass { PlaceClassCode = testName, PlaceClassName = testName }; session.Save(placeClass); var teType = new WmsTEType { TETypeCode = testName, TETypeName = testName, TETypeWidth = 10000, TETypeHeight = 10000, TETypeLength = 10000, TETypeMaxWeight = 100000 }; session.Save(teType); session.Save(new SysGlobalParamValue { GParamVal2Entity = "TETYPE", GlobalParam = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "TETypeSequence2TENumber"), GParamValKey = teType.TETypeCode, GParamValValue = "SQ_TE" }); session.Save(new WmsTEType2Mandant { TEType = teType, Partner = tstMandant }); session.Save(new WmsTEType2PlaceClass { TEType = teType, PlaceClass = placeClass }); var truckType = new WmsTruckType { TruckTypeCode = testName, TruckTypeName = testName, TruckTypeWeightMax = 100000, TruckTypePickCount = 100 }; session.Save(truckType); session.Save(new WmsTeType2TruckType { TruckType = truckType, TEType = teType, TeType2TruckTypeCount = 100 }); var receiveArea = new WmsReceiveArea { ReceiveAreaCode = testName, ReceiveAreaName = testName }; session.Save(receiveArea); var placeStart = new WmsPlace { PlaceCode = testName, PlaceName = testName, Segment = segment, PlaceS = 1, PlaceX = 1, PlaceY = 1, PlaceZ = 1, PlaceType = placeType, PlaceClass = placeClass, PlaceCapacity = 9, PlaceCapacityMax = 10, PlaceWeight = 20000, PlaceHeight = 20000, PlaceLength = 20000, PlaceWidth = 20000, Status = session.Query <WmsPlaceStatus>().Single(i => i.StatusCode == "PLC_FREE"), }; session.Save(placeStart); var art = new WmsArt { Partner = tstMandant, ArtName = testName, ArtCode = testName, ArtInputDateMethod = session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"), ArtType = "PRODUCT", ArtABCD = 'A' }; session.Save(art); var measureType = new WmsMeasureType { MeasureTypeCode = testName }; session.Save(measureType); var measure = new WmsMeasure { MeasureCode = testName, MeasureType = measureType, MeasureFactor = 1 }; session.Save(measure); var sku = new WmsSKU { SKUName = testName, Measure = measure, SKUCount = 1, Art = art, SKUPrimary = true, SKUClient = true, SKUDefault = true, SKUIndivisible = true, SKUWeight = 10, SKUHeight = 10, SKULength = 10, SKUWidth = 10, SKUVolume = 10 }; session.Save(sku); session.Save(new WmsSKU2TTE { SKU = sku, TEType = teType, SKU2TTEDefault = true, SKU2TTEQuantity = 1000, SKU2TTEQuantityMax = 1000, SKU2TTEMaxWeight = 10000 }); var te = new WmsTE { TECode = testName, TEType = session.Query <WmsTEType>().Single(i => i.TETypeCode == testName), TECurrentPlace = placeStart, TECreationPlace = placeStart.PlaceCode, TELength = 1000, TEHeight = 1000, TEWeight = 1000, TEWidth = 1000, Status = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"), TEPackStatus = "TE_PKG_NONE", TEMaxWeight = 1000 }; session.Save(te); var owbPos = new WmsOWBPos { SKU = sku, OWBPosCount = 1, OWBPosCount2SKU = 1, OWBPosOwner = tstMandant, OWB = owb, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), Status = session.Query <WmsOWBPosStatus>().Single(i => i.StatusCode == "OWBPOS_CREATED") }; session.Save(owbPos); session.Save(new WmsProduct { TE = te, SKU = session.Query <WmsSKU>().Single(i => i.SKUName == testName), ProductCountSKU = 1, ProductCount = 1, ProductTTEQuantity = 1, QLF = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"), ProductInputDate = DateTime.Now, ProductInputDateMethod = art.ArtInputDateMethod, Art = art, Partner = tstMandant, ProductOwner = tstMandant, Status = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"), ProductTone = testName, ProductLot = testName, OWBPos = owbPos }); #endregion session.Flush(); try { // запускаем var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>()); api.ChangeOwbRoute(owb.OWBID, route.RouteID, null, false, true); } catch (OracleException oraex) { if (!string.IsNullOrEmpty(oraex.Message)) { var errorText = oraex.Message.Split(new[] { "\n" }, StringSplitOptions.None); errorText[0].Should().NotBe(string.Format("ORA-20800: По накладной с ID = {0} имеется товар на воротах отгрузки", owb.OWBID)); } else { // Все OK } } catch (Exception ex) { // Все OK } transaction.Rollback(); } }