...
|
...
|
@@ -38,6 +38,9 @@ import java.nio.charset.StandardCharsets; |
|
|
import java.security.*;
|
|
|
import java.security.spec.PKCS8EncodedKeySpec;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2020/3/31.
|
...
|
...
|
@@ -63,6 +66,8 @@ public class ProductChainService { |
|
|
@Value("${urltrainblock.url}")
|
|
|
private String urltrainblockUrl;
|
|
|
|
|
|
private ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 2, 1, TimeUnit.HOURS, new ArrayBlockingQueue<>(10000));
|
|
|
|
|
|
// curl http://40.73.0.117:8078/yoho/post/query POST -H "Content-Type:application/json" -d '"id":"156663177401529"' -v
|
|
|
public void postQuery(Long chainId, String tagid) {
|
|
|
// (String serviceName, String url, Object request, Class<T> responseType, T fallback, int timeout)
|
...
|
...
|
@@ -92,10 +97,27 @@ public class ProductChainService { |
|
|
}
|
|
|
|
|
|
|
|
|
private class SynChainThread implements Runnable {
|
|
|
public SynChainThread(){}
|
|
|
|
|
|
public SynChainThread(Map<String, Object> request, Long id, String sign) {
|
|
|
this.request = request;
|
|
|
this.id = id;
|
|
|
this.sign = sign;
|
|
|
}
|
|
|
|
|
|
public void postChainInfo(Map<String, Object> request, Long id, String sign) {
|
|
|
private Map<String, Object> request;
|
|
|
|
|
|
private Long id;
|
|
|
|
|
|
private String sign;
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
postChainInfo(request, id, sign);
|
|
|
}
|
|
|
|
|
|
public void postChainInfo(Map<String, Object> request, Long id, String sign) {
|
|
|
HttpHeaders headers = getHttpHeaders(sign);
|
|
|
HttpEntity<String> formEntity = getStringHttpEntity(request, headers);
|
|
|
ResponseEntity<String> response = restTemplate.postForEntity(urltrainblockUrl + "/post/info", formEntity, String.class);
|
...
|
...
|
@@ -109,6 +131,12 @@ public class ProductChainService { |
|
|
updateIsupload(id, 1); // 如果更新成功,则更新数据库字段
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void aSynPostChainInfo(Map<String, Object> request, Long id, String sign) {
|
|
|
executor.submit(new SynChainThread(request, id, sign));
|
|
|
}
|
|
|
|
|
|
// SELECT * FROM ${TABLE_PRODUCT_CHAIN} WHERE transaction_id IS NULL
|
|
|
public List<ProductChain> queryProductChain() {
|
...
|
...
|
|