You've already forked FrameTour-BE
支持图片占位符
This commit is contained in:
@@ -60,6 +60,7 @@ import com.ycwl.basic.utils.VideoReUploader;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -257,6 +258,34 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理以P开头的templatePlaceHolder,添加type=2的source
|
||||||
|
boolean hasPPlaceholder = templatePlaceholder.stream().anyMatch(placeholder -> placeholder.startsWith("P"));
|
||||||
|
if (hasPPlaceholder) {
|
||||||
|
List<SourceEntity> imageSourceList = sourceMapper.listImageSourcesByFaceId(faceId);
|
||||||
|
if (!imageSourceList.isEmpty()) {
|
||||||
|
// 将图片source按设备ID分组并添加到sourcesMap中
|
||||||
|
Map<String, List<SourceEntity>> imageSourceMap = imageSourceList.stream()
|
||||||
|
.peek(item -> item.setUrl(item.getUrl())) // 图片使用url字段
|
||||||
|
.filter(item -> item.getDeviceId() != null)
|
||||||
|
.filter(item -> {
|
||||||
|
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||||
|
if (device == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Integer.valueOf(1).equals(device.getStatus());
|
||||||
|
})
|
||||||
|
.collect(Collectors.groupingBy(item -> Strings.concat("P", item.getDeviceId().toString())));
|
||||||
|
|
||||||
|
// 合并到现有的sourcesMap中
|
||||||
|
imageSourceMap.forEach((key, value) -> {
|
||||||
|
sourcesMap.merge(key, value, (existing, replacement) -> {
|
||||||
|
existing.addAll(replacement);
|
||||||
|
return existing;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||||
taskReqQuery.setFaceId(faceId);
|
taskReqQuery.setFaceId(faceId);
|
||||||
taskReqQuery.setTemplateId(templateId);
|
taskReqQuery.setTemplateId(templateId);
|
||||||
@@ -469,6 +498,34 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理以P开头的templatePlaceHolder,添加type=2的source
|
||||||
|
boolean hasPPlaceholder = templatePlaceholder.stream().anyMatch(placeholder -> placeholder.startsWith("P"));
|
||||||
|
if (hasPPlaceholder) {
|
||||||
|
List<SourceEntity> imageSourceList = sourceMapper.listImageSourcesByFaceId(faceId);
|
||||||
|
if (!imageSourceList.isEmpty()) {
|
||||||
|
// 将图片source按设备ID分组并添加到sourcesMap中
|
||||||
|
Map<String, List<SourceEntity>> imageSourceMap = imageSourceList.stream()
|
||||||
|
.peek(item -> item.setUrl(item.getUrl())) // 图片使用url字段
|
||||||
|
.filter(item -> item.getDeviceId() != null)
|
||||||
|
.filter(item -> {
|
||||||
|
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||||
|
if (device == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Integer.valueOf(1).equals(device.getStatus());
|
||||||
|
})
|
||||||
|
.collect(Collectors.groupingBy(item -> Strings.concat("P", item.getDeviceId().toString())));
|
||||||
|
|
||||||
|
// 合并到现有的sourcesMap中
|
||||||
|
imageSourceMap.forEach((key, value) -> {
|
||||||
|
sourcesMap.merge(key, value, (existing, replacement) -> {
|
||||||
|
existing.addAll(replacement);
|
||||||
|
return existing;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
TaskReqQuery taskReqQuery = new TaskReqQuery();
|
||||||
taskReqQuery.setFaceId(faceId);
|
taskReqQuery.setFaceId(faceId);
|
||||||
taskReqQuery.setTemplateId(templateId);
|
taskReqQuery.setTemplateId(templateId);
|
||||||
|
@@ -248,4 +248,10 @@
|
|||||||
set member_id = #{memberId}
|
set member_id = #{memberId}
|
||||||
where face_id = #{faceId}
|
where face_id = #{faceId}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="listImageSourcesByFaceId" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||||
|
select s.*
|
||||||
|
from source s
|
||||||
|
inner join member_source ms on s.id = ms.source_id
|
||||||
|
where ms.face_id = #{faceId} and s.type = 2
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Reference in New Issue
Block a user