From ad65038d6e7d308ddfc4842e91a8d3e385f77965 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期一, 20 一月 2025 15:07:59 +0800 Subject: [PATCH] 实时页面推送 --- src/main/java/com/whyc/service/LockInfService.java | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/whyc/service/LockInfService.java b/src/main/java/com/whyc/service/LockInfService.java index f5cada8..9d30d28 100644 --- a/src/main/java/com/whyc/service/LockInfService.java +++ b/src/main/java/com/whyc/service/LockInfService.java @@ -13,12 +13,11 @@ import com.whyc.pojo.db_area.LockInf; import com.whyc.pojo.db_user.UserInf; import com.whyc.util.ActionUtil; +import com.whyc.util.PageInfoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service @@ -185,4 +184,45 @@ .collect(Collectors.toList()); // 杞崲涓哄垪琛�*/ return new Response().setII(1,list!=null,typeList,"鏌ヨ灞忔煖鍏ㄩ儴鍝佺墝(涓嬫媺)"); } + //瀹炴椂鑾峰彇鑾峰彇鍖哄煙涓嬫墍鏈夐攣鐨勭姸鎬� + public Response getRealLock(Integer areaId, Integer pageNum, Integer pageSize) { + Map<String,Object> map=new HashMap<>(); + map.put("sumLinf",0); + map.put("onlineNum",0); + map.put("offLineNum",0); + map.put("openNum",0); + map.put("closeNum",0); + map.put("unLoadNum",0); + List<Integer> areaList=new ArrayList(); + areaList.add(areaId); + areaInfService.getAllAreaId(areaId,areaList); + List<LockInf> linfs=mapper.getRealLock(areaList); + if(linfs!=null&&linfs.size()>0){ + map.put("sumLinf",linfs.size()); + Map<Integer, List<LockInf>> onlinemap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockOnline)); + for (Integer state : onlinemap.keySet()) { + if(state==0){ + map.put("offLineNum", onlinemap.get(0).size());//绂荤嚎 + } + if(state==1){ + map.put("onlineNum", onlinemap.get(1).size());//鍦ㄧ嚎 + } + } + Map<Integer, List<LockInf>> openmap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockState)); + for (Integer open : openmap.keySet()) { + if(open==0){ + map.put("closeNum", openmap.get(0).size());//闂攣 + } + if(open==1){ + map.put("openNum", openmap.get(1).size());//寮�閿� + } + if(open==-1){ + map.put("unLoadNum", openmap.get(-1).size());//鏈畨瑁� + } + } + } + PageInfo pageInfo= PageInfoUtils.list2PageInfo(linfs,pageNum,pageSize); + map.put("pageInfo",pageInfo); + return new Response().setII(1,linfs!=null,map,"瀹炴椂鑾峰彇鑾峰彇鍖哄煙涓嬫墍鏈夐攣鐨勭姸鎬�"); + } } \ No newline at end of file -- Gitblit v1.9.1