Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
Signed-off-by: hubin6 <[email protected]>
  • Loading branch information
hubin6 committed Nov 9, 2017
1 parent d5c9d19 commit daf5da4
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public class Constants {
public static final String TEMPLATE_PARENT_FOLDER = "metrics";
public static final String CHART_OPTION_SUFFIX = ".chart.json";
public static final String CHART_OPTION_SUFFIX = ".option";
public static final String CHART_TEMPLATE_SUFFIX = "chart.html";
public static final String VALUE_TEMPLATE_SUFFIX = "number.html";
public static final String TEMPLATE_MODEL_FILE = "model.json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jd.logistics.cloud.data.domain.DateCycle;
import com.jd.logistics.cloud.data.domain.Warehouse;
import com.jd.logistics.cloud.data.repository.DimRepository;
import com.jd.logistics.cloud.data.service.DimService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jd.logistics.cloud.data.domain.Function;
import com.jd.logistics.cloud.data.repository.FuncRepository;
import com.jd.logistics.cloud.data.service.FuncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jd.logistics.cloud.data.commons.Constants;
import com.jd.logistics.cloud.data.commons.Helper;
import com.jd.logistics.cloud.data.service.ModelService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jd.logistics.cloud.data.domain.User;
import com.jd.logistics.cloud.data.repository.UserRepository;
import com.jd.logistics.cloud.data.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
* @Author hubin
* @Description:
* @Date 2017/11/7 9:18
*/
@RequestMapping(value = "/api/model")
@RequestMapping(value = "/api")
public interface ModelApi {
@RequestMapping(value = "/{funcName}",
@RequestMapping(value = "/model/{funcName}",
produces = {"application/json"},
method = RequestMethod.GET)
Map getFuncModel(@PathVariable("funcName") String funcName);

@RequestMapping(value = "/models",
produces = {"application/json"},
method = RequestMethod.GET)
List<Map> getModels();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
Expand All @@ -22,4 +24,11 @@ public class ModelRestController implements ModelApi {
public Map getFuncModel(@PathVariable("funcName") String funcName) {
return modelService.getFuncModel(funcName);
}

@Override
public List<Map> getModels() {
List<Map> res = new ArrayList<>();
res.add(modelService.getFuncModel("sample1"));
return res;
}
}
16 changes: 8 additions & 8 deletions dashboard-web/src/main/resources/dev.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
spring.velocity.cache=false
spring.devtools.remote.restart.enabled=false
spring.datasource.url=jdbc:h2:mem:dev_db;MODE=MySQL
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
# spring.datasource.url=jdbc:mysql://192.168.99.100:3306/dev?characterEncoding=utf8&useSSL=false
# spring.datasource.username=root
# spring.datasource.password=root
# spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:h2:mem:dev_db;MODE=MySQL
#spring.datasource.username=
#spring.datasource.password=
#spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:mysql://192.168.99.100:3306/dev?characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 changes: 1 addition & 1 deletion dashboard-web/src/main/resources/metrics/sample1/a.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT '14,300' as v1, 8.8 as v2, -4.3 as v3
SELECT '在库SKU数'as f1, '14,300' as v1, '昨日环比'as f2, 8.8 as v2, '上周同比'as f3, -4.3 as v3
30 changes: 17 additions & 13 deletions dashboard-web/src/main/resources/metrics/sample1/chart.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<v-flex xs12 chart-header v-if=" data.values ">
<v-flex xs12 chart-header v-if="data.day">
<v-card>
<v-layout row wrap>
<v-flex xs4 chart-func-name-tag>{{data.labels.val1}}</v-flex>
<v-flex xs4 chart-func-name-tag>{{data.day.f1}}</v-flex>
<v-flex xs3 chart-idx-name>
<span>{{data.labels.val2}}<br><span class="box-idx-value"><b>{{data.values.val2}}%</b></span></span>
<i v-if="data.values.val2 > 0" class="material-icons md-16 green100">trending_up</i>
<i v-else-if="data.values.val2 == 0" class="material-icons md-16 yellow100">trending_flat</i>
<i v-else-if="data.values.val2 < 0" class="material-icons md-16 red100">trending_down</i>
<span>{{data.day.f2}}<br><span class="box-idx-value"><b>{{data.day.v2}}%</b></span>
<div v-if="data.day.v2 > 0" class="trending-up"></div>
<div v-else-if="data.day.v2 == 0" class="trending-flat"></div>
<div v-else-if="data.day.v2 < 0" class="trending-down"></div></span>
</v-flex>
<v-flex xs1 grey-bar></v-flex>
<v-flex xs3 chart-idx-name>2017/07/07</v-flex>
<v-flex xs1><i class="material-icons md-24 grey100">more_horiz</i></v-flex>
<v-flex xs4 chart-func-value-tag><b>{{data.values.val1}}</b></v-flex>
<v-flex xs1>
<v-btn icon v-on:click="goDetails('sample1')">
<v-icon class="md-24 grey100">more_horiz</v-icon>
</v-btn>
</v-flex>
<v-flex xs4 chart-func-value-tag><b>{{data.day.v1}}</b></v-flex>
<v-flex xs3 chart-idx-name>
<span>{{data.labels.val3}}<br><span class="box-idx-value"><b>{{data.values.val3}}%</b></span></span>
<i v-if="data.values.val3 > 0" class="material-icons md-16 green100">trending_up</i>
<i v-else-if="data.values.val3 == 0" class="material-icons md-16 yellow100">trending_flat</i>
<i v-else-if="data.values.val3 < 0" class="material-icons md-16 red100">trending_down</i>
<span>{{data.day.f3}}<br><span class="box-idx-value"><b>{{data.day.v3}}%</b></span>
<div v-if="data.day.v3 > 0" class="trending-up"></div>
<div v-else-if="data.day.v3 == 0" class="trending-flat"></div>
<div v-else-if="data.day.v3 < 0" class="trending-down"></div></span>
</v-flex>
<v-flex xs1 cyan-bar></v-flex>
<v-flex xs4 chart-idx-name>2017/07/14</v-flex>
Expand All @@ -26,7 +30,7 @@
<v-layout row wrap>
<v-flex xs12 chart-detail>
<v-card>
<div id="sample1-chart1" style="width:100%;height:240px"></div>
<div id="sample1-day" style="width:100%;height:240px"></div>
</v-card>
</v-flex>
</v-layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
color: '#6E88AC'
}
},
data: res.r_date.slice(-7)
data: res.stat_date.slice(-7)
},
yAxis: {
type: 'value',
Expand All @@ -41,7 +41,7 @@
width: 1
}
},
data: res.metrics_3.slice(-7)
data: res.func_value.slice(-7)
},
{
type: 'line',
Expand All @@ -51,6 +51,6 @@
width: 1
}
},
data: res.metrics_3.slice(0,7)
data: res.func_value.slice(0,7)
}]
}
44 changes: 38 additions & 6 deletions dashboard-web/src/main/resources/metrics/sample1/model.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
{
"charts": [
{
"name": "chart1",
"sql": "e.sql"
"name": "day",
"sql": "e.sql",
"params": [
{
"name": "dateCycle",
"value": ""
}
]
},
{
"name": "week",
"sql": "e.sql",
"params": [
{
"name": "dateCycle",
"value": ""
}
]
},
{
"name": "month",
"sql": "e.sql",
"params": [
{
"name": "dateCycle",
"value": ""
}
]
}
],
"name": "sample1",
"values": [
"description": [
{
"name": "day",
"sql": "a.sql"
"text": "just a test 日维度"
},
{
"name": "week",
"sql": "b.sql"
"text": "just a test 周维度"
},
{
"name": "month",
"sql": "c.sql"
"text": "just a test 月维度"
}
],
"values": [
{
"name": "day",
"sql": "a.sql"
}
]
}
56 changes: 56 additions & 0 deletions dashboard-web/src/main/resources/metrics/sample1/month.option
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
tooltip: {
trigger: 'axis',
axisPointer: {
animation: false
},
formatter:function(params) {
return '<span style="font-size:12px; color: #00D7FB">' + params[0].name + ' : ' + params[0].value + '</span><br>' +
'<span style="font-size:12px; color: #6E88AC">' + addDate(params[0].name, -7) + ' : ' + params[1].value + '</span>'
}
},
xAxis: {
type: 'category',
splitLine: {
show: false
},
axisLine: {
lineStyle: {
color: '#6E88AC'
}
},
data: res.stat_date.slice(-7)
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
splitLine: {
show: false
},
axisLine: {
lineStyle: {
color: '#6E88AC'
}
}
},
series: [{
type: 'bar',
itemStyle: {
normal: {
color: '#00D7FB',
width: 1
}
},
data: res.func_value.slice(-7)
},
{
type: 'bar',
itemStyle: {
normal: {
color: '#6E88AC',
width: 1
}
},
data: res.func_value.slice(0,7)
}]
}
22 changes: 11 additions & 11 deletions dashboard-web/src/main/resources/metrics/sample1/number.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<v-flex xs6 v-if="data.values">
<v-flex xs6 v-if="data.day">
<v-card>
<v-layout row wrap>
<v-flex xs8 box-func-name-tag>{{data.labels.val1}}</v-flex>
<v-flex xs8 box-func-name-tag>{{data.day.f1}}</v-flex>
<v-flex xs4 box-idx-name>
<span>{{data.labels.val2}}<br><span class="box-idx-value"><b>{{data.values.val2}}%</b></span></span>
<i v-if="data.values.val2 > 0" class="material-icons md-16 green100">trending_up</i>
<i v-else-if="data.values.val2 == 0" class="material-icons md-16 yellow100">trending_flat</i>
<i v-else-if="data.values.val2 < 0" class="material-icons md-16 red100">trending_down</i>
<span>{{data.day.f2}}<br><span class="box-idx-value"><b>{{data.day.v2}}%</b></span>
<div v-if="data.day.v2 > 0" class="trending-up"></div>
<div v-else-if="data.day.v2 == 0" class="trending-flat"></div>
<div v-else-if="data.day.v2 < 0" class="trending-down"></div></span>
</v-flex>
<v-flex xs8 box-func-value-tag><b>{{data.values.val1}}</b></v-flex>
<v-flex xs8 box-func-value-tag><b>{{data.day.v1}}</b></v-flex>
<v-flex xs4 box-idx-name>
<span>{{data.labels.val3}}<br><span class="box-idx-value"><b>{{data.values.val3}}%</b></span></span>
<i v-if="data.values.val3 > 0" class="material-icons md-16 green100">trending_up</i>
<i v-else-if="data.values.val3 == 0" class="material-icons md-16 yellow100">trending_flat</i>
<i v-else-if="data.values.val3 < 0" class="material-icons md-16 red100">trending_down</i>
<span>{{data.day.f3}}<br><span class="box-idx-value"><b>{{data.day.v3}}%</b></span>
<div v-if="data.day.v3 > 0" class="trending-up"></div>
<div v-else-if="data.day.v3 == 0" class="trending-flat"></div>
<div v-else-if="data.day.v3 < 0" class="trending-down"></div></span>
</v-flex>
<v-flex xs6 under-bar></v-flex>
</v-layout>
Expand Down
56 changes: 56 additions & 0 deletions dashboard-web/src/main/resources/metrics/sample1/week.option
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
tooltip: {
trigger: 'axis',
axisPointer: {
animation: false
},
formatter:function(params) {
return '<span style="font-size:12px; color: #00D7FB">' + params[0].name + ' : ' + params[0].value + '</span><br>' +
'<span style="font-size:12px; color: #6E88AC">' + addDate(params[0].name, -7) + ' : ' + params[1].value + '</span>'
}
},
xAxis: {
type: 'category',
splitLine: {
show: false
},
axisLine: {
lineStyle: {
color: '#6E88AC'
}
},
data: res.stat_date.slice(-7)
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
splitLine: {
show: false
},
axisLine: {
lineStyle: {
color: '#6E88AC'
}
}
},
series: [{
type: 'line',
itemStyle: {
normal: {
color: '#00D7FB',
width: 1
}
},
data: res.func_value.slice(-7)
},
{
type: 'bar',
itemStyle: {
normal: {
color: '#6E88AC',
width: 1
}
},
data: res.func_value.slice(0,7)
}]
}

0 comments on commit daf5da4

Please sign in to comment.