|
@@ -16,7 +16,7 @@
|
|
|
*/
|
|
|
package org.springblade.archive.service.impl;
|
|
|
|
|
|
-import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.archive.entity.ArchiveAiName;
|
|
@@ -25,22 +25,16 @@ import org.springblade.archive.service.IArchiveAiNameService;
|
|
|
import org.springblade.archive.vo.ArchiveAiNameVO;
|
|
|
import org.springblade.archive.vo.ArchiveAiNameVO1;
|
|
|
import org.springblade.common.utils.DeepSeekClient;
|
|
|
-import org.springblade.common.vo.DeepSeekResponse;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -79,17 +73,24 @@ public class ArchiveAiNameServiceImpl extends BaseServiceImpl<ArchiveAiNameMappe
|
|
|
apiSemaphore.acquire();
|
|
|
try {
|
|
|
String content = deepSeekClient.getSimplifiedContent(name.getArchiveName() + DEEPSEEK_ARCHIVE_NAME);
|
|
|
- name.setArchiveNameAi(content);
|
|
|
- name.setStatus(2);
|
|
|
+ if (content.startsWith("API_ERROR:") ||
|
|
|
+ content.startsWith("PARSE_ERROR:") ||
|
|
|
+ content.startsWith("IO_ERROR:")||content.startsWith("Error:")) {
|
|
|
+ name.setStatus(4);
|
|
|
+ name.setArchiveNameAi("获取失败");
|
|
|
+ } else {
|
|
|
+ name.setArchiveNameAi(content);
|
|
|
+ name.setStatus(2); // 标记为成功
|
|
|
+ }
|
|
|
} finally {
|
|
|
apiSemaphore.release();
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
|
Thread.currentThread().interrupt();
|
|
|
- name.setStatus(2); // 设置失败状态
|
|
|
+ name.setStatus(4); // 设置失败状态
|
|
|
name.setArchiveNameAi("获取失败");
|
|
|
} catch (Exception e) {
|
|
|
- name.setStatus(2); // 设置失败状态
|
|
|
+ name.setStatus(4); // 设置失败状态
|
|
|
name.setArchiveNameAi("获取失败");
|
|
|
}
|
|
|
});
|
|
@@ -128,16 +129,14 @@ public class ArchiveAiNameServiceImpl extends BaseServiceImpl<ArchiveAiNameMappe
|
|
|
|
|
|
@Transactional
|
|
|
public boolean confirmAiName(List<ArchiveAiNameVO1>vos) {
|
|
|
- List<ArchiveAiName> archiveAiNameList = this.listByIds(vos.stream().map(o->o.getId()).collect(Collectors.toList()));
|
|
|
- if(!archiveAiNameList.isEmpty()){
|
|
|
- for (ArchiveAiNameVO1 archiveAiName : vos) {
|
|
|
- if(archiveAiName.getStatus()==2&& StringUtils.isNotEmpty(archiveAiName.getArchiveNameAi())){
|
|
|
- archiveAiName.setStatus(3);
|
|
|
- String sql=" update u_archives_auto set name='"+archiveAiName.getArchiveNameAi()+"' where id="+archiveAiName.getId();
|
|
|
- jdbcTemplate.update(sql);
|
|
|
- }
|
|
|
+ for (ArchiveAiNameVO1 archiveAiName : vos) {
|
|
|
+ if(archiveAiName.getStatus()==2&& StringUtils.isNotEmpty(archiveAiName.getArchiveNameAi())){
|
|
|
+ archiveAiName.setStatus(3);
|
|
|
+ String sql=" update u_archives_auto set name='"+archiveAiName.getArchiveNameAi()+"' where id="+archiveAiName.getArchiveAutoId();
|
|
|
+ jdbcTemplate.update(sql);
|
|
|
+ String sql2="update u_archive_ai_name set status=3 where id="+archiveAiName.getId();
|
|
|
+ jdbcTemplate.update(sql2);
|
|
|
}
|
|
|
- return this.updateBatchById(archiveAiNameList);
|
|
|
}
|
|
|
return true;
|
|
|
}
|