|
@@ -11,16 +11,21 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.framework.obs.ObsService;
|
|
|
import com.ruoyi.zdsz.domain.ZEngiineeringPhoto;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZEngiineeringPhotoBo;
|
|
|
+import com.ruoyi.zdsz.domain.bo.ZEngineeringCivilBo;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZEngineeringInfoBo;
|
|
|
import com.ruoyi.zdsz.domain.vo.ZEngiineeringPhotoVo;
|
|
|
import com.ruoyi.zdsz.mapper.ZEngiineeringPhotoMapper;
|
|
|
import com.ruoyi.zdsz.service.IZEngiineeringPhotoService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -33,16 +38,18 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService {
|
|
|
+ @Value("${filePath}")
|
|
|
+ private String filePath;
|
|
|
|
|
|
private final ZEngiineeringPhotoMapper baseMapper;
|
|
|
@Resource
|
|
|
- private ObsService obsService;
|
|
|
+ private ObsService obsService;
|
|
|
|
|
|
/**
|
|
|
* 查询照片
|
|
|
*/
|
|
|
@Override
|
|
|
- public ZEngiineeringPhotoVo queryById(String id){
|
|
|
+ public ZEngiineeringPhotoVo queryById(String id) {
|
|
|
return baseMapper.selectVoById(id);
|
|
|
}
|
|
|
|
|
@@ -50,11 +57,11 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
@DynamicName(spel = "#bo.createTime")
|
|
|
// @Async("threadPoolTaskExecutor")
|
|
|
public List<String> queryList(ZEngineeringInfoBo bo) {
|
|
|
- List<String> list =new ArrayList<>();
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
LambdaQueryWrapper<ZEngiineeringPhoto> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngiineeringPhoto::getParentId, bo.getId()).orderByDesc(ZEngiineeringPhoto::getCreateTime);
|
|
|
- List<ZEngiineeringPhoto> zEngiineeringPhotoList= baseMapper.selectList(lqw);
|
|
|
- zEngiineeringPhotoList.stream().forEach( item->{
|
|
|
+ List<ZEngiineeringPhoto> zEngiineeringPhotoList = baseMapper.selectList(lqw);
|
|
|
+ zEngiineeringPhotoList.stream().forEach(item -> {
|
|
|
list.add(item.getPicUrl());
|
|
|
});
|
|
|
return list;
|
|
@@ -103,11 +110,12 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
|
|
|
/**
|
|
|
* 批量插入
|
|
|
+ *
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor=Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@DynamicName(spel = "#bo[0].createTime")
|
|
|
// @Async("threadPoolTaskExecutor")
|
|
|
public Boolean insertBatch(List<ZEngiineeringPhoto> bo) {
|
|
@@ -133,42 +141,39 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
ZEngiineeringPhoto zEngiineeringPhoto = bo.get(0);
|
|
|
LambdaQueryWrapper<ZEngiineeringPhoto> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(StringUtils.isNotBlank(zEngiineeringPhoto.getParentId()), ZEngiineeringPhoto::getParentId, zEngiineeringPhoto.getParentId());
|
|
|
- List<ZEngiineeringPhoto> zEngiineeringPhotoList= baseMapper.selectList(lqw);
|
|
|
- List<String> list=new ArrayList<>();
|
|
|
- zEngiineeringPhotoList.stream().forEach(item->{
|
|
|
+ List<ZEngiineeringPhoto> zEngiineeringPhotoList = baseMapper.selectList(lqw);
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ zEngiineeringPhotoList.stream().forEach(item -> {
|
|
|
list.add(item.getPicUrl());
|
|
|
});
|
|
|
- List<String> bolist=new ArrayList<>();
|
|
|
- bo.stream().forEach(item->{
|
|
|
+ List<String> bolist = new ArrayList<>();
|
|
|
+ bo.stream().forEach(item -> {
|
|
|
bolist.add(item.getPicUrl());
|
|
|
});
|
|
|
- List dlList= list.stream().filter(i->!bolist.contains(i)).collect(Collectors.toList());
|
|
|
- List<String> inList= bolist.stream().filter(i->!list.contains(i)).collect(Collectors.toList());
|
|
|
+ List dlList = list.stream().filter(i -> !bolist.contains(i)).collect(Collectors.toList());
|
|
|
+ List<String> inList = bolist.stream().filter(i -> !list.contains(i)).collect(Collectors.toList());
|
|
|
obsService.deleteFiles(dlList);
|
|
|
- List dlIdList=new ArrayList();
|
|
|
- dlList.stream().forEach(item->{
|
|
|
- zEngiineeringPhotoList.stream().forEach(Photoitem->{
|
|
|
- if (Photoitem.getPicUrl()==item)
|
|
|
- {
|
|
|
+ List dlIdList = new ArrayList();
|
|
|
+ dlList.stream().forEach(item -> {
|
|
|
+ zEngiineeringPhotoList.stream().forEach(Photoitem -> {
|
|
|
+ if (Photoitem.getPicUrl() == item) {
|
|
|
dlIdList.add(Photoitem);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
- if (dlIdList.size()!=0)
|
|
|
- {
|
|
|
+ if (dlIdList.size() != 0) {
|
|
|
baseMapper.deleteBatchIds(dlIdList);
|
|
|
|
|
|
- }else if (inList.size()!=0)
|
|
|
- {
|
|
|
- List <ZEngiineeringPhoto> photoList=new ArrayList();
|
|
|
- inList.stream().forEach(item->{
|
|
|
- ZEngiineeringPhoto zEngiineeringPhoto1=new ZEngiineeringPhoto();
|
|
|
- zEngiineeringPhoto1.setParentId(zEngiineeringPhoto.getParentId());
|
|
|
- zEngiineeringPhoto1.setPicUrl(item);
|
|
|
+ } else if (inList.size() != 0) {
|
|
|
+ List<ZEngiineeringPhoto> photoList = new ArrayList();
|
|
|
+ inList.stream().forEach(item -> {
|
|
|
+ ZEngiineeringPhoto zEngiineeringPhoto1 = new ZEngiineeringPhoto();
|
|
|
+ zEngiineeringPhoto1.setParentId(zEngiineeringPhoto.getParentId());
|
|
|
+ zEngiineeringPhoto1.setPicUrl(item);
|
|
|
zEngiineeringPhoto1.setUpdateTime(new Date());
|
|
|
zEngiineeringPhoto1.setCreateTime(zEngiineeringPhoto.getCreateTime());
|
|
|
- photoList.add(zEngiineeringPhoto1);
|
|
|
+ photoList.add(zEngiineeringPhoto1);
|
|
|
});
|
|
|
insertBatch(photoList);
|
|
|
}
|
|
@@ -184,28 +189,27 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
public Boolean delete(ZEngineeringInfoBo bo) {
|
|
|
LambdaQueryWrapper<ZEngiineeringPhoto> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngiineeringPhoto::getParentId, bo.getId());
|
|
|
- List<ZEngiineeringPhoto> zEngiineeringPhoto= baseMapper.selectList(lqw);
|
|
|
- List IdList=new ArrayList();
|
|
|
- List UrlList=new ArrayList();
|
|
|
- zEngiineeringPhoto.stream().forEach(item->{
|
|
|
+ List<ZEngiineeringPhoto> zEngiineeringPhoto = baseMapper.selectList(lqw);
|
|
|
+ List IdList = new ArrayList();
|
|
|
+ List UrlList = new ArrayList();
|
|
|
+ zEngiineeringPhoto.stream().forEach(item -> {
|
|
|
IdList.add(item.getId());
|
|
|
UrlList.add(item.getPicUrl());
|
|
|
|
|
|
});
|
|
|
- int flag=0;
|
|
|
- if(IdList.size()>0)
|
|
|
- {
|
|
|
+ int flag = 0;
|
|
|
+ if (IdList.size() > 0) {
|
|
|
obsService.deleteFiles(UrlList);
|
|
|
- flag= baseMapper.deleteBatchIds(IdList);
|
|
|
+ flag = baseMapper.deleteBatchIds(IdList);
|
|
|
}
|
|
|
- ;
|
|
|
- return flag>0;
|
|
|
+ ;
|
|
|
+ return flag > 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(ZEngiineeringPhoto entity){
|
|
|
+ private void validEntityBeforeSave(ZEngiineeringPhoto entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
@@ -214,7 +218,7 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
@@ -243,4 +247,84 @@ public class ZEngiineeringPhotoServiceImpl implements IZEngiineeringPhotoService
|
|
|
}
|
|
|
return baseMapper.deleteByUrls(bo.getPicUrl()) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void write(ZEngineeringCivilBo zEngineeringCivilBo) {
|
|
|
+ zEngineeringCivilBo.getzEngineeringNodeBo().getzEngineeringInfoBoList().forEach(zEngineeringInfoBo -> {
|
|
|
+ zEngineeringInfoBo.getzEngiineeringPhotoBoList().forEach(photo -> {
|
|
|
+ if (StringUtils.isNotBlank(photo)) {
|
|
|
+ // 创建最外层文件夹
|
|
|
+ File file = new File(filePath);
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.mkdirs();
|
|
|
+ }
|
|
|
+ // 创建行政区
|
|
|
+ File headFile = new File(file.getPath() + "/" + zEngineeringCivilBo.getDistrict());
|
|
|
+ if (!headFile.exists()) {
|
|
|
+ headFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 小区下再次创建小区,本级用于导出
|
|
|
+ File areaFile = new File(headFile.getPath() + "/" + zEngineeringCivilBo.getAreaId());
|
|
|
+ if (!areaFile.exists()) {
|
|
|
+ areaFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 楼
|
|
|
+ File buildingFile = new File(areaFile.getPath() + "/" + zEngineeringCivilBo.getBuildingId());
|
|
|
+ if (!buildingFile.exists()) {
|
|
|
+ buildingFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 单元
|
|
|
+ File unitFile = new File(buildingFile.getPath() + "/" + zEngineeringCivilBo.getUnitId());
|
|
|
+ if (!unitFile.exists()) {
|
|
|
+ unitFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 房间
|
|
|
+ File houseFile = new File(unitFile.getPath() + "/" + zEngineeringCivilBo.getHouseId());
|
|
|
+ if (!houseFile.exists()) {
|
|
|
+ houseFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 工程周期
|
|
|
+ File EnginCycleFile = new File(houseFile.getPath() + "/" + zEngineeringCivilBo.getEnginCycle());
|
|
|
+ if (!EnginCycleFile.exists()) {
|
|
|
+ EnginCycleFile.mkdirs();
|
|
|
+ }
|
|
|
+ // 工程类型
|
|
|
+ File EnginType = new File(EnginCycleFile.getPath() + "/" + zEngineeringCivilBo.getEnginType());
|
|
|
+ if (!EnginType.exists()) {
|
|
|
+ EnginType.mkdirs();
|
|
|
+ }
|
|
|
+ // 工程分类
|
|
|
+ File EnginClassification = new File(EnginType.getPath() + "/" + zEngineeringCivilBo.getEnginClassification());
|
|
|
+ if (!EnginClassification.exists()) {
|
|
|
+ EnginClassification.mkdirs();
|
|
|
+ }
|
|
|
+ // 节点类型
|
|
|
+ File Type = new File(EnginClassification.getPath() + "/" + zEngineeringCivilBo.getzEngineeringNodeBo().getType());
|
|
|
+ if (!Type.exists()) {
|
|
|
+ Type.mkdirs();
|
|
|
+ }
|
|
|
+ // 时间
|
|
|
+ File CreateTimeFile = new File(Type.getPath() + "/" + new SimpleDateFormat("yyyy-MM-dd").format(zEngineeringInfoBo.getCreateTime()) );
|
|
|
+ if (!CreateTimeFile.exists()) {
|
|
|
+ CreateTimeFile.mkdirs();
|
|
|
+ }
|
|
|
+ File CreateByFile = new File(CreateTimeFile.getPath() + "/" + zEngineeringInfoBo.getConstructUser());
|
|
|
+ if (!CreateByFile.exists()) {
|
|
|
+ CreateByFile.mkdirs();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ obsService.download(CreateByFile.getPath(), photo.substring(photo.lastIndexOf("/")+1));
|
|
|
+ System.out.println(photo.substring(photo.lastIndexOf("/")+1));
|
|
|
+ System.out.println(photo);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|