| | |
| | | |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.service.business.impl.hksync.HkSyncImgServiceImpl; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.utils.URIBuilder; |
| | |
| | | @EnableScheduling |
| | | public class ScheduleTool { |
| | | |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | private HkSyncImgServiceImpl hkSyncImgService; |
| | | /** |
| | | * 是否开发者 |
| | | */ |
| | |
| | | * 缓存省市区 |
| | | * @throws Exception |
| | | */ |
| | | @Scheduled(fixedDelay=24*60*60*1000) |
| | | public void cacheCampus() throws Exception { |
| | | } |
| | | /** |
| | | * 每天凌晨重置所有订单code类初始值 |
| | | * @throws Exception |
| | | */ |
| | | @Scheduled(cron="0 0 0 * * ?") |
| | | public void resetOrderCodes() throws Exception { |
| | | @Scheduled(fixedDelay= 60*1000) |
| | | public void downloadHkImg() throws Exception { |
| | | hkSyncImgService.downHKImgs(0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 发送get请求 |
| | | * @param url 请求URL |
| | | * @param param 请求参数 key:value url携带参数 或者无参可不填 |
| | | * @return |
| | | */ |
| | | public String doGet(String url, Map<String, String> param) { |
| | | // 创建Httpclient对象 |
| | | CloseableHttpClient httpclient = HttpClients.createDefault(); |
| | | String resultString = ""; |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | // 创建uri |
| | | URIBuilder builder = new URIBuilder(url); |
| | | if (param != null) { |
| | | for (String key : param.keySet()) { |
| | | builder.addParameter(key, param.get(key)); |
| | | } |
| | | } |
| | | URI uri = builder.build(); |
| | | // 创建http GET请求 |
| | | HttpGet httpGet = new HttpGet(uri); |
| | | // 执行请求 |
| | | response = httpclient.execute(httpGet); |
| | | // 判断返回状态是否为200 |
| | | if (response.getStatusLine().getStatusCode() == 200) { |
| | | resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (response != null) { |
| | | response.close(); |
| | | } |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return resultString; |
| | | } |
| | | |
| | | } |