From 6685e334ec678617ef12712801f6a0d0bb8de188 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Mon, 26 Jul 2021 14:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xkrs/model/entity/FireTaskPhoto.java | 2 +- .../com/xkrs/service/impl/FirePointServiceImpl.java | 5 +++-- src/main/java/com/xkrs/utils/PhotoUtil.java | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/xkrs/model/entity/FireTaskPhoto.java b/src/main/java/com/xkrs/model/entity/FireTaskPhoto.java index 3113346..d22cc6e 100644 --- a/src/main/java/com/xkrs/model/entity/FireTaskPhoto.java +++ b/src/main/java/com/xkrs/model/entity/FireTaskPhoto.java @@ -14,7 +14,7 @@ public class FireTaskPhoto implements Serializable { * id 主键 */ @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_task_photo_seq_gen") + @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "fire_task_photo_seq_gen") @SequenceGenerator(name = "fire_task_photo_seq_gen", sequenceName = "fire_task_photo_id_seq",allocationSize = 1) private Integer id; diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 0cd37b7..88c1756 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -214,8 +214,9 @@ public class FirePointServiceImpl implements FirePointService { return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"任务提交失败",locale); } List fireTaskPhotos = PhotoUtil.uploadImage(files, appTaskBodyVo.getFireCode()); - List fireTaskPhotos1 = jdbcUtils.batchWithJdbcTemplate(fireTaskPhotos); - if(fireTaskPhotos1.size() == 0 || fireTaskPhotos1 == null){ + List fireTaskPhotos1 = fireTaskPhotoDao.saveAll(fireTaskPhotos); + //List fireTaskPhotos1 = jdbcUtils.batchWithJdbcTemplate(fireTaskPhotos); + if(fireTaskPhotos1 == null || fireTaskPhotos1.size() == 0){ return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"图片上传失败,任务提交失败",locale); } return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"任务提交成功",locale); diff --git a/src/main/java/com/xkrs/utils/PhotoUtil.java b/src/main/java/com/xkrs/utils/PhotoUtil.java index 35dda85..86ff2f8 100644 --- a/src/main/java/com/xkrs/utils/PhotoUtil.java +++ b/src/main/java/com/xkrs/utils/PhotoUtil.java @@ -64,7 +64,8 @@ public class PhotoUtil { * @throws IOException */ public static List uploadImage(MultipartFile[] files, String fireCode) throws IOException { - String uploadPath = "http://139.199.98.175:2099/forestTaskImage/"; + //String uploadPath = "http://139.199.98.175:2099/forestTaskImage/"; + String uploadPath = "http://192.168.2.139/"; String newName = ""; String oldName = ""; List fireTaskPhotos = new ArrayList<>(); @@ -78,13 +79,13 @@ public class PhotoUtil { //uuid生成新的文件名 newName = UUID.randomUUID().toString() + suffix; //将图片保存到本地/usr/etc/images/Folder - File file1 = new File("/home/web/wf-fire-service/forestTaskImage/"); - //File file1 = new File("E:/wfTaskImage/"); + //File file1 = new File("/home/web/wf-fire-service/forestTaskImage/"); + File file1 = new File("E:/file/work/image/"); if (!file1.exists()) { file1.mkdirs(); } - String path = "/home/web/wf-fire-service/forestTaskImage/" + newName; - //String path = "E:/wfTaskImage/" + newName; + //String path = "/home/web/wf-fire-service/forestTaskImage/" + newName; + String path = "E:/file/work/image/" + newName; String uploadPaths = uploadPath + newName; //实现上传 file.transferTo(new File(path));