ソースを参照

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatServiceImpl.java
Administrator 1 年間 前
コミット
f1d424c965

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -113,7 +113,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 .antMatchers("/login", "/register", "/captchaImage","/boman/common/**","/sendSms/**","/system/pinglun/**").permitAll()
                 .antMatchers("/system/personnel/**", "/reservat/config/**", "/reservat/time/**","/system/reservat/**","/system/news/**","/system/annex/listNo").permitAll()
-                .antMatchers("/system/dict/data/type/**").permitAll()
+                .antMatchers("/system/dict/data/type/**","/system/app/new").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

+ 50 - 21
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ruoyi.system.service.impl;
 
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -8,6 +10,7 @@ import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SendSmsUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -219,20 +222,20 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
     @Override
     public AjaxResult indexStatistics(BomanReservat bomanReservat) {
         Map<String, Object> map = new HashMap<>(4);
-        map.put("canGuan", 0);
-        map.put("yuYue", 0);
-        map.put("todayYuYue", 0);
-        map.put("todayCanGuan", 0);
+        map.put("canGuan" , 0);
+        map.put("yuYue" , 0);
+        map.put("todayYuYue" , 0);
+        map.put("todayCanGuan" , 0);
         List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(bomanReservat);
         if (bomanReservats != null && bomanReservats.size() > 0) {
             //来访数
             long canGuan = bomanReservats.stream().filter(s -> "2".equals(s.getVisitStatus())).count();
             long todayYuYue = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).count();
             long todayCanGuan = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).filter(s -> "2".equals(s.getVisitStatus())).count();
-            map.put("canGuan", canGuan);
-            map.put("yuYue", bomanReservats.size());
-            map.put("todayYuYue", todayYuYue);
-            map.put("todayCanGuan", todayCanGuan);
+            map.put("canGuan" , canGuan);
+            map.put("yuYue" , bomanReservats.size());
+            map.put("todayYuYue" , todayYuYue);
+            map.put("todayCanGuan" , todayCanGuan);
         }
         return AjaxResult.success(map);
     }
@@ -257,11 +260,37 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
     @Override
     public AjaxResult realTime() {
         // todo
+
+        String configKey = "lyssllsj";
+        String configKey_1 = "lyssllsj_1";
+        String configValue = Convert.toStr(redisCache.getCacheObject(configKey));
+        String configValue_1 = Convert.toStr(redisCache.getCacheObject(configKey_1));
+        if(StringUtils.isEmpty(configValue) || "0".equals(configValue)){
+            configValue = "0";
+        }
+        if(StringUtils.isEmpty(configValue_1) || "0".equals(configValue_1)){
+            configValue_1 = "0";
+        }
+
+
         Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("scale" , "0%");
+
+        if(!"0".equals(configValue) && !"0".equals(configValue_1)){
+            BigDecimal num1 = new BigDecimal("configValue");
+            BigDecimal num2 = new BigDecimal("configValue_1");
+            double result = Double.parseDouble(((num1.divide(num2)).setScale(2,BigDecimal.ROUND_HALF_UP)).toString());
+            DecimalFormat decimalFormat = new DecimalFormat("0%"); // 创建DecimalFormat对象并设置格式化模式为"0%"
+            String percentage = decimalFormat.format((result * 100)); // 使用DecimalFormat对象进行格式化操作
+            resultMap.put("scale" , percentage);
+        }
 
-        resultMap.put("scale", "50%");
-        resultMap.put("current", 5);
-        resultMap.put("total", 10);
+        //今天比昨天新增多少人
+        resultMap.put("addNum" , Long.parseLong(configValue)-Long.parseLong(configValue_1));
+        //昨天人数
+        resultMap.put("current" , configValue_1);
+        //今天人数
+        resultMap.put("total" , configValue);
         return AjaxResult.success(resultMap);
     }
 
@@ -281,18 +310,18 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
         long todayYy = 0;
         for (BomanReservat bomanReservat : bomanReservatYearList) {
             yearYy = yearYy + Long.parseLong(bomanReservat.getVisitNum());
-            if (bomanReservat.getVisitDate().contains(time.substring(0, time.lastIndexOf("-")))) {
+            if(bomanReservat.getVisitDate().contains(time.substring(0,time.lastIndexOf("-")))){
                 monthYy = monthYy + Long.parseLong(bomanReservat.getVisitNum());
             }
             if (bomanReservat.getVisitDate().equals(time)) {
                 todayYy = todayYy + Long.parseLong(bomanReservat.getVisitNum());
             }
         }
-        map.put("yearYy", yearYy);
-        map.put("monthYy", monthYy);
-        map.put("todayYy", todayYy);
+        map.put("yearYy" , yearYy);
+        map.put("monthYy" , monthYy);
+        map.put("todayYy" , todayYy);
         //todo 今日参观人数
-        map.put("todayVisit", 10);
+        map.put("todayVisit" , 10);
 
         Map<String, Object> sevenMap = new HashMap<>();
         //获取近7天的数组
@@ -327,12 +356,12 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
             td = 0L;
         }
 
-        sevenMap.put("date", sevenDate);
-        sevenMap.put("zrs", zrsList);
-        sevenMap.put("sk", skList);
-        sevenMap.put("td", tdList);
+        sevenMap.put("date" , sevenDate);
+        sevenMap.put("zrs" , zrsList);
+        sevenMap.put("sk" , skList);
+        sevenMap.put("td" , tdList);
 
-        map.put("sevenMap", sevenMap);
+        map.put("sevenMap" , sevenMap);
         return AjaxResult.success(map);
     }