From 73ad522d4b5545eb9a88086a9e542d1cd4e80aa6 Mon Sep 17 00:00:00 2001 From: luyie Date: Fri, 30 Aug 2024 17:10:33 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=99=BA=E8=B0=B1=E5=88=86=E6=9E=90?= =?UTF-8?q?=E6=8C=89=E7=AB=99=E7=82=B9=E6=88=AA=E5=9B=BE=E5=88=86=E6=9E=90?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=AF=86=E5=88=AB=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/service/impl/ZhiPuBigModelServiceImpl.java | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) 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; } }