diff --git a/app/charts/service/compare.data.js b/app/charts/service/compare.data.js new file mode 100644 index 00000000..5306cd7f --- /dev/null +++ b/app/charts/service/compare.data.js @@ -0,0 +1,3 @@ +function main(args, out, res) { + console.log(args, out, res); +} diff --git a/app/charts/service/compare.json b/app/charts/service/compare.json new file mode 100644 index 00000000..bb9392ed --- /dev/null +++ b/app/charts/service/compare.json @@ -0,0 +1,63 @@ +{ + "engine": "gou", + "name": "指标对比", + "version": "1.0.0", + "decription": "指标对比", + "nodes": [ + { + "name": "行业分布", + "process": "models.service.get", + "query": { + "select": ["city", ":COUNT(id) as cnt", "@industries.$ as industry"], + "wheres": [ + { "column": "created_at", "value": "{{$query.from}}", "op": "ge" }, + { "column": "created_at", "value": "{{$query.to}}", "op": "le" } + ], + "order": ["cnt.desc"], + "limit": 100, + "group": ["@industries.$", "city"] + } + }, + { + "name": "计费方式", + "process": "models.service.get", + "query": { + "select": ["city", ":COUNT(id) as cnt", "@price_options.$ as option"], + "wheres": [ + { "column": "created_at", "value": "{{$query.from}}", "op": "ge" }, + { "column": "created_at", "value": "{{$query.to}}", "op": "le" } + ], + "order": ["cnt.desc"], + "limit": 100, + "group": ["@price_options.$", "city"] + } + }, + { + "name": "合并结果", + "process": "xiang.chart.MergeData", + "args": [ + ["城市", "行业", "计费"], + { + "行业": { "key": "city", "values": "{{$res.行业分布[*].industry}}" }, + "计费": { "key": "city", "values": "{{$res.计费方式[*].option}}" } + } + ] + } + ], + "data": "{{$res.合并结果}}", + "filters": {}, + "page": { + "primary": "城市", + "layout": { + "filters": [ + { "name": "开始时间", "width": 6 }, + { "name": "结束时间", "width": 6 } + ], + "charts": [ + { "type": "line", "props": {} }, + { "type": "bar", "props": {} } + ] + }, + "actions": {} + } +} diff --git a/app/charts/service/service.sql b/app/charts/service/service.sql new file mode 100644 index 00000000..97299a6b --- /dev/null +++ b/app/charts/service/service.sql @@ -0,0 +1,8 @@ +SELECT * FROM service as service +JOIN JSON_TABLE(service.price_options, '$[*]' columns (price varchar(50) path '$') ) as t group by price + +/** +[mysqld] +sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" + */ + \ No newline at end of file