You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.8 KiB
Java

package com.supervision.pdfqaserver.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.pdfqaserver.domain.Intention;
import com.supervision.pdfqaserver.service.IntentionService;
import com.supervision.pdfqaserver.mapper.IntentionMapper;
import com.supervision.pdfqaserver.service.IntentionTruncationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author Administrator
* @description intentionService
* @createDate 2025-05-14 15:23:54
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class IntentionServiceImpl extends ServiceImpl<IntentionMapper, Intention>
implements IntentionService{
private final IntentionTruncationService intentionTruncationService;
@Override
public List<Intention> batchSaveIfAbsent(List<String> intents, String domainCategoryId,String truncateId) {
Assert.notEmpty(domainCategoryId, "行业分类ID不能为空");
if (CollUtil.isEmpty(intents)){
return new ArrayList<>();
}
List<Intention> intentions = this.lambdaQuery().in(Intention::getDigest, intents)
.eq(Intention::getDomainCategoryId, domainCategoryId).list();
List<Intention> result = new ArrayList<>();
for (String intent : intents) {
Intention one = intentions.stream().filter(i -> i.getDigest().equals(intent)).findFirst().orElse(null);
if (null == one){
Intention intention = new Intention();
intention.setDigest(intent);
intention.setDomainCategoryId(domainCategoryId);
intention.setGenerationType("1");// 1:系统录入
this.save(intention);
result.add(intention);
// 保存关联关系
intentionTruncationService.saveIfAbsent(intention.getId(), truncateId);
}else {
result.add(one);
intentionTruncationService.saveIfAbsent(one.getId(), truncateId);
}
}
return result;
}
@Override
public Intention queryByDigestAndDomainCategoryId(String digest, String domainCategoryId) {
return this.lambdaQuery().eq(Intention::getDigest, digest)
.eq(Intention::getDomainCategoryId, domainCategoryId).one();
}
@Override
public List<Intention> queryByDomainCategoryId(String domainCategoryId) {
return super.lambdaQuery().eq(Intention::getDomainCategoryId, domainCategoryId).list();
}
@Override
public List<Intention> listAllPassed() {
return super.lambdaQuery().eq(Intention::getGenerationType, "0").list();
}
}