zoukankan      html  css  js  c++  java
  • java-查询图片url导出到本地

    SQL查询语句附给一个变量list,遍历,取每个图片的url,定义本地路径,fastdfsService的copyFileFromDfs方法将图片下载到本地。

    public void import1() {
            /**
             * SELECT
             * imc.id,imc.img_md5,imc.img_url,imc.thumb_width,imc.thumb_height
             * ,imc.img_url_thumb,c.serial_number from img_center imc left join
             * img_case c on imc.case_id=c.id where
             * source_id='8310f5b97fe54a6495688263fa6ca928' and c.create_user =
             * '2-2-1'
             * 
             * SELECT
             * imc.id,imc.img_md5,imc.img_url,imc.thumb_width,imc.thumb_height
             * ,imc.img_url_thumb from img_center imc left join img_case c on
             * imc.case_id=c.id where source_id='8310f5b97fe54a6495688263fa6ca928'
             * and c.create_user='正常'
             * 
             * SELECT
             * imc.id,imc.img_md5,imc.img1024_url,imc.thumb_width,imc.thumb_height
             * ,imc.img_url_thumb,c.img_info from img_center imc left join img_case
             * c on imc.case_id=c.id where
             * c.source_id='8310f5b97fe54a6495688263fa6ca928' and imc.img_md5
             * in(SELECT img_md5 FROM tag_img WHERE
             * type_id='740bc5fb849f451fad666dae1dcbb0f0' AND tag_json IS NOT NULL)
             */
    
            //TagImgFilter filter = new TagImgFilter();
            //filter.setEq_typeId("413f225ed6a745c2b88cfb5d6053fc1d");
            //filter.setNull_tagJson(false);
    
            //List<Map<String, Object>> list = jdbcTemplate
            //        .queryForList("SELECT t.img_md5,imc.img1024_url FROM tag_img t LEFT JOIN img_center imc ON t.img_md5=imc.img_md5 WHERE t.type_id='5d8f5f9aecb14e54aef64f55aec57b5b' and t.del_flag=1 and t.tag_flag=1 and imc.del_flag=1");
            /*List<Map<String, Object>> list = jdbcTemplate
                    .queryForList("SELECT t.id,imc.img1024_url FROM tag_img t LEFT JOIN img_center imc ON t.img_md5=imc.img_md5 WHERE type_id='5976d4dda1e141c181d3e7bdaba7ae9f' AND t.del_flag=1 AND t.img_md5 NOT IN (SELECT img_md5 FROM tag_img WHERE set_id='6f2b4c77fdab4137aeabda9282c0c597' AND del_flag=1)");
    */
            List<Map<String, Object>> list = jdbcTemplate
                    .queryForList("SELECT id,img_url FROM tag_img WHERE type_id='672497aee4a84a49b78a60b78602166e' and del_flag=1 and tag_flag=1");
    
            int i = 0;
    
            for (Map<String, Object> tagimg : list) {
                //String img1024Url = tagimg.get("img1024_url").toString();//获取img1024_url
                String imgUrl = tagimg.get("img_url").toString();
                //String imgMD5 = tagimg.get("img_md5").toString();
                String id = tagimg.get("id").toString();
                i++;
                System.out.println(i);
                //System.out.println(i+ "_" +imgMD5);
    
                System.out.println(imgUrl);
                String path = "D:/downloadjpg/yang";
                //String localPath = path + "/" + imgMD5 + ".jpg";
                //String localPath = path + "/" + i + "_" +imgMD5 + ".jpg";
                String localPath = path + "/" + id +".jpg";
                
                //fastdfsService.copyFileFromDfs(img1024Url, localPath);
                fastdfsService.copyFileFromDfs(imgUrl, localPath);
            }
  • 相关阅读:
    .net core web api swagger 配置笔记
    mvc下ajax请求遇到session超时简单处理方式
    sql ltrim/rtrim 字段中为中文时出现?的问题
    SQL 将一个字段内用逗号分隔的内容分成多条记录
    bootstrap下modal模态框中webuploader控件按钮异常(无法点击)问题解决办法【转】
    mvc 封装控件使用mvcpager
    uploadify在chrome下初始化失败,在Firefox下却可以原因探析
    MVC FormCollection 无法获取值的问题
    linq to sql之like
    mvcpager 表单提交时无法获取pageindex的值
  • 原文地址:https://www.cnblogs.com/lely/p/10242598.html
Copyright © 2011-2022 走看看