cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Automated Distribution and Logistics Part 2

No ratings

 

 

Step 3: Creating Customer Data

 

Now let’s begin creating the customer data. Just enough examples for us to understand what is happening at each step. Let’s create at least 4 customers by following the steps below:

 

  1. Open the Fizos.Customers.DataTable Data Table and go to the services tab.

  2. Open the AddDataTableEntries service to be executed. This service will allow us to create some general data to work with. You can create as many as you like for this test. Click the values parameter to start creating entries.

  3. After clicking + Add, and enter data for customers. Try to add at least 1 Factor data tag for each customer.

    customer_add_service.png

     

     

  4. Save your entry and create a second entry with any location and tags you like. We aren’t adding vehicles as of yet, but we will in the next section.

  5. After saving, don’t forget to execute the service with the two entries saved. If you did it correctly, the values parameter of the service, should show at least 1 inside of the parentheses. See below for an example:

    execute_customer_entries.png

     

     

We just added customers manually. While convenient for our test, what we truly want is a system that is hands off. What we need is, a way to add customers programatically. Whether a customer is ordering on a website you created for them or they are checking out as a guest (we still want to track this). Below, you’ll see a quick service to add a new user. This service can be created inside of the Fizos.Customers.DataTable data table.

 

var customer = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
    infoTableName : "InfoTable",
    dataShapeName : "Fizos.Customers.DataShape"
});

var count =  me.GetDataTableEntryCount();

var newEntry = {};
newEntry.ID = count + 1;
newEntry.UUID = generateGUID();
newEntry.Type = Type;
newEntry.Factors = "Fizos.CustomerTags:FirstTime";
newEntry.Name = Name;
newEntry.Email = Email;
newEntry.Address = Address;
newEntry.Phone = Phone;

customer.AddRow();

me.AddDataTableEntry({
    sourceType: "Service",
    values: customer,
    source: "AddNewCustomer"
});


We can adapt these for the customers that would rather not have accounts and be considered guests. Instead of the FirstTime data tag, you might want to add a 
Guest tag. For name, you could have it empty. The other fields, you’ll still want to likely have. This can give you insight into who these customers are that rather the guest checkout/ordering.

 

 

Step 4: Expanding Logistics Models

 

Let's do a quick review of what we have before we jump forward. In this Learning Path, we've setup scheduled factory inspections, machine automation, created customers, and setup order creation. What we're missing is the handling of deliveries.

 

In this learning path, we have talked about how to handle design aspects that could be held in a data table or have entities created to model each one. While there are many pros and cons to each method, we will do a mixture of both. Having the logistics data in data tables provide us with an easy form of querying data. Having entities match up with vehicles/transportation allows us to have greater tracking and live updates.

 

Let's create the vehicle/transportation data model, come up with logic on how to do deliveries from the factories we created earlier in this learning path, then setup a schedule or timer to kickstart the process.

 

Vehicles Data Model

We already have our Data Table of vehicles. Let's create the templates and entities that will be a 1 to 1 between Thing and vehicle.

 

  1. In the ThingWorx Composer, click the + New in the top left of the screen.


    select_new.png

     

  2. Select Thing Shape in the dropdown.

    create_new_thingshape.png

     

  3. In the name field, enter Fizos.Vehicles.ThingShape and select a Project (ie, PTCDefaultProject). This Entity will have Services implemented by all types of vehicles.

    new_vehicle_shape.png

  4. Save your changes and create three Thing Templates which implement this Thing Shape. See below for examples:

 

Fizos.Vans.ThingTemplate: These are smaller vehicles used to make short or last step deliveries.

new_van_template.png

 

 

Fizos.Trucks.ThingTemplate: These are trucks of different types making larger deliveries.

new_truck_template.png

 

 

Fizos.Planes.ThingTemplate: These are planes used to deliver products to long distance locations.

 
new_plane_template.png

 

Handling Shipping and Deliveries

The cost of shipping and delivering goods is often the last thing people want to think about. Sometimes the cost of shipping goods is more expensive than the goods themselves. So how can we make this one of our strongest factors? By continuing trying to make our design simpler and less costly. We all know that it won't be an easy feat. The best way to do this is to have a system where we can have analytics and continuously improve on.

 

Let's start with the beginner steps of creating our straight-forward delivery service. Then, we will add Value Streams and tracking to see where we can make improvements. Finally, the solutions get better as we repeat these steps. No one solution is perfect, and no logic will be without holes or issues. Nevertheless, you continuously work on it, so that you can save cost and improve customer experience.

 

  1. Open Fizos.Vehicles.ThingShape and go to the Properties tab.

  2. Create the following list of Properties. These properties are the generic concepts for a vehicle that can deliver a package.

    NameBase TypeAspectsDetails
    FuelCapacityNumber0 minimum, unit: literslogged, persistent
    AverageFuelConsumptionNumber0 minimum, unit: literslogged, persistent
    MaxMassNumber0 minimum, unit: kilogramslogged, persistent
    MaxVolumeNumber0 minimum, unit: cubic meterslogged, persistent
    CurrentLocationLocationN/Alogged, persistent
    CurrentOrdersInfoTable(Fizos.Orders.DataShape)N/Alogged, persistent


    Your properties should look like the following:

    new_veh_properties.png

  3. Inside the Fizos.Vehicles.ThingShape entity, go to the Services tab.

  4. Create the following list of Services. These services are also generic in nature and are based on the concept of a vehicle going to a pick up location, goods being loaded onto the vehicle, the vehicle traveling to a destination, then delivering goods.

    NameInputReturn TypeOverrideAsyncDescription
    PickUpGoodsPickUpLocation: LocationNothingYesYesGo to a pickup location (factory or otherwise), and pick up goods.
    LoadGoodsOrders: InfoTable (Fizos.Orders.DataShape)NothingYesYesPerform the task of loading goods onto a vehicle (adding rows to the CurrentOrders property)
    TravelDestination: LocationNothingYesYesTravel for destination A to destination B
    DeliverGoodsOrders: InfoTable (Fizos.Orders.DataShape)NothingYesYesPerform the task of unloading goods at a current location

    As you can see, the goods are orders. In a real world environment, we would create a separate Data Shape and Data Table for packages to hold a number of orders. We are doing this without the packages Data Table for simplicity in this example. One reason why our products have mass and volume properties is to help with the idea of loading a vehicle and the type of boxes or packaging to use. This could be another way to cut cost.

    Your Services should look like the following:

    new_veh_services.pngThe same way we were able to create a system that was automated, we will create events that will notify subscribers of certain tasks being complete. This way, the next level of service can be performed instantly by our robot army.

  5. Inside the Fizos.Vehicles.ThingShape entity, go to the Events tab.

  6. Create the following list of events. These Events will connect to a task being completed. For example, when the vehicle has arrived to a location, an Event will be triggered and thus the next task can begin. For a bit more automation, add an Event you might think is needed, like when fuel is needed in the vehicle.

 

NameData ShapeDescription
DestinationReachedAlertEventThis alert is fired when the vehicle has reached a location (whether for delivery or pickup).
OrdersLoadedAlertEventThis alert is fired when all orders have been loaded onto a vehicle.
DeliveryCompletedAlertEventThis alert is fired when the vehicle has completed a delivery. This delivery might have been the last order delivery and vehicle needs to head back for more orders to be picked up.


Your Services should look like the following:

new_veh_events.png
Let's take a quick break to go over how this will work.

  1. A Service in the Fizos.Logistics Entity will search for all Things that implement the Fizos.Vehicles.ThingShape Entity.
  2. Each list of these Entities will have it's PickUpGoods Service called with the desired pickup location.
  3. When the destination is reached inside of the PickUpGoods Service, the DestinationReached Alert will be triggered.
  4. A Subscription waiting for this Event at the Thing level, will call the LoadGoods Service based on the condition of no orders being in the vehicle CurrentOrders Property.
  5. This LoadGoods Service will finish and trigger a OrdersLoaded Event.
  6. A subscription waiting for this Event at the Thing level, will call the Travel service. The Service will be called with the customer location as the destination OR the location of another site to perform other tasks.
  7. When the destination is reached inside of the Travel Service, the DestinationReached Alert will be triggered.
  8. A Subscription waiting for this Event at the Thing level, will call the DeliverGoods Service based on the condition of orders being left in the CurrentOrders Property.
  9. When the delivery is complete, the DeliveryCompleted Alert will be triggered.
  10. A Subscription waiting for this Event at the Thing level, will decide whether to go to a factory or pickup location to restart the process or wait for more instructions.

You may have noticed a few things here. For starters, we are starting this from the Fizos.Logistics entity instead of a scheduler. For this process, you can start it with a scheduler, but being a 24 hour company, we don't have a schedule to start deliveries. That being said, the click of a button would do the job.

 

You can also see that we haven't given you the service code for some of these services. For some of these functions, they're almost duplicates of prior services. What will be more challenging and fun is the logic for which orders go to which delivery method. This is a mixture of vehicle properties, order properties, customer type, and customer location.

 

 

Step 5: Next Steps

 

Congratulations! You've successfully completed the Automated Distribution and Logistics guide.

 

In this guide, you learned how to:

  • Create automated logistical processes
  • Use services, alerts, and subscriptions to handle processes without human interaction
  • Integrating complex logic with straight forward step by step systems

 

The next guide in the Complex and Automatic Food and Beverage Systems learning path is Securing Industry Data

 

Learn More

We recommend the following resources to continue your learning experience:

 

Capability            Guide
BuildThingWorx Solutions in Food Industry
BuildDesign Your Data Model
BuildImplement Services, Events, and Subscriptions

 

Additional Resources

 

If you have questions, issues, or need additional information, refer to:

 

ResourceLink
CommunityDeveloper Community Forum
SupportHelp Center
Version history
Last update:
‎Nov 16, 2022 03:58 PM
Updated by:
Labels (1)
Contributors