|
|
|
|
@ -13,10 +13,14 @@ import com.da.dangan.domain.DaPicturesRecard;
|
|
|
|
|
import com.da.dangan.mapper.*;
|
|
|
|
|
import com.da.dangan.service.IDaCatalogService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 档案目录Service业务层处理
|
|
|
|
|
@ -269,7 +273,6 @@ public class DaCatalogServiceImpl implements IDaCatalogService {
|
|
|
|
|
catalogList = daCatalogMapper.exportDaCatalogListByUserId(daCatalog);
|
|
|
|
|
}
|
|
|
|
|
return catalogList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -287,7 +290,7 @@ public class DaCatalogServiceImpl implements IDaCatalogService {
|
|
|
|
|
DaCatalog info = daCatalogMapper.selectDaCatalogById(daCatalog.getPid());
|
|
|
|
|
// 如果父节点不为正常状态,则不允许新增子节点
|
|
|
|
|
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
|
|
throw new ServiceException("此目录停用,不允许新增");
|
|
|
|
|
throw new ServiceException("上级部门停用,不能新增");
|
|
|
|
|
}
|
|
|
|
|
daCatalog.setAncestors(info.getAncestors() + "," + daCatalog.getPid());
|
|
|
|
|
daCatalog.setYwType(info.getYwType());
|
|
|
|
|
@ -296,13 +299,77 @@ public class DaCatalogServiceImpl implements IDaCatalogService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改档案目录
|
|
|
|
|
* 修改档案目录:档案目录的层级在——有识别数据后不允许修改 存储的识别count数量、任务muPath、识别数据muPath会错误
|
|
|
|
|
*
|
|
|
|
|
* @param daCatalog 档案目录
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int updateDaCatalog(DaCatalog daCatalog) {
|
|
|
|
|
DaCatalog oldData = daCatalogMapper.selectDaCatalogById(daCatalog.getId());//查询原数据
|
|
|
|
|
if(oldData.getCountNum()>0L&&!oldData.getMuName().equals(daCatalog.getMuName())){
|
|
|
|
|
throw new ServiceException("该目录下有识别数据,不能修改目录名称!");
|
|
|
|
|
}
|
|
|
|
|
if(!daCatalog.getPid().equals(oldData.getPid())){
|
|
|
|
|
if(oldData.getCountNum()>0L){
|
|
|
|
|
throw new ServiceException("该目录下有识别数据,不能修改层级!");
|
|
|
|
|
}
|
|
|
|
|
DaCatalog pcatalog = new DaCatalog();
|
|
|
|
|
pcatalog.setPid(daCatalog.getId());
|
|
|
|
|
//有子级目录的不能删除
|
|
|
|
|
List<DaCatalog> daCatalogs = daCatalogMapper.selectDaCatalogList(pcatalog);
|
|
|
|
|
if (daCatalogs != null && daCatalogs.size() > 0) {
|
|
|
|
|
throw new ServiceException("有子级目录,不能修改层级");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改父级目录的情况
|
|
|
|
|
String fAncestors; //父级目录
|
|
|
|
|
if (daCatalog.getPid() == 0) { //代表添加的是主目录
|
|
|
|
|
fAncestors=daCatalog.getPid().toString();
|
|
|
|
|
daCatalog.setAncestors(fAncestors);
|
|
|
|
|
} else {
|
|
|
|
|
DaCatalog info = daCatalogMapper.selectDaCatalogById(daCatalog.getPid());
|
|
|
|
|
// 如果父节点不为正常状态,则不允许添加子节点
|
|
|
|
|
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
|
|
throw new ServiceException("失败,上级部门是停用状态");
|
|
|
|
|
}
|
|
|
|
|
//不能选择自己为父节点
|
|
|
|
|
if (daCatalog.getPid().equals(daCatalog.getId()))
|
|
|
|
|
{
|
|
|
|
|
throw new ServiceException("失败,上级部门不能是自己");
|
|
|
|
|
}
|
|
|
|
|
fAncestors=info.getAncestors() + "," + daCatalog.getPid();
|
|
|
|
|
//修改目录层级——修改对应的字段ancestors
|
|
|
|
|
daCatalog.setAncestors(fAncestors);
|
|
|
|
|
daCatalog.setYwType(info.getYwType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果修改了目录名字、查看下面有没有图片,有则修改图片里的档案路径
|
|
|
|
|
DaPicturesRecard muPicRecard = new DaPicturesRecard();
|
|
|
|
|
muPicRecard.setMuId(daCatalog.getId());
|
|
|
|
|
List<DaPicturesRecard> muPicRecards = daPicturesRecardMapper.selectDaPicturesRecardList(muPicRecard);
|
|
|
|
|
if(muPicRecards!=null&&muPicRecards.size()>0){ //该目录存在上传的图片
|
|
|
|
|
//获取新的目录路径,重新设置目录路径
|
|
|
|
|
List<Long> fsplit = Stream.of(fAncestors.split(","))
|
|
|
|
|
.map(Long::parseLong)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
fsplit.remove(0L);
|
|
|
|
|
|
|
|
|
|
List<DaCatalog> catalogs = new ArrayList<>();
|
|
|
|
|
for(Long mId:fsplit){
|
|
|
|
|
catalogs.add(daCatalogMapper.selectDaCatalogById(mId));
|
|
|
|
|
}
|
|
|
|
|
List<String> muNames = catalogs.stream().map(DaCatalog::getMuName).collect(Collectors.toList());
|
|
|
|
|
muNames.add(daCatalog.getMuName());//把当前自己的目录名称添加到最后
|
|
|
|
|
String muPath = StringUtils.join(muNames, "/");
|
|
|
|
|
DaPicturesRecard picturesRecard = new DaPicturesRecard();
|
|
|
|
|
picturesRecard.setMuId(daCatalog.getId());
|
|
|
|
|
picturesRecard.setMuPath(muPath);
|
|
|
|
|
daPicturesRecardMapper.updateMuPathByMuId(picturesRecard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
daCatalog.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return daCatalogMapper.updateDaCatalog(daCatalog);
|
|
|
|
|
}
|
|
|
|
|
|