123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package com.metro.job;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.metro.utils.HttpClientUtil;
- import lombok.extern.log4j.Log4j2;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.scheduling.annotation.EnableScheduling;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- /**
- * @ClassName: RenheCodeTask
- * @Description: TODO
- * @Author: ZS
- * @CreateName: lws
- * @Date 2022/3/23 16:18
- * ...
- */
- @Component
- @EnableScheduling
- @Log4j2
- @Slf4j
- public class RenheCodeTask {
- @Scheduled(cron = "0/5 * * * * ?")
- public void boot(){
- long begin = System.currentTimeMillis();
- String params = "{\"idNumber\": \"410322199907309877\",\"token\":\"hh_token_51063b27-9fd8-420d-b7eb-e5600fe0dec9\"}";
- String result = HttpClientUtil.httpPostSetConfig("https://renhe.hz-hanghui.com/health-code/hh/getHealthCode", params);
- if (StringUtils.isEmpty(result)) {
- long timeValue = System.currentTimeMillis() - begin;
- log.error("调用仁和接口调用失败,总耗时: {} 毫秒",timeValue);
- return;
- }
- JSONObject jsonObject = JSON.parseObject(result);
- if (200==jsonObject.getInteger("code")) {
- long timeValue = System.currentTimeMillis() - begin;
- } else {
- long timeValue = System.currentTimeMillis() - begin;
- log.error("调用仁和失败!:返回结果为:{},总耗时:{} 毫秒", result,timeValue);
- }
- }
- }
|