Commit 1152dda6 authored by Allen Chen's avatar Allen Chen

commit

parent f14e0b27
......@@ -25,8 +25,10 @@ public class PddGDUtil {
while (page * page_size <= total_count) {
page++;
try {
JSONObject jsonObject = getTicketsByPage(1, end);
JSONObject respObject = getTicketsByPage(1, end);
JSONObject jsonObject = respObject.getJSONObject("logistics_ticket_get_response");
total_count = jsonObject.getInteger("total_count");
log.info("本次数量:{}", total_count);
List<GDTicketRepsonse> tempList = jsonObject.getJSONArray("logistics_ticket_list").toJavaList(GDTicketRepsonse.class);
if (tempList != null && !tempList.isEmpty()) {
list.addAll(tempList);
......
package org.ta.pddserver.utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
......@@ -13,6 +15,7 @@ import java.util.HashMap;
import java.util.Map;
@Slf4j
public class PddHttpTool {
// private static final String URL = "https://opengw-api.hutaojie.com/ark/router";
// private static final String URL_GD = "https://opengw-api.hutaojie.com/api/router";
......@@ -38,6 +41,7 @@ public class PddHttpTool {
}
public static String sendJsonPost(Object requestObj) {
log.info("REQ:{}", JSONObject.toJSONString(requestObj));
// 自动序列化 requestObj 为 JSON,并设置 Content-Type: application/json
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> resp = restTemplate.postForEntity(URL, requestObj, String.class);
......@@ -45,6 +49,7 @@ public class PddHttpTool {
}
public static String sendJsonPostGD(Object requestObj) {
log.info("REQ:{}", JSONObject.toJSONString(requestObj));
// 自动序列化 requestObj 为 JSON,并设置 Content-Type: application/json
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> resp = restTemplate.postForEntity(URL_GD, requestObj, String.class);
......
......@@ -61,7 +61,7 @@ public class PddSignTool {
}
// 5. 拼接appSecret(注意末尾无&)
paramStr.append(secret);
log.info("string = {}", paramStr.toString());
// log.info("string = {}", paramStr.toString());
// 6. MD5加密并转大写
return MD5Util.encode(paramStr.toString()).toUpperCase();
}
......
......@@ -3,12 +3,11 @@ package org.ta.pddserver.xxl;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.GDTicketEntity;
import org.ta.pddserver.model.pddgd.response.GDTicketRepsonse;
import org.ta.pddserver.service.GDTicketService;
import org.ta.pddserver.service.impl.GDTicketImpl;
import org.ta.pddserver.utils.PddGDUtil;
......@@ -17,17 +16,13 @@ import java.util.List;
@Component
@Slf4j
@EnableScheduling
public class GDOperator {
@Resource
GDTicketImpl gdTicketImpl;
@PostConstruct
public void init(){
getGdTickets();
}
@Scheduled(fixedRate = 1000 * 60 * 5) // 每5分钟执行一次
@Scheduled(fixedRate = 1000 * 60 * 5, initialDelay = 1000) // 每5分钟执行一次
public void getGdTickets() {
List<GDTicketRepsonse> list = PddGDUtil.getTickets();
log.info("{} 工单数量:{}", new Date().toLocaleString(), list.size());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment