|
@@ -1,6 +1,7 @@
|
|
|
package com.ruoyi.zdsz.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.ruoyi.common.helper.LoginHelper;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
@@ -8,8 +9,12 @@ import com.ruoyi.common.core.domain.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.ruoyi.zdsz.domain.ZEngiineeringPhoto;
|
|
|
+import com.ruoyi.zdsz.domain.bo.ZEngiineeringPhotoBo;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZHouseBo;
|
|
|
+import com.ruoyi.zdsz.domain.vo.ZEngiineeringPhotoVo;
|
|
|
import com.ruoyi.zdsz.domain.vo.ZHouseVo;
|
|
|
+import com.ruoyi.zdsz.mapper.ZEngiineeringPhotoMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZComprehensiveBo;
|
|
@@ -17,10 +22,11 @@ import com.ruoyi.zdsz.domain.vo.ZComprehensiveVo;
|
|
|
import com.ruoyi.zdsz.domain.ZComprehensive;
|
|
|
import com.ruoyi.zdsz.mapper.ZComprehensiveMapper;
|
|
|
import com.ruoyi.zdsz.service.IZComprehensiveService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 开栓|安检|维修Service业务层处理
|
|
@@ -34,12 +40,22 @@ public class ZComprehensiveServiceImpl implements IZComprehensiveService {
|
|
|
|
|
|
private final ZComprehensiveMapper baseMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ZEngiineeringPhotoMapper photoMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询开栓|安检|维修
|
|
|
*/
|
|
|
@Override
|
|
|
public ZComprehensiveVo queryById(String id){
|
|
|
- return baseMapper.selectVoById(id);
|
|
|
+ ZComprehensiveVo vo = baseMapper.selectVoById(id);
|
|
|
+// List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// map.put("url","http://localhost/static/img/profile.f470f2a8.jpg");
|
|
|
+// map.put("id","111");
|
|
|
+// list.add(map);
|
|
|
+ vo.setMapList(photoMapper.getlist(id));
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -81,12 +97,25 @@ public class ZComprehensiveServiceImpl implements IZComprehensiveService {
|
|
|
* 新增开栓|安检|维修
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(ZComprehensiveBo bo) {
|
|
|
ZComprehensive add = BeanUtil.toBean(bo, ZComprehensive.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setId(add.getId());
|
|
|
+ List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
+ bo.getPicIds().stream().forEach(o->{
|
|
|
+ ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
+ pic.setParentId(bo.getId());
|
|
|
+ pic.setPicUrl(o);
|
|
|
+ pic.setUpdateBy(String.valueOf(LoginHelper.getUserId()));
|
|
|
+ pic.setUpdateTime(new Date());
|
|
|
+ list.add(pic);
|
|
|
+ });
|
|
|
+ if (list.size()>0) {
|
|
|
+ photoMapper.insertBatch(list);
|
|
|
+ }
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
@@ -98,6 +127,27 @@ public class ZComprehensiveServiceImpl implements IZComprehensiveService {
|
|
|
public Boolean updateByBo(ZComprehensiveBo bo) {
|
|
|
ZComprehensive update = BeanUtil.toBean(bo, ZComprehensive.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
+ if (StringUtils.isNotBlank(bo.getId())) {
|
|
|
+ bo.setId(bo.getId());
|
|
|
+ List<ZEngiineeringPhoto> list = new ArrayList<>();
|
|
|
+ if (!bo.getPicIds().isEmpty()) {
|
|
|
+ List<String> collect = photoMapper.getlist(bo.getId()).stream().map(ele -> String.valueOf(ele.get("url"))).collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ bo.setPicIds(bo.getPicIds().stream().filter(pic -> !collect.contains(pic)).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ bo.getPicIds().stream().forEach(o -> {
|
|
|
+ ZEngiineeringPhoto pic = new ZEngiineeringPhoto();
|
|
|
+ pic.setParentId(bo.getId());
|
|
|
+ pic.setPicUrl(o);
|
|
|
+ pic.setCreateBy(String.valueOf(LoginHelper.getUserId()));
|
|
|
+ pic.setCreateTime(new Date());
|
|
|
+ list.add(pic);
|
|
|
+ });
|
|
|
+ if (list.size()>0) {
|
|
|
+ photoMapper.insertBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
@@ -112,6 +162,7 @@ public class ZComprehensiveServiceImpl implements IZComprehensiveService {
|
|
|
* 批量删除开栓|安检|维修
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
|
|
if(isValid){
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|