Commit 04aedaf3 authored by wei's avatar wei 🎱

案卷下有文件不能删除

parent 7f1cd55c
......@@ -2,12 +2,22 @@ package com.inet.dcs.document.core.service;
import com.inet.dcs.document.common.vo.ExtFilesDocLinkVO;
import com.inet.dcs.document.core.service.shadow.ExtFilesDocLinkServiceShadow;
import java.util.List;
/**
* @description: ExtFilesDocLink-service
* @author: dexadmin
* @version: V
* @date: 2024-10-29 10:30:49
**/
* @description: ExtFilesDocLink-service
* @author: dexadmin
* @version: V
* @date: 2024-10-29 10:30:49
**/
public interface ExtFilesDocLinkService<V extends ExtFilesDocLinkVO> extends ExtFilesDocLinkServiceShadow<V> {
/**
* 根据案卷ID查询关联文件的source
*
* @param targetId
* @return
*/
List<ExtFilesDocLinkVO> getFilesDocLinkByTargetId(Long targetId);
}
package com.inet.dcs.document.core.service.impl;
import org.springframework.stereotype.Service;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import com.inet.dcs.document.common.vo.ExtFilesDocLinkVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.inet.dcs.document.core.service.ExtFilesDocLinkService;
import com.inet.dcs.document.core.repository.ExtFilesDocLinkRepository;
import com.inet.dcs.document.core.service.ExtFilesDocLinkService;
import com.inet.dcs.document.entity.po.ExtFilesDocLink;
import javax.annotation.Resource;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description: ExtFilesDocLink-ServiceImpl
* @author: dexadmin
* @version: V
* @date: 2024-10-29 10:30:49
**/
* @description: ExtFilesDocLink-ServiceImpl
* @author: dexadmin
* @version: V
* @date: 2024-10-29 10:30:49
**/
@Slf4j
@Service(ExtFilesDocLinkServiceImpl.BEAN_NAME)
public class ExtFilesDocLinkServiceImpl<V extends ExtFilesDocLinkVO> implements ExtFilesDocLinkService<V>{
public class ExtFilesDocLinkServiceImpl<V extends ExtFilesDocLinkVO> implements ExtFilesDocLinkService<V> {
public static final String BEAN_NAME = "extFilesDocLinkServiceImpl";
......@@ -29,6 +29,15 @@ public class ExtFilesDocLinkServiceImpl<V extends ExtFilesDocLinkVO> implements
@Autowired
ExtFilesDocLinkRepository<ExtFilesDocLink> extFilesDocLinkRepository;
@Override
public List<ExtFilesDocLinkVO> getFilesDocLinkByTargetId(Long targetId) {
SearchQueryCondition queryDoc = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("source").build())
.searchItems(SearchItems.builder().item(new SearchItem("targetId", SearchItem.Operator.EQ,
targetId, null)).operator(SearchItems.BooleanOperator.AND).build()).build();
return (List<ExtFilesDocLinkVO>) this.findRecursion(queryDoc).getContent();
}
}
package com.inet.dcs.document.core.service.impl;
import com.inet.dcs.document.common.vo.ExtFilesDocLinkVO;
import com.inet.dcs.document.common.vo.ExtFilesVO;
import com.inet.dcs.document.core.repository.ExtFilesRepository;
import com.inet.dcs.document.core.service.ExtFilesDocLinkService;
import com.inet.dcs.document.core.service.ExtFilesService;
import com.inet.dcs.document.core.util.SearchUtil;
import com.inet.dcs.document.entity.po.ExtFiles;
......@@ -43,6 +45,9 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
@Autowired
private ExtDxContextProjectServiceFeign extDxContextProjectServiceFeign;
@Autowired
private ExtFilesDocLinkService extFilesDocLinkService;
@Override
public void beforeSave(Collection<V> target) {
// 全宗号+项目号+项目代号+类别代号+盒号(三位流水号)+后缀“-(两位数字流水号)例如:2-20114272031-QH03-JS01-001-(01)
......@@ -65,6 +70,16 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
}
}
@Override
public void beforeDelete(Collection<V> target) {
for (V v : target) {
List<ExtFilesDocLinkVO> filesDocLink = extFilesDocLinkService.getFilesDocLinkByTargetId(v.getId());
if (CollectionUtils.isNotEmpty(filesDocLink)) {
throw new DxBusinessException("500", "案卷下有文件不能删除");
}
}
}
/**
* 根据案卷序号查询案卷
*
......@@ -76,6 +91,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
.searchItems(SearchItems.builder()
.item(new SearchItem("volumeNumber", SearchItem.Operator.EQ, volumeNumber, null))
.item(new SearchItem("latest", SearchItem.Operator.EQ, true, null))
.item(new SearchItem("checkOuted", SearchItem.Operator.EQ, true, null))
.operator(SearchItems.BooleanOperator.AND).build()).build();
return (List<ExtFilesVO>) this.findRecursion(queryDoc).getContent();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment