Просмотр исходного кода

先加个历史趋势的模拟数据接口

wukai 9 месяцев назад
Родитель
Сommit
385b97e0ca

+ 10 - 0
jjt-admin/src/test/java/com/test/Test.java

@@ -1,5 +1,9 @@
 package com.test;
 
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.Random;
+
 /**
  * Test$
  *
@@ -8,6 +12,12 @@ package com.test;
  */
 public class Test {
     public static void main(String[] args) {
+        Random r = new Random();
+        DecimalFormat df = new DecimalFormat("#0.00");
+        for (int i = 0; i < 10; i++) {
+            float f = r.nextFloat()*100;
+            System.err.println(df.format(f));
+        }
         String xx = "pp.jvm.gc";
         System.err.println(!xx.startsWith("pp.jvm."));
     }

+ 31 - 1
jjt-biz/src/main/java/com/jjt/biz/controller/BizObjMetricsController.java

@@ -15,7 +15,10 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
-import java.util.List;
+import java.text.DecimalFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.*;
 
 /**
  * 业务对象指标Controller
@@ -62,10 +65,37 @@ public class BizObjMetricsController extends BaseController {
     @PreAuthorize("@ss.hasPermi('obj:metrics:query')")
     @GetMapping(value = "/{objMetricsId}")
     public AjaxResult getInfo(@PathVariable("objMetricsId") Long objMetricsId) {
+        BizObjMetrics metrics = bizObjMetricsService.selectBizObjMetricsByObjMetricsId(objMetricsId);
         return success(bizObjMetricsService.selectBizObjMetricsByObjMetricsId(objMetricsId));
     }
 
     /**
+     * 获取业务对象指标详细信息
+     */
+    @ApiOperation("获取业务对象历史趋势")
+    @GetMapping(value = "/history/{objMetricsId}")
+    public AjaxResult history(@PathVariable("objMetricsId") Long objMetricsId) {
+        List<Long> times = new ArrayList<>();
+        List<Float> values = new ArrayList<>();
+        LocalDateTime ed = LocalDateTime.now();
+        LocalDateTime st = ed.minusDays(7);
+        Random r = new Random();
+        DecimalFormat df = new DecimalFormat("#0.00");
+        do {
+            long time = st.toEpochSecond(ZoneOffset.ofHours(8)) * 1000;
+            times.add(time);
+            float f = r.nextFloat() * 100;
+//                System.err.println(df.format(f));
+            values.add(Float.parseFloat(df.format(f)));
+            st = st.plusMinutes(15);
+        } while (!st.isAfter(ed));
+        Map<String, Object> map = new HashMap<>(16);
+        map.put("times", times);
+        map.put("values", values);
+        return AjaxResult.success(map);
+    }
+
+    /**
      * 新增业务对象指标
      */
     @ApiOperation("新增业务对象指标")