From 041a2b998dc757305f875b95fe22dcd913c9fd09 Mon Sep 17 00:00:00 2001 From: hubin6 Date: Mon, 13 Nov 2017 16:04:03 +0800 Subject: [PATCH] refine code Signed-off-by: hubin6 --- .../cloud/data/commons/Constants.java | 11 +- .../cloud/data/commons/GenStatService.java | 17 +- .../logistics/cloud/data/commons/Helper.java | 85 ++++++--- .../cloud/data/domain/BaseModel.java | 7 +- .../jd/logistics/cloud/data/domain/Col.java | 22 --- .../domain/{Description.java => Def.java} | 2 +- .../logistics/cloud/data/domain/DimQuery.java | 71 ------- .../logistics/cloud/data/domain/Function.java | 52 ------ .../cloud/data/domain/GenericRes.java | 80 -------- .../logistics/cloud/data/domain/Metric.java | 35 ++++ .../jd/logistics/cloud/data/domain/Stat.java | 2 - .../cloud/data/domain/StatQuery.java | 17 -- .../data/implement/ChartServiceImpl.java | 25 +-- .../cloud/data/implement/DefServiceImpl.java | 28 +++ .../cloud/data/implement/FuncServiceImpl.java | 40 ---- .../data/implement/MetricServiceImpl.java | 40 ++++ .../data/implement/ModelServiceImpl.java | 35 ++-- .../cloud/data/implement/StatServiceImpl.java | 175 ------------------ .../data/implement/ValueServiceImpl.java | 18 +- .../cloud/data/repository/FuncRepository.java | 30 --- .../data/repository/MetricRepository.java | 30 +++ .../cloud/data/repository/StatRepository.java | 63 ------- .../cloud/data/repository/UserRepository.java | 8 +- .../cloud/data/service/ChartService.java | 6 +- .../cloud/data/service/DefService.java | 12 ++ .../cloud/data/service/FuncService.java | 20 -- .../cloud/data/service/MetricService.java | 20 ++ .../cloud/data/service/ModelService.java | 3 +- .../cloud/data/service/StatService.java | 32 ---- .../cloud/data/service/ValueService.java | 4 +- .../cloud/data/web/api/ChartApi.java | 24 +-- .../cloud/data/web/api/DefinitionApi.java | 26 +++ .../web/api/{FuncApi.java => MetricApi.java} | 12 +- .../cloud/data/web/api/ModelApi.java | 11 -- .../logistics/cloud/data/web/api/StatApi.java | 65 ------- .../cloud/data/web/api/ValueApi.java | 18 +- .../web/controller/ChartRestController.java | 27 +-- .../controller/DefinitionRestController.java | 40 ++++ ...troller.java => MetricRestController.java} | 24 +-- .../web/controller/ModelRestController.java | 24 +-- .../web/controller/StatRestController.java | 70 ------- .../web/controller/ValueRestController.java | 22 +-- .../src/main/resources/dev.properties | 9 +- .../sample1/{day.option => day.chartOption} | 0 .../main/resources/metrics/sample1/model.json | 2 +- .../{month.option => month.chartOption} | 0 .../resources/metrics/sample1/number.html | 35 ---- .../sample1/{week.option => week.chartOption} | 0 .../main/resources/metrics/sample2/chart.html | 59 ------ .../sample2/{day.option => day.chartOption} | 0 .../main/resources/metrics/sample2/model.json | 2 +- .../{month.option => month.chartOption} | 0 .../resources/metrics/sample2/number.html | 35 ---- .../sample2/{week.option => week.chartOption} | 0 .../main/resources/metrics/sample3/chart.html | 59 ------ .../sample3/{day.option => day.chartOption} | 0 .../main/resources/metrics/sample3/model.json | 2 +- .../{month.option => month.chartOption} | 0 .../sample3/{week.option => week.chartOption} | 0 .../main/resources/metrics/sample4/chart.html | 59 ------ .../sample4/{day.option => day.chartOption} | 0 .../main/resources/metrics/sample4/model.json | 2 +- .../{month.option => month.chartOption} | 0 .../resources/metrics/sample4/number.html | 35 ---- .../sample4/{week.option => week.chartOption} | 0 .../{metrics/sample1 => templates}/chart.html | 6 +- .../sample3 => templates}/number.html | 2 +- dashboard-web/src/main/webapp/index.html | 4 + dashboard-web/src/main/webapp/index_2.html | 2 + pom.xml | 90 ++++----- 70 files changed, 446 insertions(+), 1310 deletions(-) delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Col.java rename dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/{Description.java => Def.java} (88%) delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/DimQuery.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Function.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/GenericRes.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Metric.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/StatQuery.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/DefServiceImpl.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/FuncServiceImpl.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/MetricServiceImpl.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/StatServiceImpl.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/FuncRepository.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/MetricRepository.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/StatRepository.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DefService.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncService.java create mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/MetricService.java delete mode 100644 dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/StatService.java create mode 100644 dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DefinitionApi.java rename dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/{FuncApi.java => MetricApi.java} (73%) delete mode 100644 dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/StatApi.java create mode 100644 dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/DefinitionRestController.java rename dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/{FuncRestController.java => MetricRestController.java} (50%) delete mode 100644 dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/StatRestController.java rename dashboard-web/src/main/resources/metrics/sample1/{day.option => day.chartOption} (100%) rename dashboard-web/src/main/resources/metrics/sample1/{month.option => month.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample1/number.html rename dashboard-web/src/main/resources/metrics/sample1/{week.option => week.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample2/chart.html rename dashboard-web/src/main/resources/metrics/sample2/{day.option => day.chartOption} (100%) rename dashboard-web/src/main/resources/metrics/sample2/{month.option => month.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample2/number.html rename dashboard-web/src/main/resources/metrics/sample2/{week.option => week.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample3/chart.html rename dashboard-web/src/main/resources/metrics/sample3/{day.option => day.chartOption} (100%) rename dashboard-web/src/main/resources/metrics/sample3/{month.option => month.chartOption} (100%) rename dashboard-web/src/main/resources/metrics/sample3/{week.option => week.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample4/chart.html rename dashboard-web/src/main/resources/metrics/sample4/{day.option => day.chartOption} (100%) rename dashboard-web/src/main/resources/metrics/sample4/{month.option => month.chartOption} (100%) delete mode 100644 dashboard-web/src/main/resources/metrics/sample4/number.html rename dashboard-web/src/main/resources/metrics/sample4/{week.option => week.chartOption} (100%) rename dashboard-web/src/main/resources/{metrics/sample1 => templates}/chart.html (92%) rename dashboard-web/src/main/resources/{metrics/sample3 => templates}/number.html (96%) diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Constants.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Constants.java index 9c009bd..3aedae3 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Constants.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Constants.java @@ -6,9 +6,10 @@ * @Date 2017/11/7 9:32 */ public class Constants { - public static final String TEMPLATE_PARENT_FOLDER = "metrics"; - 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"; + public static final String CONFIG_PARENT_FOLDER = "metrics"; + public static final String CHART_OPTION_SUFFIX = ".chartOption"; + public static final String CHART_TEMPLATE_FILE = "chart.html"; + public static final String VALUE_TEMPLATE_FILE = "number.html"; + public static final String CONFIG_MODEL_FILE = "model.json"; + public static final String TEMPLATE_PARENT_FOLDER = "templates"; } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/GenStatService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/GenStatService.java index d828d94..42ad7dc 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/GenStatService.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/GenStatService.java @@ -1,7 +1,6 @@ package com.jd.logistics.cloud.data.commons; -import com.jd.logistics.cloud.data.domain.Function; -import com.jd.logistics.cloud.data.domain.Stat; +import com.jd.logistics.cloud.data.domain.Metric; import java.text.SimpleDateFormat; import java.util.*; @@ -14,8 +13,7 @@ public class GenStatService { private final static int rec_num = 32; private final static Random r = new Random(rec_num); - public static List statList = new ArrayList<>(); - public static List functionList = new ArrayList<>(); + public static List functionList = new ArrayList<>(); static { // gen(rec_num); @@ -77,20 +75,11 @@ private static void gen(int num) { } - public static List getStatList(int limit, int offset) { - List tmpList = new ArrayList<>(); - for (int i = offset; i < offset + limit; i++) { - if (i > count - 1) break; - tmpList.add(statList.get(i)); - } - return tmpList; - } - public static List getFunctionList() { + public static List getFunctionList() { return functionList; } - public static int count = statList.size(); public static void main(String[] args) { GenStatService gs = new GenStatService(); diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Helper.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Helper.java index b6386cd..3f0d06a 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Helper.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/commons/Helper.java @@ -4,6 +4,7 @@ import com.google.common.io.Resources; import com.jd.logistics.cloud.data.domain.*; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; @@ -41,37 +42,72 @@ public static String getStringFromResourcePath(String filePath) { } catch (IOException e) { e.printStackTrace(); } - return Helper.InputStream2String(in); + return InputStream2String(in); } - public static Map getDesc(String funcId) { - String json = Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcId + "/" + Constants.TEMPLATE_MODEL_FILE); + public static BaseModel getBaseModel(String metricId) { + String json = getStringFromResourcePath(Constants.CONFIG_PARENT_FOLDER + "/" + + metricId + "/" + Constants.CONFIG_MODEL_FILE); BaseModel bm = JSON.parseObject(json, BaseModel.class); - Map descList = new HashMap<>(); - for (Description desc: bm.getDescriptions()) { - descList.put(desc.getName(), desc.getText()); + return bm; + } + + public static Map getDesc(String metricId) { + BaseModel model = getBaseModel(metricId); + Map defList = new HashMap<>(); + for (Def def : model.getDef()) { + defList.put(def.getName(), def.getText()); } - return descList; + return defList; } - public static Map getFuncSqlByType(String funcId, ShowType type) { - String json = Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcId + "/" + Constants.TEMPLATE_MODEL_FILE); - BaseModel bm = JSON.parseObject(json, BaseModel.class); - Map sqlList = new HashMap<>(); - if (type == ShowType.CHART) { - for (ChartModel model : bm.getCharts()) { - sqlList.put(model.getName(), Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcId + "/" + model.getSql())); - } - } else if (type == ShowType.VALUE) { - for (ValueModel model : bm.getValues()) { - sqlList.put(model.getName(), Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcId + "/" + model.getSql())); - } + public static List getChartModels(String metricId) { + BaseModel model = getBaseModel(metricId); + return model.getCharts(); + } + + @Nullable + public static ChartModel getChartModelByDateCycle(String metricId, String dateCycle) { + BaseModel model = getBaseModel(metricId); + for (ChartModel m : model.getCharts()) { + if (m.getName().equals(dateCycle)) + return m; } - return sqlList; + return null; + } + + public static List getValueModels(String metricId) { + BaseModel model = getBaseModel(metricId); + return model.getValues(); + } + + @Nullable + public static ValueModel getValueModelByDateCycle(String metricId, String dateCycle) { + BaseModel model = getBaseModel(metricId); + for (ValueModel m : model.getValues()) { + if (m.getName().equals(dateCycle)) + return m; + } + return null; + } + + @NotNull + public static String getMetricChartSql(String metricId, String dateCycle) { + ChartModel model = getChartModelByDateCycle(metricId, dateCycle); + return getStringFromResourcePath(Constants.CONFIG_PARENT_FOLDER + "/" + + metricId + "/" + model.getSql()); + } + + @NotNull + public static String getMetricValueSql(String metricId, String dateCycle) { + ValueModel model = getValueModelByDateCycle(metricId, dateCycle); + return getStringFromResourcePath(Constants.CONFIG_PARENT_FOLDER + "/" + + metricId + "/" + model.getSql()); + } + + public static String getMetricChartOption(String metricId, String dateCycle) { + return getStringFromResourcePath(Constants.CONFIG_PARENT_FOLDER + "/" + + metricId + "/" + dateCycle + Constants.CHART_OPTION_SUFFIX); } public static Map> RowSet2ArrayRes(SqlRowSet rowSet) { @@ -87,7 +123,6 @@ public static Map> RowSet2ArrayRes(SqlRowSet rowSet) { return cr.getArrayResult(); } - public static Map RowSet2SingleRes(SqlRowSet rowSet) { SqlRowSetMetaData metaData = rowSet.getMetaData(); String[] colNames = metaData.getColumnNames(); diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/BaseModel.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/BaseModel.java index cd5ff98..29326a2 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/BaseModel.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/BaseModel.java @@ -1,7 +1,6 @@ package com.jd.logistics.cloud.data.domain; import lombok.Data; -import org.apache.ibatis.javassist.runtime.Desc; import java.io.Serializable; import java.util.List; @@ -18,7 +17,7 @@ public class BaseModel implements Serializable { private String name; private List charts; private List values; - private List descriptions; + private List def; public String getId() { return id; @@ -36,7 +35,7 @@ public List getValues() { return values; } - public List getDescriptions() { - return descriptions; + public List getDef() { + return def; } } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Col.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Col.java deleted file mode 100644 index 227250d..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Col.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.jd.logistics.cloud.data.domain; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/23 16:16 - */ -@Data -public class Col implements Serializable { - private static final long serialVersionUID = 6155650348427219235L; - private String title; - private String key; - - public Col(String key, String title) { - this.title = title; - this.key = key; - } -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Description.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Def.java similarity index 88% rename from dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Description.java rename to dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Def.java index e496761..e5aea07 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Description.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Def.java @@ -10,7 +10,7 @@ * @Date 2017/11/10 10:10 */ @Data -public class Description implements Serializable { +public class Def implements Serializable { private static final long serialVersionUID = -8617270101773389965L; private String name; private String text; diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/DimQuery.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/DimQuery.java deleted file mode 100644 index 7fa2e08..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/DimQuery.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.jd.logistics.cloud.data.domain; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/31 15:39 - */ -@Data -public class DimQuery implements Serializable { - private static final long serialVersionUID = -946299281247438489L; - private String funcName; - private List funcNameList; - private String warehouse; - private String dateCycle; - private String statDate; - private String dateStart; - private String dateEnd; - - public String getWarehouse() { - return warehouse; - } - - public String getDateCycle() { - return dateCycle; - } - - public String getStatDate() { - return statDate; - } - - public String getDateStart() { - return dateStart; - } - - public String getDateEnd() { - return dateEnd; - } - - public List getFuncNameList() { - return funcNameList; - } - - public void setFuncName(String funcName) { - this.funcName = funcName; - } - - public void setWarehouse(String warehouse) { - this.warehouse = warehouse; - } - - public void setDateCycle(String dateCycle) { - this.dateCycle = dateCycle; - } - - public void setStatDate(String statDate) { - this.statDate = statDate; - } - - public void setDateStart(String dateStart) { - this.dateStart = dateStart; - } - - public void setDateEnd(String dateEnd) { - this.dateEnd = dateEnd; - } -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Function.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Function.java deleted file mode 100644 index eb6f7ca..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Function.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jd.logistics.cloud.data.domain; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Created by GIN on 2017/10/30. - */ -@Data -public class Function implements Serializable { - private static final long serialVersionUID = -3908221732001318230L; - // public enum FuncType { -// BOX(0), CHART(1), FREE(2); -// private int index; -// FuncType(int index) { -// this.index = index; -// } -// public static FuncType getFuncType(int index) { -// switch (index) { -// case 0: -// return FuncType.BOX; -// case 1: -// return FuncType.CHART; -// case 2: -// return FuncType.FREE; -// } -// return FuncType.BOX; -// } -// } - private String id; - private String funcName; - private int funcType; // BOX(0), CHART(1), FREE(2); - private int seq; - - public String getId() { - return id; - } - - public String getFuncName() { - return funcName; - } - - public int getFuncType() { - return funcType; - } - - public int getSeq() { - return seq; - } - -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/GenericRes.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/GenericRes.java deleted file mode 100644 index 5e930ab..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/GenericRes.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jd.logistics.cloud.data.domain; - -import lombok.Data; - -import java.io.Serializable; -import java.text.DecimalFormat; -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/31 15:50 - */ -@Data -public class GenericRes implements Serializable { - private static final long serialVersionUID = 1902248647108008231L; - private String funcName; - private double funcValue; - private String funcFormatValue; - private String idxName1; - private double idxValue1; - private String idxName2; - private double idxValue2; - private String idxName3; - private double idxValue3; - private String idxName4; - private double idxValue4; - private String idxName5; - private double idxValue5; - private String idxName6; - private double idxValue6; - private String idxName7; - private double idxValue7; - private String idxName8; - private double idxValue8; - private String idxName9; - private double idxValue9; - private String idxName10; - private double idxValue10; - private String idxName11; - private double idxValue11; - private String statDate; - private List p; - private List v1; - private List v2; - - public String getFuncFormatValue() { - DecimalFormat df = new DecimalFormat("###,##0"); - DecimalFormat df2 = new DecimalFormat("###,##0.00"); - double tmp = funcValue; - if (tmp / 100000 >= 1) - funcFormatValue = df.format(tmp / 1000) + "K"; - else if ((tmp * 10) % 10 == 0) // integer - funcFormatValue = df.format(tmp); - else if (tmp <= 1) // 百分比 - funcFormatValue = df2.format(tmp * 100) + "%"; - else funcFormatValue = df2.format(tmp); - return funcFormatValue; - } - - public double getFuncValue() { - return funcValue; - } - - public String getStatDate() { - return statDate; - } - - public void setP(List p) { - this.p = p; - } - - public void setV1(List v1) { - this.v1 = v1; - } - - public void setV2(List v2) { - this.v2 = v2; - } -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Metric.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Metric.java new file mode 100644 index 0000000..9d3cf02 --- /dev/null +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Metric.java @@ -0,0 +1,35 @@ +package com.jd.logistics.cloud.data.domain; + +import lombok.Data; + +import java.io.Serializable; + +/** + * Created by GIN on 2017/10/30. + */ +@Data +public class Metric implements Serializable { + private static final long serialVersionUID = -3908221732001318230L; + + private String id; + private String metricName; + private int metricType; // BOX(0), CHART(1), FREE(2); + private int seq; + + public String getId() { + return id; + } + + public String getMetricName() { + return metricName; + } + + public int getMetricType() { + return metricType; + } + + public int getSeq() { + return seq; + } + +} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Stat.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Stat.java index e5241bc..deee9a9 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Stat.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/Stat.java @@ -4,8 +4,6 @@ import lombok.Data; import java.io.Serializable; -import java.util.List; -import java.util.Random; /** * @Author hubin diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/StatQuery.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/StatQuery.java deleted file mode 100644 index ae4ca3f..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/domain/StatQuery.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.jd.logistics.cloud.data.domain; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/23 14:46 - */ -@Data -public class StatQuery implements Serializable { - private static final long serialVersionUID = 4450457201267066885L; - private String D1; - -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ChartServiceImpl.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ChartServiceImpl.java index 70024d3..a78e20a 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ChartServiceImpl.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ChartServiceImpl.java @@ -1,15 +1,12 @@ package com.jd.logistics.cloud.data.implement; -import com.jd.logistics.cloud.data.commons.Constants; import com.jd.logistics.cloud.data.commons.Helper; -import com.jd.logistics.cloud.data.commons.ShowType; import com.jd.logistics.cloud.data.service.ChartService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.stereotype.Service; -import java.util.HashMap; import java.util.Map; /** @@ -23,21 +20,8 @@ public class ChartServiceImpl implements ChartService { JdbcTemplate jdbcTemplate; @Override - public Map getFuncCharts(String funcId) { - Map sqlList = Helper.getFuncSqlByType(funcId, ShowType.CHART); - Map res = new HashMap<>(); - for (Map.Entry e : sqlList.entrySet()) { - String sql = e.getValue(); - SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql); - res.put(e.getKey(), Helper.RowSet2ArrayRes(rowSet)); - } - return res; - } - - @Override - public Map getFuncChartByDateCycle(String funcId, String dateCycle, Map params) { - Map sqlList = Helper.getFuncSqlByType(funcId, ShowType.CHART); - String sql = sqlList.get(dateCycle); + public Map getMetricChart(String metricId, String dateCycle, Map params) { + String sql = Helper.getMetricChartSql(metricId, dateCycle); for (Map.Entry p : params.entrySet()) { sql = sql.replace(String.format("#{{%s}}", p.getKey()), p.getValue()); } @@ -46,8 +30,7 @@ public Map getFuncChartByDateCycle(String funcId, String dateCycle, Map getFuncByType(int type) { - return funcRepository.getByType(type); - } - - @Override - public List getAllFunc() { - return funcRepository.getAll(); - } - - @Override - public void updateFuncType(Function func) { - funcRepository.update(func); - } - - @Override - public String getFuncNameById(String funcId) { - return funcRepository.getFuncNameById(funcId); - } -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/MetricServiceImpl.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/MetricServiceImpl.java new file mode 100644 index 0000000..297a497 --- /dev/null +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/MetricServiceImpl.java @@ -0,0 +1,40 @@ +package com.jd.logistics.cloud.data.implement; + +import com.jd.logistics.cloud.data.domain.Metric; +import com.jd.logistics.cloud.data.repository.MetricRepository; +import com.jd.logistics.cloud.data.service.MetricService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author hubin + * @Description: + * @Date 2017/10/31 10:17 + */ +@Service +public class MetricServiceImpl implements MetricService { + @Autowired + MetricRepository metricRepository; + + @Override + public List getMetricsByType(int type) { + return metricRepository.getByType(type); + } + + @Override + public List getAllMetrics() { + return metricRepository.getAll(); + } + + @Override + public void updateMetric(Metric func) { + metricRepository.update(func); + } + + @Override + public String getMetricNameById(String metricId) { + return metricRepository.getMetricNameById(metricId); + } +} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ModelServiceImpl.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ModelServiceImpl.java index ef4ab42..acf1937 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ModelServiceImpl.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ModelServiceImpl.java @@ -2,9 +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.FuncService; import com.jd.logistics.cloud.data.service.ModelService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -17,35 +15,26 @@ */ @Service public class ModelServiceImpl implements ModelService { - @Autowired - FuncService funcService; - private String getFuncChartFormat(String funcName) { - return Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcName + "/" + Constants.CHART_TEMPLATE_SUFFIX); + private static final String chartTemplate = getMetricChartFormat(); + private static final String numberTemplate = getMetricValueFormat(); + + private static String getMetricChartFormat() { + return Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + + "/" + Constants.CHART_TEMPLATE_FILE); } - private String getFuncValueFormat(String funcName) { - return Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + "/" + - funcName + "/" + Constants.VALUE_TEMPLATE_SUFFIX); + private static String getMetricValueFormat() { + return Helper.getStringFromResourcePath(Constants.TEMPLATE_PARENT_FOLDER + + "/" + Constants.VALUE_TEMPLATE_FILE); } @Override - public Map getFuncModel(String funcId) { - String chartTemplate = getFuncChartFormat(funcId); - String numberTemplate = getFuncValueFormat(funcId); + public Map getModel(String metricId, String metricName) { Map res = new HashMap<>(); - res.put("id", funcId); - res.put("name", funcService.getFuncNameById(funcId)); + res.put("id", metricId); + res.put("name", metricName); res.put("chartTemplate", chartTemplate); res.put("numberTemplate", numberTemplate); return res; } - - @Override - public Map getFuncDesc(String funcId) { - Map res = Helper.getDesc(funcId); - res.put("id", funcId); - res.put("name", funcService.getFuncNameById(funcId)); - return res; - } } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/StatServiceImpl.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/StatServiceImpl.java deleted file mode 100644 index 081d889..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/StatServiceImpl.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.jd.logistics.cloud.data.implement; - - -import com.jd.logistics.cloud.data.commons.GenStatService; -import com.jd.logistics.cloud.data.commons.page.Page; -import com.jd.logistics.cloud.data.commons.page.PageRequest; -import com.jd.logistics.cloud.data.domain.*; -import com.jd.logistics.cloud.data.repository.StatRepository; -import com.jd.logistics.cloud.data.service.StatService; -import io.swagger.annotations.ApiModelProperty; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.lang.reflect.Field; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/23 14:47 - */ -@Service -public class StatServiceImpl implements StatService { - @Autowired - StatRepository statRepository; - - public static void main(String[] args) { - StatServiceImpl ss = new StatServiceImpl(); - System.out.println(ss.getPeriods()); - DecimalFormat df = new DecimalFormat("###,##0.00"); - double d = 0.777; - System.out.println(df.format(d * 100) + "%"); - //System.out.println(GenStatService.statList); - } - - @Override - public Page findStats(StatQuery query, PageRequest pageRequest) { - List statList = GenStatService.getStatList(pageRequest.getPageSize(), (int) pageRequest.getOffset()); - Page statPage = new Page<>(); - statPage.setPage(pageRequest.getPage()); - statPage.setSize(pageRequest.getPageSize()); - statPage.setTotalElements(GenStatService.count); - statPage.setContent(statList); - return statPage; - } - - @Override - public List getCols() { - List cols = new ArrayList<>(); - for (Field f : Stat.class.getDeclaredFields()) { - if (null != f.getAnnotation(ApiModelProperty.class)) { - cols.add(new Col(f.getName().toLowerCase(), f.getAnnotation(ApiModelProperty.class).name())); - } - } - return cols; - } - - @Override - public List getCategories() { - List categories = new ArrayList<>(); - for (Field f : Stat.class.getDeclaredFields()) { - if (null != f.getAnnotation(ApiModelProperty.class) && f.getAnnotation(ApiModelProperty.class).value().equals("")) { - categories.add(f.getAnnotation(ApiModelProperty.class).name()); - } - } - return categories; - } - - @Override - public List getPeriods() { - List tmp = new ArrayList(); - for (int i = 0; i < GenStatService.statList.size(); i++) { - Stat s = GenStatService.statList.get(i); - tmp.add(s.getD1()); - } - return tmp; - } - - @Override - public List getColumn(String c1) { - List tmp = new ArrayList(); - for (int i = 0; i < GenStatService.statList.size(); i++) { - Stat s = GenStatService.statList.get(i); - if ("1".equalsIgnoreCase(c1)) tmp.add(s.getC1()); - else if ("2".equalsIgnoreCase(c1)) tmp.add(s.getC2()); - else if ("3".equalsIgnoreCase(c1)) tmp.add(s.getC3()); - else if ("4".equalsIgnoreCase(c1)) tmp.add(s.getC4()); - } - return tmp; - } - - @Override - public List> getColumns() { - List> tmp = new ArrayList(); - List t1 = new ArrayList(); - List t2 = new ArrayList(); - List t3 = new ArrayList(); - List t4 = new ArrayList(); - for (int i = 0; i < GenStatService.statList.size(); i++) { - Stat s = GenStatService.statList.get(i); - t1.add(s.getC1()); - t2.add(s.getC2()); - t3.add(s.getC3()); - t4.add(s.getC4()); - } - tmp.add(t1); - tmp.add(t2); - tmp.add(t3); - tmp.add(t4); - return tmp; - } - - @Override - public double[] getRow(String date) { - double[] d = new double[4]; - for (int i = 0; i < GenStatService.statList.size(); i++) { - Stat tmp = GenStatService.statList.get(i); - if (date.equalsIgnoreCase(tmp.getD1())) { - d[0] = tmp.getC1(); - d[1] = tmp.getC2(); - d[2] = tmp.getC3(); - d[3] = tmp.getC4(); - return d; - } - } - return null; - } - - @Override - public List getBoxRes(DimQuery query) { - List resList = new ArrayList<>(); - for (String funcName : query.getFuncNameList()) { - DimQuery q = new DimQuery(); - q.setFuncName(funcName); - q.setWarehouse(query.getWarehouse()); - q.setDateCycle(query.getDateCycle()); - q.setStatDate(query.getStatDate()); - q.setDateStart(query.getDateStart()); - q.setDateEnd(query.getDateEnd()); - GenericRes res = statRepository.getOneRes(q); - if (res == null) continue; - resList.add(res); - } - return resList; - } - - @Override - public List getChartRes(DimQuery query) { - List resList = new ArrayList<>(); - for (String funcName : query.getFuncNameList()) { - DimQuery q = new DimQuery(); - q.setFuncName(funcName); - q.setWarehouse(query.getWarehouse()); - q.setDateCycle(query.getDateCycle()); - q.setStatDate(query.getStatDate()); - q.setDateStart(query.getDateStart()); - q.setDateEnd(query.getDateEnd()); - GenericRes resInfo = statRepository.getOneRes(q); - if (resInfo == null) continue; - List resDetail = statRepository.getResList(q); - List p = new ArrayList<>(); - List v1 = new ArrayList<>(); - for (GenericRes r : resDetail) { - p.add(r.getStatDate()); - v1.add(r.getFuncValue()); - } - resInfo.setP(p); - resInfo.setV1(v1); - resList.add(resInfo); - } - return resList; - } -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ValueServiceImpl.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ValueServiceImpl.java index 87e1372..37f457f 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ValueServiceImpl.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/implement/ValueServiceImpl.java @@ -1,7 +1,6 @@ package com.jd.logistics.cloud.data.implement; import com.jd.logistics.cloud.data.commons.Helper; -import com.jd.logistics.cloud.data.commons.ShowType; import com.jd.logistics.cloud.data.service.ValueService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -22,21 +21,8 @@ public class ValueServiceImpl implements ValueService { JdbcTemplate jdbcTemplate; @Override - public Map getFuncValues(String funcId) { - Map sqlList = Helper.getFuncSqlByType(funcId, ShowType.VALUE); - Map res = new HashMap<>(); - for (Map.Entry e : sqlList.entrySet()) { - String sql = e.getValue(); - SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql); - res.put(e.getKey(), Helper.RowSet2SingleRes(rowSet)); - } - return res; - } - - @Override - public Map getFuncValuesByDateCycle(String funcId, String dateCycle, Map params) { - Map sqlList = Helper.getFuncSqlByType(funcId, ShowType.VALUE); - String sql = sqlList.get(dateCycle); + public Map getMetricValue(String metricId, String dateCycle, Map params) { + String sql = Helper.getMetricValueSql(metricId, dateCycle); for (Map.Entry p : params.entrySet()) { sql = sql.replace(String.format("#{{%s}}", p.getKey()), p.getValue()); } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/FuncRepository.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/FuncRepository.java deleted file mode 100644 index 474eaed..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/FuncRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.jd.logistics.cloud.data.repository; - -import com.jd.logistics.cloud.data.domain.Function; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; - -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/30 9:22 - */ -@Mapper -public interface FuncRepository { - - @Select("SELECT concat('sample',id) as id, func_name as funcName, func_type_id as funcType, seq FROM T_FUNCTION where func_type_id=#{type} order by seq") - List getByType(@Param("type") int type); - - @Select("SELECT concat('sample',id) as id, func_name as funcName, func_type_id as funcType, seq FROM T_FUNCTION order by seq") - List getAll(); - - @Update("UPDATE T_FUNCTION SET func_type_id=#{func.funcType}, seq=#{func.seq} WHERE func_name=#{func.funcName}") - void update(@Param("func") Function func); - - @Select("SELECT func_name as funcName FROM T_FUNCTION where concat('sample',id)=#{funcId}") - String getFuncNameById(@Param("funcId") String funcId); -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/MetricRepository.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/MetricRepository.java new file mode 100644 index 0000000..eabee69 --- /dev/null +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/MetricRepository.java @@ -0,0 +1,30 @@ +package com.jd.logistics.cloud.data.repository; + +import com.jd.logistics.cloud.data.domain.Metric; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + * @Author hubin + * @Description: + * @Date 2017/10/30 9:22 + */ +@Mapper +public interface MetricRepository { + + @Select("SELECT concat('sample',id) as id, func_name as metricName, func_type_id as metricType, seq FROM T_FUNCTION where func_type_id=#{type} order by seq") + List getByType(@Param("type") int type); + + @Select("SELECT concat('sample',id) as id, func_name as metricName, func_type_id as metricType, seq FROM T_FUNCTION order by seq") + List getAll(); + + @Update("UPDATE T_FUNCTION SET func_type_id=#{func.metricType}, seq=#{func.seq} WHERE func_name=#{func.metricName}") + void update(@Param("metric") Metric metric); + + @Select("SELECT func_name as metricName FROM T_FUNCTION where concat('sample',id)=#{metricId}") + String getMetricNameById(@Param("metricId") String metricId); +} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/StatRepository.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/StatRepository.java deleted file mode 100644 index 82ef0d9..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/StatRepository.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.jd.logistics.cloud.data.repository; - -import com.jd.logistics.cloud.data.domain.DimQuery; -import com.jd.logistics.cloud.data.domain.GenericRes; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/31 17:41 - */ -@Mapper -public interface StatRepository { - @Select("" - ) - GenericRes getOneRes(@Param("query") DimQuery query); // one row result (warehouse, funcName, statDate) - - @Select("" - ) - List getResList(@Param("query") DimQuery query); // mutiple row results (warehouse, funcName, statDate) -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/UserRepository.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/UserRepository.java index c848e4a..ba82395 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/UserRepository.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/repository/UserRepository.java @@ -1,11 +1,9 @@ package com.jd.logistics.cloud.data.repository; -import com.jd.logistics.cloud.data.domain.DimQuery; -import com.jd.logistics.cloud.data.domain.GenericRes; import com.jd.logistics.cloud.data.domain.User; -import org.apache.ibatis.annotations.*; - -import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; /** * @Author hubin diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ChartService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ChartService.java index df9ba3a..31461de 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ChartService.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ChartService.java @@ -8,9 +8,7 @@ * @Date 2017/11/7 9:22 */ public interface ChartService { - Map getFuncCharts(String funcId); + Map getMetricChart(String metricId, String dateCycle, Map params); - Map getFuncChartByDateCycle(String funcId, String dateCycle, Map params); - - String getFuncChartOptionByDateCycle(String funcId, String dateCycle); + String getMetricChartOption(String metricId, String dateCycle); } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DefService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DefService.java new file mode 100644 index 0000000..7f1020e --- /dev/null +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/DefService.java @@ -0,0 +1,12 @@ +package com.jd.logistics.cloud.data.service; + +import java.util.Map; + +/** + * @Author hubin + * @Description: + * @Date 2017/11/13 15:21 + */ +public interface DefService { + Map getMetricDef(String metricId); +} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncService.java deleted file mode 100644 index 54a3873..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/FuncService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.jd.logistics.cloud.data.service; - -import com.jd.logistics.cloud.data.domain.Function; - -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/31 10:17 - */ -public interface FuncService { - List getFuncByType(int type); - - List getAllFunc(); - - void updateFuncType(Function func); - - String getFuncNameById(String funcId); -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/MetricService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/MetricService.java new file mode 100644 index 0000000..5f1a5da --- /dev/null +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/MetricService.java @@ -0,0 +1,20 @@ +package com.jd.logistics.cloud.data.service; + +import com.jd.logistics.cloud.data.domain.Metric; + +import java.util.List; + +/** + * @Author hubin + * @Description: + * @Date 2017/10/31 10:17 + */ +public interface MetricService { + List getMetricsByType(int type); + + List getAllMetrics(); + + void updateMetric(Metric metric); + + String getMetricNameById(String metricId); +} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ModelService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ModelService.java index f92bb48..b7ad2cc 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ModelService.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ModelService.java @@ -8,6 +8,5 @@ * @Date 2017/11/7 9:35 */ public interface ModelService { - Map getFuncModel(String funcId); - Map getFuncDesc(String funcId); + Map getModel(String metricId, String metricName); } diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/StatService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/StatService.java deleted file mode 100644 index 7deea3c..0000000 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/StatService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jd.logistics.cloud.data.service; - -import com.jd.logistics.cloud.data.commons.page.Page; -import com.jd.logistics.cloud.data.commons.page.PageRequest; -import com.jd.logistics.cloud.data.domain.*; - -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/23 14:46 - */ -public interface StatService { - Page findStats(StatQuery query, PageRequest pageRequest); - - List getCols(); - - List getCategories(); - - double[] getRow(String date); - - List getPeriods(); - - List getColumn(String c1); - - List> getColumns(); - - List getBoxRes(DimQuery query); - - List getChartRes(DimQuery query); -} diff --git a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ValueService.java b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ValueService.java index 55f3310..b261016 100644 --- a/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ValueService.java +++ b/dashboard-domain-service/src/main/java/com/jd/logistics/cloud/data/service/ValueService.java @@ -8,7 +8,5 @@ * @Date 2017/11/7 9:22 */ public interface ValueService { - Map getFuncValues(String funcId); - - Map getFuncValuesByDateCycle (String funcId, String dateCycle, Map params); + Map getMetricValue(String metricId, String dateCycle, Map params); } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ChartApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ChartApi.java index 4d33d6a..bb05a51 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ChartApi.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ChartApi.java @@ -1,12 +1,9 @@ package com.jd.logistics.cloud.data.web.api; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; import java.util.Map; /** @@ -16,22 +13,17 @@ */ @RequestMapping(value = "/api") public interface ChartApi { - @RequestMapping(value = "/chart/{funcId}", + @RequestMapping(value = "/chart", produces = {"application/json"}, method = RequestMethod.GET) - Map getFuncCharts(@PathVariable("funcId") String funcId); + Map getMetricChart(@RequestParam("metric") String metricId, + @RequestParam("cycle") String dateCycle, + @RequestParam("warehouse") String warehouse, + @RequestParam("sysdate") String sysdate); - @RequestMapping(value = "/chart/{funcId}/{dateCycle}", + @RequestMapping(value = "/chartOption", produces = {"application/json"}, method = RequestMethod.GET) - Map getFuncChartByDateCycle(@PathVariable("funcId") String funcId, - @PathVariable(value="dateCycle")String dateCycle, - @RequestParam(value="warehouse")String warehouse, - @RequestParam(value="sysdate")String sysdate, - HttpServletRequest request); - - @RequestMapping(value = "/chartOption/{funcId}/{dateCycle}", - produces = {"application/json"}, - method = RequestMethod.GET) - String getFuncChartOptionByDateCycle(@PathVariable("funcId") String funcId, @PathVariable("dateCycle") String dateCycle); + String getMetricChartOption(@RequestParam("metric") String metricId, + @RequestParam("cycle") String dateCycle); } \ No newline at end of file diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DefinitionApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DefinitionApi.java new file mode 100644 index 0000000..8183bd6 --- /dev/null +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/DefinitionApi.java @@ -0,0 +1,26 @@ +package com.jd.logistics.cloud.data.web.api; + +import org.springframework.web.bind.annotation.PathVariable; +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/13 12:42 + */ +@RequestMapping(value = "/api") +public interface DefinitionApi { + @RequestMapping(value = "/def/{metricId}", + produces = {"application/json"}, + method = RequestMethod.GET) + Map getMetricDef(@PathVariable("metricId") String metricId); + + @RequestMapping(value = "/def", + produces = {"application/json"}, + method = RequestMethod.GET) + List getDef(); +} diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/FuncApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/MetricApi.java similarity index 73% rename from dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/FuncApi.java rename to dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/MetricApi.java index a092a96..fb9a551 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/FuncApi.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/MetricApi.java @@ -1,6 +1,6 @@ package com.jd.logistics.cloud.data.web.api; -import com.jd.logistics.cloud.data.domain.Function; +import com.jd.logistics.cloud.data.domain.Metric; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -15,21 +15,21 @@ * @Description: * @Date 2017/10/31 10:14 */ -@RequestMapping(value = "/api/func") -public interface FuncApi { +@RequestMapping(value = "/api/metric") +public interface MetricApi { @RequestMapping(value = "/{type}", produces = {"application/json"}, method = RequestMethod.GET) - List getFuncByType(@PathVariable("type") int type); + List getMetricsByType(@PathVariable("type") int type); @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) - List getFunc(); + List getAllMetrics(); @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.PUT) - ResponseEntity updateFuncType(@Valid @RequestBody List functionList); + ResponseEntity updateMetric(@Valid @RequestBody List functionList); } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ModelApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ModelApi.java index cec8610..c3a705b 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ModelApi.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ModelApi.java @@ -1,6 +1,5 @@ package com.jd.logistics.cloud.data.web.api; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -14,18 +13,8 @@ */ @RequestMapping(value = "/api") public interface ModelApi { - @RequestMapping(value = "/model/{funcId}", - produces = {"application/json"}, - method = RequestMethod.GET) - Map getFuncModel(@PathVariable("funcId") String funcId); - @RequestMapping(value = "/models", produces = {"application/json"}, method = RequestMethod.GET) List getModels(); - - @RequestMapping(value = "/desc", - produces = {"application/json"}, - method = RequestMethod.GET) - List getDesc(); } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/StatApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/StatApi.java deleted file mode 100644 index 435c9bd..0000000 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/StatApi.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.jd.logistics.cloud.data.web.api; - -import com.jd.logistics.cloud.data.commons.page.Page; -import com.jd.logistics.cloud.data.commons.page.PageRequest; -import com.jd.logistics.cloud.data.domain.*; -import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/12 9:55 - */ -@Api(value = "order stats", description = "the order API") -@RequestMapping(value = "/api/stat") -public interface StatApi { - @RequestMapping(value = "", - produces = {"application/json"}, - method = RequestMethod.GET) - Page list(@ModelAttribute StatQuery query, @ModelAttribute PageRequest pageRequest); - - @RequestMapping(value = "/cols", - produces = {"application/json"}, - method = RequestMethod.GET) - List cols(); - - @RequestMapping(value = "/categories", - produces = {"application/json"}, - method = RequestMethod.GET) - List categories(); - - @RequestMapping(value = "/date/{date}", - produces = {"application/json"}, - method = RequestMethod.GET) - double[] row(@PathVariable("date") String date); - - @RequestMapping(value = "/periods", - produces = {"application/json"}, - method = RequestMethod.GET) - List periods(); - - @RequestMapping(value = "/c/{c}", - produces = {"application/json"}, - method = RequestMethod.GET) - List c(@PathVariable("c") String c); - - @RequestMapping(value = "/c", - produces = {"application/json"}, - method = RequestMethod.GET) - List> cAll(); - - @RequestMapping(value = "/res/box", - produces = {"application/json"}, - method = RequestMethod.POST) - List getBoxRes(@Valid @RequestBody DimQuery query); - - @RequestMapping(value = "/res/chart", - produces = {"application/json"}, - method = RequestMethod.POST) - List getChartRes(@Valid @RequestBody DimQuery query); - -} diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ValueApi.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ValueApi.java index 611b0ff..6e4d9cc 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ValueApi.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/api/ValueApi.java @@ -1,11 +1,9 @@ package com.jd.logistics.cloud.data.web.api; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import javax.servlet.http.HttpServletRequest; import java.util.Map; /** @@ -15,17 +13,11 @@ */ @RequestMapping(value = "/api/value") public interface ValueApi { - @RequestMapping(value = "/{funcId}", + @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) - Map getFuncValues(@PathVariable("funcId") String funcId); - - @RequestMapping(value = "/{funcId}/{dateCycle}", - produces = {"application/json"}, - method = RequestMethod.GET) - Map getFuncValuesByDateCycle(@PathVariable("funcId") String funcId, - @PathVariable(value="dateCycle")String dateCycle, - @RequestParam(value="warehouse")String warehouse, - @RequestParam(value="sysdate")String sysdate, - HttpServletRequest request); + Map getFuncValue(@RequestParam("metric") String metricId, + @RequestParam("cycle") String dateCycle, + @RequestParam(value = "warehouse") String warehouse, + @RequestParam(value = "sysdate") String sysdate); } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ChartRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ChartRestController.java index 97dcb86..d9dbec9 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ChartRestController.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ChartRestController.java @@ -3,11 +3,9 @@ import com.jd.logistics.cloud.data.service.ChartService; import com.jd.logistics.cloud.data.web.api.ChartApi; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; @@ -22,24 +20,19 @@ public class ChartRestController implements ChartApi { ChartService chartService; @Override - public Map getFuncCharts(@PathVariable("funcId") String funcId) { - return chartService.getFuncCharts(funcId); - } - - @Override - public Map getFuncChartByDateCycle(@PathVariable("funcId") String funcId, - @PathVariable(value="dateCycle")String dateCycle, - @RequestParam(value="warehouse")String warehouse, - @RequestParam(value="sysdate")String sysdate, - HttpServletRequest request) { + public Map getMetricChart(@RequestParam("metric") String metricId, + @RequestParam("cycle") String dateCycle, + @RequestParam("warehouse") String warehouse, + @RequestParam("sysdate") String sysdate) { Map map = new HashMap<>(); - map.put("warehouse", request.getParameter("warehouse")); - map.put("sysdate", request.getParameter("sysdate")); - return chartService.getFuncChartByDateCycle(funcId, dateCycle, map); + map.put("warehouse", warehouse); + map.put("sysdate", sysdate); + return chartService.getMetricChart(metricId, dateCycle, map); } @Override - public String getFuncChartOptionByDateCycle(@PathVariable("funcId")String funcId, @PathVariable("dateCycle")String dateCycle) { - return chartService.getFuncChartOptionByDateCycle(funcId, dateCycle); + public String getMetricChartOption(@RequestParam("metric") String metricId, + @RequestParam("cycle") String dateCycle) { + return chartService.getMetricChartOption(metricId, dateCycle); } } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/DefinitionRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/DefinitionRestController.java new file mode 100644 index 0000000..6d72720 --- /dev/null +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/DefinitionRestController.java @@ -0,0 +1,40 @@ +package com.jd.logistics.cloud.data.web.controller; + +import com.jd.logistics.cloud.data.domain.Metric; +import com.jd.logistics.cloud.data.service.DefService; +import com.jd.logistics.cloud.data.service.MetricService; +import com.jd.logistics.cloud.data.web.api.DefinitionApi; +import org.springframework.beans.factory.annotation.Autowired; +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; + +/** + * @Author hubin + * @Description: + * @Date 2017/11/13 12:45 + */ +@RestController +public class DefinitionRestController implements DefinitionApi { + @Autowired + DefService defService; + @Autowired + MetricService metricService; + + @Override + public Map getMetricDef(@PathVariable("metricId") String metricId) { + return defService.getMetricDef(metricId); + } + + @Override + public List getDef() { + List res = new ArrayList<>(); + for (Metric metric : metricService.getAllMetrics()) { + res.add(defService.getMetricDef(metric.getId())); + } + return res; + } +} diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/FuncRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/MetricRestController.java similarity index 50% rename from dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/FuncRestController.java rename to dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/MetricRestController.java index 61910e6..799c020 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/FuncRestController.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/MetricRestController.java @@ -1,8 +1,8 @@ package com.jd.logistics.cloud.data.web.controller; -import com.jd.logistics.cloud.data.domain.Function; -import com.jd.logistics.cloud.data.service.FuncService; -import com.jd.logistics.cloud.data.web.api.FuncApi; +import com.jd.logistics.cloud.data.domain.Metric; +import com.jd.logistics.cloud.data.service.MetricService; +import com.jd.logistics.cloud.data.web.api.MetricApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -19,24 +19,24 @@ * @Date 2017/10/31 10:16 */ @RestController -public class FuncRestController implements FuncApi { +public class MetricRestController implements MetricApi { @Autowired - FuncService funcService; + MetricService metricService; @Override - public List getFuncByType(@PathVariable("type") int type) { - return funcService.getFuncByType(type); + public List getMetricsByType(@PathVariable("type") int type) { + return metricService.getMetricsByType(type); } @Override - public List getFunc() { - return funcService.getAllFunc(); + public List getAllMetrics() { + return metricService.getAllMetrics(); } @Override - public ResponseEntity updateFuncType(@Valid @RequestBody List functionList) { - for (Function function : functionList) { - funcService.updateFuncType(function); + public ResponseEntity updateMetric(@Valid @RequestBody List functionList) { + for (Metric function : functionList) { + metricService.updateMetric(function); } return new ResponseEntity<>(HttpStatus.OK); } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ModelRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ModelRestController.java index a0a2f83..600cbd2 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ModelRestController.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ModelRestController.java @@ -1,11 +1,10 @@ package com.jd.logistics.cloud.data.web.controller; -import com.jd.logistics.cloud.data.domain.Function; -import com.jd.logistics.cloud.data.service.FuncService; +import com.jd.logistics.cloud.data.domain.Metric; +import com.jd.logistics.cloud.data.service.MetricService; import com.jd.logistics.cloud.data.service.ModelService; import com.jd.logistics.cloud.data.web.api.ModelApi; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; @@ -22,26 +21,13 @@ public class ModelRestController implements ModelApi { @Autowired ModelService modelService; @Autowired - FuncService funcService; - @Override - public Map getFuncModel(@PathVariable("funcId") String funcId) { - return modelService.getFuncModel(funcId); - } + MetricService metricService; @Override public List getModels() { List res = new ArrayList<>(); - for(Function function: funcService.getAllFunc()){ - res.add(modelService.getFuncModel(function.getId())); - } - return res; - } - - @Override - public List getDesc() { - List res = new ArrayList<>(); - for(Function function: funcService.getAllFunc()){ - res.add(modelService.getFuncDesc(function.getId())); + for (Metric metric : metricService.getAllMetrics()) { + res.add(modelService.getModel(metric.getId(), metric.getMetricName())); } return res; } diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/StatRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/StatRestController.java deleted file mode 100644 index 4a16b9a..0000000 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/StatRestController.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.jd.logistics.cloud.data.web.controller; - -import com.jd.logistics.cloud.data.commons.page.Page; -import com.jd.logistics.cloud.data.commons.page.PageRequest; -import com.jd.logistics.cloud.data.domain.*; -import com.jd.logistics.cloud.data.service.StatService; -import com.jd.logistics.cloud.data.web.api.StatApi; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @Author hubin - * @Description: - * @Date 2017/10/23 15:08 - */ -@RestController -public class StatRestController implements StatApi { - @Autowired - StatService statService; - - @Override - public Page list(@ModelAttribute StatQuery query, @ModelAttribute PageRequest pageRequest) { - return statService.findStats(query, pageRequest); - } - - @Override - public List cols() { - return statService.getCols(); - } - - @Override - public List categories() { - return statService.getCategories(); - } - - @Override - public double[] row(@PathVariable("date") String date) { - return statService.getRow(date); - } - - @Override - public List periods() { - return statService.getPeriods(); - } - - @Override - public List c(@PathVariable("c") String c) { - return statService.getColumn(c); - } - - @Override - public List> cAll() { - return statService.getColumns(); - } - - @Override - public List getBoxRes(@RequestBody DimQuery query) { - return statService.getBoxRes(query); - } - - @Override - public List getChartRes(@RequestBody DimQuery query) { - return statService.getChartRes(query); - } -} diff --git a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ValueRestController.java b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ValueRestController.java index 5d48b73..b866427 100644 --- a/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ValueRestController.java +++ b/dashboard-web/src/main/java/com/jd/logistics/cloud/data/web/controller/ValueRestController.java @@ -3,11 +3,9 @@ import com.jd.logistics.cloud.data.service.ValueService; import com.jd.logistics.cloud.data.web.api.ValueApi; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; @@ -22,19 +20,13 @@ public class ValueRestController implements ValueApi { ValueService valueService; @Override - public Map getFuncValues(@PathVariable("funcId") String funcId) { - return valueService.getFuncValues(funcId); - } - - @Override - public Map getFuncValuesByDateCycle(@PathVariable("funcId") String funcId, - @PathVariable(value="dateCycle")String dateCycle, - @RequestParam(value="warehouse")String warehouse, - @RequestParam(value="sysdate")String sysdate, - HttpServletRequest request) { + public Map getFuncValue(@RequestParam("metric") String metricId, + @RequestParam(value = "cycle") String dateCycle, + @RequestParam(value = "warehouse") String warehouse, + @RequestParam(value = "sysdate") String sysdate) { Map map = new HashMap<>(); - map.put("warehouse", request.getParameter("warehouse")); - map.put("sysdate", request.getParameter("sysdate")); - return valueService.getFuncValuesByDateCycle(funcId, dateCycle, map); + map.put("warehouse", warehouse); + map.put("sysdate", sysdate); + return valueService.getMetricValue(metricId, dateCycle, map); } } diff --git a/dashboard-web/src/main/resources/dev.properties b/dashboard-web/src/main/resources/dev.properties index e0ac7ed..bcc577d 100644 --- a/dashboard-web/src/main/resources/dev.properties +++ b/dashboard-web/src/main/resources/dev.properties @@ -4,7 +4,8 @@ spring.devtools.remote.restart.enabled=false #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 \ No newline at end of file +spring.datasource.url=jdbc:mysql://192.168.99.100:3306/dev?\ + characterEncoding=utf8&useSSL=false&autoReconnect=true&maxReconnects=2&initialTimeout=5 +spring.datasource.username=root +spring.datasource.password=root +spring.datasource.driver-class-name=com.mysql.jdbc.Driver \ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample1/day.option b/dashboard-web/src/main/resources/metrics/sample1/day.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample1/day.option rename to dashboard-web/src/main/resources/metrics/sample1/day.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample1/model.json b/dashboard-web/src/main/resources/metrics/sample1/model.json index aca945e..70a2825 100644 --- a/dashboard-web/src/main/resources/metrics/sample1/model.json +++ b/dashboard-web/src/main/resources/metrics/sample1/model.json @@ -15,7 +15,7 @@ ], "id": "sample1", "name": "在库SKU数", - "descriptions": [ + "def": [ { "name": "day", "text": "just a test 日维度1" diff --git a/dashboard-web/src/main/resources/metrics/sample1/month.option b/dashboard-web/src/main/resources/metrics/sample1/month.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample1/month.option rename to dashboard-web/src/main/resources/metrics/sample1/month.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample1/number.html b/dashboard-web/src/main/resources/metrics/sample1/number.html deleted file mode 100644 index 2e8242b..0000000 --- a/dashboard-web/src/main/resources/metrics/sample1/number.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - \ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample1/week.option b/dashboard-web/src/main/resources/metrics/sample1/week.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample1/week.option rename to dashboard-web/src/main/resources/metrics/sample1/week.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample2/chart.html b/dashboard-web/src/main/resources/metrics/sample2/chart.html deleted file mode 100644 index 0128f4c..0000000 --- a/dashboard-web/src/main/resources/metrics/sample2/chart.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - - {{sysDateBefore}} - - - - - more_horiz - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - - {{sysDate}} - - - - - - - -
-
-
-
-
\ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample2/day.option b/dashboard-web/src/main/resources/metrics/sample2/day.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample2/day.option rename to dashboard-web/src/main/resources/metrics/sample2/day.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample2/model.json b/dashboard-web/src/main/resources/metrics/sample2/model.json index bea99b5..37f66dc 100644 --- a/dashboard-web/src/main/resources/metrics/sample2/model.json +++ b/dashboard-web/src/main/resources/metrics/sample2/model.json @@ -15,7 +15,7 @@ ], "id": "sample2", "name": "接收订单量", - "descriptions": [ + "def": [ { "name": "day", "text": "just a test 日维度2" diff --git a/dashboard-web/src/main/resources/metrics/sample2/month.option b/dashboard-web/src/main/resources/metrics/sample2/month.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample2/month.option rename to dashboard-web/src/main/resources/metrics/sample2/month.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample2/number.html b/dashboard-web/src/main/resources/metrics/sample2/number.html deleted file mode 100644 index dedde21..0000000 --- a/dashboard-web/src/main/resources/metrics/sample2/number.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - \ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample2/week.option b/dashboard-web/src/main/resources/metrics/sample2/week.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample2/week.option rename to dashboard-web/src/main/resources/metrics/sample2/week.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample3/chart.html b/dashboard-web/src/main/resources/metrics/sample3/chart.html deleted file mode 100644 index 13f5aff..0000000 --- a/dashboard-web/src/main/resources/metrics/sample3/chart.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - - {{sysDateBefore}} - - - - - more_horiz - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - - {{sysDate}} - - - - - - - -
-
-
-
-
\ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample3/day.option b/dashboard-web/src/main/resources/metrics/sample3/day.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample3/day.option rename to dashboard-web/src/main/resources/metrics/sample3/day.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample3/model.json b/dashboard-web/src/main/resources/metrics/sample3/model.json index 7f88cff..7db8ff5 100644 --- a/dashboard-web/src/main/resources/metrics/sample3/model.json +++ b/dashboard-web/src/main/resources/metrics/sample3/model.json @@ -15,7 +15,7 @@ ], "id": "sample3", "name": "成本效率", - "descriptions": [ + "def": [ { "name": "day", "text": "just a test 日维度3" diff --git a/dashboard-web/src/main/resources/metrics/sample3/month.option b/dashboard-web/src/main/resources/metrics/sample3/month.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample3/month.option rename to dashboard-web/src/main/resources/metrics/sample3/month.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample3/week.option b/dashboard-web/src/main/resources/metrics/sample3/week.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample3/week.option rename to dashboard-web/src/main/resources/metrics/sample3/week.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample4/chart.html b/dashboard-web/src/main/resources/metrics/sample4/chart.html deleted file mode 100644 index f21bedb..0000000 --- a/dashboard-web/src/main/resources/metrics/sample4/chart.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - - {{sysDateBefore}} - - - - - more_horiz - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - - {{sysDate}} - - - - - - - -
-
-
-
-
\ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample4/day.option b/dashboard-web/src/main/resources/metrics/sample4/day.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample4/day.option rename to dashboard-web/src/main/resources/metrics/sample4/day.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample4/model.json b/dashboard-web/src/main/resources/metrics/sample4/model.json index c8d228e..7eaf2a9 100644 --- a/dashboard-web/src/main/resources/metrics/sample4/model.json +++ b/dashboard-web/src/main/resources/metrics/sample4/model.json @@ -15,7 +15,7 @@ ], "id": "sample4", "name": "发出订单量", - "descriptions": [ + "def": [ { "name": "day", "text": "just a test 日维度4" diff --git a/dashboard-web/src/main/resources/metrics/sample4/month.option b/dashboard-web/src/main/resources/metrics/sample4/month.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample4/month.option rename to dashboard-web/src/main/resources/metrics/sample4/month.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample4/number.html b/dashboard-web/src/main/resources/metrics/sample4/number.html deleted file mode 100644 index 777230e..0000000 --- a/dashboard-web/src/main/resources/metrics/sample4/number.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - {{data.value.f1}} - - - {{data.value.f2}} - {{data.value.v2}}% - - - - - - - - - - {{data.value.v1}} - - - - - - {{data.value.f3}} - {{data.value.v3}}% - - - - - - - - - - \ No newline at end of file diff --git a/dashboard-web/src/main/resources/metrics/sample4/week.option b/dashboard-web/src/main/resources/metrics/sample4/week.chartOption similarity index 100% rename from dashboard-web/src/main/resources/metrics/sample4/week.option rename to dashboard-web/src/main/resources/metrics/sample4/week.chartOption diff --git a/dashboard-web/src/main/resources/metrics/sample1/chart.html b/dashboard-web/src/main/resources/templates/chart.html similarity index 92% rename from dashboard-web/src/main/resources/metrics/sample1/chart.html rename to dashboard-web/src/main/resources/templates/chart.html index f2555b7..87a9c04 100644 --- a/dashboard-web/src/main/resources/metrics/sample1/chart.html +++ b/dashboard-web/src/main/resources/templates/chart.html @@ -1,7 +1,7 @@ - {{data.value.f1}} + {{data.value.f1}} {{data.value.f2}} @@ -20,13 +20,13 @@ - + more_horiz - {{data.value.v1}} + {{data.value.v1}} diff --git a/dashboard-web/src/main/resources/metrics/sample3/number.html b/dashboard-web/src/main/resources/templates/number.html similarity index 96% rename from dashboard-web/src/main/resources/metrics/sample3/number.html rename to dashboard-web/src/main/resources/templates/number.html index 8c4bb4b..892d840 100644 --- a/dashboard-web/src/main/resources/metrics/sample3/number.html +++ b/dashboard-web/src/main/resources/templates/number.html @@ -1,6 +1,6 @@ - + {{data.value.f1}} diff --git a/dashboard-web/src/main/webapp/index.html b/dashboard-web/src/main/webapp/index.html index 97c0d1c..66eab19 100644 --- a/dashboard-web/src/main/webapp/index.html +++ b/dashboard-web/src/main/webapp/index.html @@ -59,6 +59,7 @@ // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); + @@ -121,6 +122,7 @@ } }; + \ No newline at end of file diff --git a/dashboard-web/src/main/webapp/index_2.html b/dashboard-web/src/main/webapp/index_2.html index f8f787e..36911a7 100644 --- a/dashboard-web/src/main/webapp/index_2.html +++ b/dashboard-web/src/main/webapp/index_2.html @@ -31,6 +31,7 @@ } + @@ -338,6 +339,7 @@ }; + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f40a225..994c61e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,51 +1,51 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.jd.logistics.cloud.data - dashboard-parent - pom - 1.0-SNAPSHOT - - dashboard-commons - dashboard-domain-service - dashboard-web - - + com.jd.logistics.cloud.data + dashboard-parent + pom + 1.0-SNAPSHOT + + dashboard-commons + dashboard-domain-service + dashboard-web + + - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-banned-dependencies - - enforce - - - - - - log4j:log4j - org.slf4j:slf4j-log4j12 - commons-logging:commons-logging - - - - true - - - - - - + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-banned-dependencies + + enforce + + + + + + log4j:log4j + org.slf4j:slf4j-log4j12 + commons-logging:commons-logging + + + + true + + + + + +