diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java index af93b3c..37bb18f 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java @@ -12,6 +12,7 @@ import com.hnac.hzinfo.inspect.ai.service.IZhiPuBigModelService; import com.hnac.hzinfo.inspect.ai.vo.ZhiPuImageAnalysisDTO; import com.hnac.hzinfo.inspect.utils.HiKUtil; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.StringUtil; @@ -21,6 +22,8 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** @@ -29,6 +32,7 @@ import java.util.stream.Collectors; */ @Service @AllArgsConstructor +@Slf4j public class ZhiPuBigModelServiceImpl implements IZhiPuBigModelService { private final IStationVideoTypeClient stationVideoTypeClient; @@ -59,7 +63,6 @@ public class ZhiPuBigModelServiceImpl implements IZhiPuBigModelService { if (StringUtil.isBlank(url)) { continue; } - BigModelAnalysisRequestDTO zhiPuRequest = new BigModelAnalysisRequestDTO(); zhiPuRequest.setUrl(url); zhiPuRequest.setCheckTypeSonList(analysisTypeList); @@ -85,23 +88,35 @@ public class ZhiPuBigModelServiceImpl implements IZhiPuBigModelService { @Override public List getZhiPuAnalysisType(String[] originalCode) { List result = new ArrayList<>(); + Map typeMap = mappingTypes(); + for (String code : originalCode) { + String zhiPuType = typeMap.get(code); + if (StringUtil.isNotBlank(zhiPuType)) { + result.add(zhiPuType); + } + } + return result; + } + + public Map mappingTypes() { + Map typeMap = new ConcurrentHashMap<>(); R> zhiPuResponse = dictClient.getList(ZHI_PU_TYPE_KEY); - if (!zhiPuResponse.isSuccess()) { - return result; + if (!zhiPuResponse.isSuccess() || CollectionUtil.isEmpty(zhiPuResponse.getData())) { + return typeMap; + } + R> cameraResponse = dictClient.getList(CAMERA_TYPE_KEY); + if (!cameraResponse.isSuccess() || CollectionUtil.isEmpty(cameraResponse.getData())) { + return typeMap; } List zhiPuList = zhiPuResponse.getData(); - for (String code : originalCode) { - R valueResponse = dictClient.getValue(CAMERA_TYPE_KEY, code); - if (!valueResponse.isSuccess()|| StringUtil.isBlank(valueResponse.getData())) { - continue; - } - String value = valueResponse.getData(); - for (Dict dict : zhiPuList) { - if (value.indexOf(dict.getDictValue()) >= 0 || dict.getDictValue().indexOf(value) >= 0) { - result.add(dict.getDictKey()); + List cameraList = cameraResponse.getData(); + for (Dict camera : cameraList) { + for (Dict zhiPu : zhiPuList) { + if (camera.getDictValue().indexOf(zhiPu.getDictValue()) >= 0 || zhiPu.getDictValue().indexOf(camera.getDictValue()) >= 0) { + typeMap.put(camera.getDictKey(), zhiPu.getDictKey()); } } } - return result; + return typeMap; } }