瀏覽代碼

归集数据分析

wangzhe 2 年之前
父節點
當前提交
6c7fa12cee

+ 12 - 0
mybusiness/src/main/java/com/business/controller/VisualizationController.java

@@ -120,6 +120,18 @@ public class VisualizationController extends BaseController {
     }
 
     /**
+     * 更新归集数据分析
+     * */
+    @PostMapping("imputationData")
+    @ResponseBody
+    public JSONObject imputationData(){
+        JSONObject jsonObject = new JSONObject();
+        interfaceinfoService.imputationData();
+        jsonObject.put("data", "well done");
+        return jsonObject;
+    }
+
+    /**
      * 审批分析 - 可视化二级页(右下) 自动获取近三年数据
      * 目前显示接口应用审批、数据应用审批、证照应用审批。按照这三类进行查询。
      * */

+ 9 - 0
mybusiness/src/main/java/com/sooka/system/mapper/TUInterfaceinfoMapper.java

@@ -3,6 +3,7 @@ package com.sooka.system.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.business.domain.ImputationData;
 import com.sooka.system.domain.TUInterfaceinfo;
 import org.apache.ibatis.annotations.Param;
 
@@ -81,6 +82,14 @@ public interface TUInterfaceinfoMapper
     public int updateInterfaceCallsuccnum(TUInterfaceinfo tUInterfaceinfo);
 
     /**
+     * 修改【归集数据分析】
+     *
+     * @param imputationData 【归集数据分析】
+     * @return 结果
+     */
+    public ImputationData imputationData(Map imputationData);
+
+    /**
      * 修改【接口数据条数】
      *
      * @param tUInterfaceinfo 【接口数据条数】

+ 5 - 0
mybusiness/src/main/java/com/sooka/system/service/ITUInterfaceinfoService.java

@@ -76,6 +76,11 @@ public interface ITUInterfaceinfoService
     public void refreshData();
 
     /**
+     * 刷新归集数据分析
+     */
+    public void imputationData();
+
+    /**
      * 查询接口数量
      * @return 结果
      */

+ 74 - 0
mybusiness/src/main/java/com/sooka/system/service/impl/TUInterfaceinfoServiceImpl.java

@@ -5,6 +5,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.business.domain.ImputationData;
+import com.business.mapper.ImputationDataMapper;
 import com.sooka.apply.domain.IntDetailed;
 import com.sooka.apply.mapper.IntRecordMapper;
 import com.sooka.common.core.text.Convert;
@@ -34,6 +36,8 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
     @Resource
     private TUInterfaceinfoMapper tUInterfaceinfoMapper;
     @Resource
+    private ImputationDataMapper imputationDataMapper;
+    @Resource
     private IntRecordMapper intRecordMapper;
 
     /**
@@ -223,6 +227,76 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
     }
 
     /**
+     * 刷新归集数据分析
+     */
+    @Override
+    public void imputationData(){
+        Long[] calendar = new Long[13];
+        calendar[1] = 0L;
+        calendar[2] = 0L;
+        calendar[3] = 0L;
+        calendar[4] = 0L;
+        calendar[5] = 0L;
+        calendar[6] = 0L;
+        calendar[7] = 0L;
+        calendar[8] = 0L;
+        calendar[9] = 0L;
+        calendar[10] = 0L;
+        calendar[11] = 0L;
+        calendar[12] = 0L;
+        TUInterfaceinfo param = new TUInterfaceinfo();
+//        param.setNeedRefresh("1");
+        List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoList(param);
+        for (int i = 0; i < tuInterfaceinfoList.size(); i++) {
+            TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoList.get(i);
+            String tableName = tuInterfaceinfo.getTableName();
+            if (tableName == null || tableName.equals("")) {
+                System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + 0 + " ms");
+                continue;
+            }
+            Map map = new HashMap();
+            map.put("year", "2020");
+            map.put("tableName", tableName);
+            System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
+            Date dateBegin = new Date();
+            Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
+            ImputationData imputationData = tUInterfaceinfoMapper.imputationData(map);
+            calendar[1] += Long.valueOf(imputationData.getJan());
+            calendar[2] += Long.valueOf(imputationData.getFeb());
+            calendar[3] += Long.valueOf(imputationData.getMar());
+            calendar[4] += Long.valueOf(imputationData.getApr());
+            calendar[5] += Long.valueOf(imputationData.getMay());
+            calendar[6] += Long.valueOf(imputationData.getJun());
+            calendar[7] += Long.valueOf(imputationData.getJul());
+            calendar[8] += Long.valueOf(imputationData.getAug());
+            calendar[9] += Long.valueOf(imputationData.getSep());
+            calendar[10] += Long.valueOf(imputationData.getOct());
+            calendar[11] += Long.valueOf(imputationData.getNov());
+            calendar[12] += Long.valueOf(imputationData.getDecb());
+            System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + interval + " ms");
+            tuInterfaceinfo.setRefreshTime(new Date());
+//            tuInterfaceinfo.setNeedRefresh("2");
+//            tUInterfaceinfoMapper.updateInterfaceCallsuccnum(tuInterfaceinfo);
+            //update t_u_interfaceinfo set callsuccnum = #{callsuccnum} where id = #{id}
+        }
+        ImputationData imputationData = new ImputationData();
+        imputationData.setYear("2020");
+        imputationData.setJan(calendar[1].toString());
+        imputationData.setFeb(calendar[2].toString());
+        imputationData.setMar(calendar[3].toString());
+        imputationData.setApr(calendar[4].toString());
+        imputationData.setMay(calendar[5].toString());
+        imputationData.setJun(calendar[6].toString());
+        imputationData.setJul(calendar[7].toString());
+        imputationData.setAug(calendar[8].toString());
+        imputationData.setSep(calendar[9].toString());
+        imputationData.setOct(calendar[10].toString());
+        imputationData.setNov(calendar[11].toString());
+        imputationData.setDecb(calendar[12].toString());
+        imputationDataMapper.updateImputationData(imputationData);
+    }
+
+    /**
      * 查询接口数量
      * @return 结果
      */

+ 17 - 0
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -217,6 +217,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update t_u_interfaceinfo set refresh_time = #{refreshTime}, need_refresh = #{needRefresh}, callsuccnum = #{callsuccnum} where id = #{id}
     </update>
 
+    <select id="imputationData" parameterType="java.util.Map" resultType="ImputationData">
+        select * from(
+	        (select count(id) jan from ${tableName} where year(create_time) = #{year} and month(create_time) = 1) a,
+	        (select count(id) feb from ${tableName} where year(create_time) = #{year} and month(create_time) = 2) b,
+	        (select count(id) mar from ${tableName} where year(create_time) = #{year} and month(create_time) = 3) c,
+	        (select count(id) apr from ${tableName} where year(create_time) = #{year} and month(create_time) = 4) d,
+	        (select count(id) may from ${tableName} where year(create_time) = #{year} and month(create_time) = 5) e,
+	        (select count(id) jun from ${tableName} where year(create_time) = #{year} and month(create_time) = 6) f,
+	        (select count(id) jul from ${tableName} where year(create_time) = #{year} and month(create_time) = 7) g,
+	        (select count(id) aug from ${tableName} where year(create_time) = #{year} and month(create_time) = 8) h,
+	        (select count(id) sep from ${tableName} where year(create_time) = #{year} and month(create_time) = 9) i,
+	        (select count(id) oct from ${tableName} where year(create_time) = #{year} and month(create_time) = 10) j,
+	        (select count(id) nov from ${tableName} where year(create_time) = #{year} and month(create_time) = 11) k,
+	        (select count(id) decb from ${tableName} where year(create_time) = #{year} and month(create_time) = 12) l
+        )
+    </select>
+
     <update id="updateDataNum" parameterType="TUInterfaceinfo">
         update t_u_interfaceinfo_datanum set update_time = #{updateTime}, datanum = (select count(id) from ${tableName}) where id = #{id}
     </update>

+ 5 - 1
mybusiness/src/main/resources/static/visualization/js/vice-script.js

@@ -7,7 +7,11 @@ onkeydown = function (e) {
     if (keyCode === nuttertools[nuttertools_index]) {
         if(nuttertools.length-1 == nuttertools_index){
             console.log("MISSION SUCCESS");
-            $.post("/visualization/refreshData", function (res) {
+            // $.post("/visualization/refreshData", function (res) {
+            //     console.log("Cheat activated");
+            //     console.log(res);
+            // });
+            $.post("/visualization/imputationData", function (res) {
                 console.log("Cheat activated");
                 console.log(res);
             });