|
|
@@ -22,6 +22,7 @@ import top.lvzhiqiang.service.CoinService;
|
|
|
import top.lvzhiqiang.util.CheckSign4Bitget;
|
|
|
import top.lvzhiqiang.util.DateUtils;
|
|
|
import top.lvzhiqiang.util.JsoupUtil;
|
|
|
+import top.lvzhiqiang.util.SpringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
@@ -45,6 +46,17 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class CoinServiceImpl implements CoinService {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 任务告警方式-应用文本卡片
|
|
|
+ */
|
|
|
+ public static final String JOB_ALARM_MODE_APP_TEXT_CARD = "1";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 任务告警方式-群聊机器人
|
|
|
+ */
|
|
|
+ public static final String JOB_ALARM_MODE_CHAT_BOT = "2";
|
|
|
+
|
|
|
// 所有REST请求的header都必须包含以下key:
|
|
|
private static final Map<String, String> basicHeaderMap = new HashMap<>();
|
|
|
// 主域名 URL
|
|
|
@@ -109,22 +121,23 @@ public class CoinServiceImpl implements CoinService {
|
|
|
JSONArray orderList = response.getJSONObject("data").getJSONArray("orderList");
|
|
|
if (orderList.size() > 0) {
|
|
|
coinMapper.insertHistoryOrderList(JSONArray.parseArray(orderList.toJSONString(), CoinHistoryOrder.class));
|
|
|
+ log.warn("syncData->insertHistoryOrderList,startTime={},endTime={},size={}", startTime, endTime, orderList.size());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- @Async("coinTaskExecutor")
|
|
|
public String monitorJob() {
|
|
|
Timer timer = new Timer();
|
|
|
timer.scheduleAtFixedRate(new TimerTask() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+ LocalDateTime endTime = LocalDateTime.now();
|
|
|
// 全部历史委托监控
|
|
|
Map<String, String> paramMap = new LinkedHashMap<>();
|
|
|
paramMap.put("productType", "umcbl");
|
|
|
- paramMap.put("startTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(LocalDateTime.now().minusSeconds(10))));
|
|
|
- paramMap.put("endTime", String.valueOf(System.currentTimeMillis()));
|
|
|
+ paramMap.put("startTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(endTime.minusSeconds(10))));
|
|
|
+ paramMap.put("endTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(endTime)));
|
|
|
paramMap.put("pageSize", "100");
|
|
|
|
|
|
String signQueryString = paramMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
|
|
|
@@ -135,9 +148,9 @@ public class CoinServiceImpl implements CoinService {
|
|
|
JSONObject order = orderList.getJSONObject(i);
|
|
|
LocalDateTime cTime = DateUtils.longToLocalDateTime(order.getLong("cTime"));
|
|
|
String orderId = order.getString("orderId");
|
|
|
- if (Duration.between(cTime, LocalDateTime.now()).getSeconds() < 5 && !orderMap.containsKey(order.getString("orderId"))) {
|
|
|
+ if (Duration.between(cTime, endTime).getSeconds() < 5 && !orderMap.containsKey(orderId)) {
|
|
|
orderMap.put(orderId, "1");
|
|
|
- monitorAlarm(order);
|
|
|
+ SpringUtils.getBean(CoinServiceImpl.class).monitorAlarm(order);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -279,16 +292,4 @@ public class CoinServiceImpl implements CoinService {
|
|
|
jsonObject.put("symbol", "<strong style=\"background-color:#F1B90d;\"><font color=\"#242A30\">" + symbol + "</font></strong>USDT_UMCBL");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- CoinServiceImpl coinService = new CoinServiceImpl();
|
|
|
- JSONObject params = new JSONObject();
|
|
|
- /*params.put("nameEn", "allPositionv2");
|
|
|
- params.put("url", "/api/mix/v1/position/allPosition-v2");*/
|
|
|
-
|
|
|
- /*params.put("nameEn", "orderMarginCoinCurrent");
|
|
|
- params.put("url", "/api/mix/v1/order/marginCoinCurrent");*/
|
|
|
-
|
|
|
- System.out.println(coinService.mainSearch(params));
|
|
|
- }
|
|
|
}
|