|
@@ -117,15 +117,17 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
ZEngineeringNode entity = izEngineeringNodeService.insert(bo.getzEngineeringNodeBo());
|
|
|
if (!ObjectUtil.isEmpty(entity)) {
|
|
|
List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
- bo.getPics().stream().forEach(o -> {
|
|
|
- ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
- pic.setParentId(bo.getId());
|
|
|
- pic.setPicUrl(o.getPicUrl());
|
|
|
- pic.setUpdateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
- pic.setUpdateTime(new Date());
|
|
|
- pic.setCreateTime(bo.getCreateTime());
|
|
|
- list.add(pic);
|
|
|
- });
|
|
|
+ if (!ObjectUtils.isEmpty(bo.getFiles())) {
|
|
|
+ bo.getFiles().stream().forEach(o -> {
|
|
|
+ ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
+ pic.setParentId(bo.getId());
|
|
|
+ pic.setPicUrl(o.getUrl());
|
|
|
+ pic.setUpdateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
+ pic.setUpdateTime(new Date());
|
|
|
+ pic.setCreateTime(bo.getCreateTime());
|
|
|
+ list.add(pic);
|
|
|
+ });
|
|
|
+ }
|
|
|
if (!list.isEmpty()) {
|
|
|
photoService.insertBatch(list);
|
|
|
}
|
|
@@ -152,34 +154,40 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
if (i > 0) {
|
|
|
List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
|
|
|
- // 查询数据库中已存在的文件列表
|
|
|
- ZEngiineeringPhotoBo bo1 = new ZEngiineeringPhotoBo();
|
|
|
- bo1.setParentId(update.getId());
|
|
|
- List<String> existingPhotos = photoService.queryList(bo1).stream()
|
|
|
- .map(ZEngiineeringPhotoVo::getPicUrl)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ if (!ObjectUtils.isEmpty(bo.getFiles())) {
|
|
|
+ // 查询数据库中已存在的文件列表
|
|
|
+ ZEngiineeringPhotoBo bo1 = new ZEngiineeringPhotoBo();
|
|
|
+ bo1.setParentId(update.getId());
|
|
|
+ List<String> existingPhotos = photoService.queryList(bo1).stream()
|
|
|
+ .map(ZEngiineeringPhotoVo::getPicUrl)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- // 插入前端传来的新文件
|
|
|
- for (ZEngiineeringPhotoVo pic : bo.getPics()) {
|
|
|
- if (!existingPhotos.contains(pic.getPicUrl())) {
|
|
|
- ZEngiineeringPhoto newPhoto = new ZEngiineeringPhoto();
|
|
|
- newPhoto.setParentId(bo.getId());
|
|
|
- newPhoto.setPicUrl(pic.getPicUrl());
|
|
|
- newPhoto.setFileName(pic.getFileName());
|
|
|
- newPhoto.setCreateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
- newPhoto.setCreateTime(new Date());
|
|
|
- list.add(newPhoto);
|
|
|
+ for (ZFileBo pic : bo.getFiles()) {
|
|
|
+ if (!existingPhotos.contains(pic.getUrl())) {
|
|
|
+ ZEngiineeringPhoto newPhoto = new ZEngiineeringPhoto();
|
|
|
+ newPhoto.setParentId(bo.getId());
|
|
|
+ newPhoto.setPicUrl(pic.getUrl());
|
|
|
+ newPhoto.setFileName(pic.getName());
|
|
|
+ newPhoto.setCreateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
+ newPhoto.setUpdateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
+ newPhoto.setCreateTime(bo.getCreateTime());
|
|
|
+ newPhoto.setUpdateTime(new Date());
|
|
|
+ list.add(newPhoto);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 删除数据库中多余的文件
|
|
|
- List<String> photosToDelete = existingPhotos.stream()
|
|
|
- .filter(pic -> !bo.getPics().stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList()).contains(pic))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!photosToDelete.isEmpty()) {
|
|
|
- photosToDelete.forEach(item -> {
|
|
|
- photoService.deleteWithValidByurls(item);
|
|
|
- });
|
|
|
+ // 删除数据库中多余的文件
|
|
|
+ List<String> photosToDelete = existingPhotos.stream()
|
|
|
+ .filter(pic -> !bo.getFiles().stream().map(ZFileBo::getUrl).collect(Collectors.toList()).contains(pic))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!photosToDelete.isEmpty()) {
|
|
|
+ photosToDelete.forEach(item->{
|
|
|
+ ZEngiineeringPhoto zEngiineeringPhoto=new ZEngiineeringPhoto();
|
|
|
+ zEngiineeringPhoto.setPicUrl(item);
|
|
|
+ zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
|
|
|
+ photoService.deleteWithValid(zEngiineeringPhoto);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 批量插入新图片
|
|
@@ -285,12 +293,12 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 插入前端传来的新文件
|
|
|
- for (ZEngiineeringPhotoVo pic : bo.getPics()) {
|
|
|
- if (!existingPhotos.contains(pic.getPicUrl())) {
|
|
|
+ for (ZFileBo pic : bo.getFiles()) {
|
|
|
+ if (!existingPhotos.contains(pic.getUrl())) {
|
|
|
ZEngiineeringPhoto newPhoto = new ZEngiineeringPhoto();
|
|
|
- newPhoto.setParentId(bo.getId());
|
|
|
- newPhoto.setPicUrl(pic.getPicUrl());
|
|
|
- newPhoto.setFileName(pic.getFileName());
|
|
|
+ newPhoto.setParentId(update.getId());
|
|
|
+ newPhoto.setPicUrl(pic.getUrl());
|
|
|
+ newPhoto.setFileName(pic.getName());
|
|
|
newPhoto.setCreateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
newPhoto.setUpdateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
newPhoto.setCreateTime(bo.getCreateTime());
|