1. 程式人生 > >java將文件夾md5為名的圖片與數據庫查詢對應md5後導入相應圖片到某分類下

java將文件夾md5為名的圖片與數據庫查詢對應md5後導入相應圖片到某分類下

getc selectall height user save etc jpg span filter

   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); } }

java將文件夾md5為名的圖片與數據庫查詢對應md5後導入相應圖片到某分類下