src/main/java/com/whyc/pojo/db_area/LockInf.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/AreaInfService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/webSocket/HomeSocket.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/pojo/db_area/LockInf.java
@@ -76,7 +76,7 @@ @ApiModelProperty(value = "屏柜品牌") private String screenBoxProduct; @ApiModelProperty(value = "是否是屏柜:0否,1是") @ApiModelProperty(value = "是否是屏柜:1是屏柜") private Integer screenFlag; @ApiModelProperty(value = "经度") src/main/java/com/whyc/service/AreaInfService.java
@@ -52,17 +52,7 @@ @Autowired(required = false) private UserInfMapper uinfMapper; //首页分组统计前10开锁次数 public Response getGroupCtlCount(int uid,int urole) { List areaList=getAllAreaUser(uid,urole); QueryWrapper wrapper=new QueryWrapper(); wrapper.in("area_id",areaList); wrapper.orderByAsc("num"); List<LockInf> list=linfMapper.selectList(wrapper); //根据用户id查询管理的锁的id List<HomeCtlGroupDto> listGroup=ctlLogMapper.getGroupCtlCount(uid); return new Response().setII(1,listGroup!=null,listGroup,"首页分组统计前10开锁次数"); } //查看当前用户管理的所有区域 public List getAllAreaUser(int uid,int urole){ @@ -479,4 +469,43 @@ PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"查询最近的开锁日志"); } //首页分组统计前10开锁次数 public Response getGroupCtlCount(int uid,int urole) { List areaList=getAllAreaUser(uid,urole); QueryWrapper wrapper=new QueryWrapper(); wrapper.in("area_id",areaList); wrapper.orderByAsc("num"); List<LockInf> list=linfMapper.selectList(wrapper); //根据用户id查询管理的锁的id List<HomeCtlGroupDto> listGroup=ctlLogMapper.getGroupCtlCount(uid); return new Response().setII(1,listGroup!=null,listGroup,"首页分组统计前10开锁次数"); } //首页统计屏柜类型 public Response getScreenBoxType(int uid,int urole) { try { List areaList=getAllAreaUser(uid,urole); QueryWrapper wrapper=new QueryWrapper(); wrapper.in("area_id",areaList); wrapper.eq("screen_flag",1);//只取屏柜 wrapper.orderByAsc("num"); List<LockInf> list=linfMapper.selectList(wrapper); Map<String, List<LockInf>> boxType = list.stream().collect(Collectors.groupingBy(LockInf::getScreenBoxType)); Map<String, Object> map = new HashMap<>(); Map<String, Object> typeMap = new HashMap<>(); for (String type : boxType.keySet()) { typeMap.put(type, boxType.get(type).size()); } map.put("type",typeMap); Map<String, List<LockInf>> productType = list.stream().collect(Collectors.groupingBy(LockInf::getScreenBoxProduct)); Map<String, Object> productMap = new HashMap<>(); for (String product : productType.keySet()) { productMap.put(product, productType.get(product).size()); } map.put("product",productMap); return new Response().setII(1,true,map,"首页统计屏柜类型"); } catch (Exception e) { return new Response().set(1,false,"首页统计屏柜类型"); } } } src/main/java/com/whyc/webSocket/HomeSocket.java
@@ -6,6 +6,7 @@ import com.whyc.pojo.db_user.UserInf; import com.whyc.service.AreaInfService; import com.whyc.service.LockCtlLogService; import com.whyc.service.LockInfService; import com.whyc.service.UserInfService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -39,6 +40,8 @@ private static AreaInfService ainfService; private static LockInfService lockInfService; @Autowired public void setLockCtlLogService(LockCtlLogService ctlLogService) { HomeSocket.ctlLogService = ctlLogService; @@ -49,6 +52,11 @@ HomeSocket.ainfService = ainfService; } @Autowired public void setLockInfService(LockInfService lockInfService) { HomeSocket.lockInfService = lockInfService; } @OnOpen public void onOpen(Session session, EndpointConfig config) { this.session = session; @@ -57,7 +65,7 @@ @OnMessage public void onMessage(Session session, String message){ /* UserInf user = (UserInf) this.httpSession.getAttribute("user"); UserInf user = (UserInf) this.httpSession.getAttribute("user"); final int userId = user.getUid(); final int urole = user.getUrole(); Thread thread = new Thread() { @@ -75,9 +83,9 @@ latch.countDown(); }); poolExecutor.execute(() -> { //基础资源信息 Response resBattInfoAnalysis = battInfService.getBattInfoAnalysis(userId); res.put("resBattInfoAnalysis", resBattInfoAnalysis); //屏柜类型 Response resScreenBox = ainfService.getScreenBoxType(userId,urole); res.put("resScreenBox", resScreenBox); latch.countDown(); }); poolExecutor.execute(() -> { @@ -89,14 +97,13 @@ }); poolExecutor.execute(() -> { //不同品牌同一时间品质和同品牌同时间品质 Response resProductQuaAnalysis = badBattMonService.getProductQuaAnalysis(userId); Response resProductQuaAnalysis = new Response(); res.put("resProductQuaAnalysis", resProductQuaAnalysis); latch.countDown(); }); poolExecutor.execute(() -> { //电池信息 Response res_battGroupInfo = new Response(); res.put("battGroupInfo", res_battGroupInfo); latch.countDown(); }); @@ -109,7 +116,7 @@ }); poolExecutor.execute(() -> { //测试信息 Response resTestdataInfAnalysis = batttestdataInfService.getTestdataInfAnalysis(userId); Response resTestdataInfAnalysis = new Response(); res.put("resTestdataInfAnalysis", resTestdataInfAnalysis); latch.countDown(); }); @@ -123,7 +130,7 @@ } }; thread.start(); this.thread = thread;*/ this.thread = thread; } @OnClose