فهرست منبع

物业管理端评论

tjf 3 ماه پیش
والد
کامیت
c52195856d

+ 34 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/statistics/StatisticsController.java

@@ -1,18 +1,12 @@
 package com.ruoyi.web.controller.statistics;
 
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.system.domain.houseInfo.PropertyFee;
-import com.ruoyi.system.domain.suggestionFj.SuggestionFj;
+import com.ruoyi.common.core.domain.entity.ResidentInfo;
+import com.ruoyi.common.core.domain.entity.StaffManage;
 import com.ruoyi.system.service.IStatisticsService;
-import com.ruoyi.system.service.ISuggestionFjService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 首页统计Controller
@@ -36,4 +30,35 @@ public class StatisticsController {
     {
         return statisticsService.numApp();
     }
+
+
+
+    /**
+     * APP首页红点物业统计
+     */
+    @PreAuthorize("@ss.hasPermi('wuYe:statistics:wuYeTips')")
+    @PostMapping("/num/app/wuYeTips")
+    public AjaxResult appWuYeTips(@RequestBody  StaffManage staffManage)
+    {
+        return statisticsService.wuYeTips(staffManage);
+    }
+    /**
+     * APP首页红点业主统计
+     */
+    @PreAuthorize("@ss.hasPermi('wuYe:statistics:yeZhuTips')")
+    @PostMapping("/num/app/yeZhuTips")
+    public AjaxResult appYeZhuTips(@RequestBody ResidentInfo residentInfo)
+    {
+        return statisticsService.yeZhuTips(residentInfo);
+    }
+
+    /**
+     * web车辆管控统计
+     */
+    @PreAuthorize("@ss.hasPermi('wuYe:statistics:vehicleControl')")
+    @GetMapping("/num/vehicleControl")
+    public AjaxResult vehicleControl()
+    {
+        return statisticsService.vehicleControl();
+    }
 }

+ 24 - 2
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -176,10 +176,32 @@ public class Constants
     public static final String THR ="3";
     public static final String FOR ="4";
     public static final String FIV ="5";
-
-
+    public static final String Y ="Y";
     public static final String FRONT = "front";
     public static final String BACK = "back";
+    public static final String UP = "up";
+    public static final String DOWN = "down";
+    //持平
+    public static final String FLAT = "flat";
+    //-----------------------web首页统计的key--------------
+    //web首页统计上月外来车辆数量
+    public static final String LAST_MONTH_VISITOR_CAR = "last_month_visitor_car:";
+    //web首页统计当月外来车辆数量
+    public static final String NOW_MONTH_VISITOR_CAR = "now_month_visitor_car:";
+    //web首页统计上月违停车辆数量
+    public static final String LAST_MONTH_ILLEGAL_CAR = "last_month_illegal_car:";
+    //web首页统计当月违停车辆数量
+    public static final String NOW_MONTH_ILLEGAL_CAR = "now_month_illegal_car:";
+    //--------------------app首页统计的key----------------
+    //用户个人报修维修未完成的数量property_repair_no:{userId} KEY=数量
+    public static final String PROPERTY_REPAIR_NO = "property_repair_no:";
+    //维修未完成的总数量 property_repair_no_all: KEY=数量
+    public static final String PROPERTY_REPAIR_NO_ALL = "property_repair_no_all:";
+    //用户个人投诉建议未回复的数量 complaint_suggestion_no:{userId} KEY=数量
+    public static final String COMPLAINT_SUGGESTION_NO = "complaint_suggestion_no:";
+    //投诉建议未回复的总数量
+    public static final String COMPLAINT_SUGGESTION_NO_ALL = "complaint_suggestion_no_all:";
+
 
     //------------------文章的key----------------------------
     //社区资讯文章点赞的人员集合的key value = 该文章的[userId]

+ 17 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -57,6 +57,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     {
         return dateTimeNow(YYYY);
     }
+    public static String getMonth()
+    {
+        return dateTimeNow(YYYY_MM);
+    }
 
     public static final String getTime()
     {
@@ -103,7 +107,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyy/MM/dd");
     }
-
     /**
      * 日期路径 即年/月/日 如20180808
      */
@@ -206,4 +209,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     }
 
 
+    /**
+     * 获取上个月年月
+     * @return
+     */
+    public static String getLastMonth(){
+        // 获取当前日期
+        LocalDate currentDate = LocalDate.now();
+
+        // 获取当前年份和上一个月份的组合(不包含具体的日)
+        YearMonth lastMonthYearMonth = YearMonth.from(currentDate).minusMonths(1);
+
+        return lastMonthYearMonth.toString();
+    }
 }

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/IllegalParkingMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.mapper;
 
 import com.ruoyi.system.domain.illegalParking.IllegalParking;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -30,6 +31,13 @@ public interface IllegalParkingMapper
     public List<IllegalParking> selectIllegalParkingList(IllegalParking illegalParking);
     public List<IllegalParking> selectIllegalParkingByPlateNumber(String plateNumber);
 
+    /**
+     * 查询违停数量根据时间
+     * @param createTime
+     * @return
+     */
+    public int selectIllegalCount(@Param("createTime") String createTime);
+
     /**
      * 新增违章停车登记
      * 

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/VisitorManageMapper.java

@@ -29,6 +29,13 @@ public interface VisitorManageMapper
      */
     public List<VisitorManage> selectVisitorManageList(VisitorManage visitorManage);
 
+    /**
+     * 查询外来车辆数量
+     * @param visitorTime
+     * @return
+     */
+    public int selectVisitorManageVehicleCount(String visitorTime);
+
     /**
      * 新增来访管理
      * 

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IStatisticsService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.ResidentInfo;
+import com.ruoyi.common.core.domain.entity.StaffManage;
 
 /**
  * 首页统计Service接口
@@ -14,4 +16,18 @@ public interface IStatisticsService {
      * APP首页统计
      */
     AjaxResult numApp();
+
+    /**
+     * APP首页红点统计
+     */
+    AjaxResult wuYeTips(StaffManage staffManage);
+
+    /**
+     * APP首页红点业主统计
+     */
+    AjaxResult yeZhuTips(ResidentInfo residentInfo);
+    /**
+     * web车辆管控统计
+     */
+    AjaxResult vehicleControl();
 }

+ 54 - 6
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ComplaintSuggestionServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.impl;
 
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.complaintSuggestion.ComplaintSuggestion;
@@ -7,11 +8,15 @@ import com.ruoyi.system.domain.suggestionFj.SuggestionFj;
 import com.ruoyi.system.mapper.ComplaintSuggestionMapper;
 import com.ruoyi.system.mapper.SuggestionFjMapper;
 import com.ruoyi.system.service.IComplaintSuggestionService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
+import static com.ruoyi.common.constant.Constants.*;
+
 /**
  * 投诉建议Service业务层处理
  * 
@@ -27,6 +32,9 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
     @Autowired
     private SuggestionFjMapper suggestionFjMapper;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 查询投诉建议
      * 
@@ -67,9 +75,28 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
     @Override
     public int insertComplaintSuggestion(ComplaintSuggestion complaintSuggestion)
     {
+        Long userId = SecurityUtils.getUserId();
         complaintSuggestion.setCreateTime(DateUtils.getNowDate());
-        complaintSuggestion.setUserId(SecurityUtils.getUserId());
-        return complaintSuggestionMapper.insertComplaintSuggestion(complaintSuggestion);
+        complaintSuggestion.setUserId(userId);
+        int result = complaintSuggestionMapper.insertComplaintSuggestion(complaintSuggestion);
+        if (result > 0){
+            String userSuggestionKey = COMPLAINT_SUGGESTION_NO + userId;
+            //往redis中新增 个人 投诉建议未回复的数量 app统计使用
+            Object userNum = redisCache.getCacheObject(userSuggestionKey);
+            if (ObjectUtils.isNotEmpty(userNum)) {
+                redisCache.setCacheObject(userSuggestionKey, Math.max((int) userNum + 1, 0));
+            }else {
+                redisCache.setCacheObject(userSuggestionKey,0);
+            }
+            //往redis中新增 总数 投诉建议未回复的数量 app统计使用
+            Object allNum = redisCache.getCacheObject(COMPLAINT_SUGGESTION_NO_ALL);
+            if (ObjectUtils.isNotEmpty(allNum)) {
+                redisCache.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL, Math.max((int) allNum + 1, 0));
+            }else {
+                redisCache.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL,0);
+            }
+        }
+        return result;
     }
 
     /**
@@ -79,13 +106,34 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int updateComplaintSuggestion(ComplaintSuggestion complaintSuggestion)
     {
-        //判断是否有附件
-        List<SuggestionFj> suggestionFjList = complaintSuggestion.getSuggestionFjList();
-        if (suggestionFjList != null && suggestionFjList.size() > 0){
-            suggestionFjMapper.batchSuggestionFj(suggestionFjList);
+        Long userId = complaintSuggestion.getUserId();
+        String status = complaintSuggestion.getStatus();
+        if (TWO.equals(status)){
+            //判断是否有附件
+            List<SuggestionFj> suggestionFjList = complaintSuggestion.getSuggestionFjList();
+            if (suggestionFjList != null && suggestionFjList.size() > 0){
+                suggestionFjMapper.batchSuggestionFj(suggestionFjList);
+            }
+            String userSuggestionKey = COMPLAINT_SUGGESTION_NO + userId;
+            //往redis中新增 个人 投诉建议未回复的数量 app统计使用
+            Object userNum = redisCache.getCacheObject(userSuggestionKey);
+            if (ObjectUtils.isNotEmpty(userNum)) {
+                redisCache.setCacheObject(userSuggestionKey, Math.max((int) userNum - 1, 0));
+            }else {
+                redisCache.setCacheObject(userSuggestionKey,0);
+            }
+            //往redis中新增 总数 投诉建议未回复的数量 app统计使用
+            Object allNum = redisCache.getCacheObject(COMPLAINT_SUGGESTION_NO_ALL);
+            if (ObjectUtils.isNotEmpty(allNum)) {
+                redisCache.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL, Math.max((int) allNum - 1, 0));
+            }else {
+                redisCache.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL,0);
+            }
         }
+
         complaintSuggestion.setUpdateTime(DateUtils.getNowDate());
         return complaintSuggestionMapper.updateComplaintSuggestion(complaintSuggestion);
     }

+ 68 - 30
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PropertyRepairServiceImpl.java

@@ -2,13 +2,17 @@ package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.StaffManage;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.propertyRepair.PropertyRepair;
 import com.ruoyi.system.mapper.PropertyRepairMapper;
 import com.ruoyi.system.mapper.StaffManageMapper;
 import com.ruoyi.system.service.IPropertyRepairService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -19,76 +23,112 @@ import static com.ruoyi.common.constant.Constants.*;
 
 /**
  * 物业报修Service业务层处理
- * 
+ *
  * @author boman
  * @date 2025-02-14
  */
 @Service
-public class PropertyRepairServiceImpl implements IPropertyRepairService 
-{
+public class PropertyRepairServiceImpl implements IPropertyRepairService {
     @Autowired
     private PropertyRepairMapper propertyRepairMapper;
     @Autowired
     private StaffManageMapper staffManageMapper;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 查询物业报修
-     * 
+     *
      * @param repairId 物业报修主键
      * @return 物业报修
      */
     @Override
-    public PropertyRepair selectPropertyRepairByRepairId(Long repairId)
-    {
+    public PropertyRepair selectPropertyRepairByRepairId(Long repairId) {
         return propertyRepairMapper.selectPropertyRepairByRepairId(repairId);
     }
 
     /**
      * 查询物业报修列表
-     * 
+     *
      * @param propertyRepair 物业报修
      * @return 物业报修
      */
     @Override
-    public List<PropertyRepair> selectPropertyRepairList(PropertyRepair propertyRepair)
-    {
+    public List<PropertyRepair> selectPropertyRepairList(PropertyRepair propertyRepair) {
         return propertyRepairMapper.selectPropertyRepairList(propertyRepair);
     }
 
     /**
      * 新增物业报修
-     * 
+     *
      * @param propertyRepair 物业报修
      * @return 结果
      */
     @Override
-    public int insertPropertyRepair(PropertyRepair propertyRepair)
-    {
+    public int insertPropertyRepair(PropertyRepair propertyRepair) {
+        Long userId = SecurityUtils.getUserId();
+        propertyRepair.setUserId(userId);
         propertyRepair.setCreateTime(DateUtils.getNowDate());
-        return propertyRepairMapper.insertPropertyRepair(propertyRepair);
+        int result = propertyRepairMapper.insertPropertyRepair(propertyRepair);
+        if (result > 0) {
+            String userRepairKey = PROPERTY_REPAIR_NO + userId;
+            //往redis中新增 个人 物业未完成的报修数量 app统计使用
+            Object userNum = redisCache.getCacheObject(userRepairKey);
+            if (ObjectUtils.isNotEmpty(userNum)) {
+                redisCache.setCacheObject(userRepairKey, (int) userNum + 1);
+            }else {
+                redisCache.setCacheObject(userRepairKey,1);
+            }
+            //往redis中新增 总数 物业未完成的报修数量 app统计使用
+            Object allNum = redisCache.getCacheObject(PROPERTY_REPAIR_NO_ALL);
+            if (ObjectUtils.isNotEmpty(allNum)) {
+                redisCache.setCacheObject(PROPERTY_REPAIR_NO_ALL, (int) allNum + 1);
+            }else {
+                redisCache.setCacheObject(PROPERTY_REPAIR_NO_ALL,1);
+            }
+        }
+        return result;
     }
 
     /**
      * 修改物业报修
-     * 
+     *
      * @param propertyRepair 物业报修
      * @return 结果
      */
     @Override
-    public int updatePropertyRepair(PropertyRepair propertyRepair)
-    {
+    @Transactional(rollbackFor = Exception.class)
+    public int updatePropertyRepair(PropertyRepair propertyRepair) {
+        Long userId = propertyRepair.getUserId();
         propertyRepair.setUpdateTime(DateUtils.getNowDate());
         int i = propertyRepairMapper.updatePropertyRepair(propertyRepair);
         String repairStatus = propertyRepair.getRepairStatus();
-        if (FOR.equals(repairStatus)){
+        if (FOR.equals(repairStatus)) {
             //判断如果维修完成,把维修人员的状态改成空闲
             StaffManage staffManage = new StaffManage();
             staffManage.setStaffId(propertyRepair.getStaffId());
             staffManage.setStatus(ONE);
             staffManageMapper.updateStaffManage(staffManage);
+            String userRepairKey = PROPERTY_REPAIR_NO + userId;
+            //往redis中新增 个人 物业未完成的报修数量 app统计使用
+            Object userNum = redisCache.getCacheObject(userRepairKey);
+            if (ObjectUtils.isNotEmpty(userNum)) {
+                redisCache.setCacheObject(userRepairKey, Math.max((int) userNum - 1, 0));
+            }else {
+                redisCache.setCacheObject(userRepairKey,0);
+            }
+            //往redis中新增 总数 物业未完成的报修数量 app统计使用
+            Object allNum = redisCache.getCacheObject(PROPERTY_REPAIR_NO_ALL);
+            if (ObjectUtils.isNotEmpty(allNum)) {
+                redisCache.setCacheObject(PROPERTY_REPAIR_NO_ALL, Math.max((int) allNum - 1, 0));
+            }else {
+                redisCache.setCacheObject(PROPERTY_REPAIR_NO_ALL,0);
+            }
         }
         return i;
     }
+
     /**
      * 指派物业报修人员
      */
@@ -97,13 +137,13 @@ public class PropertyRepairServiceImpl implements IPropertyRepairService
 
         Long staffId = propertyRepair.getStaffId();
         StaffManage staffManageOld = staffManageMapper.selectStaffManageByStaffId(staffId);
-        if (TWO.equals(staffManageOld.getStatus())){
+        if (TWO.equals(staffManageOld.getStatus())) {
             return AjaxResult.error("当前人员处于不在空闲状态无法指派");
         }
         //报修ID/维修人员姓名/维修人员ID/维修人员手机号
         int i = propertyRepairMapper.updatePropertyRepair(propertyRepair);
         //修改维修人员的状态
-        if (i > 0){
+        if (i > 0) {
             StaffManage staffManage = new StaffManage();
             staffManage.setStaffId(propertyRepair.getStaffId());
             staffManage.setStatus(TWO);
@@ -117,35 +157,33 @@ public class PropertyRepairServiceImpl implements IPropertyRepairService
 
     /**
      * 批量删除物业报修
-     * 
+     *
      * @param repairIds 需要删除的物业报修主键
      * @return 结果
      */
     @Override
-    public int deletePropertyRepairByRepairIds(Long[] repairIds)
-    {
+    public int deletePropertyRepairByRepairIds(Long[] repairIds) {
         return propertyRepairMapper.deletePropertyRepairByRepairIds(repairIds);
     }
 
     /**
      * 删除物业报修信息
-     * 
+     *
      * @param repairId 物业报修主键
      * @return 结果
      */
     @Override
-    public int deletePropertyRepairByRepairId(Long repairId)
-    {
+    public int deletePropertyRepairByRepairId(Long repairId) {
         return propertyRepairMapper.deletePropertyRepairByRepairId(repairId);
     }
 
     @Override
     public AjaxResult statisticsQx() {
-        Map<String,Object> mapList = new HashMap<>();
+        Map<String, Object> mapList = new HashMap<>();
         List<String> weekDays = DateUtils.getPreviousSevenDays(DateUtils.YYYY_MM_DD);
         String starTime = weekDays.get(0);
-        String endTime = weekDays.get(weekDays.size()-1);
-        mapList.put("x",weekDays);
+        String endTime = weekDays.get(weekDays.size() - 1);
+        mapList.put("x", weekDays);
         //查询两个日期内的保修数据
         List<PropertyRepair> propertyRepairs = propertyRepairMapper.selectPropertyRepairListByTime(starTime, endTime);
         List<Integer> numList = new ArrayList<>();
@@ -153,13 +191,13 @@ public class PropertyRepairServiceImpl implements IPropertyRepairService
             int num = 0;
             for (PropertyRepair propertyRepair : propertyRepairs) {
                 String day = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, propertyRepair.getRepairTime());
-                if(day.equals(weekDays.get(i))){
+                if (day.equals(weekDays.get(i))) {
                     num++;
                 }
             }
             numList.add(num);
         }
-        mapList.put("y",numList);
+        mapList.put("y", numList);
         return AjaxResult.success(mapList);
     }
 }

+ 268 - 30
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StatisticsServiceImpl.java

@@ -1,17 +1,18 @@
 package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.ResidentInfo;
+import com.ruoyi.common.core.domain.entity.StaffManage;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.checkPoint.CheckPointRecord;
 import com.ruoyi.system.domain.complaintSuggestion.ComplaintSuggestion;
 import com.ruoyi.system.domain.illegalParking.IllegalParking;
 import com.ruoyi.system.domain.propertyRepair.PropertyRepair;
-import com.ruoyi.system.mapper.CheckPointRecordMapper;
-import com.ruoyi.system.mapper.ComplaintSuggestionMapper;
-import com.ruoyi.system.mapper.IllegalParkingMapper;
-import com.ruoyi.system.mapper.PropertyRepairMapper;
+import com.ruoyi.system.mapper.*;
 import com.ruoyi.system.service.IStatisticsService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -20,6 +21,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static com.ruoyi.common.constant.Constants.*;
+import static com.ruoyi.common.utils.DateUtils.getLastMonth;
+
 /**
  * 首页统计Service业务层处理
  *
@@ -37,13 +41,17 @@ public class StatisticsServiceImpl implements IStatisticsService {
     private PropertyRepairMapper propertyRepairMapper;
     @Autowired
     private ComplaintSuggestionMapper complaintSuggestionMapper;
+    @Autowired
+    private VisitorManageMapper visitorManageMapper;
+    @Autowired
+    private RedisCache redisCache;
 
 
     @Override
     public AjaxResult numApp() {
         String day = DateUtils.getDate();
         String dayTime = DateUtils.getTime();
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
         //空闲车位
         int kxcw = 0;
         //空闲充电桩
@@ -81,33 +89,33 @@ public class StatisticsServiceImpl implements IStatisticsService {
 
         //查询违停登记
         Map<String, Object> params = new HashMap<>();
-        params.put("createTime",day);
+        params.put("createTime", day);
         IllegalParking illegalParking = new IllegalParking();
         illegalParking.setParams(params);
         List<IllegalParking> illegalParkings = illegalParkingMapper.selectIllegalParkingList(illegalParking);
-        if(illegalParkings!=null && illegalParkings.size()>0){
+        if (illegalParkings != null && illegalParkings.size() > 0) {
             wtdj = illegalParkings.size();
         }
         //查询巡更
         CheckPointRecord checkPointRecord = new CheckPointRecord();
         checkPointRecord.setCheckTime(DateUtils.getNowDate());
         List<CheckPointRecord> checkPointRecords = checkPointRecordMapper.selectCheckPointRecordList(checkPointRecord);
-        if(checkPointRecords!=null && checkPointRecords.size()>0){
+        if (checkPointRecords != null && checkPointRecords.size() > 0) {
             Map<String, List<CheckPointRecord>> collects = checkPointRecords.stream().collect(Collectors.groupingBy(CheckPointRecord::getCheckStatus));
-            if(collects.containsKey("1")){
+            if (collects.containsKey("1")) {
                 wxg = collects.get("1").size();
             }
-            if(collects.containsKey("2")){
+            if (collects.containsKey("2")) {
                 yxg = collects.get("2").size();
             }
         }
 
         //查询报修
         List<PropertyRepair> propertyRepairs = propertyRepairMapper.selectPropertyRepairListByTime(day, day);
-        if(propertyRepairs!=null && propertyRepairs.size()>0){
+        if (propertyRepairs != null && propertyRepairs.size() > 0) {
             jrbx = propertyRepairs.size();
             for (PropertyRepair propertyRepair : propertyRepairs) {
-                if(StringUtils.isNotEmpty(propertyRepair.getPhoneNumber())){
+                if (StringUtils.isNotEmpty(propertyRepair.getPhoneNumber())) {
                     ypbx++;
                 }
             }
@@ -116,30 +124,260 @@ public class StatisticsServiceImpl implements IStatisticsService {
         ComplaintSuggestion complaintSuggestion = new ComplaintSuggestion();
         complaintSuggestion.setParams(params);
         List<ComplaintSuggestion> complaintSuggestions = complaintSuggestionMapper.selectComplaintSuggestionList(complaintSuggestion);
-        if(complaintSuggestions!=null && complaintSuggestions.size()>0){
+        if (complaintSuggestions != null && complaintSuggestions.size() > 0) {
             tsjy = complaintSuggestions.size();
             Map<String, List<ComplaintSuggestion>> suggestionCollect = complaintSuggestions.stream().collect(Collectors.groupingBy(ComplaintSuggestion::getStatus));
-            if(suggestionCollect.containsKey("2")){
+            if (suggestionCollect.containsKey("2")) {
                 yhjy = suggestionCollect.get("2").size();
             }
         }
-        map.put("wtdj",wtdj);
-        map.put("yxg",yxg);
-        map.put("wxg",wxg);
-        map.put("jrbx",jrbx);
-        map.put("ypbx",ypbx);
-        map.put("tsjy",tsjy);
-        map.put("yhjy",yhjy);
+        map.put("wtdj", wtdj);
+        map.put("yxg", yxg);
+        map.put("wxg", wxg);
+        map.put("jrbx", jrbx);
+        map.put("ypbx", ypbx);
+        map.put("tsjy", tsjy);
+        map.put("yhjy", yhjy);
         // todo 空闲车位,空闲充电桩,进入车辆,离开车辆,外来车辆,外来人员,进入人员,家政订单,完成订单
-        map.put("kxcw",kxcw);
-        map.put("kxcdz",kxcdz);
-        map.put("jrcl",jrcl);
-        map.put("lkcl",lkcl);
-        map.put("wlcl",wlcl);
-        map.put("wlry",wlry);
-        map.put("jrry",jrry);
-        map.put("jzdd",jzdd);
-        map.put("wcdd",wcdd);
+        map.put("kxcw", kxcw);
+        map.put("kxcdz", kxcdz);
+        map.put("jrcl", jrcl);
+        map.put("lkcl", lkcl);
+        map.put("wlcl", wlcl);
+        map.put("wlry", wlry);
+        map.put("jrry", jrry);
+        map.put("jzdd", jzdd);
+        map.put("wcdd", wcdd);
+        return AjaxResult.success(map);
+    }
+
+    /**
+     * APP首页红点统计
+     */
+    @Override
+    public AjaxResult wuYeTips(StaffManage staffManage) {
+        Map<String, Object> map = new HashMap<>(3);
+        Long userId = staffManage.getUserId();
+        //物业报修未完成的数量 投诉建议未回复的数量 社区资讯未读数量
+        Object repairNum = redisCache.getCacheObject(PROPERTY_REPAIR_NO_ALL);
+        map.put("propertyRepair", 0);
+        if (ObjectUtils.isNotEmpty(repairNum)) {
+            map.put("propertyRepair", repairNum);
+        }
+        //投诉建议未回复的数量
+        Object complaintSuggestionNum = redisCache.getCacheObject(COMPLAINT_SUGGESTION_NO_ALL);
+        map.put("complaintSuggestion", 0);
+        if (ObjectUtils.isNotEmpty(repairNum)) {
+            map.put("complaintSuggestion", complaintSuggestionNum);
+        }
+        //查询社区资讯未读互动数量
+        map.put("commentInteractionUserCount", 0);
+        String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + userId;
+        Object commentInteractionUserCount = redisCache.getCacheObject(commentInteractionUserCountKey);
+        if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+            map.put("commentInteractionUserCount", commentInteractionUserCount);
+        }
+        return AjaxResult.success(map);
+    }
+
+    /**
+     * APP首页红点业主统计
+     */
+    @Override
+    public AjaxResult yeZhuTips(ResidentInfo residentInfo) {
+        Map<String, Object> map = new HashMap<>(5);
+        Long userId = residentInfo.getUserId();
+        //物业报修未完成的数量 投诉建议未回复的数量 社区资讯未读数量
+        String userRepairKey = PROPERTY_REPAIR_NO + userId;
+        Object repairNum = redisCache.getCacheObject(userRepairKey);
+        map.put("propertyRepair", 0);
+        if (ObjectUtils.isNotEmpty(repairNum)) {
+            map.put("propertyRepair", repairNum);
+        }
+        //个人投诉建议未回复的数量
+        String userSuggestionKey = COMPLAINT_SUGGESTION_NO + userId;
+        Object complaintSuggestionNum = redisCache.getCacheObject(userSuggestionKey);
+        map.put("complaintSuggestion", 0);
+        if (ObjectUtils.isNotEmpty(repairNum)) {
+            map.put("complaintSuggestion", complaintSuggestionNum);
+        }
+        //未读互动的数量
+        //查询社区资讯未读互动数量
+        map.put("commentInteractionUserCount", 0);
+        String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + userId;
+        Object commentInteractionUserCount = redisCache.getCacheObject(commentInteractionUserCountKey);
+        if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+            map.put("commentInteractionUserCount", commentInteractionUserCount);
+        }
+        //点赞的数量
+        //获取记录社区资讯某个用户一共有多少个未读的互动(点赞,收藏,回复)的具体信息
+        String commentInteractionUserKey = COMMENT_INTERACTION_USER + userId;
+        Map<String, Object> commentInteractionUserMap = redisCache.getCacheMap(commentInteractionUserKey);
+        //点赞数量
+        int likeCount = 0;
+        //评论数量
+        int contentCount = 0;
+        if (commentInteractionUserMap != null && commentInteractionUserMap.size() > 0) {
+            // hkey = {targetType:targetId} targetType = 目标类型(1:资讯评论 2:资讯点赞 3:资讯收藏 4:评论回复 5:回复点赞)
+            for (String hKey : commentInteractionUserMap.keySet()) {
+                //找到所有点赞的数量targetType = 2|5
+                String type = hKey.split(":")[0];
+                if (type.equals(TWO) || type.equals(FIV)) {
+                    likeCount = likeCount + 1;
+                }
+                if (likeCount==99){
+                    break;
+                }
+            }
+            for (String hKey : commentInteractionUserMap.keySet()) {
+                //找到所有评论的数量targetType = 2|5
+                String type = hKey.split(":")[0];
+                if (type.equals(ONE) || type.equals(FOR)){
+                    contentCount = contentCount + 1;
+                }
+                if (contentCount==99){
+                    break;
+                }
+            }
+
+        }
+        map.put("likeCount", likeCount);
+        map.put("contentCount", contentCount);
         return AjaxResult.success(map);
     }
+
+    /**
+     * web车辆管控统计
+     */
+    @Override
+    public AjaxResult vehicleControl() {
+        Map<String, Object> map = new HashMap<>();
+        // todo 空闲车位,空闲充电桩,进入车辆,离开车辆
+        //空闲车位数量
+        map.put("idlePlace", 0);
+        //空闲车位占比
+        map.put("idlePercentage", "25%");
+        //空闲充电桩数量
+        map.put("chargePlace", 0);
+        //空闲充电桩占比
+        map.put("chargePercentage", "25%");
+        //进入车辆
+        map.put("interCarNum", 0);
+        map.put("interCarStatus", UP);
+        map.put("interCarPercentage", "25.83%");
+        //离开车辆
+        map.put("outCarNum", 0);
+        map.put("outCarStatus", UP);
+        map.put("outCarPercentage", "25.83%");
+
+        //---------外来车辆------------
+        getVisitorCar(map);
+        //---------外来车辆结束------------
+        //---------违停登记------------
+        getIllegalCar(map);
+
+        //---------违停登记结束------------
+        return AjaxResult.success(map);
+    }
+
+    /**
+     * visitor_manage来访管理表表中的车辆
+     *
+     * @param map
+     * @return
+     */
+    public Map<String, Object> getVisitorCar(Map<String, Object> map) {
+        //查询当月来访车辆总数
+        int currentMonth = 0;
+        Object nowMonthRedis = redisCache.getCacheObject(NOW_MONTH_VISITOR_CAR + DateUtils.getMonth());
+        if (ObjectUtils.isNotEmpty(nowMonthRedis)) {
+            currentMonth = (int) nowMonthRedis;
+        }
+        //上月数据
+        int previousMonth = 0;
+        map.put("visitorNum", currentMonth);
+        map.put("visitorStatus", UP);
+        //查询上月月来访车辆总数
+        Object cacheObject = redisCache.getCacheObject(LAST_MONTH_VISITOR_CAR);
+        if (ObjectUtils.isNotEmpty(cacheObject)) {
+            previousMonth = Integer.parseInt(cacheObject.toString());
+        } else {
+            //查询数据库写入redis
+            previousMonth = visitorManageMapper.selectVisitorManageVehicleCount(getLastMonth());
+            redisCache.setCacheObject(LAST_MONTH_VISITOR_CAR, previousMonth);
+        }
+        //判断谁大
+        if (currentMonth < previousMonth) {
+            map.put("visitorStatus", DOWN);
+        } else if (currentMonth == previousMonth) {
+            map.put("visitorStatus", FLAT);
+        }
+        //计算百分比
+        map.put("visitorPercentage", getPercentageChange(currentMonth, previousMonth));
+        return map;
+    }
+
+
+    /**
+     * illegal_parking 违章停车登记表
+     *
+     * @param map
+     * @return
+     */
+    public Map<String, Object> getIllegalCar(Map<String, Object> map) {
+        //查询当月违停车辆总数
+        int currentMonth = 0;
+        Object nowMonthRedis = redisCache.getCacheObject(NOW_MONTH_ILLEGAL_CAR + DateUtils.getMonth());
+        if (ObjectUtils.isNotEmpty(nowMonthRedis)) {
+            currentMonth = (int) nowMonthRedis;
+        }
+        //上月数据
+        int previousMonth = 0;
+        map.put("illegalNum", currentMonth);
+        map.put("illegalStatus", UP);
+        //查询上月月违停车辆总数
+        Object cacheObject = redisCache.getCacheObject(LAST_MONTH_ILLEGAL_CAR);
+        if (ObjectUtils.isNotEmpty(cacheObject)) {
+            previousMonth = Integer.parseInt(cacheObject.toString());
+        } else {
+            //查询数据库写入redis
+            previousMonth = illegalParkingMapper.selectIllegalCount(getLastMonth());
+            redisCache.setCacheObject(LAST_MONTH_ILLEGAL_CAR, previousMonth);
+        }
+        //判断谁大
+        if (currentMonth < previousMonth) {
+            map.put("illegalStatus", DOWN);
+        } else if (currentMonth == previousMonth) {
+            map.put("illegalStatus", FLAT);
+        }
+        //计算百分比
+        map.put("illegalPercentage", getPercentageChange(currentMonth, previousMonth));
+
+        return map;
+    }
+
+
+    /**
+     * 两个数计算绝对值百分比
+     * 格式化为两位小数+百分号
+     *
+     * @param previousMonth 上月
+     * @param currentMonth  当月
+     * @return
+     */
+    public String getPercentageChange(int currentMonth, int previousMonth) {
+        double percentageChange;
+
+        if (previousMonth == 0) {
+            // 处理上月为0的特殊情况
+            percentageChange = (currentMonth == 0)
+                    ? 0.0          // 两月都为0 → 0%变化
+                    : 100.0;       // 上月为0且本月非0 → 视为100%增长
+        } else {
+            // 常规计算并取绝对值确保正数
+            double change = currentMonth - previousMonth;
+            percentageChange = Math.abs((change / previousMonth) * 100);
+        }
+        return String.format("%.2f%%", percentageChange);
+    }
 }

+ 42 - 21
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/VisitorManageServiceImpl.java

@@ -1,99 +1,120 @@
 package com.ruoyi.system.service.impl;
 
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.visitor.VisitorManage;
 import com.ruoyi.system.mapper.VisitorManageMapper;
 import com.ruoyi.system.service.IVisitorManageService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 
+import static com.ruoyi.common.constant.Constants.NOW_MONTH_VISITOR_CAR;
+import static com.ruoyi.common.constant.Constants.Y;
+
 /**
  * 来访管理Service业务层处理
- * 
+ *
  * @author boman
  * @date 2025-02-14
  */
 @Service
-public class VisitorManageServiceImpl implements IVisitorManageService 
-{
+public class VisitorManageServiceImpl implements IVisitorManageService {
     @Autowired
     private VisitorManageMapper visitorManageMapper;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 查询来访管理
-     * 
+     *
      * @param visitorManageId 来访管理主键
      * @return 来访管理
      */
     @Override
-    public VisitorManage selectVisitorManageByVisitorManageId(Long visitorManageId)
-    {
+    public VisitorManage selectVisitorManageByVisitorManageId(Long visitorManageId) {
         return visitorManageMapper.selectVisitorManageByVisitorManageId(visitorManageId);
     }
 
     /**
      * 查询来访管理列表
-     * 
+     *
      * @param visitorManage 来访管理
      * @return 来访管理
      */
     @Override
-    public List<VisitorManage> selectVisitorManageList(VisitorManage visitorManage)
-    {
+    public List<VisitorManage> selectVisitorManageList(VisitorManage visitorManage) {
         return visitorManageMapper.selectVisitorManageList(visitorManage);
     }
 
     /**
      * 新增来访管理
-     * 
+     *
      * @param visitorManage 来访管理
      * @return 结果
      */
     @Override
-    public int insertVisitorManage(VisitorManage visitorManage)
-    {
+    public int insertVisitorManage(VisitorManage visitorManage) {
         //todo 车牌需要进入道闸系统临时车
         visitorManage.setCreateTime(DateUtils.getNowDate());
         visitorManage.setVisitorTime(DateUtils.getNowDate());
+        //统计中外来车辆
+        if (Y.equals(visitorManage.getIsCar())) {
+            int currentMonth = 1;
+            Object nowMonthRedis = redisCache.getCacheObject(NOW_MONTH_VISITOR_CAR + DateUtils.getMonth());
+            if (ObjectUtils.isNotEmpty(nowMonthRedis)) {
+                currentMonth = (int) nowMonthRedis + currentMonth;
+            }
+            redisCache.setCacheObject(NOW_MONTH_VISITOR_CAR + DateUtils.getMonth(), currentMonth);
+        }
         return visitorManageMapper.insertVisitorManage(visitorManage);
     }
 
     /**
      * 修改来访管理
-     * 
+     *
      * @param visitorManage 来访管理
      * @return 结果
      */
     @Override
-    public int updateVisitorManage(VisitorManage visitorManage)
-    {
+    public int updateVisitorManage(VisitorManage visitorManage) {
+        if (Y.equals(visitorManage.getIsCar())) {
+            VisitorManage visitorManageOld = visitorManageMapper.selectVisitorManageByVisitorManageId(visitorManage.getVisitorManageId());
+            if (!Y.equals(visitorManageOld.getIsCar())) {
+                int currentMonth = 1;
+                Object nowMonthRedis = redisCache.getCacheObject(NOW_MONTH_VISITOR_CAR + DateUtils.getMonth());
+                if (ObjectUtils.isNotEmpty(nowMonthRedis)) {
+                    currentMonth = (int) nowMonthRedis + currentMonth;
+                }
+                redisCache.setCacheObject(NOW_MONTH_VISITOR_CAR + DateUtils.getMonth(), currentMonth);
+            }
+        }
         visitorManage.setUpdateTime(DateUtils.getNowDate());
         return visitorManageMapper.updateVisitorManage(visitorManage);
     }
 
     /**
      * 批量删除来访管理
-     * 
+     *
      * @param visitorManageIds 需要删除的来访管理主键
      * @return 结果
      */
     @Override
-    public int deleteVisitorManageByVisitorManageIds(Long[] visitorManageIds)
-    {
+    public int deleteVisitorManageByVisitorManageIds(Long[] visitorManageIds) {
         return visitorManageMapper.deleteVisitorManageByVisitorManageIds(visitorManageIds);
     }
 
     /**
      * 删除来访管理信息
-     * 
+     *
      * @param visitorManageId 来访管理主键
      * @return 结果
      */
     @Override
-    public int deleteVisitorManageByVisitorManageId(Long visitorManageId)
-    {
+    public int deleteVisitorManageByVisitorManageId(Long visitorManageId) {
         return visitorManageMapper.deleteVisitorManageByVisitorManageId(visitorManageId);
     }
 }

+ 6 - 0
ruoyi-system/src/main/resources/mapper/system/IllegalParkingMapper.xml

@@ -49,6 +49,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectIllegalParkingVo"/>
         where plate_number = #{plateNumber}
     </select>
+    <select id="selectIllegalCount" parameterType="string" resultType="java.lang.Integer">
+        SELECT COUNT(1) from illegal_parking
+        <where>
+        <if test="createTime != null  and createTime != ''"> AND date_format(create_time,'%Y%m') = date_format(#{createTime},'%Y%m')</if>
+        </where>
+    </select>
 
     <insert id="insertIllegalParking" parameterType="IllegalParking" useGeneratedKeys="true" keyProperty="illegalParkingId">
         insert into illegal_parking

+ 8 - 0
ruoyi-system/src/main/resources/mapper/system/VisitorManageMapper.xml

@@ -47,6 +47,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by create_time DESC
     </select>
+
+    <select id="selectVisitorManageVehicleCount" parameterType="string" resultType="integer">
+        select count(1) from visitor_manage
+        <where>
+             is_car = 'Y'
+            <if test="visitorTime != null "> and date_format(visitor_time,'%Y%m')  = date_format(#{visitorTime},'%Y%m')</if>
+        </where>
+    </select>
     
     <select id="selectVisitorManageByVisitorManageId" parameterType="Long" resultMap="VisitorManageResult">
         <include refid="selectVisitorManageVo"/>