فهرست منبع

数据中心数据统计

hanfucheng 1 سال پیش
والد
کامیت
433bb7b5fb

+ 15 - 2
src/main/java/com/sooka/sponest/data/index/controller/IndexViewController.java

@@ -2,6 +2,7 @@ package com.sooka.sponest.data.index.controller;
 
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.sooka.sponest.data.index.domain.MenuInfo;
 import com.sooka.sponest.data.index.service.IndexViewService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -26,8 +27,8 @@ public class IndexViewController extends BaseController {
      */
     @ApiOperation(value = "基础数据列表", notes = "基础数据列表")
     @GetMapping("/BasicDataList")
-    public AjaxResult getBasicDataList() {
-        return AjaxResult.success(indexViewService.getBasicDataList());
+    public AjaxResult getBasicDataList(MenuInfo menuInfo) {
+        return AjaxResult.success(indexViewService.getBasicDataList(menuInfo));
     }
 
     /**
@@ -106,4 +107,16 @@ public class IndexViewController extends BaseController {
     public AjaxResult dataReport() {
         return AjaxResult.success(indexViewService.systemInfoReport());
     }
+    
+    /*
+    * 数据中心-数据统计
+    *
+    * @author 韩福成
+    * @date 2023/11/3 9:01
+    */
+    @ApiOperation(value = "数据中心-数据统计", notes = "数据中心-数据统计")
+    @GetMapping("/dataStatistics")
+    public AjaxResult dataStatistics(MenuInfo menuInfo) {
+        return AjaxResult.success(indexViewService.dataStatistics(menuInfo));
+    }
 }

+ 6 - 0
src/main/java/com/sooka/sponest/data/index/domain/IndexViewInfo.java

@@ -35,4 +35,10 @@ public class IndexViewInfo extends BaseBusinessEntity {
      */
     @ApiModelProperty(value = "基础数据列表-菜单ID", required = false)
     private Integer menuId;
+
+    /*
+     * 数据更新数
+     */
+    @ApiModelProperty(value = "数据更新数", required = false)
+    private Long updataCount;
 }

+ 18 - 0
src/main/java/com/sooka/sponest/data/index/domain/MenuInfo.java

@@ -36,4 +36,22 @@ public class MenuInfo extends BaseBusinessEntity {
     @ApiModelProperty(value = "类型", required = false)
     private String type;
 
+    /*
+     * 开始时间
+     */
+    @ApiModelProperty(value = "开始时间", required = false)
+    private String startDate;
+
+    /*
+     * 结束时间
+     */
+    @ApiModelProperty(value = "结束时间", required = false)
+    private String endDate;
+
+    /*
+    * 部门id
+    */
+    @ApiModelProperty(value = "结束时间", required = false)
+    private String deptIds;
+
 }

+ 10 - 1
src/main/java/com/sooka/sponest/data/index/service/IndexViewService.java

@@ -1,6 +1,7 @@
 package com.sooka.sponest.data.index.service;
 
 import com.sooka.sponest.data.index.domain.IndexViewInfo;
+import com.sooka.sponest.data.index.domain.MenuInfo;
 
 import java.util.List;
 import java.util.Map;
@@ -13,7 +14,7 @@ public interface IndexViewService {
      *
      * @return
      */
-    List<IndexViewInfo> getBasicDataList();
+    List<IndexViewInfo> getBasicDataList(MenuInfo menuInfo);
 
     List<Map<String, Object>> getResList(String res);
 
@@ -53,4 +54,12 @@ public interface IndexViewService {
      * @return
      */
     Map<String, Long> systemInfoReport();
+
+    /*
+    * 数据中心-数据统计
+    *
+    * @author 韩福成
+    * @date 2023/11/3 9:53
+    */
+    List<Map<String,Object>> dataStatistics(MenuInfo menuInfo);
 }

+ 88 - 3
src/main/java/com/sooka/sponest/data/index/service/impl/IndexViewServiceImpl.java

@@ -8,9 +8,12 @@ import com.sooka.sponest.data.index.domain.MenuInfo;
 import com.sooka.sponest.data.index.mapper.IndexViewMapper;
 import com.sooka.sponest.data.index.service.IndexViewService;
 import org.apache.commons.collections4.MapUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 
 @Service
@@ -66,8 +69,7 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
      *
      * @return
      */
-    public List<IndexViewInfo> getBasicDataList() {
-        MenuInfo menu = new MenuInfo();
+    public List<IndexViewInfo> getBasicDataList(MenuInfo menu) {
         setSookaDataBase(menu);
         List<IndexViewInfo> basicList = new ArrayList<>();
 
@@ -107,6 +109,7 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
             String subclass = entry.getKey();
             IndexViewInfo indexViewInfo = new IndexViewInfo();
             indexViewInfo.setCount(0L);
+            indexViewInfo.setUpdataCount(0L);
 
             // 分类名称映射
             Map<String, String> categoryMap = new HashMap<>();
@@ -124,8 +127,17 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
 
             List<MenuInfo> menuInfos = entry.getValue();
             for (MenuInfo menuInfo : menuInfos) {
+                setSookaDataBase(menuInfo);
                 Long dataCount = indexViewMapper.getBasicDataCount(menuInfo);
                 indexViewInfo.setCount(indexViewInfo.getCount() + dataCount);
+                MenuInfo menuInfo1 = new MenuInfo();
+                setSookaDataBase(menuInfo1);
+                BeanUtils.copyProperties(menuInfo, menuInfo1);
+                menuInfo1.setStartDate(menu.getStartDate());
+                menuInfo1.setEndDate(menu.getEndDate());
+                Long updateCount = indexViewMapper.getBasicDataCount(menuInfo1);
+                indexViewInfo.setUpdataCount(indexViewInfo.getUpdataCount() + updateCount);
+
             }
             basicList.add(indexViewInfo);
         }
@@ -213,8 +225,9 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
      */
     @Override
     public Map<String, Long> systemInfoReport() {
+        MenuInfo menu = new MenuInfo();
         // 1.基础数据
-        List<IndexViewInfo> basicDataList = this.getBasicDataList();
+        List<IndexViewInfo> basicDataList = this.getBasicDataList(menu);
         // 2.四长人数、巡护距离
         Map<String, Long> siZhang = this.getAllSiZhangNum();
         Map<String, Long> fourLengthPatrolDistance = this.getFourLengthPatrolDistance();
@@ -292,5 +305,77 @@ public class IndexViewServiceImpl extends BaseServiceImpl implements IndexViewSe
         list.forEach(a -> map.put(MapUtils.getString(a, "name"), MapUtils.getLong(a, "num")));
         return map;
     }
+
+    /*
+    * 数据中心-数据统计
+    *
+    * @author 韩福成
+    * @date 2023/11/3 11:19
+    */
+    public List<Map<String,Object>> dataStatistics(MenuInfo menuInfo) {
+        List<Map<String,Object>> list = new ArrayList<>();
+        setSookaDataBase(menuInfo);
+        // 获取菜单信息
+        List<MenuInfo> basicDataList = indexViewMapper.getBasicDataList(menuInfo);
+        /*List<MenuInfo> basicDataList = new ArrayList<>();
+        MenuInfo info = new MenuInfo();
+        info.setTableNameAndType("centerdata_t_emergency_team");
+        basicDataList.add(info);*/
+        Map<String,Object> map = new HashMap<>();
+        map.put("铁东区","0,100,365,372");
+        map.put("铁西区","0,100,365,373");
+        map.put("双辽市","0,100,365,369");
+        map.put("伊通县","0,100,365,370");
+        map.put("梨树县","0,100,365,371");
+        for (Map.Entry<String, Object> m : map.entrySet()){
+            Map<String,Object> td = new HashMap<>();
+            Long updateCount = 0L;
+            Long count = 0L;
+            for (MenuInfo item : basicDataList) {
+                String[] tableNameAndType = item.getTableNameAndType().split("/");
+                item.setTableName(tableNameAndType[0]);
+                item.setDeptIds(String.valueOf(m.getValue()));
+                setSookaDataBase(item);
+                //总数
+                count += indexViewMapper.getBasicDataCount(item);
+                //更新数
+                MenuInfo info1 = new MenuInfo();
+                setSookaDataBase(info1);
+                BeanUtils.copyProperties(item,info1);
+                info1.setStartDate(menuInfo.getStartDate());
+                info1.setEndDate(menuInfo.getEndDate());
+                updateCount += indexViewMapper.getBasicDataCount(info1);
+            }
+            td.put("name",m.getKey());
+            td.put("count",count);
+            td.put("updateCount",updateCount);
+            BigDecimal updateRate = new BigDecimal(0);
+            if (updateCount!=0) {
+                BigDecimal counts = new BigDecimal(count);
+                BigDecimal updateCounts = new BigDecimal(updateCount);
+                updateRate = updateCounts.divide(counts,4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).setScale(2,RoundingMode.HALF_UP);
+            }
+            td.put("updateRate",updateRate+"%");
+            list.add(td);
+        }
+        List<IndexViewInfo> indexViewInfoList = this.getBasicDataList(menuInfo);
+        for (IndexViewInfo indexViewInfo : indexViewInfoList){
+            Map<String,Object> map1 = new HashMap<>();
+            if (!indexViewInfo.getCategory().equals("共有基础数据类型")){
+                map1.put("name",indexViewInfo.getCategory());
+                map1.put("count",indexViewInfo.getCount());
+                map1.put("updateCount",indexViewInfo.getUpdataCount());
+                BigDecimal updateRate = new BigDecimal(0);
+                if (indexViewInfo.getUpdataCount()!=0){
+                    BigDecimal counts = new BigDecimal(indexViewInfo.getCount());
+                    BigDecimal updateCounts = new BigDecimal(indexViewInfo.getUpdataCount());
+                    updateRate = updateCounts.divide(counts,4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).setScale(2,RoundingMode.HALF_UP);
+                }
+                map1.put("updateRate",updateRate+"%");
+                list.add(map1);
+            }
+        }
+        return list;
+    }
 }
 

+ 6 - 2
src/main/resources/mapper/index/IndexViewMapper.xml

@@ -23,9 +23,13 @@
 
     <select id="getBasicDataCount" parameterType="MenuInfo" resultType="Long">
         SELECT count(*) FROM
-        ${tableName}
+        ${tableName} a
+        left join ${database_system}.sys_dept d on a.dept_id = d.dept_id
         <where>
-            <if test="type != null and type != ''">and type = #{type}</if>
+            <if test="type != null and type != ''">and a.type = #{type}</if>
+            <if test="startDate != null and startDate != ''">and a.update_time &gt;= concat(#{startDate},' 00:00:00')</if>
+            <if test="endDate != null and endDate != ''">and a.update_time &lt;= concat(#{endDate},' 23:59:59')</if>
+            <if test="deptIds != null and deptIds != ''">and CONCAT(d.ancestors,',',a.dept_id) = #{deptIds}</if>
         </where>
     </select>