|
@@ -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,21 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
private PropertyRepairMapper propertyRepairMapper;
|
|
|
@Autowired
|
|
|
private ComplaintSuggestionMapper complaintSuggestionMapper;
|
|
|
+ @Autowired
|
|
|
+ private VisitorManageMapper visitorManageMapper;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+ @Autowired
|
|
|
+ private HouseInfoMapper houseInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProprietorCarMapper proprietorCarMapper;
|
|
|
|
|
|
|
|
|
@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 +93,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 +128,285 @@ 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<>(7);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //我的房屋
|
|
|
+ int houseCount = 0;
|
|
|
+ List<ResidentInfo> residentInfos = houseInfoMapper.selectHouseInfoListAndResidentInfo(residentInfo);
|
|
|
+ if (residentInfos != null && residentInfos.size() > 0) {
|
|
|
+ houseCount = residentInfos.size();
|
|
|
+ }
|
|
|
+ map.put("houseCount", houseCount);
|
|
|
+ //我的车辆
|
|
|
+ map.put("carCount", proprietorCarMapper.selectProprietorCarCount(residentInfo.getResidentPhone()));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult numCar() {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //总数
|
|
|
+ int zs = 1237;
|
|
|
+ //外来
|
|
|
+ int wl = 396;
|
|
|
+ //内部
|
|
|
+ int nb = 841;
|
|
|
+ map.put("zs",zs);
|
|
|
+ map.put("wl",wl);
|
|
|
+ map.put("nb",nb);
|
|
|
return AjaxResult.success(map);
|
|
|
}
|
|
|
}
|