diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java index 3904011b00..2939bd62eb 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java @@ -26,4 +26,13 @@ public class RedisKeys { public static String getWhiteList () { return rootPrefix.concat("openapi:scan:whitelist"); } + + /** + * desc: 语音检测任务,异步回调,需要根据taskId获取存储seed的Key + * @param taskId 提交检测任务API接口返回的taskId eg:1001 + * @return epmet:openapi:scan:voice:seed:1001 + */ + public static String getVoiceScanSeedKey(String taskId){ + return rootPrefix.concat("openapi:scan:voice:seed:").concat(taskId); + } } diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/redis/ScanRedis.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/redis/ScanRedis.java deleted file mode 100644 index 294d40e04c..0000000000 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/redis/ScanRedis.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.openapi.scan.redis; - -import com.epmet.commons.tools.redis.RedisUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 用户居民端注册信息表 用户在居民端完善的个人信息 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-03-30 - */ -@Component -public class ScanRedis { - @Autowired - private RedisUtils redisUtils; - - public void test(){ - redisUtils.set("yinzuomei", "尹作梅测试用",RedisUtils.MINUTE_THIRTY_EXPIRE); - } - - public void setVoiceScanKey(String taskId, String seed) { - redisUtils.set(taskId, seed,RedisUtils.HOUR_FOUR_EXPIRE); - } -} \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java index 6ea86b824f..86897f5a9e 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java @@ -14,8 +14,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.openapi.scan.common.constant.SysConstant; import com.epmet.openapi.scan.common.enu.*; import com.epmet.openapi.scan.common.exception.ExecuteHttpException; +import com.epmet.openapi.scan.common.redis.RedisKeys; import com.epmet.openapi.scan.common.util.IAcsClientUtil; -import com.epmet.openapi.scan.redis.ScanRedis; import com.epmet.openapi.scan.support.param.*; import com.epmet.openapi.scan.support.result.*; import lombok.extern.slf4j.Slf4j; @@ -24,6 +24,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -44,7 +46,7 @@ public class ScanServiceImpl implements ScanService { @Value("${aliyun.green.bizType}") private String bizType; @Autowired - private ScanRedis scanRedis; + private RedisTemplate redisTemplate; @Override public Result sendTextScan(TextScanParam textScanParam) { //默认参数 @@ -308,8 +310,10 @@ public class ScanServiceImpl implements ScanService { if (StringUtils.isNotBlank(voiceAsyncScanParam.getCallback())) { // 存储seed和 任务id、dataId的关系 用于回调鉴权 log.info("need to save seed and taskId、dataId的关系"); + ValueOperations valueOperations=redisTemplate.opsForValue(); taskList.forEach(task -> { - scanRedis.setVoiceScanKey(task.getTaskId(), voiceAsyncScanParam.getSeed()); + String seedKey = RedisKeys.getVoiceScanSeedKey(task.getTaskId()); + valueOperations.set(seedKey,voiceAsyncScanParam.getSeed()); }); } return new Result().ok(resultDto);