Commit 51bc347f by xmh

匹配bug修复,代码优化

1 parent 6e44e6cb
......@@ -325,7 +325,7 @@ public class ReidService {
Date max = DateUtil.addMinutes(pic.getCreateTime(), timeInterval);
Date min = DateUtil.addMinutes(pic.getCreateTime(), -timeInterval);
countTimeLTE = countTimeLTE == null ? max : max.compareTo(countTimeLTE) > 0 ? max : countTimeLTE;
countTimeGTE = countTimeGTE == null ? min : min.compareTo(countTimeGTE) < 0 ? min : countTimeLTE;
countTimeGTE = countTimeGTE == null ? min : min.compareTo(countTimeGTE) < 0 ? min : countTimeGTE;
}
BodyFeature feature = storageUtils.getBodyFeature(picId);
......
......@@ -5,6 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.viontech.label.core.base.DateConverter;
import com.viontech.label.tool.keliu.service.FileService;
import com.viontech.label.tool.keliu.service.LocalFileServiceImpl;
import com.viontech.label.tool.keliu.service.OnlineFileServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -48,6 +52,19 @@ public class WebConfig implements WebMvcConfigurer {
return restTemplateBuilder.build();
}
@Bean("fileService")
@ConditionalOnProperty("vion.keliu-image-path")
public FileService localFileService() {
return new LocalFileServiceImpl();
}
@Bean("fileService")
@ConditionalOnProperty("vion.keliu-image-url")
public FileService onlineFileService() {
return new OnlineFileServiceImpl();
}
@Configuration
public static class CorsConfig {
@Bean
......
package com.viontech.label.tool.keliu.service;
import com.viontech.label.tool.keliu.config.VionConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
......@@ -14,12 +13,15 @@ import java.io.File;
* @author 谢明辉
* @date 2021/7/9
*/
@Service("fileService")
@ConditionalOnProperty("vion.keliu-image-path")
@Slf4j
public class LocalFileServiceImpl implements FileService {
@Resource
private VionConfig vionConfig;
public LocalFileServiceImpl() {
log.info("======================= LocalFileServiceImpl =======================");
}
@Override
public byte[] getFile(String filePath) {
try {
......
package com.viontech.label.tool.keliu.service;
import com.viontech.label.tool.keliu.config.VionConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
......@@ -13,8 +12,7 @@ import javax.annotation.Resource;
* @author 谢明辉
* @date 2021/7/9
*/
@Service("fileService")
@ConditionalOnProperty("vion.keliu-image-url")
@Slf4j
public class OnlineFileServiceImpl implements FileService {
@Resource
......@@ -22,6 +20,10 @@ public class OnlineFileServiceImpl implements FileService {
@Resource
private RestTemplate restTemplate;
public OnlineFileServiceImpl() {
log.info("======================= OnlineFileServiceImpl =======================");
}
@Override
public byte[] getFile(String filePath) {
return restTemplate.getForObject(vionConfig.getKeliuImageUrl() + filePath, byte[].class);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!