This commit is contained in:
lcj
2025-11-06 09:18:34 +08:00
parent d26a99cdbb
commit d1d6c443de
2 changed files with 23 additions and 20 deletions

View File

@ -32,7 +32,7 @@ public class DashScopeChat {
private final ChatClient chatClient; private final ChatClient chatClient;
private static final String DEFAULT_PROMPT = "你是一个博学的智能聊天助手,请根据用户提问回答!"; private static final String DEFAULT_PROMPT = "叫煤球,是一个博学的智能聊天助手,请根据用户提问回答!";
private static final String DEFAULT_FILE_DIR = System.getProperty("user.dir") + "/chat-memory"; private static final String DEFAULT_FILE_DIR = System.getProperty("user.dir") + "/chat-memory";
@ -96,7 +96,7 @@ public class DashScopeChat {
} }
// 构建生成标题的提示词 // 构建生成标题的提示词
String prompt = String.format(""" String prompt = String.format("""
请为下面这段用户与AI的对话生成一个简短的标题不超过10个字 请为下面这段用户与AI的对话生成一个简短的标题不超过10个字,并且以陈述句的形式进行总结
用户:%s 用户:%s
AI%s AI%s
""", userMessage, aiResponse); """, userMessage, aiResponse);

View File

@ -218,26 +218,23 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
List<HseViolationLevel> levelList = violationLevelService.lambdaQuery() List<HseViolationLevel> levelList = violationLevelService.lambdaQuery()
.in(HseViolationLevel::getProjectId, projectIds) .in(HseViolationLevel::getProjectId, projectIds)
.list(); .list();
if (CollUtil.isEmpty(levelList)) {
log.error("未设置安全等级");
return;
}
Map<Long, List<RecognizerTypeEnum>> level = new HashMap<>(); Map<Long, List<RecognizerTypeEnum>> level = new HashMap<>();
Map<Long, List<HseViolationLevel>> levelMap = levelList.stream() if (CollUtil.isNotEmpty(levelList)) {
.collect(Collectors.groupingBy(HseViolationLevel::getProjectId)); Map<Long, List<HseViolationLevel>> levelMap = levelList.stream()
for (Map.Entry<Long, List<HseViolationLevel>> entry : levelMap.entrySet()) { .collect(Collectors.groupingBy(HseViolationLevel::getProjectId));
List<RecognizerTypeEnum> recognizerTypeEnums = entry.getValue().stream().map(l -> { for (Map.Entry<Long, List<HseViolationLevel>> entry : levelMap.entrySet()) {
List<String> levels = StringUtils.splitList(l.getViolationType()); List<RecognizerTypeEnum> recognizerTypeEnums = entry.getValue().stream().map(l -> {
return RecognizerTypeEnum.listFromCodes(levels); List<String> levels = StringUtils.splitList(l.getViolationType());
}).filter(CollUtil::isNotEmpty) return RecognizerTypeEnum.listFromCodes(levels);
.flatMap(Collection::stream) }).filter(CollUtil::isNotEmpty)
.distinct() .flatMap(Collection::stream)
.toList(); .distinct()
level.put(entry.getKey(), recognizerTypeEnums); .toList();
level.put(entry.getKey(), recognizerTypeEnums);
}
} }
if (CollUtil.isEmpty(level)) { if (CollUtil.isEmpty(level)) {
log.error("未设置安全等级"); log.error("未设置安全等级");
return;
} }
for (OthYs7DeviceImgCreateByCapture img : imgList) { for (OthYs7DeviceImgCreateByCapture img : imgList) {
OthYs7DeviceImg othYs7DeviceImg = new OthYs7DeviceImg(); OthYs7DeviceImg othYs7DeviceImg = new OthYs7DeviceImg();
@ -253,9 +250,13 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
othYs7DeviceImg.setDeviceName(img.getDeviceName()); othYs7DeviceImg.setDeviceName(img.getDeviceName());
othYs7DeviceImg.setUrl(ossUrl); othYs7DeviceImg.setUrl(ossUrl);
// 将抓取的图片进行识别 // 将抓取的图片进行识别
List<RecognizerTypeEnum> recTypes = level.get(img.getProjectId()); List<RecognizerTypeEnum> recTypes = new ArrayList<>();
if (CollUtil.isNotEmpty(level)) {
recTypes = level.get(img.getProjectId());
}
if (CollUtil.isEmpty(recTypes)) { if (CollUtil.isEmpty(recTypes)) {
log.error("未设置安全等级"); log.error("项目:{}未设置安全等级", img.getProjectId());
saveList.add(othYs7DeviceImg);
continue; continue;
} }
RecognizeVo recognizeVo = null; RecognizeVo recognizeVo = null;
@ -301,12 +302,14 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
} }
} }
if (CollUtil.isNotEmpty(saveList)) { if (CollUtil.isNotEmpty(saveList)) {
log.info("批量保存抓拍图片开始,共:{} 张", saveList.size());
boolean result = saveBatch(saveList); boolean result = saveBatch(saveList);
if (!result) { if (!result) {
throw new ServiceException("批量新增图片失败,数据库异常", HttpStatus.ERROR); throw new ServiceException("批量新增图片失败,数据库异常", HttpStatus.ERROR);
} }
} }
if (CollUtil.isNotEmpty(recordList)) { if (CollUtil.isNotEmpty(recordList)) {
log.info("批量保存识别记录开始,共:{} 条", recordList.size());
recognizeRecordService.saveByMonitor(recordList); recognizeRecordService.saveByMonitor(recordList);
} }
} }