|  |  | 
 |  |  |                     .collect(Collectors.joining(",")); | 
 |  |  |             supervision.setImages(image); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         supervisionMapper.insert(supervision); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  | 
 |  |  |  | 
 |  |  |         List<String> images = new ArrayList<>(); | 
 |  |  |  | 
 |  |  |         System.out.println(files.size()); | 
 |  |  |         //如果上传了图片,就覆盖之前图片,删除服务器中图片 | 
 |  |  |         if (files.size() > 0) { | 
 |  |  |             //删除服务器中的原来督办单中图片 | 
 |  |  |             String[] oldImages = supervisionMapper.selectById(supervision.getId()).getImages().split(","); | 
 |  |  |             for (String image : oldImages) { | 
 |  |  |                 String realPath = path + File.separator + image; | 
 |  |  |                 File file = new File(realPath); | 
 |  |  |                 if (file.exists() && file.isFile()) { | 
 |  |  |                     file.delete(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             for (MultipartFile file : files) { | 
 |  |  |                 //判断上传文件格式 | 
 |  |  |                 String fileType = file.getContentType(); | 
 |  |  |                 if ("image/jpg".equals(fileType) || "image/png".equals(fileType) || "image/jpeg".equals(fileType)) { | 
 |  |  |                     //获取文件类型 | 
 |  |  |                     String contentType = file.getContentType(); | 
 |  |  |                     //获取文件名 | 
 |  |  |                     String fileName = file.getOriginalFilename(); | 
 |  |  |                     //获取文件后缀名 | 
 |  |  |                     String suffixName = contentType.substring(contentType.lastIndexOf("/")).replace("/", "."); | 
 |  |  |                     String suffixName = fileName.substring(fileName.lastIndexOf(".")); | 
 |  |  |                     //重新生成文件名 | 
 |  |  |                     String fileName = UUID.randomUUID() + suffixName; | 
 |  |  |                     fileName = UUID.randomUUID() + suffixName; | 
 |  |  |                     //图片上传 | 
 |  |  |                     if (FileUtils.upload(file, path, fileName)) { | 
 |  |  |                         images.add(fileName); | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         if (!ObjectUtils.isEmpty(images)) { | 
 |  |  |             //删除服务器中的原来督办单中图片 | 
 |  |  |             for (String image : images) { | 
 |  |  |                 String realPath = path + File.separator + image; | 
 |  |  |                 File file = new File(realPath); | 
 |  |  |                 if (file.exists() && file.isFile()) { | 
 |  |  |                     file.delete(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             String image = images.stream() | 
 |  |  |                     .map(String::valueOf) | 
 |  |  |                     .collect(Collectors.joining(",")); |