|
@@ -507,47 +507,14 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
|
|
|
boolean flag = baseMapper.updateById(update) > 0;
|
|
|
ZEngineeringIndustryVo voById = baseMapper.selectVoById(bo.getId());
|
|
|
bo.setCreateTime(voById.getCreateTime());
|
|
|
- if (flag) {
|
|
|
- List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
- // 查询数据库中已存在的文件列表
|
|
|
- ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
- zEngiineeringPhotoBo.setParentId(update.getId());
|
|
|
- zEngiineeringPhotoBo.setCreateTime(bo.getCreateTime());
|
|
|
- List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
|
|
|
- // 插入前端传来的新文件
|
|
|
- if (!ObjectUtils.isEmpty(bo.getFiles())) {
|
|
|
- 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.getUserId()));
|
|
|
- newPhoto.setCreateTime(bo.getCreateTime());
|
|
|
- newPhoto.setUpdateTime(new Date());
|
|
|
- list.add(newPhoto);
|
|
|
- }
|
|
|
- }
|
|
|
- // 删除数据库中多余的文件
|
|
|
- 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);
|
|
|
- });
|
|
|
- }
|
|
|
- // 批量插入新图片
|
|
|
- if (!list.isEmpty()) {
|
|
|
- photoService.insertBatch(list);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
//节点表与info表
|
|
|
if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo())) {
|
|
|
bo.getzEngineeringNodeBo().setCreateTime(voById.getCreateTime());
|
|
|
- izEngineeringNodeService.update(bo.getzEngineeringNodeBo());
|
|
|
+ if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo().getzEngineeringInfoBoList())) {
|
|
|
+ izEngineeringNodeService.updateMuch(bo.getzEngineeringNodeBo());
|
|
|
+ } else {
|
|
|
+ izEngineeringNodeService.update(bo.getzEngineeringNodeBo());
|
|
|
+ }
|
|
|
}
|
|
|
return flag;
|
|
|
}
|