当前位置:网站首页>Sequence diagram data modeling and industrial chain analysis
Sequence diagram data modeling and industrial chain analysis
2022-07-04 16:39:00 【Ma Chao's blog】
Use chart data to analyze time series data of industrial chain - Design of data model
- Function and process function introduction
- Complete implementation - Build company and product sequence diagram data
- Query case - analysis ' Consumer goods trading ' industry 2020Q2 Total quarterly revenue
- Other information
Design of data model
industry 、 product 、 Company related industrial chain data modeling , Include product level maps 、 Industry stratification map 、 Upstream and downstream map of the industrial chain 、 Company and product atlas . The following is mainly the implementation scheme of sequence diagram data modeling of company and product revenue .
Function and process function introduction
- HTTP request
RETURN olab.http.post('api-address','input')- Reset MAP- Remove incoming KEY
RETURN olab.reset.map({map},{keys}) AS value- Generate JSON-STRING
RETURN olab.convert.json({object})
Complete implementation - Build company and product sequence diagram data
- In the following implementation, the timing data related to revenue is used JSON The format data modeling is stored in the attributes of the relationship
The following implementation integrates GraphQL-API、olab-apoc Components 、 Access database and other operations , The constructed graph data finally stores the timing data in a JSON Array .
CALL apoc.periodic.iterate('CALL apoc.load.jdbc(\'jdbc:mysql://contentdb.crkldnwly6ki.rds.cn-north-1.amazonaws.com.cn:3306/database?user=datalab_dev&password=datalabgogo&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC\',
\'SELECT calc.company_id AS fromCompanyId,pro.`name` AS `to`,CONVERT(DATE_FORMAT(calc.report_date,\\\'%Y%m%d%H%i%S\\\'),UNSIGNED INTEGER)
AS report_date,income,profit,product_income,product_income_ratio,product_profit,product_profit_ratio,\\\'id\\\' AS uniqueField,calc.id AS uniqueFieldID,\\\'chinascope_supply_chain.fin_secu_sam_product_calc\\\' AS jsDataApi FROM fin_secu_sam_product_calc calc RIGHT JOIN dict_product_rs pro ON calc.product_code=pro.`code` WHERE calc.update_time>=DATE_SUB(NOW(),INTERVAL 1 DAY)\')',
'WITH REPLACE(\'{"query": "{ horgByName(sourceCode: \\\\\\"company-id\\\\\\", sourceFlag: \\\\\\"chinascope\\\\\\") { name hcode }}","variables": null}\',\'company-id\',row.fromCompanyId) AS query,row WITH apoc.convert.fromJsonMap(olab.http.post(\'http://ip/ongdb/graphql\',query))
AS result,row WHERE result IS NOT NULL WITH result.data.horgByName[0].hcode AS fromHcode,result.data.horgByName[0].name AS fromName,row WHERE fromHcode IS NOT NULL WITH fromHcode,fromName,row.to AS toName,row
WITH fromHcode,fromName,\'HPRDCLS\'+apoc.util.md5([toName]) AS toHcode,row MERGE (from:HORGProductCalc {hcode:fromHcode}) SET from.name=fromName,from:HORG WITH from,toHcode,row MATCH (to: industry {hcode:toHcode})
WITH from,to,row WHERE from<>to WITH from,to,olab.reset.map(row,[\'fromCompanyId\',\'to\']) AS row OPTIONAL MATCH (from)-[r]->(to) WITH from,to,row,apoc.coll.union(apoc.convert.fromJsonList(r.detail),[row]) AS detail
WITH from,to,row,olab.convert.json(detail) AS detail,SIZE(detail) AS detail_size MERGE (from)-[r: product ]->(to) SET r.detail=detail,r.detail_size=detail_size', {parallel:false,batchSize:100})
YIELD batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
Query case - analysis ’ Consumer goods trading ’ industry 2020Q2 Total quarterly revenue
- Inquire about ’ Consumer goods trading ’ All relevant products in the sub category of the industry
During data modeling, products are related to industries , Therefore, when used here, you can directly get , Pay attention to all the products of the sub industry of a certain industry .
# Expand PATH The way MATCH (indus: industry ) WHERE indus.name=' Consumer goods trading ' WITH indusCALL apoc.path.expandConfig(indus,{maxLevel:3, relationshipFilter:'NEXT>|<BELONG_TO', labelFilter:'+ industry |/ product ', bfs:false, filterStartNode:true,uniqueness:'NODE_GOLBEL', limit:-1}) YIELD pathWITHpathRETURNpath
# Expand NODE The way
MATCH (indus: industry ) WHERE indus.name=' Consumer goods trading ' WITH indus
CALL apoc.path.subgraphNodes(indus,{maxLevel:3, relationshipFilter:'NEXT>|<BELONG_TO',
labelFilter:'+ industry |/ product ', bfs:false, filterStartNode:true,uniqueness:'NODE_GOLBEL', limit:-1})
YIELD node WITH node
RETURN nodeSchematic diagram of industry and product association structure
- ' Consumer goods trading ’ Industry related products 【 Correlation refers to the division of subordination , Here are the industry related products within the three levels of subordinates 】2020Q2 Revenue analysis 【 The case realizes the total revenue 】
MATCH (indus: industry ) WHERE indus.name=' Consumer goods trading ' WITH indus
CALL apoc.path.subgraphNodes(indus,{maxLevel:3, relationshipFilter:'NEXT>|<BELONG_TO',
labelFilter:'+ industry |/ product ', bfs:false, filterStartNode:true,uniqueness:'NODE_GOLBEL', limit:-1}) YIELD node WITH node
MATCH p=(node)<-[r: product ]-(:HORGProductCalc) WITH apoc.convert.fromJsonList(r.detail) AS detail
UNWIND detail AS map
WITH map WHERE TOINTEGER(map.report_date)>=20200331000000 AND TOINTEGER(map.report_date)<=20200630000000
WITH TOINTEGER(map.income) AS income
RETURN SUM(income)
# The total revenue is twotrillion
╒═════════════╕
│"SUM(income)"│
╞═════════════╡
│2215100453627│
└─────────────┘- Sample diagram structure of products and companies .
Other information
- olab-apoc Components
https://github.com/ongdb-contrib/ongdb-lab-apoc- apoc Components 【Neo4j Official open source components 】
https://github.com/neo4j-contrib/neo4j-apoc-procedures边栏推荐
- Model fusion -- stacking principle and Implementation
- What is torch NN?
- . Net delay queue
- How can floating point numbers be compared with 0?
- Daily notes~
- [North Asia data recovery] data recovery case of database data loss caused by HP DL380 server RAID disk failure
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
- 时序图数据建模与产业链分析
- What does IOT engineering learn and work for?
- How to decrypt worksheet protection password in Excel file
猜你喜欢
![[native JS] optimized text rotation effect](/img/50/3c09f223e821c14e7e9e0fb47622b6.jpg)
[native JS] optimized text rotation effect

Move, say goodbye to the past again

Function test - knowledge points and common interview questions

Overview of convolutional neural network structure optimization

《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下

Big God explains open source buff gain strategy live broadcast

Game theory

165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
![[Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded](/img/c5/f933ad4a7bc903f15beede62c6d86f.jpg)
[Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded
![[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server](/img/79/3fab19045e1ab2f5163033afaa4309.jpg)
[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server
随机推荐
Practice: fabric user certificate revocation operation process
What should ABAP do when it calls a third-party API and encounters garbled code?
What is the catalog of SAP commerce cloud
如何为ONgDB核心项目源码做贡献
[Chongqing Guangdong education] National Open University spring 2019 1396 pharmaceutical administration and regulations (version) reference questions
Stress, anxiety or depression? Correct diagnosis and retreatment
Detailed process of DC-2 range construction and penetration practice (DC range Series)
多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
Feature extraction and detection 15-akaze local matching
Review of Weibo hot search in 2021 and analysis of hot search in the beginning of the year
std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
Research Report on market supply and demand and strategy of surgical stapler industry in China
Hair and fuzz interceptor Industry Research Report - market status analysis and development prospect forecast
. Net delay queue
时钟轮在 RPC 中的应用
Vscode setting outline shortcut keys to improve efficiency
JS to realize the countdown function