大量的手机号码按照记事本格式(记事本文档里面只可以有手机号和状态)导入(手机号----状态),具体代码包括工具类的使用,可以点击下载查询。
//导出跳转@GetMapping("/phone-list-export")public ModelAndView toexport(){ModelAndView mv = getModelAndView("html/phone-list-export");return mv;}//展现数据@GetMapping("/getList")@ResponseBodypublic LayuiTable getList(int page,int limit){Page<JmPhone> phonePage=new Page<>(page,limit);QueryWrapper<JmPhone> qw=new QueryWrapper<>();qw.orderByDesc("gmt_create");IPage<JmPhone> selectPage = jmPhoneMapper.selectPage(phonePage, qw);return new LayuiTable(0,"",selectPage.getTotal(),selectPage.getRecords());}//批量上传手机号@PostMapping("/batchPhone")@ResponseBodypublic R uploadFileTxt(HttpServletRequest request) {String strPath = "/uploadFile/txt/";return FileUploadUtil.getUploadFile(request, strPath);}//批量导入手机号,开启事务@PostMapping("/importBatchPhone")@Transactional@ResponseBodypublic R importBatchPhone(String filePath, String batchId){try {jmBathService.addBatchPhone(filePath, batchId);return R.ok();} catch (Exception e) {e.printStackTrace();return R.error();}}//批量导出手机号@PostMapping("/exportphone")@ResponseBodypublic R exportBathPhone(String batchId,String status) throws IOException {String[] strBatch=batchId.split(",");QueryWrapper<JmPhone> qw=new QueryWrapper<>();qw.in("bath_id",strBatch);qw.eq("statue",status);List<JmPhone> jmPhoneList = jmPhoneMapper.selectList(qw);String text=new String();for (JmPhone j:jmPhoneList){text+=j.getPhone();text+=("----");if (j.getStatue().equals(false)){text+="未开通";}else{text+="开通";}text+=("\r\n");}//创建文本文件及存储位置TxtExport.creatTxtFile(new DateTime().toString("yyyy-MM-dd"), "D:/");TxtExport.writeTxtFile(text);return R.ok();}//删除@PostMapping("/delBatchPhone/{ids}")@ResponseBodypublic R delBatchPhone(@PathVariable String ids ){String[] strId=ids.split(",");List<String> list= Arrays.asList(strId);jmPhoneMapper.deleteBatchIds(list);return R.ok();}//查询@GetMapping("/getSearchData")@ResponseBodypublic LayuiTable getSearchData(int page,int limit,String phone,String statue,String bath_id){Page<JmPhone> phonePage=new Page<>(page,limit);QueryWrapper<JmPhone> queryWrapper=new QueryWrapper<>();if (!phone.equals("")){queryWrapper.eq("phone",phone);}if (!bath_id.equals("")){queryWrapper.eq("bath_id",bath_id);}if (!statue.equals("")){queryWrapper.eq("statue",statue);}IPage<JmPhone> jmPhoneIPage = jmPhoneMapper.selectPage(phonePage, queryWrapper);return new LayuiTable(0,"",jmPhoneIPage.getTotal(),jmPhoneIPage.getRecords());}//公共批次方法private ModelAndView getModelAndView(String toPage) {List<JmBath> jmBaths = jmBathMapper.selectList(null);ModelAndView mv = new ModelAndView(toPage);mv.addObject("batchList", jmBaths);return mv;}
详细点击:点击下载