You've already forked FrameTour-BE
refactor(face): 替换Strings工具类引用以优化代码
- 将org.apache.logging.log4j.util.Strings替换为org.apache.commons.lang3.StringUtils - 统一使用StringUtils处理字符串判空逻辑 - 优化线程join条件判断中的字符串比较方式 - 更新所有相关字符串工具方法调用以保持一致性
This commit is contained in:
@@ -85,7 +85,8 @@ import com.ycwl.basic.storage.enums.StorageAcl;
|
|||||||
import com.ycwl.basic.storage.utils.StorageUtil;
|
import com.ycwl.basic.storage.utils.StorageUtil;
|
||||||
import com.ycwl.basic.utils.*;
|
import com.ycwl.basic.utils.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.Strings;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -313,14 +314,14 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
Long finalFaceId = newFaceId;
|
Long finalFaceId = newFaceId;
|
||||||
Thread thread = new Thread(() -> printerService.autoAddPhotosToPreferPrint(finalFaceId), "auto-add-print-" + newFaceId);
|
Thread thread = new Thread(() -> printerService.autoAddPhotosToPreferPrint(finalFaceId), "auto-add-print-" + newFaceId);
|
||||||
thread.start();
|
thread.start();
|
||||||
if (org.apache.commons.lang3.Strings.CI.equals("print", scene)) {
|
if (Strings.CI.equals("print", scene)) {
|
||||||
try {
|
try {
|
||||||
thread.join();
|
thread.join();
|
||||||
} catch (InterruptedException ignore) {
|
} catch (InterruptedException ignore) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (org.apache.commons.lang3.Strings.CI.equals("aiCam", scene)) {
|
if (Strings.CI.equals("aiCam", scene)) {
|
||||||
faceDetectLogAiCamService.searchAndLog(scenicId, newFaceId, faceUrl, faceBodyAdapter);
|
faceDetectLogAiCamService.searchAndLog(scenicId, newFaceId, faceUrl, faceBodyAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +597,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
sourceImageContent.setSourceType(2);
|
sourceImageContent.setSourceType(2);
|
||||||
sourceImageContent.setLockType(-1);
|
sourceImageContent.setLockType(-1);
|
||||||
sourceImageContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
sourceImageContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
||||||
if (Strings.isBlank(sourceVideoContent.getTemplateCoverUrl())) {
|
if (StringUtils.isBlank(sourceVideoContent.getTemplateCoverUrl())) {
|
||||||
sourceVideoContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
sourceVideoContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -807,7 +808,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
String matchResult = face.getMatchResult();
|
String matchResult = face.getMatchResult();
|
||||||
if (matchResult == null || Strings.isBlank(matchResult)) {
|
if (matchResult == null || StringUtils.isBlank(matchResult)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
||||||
@@ -1013,7 +1014,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
handleCustomFaceMatching(faceId, finalSampleList);
|
handleCustomFaceMatching(faceId, finalSampleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNotBlank(req.getRemark())) {
|
if (StringUtils.isNotBlank(req.getRemark())) {
|
||||||
log.info("人脸识别人工调整备注:faceId={}, remark={}", faceId, req.getRemark());
|
log.info("人脸识别人工调整备注:faceId={}, remark={}", faceId, req.getRemark());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1040,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
detail.setLastMatchedAt(face.getUpdateAt() != null ? face.getUpdateAt() : face.getCreateAt());
|
detail.setLastMatchedAt(face.getUpdateAt() != null ? face.getUpdateAt() : face.getCreateAt());
|
||||||
|
|
||||||
String matchResultJson = face.getMatchResult();
|
String matchResultJson = face.getMatchResult();
|
||||||
if (Strings.isBlank(matchResultJson)) {
|
if (StringUtils.isBlank(matchResultJson)) {
|
||||||
detail.setAcceptedSamples(Collections.emptyList());
|
detail.setAcceptedSamples(Collections.emptyList());
|
||||||
detail.setFilteredSamples(Collections.emptyList());
|
detail.setFilteredSamples(Collections.emptyList());
|
||||||
return detail;
|
return detail;
|
||||||
@@ -1159,7 +1160,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> parseMatchSampleIds(String matchSampleIds) {
|
private List<Long> parseMatchSampleIds(String matchSampleIds) {
|
||||||
if (Strings.isBlank(matchSampleIds)) {
|
if (StringUtils.isBlank(matchSampleIds)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
String[] segments = matchSampleIds.split(",");
|
String[] segments = matchSampleIds.split(",");
|
||||||
@@ -1174,7 +1175,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Long parseLongSilently(String value) {
|
private Long parseLongSilently(String value) {
|
||||||
if (Strings.isBlank(value)) {
|
if (StringUtils.isBlank(value)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -1226,10 +1227,10 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
if (sourceEntity == null) {
|
if (sourceEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!Strings.isBlank(sourceEntity.getThumbUrl())) {
|
if (!StringUtils.isBlank(sourceEntity.getThumbUrl())) {
|
||||||
return sourceEntity.getThumbUrl();
|
return sourceEntity.getThumbUrl();
|
||||||
}
|
}
|
||||||
if (!Strings.isBlank(sourceEntity.getUrl())) {
|
if (!StringUtils.isBlank(sourceEntity.getUrl())) {
|
||||||
return sourceEntity.getUrl();
|
return sourceEntity.getUrl();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user