|
@@ -34,7 +34,11 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -70,6 +74,8 @@ public class CompareLiteratureService extends ServiceImpl<CompareLiteratureMappe
|
|
|
private EsService esService;
|
|
|
@Autowired
|
|
|
private MessageService messageService;
|
|
|
+ @Autowired
|
|
|
+ private CompareLiteratureMapper compareLiteratureMapper;
|
|
|
|
|
|
//添加专利对比文献
|
|
|
public Integer addPatentCompareLiterature(Patent patent, Integer projectId, String createId) {
|
|
@@ -520,10 +526,21 @@ public class CompareLiteratureService extends ServiceImpl<CompareLiteratureMappe
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public Boolean deleteCompareLiterature(List<Integer> ids) {
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
+ public Boolean deleteCompareLiterature(List<Integer> ids) throws IOException {
|
|
|
if (ids == null || ids.size() <= 0) {
|
|
|
throw new XiaoShiException("请选择对比文献");
|
|
|
}
|
|
|
+ List<CompareLiterature> literatures = compareLiteratureMapper.selectBatchIds(ids);
|
|
|
+ if (!CollectionUtils.isEmpty(literatures)) {
|
|
|
+ List<CompareLiterature> literatureList = literatures.stream().filter(i -> i.getType().equals(0)).collect(Collectors.toList());
|
|
|
+ for (CompareLiterature literature : literatureList) {
|
|
|
+ Integer number = esService.getPatent(literature.getLiteratureNo(), literature.getProjectId());
|
|
|
+ if (number < 1) {
|
|
|
+ throw new XiaoShiException("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return this.removeBatchByIds(ids);
|
|
|
|
|
|
}
|