java研发手机归属地批量查询

需求:通过一个手机号可以查出手机号的归属地,网上是可以查的,但是10万个手机捏?当然你有1万个员工,每人帮你查10个,也算还可以。相形见绌,运用程序帮你查分分钟事情,接下来教大家如何用java批量查询手机归属地,当然代码还可以继续优化的,没有使用多线程,效率有所慢一些。

思路:excel读取——数据库查询手机归属地——excel写出
这里写图片描述

代码:

File f2003 = new File(filePath);
        try {
            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            List<List<Object>> lists = _excelUtil.readExcel(f2003);
            for(int i = 0;i<lists.size();i++){
                String result02 = insertQuestions2ForExcel(lists.get(i),paperId,questionNoNum);
                String[] result02_ = result02.split(",");
                if(result02_.length == 4){
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("CODEA", result02_[0]);
                    map.put("CODEB", result02_[1]);
                    map.put("CODEC", result02_[2]);
                    map.put("CODED", result02_[3]);
                    list.add(map);
                }
            }
            /*final List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            List<List<Object>> lists = _excelUtil.readExcel(f2003);
            ExecutorService executorService=Executors.newFixedThreadPool(10);
            for(final List<Object> listss : lists){
                executorService.execute(new Runnable() {
                    public synchronized void run() {
                        Map<String, Object> map = null;
                        String result02 = insertQuestions2ForExcel(listss,paperId,questionNoNum);
                        String[] result02_ = result02.split(",");
                        if(result02_.length == 4){
                            map = new HashMap<String, Object>();
                            map.put("CODEA", result02_[0]);
                            map.put("CODEB", result02_[1]);
                            map.put("CODEC", result02_[2]);
                            map.put("CODED", result02_[3]);
                            list.add(map);
                        }
                    }
                }); 
                try {
                    Thread.sleep(100); 
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            executorService.shutdown();*/



            LinkedHashMap<String, String> titleMap = new LinkedHashMap<String, String>();
            titleMap.put("CODEA", "姓名");
            titleMap.put("CODEB", "手机");
            titleMap.put("CODEC", "省份");
            titleMap.put("CODED", "城市");

            FileOutputStream out = new FileOutputStream("D:/33.xls");
            try {
                _excelUtil.exportCommonExcel(null, titleMap, list, out);
            } catch (Exception e) {
                e.printStackTrace();
            }

            System.out.println("导出成功!");
        } catch (IOException e) {
            e.printStackTrace();
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值