master
ljl 9 months ago
parent 1ccf00955f
commit d4c36f1fc0

@ -0,0 +1,26 @@
package com.ms.biz.spi.timer;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.dto.ItemDTO;
import com.ms.biz.common.R;
import com.ms.biz.common.Ret;
import com.ms.biz.common.TimerBaseService;
import com.ms.biz.task.GetAuthInfoTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ExtensionService("getAuthInfoTimer")
@Slf4j
public class GetAuthInfoTimerService extends TimerBaseService implements ExtensionServiceHandler<ItemDTO, Ret> {
@Autowired
GetAuthInfoTaskService getAuthInfoTaskService;
@Override
public BaseResponse<Ret> handle(BaseRequest<ItemDTO> req) {
getAuthInfoTaskService.runTask();
return R.ok(Ret.success());
}
}

@ -0,0 +1,71 @@
package com.ms.biz.task;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.data.OpenGetAuthInfoData;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.ms.biz.common.TaskBaseService;
import com.ms.biz.util.DDApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.concurrent.Executor;
@Configuration
@Component
@Slf4j
public class GetAuthInfoTaskService extends TaskBaseService {
@Bean(name = "getAuthInfoTaskPool")
@Override
public Executor getAsyncExecutor() {
return super.getAsyncExecutor();
}
@Resource(name = "getAuthInfoTaskPool")
protected Executor taskPool;
@Async("getAuthInfoTaskPool")
@Scheduled(fixedRate = 10000)
@Override
public void runTask() {
super.runTask();
}
@Override
public int getCorePoolSiz() {
return 3;
}
@Override
public String getTaskExecutorName() {
return "getAuthInfoTaskPool";
}
@Override
protected Executor getTaskPool() {
return taskPool;
}
@Override
public Object getTask() {
return true;
}
@Override
public Object processTask(Object params) {
OpenGetAuthInfoParam param = new OpenGetAuthInfoParam();
param.setAuthId("1111502210");
OpenGetAuthInfoData data = DDApi.getAuthInfo(param);
log.info("GetAuthInfoService" + JSONObject.toJSONString(data));
return null;
}
@Override
public void clearTask(Object params) {
}
}

@ -2,6 +2,10 @@ package com.ms.biz.util;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoRequest;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoResponse;
import com.doudian.open.api.open_getAuthInfo.data.OpenGetAuthInfoData;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackRequest;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackResponse;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
@ -148,6 +152,16 @@ public class DDApi {
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static OpenGetAuthInfoData getAuthInfo(OpenGetAuthInfoParam param) {
OpenGetAuthInfoRequest request = new OpenGetAuthInfoRequest();
request.setParam(param);
OpenGetAuthInfoResponse response = request.execute();
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
private static <T, R> T execute(DoudianOpRequest<R> request) {
// GlobalConfig.getGlobalConfig().addHttpRequestHeader("X-USE-BOE", "1");
// GlobalConfig.getGlobalConfig().addHttpRequestHeader("Origin-From", "djt_prod");

Loading…
Cancel
Save