浏览代码

中台-可视化子页

limeng 2 年之前
父节点
当前提交
1b9169f206

+ 48 - 0
leiSP-admin/src/main/java/com/sooka/web/controller/system/NumberUtils.java

@@ -0,0 +1,48 @@
+package com.sooka.web.controller.system;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Administrator
+ */
+public class NumberUtils {
+
+    private static final String MILLION_UNIT = "w";
+    private static final String BILLION_UNIT = "e";
+    private static final BigDecimal ONE_HUNDRED_THOUSAND = new BigDecimal(100000);
+    private static final BigDecimal ONE_HUNDRED_MILLION = new BigDecimal(100000000);
+    private static final BigDecimal TEN_THOUSAND = new BigDecimal(10000);
+
+    /**
+     * 将数字转换成以万为单位或者以亿为单位,因为在前端数字太大显示有问题
+     * @param str
+     * @return
+     */
+    public static String amountConversion(int str){
+        BigDecimal amount = new BigDecimal(str);
+        if (amount == null) {
+            return null;
+        }
+        if (amount.abs().compareTo(ONE_HUNDRED_THOUSAND) < 0) {
+            //如果小于10万
+            return amount.stripTrailingZeros().toPlainString();
+        }
+        if (amount.abs().compareTo(ONE_HUNDRED_MILLION) < 0) {
+            //如果大于10万小于1亿
+            return amount.divide(TEN_THOUSAND, 0, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString() + MILLION_UNIT;
+        }
+        return amount.divide(ONE_HUNDRED_MILLION, 0, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString() + BILLION_UNIT;
+    }
+
+    /**
+     * 将数字转换成以亿为单位
+     * @param amount
+     * @return
+     */
+    public static Double amountConversionBillion(BigDecimal amount){
+        if (amount == null) {
+            return null;
+        }
+        return amount.divide(ONE_HUNDRED_MILLION, 2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().doubleValue();
+    }
+}

+ 30 - 1
leiSP-admin/src/main/java/com/sooka/web/controller/system/SysIndexController.java

@@ -1,6 +1,11 @@
 package com.sooka.web.controller.system;
 
 import java.util.List;
+
+import com.sooka.system.domain.SysDept;
+import com.sooka.system.domain.TUInterfaceinfo;
+import com.sooka.system.service.ISysDeptService;
+import com.sooka.system.service.ITUInterfaceinfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
@@ -15,7 +20,7 @@ import com.sooka.system.service.ISysMenuService;
 
 /**
  * 首页 业务处理
- * 
+ *
  * @author lei_wang
  */
 @Controller
@@ -27,6 +32,12 @@ public class SysIndexController extends BaseController
     @Autowired
     private ISysConfigService configService;
 
+    @Autowired
+    private ITUInterfaceinfoService interfaceinfoService;
+
+    @Autowired
+    private ISysDeptService sysDeptService;
+
     // 系统首页
     @GetMapping("/index")
     public String index(ModelMap mmap)
@@ -55,7 +66,25 @@ public class SysIndexController extends BaseController
     @GetMapping("/system/main")
     public String main(ModelMap mmap)
     {
+        //接口数量
+        List<TUInterfaceinfo> list_count = interfaceinfoService.getCount();
         mmap.put("version", Global.getVersion());
+        //接口数量
+        mmap.put("count", interfaceinfoService.getInterfaceCount("0"));
+        //故障接口数量
+        mmap.put("faultCount", interfaceinfoService.getInterfaceCount("1"));
+        //调用频次
+        mmap.put("callFrequency", NumberUtils.amountConversion(interfaceinfoService.callFrequency()));
+        //归集频次
+        mmap.put("pushFrequency", NumberUtils.amountConversion(interfaceinfoService.pushFrequency()));
+        //共享频次
+        mmap.put("pullFrequency", NumberUtils.amountConversion(interfaceinfoService.pullFrequency()));
+        //接入部门
+        SysDept dept = new SysDept();
+        dept.setParentId(214L);
+        List<SysDept> depts = sysDeptService.selectDeptList(dept);
+        mmap.put("depts", depts.size());
         return "main";
     }
+
 }

+ 6 - 11
leiSP-admin/src/main/resources/templates/main.html

@@ -95,7 +95,7 @@
                 <h5>接口总数</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_interface_total">39</span>
+                <span id="tj_interface_total">[[${count}]]</span>
             </div>
         </div>
         <div class="th-wid-6 ibox-th-colorbar2">
@@ -105,7 +105,7 @@
                 <h5>调用频次</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_dypc">39</span>
+                <span id="tj_dypc">[[${callFrequency}]]</span>
             </div>
         </div>
         <div class="th-wid-6 ibox-th-colorbar3">
@@ -115,7 +115,7 @@
                 <h5>归集频次</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_gjpc">39</span>
+                <span id="tj_gjpc">[[${pushFrequency}]]</span>
             </div>
         </div>
         <div class="th-wid-6 ibox-th-colorbar4">
@@ -125,7 +125,7 @@
                 <h5>共享频次</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_gxpc">39</span>
+                <span id="tj_gxpc">[[${pullFrequency}]]</span>
             </div>
         </div>
         <div class="th-wid-6 ibox-th-colorbar5">
@@ -135,7 +135,7 @@
                 <h5 >接入部门</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_jrbm">39</span>
+                <span id="tj_jrbm">[[${depts}]]</span>
             </div>
         </div>
         <div class="th-wid-6 ibox-th-colorbar6">
@@ -145,7 +145,7 @@
                 <h5>接口故障</h5>
             </div>
             <div class="col-sm-6 ibox-right-th">
-                <span id="tj_jkgz">39</span>
+                <span id="tj_jkgz">[[${faultCount}]]</span>
             </div>
         </div>
 
@@ -158,11 +158,6 @@
                 <div class="ibox-title">
                     <h5>日调用频次</h5>
                     <div class="pull-right">
-                        <!--<div class="btn-group">-->
-                            <!--<button type="button" class="btn btn-xs btn-white active">天</button>-->
-                            <!--<button type="button" class="btn btn-xs btn-white">月</button>-->
-                            <!--<button type="button" class="btn btn-xs btn-white">年</button>-->
-                        <!--</div>-->
                     </div>
                 </div>
                 <div class="ibox-content">

+ 2 - 3
mybusiness/src/main/java/com/business/controller/VisualizationController.java

@@ -19,6 +19,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.*;
 import sun.plugin2.util.SystemUtil;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -57,8 +58,6 @@ public class VisualizationController extends BaseController {
         /**查询接口数量**/
         TUInterfaceinfo shareCount = interfaceinfoService.getShareCountByDeptId(id.toString());
 
-        /**查询归集数据分析**/
-
         mmap.put("deptId",sysDept.getDeptId());
         mmap.put("deptName",sysDept.getDeptName());
         mmap.put("interfaceList",interfaceList);
@@ -208,7 +207,7 @@ public class VisualizationController extends BaseController {
     @PostMapping("getFaultInterfaceCount")
     @ResponseBody
     public Integer getFaultInterfaceCount(){
-        return interfaceinfoService.getFaultInterfaceCount();
+        return interfaceinfoService.getInterfaceCount("1");
     }
 
 }

+ 19 - 1
mybusiness/src/main/java/com/sooka/system/mapper/TUInterfaceinfoMapper.java

@@ -133,11 +133,29 @@ public interface TUInterfaceinfoMapper
      * 查询故障接口数量
      * @return 结果
      * */
-    public Integer getFaultInterfaceCount();
+    public Integer getInterfaceCount(@Param("status") String status);
 
     /**
      * 根据部门ID查询分类数量
      * @return 结果
      * */
     public TUInterfaceinfo getShareCountByDeptId(@Param("deptId") String deptId);
+
+    /**
+     * 接口调用频次
+     * @return 结果
+     * */
+    public int callFrequency();
+
+    /**
+     * 接口归集频次
+     * @return 结果
+     * */
+    public int pushFrequency();
+
+    /**
+     * 接口共享频次
+     * @return 结果
+     * */
+    public int pullFrequency();
 }

+ 19 - 1
mybusiness/src/main/java/com/sooka/system/service/ITUInterfaceinfoService.java

@@ -129,7 +129,7 @@ public interface ITUInterfaceinfoService
      * 查询故障接口数量
      * @return 结果
      * */
-    public Integer getFaultInterfaceCount();
+    public Integer getInterfaceCount(String status);
 
     /**
      * 根据部门ID查询分类数量
@@ -137,4 +137,22 @@ public interface ITUInterfaceinfoService
      * */
     public TUInterfaceinfo getShareCountByDeptId(String deptId);
 
+    /**
+     * 接口调用频次
+     * @return 结果
+     * */
+    public int callFrequency();
+
+    /**
+     * 接口归集频次
+     * @return 结果
+     * */
+    public int pushFrequency();
+
+    /**
+     * 接口共享频次
+     * @return 结果
+     * */
+    public int pullFrequency();
+
 }

+ 29 - 2
mybusiness/src/main/java/com/sooka/system/service/impl/TUInterfaceinfoServiceImpl.java

@@ -227,8 +227,8 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
      * @return 结果
      * */
     @Override
-    public Integer getFaultInterfaceCount(){
-        return tUInterfaceinfoMapper.getFaultInterfaceCount();
+    public Integer getInterfaceCount(String status){
+        return tUInterfaceinfoMapper.getInterfaceCount(status);
     }
 
     /**
@@ -239,4 +239,31 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
     public TUInterfaceinfo getShareCountByDeptId(String deptId){
         return tUInterfaceinfoMapper.getShareCountByDeptId(deptId);
     }
+
+    /**
+     * 接口调用频次
+     * @return 结果
+     * */
+    @Override
+    public int callFrequency(){
+        return tUInterfaceinfoMapper.callFrequency();
+    }
+
+    /**
+     * 接口归集频次
+     * @return 结果
+     * */
+    @Override
+    public int pushFrequency(){
+        return tUInterfaceinfoMapper.pushFrequency();
+    }
+
+    /**
+     * 接口共享频次
+     * @return 结果
+     * */
+    @Override
+    public int pullFrequency(){
+        return tUInterfaceinfoMapper.pullFrequency();
+    }
 }

+ 32 - 2
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -406,13 +406,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         10
     </select>
 
-    <select id="getFaultInterfaceCount" resultType="Integer">
+    <select id="getInterfaceCount" parameterType="String" resultType="Integer">
         SELECT
             count(id) count
         FROM
             t_u_interfaceinfo
         WHERE
-            status = 1
+            status = #{status}
     </select>
 
     <select id="getSubJkspfx" resultMap="TUInterfaceinfoResult">
@@ -470,4 +470,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         AND DATE_FORMAT(r.examine_time, '%Y') = #{year}
     </select>
 
+    <select id="callFrequency" resultType="Integer">
+        SELECT
+            SUM(callsuccnum) count
+        FROM
+            t_u_interfaceinfo
+    </select>
+
+    <select id="pushFrequency" resultType="Integer">
+        SELECT
+            SUM(callsuccnum) count
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            share_type IN (
+                'share_type_2',
+                'share_type_3'
+            )
+    </select>
+
+    <select id="pullFrequency" resultType="Integer">
+        SELECT
+            SUM(callsuccnum) count
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            share_type IN (
+                'share_type_1',
+                'share_type_4'
+            )
+    </select>
 </mapper>

+ 6 - 0
mybusiness/src/main/resources/templates/visualization/tk_iframe.html

@@ -530,6 +530,12 @@
 						_p.eq(num).addClass(_s);
 					}
 				}
+				var li_num = $('.jk_list li').length;
+				if( li_num >= 3){
+					$('#FontScroll').FontScroll({time: 2000,num: 1});
+				}else{
+					return
+				}
 			})(jQuery);
 			$('#FontScroll').FontScroll({time: 2000,num: 1});
 		</script>