Merge branch 'dev' into 'release'
Dev See merge request wanghao/afis-recall!6
This commit is contained in:
@@ -23,6 +23,13 @@
|
||||
<alibaba.boot.druid>1.1.22</alibaba.boot.druid>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.wabestway.recall</groupId>
|
||||
<artifactId>afis-recall-api</artifactId>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.wabestway.recall.jobtask;
|
||||
|
||||
import com.wabestway.recall.trace.service.RecallOrderApiService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class GenVideoJobHandler {
|
||||
@Autowired
|
||||
private RecallOrderApiService recallOrderApiService;
|
||||
|
||||
@XxlJob("VideoGenJobHandler")
|
||||
public ReturnT<String> genRecallVideo() {
|
||||
log.info("[定时器:回溯视频]-开始执行");
|
||||
recallOrderApiService.traceVideo();
|
||||
log.info("[定时器:回溯视频]-执行完成");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.wabestway.recall.jobtask;
|
||||
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class XXLJobConfig {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(XXLJobConfig.class);
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String adminAddresses;
|
||||
|
||||
@Value("${xxl.job.accessToken}")
|
||||
private String accessToken;
|
||||
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appname;
|
||||
|
||||
@Value("${xxl.job.executor.port:-1}")
|
||||
private int port;
|
||||
|
||||
@Value("${xxl.job.executor.logpath}")
|
||||
private String logPath;
|
||||
|
||||
@Value("${xxl.job.executor.logretentiondays}")
|
||||
private int logRetentionDays;
|
||||
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||
xxlJobSpringExecutor.setAppname(appname);
|
||||
xxlJobSpringExecutor.setPort(port);
|
||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||
xxlJobSpringExecutor.setLogPath(logPath);
|
||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.wabestway.commons.http.Paging;
|
||||
import com.wabestway.commons.http.ResObj;
|
||||
import com.wabestway.recall.util.HeaderDataUtil;
|
||||
import com.wabestway.recall.util.ShortAppKeyGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import com.wabestway.ins.utils.UUIDUtil;
|
||||
@@ -47,6 +48,7 @@ public class RecallApiApiServiceImpl implements RecallApiApiService {
|
||||
BeanUtils.copyProperties(paramReq, recallApi);
|
||||
|
||||
recallApi.setId(UUIDUtil.generate());//赋值id
|
||||
recallApi.setAppKey(ShortAppKeyGenerator.generate());
|
||||
recallApi.setTenantId(HeaderDataUtil.getTenantId());
|
||||
recallApi.setCreateBy(HeaderDataUtil.getUserId());//创建人
|
||||
recallApi.setCreateTime(System.currentTimeMillis());//创建时间
|
||||
@@ -61,6 +63,7 @@ public class RecallApiApiServiceImpl implements RecallApiApiService {
|
||||
@Override
|
||||
public ResObj updateRecallApi(RecallApiDTO paramReq) {
|
||||
RecallApiEntity recallApi = new RecallApiEntity();
|
||||
paramReq.setAppKey(null);
|
||||
BeanUtils.copyProperties(paramReq, recallApi);
|
||||
recallApi.setUpdateBy(HeaderDataUtil.getUserId());//更新人
|
||||
recallApi.setUpdateTime(System.currentTimeMillis());//更新时间
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.wabestway.recall.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ShortAppKeyGenerator {
|
||||
private static final char[] BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
|
||||
|
||||
public static String generate() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
long mostSigBits = uuid.getMostSignificantBits();
|
||||
long leastSigBits = uuid.getLeastSignificantBits();
|
||||
byte[] bytes = new byte[16];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
bytes[i] = (byte) (mostSigBits >>> (8 * (7 - i)));
|
||||
bytes[i + 8] = (byte) (leastSigBits >>> (8 * (7 - i)));
|
||||
}
|
||||
return toBase62(bytes);
|
||||
}
|
||||
|
||||
private static String toBase62(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
long num = toLong(bytes);
|
||||
while (num > 0) {
|
||||
int remainder = (int) (num % 62);
|
||||
sb.append(BASE62_CHARS[remainder]);
|
||||
num /= 62;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static long toLong(byte[] bytes) {
|
||||
long result = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
result <<= 8;
|
||||
result |= (bytes[i] & 0xFF);
|
||||
}
|
||||
for (int i = 8; i < 16; i++) {
|
||||
result <<= 8;
|
||||
result |= (bytes[i] & 0xFF);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user