|
@@ -29,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
@@ -216,6 +218,112 @@ public class ZEngineeringAirWallServiceImpl implements IZEngineeringAirWallServi
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 本故事为管道厚度功能原创模块
|
|
|
+ */
|
|
|
+ private void batchUpdatePic(ZEngineeringAirWallBo bo, String methodName, String type) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
|
|
+ // 获取类对象
|
|
|
+ Class<?> cls = ZEngineeringInfoBo.class;
|
|
|
+ // 获取指定方法
|
|
|
+ Method method = cls.getDeclaredMethod(methodName);
|
|
|
+// System.out.println("method.invoke(obj);==="+method.invoke(bo.getzEngineeringNodeBo().getzEngineeringInfoBoList().get(0)));
|
|
|
+ // 故事正文开始
|
|
|
+ List<ZEngineeringInfoBo> zEngineeringInfoBoList = bo.getzEngineeringNodeBo().getzEngineeringInfoBoList();
|
|
|
+ System.out.println("#003 zEngineeringInfoBoList.size()=" +zEngineeringInfoBoList.size());
|
|
|
+ for (int i = 0; i < zEngineeringInfoBoList.size(); i++) {
|
|
|
+ System.out.println("#003 进入 for type=" + type);
|
|
|
+ ZEngineeringInfoBo zEngineeringInfoBo = zEngineeringInfoBoList.get(i);
|
|
|
+ if (!ObjectUtils.isEmpty(method.invoke(zEngineeringInfoBo))) {
|
|
|
+ System.out.println("#003 if if if if (!ObjectUtils.isEmpty(method.invoke(zEngineeringInfoBo))) ");
|
|
|
+ List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
+ // 查询数据库中已存在的文件列表
|
|
|
+ ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
+ zEngiineeringPhotoBo.setCreateTime(zEngineeringInfoBo.getCreateTime());//
|
|
|
+ zEngiineeringPhotoBo.setType(type);
|
|
|
+ zEngiineeringPhotoBo.setParentId(zEngineeringInfoBo.getId());
|
|
|
+ List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
|
|
|
+ // 插入前端传来的新文件
|
|
|
+// for (ZFileBo pic : bo.getzEngineeringNodeBo().getzEngineeringInfoBo().getIronPipelineThickness()) {
|
|
|
+ for (String pic : (List<String>)method.invoke(zEngineeringInfoBo)) {
|
|
|
+ if (!existingPhotos.contains(pic)) {
|
|
|
+ ZEngiineeringPhoto newPhoto = new ZEngiineeringPhoto();
|
|
|
+ // newPhoto.setParentId(bo.getId());
|
|
|
+ newPhoto.setParentId(zEngineeringInfoBo.getId());
|
|
|
+ newPhoto.setPicUrl(pic);
|
|
|
+ newPhoto.setFileName(pic);
|
|
|
+// newPhoto.setType("ironPipelineThickness");
|
|
|
+ newPhoto.setType(type);
|
|
|
+ newPhoto.setCreateBy(String.valueOf(LoginHelper.getUsername()));
|
|
|
+ newPhoto.setCreateTime(bo.getCreateTime());
|
|
|
+ newPhoto.setUpdateTime(new Date());
|
|
|
+ list.add(newPhoto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("#003 删除数据库中多余的文件");
|
|
|
+ // 删除数据库中多余的文件
|
|
|
+// List<String> photosToDelete = existingPhotos.stream().filter(pic -> !bo.getzEngineeringNodeBo().getzEngineeringInfoBo().getIronPipelineThickness().contains(pic)).collect(Collectors.toList());
|
|
|
+ List<String> photosToDelete = existingPhotos.stream().filter(pic -> {
|
|
|
+ try {
|
|
|
+ return !((List<String>)(method.invoke(zEngineeringInfoBo))).contains(pic);
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (InvocationTargetException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if (!photosToDelete.isEmpty()) {
|
|
|
+ photosToDelete.forEach(item -> {
|
|
|
+ ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
|
|
|
+// zEngiineeringPhoto.setType("ironPipelineThickness");
|
|
|
+ zEngiineeringPhoto.setType(type);
|
|
|
+ zEngiineeringPhoto.setPicUrl(item);
|
|
|
+ zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
|
|
|
+ photoService.deleteWithValid(zEngiineeringPhoto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 批量插入新图片
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ photoService.insertBatch(list);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ System.out.println("#003 else 删除数据库中多余的文件");
|
|
|
+ // 查询数据库中已存在的文件列表
|
|
|
+ ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
+ zEngiineeringPhotoBo.setCreateTime(zEngineeringInfoBo.getCreateTime());//
|
|
|
+ zEngiineeringPhotoBo.setParentId(zEngineeringInfoBo.getId());
|
|
|
+ zEngiineeringPhotoBo.setType(type);
|
|
|
+ List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
|
|
|
+ // 删除数据库中多余的文件
|
|
|
+// List<String> photosToDelete = existingPhotos.stream().filter(pic -> !bo.getzEngineeringNodeBo().getzEngineeringInfoBo().getIronPipelineThickness().contains(pic)).collect(Collectors.toList());
|
|
|
+ List<String> photosToDelete = null;
|
|
|
+ try {
|
|
|
+ photosToDelete = existingPhotos.stream().filter(pic -> {
|
|
|
+ try {
|
|
|
+// return !method.invoke(zEngineeringInfoBo).toString().contains(pic);
|
|
|
+ return !((List<String>)(method.invoke(zEngineeringInfoBo))).contains(pic);
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (InvocationTargetException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!photosToDelete.isEmpty()) {
|
|
|
+ photosToDelete.forEach(item -> {
|
|
|
+ ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
|
|
|
+ zEngiineeringPhoto.setType("ironPipelineThickness");
|
|
|
+ zEngiineeringPhoto.setType(type);
|
|
|
+ zEngiineeringPhoto.setPicUrl(item);
|
|
|
+ zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
|
|
|
+ photoService.deleteWithValid(zEngiineeringPhoto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 修改,带气封堵施工
|
|
|
*/
|
|
|
@Override
|
|
@@ -229,6 +337,7 @@ public class ZEngineeringAirWallServiceImpl implements IZEngineeringAirWallServi
|
|
|
// 查询数据库中已存在的文件列表
|
|
|
ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
|
zEngiineeringPhotoBo.setParentId(update.getId());
|
|
|
+ zEngiineeringPhotoBo.setCreateTime(update.getCreateTime());
|
|
|
List<String> existingPhotos = photoService.queryList(zEngiineeringPhotoBo).stream().map(ZEngiineeringPhotoVo::getPicUrl).collect(Collectors.toList());
|
|
|
// 插入前端传来的新文件
|
|
|
for (ZFileBo pic : bo.getFiles()) {
|
|
@@ -261,8 +370,35 @@ public class ZEngineeringAirWallServiceImpl implements IZEngineeringAirWallServi
|
|
|
/**
|
|
|
* 管道厚度
|
|
|
*/
|
|
|
+ try {
|
|
|
+ batchUpdatePic(bo, "getIronPipelineThickness", "ironPipelineThickness");
|
|
|
+ batchUpdatePic(bo, "getIron4Welding", "iron4Welding");
|
|
|
+ batchUpdatePic(bo, "getIronBypassWelding", "ironBypassWelding");
|
|
|
+ batchUpdatePic(bo, "getIronHolesOpening", "ironHolesOpening");
|
|
|
+ batchUpdatePic(bo, "getIronCleaning", "ironCleaning");
|
|
|
+ batchUpdatePic(bo, "getIronNitrogenPurging", "ironNitrogenPurging");
|
|
|
+ batchUpdatePic(bo, "getIronPipelineReplacing", "ironPipelineReplacing");
|
|
|
+ batchUpdatePic(bo, "getIronLowerEndCap", "ironLowerEndCap");
|
|
|
+ batchUpdatePic(bo, "getIronHomeworkDone", "ironHomeworkDone");
|
|
|
+ batchUpdatePic(bo, "getIron4Aczoiling", "iron4Aczoiling");
|
|
|
+
|
|
|
+ batchUpdatePic(bo, "getPeSaddleWelding", "peSaddleWelding");
|
|
|
+ batchUpdatePic(bo, "getPeAirtightTest", "peAirtightTest");
|
|
|
+ batchUpdatePic(bo, "getPeHolesOpening", "peHolesOpening");
|
|
|
+ batchUpdatePic(bo, "getPeCleaning", "peCleaning");
|
|
|
+ batchUpdatePic(bo, "getPePlugging", "pePlugging");
|
|
|
+ batchUpdatePic(bo, "getPeCollisionOperating", "peCollisionOperating");
|
|
|
+ batchUpdatePic(bo, "getPeAirrecovering", "peAirrecovering");
|
|
|
+ batchUpdatePic(bo, "getPeHomeworkDone", "peHomeworkDone");
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管道厚度
|
|
|
+ */
|
|
|
// if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo().getzEngineeringInfoBo().getIronPipelineThickness())) {
|
|
|
- if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo().getzEngineeringInfoBoList().get(0).getIronPipelineThickness())) {
|
|
|
+ /*if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo().getzEngineeringInfoBoList().get(0).getIronPipelineThickness())) {
|
|
|
List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
// 查询数据库中已存在的文件列表
|
|
|
ZEngiineeringPhotoBo zEngiineeringPhotoBo = new ZEngiineeringPhotoBo();
|
|
@@ -320,7 +456,7 @@ public class ZEngineeringAirWallServiceImpl implements IZEngineeringAirWallServi
|
|
|
photoService.deleteWithValid(zEngiineeringPhoto);
|
|
|
});
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(bo.getzEngineeringNodeBo())){
|
|
|
List<ZEngineeringInfoBo> engineeringInfoBoList1 = bo.getzEngineeringNodeBo().getzEngineeringInfoBoList();
|