|
@@ -65,9 +65,9 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
* 查询危险工程详情
|
|
|
*/
|
|
|
@Override
|
|
|
- public ZEngineeringDangerousVo query(String id) {
|
|
|
+ public ZEngineeringDangerousVo query(String id) {
|
|
|
ZEngineeringDangerousVo vo = baseMapper.selectVoById(id);
|
|
|
- ZEngiineeringPhotoBo bo= new ZEngiineeringPhotoBo();
|
|
|
+ ZEngiineeringPhotoBo bo = new ZEngiineeringPhotoBo();
|
|
|
bo.setParentId(vo.getId());
|
|
|
bo.setCreateTime(vo.getCreateTime());
|
|
|
vo.setPics(photoService.queryList(bo));
|
|
@@ -102,7 +102,7 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
* 新增危险工程
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor=Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@DynamicName(spel = "#bo.createTime")
|
|
|
public Boolean insert(ZEngineeringDangerousBo bo) {
|
|
|
ZEngineeringDangerous add = BeanUtil.toBean(bo, ZEngineeringDangerous.class);
|
|
@@ -114,9 +114,9 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
bo.getzEngineeringNodeBo().setCivliId(add.getId());
|
|
|
bo.getzEngineeringNodeBo().setCreateTime(add.getCreateTime());
|
|
|
ZEngineeringNode entity = izEngineeringNodeService.insert(bo.getzEngineeringNodeBo());
|
|
|
- if (!ObjectUtil.isEmpty(entity)){
|
|
|
+ if (!ObjectUtil.isEmpty(entity)) {
|
|
|
List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
- bo.getFiles().stream().forEach(o->{
|
|
|
+ bo.getFiles().stream().forEach(o -> {
|
|
|
ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
pic.setParentId(bo.getId());
|
|
|
pic.setPicUrl(o.getUrl());
|
|
@@ -142,13 +142,13 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
public Boolean update(ZEngineeringDangerousBo bo) {
|
|
|
ZEngineeringDangerous update = BeanUtil.toBean(bo, ZEngineeringDangerous.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
- ZEngineeringNodeBo zEngineeringNodeBo =bo.getzEngineeringNodeBo();
|
|
|
+ ZEngineeringNodeBo zEngineeringNodeBo = bo.getzEngineeringNodeBo();
|
|
|
zEngineeringNodeBo.setCivliId(update.getId());
|
|
|
zEngineeringNodeBo.setId(baseMapper.selectIdByCid(zEngineeringNodeBo.getCivliId()));
|
|
|
zEngineeringNodeBo.setCreateTime(update.getCreateTime());
|
|
|
izEngineeringNodeService.update(zEngineeringNodeBo);
|
|
|
int i = baseMapper.updateById(update);
|
|
|
- if (i>0){
|
|
|
+ if (i > 0) {
|
|
|
List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
|
|
|
// 查询数据库中已存在的文件列表
|
|
@@ -176,7 +176,7 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
.filter(pic -> !bo.getFiles().stream().map(ZFileBo::getUrl).collect(Collectors.toList()).contains(pic))
|
|
|
.collect(Collectors.toList());
|
|
|
if (!photosToDelete.isEmpty()) {
|
|
|
- photosToDelete.forEach(item->{
|
|
|
+ photosToDelete.forEach(item -> {
|
|
|
photoService.deleteWithValidByurls(item);
|
|
|
});
|
|
|
}
|
|
@@ -192,7 +192,7 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(ZEngineeringDangerous entity){
|
|
|
+ private void validEntityBeforeSave(ZEngineeringDangerous entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
@@ -201,7 +201,7 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
ids.forEach(item -> {
|
|
@@ -217,7 +217,9 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 危险工程历史
|
|
|
+ */
|
|
|
@Override
|
|
|
public ZEngineeringDangerousVo queryEngineeringDangerous(String id) {
|
|
|
ZEngineeringDangerousVo vo = baseMapper.selectVoById(id);
|
|
@@ -227,4 +229,96 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
vo.setzEngineeringNodeBoList(izEngineeringNodeService.queryListDetails(zEngineeringNodeBo));
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增危险工程(无节点)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(ZEngineeringDangerousBo bo) {
|
|
|
+ ZEngineeringDangerous add = BeanUtil.toBean(bo, ZEngineeringDangerous.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ if (!bo.getFiles().isEmpty()) {
|
|
|
+ List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
+ bo.getFiles().stream().forEach(o -> {
|
|
|
+ ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
+ pic.setParentId(bo.getId());
|
|
|
+ pic.setPicUrl(o.getUrl());
|
|
|
+ pic.setUpdateBy(String.valueOf(LoginHelper.getUserId()));
|
|
|
+ pic.setUpdateTime(new Date());
|
|
|
+ pic.setCreateTime(bo.getCreateTime());
|
|
|
+ list.add(pic);
|
|
|
+ });
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ photoService.insertBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改危险工程(无节点)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(ZEngineeringDangerousBo bo) {
|
|
|
+ ZEngineeringDangerous update = BeanUtil.toBean(bo, ZEngineeringDangerous.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ int i = baseMapper.updateById(update);
|
|
|
+ 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());
|
|
|
+
|
|
|
+ // 插入前端传来的新文件
|
|
|
+ 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(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 -> {
|
|
|
+ photoService.deleteWithValidByurls(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量插入新图片
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ photoService.insertBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询危险工程(无节点)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ZEngineeringDangerousVo queryById(String id) {
|
|
|
+ ZEngineeringDangerousVo vo = baseMapper.selectVoById(id);
|
|
|
+ ZEngiineeringPhotoBo bo = new ZEngiineeringPhotoBo();
|
|
|
+ bo.setParentId(vo.getId());
|
|
|
+ bo.setCreateTime(vo.getCreateTime());
|
|
|
+ vo.setPics(photoService.queryList(bo));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|