| | |
| | | import com.whyc.pojo.db_area.AreaUser; |
| | | import com.whyc.pojo.db_area.KeyInf; |
| | | import com.whyc.pojo.db_area.LockInf; |
| | | import com.whyc.pojo.db_lock_ram.LockCtlLog; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.PageInfoUtils; |
| | |
| | | @Autowired(required = false) |
| | | private AreaUserService areaUserService; |
| | | |
| | | //查看当前用户管理的所有区域 |
| | | @Autowired(required = false) |
| | | private LockCtlLogService ctlLogService; |
| | | |
| | | |
| | | //查看当前用户管理的所有区域 |
| | | public List getAllAreaUser(int uid,int urole){ |
| | | //获取用户所管理的区域 |
| | | List<Integer> list =areaUserService.setAreaId(uid); |
| | |
| | | return new Response().setII(1,linfs!=null,linfs,"区域管理员点击指定区域查看所有的锁信息--区域管理员"); |
| | | } |
| | | |
| | | //查询所有区域下所有用户信息 |
| | | /* public Response getUinfById(Integer id, int pageNum, int pageSize) { |
| | | //获取获取id下所有的区域id |
| | | List uinfList=new ArrayList(); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("id",id); |
| | | wrapper.last("limit 1"); |
| | | AreaInf ainf=mapper.selectOne(wrapper); |
| | | if(ainf!=null){ |
| | | uinfList.add(ainf.getAreaUname()); |
| | | } |
| | | getAllUinfId(id,uinfList); |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.select("uid","uname","CREATE_TIME"); |
| | | wrapper1.in("uname",uinfList); |
| | | List<UserInf> list=uInfMapper.selectList(wrapper1); |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(list,pageNum,pageSize); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询所有区域下所有用户信息"); |
| | | }*/ |
| | | |
| | | /* //获取获取id下所有的区域用户名 |
| | | private void getAllUinfId(Integer id,List uinfList) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("parent_id",id); |
| | | List<AreaInf> list=mapper.selectList(wrapper); |
| | | if(list!=null){ |
| | | for (AreaInf painf:list) { |
| | | uinfList.add(painf.getAreaUname()); |
| | | getAllUinfId(painf.getId(),uinfList); |
| | | //区域管理员点击查看开锁操作记录--区域管理员 |
| | | public Response getCtlog(int pageNum, int pageSize) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | PageInfo pageInfo=new PageInfo(); |
| | | map.put("sumLog",0); |
| | | map.put("goodLogNum",0); |
| | | map.put("errorLogNum",0); |
| | | map.put("allLogs",pageInfo); |
| | | UserInf uinf= ActionUtil.getUser(); |
| | | //查看所有区域 |
| | | List areaList=getAllAreaUser(uinf.getUid(),uinf.getUrole()); |
| | | //查看区域下所有的锁 |
| | | QueryWrapper linfWrapper=new QueryWrapper(); |
| | | linfWrapper.in("area_id",areaList); |
| | | List<LockInf> linfs=linfMapper.selectList(linfWrapper); |
| | | if(linfs!=null&&linfs.size()>0){ |
| | | List lockIds=linfs.stream().map(LockInf::getLockId) // 提取用户名 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | //获取锁的日志 |
| | | List<LockCtlLog> logList=ctlLogService.getAllLog(lockIds); |
| | | if(logList!=null&&logList.size()>0){ |
| | | map.put("sumLog",logList.size()); |
| | | Map<Integer, List<LockCtlLog>> logmap = logList.stream().collect(Collectors.groupingBy(LockCtlLog::getCtlResult)); |
| | | for (Integer result : logmap.keySet()) { |
| | | if(result==0){ |
| | | map.put("errorLogNum", logmap.get(0).size());//失败 |
| | | } |
| | | if(result==1){ |
| | | map.put("goodLogNum", logmap.get(1).size());//成功 |
| | | } |
| | | } |
| | | pageInfo=PageInfoUtils.list2PageInfo(logList,pageNum,pageSize); |
| | | map.put("allLogs",pageInfo); |
| | | } |
| | | |
| | | } |
| | | }*/ |
| | | //查询所有区域下所有钥匙信息 |
| | | /* public Response getKinfById(Integer id, int pageNum, int pageSize) { |
| | | //获取获取id下所有的区域id |
| | | List areaList=new ArrayList(); |
| | | areaList.add(id); |
| | | getAllAreaId(id,areaList); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.in("area_id",areaList); |
| | | List<KeyInf> list=kinfMapper.selectList(wrapper); |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(list,pageNum,pageSize); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询所有区域下所有钥匙信息"); |
| | | }*/ |
| | | /* //查询所在区域下所有开锁日志 |
| | | public Response getLogById(Integer id, int pageNum, int pageSize) { |
| | | //获取获取id下所有的区域id |
| | | List areaList=new ArrayList(); |
| | | areaList.add(id); |
| | | getAllAreaId(id,areaList); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.in("area_id",areaList); |
| | | List<LockInf> lockList=linfMapper.selectList(wrapper); |
| | | List<Integer> lockIdList=lockList.stream().map(LockInf::getLockId).collect(Collectors.toList()); |
| | | QueryWrapper logwrapper=new QueryWrapper(); |
| | | wrapper.in("lock_id",lockIdList); |
| | | List<KeyInf> list=ctlLogMapper.selectList(logwrapper); |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(list,pageNum,pageSize); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询所在区域下所有开锁日志"); |
| | | }*/ |
| | | return new Response().setII(1,true,map,"区域管理员点击查看开锁操作记录--区域管理员"); |
| | | } |
| | | |
| | | |
| | | } |