Kaynağa Gözat

登录和首页数据展示问题修复

zyp 1 hafta önce
ebeveyn
işleme
99697dfe9b

+ 12 - 4
fs-admin-saas/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -193,13 +193,17 @@ public class IndexStatisticsController {
         TrafficLogDTO result = new TrafficLogDTO();
         if(!medicalMallConfig.isStatics() || (param.getCompanyId() == null && param.getDeptId() == null) || (param.getCompanyId() == null && param.getDeptId() == 1)) {
             result = redisCache.getCacheObject(DATA_OVERVIEW_TRAFFIC_LOG);
+            if (result == null) {
+                result = new TrafficLogDTO();
+            }
             if (!medicalMallConfig.isStatics()) {
                 SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
-                if(result == null || sysConfig == null) {
-                    return null;
+                if (result == null) {
+                    result = new TrafficLogDTO();
+                }
+                if (sysConfig != null && sysConfig.getConfigValue() != null) {
+                    result.setTraffic(sysConfig.getConfigValue());
                 }
-                String configValue = sysConfig.getConfigValue();
-                result.setTraffic(configValue);
             } else {
                 //所有部门流量之和
                 SysDept dept = new SysDept();
@@ -220,6 +224,9 @@ public class IndexStatisticsController {
         }else{
             getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+param.getDeptId());
         }
+        if (result == null) {
+            result = new TrafficLogDTO();
+        }
         return R.ok().put("data",result);
     }
 
@@ -728,6 +735,7 @@ public class IndexStatisticsController {
                     );
                 }
             }
+            authorizationInfoDTO = authorizationInfoDTO1;
         }
 
         return R.ok().put("data", authorizationInfoDTO);

+ 42 - 9
fs-admin-saas/src/main/java/com/fs/web/controller/system/SysLoginController.java

@@ -38,6 +38,8 @@ import com.fs.framework.web.service.SysLoginService;
 import com.fs.framework.web.service.SysPermissionService;
 import com.fs.system.service.ISysMenuService;
 import com.fs.system.service.IAdminMenuService;
+import com.fs.system.service.ISysConfigService;
+import com.fs.system.domain.SysConfig;
 
 /**
  * 登录验证
@@ -85,6 +87,9 @@ public class SysLoginController
     @Autowired
     private UserDetailsService userDetailsService;
 
+//    @Autowired
+//    private ISysConfigService configService;
+
     /**
      * 登录方法
      *
@@ -171,19 +176,47 @@ public class SysLoginController
         return AjaxResult.success(adminMenuService.buildAdminMenus(menus));
     }
 
+//    @GetMapping("getFirstLogin")
+//    public AjaxResult getFirstLogin()
+//    {
+//        SysConfig config = configService.selectConfigByConfigKey("his.login");
+//        if (config != null && config.getConfigValue() != null) {
+//            String configValue = config.getConfigValue();
+//            JSONObject jsonObject = JSONObject.parseObject(configValue);
+//            Boolean disabled = jsonObject.getBoolean("disabled");
+//            if (Boolean.TRUE.equals(disabled)) {
+//                LoginUser loginUser = SecurityUtils.getLoginUser();
+//                Boolean isFirstLogin = redisCache.getCacheObject("firstLogin:admin:" + loginUser.getUser().getUserId());
+//                return AjaxResult.success(isFirstLogin != null && isFirstLogin);
+//            }
+//        }
+//        return AjaxResult.success(false);
+//    }
+
+    /**
+     * 租户总后台:根据 his.login 配置判断是否需要首次登录改密(与 company 端逻辑对齐,使用 SysUser)
+     */
     @GetMapping("getFirstLogin")
     public AjaxResult getFirstLogin()
     {
         SysConfig config = configService.selectConfigByConfigKey("his.login");
-        if (config != null && config.getConfigValue() != null) {
-            String configValue = config.getConfigValue();
-            JSONObject jsonObject = JSONObject.parseObject(configValue);
-            Boolean disabled = jsonObject.getBoolean("disabled");
-            if (Boolean.TRUE.equals(disabled)) {
-                LoginUser loginUser = SecurityUtils.getLoginUser();
-                Boolean isFirstLogin = redisCache.getCacheObject("firstLogin:admin:" + loginUser.getUser().getUserId());
-                return AjaxResult.success(isFirstLogin != null && isFirstLogin);
-            }
+        if (config == null || config.getConfigValue() == null) {
+            return AjaxResult.success(false);
+        }
+        JSONObject jsonObject = JSONObject.parseObject(config.getConfigValue());
+        Boolean enabled = jsonObject.getBoolean("disabled");
+        if (!Boolean.TRUE.equals(enabled)) {
+            return AjaxResult.success(false);
+        }
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null || loginUser.getUser() == null) {
+            return AjaxResult.success(false);
+        }
+        Long tenantId = loginUser.getTenantId();
+        String cacheKey = "newSysUser:" + (tenantId != null ? tenantId : 0) + ":" + loginUser.getUsername();
+        Long flaggedUserId = redisCache.getCacheObject(cacheKey);
+        if (flaggedUserId != null && flaggedUserId.equals(loginUser.getUserId())) {
+            return AjaxResult.success(true);
         }
         return AjaxResult.success(false);
     }

+ 7 - 1
fs-admin-saas/src/main/java/com/fs/web/controller/system/SysProfileController.java

@@ -24,12 +24,13 @@ import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.file.FileUploadUtils;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.framework.web.service.TokenService;
 import com.fs.system.service.ISysUserService;
 
 /**
  * 个人信息 业务处理
- * 
+ *
 
  */
 @Profile({"admin", "company"})
@@ -43,6 +44,9 @@ public class SysProfileController extends BaseController
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 个人信息
      */
@@ -119,6 +123,8 @@ public class SysProfileController extends BaseController
             // 更新缓存用户密码
             loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
             tokenService.setLoginUser(loginUser);
+            Long tenantId = loginUser.getTenantId();
+            redisCache.deleteObject("newSysUser:" + (tenantId != null ? tenantId : 0) + ":" + userName);
             return AjaxResult.success();
         }
         return AjaxResult.error("修改密码异常,请联系管理员");

+ 8 - 0
fs-service/src/main/java/com/fs/statis/service/impl/StatisticsCompanyServiceImpl.java

@@ -813,6 +813,14 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         SysConfig config = configService.selectConfigByConfigKey("statis.config");
         Asserts.notNull(config, "流量价格配置不能为空!");
         JSONObject jsonObject = JSONObject.parseObject(config.getConfigValue());
+        if (jsonObject == null) {
+            ConsumptionBalanceDataDTO empty = new ConsumptionBalanceDataDTO();
+            empty.setTodayComsumption(BigDecimal.ZERO);
+            empty.setYesterdayComsumption(BigDecimal.ZERO);
+            BigDecimal currentBalance = consumptionBalanceMapper.getCurrentBalanceCompanyId(companyId);
+            empty.setBalance(currentBalance != null ? currentBalance : BigDecimal.ZERO);
+            return empty;
+        }
         float trafficPrice = jsonObject.getFloatValue("trafficPrice");
 
         // 创建消费余额数据对象

+ 8 - 0
fs-service/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -724,6 +724,14 @@ public class StatisticsServiceImpl implements IStatisticsService {
         SysConfig config = configService.selectConfigByConfigKey("statis.config");
         Asserts.notNull(config, "流量价格配置不能为空!");
         JSONObject jsonObject = JSONObject.parseObject(config.getConfigValue());
+        if (jsonObject == null) {
+            ConsumptionBalanceDataDTO empty = new ConsumptionBalanceDataDTO();
+            empty.setTodayComsumption(BigDecimal.ZERO);
+            empty.setYesterdayComsumption(BigDecimal.ZERO);
+            BigDecimal currentBalance = consumptionBalanceMapper.getCurrentBalance();
+            empty.setBalance(currentBalance != null ? currentBalance : BigDecimal.ZERO);
+            return empty;
+        }
         float trafficPrice = jsonObject.getFloatValue("trafficPrice");
 
         // 创建消费余额数据对象

+ 10 - 0
fs-service/src/main/java/com/fs/system/service/impl/SysUserServiceImpl.java

@@ -19,6 +19,7 @@ import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.spring.SpringUtils;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.system.domain.SysPost;
 import com.fs.system.domain.SysUserPost;
 import com.fs.system.domain.SysUserRole;
@@ -58,6 +59,9 @@ public class SysUserServiceImpl implements ISysUserService
     @Autowired
     private ISysConfigService configService;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 根据条件分页查询用户列表
      * 
@@ -287,6 +291,12 @@ public class SysUserServiceImpl implements ISysUserService
         insertUserPost(user);
         // 新增用户与角色管理
         insertUserRole(user);
+        if (rows > 0) {
+            Long tenantId = SecurityUtils.getTenantId();
+            redisCache.setCacheObject(
+                "newSysUser:" + (tenantId != null ? tenantId : 0) + ":" + user.getUserName(),
+                user.getUserId());
+        }
         return rows;
     }