java将文件夹md5为名的图片与数据库查询对应md5后导入相应图片到某分类下

   public class FolderUtil {
  /** * @param path * @return * 得到目录下的文件 */ public List<String> getDirectoryFile(String path){ List<String> retList=new ArrayList<String>(); File dir = new File(path); File[] files = dir.listFiles(); if (files == null) return null; for (int i = 0; i < files.length; i++) { if (!files[i].isDirectory()) { retList.add(files[i].getName()); } } return retList; }
}
    public void import3(){
        
        String path="D:/tt/yangtry";        
        FolderUtil fu=new FolderUtil();
        List<String> imgList=fu.getDirectoryFile(path);
                    
        System.out.println("jpg总数量:"+imgList.size());
        
        int i=0;
        for(String imgName:imgList){
            i++;
            System.out.println(i);            
            String imgMD5 = imgName.split("\\.")[0];            
            //System.out.println(imgMD5);            
            
            ImgCenterFilter filterImc = new ImgCenterFilter();
            filterImc.setEq_imgMd5(imgMD5);
            ImgCenter imgCenter = imgCenterService.selectAll(filterImc).get(0);
            String caseId= imgCenter.getCaseId();
            ImgCase imgCase = imgCaseService.getById(caseId);
                        
            TagImg  newImg=new TagImg();
              
              newImg.setSetId("d0d86b8b52aa4df9a06bc3db57ed19d3");
              newImg.setTypeId("56240f330eff4c049b19d0c7ce156647");
              newImg.setOrgId("81dae004980145ffbd261717b49f35b6");
            //imc.id,imc.img_md5,imc.img_url,imc.img_url_thumb,imc.thumb_width,imc.thumb_height,c.img_info,c.img_result                         
             
              newImg.setImportId(imgCenter.getId());
              newImg.setImgMd5(imgMD5);
              newImg.setImgUrl(imgCenter.getImgUrl());
              newImg.setImgUrlThumb(imgCenter.getImgUrlThumb());
              newImg.setThumbw(imgCenter.getThumbWidth());
              newImg.setThumbh(imgCenter.getThumbHeight());
              newImg.setRemark(imgCase.getImgInfo());//影响描述              
              newImg.setCreateUser("2018-06-22");                
              newImg.setDiagnosis(imgCase.getImgResult());//诊断意见
        
              tagImgService.save(newImg);
              
        }        
    }

 

posted @ 2019-02-12 11:55  yangly  阅读(354)  评论(0编辑  收藏  举报