浏览代码

修改添加工程后历史施工多出一个

JX.Li 1 年之前
父节点
当前提交
ea9013d4b1
共有 1 个文件被更改,包括 32 次插入43 次删除
  1. 32 43
      ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/impl/ZEngineeringIndustryServiceImpl.java

+ 32 - 43
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/impl/ZEngineeringIndustryServiceImpl.java

@@ -50,6 +50,7 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
 
     @Resource
     private IZEngiineeringPhotoService photoService;
+
     /**
      * 查询工业工程|市政工程
      */
@@ -119,7 +120,7 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
         if (flag) {
             bo.setId(add.getId());
             List<ZEngiineeringPhoto> list = new ArrayList<>();
-            bo.getFiles().forEach(o->{
+            bo.getFiles().forEach(o -> {
                 ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
                 pic.setParentId(bo.getId());
                 pic.setPicUrl(o.getUrl());
@@ -132,9 +133,11 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
                 photoService.insertBatch(list);
             }
         }
-        bo.getzEngineeringNodeBo().setCivliId(add.getId());
-        bo.getzEngineeringNodeBo().setCreateTime(new Date());
-        izEngineeringNodeService.insert(bo.getzEngineeringNodeBo());
+        if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo())) {
+            bo.getzEngineeringNodeBo().setCivliId(add.getId());
+            bo.getzEngineeringNodeBo().setCreateTime(new Date());
+            izEngineeringNodeService.insert(bo.getzEngineeringNodeBo());
+        }
         return flag;
     }
 
@@ -147,17 +150,15 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
         ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
         validEntityBeforeSave(update);
         boolean flag = baseMapper.updateById(update) > 0;
-        if (flag){
+        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());
+            List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
             // 插入前端传来的新文件
-            if (!ObjectUtils.isEmpty(bo.getFiles())){
+            if (!ObjectUtils.isEmpty(bo.getFiles())) {
                 for (ZFileBo pic : bo.getFiles()) {
                     if (!existingPhotos.contains(pic.getUrl())) {
                         ZEngiineeringPhoto newPhoto = new ZEngiineeringPhoto();
@@ -171,12 +172,10 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
                     }
                 }
                 // 删除数据库中多余的文件
-                List<String> photosToDelete = existingPhotos.stream()
-                    .filter(pic -> !bo.getFiles().stream().map(ZFileBo::getUrl).collect(Collectors.toList()).contains(pic))
-                    .collect(Collectors.toList());
+                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();
+                    photosToDelete.forEach(item -> {
+                        ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                         zEngiineeringPhoto.setPicUrl(item);
                         zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                         photoService.deleteWithValid(zEngiineeringPhoto);
@@ -211,15 +210,13 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
     public Boolean updateNodeByBo(ZEngineeringIndustryBo bo) {
         ZEngineeringIndustry update = BeanUtil.toBean(bo, ZEngineeringIndustry.class);
         boolean flag = baseMapper.updateById(update) > 0;
-        if (flag){
-            if (!ObjectUtils.isEmpty(bo.getFiles())){
+        if (flag) {
+            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());
+                List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
                 // 插入前端传来的新文件
                 for (ZFileBo pic : bo.getFiles()) {
                     if (!existingPhotos.contains(pic.getUrl())) {
@@ -234,12 +231,10 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
                     }
                 }
                 // 删除数据库中多余的文件
-                List<String> photosToDelete = existingPhotos.stream()
-                    .filter(pic -> !bo.getFiles().stream().map(ZFileBo::getUrl).collect(Collectors.toList()).contains(pic))
-                    .collect(Collectors.toList());
+                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();
+                    photosToDelete.forEach(item -> {
+                        ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                         zEngiineeringPhoto.setPicUrl(item);
                         zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                         photoService.deleteWithValid(zEngiineeringPhoto);
@@ -252,15 +247,15 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
             }
         }
         List<ZEngineeringInfoBo> engineeringInfoBoList1 = bo.getzEngineeringNodeBo().getzEngineeringInfoBoList();
-        if (engineeringInfoBoList1!=null&&!engineeringInfoBoList1.isEmpty()){
-                nodeService.updateMuch(bo.getzEngineeringNodeBo());
+        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);
-//        });
+        //        bo.getzEngineeringNodeBoList().stream().forEach(item->{
+        //            item.setCivliId(bo.getId());
+        //            item.setCreateTime(bo.getCreateTime());
+        //            item.setType(bo.getType());
+        //            izEngineeringNodeService.updateMuch(item);
+        //        });
         return flag;
     }
 
@@ -284,12 +279,10 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
             ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
             zEngiineeringPhotoBo.setParentId(item);
             // 将查询出的url放入existingPhotos
-            List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream()
-                .map(ZEngiineeringPhotoVo::getPicUrl)
-                .collect(Collectors.toList());
+            List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
             // 若存在 则进行删除
             if (!existingPhotos.isEmpty()) {
-                existingPhotos.forEach(i->{
+                existingPhotos.forEach(i -> {
                     photoService.deleteWithValidByurls(i);
                 });
             }
@@ -301,10 +294,8 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
             //  查询数据库中已存在的工程节点
             List<ZEngineeringNodeBo> zEngineeringNodeBos = nodeService.queryListDetails(zEngineeringNodeBo);
             // 若存在 则进行删除
-            if (!zEngineeringNodeBos.isEmpty()){
-                zEngineeringNodeBos.forEach(ite ->
-                    nodeService.delete(ite)
-                );
+            if (!zEngineeringNodeBos.isEmpty()) {
+                zEngineeringNodeBos.forEach(ite -> nodeService.delete(ite));
             }
         });
         return baseMapper.deleteBatchIds(ids) > 0;
@@ -324,9 +315,7 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
     public List<ZEngineeringIndustryTypeVo> queryNameByType(ZEngineeringIndustryBo bo) {
         LambdaQueryWrapper<ZEngineeringIndustry> zEngineeringIndustryBoLambdaQueryWrapper = buildListByType(bo);
         List<ZEngineeringIndustry> zEngineeringIndustryVos = baseMapper.selectList(zEngineeringIndustryBoLambdaQueryWrapper);
-        List<ZEngineeringIndustryTypeVo> zEngineeringIndustryTypeVos = zEngineeringIndustryVos.stream()
-            .map(ZEngineeringIndustryTypeVo::new)
-            .collect(Collectors.toList());
+        List<ZEngineeringIndustryTypeVo> zEngineeringIndustryTypeVos = zEngineeringIndustryVos.stream().map(ZEngineeringIndustryTypeVo::new).collect(Collectors.toList());
         return zEngineeringIndustryTypeVos;
     }