-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed insights bugs in supply shain kit #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13d4ad0
Fixed insights bugs in supply shain kit
abrahamchandy95 fa05d2e
Entity resoliton KYC insights graph name fixed for consistency
abrahamchandy95 45d5143
Enchanced comments in supply chain insights queries
abrahamchandy95 e7ee33d
changes to Insights application in mule account solution kit removed …
abrahamchandy95 949e629
KYC solution in financial crime readme formatting corrected
abrahamchandy95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
agile_operations/supply_chain_management/queries/explore_BOM_insights.gsql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| CREATE OR REPLACE DISTRIBUTED QUERY explore_BOM_insights(STRING vertType,STRING id, INT depth, BOOL upstream) FOR GRAPH Supply_Chain_Management { | ||
| /* | ||
| Query Name: explore_BOM_insights | ||
| Multi-level BOM exploration (downstream) or where-used analysis (upstream) | ||
| starting from a vertex identified by (vertType, id). | ||
|
|
||
| Key Use Cases: | ||
| . Explode a material/BOM into its components and related suppliers (downstream) | ||
| . Reverse trace: find BOMs/material relationships and supply paths (upstream) | ||
| . Useful for impact analysis, sourcing visibility, and BOM troubleshooting. | ||
|
|
||
| Parameters: | ||
| vertType (STRING): | ||
| Vertex type name of the starting vertex (e.g., Material, BOM, Supplier) | ||
| id (STRING): | ||
| Primary/external ID of the starting vertex (converted via to_vertex(id, vertType)) | ||
| depth (INT): | ||
| Maximum traversal depth | ||
| upstream (BOOL): | ||
| TRUE -> Where-used / reverse trace | ||
| FALSE -> BOM explosion / forward trace | ||
|
|
||
| Output: | ||
| Prints the traversed edge set (@@edges) and vertex set (@@nodes). | ||
| */ | ||
| SetAccum<EDGE> @@edges; | ||
| SetAccum<VERTEX> @@nodes; | ||
| OrAccum @visited; | ||
| OrAccum @isSrc; | ||
| vertex vertss; | ||
| vertss = to_vertex(id,vertType); | ||
| // get src | ||
| verts = {vertss}; | ||
| verts = select s from verts:s ACCUM s.@isSrc += TRUE,@@nodes += s; | ||
|
|
||
| // while loop | ||
| WHILE verts.size() > 0 LIMIT depth DO | ||
| // traverse up or down | ||
| IF upstream == TRUE THEN | ||
| verts = | ||
| SELECT t FROM verts:s -((Supplies|reverse_Has_Component_Material|reverse_Produced_By):e)- (Material|BOM):t | ||
| WHERE t.@visited == FALSE | ||
| ACCUM @@edges += e,@@nodes += t | ||
| POST-ACCUM | ||
| s.@visited = TRUE; | ||
| ELSE | ||
| verts = | ||
| SELECT t FROM verts:s -((reverse_Supplies|Has_Component_Material|Produced_By):e)- (Material|BOM|Supplier):t | ||
| WHERE t.@visited == FALSE | ||
| ACCUM @@edges += e,@@nodes += t | ||
| POST-ACCUM | ||
| s.@visited = TRUE; | ||
| END; | ||
| END; | ||
|
|
||
| // print edges | ||
| PRINT @@edges; | ||
| nodes = {@@nodes}; | ||
| PRINT nodes; | ||
| } |
76 changes: 76 additions & 0 deletions
76
agile_operations/supply_chain_management/queries/explore_BOM_line_Insights.gsql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| CREATE OR REPLACE DISTRIBUTED QUERY explore_BOM_line_Insights(STRING vertType,STRING id, INT depth, BOOL upstream, BOOL use_date_range, DATETIME start_date, DATETIME end_date) FOR GRAPH Supply_Chain_Management { | ||
| /* | ||
| Description: | ||
| End-to-end transactional lineage traversal (order-to-cash & procure-to-pay) | ||
| across actual production instances (SFC), sales orders, purchase orders, | ||
| shipments, and customers/suppliers. | ||
|
|
||
| This is the "digital thread" query — it connects the physical flow | ||
| (what was actually built and shipped) with the commercial flow | ||
| (who ordered it and who supplied the components). | ||
|
|
||
| Parameters: | ||
| vertType (STRING): | ||
| Vertex type name of the starting vertex — typically SFC_Material (actual batch), | ||
| Sales_Order, Purchase_Order, Customer, or Supplier | ||
| id (STRING): | ||
| Primary/external ID of the starting vertex (paired with vertType and converted | ||
| to a vertex via to_vertex(id, vertType)) | ||
| depth (INT): | ||
| Maximum traversal depth | ||
| upstream (BOOL): | ||
| FALSE → Follow the flow downstream | ||
| TRUE → Follow the flow upstream | ||
| use_date_range (BOOL): | ||
| If TRUE, only traverse through dated vertices (Sales_Order, Purchase_Order, | ||
| SFC_Assembly) that fall within the specified window | ||
| start_date / end_date (DATETIME): | ||
| Optional time fence for filtering transactional vertices | ||
|
|
||
| */ | ||
| SetAccum<VERTEX> @@nodes; | ||
| OrAccum @isSrc; | ||
| vertex vertss; | ||
| vertss = to_vertex(id,vertType); | ||
| // get src | ||
| verts = {vertss}; | ||
| verts = select s from verts:s ACCUM s.@isSrc += TRUE,@@nodes += s; | ||
|
|
||
| SetAccum<EDGE> @@edges; | ||
| OrAccum @visited; | ||
|
|
||
|
|
||
| // while loop | ||
| WHILE verts.size() > 0 LIMIT depth DO | ||
| // traverse up or down | ||
| IF upstream == TRUE THEN | ||
| verts = | ||
| SELECT t FROM verts:s -((Has_Purchase_Order|Has_Line_Number|reverse_Used_For| | ||
| reverse_Has_Component_SFC|reverse_To_Be_Produced_By|reverse_For_Material| | ||
| reverse_Has_Sales_Order_Item|reverse_Has_Sales_Order):e)- | ||
| (Purchase_Order|Line_Number|SFC_Material|SFC_Assembly|Sales_Order_Item|Sales_Order|Customer):t | ||
| WHERE t.@visited == FALSE | ||
| // relevant vertices in date range (SFC_Assembly,Sales_Order,Purchase_Order) | ||
| ACCUM @@edges += e,@@nodes += t | ||
| POST-ACCUM | ||
| s.@visited = TRUE; | ||
| ELSE | ||
| verts = | ||
| SELECT t FROM verts:s -((reverse_Has_Purchase_Order|reverse_Has_Line_Number|Used_For| | ||
| Has_Component_SFC|To_Be_Produced_By|For_Material| | ||
| Has_Sales_Order_Item|Has_Sales_Order):e)- | ||
| (Supplier|Purchase_Order|Line_Number|SFC_Material|SFC_Assembly|Sales_Order_Item|Sales_Order):t | ||
| WHERE t.@visited == FALSE | ||
| // relevant vertices in date range (SFC_Assembly,Sales_Order,Purchase_Order) | ||
| ACCUM @@edges += e,@@nodes += t | ||
| POST-ACCUM | ||
| s.@visited = TRUE; | ||
| END;//Based_On,reverse_Based_On,Happens_At,reverse_Happens_At,Produced_By,reverse_Produced_By,Has_Component_Material,reverse_Has_Component_Material,SFC_To_Material,reverse_SFC_To_Material,Supplies,reverse_Supplies,Has,reverse_Has | ||
| END; | ||
|
|
||
| // print edges | ||
| PRINT @@edges; | ||
| nodes = {@@nodes}; | ||
| PRINT nodes; | ||
| PRINT "explore_BOMLine works!"; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.