|
|
@@ -1,168 +1,26 @@
|
|
|
-//package com.hfln.portal.infrastructure.job;
|
|
|
-//
|
|
|
-//import com.alibaba.fastjson2.JSONObject;
|
|
|
-//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-//import com.fasterxml.jackson.databind.JsonNode;
|
|
|
-//import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-//import com.google.common.collect.Lists;
|
|
|
-//import com.hfln.portal.infrastructure.po.DevTarget;
|
|
|
-//import com.hfln.portal.infrastructure.service.DevTargetService;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
-//import org.apache.http.client.methods.HttpGet;
|
|
|
-//import org.apache.http.client.utils.URIBuilder;
|
|
|
-//import org.apache.http.util.EntityUtils;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.scheduling.annotation.Scheduled;
|
|
|
-//import org.springframework.stereotype.Component;
|
|
|
-//
|
|
|
-//import java.io.ByteArrayInputStream;
|
|
|
-//import java.security.cert.CertificateExpiredException;
|
|
|
-//import java.security.cert.CertificateFactory;
|
|
|
-//import java.security.cert.CertificateNotYetValidException;
|
|
|
-//import java.security.cert.X509Certificate;
|
|
|
-//import java.sql.Timestamp;
|
|
|
-//import java.time.LocalDateTime;
|
|
|
-//import java.util.ArrayList;
|
|
|
-//import java.util.Date;
|
|
|
-//import java.util.List;
|
|
|
-//
|
|
|
-//@Slf4j
|
|
|
-//@Component
|
|
|
-//public class ScheduledTask {
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private DevTargetService devTargetService;
|
|
|
-//
|
|
|
-// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
-// public void runAtOneAM() {
|
|
|
-//
|
|
|
-// devTargetService.remove(new LambdaQueryWrapper<DevTarget>().lt(DevTarget::getCreateTime, LocalDateTime.now().plusDays(-3)));
|
|
|
-// log.info("定时删除devTarget数据");
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Scheduled(cron = "0 0 */6 * * ?")
|
|
|
-// public void updateWxpayCert() {
|
|
|
-// if(Environment.wxHttpClient != null) {
|
|
|
-// CloseableHttpResponse res = null;
|
|
|
-// try {
|
|
|
-// List<X509Certificate> certs = new ArrayList<X509Certificate>();
|
|
|
-// List<WxpaycertVO> wxcerts = baseDAO.queryByCondition(WxpaycertVO.class, null, "effective_time desc");
|
|
|
-// URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/certificates");
|
|
|
-// HttpGet httpGet = new HttpGet(uriBuilder.build());
|
|
|
-// httpGet.addHeader("Accept", "application/json");
|
|
|
-// res = Environment.wxHttpClient.execute(httpGet);
|
|
|
-// String body = EntityUtils.toString(res.getEntity());
|
|
|
-// res.close();
|
|
|
-// ObjectMapper mapper = new ObjectMapper();
|
|
|
-// JsonNode dataNode = mapper.readTree(body).get("data");
|
|
|
-// if (dataNode != null) {
|
|
|
-// for (int i = 0, count = dataNode.size(); i < count; i++) {
|
|
|
-// String serial_no = dataNode.get(i).get("serial_no").textValue();
|
|
|
-// boolean match = false;
|
|
|
-// for (WxpaycertVO c : wxcerts) {
|
|
|
-// if (serial_no.equals(c.getSerial_no())) {
|
|
|
-// match = true;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (!match) {
|
|
|
-// AesUtil decryptor = new AesUtil(Constants.WXMCHKEYV3.getBytes("UTF-8"));
|
|
|
-// JsonNode encryptCertificateNode = dataNode.get(i).get("encrypt_certificate");
|
|
|
-// String cert = decryptor.decryptToString(
|
|
|
-// encryptCertificateNode.get("associated_data").toString().replaceAll("\"", "")
|
|
|
-// .getBytes("utf-8"),
|
|
|
-// encryptCertificateNode.get("nonce").toString().replaceAll("\"", "").getBytes("utf-8"),
|
|
|
-// encryptCertificateNode.get("ciphertext").toString().replaceAll("\"", ""));
|
|
|
-//
|
|
|
-// CertificateFactory cf = CertificateFactory.getInstance("X509");
|
|
|
-// X509Certificate x509Cert = (X509Certificate) cf
|
|
|
-// .generateCertificate(new ByteArrayInputStream(cert.getBytes("utf-8")));
|
|
|
-// try {
|
|
|
-// x509Cert.checkValidity();
|
|
|
-// } catch (CertificateExpiredException | CertificateNotYetValidException e) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// certs.add(x509Cert);
|
|
|
-//
|
|
|
-// WxpaycertVO c = new WxpaycertVO();
|
|
|
-// c.setSerial_no(dataNode.get(i).get("serial_no").textValue());
|
|
|
-// Date effective_time = DateUtil.parse("yyyy-MM-dd'T'HH:mm:ssX",
|
|
|
-// dataNode.get(i).get("effective_time").textValue());
|
|
|
-// c.setEffective_time(new Timestamp(effective_time.getTime()));
|
|
|
-// Date expire_time = DateUtil.parse("yyyy-MM-dd'T'HH:mm:ssX",
|
|
|
-// dataNode.get(i).get("expire_time").textValue());
|
|
|
-// c.setExpire_time(new Timestamp(expire_time.getTime()));
|
|
|
-// c.setCerttext(cert);
|
|
|
-// baseDAO.insert(c);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// if (certs.size() > 0) {
|
|
|
-// Log.info("新增证书:"+certs.size());
|
|
|
-// // 证书有变动重新加载
|
|
|
-// for (WxpaycertVO c : wxcerts) {
|
|
|
-// CertificateFactory cf = CertificateFactory.getInstance("X509");
|
|
|
-// X509Certificate x509Cert = (X509Certificate) cf
|
|
|
-// .generateCertificate(new ByteArrayInputStream(c.getCerttext().getBytes("utf-8")));
|
|
|
-// try {
|
|
|
-// x509Cert.checkValidity();
|
|
|
-// } catch (CertificateExpiredException | CertificateNotYetValidException e) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// certs.add(x509Cert);
|
|
|
-// }
|
|
|
-// Environment.wxHttpClient = WechatPayHttpClientBuilder.create()
|
|
|
-// .withMerchant(Constants.WXMCHID, Constants.WXMCHAPICERTNUM, Environment.wxPrivateKey)
|
|
|
-// .withWechatPay(certs).build();
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Scheduled(cron = "0 0 */1 * * ?")
|
|
|
-// public void updateWxgzh() {
|
|
|
-// if(StringUtils.isNotBlank(Constants.WXGZHAPPID) && StringUtils.isNotBlank(Constants.WXGZHAPPSECRET)) {
|
|
|
-// String res = HttpUtil.request("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
-// + Constants.WXGZHAPPID + "&secret=" + Constants.WXGZHAPPSECRET, null, false, null, null);
|
|
|
-// if(StringUtils.isNotEmpty(res)) {
|
|
|
-// Constants.WXGZHACCESS_TOKEN = (String) JSONObject.parseObject(res).get("access_token");
|
|
|
-// Log.info("公众号更新ACCESS_TOKEN:" + Constants.WXGZHACCESS_TOKEN);
|
|
|
-// String res_str = HttpUtil.request("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="
|
|
|
-// + Constants.WXGZHACCESS_TOKEN + "&type=jsapi", null, false, null, null);
|
|
|
-// if(StringUtils.isNotEmpty(res_str)) {
|
|
|
-// Constants.WXGZHJS_TICKET = (String) JSONObject.parseObject(res_str).get("ticket");
|
|
|
-// Log.info("公众号更新JS_TICKET:" + Constants.WXGZHJS_TICKET);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Scheduled(cron = "0 0 */1 * * ?")
|
|
|
-// public void updateWxxcx() {
|
|
|
-// if(StringUtils.isNotBlank(Constants.WXXCXAPPID) && StringUtils.isNotBlank(Constants.WXXCXAPPSECRET)) {
|
|
|
-// String res = HttpUtil.request("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
-// + Constants.WXXCXAPPID + "&secret=" + Constants.WXXCXAPPSECRET, null, false, null, null);
|
|
|
-// if(StringUtils.isNotEmpty(res)) {
|
|
|
-// Constants.WXXCXACCESS_TOKEN = (String) JSONObject.parseObject(res).get("access_token");
|
|
|
-// Log.info("小程序更新ACCESS_TOKEN:" + Constants.WXXCXACCESS_TOKEN);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Scheduled(cron = "0 */1 * * * ?")
|
|
|
-// public void processSblx() {
|
|
|
-// List<String> sqls = Lists.newArrayList();
|
|
|
-// List<SbVO> sbs = baseDAO.queryByCondition(SbVO.class, " and lx is null and UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(sign_time)>120 ", null);
|
|
|
-// for(SbVO v : sbs) {
|
|
|
-// sqls.add("update tbl_sb set lx=1 where id='"+v.getId()+"' ");
|
|
|
-// }
|
|
|
-// if(sqls.size() > 0) {
|
|
|
-// baseDAO.getJdbcTemplate().batchUpdate(sqls.toArray(new String[] {}));
|
|
|
-// }
|
|
|
-// }
|
|
|
-//}
|
|
|
+package com.hfln.portal.infrastructure.job;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.hfln.portal.infrastructure.po.DevTarget;
|
|
|
+import com.hfln.portal.infrastructure.service.DevTargetService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class ScheduledTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DevTargetService devTargetService;
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ public void runAtOneAM() {
|
|
|
+
|
|
|
+ devTargetService.remove(new LambdaQueryWrapper<DevTarget>().lt(DevTarget::getCreateTime, LocalDateTime.now().plusDays(-3)));
|
|
|
+ log.info("定时删除devTarget数据");
|
|
|
+ }
|
|
|
+}
|