|
@@ -12,10 +12,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.framework.handler.MonthTableNameHandler;
|
|
import com.ruoyi.framework.handler.MonthTableNameHandler;
|
|
import com.ruoyi.zdsz.domain.ZEngiineeringPhoto;
|
|
import com.ruoyi.zdsz.domain.ZEngiineeringPhoto;
|
|
import com.ruoyi.zdsz.domain.ZEngineeringIndustry;
|
|
import com.ruoyi.zdsz.domain.ZEngineeringIndustry;
|
|
-import com.ruoyi.zdsz.domain.bo.ZEngiineeringPhotoBo;
|
|
|
|
-import com.ruoyi.zdsz.domain.bo.ZEngineeringIndustryBo;
|
|
|
|
-import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
|
|
|
|
-import com.ruoyi.zdsz.domain.bo.ZFileBo;
|
|
|
|
|
|
+import com.ruoyi.zdsz.domain.bo.*;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngiineeringPhotoVo;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngiineeringPhotoVo;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryTypeVo;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryTypeVo;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryVo;
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryVo;
|
|
@@ -145,6 +142,7 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
|
|
* 修改工业工程|市政工程
|
|
* 修改工业工程|市政工程
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean updateByBo(ZEngineeringIndustryBo bo) {
|
|
public Boolean updateByBo(ZEngineeringIndustryBo bo) {
|
|
ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
|
|
ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
@@ -209,53 +207,60 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
|
|
* 修改工业工程|市政工程
|
|
* 修改工业工程|市政工程
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean updateNodeByBo(ZEngineeringIndustryBo bo) {
|
|
public Boolean updateNodeByBo(ZEngineeringIndustryBo bo) {
|
|
ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
|
|
ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
|
|
boolean flag = baseMapper.updateById(update) > 0;
|
|
boolean flag = baseMapper.updateById(update) > 0;
|
|
if (flag){
|
|
if (flag){
|
|
- List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
|
- // 查询数据库中已存在的文件列表
|
|
|
|
- ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
|
- zEngiineeringPhotoBo.setParentId(update.getId());
|
|
|
|
- List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream()
|
|
|
|
- .map(ZEngiineeringPhotoVo::getPicUrl)
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- // 插入前端传来的新文件
|
|
|
|
- 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.setCreateTime(bo.getCreateTime());
|
|
|
|
- newPhoto.setUpdateTime(new Date());
|
|
|
|
- list.add(newPhoto);
|
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(bo.getFiles())){
|
|
|
|
+ List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
|
+ // 查询数据库中已存在的文件列表
|
|
|
|
+ ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
|
+ zEngiineeringPhotoBo.setParentId(update.getId());
|
|
|
|
+ List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream()
|
|
|
|
+ .map(ZEngiineeringPhotoVo::getPicUrl)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ // 插入前端传来的新文件
|
|
|
|
+ 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.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);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // 删除数据库中多余的文件
|
|
|
|
- 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);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- bo.getzEngineeringNodeBoList().stream().forEach(item->{
|
|
|
|
- item.setCivliId(bo.getId());
|
|
|
|
- item.setCreateTime(bo.getCreateTime());
|
|
|
|
- item.setType(bo.getType());
|
|
|
|
- izEngineeringNodeService.updateMuch(item);
|
|
|
|
- });
|
|
|
|
|
|
+ List<ZEngineeringInfoBo> engineeringInfoBoList1 = bo.getzEngineeringNodeBo().getzEngineeringInfoBoList();
|
|
|
|
+ if (engineeringInfoBoList1!=null&&!engineeringInfoBoList1.isEmpty()){
|
|
|
|
+ nodeService.updateMuch(bo.getzEngineeringNodeBo());
|
|
|
|
+ }
|
|
|
|
+// bo.getzEngineeringNodeBoList().stream().forEach(item->{
|
|
|
|
+// item.setCivliId(bo.getId());
|
|
|
|
+// item.setCreateTime(bo.getCreateTime());
|
|
|
|
+// item.setType(bo.getType());
|
|
|
|
+// izEngineeringNodeService.updateMuch(item);
|
|
|
|
+// });
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -271,6 +276,7 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
|
|
* 批量删除工业工程|市政工程
|
|
* 批量删除工业工程|市政工程
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
|
|
|
|
|
ids.forEach(item -> {
|
|
ids.forEach(item -> {
|