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

View File

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