diff --git a/pom.xml b/pom.xml
index 8ae430e..6322617 100644
--- a/pom.xml
+++ b/pom.xml
@@ -230,7 +230,14 @@
junit
junit
-
+
+
+ com.tencentcloudapi
+ tencentcloud-sdk-java
+
+
+ 3.1.521
+
diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java
index df63859..5ebddca 100644
--- a/src/main/java/com/xkrs/controller/FirePointController.java
+++ b/src/main/java/com/xkrs/controller/FirePointController.java
@@ -15,6 +15,8 @@ import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo;
import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService;
+import com.xkrs.utils.SendSms;
+import com.xkrs.utils.WDWxSendMsgUtil;
import com.xkrs.websocket.service.WebSocketServer;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -80,6 +82,24 @@ public class FirePointController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, shanDongFirePointList, locale);
}
+ /**
+ * 发短息
+ *
+ * @return
+ */
+ @GetMapping("/sem")
+ public String sem() {
+ Locale locale = LocaleContextHolder.getLocale();
+ try {
+ WDWxSendMsgUtil.sendMsg("18447024917@chatroom", "微信发消息测试66666", 0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ SendSms.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{"荒岛66666"});
+ return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "shanDongFirePointList", locale);
+ }
+
+
/**
* 根据火点编号更新审核状态
* 操作1:将火点编号对应的火点从山东火点表转存到火点表
diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java
index 99e26b5..c5e53c1 100644
--- a/src/main/java/com/xkrs/service/FirePointService.java
+++ b/src/main/java/com/xkrs/service/FirePointService.java
@@ -2,6 +2,7 @@ package com.xkrs.service;
import com.xkrs.model.entity.FirePoint;
import com.xkrs.model.entity.FirePointEntity;
+import com.xkrs.model.entity.ShanDongFirePointEntity;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.vo.AppTaskBodyVo;
import org.springframework.web.multipart.MultipartFile;
@@ -23,6 +24,14 @@ public interface FirePointService {
*/
FirePointEntity insertFirePoint(FirePointQo firePointQo);
+ /**
+ * 添加火点信息
+ *
+ * @param firePointQo
+ * @return
+ */
+ ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo);
+
/**
* 查询今天的火点信息
*
diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
index 7d4ccda..1cd216b 100644
--- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
+++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
@@ -124,10 +124,11 @@ public class FirePointServiceImpl implements FirePointService {
e.printStackTrace();
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
- //1、如果是山东的火点,2、同时开关已打开,那么就把火点转存到山东火点表,否则就直接存到火点表
- if (firePointEntity.getCountyCode().startsWith("37") && isSwitchStateOpen()) {
- return saveToShanDongFirePoint(firePointEntity);
+ //如果开关已打开,就剔除山东的火点
+ if (isSwitchStateOpen() && firePointEntity.getCountyCode().startsWith("37")) {
+ return null;
}
+ //如果开关已关闭,所有火点都入全国火点库
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode());
if (existFireCode != null) {
return null;
@@ -136,6 +137,59 @@ public class FirePointServiceImpl implements FirePointService {
return firePointDao.save(firePointEntity);
}
+ /**
+ * 添加火点信息
+ *
+ * @param firePointQo
+ * @return
+ */
+ @CacheEvict(value = "FirePointServiceCache", allEntries = true)
+ @Override
+ public ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo) {
+ if (firePointQo.getLandtype().equals("水体")) {
+ return null;
+ }
+ if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
+ return null;
+ }
+ if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
+ return null;
+ }
+ ShanDongFirePointEntity firePointEntity = new ShanDongFirePointEntity();
+ firePointEntity.setFireCode(firePointQo.getFireCode());
+ firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
+ firePointEntity.setCountyName(firePointQo.getCountyName());
+ firePointEntity.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
+ firePointEntity.setLongitude(firePointQo.getLongitude());
+ firePointEntity.setLatitude(firePointQo.getLatitude());
+ firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
+ firePointEntity.setSatelliteType(firePointQo.getSatelliteType());
+ firePointEntity.setLandType(firePointQo.getLandtype());
+ firePointEntity.setConfidence(firePointQo.getConfidence());
+ firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
+ firePointEntity.setFireType("0");
+ firePointEntity.setFireImage(firePointQo.getFireImage());
+ firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
+ firePointEntity.setVerifyState("0");
+ try {
+ bindStreetCodeName(firePointEntity);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("添加山东火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
+ }
+ //如果开关已打开,就把山东火点入山东火点库
+ if (isSwitchStateOpen() && firePointEntity.getCountyCode().startsWith("37")) {
+ ShanDongFirePointEntity existFireCode = shanDongFirePointDao.findByFireCode(firePointEntity.getFireCode());
+ if (existFireCode != null) {
+ return null;
+ }
+ log.info("-------发现新山东火点");
+ return shanDongFirePointDao.save(firePointEntity);
+ }
+ return null;
+ }
+
+
/**
* 返回开关是否为打开状态
*
@@ -151,40 +205,27 @@ public class FirePointServiceImpl implements FirePointService {
}
/**
- * 保存到山东火点表
+ * 为实体类设置街道编号和街道名称
*/
- private FirePointEntity saveToShanDongFirePoint(FirePointEntity firePointEntity) {
- ShanDongFirePointEntity existFireCode = shanDongFirePointDao.findByFireCode(firePointEntity.getFireCode());
- if (existFireCode != null) {
- return null;
+ private void bindStreetCodeName(FirePointEntity firePointEntity) throws Exception {
+ List locationList = new ArrayList<>();
+ locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
+ GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
+ String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
+ if (townCode.length() > 9) {
+ townCode = townCode.substring(0, 9);
+ }
+ firePointEntity.setStreetCode(townCode);
+ List byStreetCode = streetDao.findByStreetCode(townCode);
+ if (byStreetCode != null && byStreetCode.size() > 0) {
+ firePointEntity.setStreetName(byStreetCode.get(0).getStreetName());
}
- ShanDongFirePointEntity shanDongFirePointEntity = new ShanDongFirePointEntity();
- shanDongFirePointEntity.setFireCode(firePointEntity.getFireCode());
- shanDongFirePointEntity.setCountyCode(firePointEntity.getCountyCode());
- shanDongFirePointEntity.setCountyName(firePointEntity.getCountyName());
- shanDongFirePointEntity.setSatelliteTime(firePointEntity.getSatelliteTime());
- shanDongFirePointEntity.setLongitude(firePointEntity.getLongitude());
- shanDongFirePointEntity.setLatitude(firePointEntity.getLatitude());
- shanDongFirePointEntity.setFirePointAddress(firePointEntity.getFirePointAddress());
- shanDongFirePointEntity.setSatelliteType(firePointEntity.getSatelliteType());
- shanDongFirePointEntity.setLandType(firePointEntity.getLandType());
- shanDongFirePointEntity.setConfidence(firePointEntity.getConfidence());
- shanDongFirePointEntity.setAddTime(firePointEntity.getAddTime());
- shanDongFirePointEntity.setFireType(firePointEntity.getFireType());
- shanDongFirePointEntity.setFireImage(firePointEntity.getFireImage());
- shanDongFirePointEntity.setSatelliteImage(firePointEntity.getSatelliteImage());
- shanDongFirePointEntity.setStreetCode(firePointEntity.getStreetCode());
- shanDongFirePointEntity.setStreetName(firePointEntity.getStreetName());
- shanDongFirePointEntity.setVerifyState("0");
- log.info("-------发现山东新火点");
- shanDongFirePointDao.save(shanDongFirePointEntity);
- return new FirePointEntity();
}
/**
* 为实体类设置街道编号和街道名称
*/
- private void bindStreetCodeName(FirePointEntity firePointEntity) throws Exception {
+ private void bindStreetCodeName(ShanDongFirePointEntity firePointEntity) throws Exception {
List locationList = new ArrayList<>();
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
diff --git a/src/main/java/com/xkrs/utils/SendSms.java b/src/main/java/com/xkrs/utils/SendSms.java
new file mode 100644
index 0000000..65325c3
--- /dev/null
+++ b/src/main/java/com/xkrs/utils/SendSms.java
@@ -0,0 +1,154 @@
+package com.xkrs.utils;
+
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.sms.v20190711.SmsClient;
+import com.tencentcloudapi.sms.v20190711.models.PullSmsReplyStatusByPhoneNumberRequest;
+import com.tencentcloudapi.sms.v20190711.models.PullSmsReplyStatusByPhoneNumberResponse;
+import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
+
+/**
+ * 短信工具
+ *
+ * @author tajochen
+ */
+public class SendSms {
+
+ public static int sendSmsToUser(String[] phoneNumbers, String templateId, String[] templateParams) {
+ int resValue = 0;
+ try {
+ /* 必要步骤:
+ * 实例化一个认证对象,入参需要传入腾讯云账户密钥对 secretId 和 secretKey
+ * 可以直接在代码中写入密钥对,但需谨防泄露,不要将代码复制、上传或者分享给他人
+ * CAM 密钥查询:https://console.cloud.tencent.com/cam/capi*/
+ String secretId = "AKIDFNOAxu0u3pRvFunvD7DE8srs46CDLlJx";
+ String secretKey = "jJjzwkT4PirqgRqCOMH2f8m051Mdlk4c";
+ Credential cred = new Credential(secretId, secretKey);
+
+ // 实例化一个 http 选项,可选,无特殊需求时可以跳过
+ HttpProfile httpProfile = new HttpProfile();
+ // 设置代理
+ // httpProfile.setProxyHost("host");
+ // httpProfile.setProxyPort(6000);
+ httpProfile.setReqMethod("POST");
+ /* SDK 有默认的超时时间,非必要请不要进行调整
+ * 如有需要请在代码中查阅以获取最新的默认值 */
+ httpProfile.setConnTimeout(60);
+ /* SDK 会自动指定域名,通常无需指定域名,但访问金融区的服务时必须手动指定域名
+ * 例如 SMS 的上海金融区域名为 sms.ap-shanghai-fsi.tencentcloudapi.com */
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+ /* 非必要步骤:
+ * 实例化一个客户端配置对象,可以指定超时时间等配置 */
+ ClientProfile clientProfile = new ClientProfile();
+ /* SDK 默认用 TC3-HMAC-SHA256 进行签名
+ * 非必要请不要修改该字段 */
+ clientProfile.setSignMethod("HmacSHA256");
+ clientProfile.setHttpProfile(httpProfile);
+ /* 实例化 SMS 的 client 对象
+ * 第二个参数是地域信息,可以直接填写字符串 ap-guangzhou,或者引用预设的常量 */
+ SmsClient client = new SmsClient(cred, "", clientProfile);
+ /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数
+ * 您可以直接查询 SDK 源码确定接口有哪些属性可以设置
+ * 属性可能是基本类型,也可能引用了另一个数据结构
+ * 推荐使用 IDE 进行开发,可以方便地跳转查阅各个接口和数据结构的文档说明 */
+ SendSmsRequest req = new SendSmsRequest();
+
+ /* 填充请求参数,这里 request 对象的成员变量即对应接口的入参
+ * 您可以通过官网接口文档或跳转到 request 对象的定义处查看请求参数的定义
+ * 基本类型的设置:
+ * 帮助链接:
+ * 短信控制台:https://console.cloud.tencent.com/smsv2
+ * sms helper:https://cloud.tencent.com/document/product/382/3773 */
+
+ /* 短信应用 ID: 在 [短信控制台] 添加应用后生成的实际 SDKAppID,例如1400006666 */
+ String appid = "1400687933";
+ req.setSmsSdkAppid(appid);
+
+ /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,可登录 [短信控制台] 查看签名信息 */
+ String sign = "星科瑞升";
+ req.setSign(sign);
+
+ /* 国际/港澳台短信 senderid: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */
+ // String senderid = "xxx";
+ String senderid = "";
+ req.setSenderId(senderid);
+
+ /* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
+ String session = "";
+ req.setSessionContext(session);
+
+ /* 短信码号扩展号: 默认未开通,如需开通请联系 [sms helper] */
+ String extendcode = "";
+ req.setExtendCode(extendcode);
+
+ /* 模板 ID: 必须填写已审核通过的模板 ID,可登录 [短信控制台] 查看模板 ID */
+ // String templateID = "730983";
+ req.setTemplateID(templateId);
+
+ /* 下发手机号码,采用 e.164 标准,+[国家或地区码][手机号]
+ * 例如+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/
+ // String[] phoneNumbers = { "+8615726240251", "+8617854119839", "+8615269088338"};
+ req.setPhoneNumberSet(phoneNumbers);
+
+ /* 模板参数: 若无模板参数,则设置为空*/
+ // String[] templateParams = {"test","100"};
+ req.setTemplateParamSet(templateParams);
+
+ /* 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的
+ * 返回的 res 是一个 SendSmsResponse 类的实例,与请求对象对应 */
+ SendSmsResponse res = client.SendSms(req);
+
+ // 输出 JSON 格式的字符串回包
+ System.out.println(SendSmsResponse.toJsonString(res));
+
+ // 可以取出单个值,您可以通过官网接口文档或跳转到 response 对象的定义处查看返回字段的定义
+ System.out.println(res.getRequestId());
+ } catch (TencentCloudSDKException e) {
+ e.printStackTrace();
+ resValue = 2;
+ }
+ return resValue;
+ }
+
+
+ public static int receiveSms() {
+ int resValue = 0;
+ try {
+
+ Credential cred = new Credential("AKIDFNOAxu0u3pRvFunvD7DE8srs46CDLlJx", "jJjzwkT4PirqgRqCOMH2f8m051Mdlk4c");
+
+ HttpProfile httpProfile = new HttpProfile();
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+ ClientProfile clientProfile = new ClientProfile();
+ clientProfile.setHttpProfile(httpProfile);
+
+ SmsClient client = new SmsClient(cred, "", clientProfile);
+
+ PullSmsReplyStatusByPhoneNumberRequest req = new PullSmsReplyStatusByPhoneNumberRequest();
+ Long ss = 1600939153L;
+ req.setSendDateTime(ss);
+ req.setOffset(0L);
+ req.setLimit(10L);
+ req.setPhoneNumber("+8617854119839");
+ req.setSmsSdkAppid("1400430088");
+
+ PullSmsReplyStatusByPhoneNumberResponse resp = client.PullSmsReplyStatusByPhoneNumber(req);
+
+ System.out.println(PullSmsReplyStatusByPhoneNumberResponse.toJsonString(resp));
+ } catch (TencentCloudSDKException e) {
+ System.out.println(e.toString());
+ resValue = 2;
+ }
+ return resValue;
+ }
+
+ public static void main(String[] args) {
+ receiveSms();
+ }
+
+}
diff --git a/src/main/java/com/xkrs/utils/WDHttpClientUtils.java b/src/main/java/com/xkrs/utils/WDHttpClientUtils.java
new file mode 100644
index 0000000..7773d98
--- /dev/null
+++ b/src/main/java/com/xkrs/utils/WDHttpClientUtils.java
@@ -0,0 +1,202 @@
+package com.xkrs.utils;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.ssl.SSLContexts;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * http工具类
+ */
+public class WDHttpClientUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(HttpClientUtils.class);
+
+ /**
+ * 发送http+get请求
+ *
+ * @param url
+ * @return 返回结果
+ * @throws Exception
+ */
+ public static String sendHttpGet(String url) throws Exception {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ return doGet(url, httpClient);
+ }
+
+ /**
+ * 发送https+get请求,绕过证书
+ *
+ * @param url 请求地址
+ * @return 返回结果
+ * @throws Exception
+ */
+ public static String sendHttpsGet(String url) throws Exception {
+// CloseableHttpClient httpClient = createIgnoreVerifyHttpClient();
+ //CloseableHttpClient httpClient = HttpClients.createDefault();
+ SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
+ CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(scsf).build();
+ return doGet(url, httpClient);
+ }
+
+ /**
+ * 发送http+post请求
+ *
+ * @param url 请求地址
+ * @param params 请求参数 json字符串
+ * @return 返回结果
+ * @throws Exception
+ */
+ public static String sendHttpPost(String url, String params) throws Exception {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ return doPost(httpClient, url, params);
+ }
+
+ /**
+ * 发送http+post请求
+ *
+ * @param url 请求地址
+ * @return 返回结果
+ * @throws Exception
+ */
+ public static String sendHttpPost(String url) throws Exception {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ return doPost(httpClient, url);
+ }
+
+ /**
+ * 发送https+post请求
+ *
+ * @param url 请求地址
+ * @param params 请求参数 json字符串
+ * @return 返回结果
+ * @throws Exception
+ */
+ public static String sendHttpsPost(String url, String params) throws Exception {
+ // CloseableHttpClient httpClient = createIgnoreVerifyHttpClient();
+ // CloseableHttpClient httpClient = null;
+ SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
+ CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(scsf).build();
+ // CloseableHttpClient httpClient = HttpClients.createDefault();
+ return doPost(httpClient, url, params);
+
+ }
+
+ /**
+ * 封装get请求方式的处理
+ */
+ private static String doGet(String url, CloseableHttpClient httpClient) throws Exception {
+ log.info("HGet请求url={}", url);
+ HttpGet httpGet = new HttpGet(url);
+ return execute(httpClient, httpGet);
+ }
+
+ /**
+ * 封装post请求方式的处理
+ */
+ private static String doPost(CloseableHttpClient httpClient, String url, String params) throws Exception {
+ log.info("Post请求url:{}", url);
+ log.info("Post请求params:{}", params);
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
+ httpPost.setEntity(new StringEntity(params, "utf-8"));
+ return execute(httpClient, httpPost);
+ }
+
+ /**
+ * 封装post请求方式的处理
+ */
+ private static String doPost(CloseableHttpClient httpClient, String url) throws Exception {
+ log.info("Post请求url:{}", url);
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
+ return execute(httpClient, httpPost);
+ }
+
+ /**
+ * 执行发送
+ */
+ private static String execute(CloseableHttpClient httpClient, HttpRequestBase requestBase) throws Exception {
+ String result = null;
+ CloseableHttpResponse response = null;
+ try {
+ response = httpClient.execute(requestBase);
+ int statusCode = response.getStatusLine().getStatusCode();
+ log.info("HttpClient响应码={}", statusCode);
+ final int success = 200;
+ if (statusCode == success) {
+ result = EntityUtils.toString(response.getEntity(), "utf-8");
+ } else {
+ log.error("HttpClient请求失败,错误码={}", statusCode);
+ }
+ } catch (Exception e) {
+ log.error("HttpClient请求异常:", e);
+ } finally {
+ if (null != httpClient) {
+ httpClient.close();
+ }
+ if (null != response) {
+ response.close();
+ }
+ }
+ log.info("HttpClient请求结果:{}", result);
+ return result;
+ }
+
+ /**
+ * 绕过验证
+ *
+ * @return
+ * @throws NoSuchAlgorithmException
+ * @throws KeyManagementException
+ */
+ public static CloseableHttpClient createIgnoreVerifyHttpClient() throws Exception {
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ // 实现一个X509TrustManager接口
+ X509TrustManager trustManager = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ };
+ sslContext.init(null, new TrustManager[]{trustManager}, null);
+ Registry socketFactoryRegistry = RegistryBuilder.create().register("http", PlainConnectionSocketFactory.INSTANCE).register("https", new SSLConnectionSocketFactory(sslContext)).build();
+ PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
+ CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build();
+ return httpClient;
+ }
+
+}
+
+
diff --git a/src/main/java/com/xkrs/utils/WDWxSendMsgUtil.java b/src/main/java/com/xkrs/utils/WDWxSendMsgUtil.java
new file mode 100644
index 0000000..eaab05e
--- /dev/null
+++ b/src/main/java/com/xkrs/utils/WDWxSendMsgUtil.java
@@ -0,0 +1,26 @@
+package com.xkrs.utils;
+
+/**
+ * @author wudong
+ * @date 2022/6/2 9:25
+ * @description
+ */
+public class WDWxSendMsgUtil {
+
+ /**
+ * 通过udp通信,调用发送微信消息服务,发送微信消息
+ *
+ * @param wxid 微信id
+ * @param text 信息
+ * @param type 类型0:文本,1:文档
+ * @throws Exception
+ */
+ public static void sendMsg(String wxid, String text, Integer type) throws Exception {
+ String url = String.format("http://118.24.27.47:10721/winxin_api/msg?wxid=%s&text=%s&type=%s", wxid, text, type);
+ WDHttpClientUtils.sendHttpPost(url);
+ }
+
+ public static void main(String[] args) throws Exception {
+ sendMsg("18447024917@chatroom", "微信发消息测试", 0);
+ }
+}