美文网首页
List集合根据条件删除数据

List集合根据条件删除数据

作者: 码天下 | 来源:发表于2020-05-25 16:53 被阅读0次

    1.根据条件删除List集合里面的数据。这里以dataAllList为列子

        @Override
        public MyPageInfo<AdminStationVO> findAdminStationList(Integer uid, PageParams params,
                AdminStationVO adminStationVO) {
            System.out.println("adminStationVO 传进来的参数"+adminStationVO);
    //      try {
            //权限校验
            Integer stationUid = ValidUtils.AdminStation(uid);
            //station返回2,说明有权限,0没有权限 
            List<AdminStationVO> newDataList=new ArrayList<AdminStationVO>();
            //封装数据
            List<AdminStationVO> dataAllList=new ArrayList<AdminStationVO>();
            Integer ischeck = adminStationVO.getIscheck();
            Integer instorage = adminStationVO.getInstorage();//未入库
            Integer isExpirationEmpty = adminStationVO.getIsExpirationEmpty();
            System.out.println("isExpirationEmpty11111111"+isExpirationEmpty);
            Integer expireDateStatus=null;
            Integer picturestatus = adminStationVO.getPicturestatus();
            Integer videostatus = adminStationVO.getVideostatus();
            Integer platformstatus = adminStationVO.getPlatformstatus();
            Integer keyamount = adminStationVO.getKeyamount();//序列号数量
            Integer serialamount = adminStationVO.getSerialamount();//终端设备数量
            String salesman = adminStationVO.getSalesman();//业务员
            String channel = adminStationVO.getChannel();
            String username = adminStationVO.getUsername();//用户名
            String stationname = adminStationVO.getStationname();
            if(stationUid==2) {
                //查询所有的机构   findDepartName
                String deptName = adminStationVO.getDeptName();
                List<Department> findDepartName = departmentService.findDepartName(uid, deptName);
                
                
                for (Department department : findDepartName) {
                    AdminStationVO adminStation=new AdminStationVO();
                    adminStation.setId(adminStationVO.getId());
                    adminStation.setStationname(adminStationVO.getStationname());
                    adminStation.setStationStarTime(adminStationVO.getStationStarTime());
                    adminStation.setStationEndTime(adminStationVO.getStationEndTime());
                    adminStation.setDeptid(department.getId());
                    adminStation.setDeptName(department.getDeptName());
                    adminStation.setStarTime(adminStationVO.getStarTime());
                    adminStation.setEndTime(adminStationVO.getEndTime());
                    adminStation.setIsExpirationEmpty(adminStationVO.getIsExpirationEmpty());//到期时间是否为空
                    System.out.println("adminStationVO.getStationStarTime() 开始时间"+adminStationVO.getStationStarTime());
                    System.out.println("adminStationVO.getStationEndTime() 结束时间"+adminStationVO.getStationEndTime());
                        //通过磅点 磅点名称,磅点的时间,磅点id
                        List<AdminStationVO> findIdDateNameAll = mapper.findIdDateNameAll(adminStation);    
                        System.out.println("findIdDateNameAll"+findIdDateNameAll);
                        for (int i = 0; i < findIdDateNameAll.size(); i++) {//findfuncidStatus
                                //磅点查询机构 获取 机构名称
                                Department findStationDpName = departmentMapper.findStationDpName(findIdDateNameAll.get(i).getId());
                                if(findStationDpName !=null) {
                                    findIdDateNameAll.get(i).setDeptName(findStationDpName.getDeptName());
                                }
                                //查询功能码
                                List<Integer> findfuncidStatus = stationFuncMapper.findfuncidStatus(findIdDateNameAll.get(i).getId());
                                findIdDateNameAll.get(i).setFuncStatus(findfuncidStatus);
                                //查询业务员
                                Salesman findStationById = salesmanMapper.findStationById(findIdDateNameAll.get(i).getId());
                                Integer channelId =null;
                                if(findStationById !=null) {
                                    findIdDateNameAll.get(i).setSalesman(findStationById.getSalesman());
                                    findIdDateNameAll.get(i).setPhone(findStationById.getPhone());
                                    findIdDateNameAll.get(i).setChannelid(findStationById.getChannelId());
                                    channelId = findStationById.getChannelId();//获取业务员对应的渠道id   
                                }
                                //查询渠道表
                                Cannel findSalesmanId = cannelMapper.findSalesmanId(channelId);
                                System.out.println("findSalesmanId 渠道"+findSalesmanId);
                                if(findSalesmanId !=null) {
                                    findIdDateNameAll.get(i).setChannel(findSalesmanId.getChannel());
                                }
                                //查询加密狗获取审核人信息,授权过期时间(激活到期时间),授权提交时间(激活时间)findStationidData
                                expireDateStatus = adminStationVO.getExpireDateStatus();//判断激活已到期的 状态
                                AuthorizeKey findStationidData = authorizeKeyMapper.findStationidData(findIdDateNameAll.get(i).getId(),ischeck,instorage,expireDateStatus);
                                if(findStationidData !=null) {
                                    findIdDateNameAll.get(i).setChecker(findStationidData.getChecker());
                                    findIdDateNameAll.get(i).setCheckdate(findStationidData.getCheckDate());
                                    findIdDateNameAll.get(i).setIscheck(findStationidData.getIsCheck());
                                    findIdDateNameAll.get(i).setInstorage(findStationidData.getInStorage());
                                    findIdDateNameAll.get(i).setAkexpiredate(findStationidData.getExpireDate());
                                }
                                //查询磅点对应的操作人员  findOperratorNew
                                Operrator findOperratorNew = operratorMapper.findOperratorNew(findIdDateNameAll.get(i).getId());
                                if(findOperratorNew !=null) {
                                    findIdDateNameAll.get(i).setOperator(findOperratorNew.getOperator());
                                    findIdDateNameAll.get(i).setTime(findOperratorNew.getTime());
                                }   
                                //用户名查询磅点信息
                                User findStationIdUserData = userMapper.findStationIdUserData(findIdDateNameAll.get(i).getId(),username);
                                if(findStationIdUserData !=null) {
                                    findIdDateNameAll.get(i).setUsername(findStationIdUserData.getUsername());
                                }
                        }
                        //通过磅点查询业务员
                        dataAllList.addAll(findIdDateNameAll);
                        //System.out.println("dataAllList"+dataAllList);
                    }
                }
            System.out.println("dataAllList"+dataAllList);
                //判断勾选的状态
            AdminStationVO adminData =null; 
            //判断用户
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                     AdminStationVO nextdata = iterator.next();
                    if(username !=null) {
                        String usernameData = nextdata.getUsername();
                        if(usernameData==null || !username.equals(usernameData)) {
                            iterator.remove();
                        }
                    }
                }
            }
            
            //判断渠道
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(channel !=null) {
                        String channelData = adminData.getChannel();
                        if(channelData==null || !channel.equals(channelData)) {
                            iterator.remove();
                        }
                    }
                }
            }
            //判断业务员是否存在数据
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(salesman !=null) {//salesman
                        String salesmanName = adminData.getSalesman();
                        if(salesmanName==null || !salesman.equals(salesmanName)) {
                            iterator.remove();
                        }
                    }
                }
            }
            //判断设备数量
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(serialamount !=null) {
                        Integer serialaCount = adminData.getSerialamount();
                        if(serialamount<serialaCount) {
                            iterator.remove();
                        }
                    }
                }
            }
            //判断加密狗数量
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(keyamount !=null) {
                        Integer keyCount = adminData.getKeyamount();
                        if(keyamount<keyCount) {
                            iterator.remove();
                        }
                    }
                }
            }
            //判断开通平台
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(platformstatus !=null) {
                        if(platformstatus==0) {//不开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            for (Integer integer : funcStatus) {
                                if(integer==1) {
                                    iterator.remove();
                                }
                            }
                        }else if(platformstatus==1) {//开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            if(!funcStatus.contains(1)) {
                                iterator.remove();
                            }
                        }
                    }
                }
            }
            //判断开通视频
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(videostatus !=null) {
                        if(videostatus==0) {//不开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            for (Integer integer : funcStatus) {
                                if(integer==3) {
                                    iterator.remove();
                                }
                            }
                        }else if(videostatus==3) {//开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            if(!funcStatus.contains(3)) {
                                iterator.remove();
                            }
                        }
                    }
                }
            }   
            //判断开通图片
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(picturestatus !=null) {
                        if(picturestatus==0) {//不开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            for (Integer integer : funcStatus) {
                                if(integer==2) {
                                    iterator.remove();
                                }
                            }
                        }else if(picturestatus==2) {//开通
                            List<Integer> funcStatus = adminData.getFuncStatus();
                            if(!funcStatus.contains(2)) {
                                iterator.remove();
                            }
                        }
                    }
                }
            }
            //判断加密狗审核
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(ischeck !=null) {
                        if(ischeck.equals(0)) {
                            if(adminData.getIscheck() != null) {
                                iterator.remove();
                            }
                        }else if(ischeck.equals(2)) {
                            if(adminData.getIscheck() == null) {
                                iterator.remove();
                            }
                        }
                    }
                }
            }
            //判断加密狗未入库有错吴
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(instorage !=null) {
                        if(instorage.equals(0)) {
                            if(adminData.getInstorage() == null || adminData.getInstorage() != 0) {
                                iterator.remove();
                            }
                        }else if(instorage.equals(1)) {
                            if(adminData.getInstorage() == null || adminData.getInstorage() != 1) {
                                iterator.remove();
                            }
                        }
                    }
                }
            }
            //判断加密狗是否过期
            if(dataAllList !=null && dataAllList.size()>0) {
                Iterator<AdminStationVO> iterator = dataAllList.iterator();     
                while (iterator.hasNext()) {
                    adminData = (AdminStationVO) iterator.next();
                    if(isExpirationEmpty !=null) {
                        if(isExpirationEmpty==0) {
                            if(adminData.getAkexpiredate()!=null) {
                                System.out.println("1111111111");
                                iterator.remove();
                            }
                        }else if(isExpirationEmpty==1) {
                            if(adminData.getAkexpiredate()==null) {
                                System.out.println("222222");
                                iterator.remove();
                            }
                        }
                    }
                }
            }       
            System.out.println("dataAllList"+dataAllList);
            List<AdminStationVO> startPage = PageUtil.startPage(dataAllList, params.getPageNum(), params.getPageSize());
            MyPageInfo<AdminStationVO> myPageInfo = new MyPageInfo<AdminStationVO>(params.getPageNum(),dataAllList.size(),startPage);
            return myPageInfo;
    //      } catch (Exception e) {
    //          throw new MyException("对不起。请选择正确的磅点");
    //      }
        }
    

    相关文章

      网友评论

          本文标题:List集合根据条件删除数据

          本文链接:https://www.haomeiwen.com/subject/zfayahtx.html