@@ -1,6 +1,8 @@ | |||
package cn.com.taiji.ats.config; | |||
import javax.annotation.PostConstruct; | |||
import okhttp3.OkHttpClient; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.context.MessageSource; | |||
import org.springframework.context.annotation.Bean; | |||
@@ -11,6 +13,7 @@ import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.pub.AppEnv; | |||
import java.util.concurrent.ThreadPoolExecutor; | |||
import java.util.concurrent.TimeUnit; | |||
@Configuration | |||
//@EntityScan(value = {"cn.com.taiji." + AppConfig.APP_NAME + ".entity", "cn.com.taiji.core.entity"}) | |||
@@ -57,4 +60,15 @@ public class AppConfig extends AbstractManager { | |||
threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | |||
return threadPoolTaskExecutor; | |||
} | |||
@Bean | |||
public OkHttpClient okHttpClient() { | |||
return new OkHttpClient.Builder() | |||
.connectTimeout(1000, TimeUnit.SECONDS)//连接超时 | |||
.readTimeout(2000, TimeUnit.SECONDS)//读取响应超时 | |||
.writeTimeout(1000, TimeUnit.SECONDS)//发送请求超时 | |||
.callTimeout(4000, TimeUnit.SECONDS)// 整个调用过程超时 | |||
.build(); | |||
} | |||
} |
@@ -46,6 +46,8 @@ public class WinXinServiceHandler extends AbstractAtsServiceHandler<WeiXinServic | |||
@Autowired | |||
private QueryRefundV3Manager queryRefundV3Manager; | |||
@Autowired | |||
private GetWeChatOpenIdManager getWeChatOpenIdManager; | |||
@Autowired | |||
private WxMessageManager wxMessageManager; | |||
@Autowired | |||
private VehicleUserStateManager vehicleUserStateManager; | |||
@@ -71,6 +73,8 @@ public class WinXinServiceHandler extends AbstractAtsServiceHandler<WeiXinServic | |||
return refundV3Manager.serviceHandle((AtsRefundV3Request) request); | |||
case REFUNDQUERYV3: | |||
return queryRefundV3Manager.serviceHandle((AtsQueryRefundV3Request) request); | |||
case GETWECHATOPENDI: | |||
return getWeChatOpenIdManager.serviceHandle((AtsGetWeChatOpenIdRequest) request); | |||
case MPISSUBSCRIBED: | |||
return wxMessageManager.isSubscribed((WxMpIsSubscribedRequest) request); | |||
case MPSENDMESSAGE: |
@@ -0,0 +1,11 @@ | |||
package cn.com.taiji.ats.manager.jpush; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageResponse; | |||
public interface JPushAllAppManager { | |||
JPushSendMessageResponse jpushSendMessageHandler(JPushSendMessageRequest request) throws ServiceHandleException; | |||
} |
@@ -0,0 +1,55 @@ | |||
package cn.com.taiji.ats.manager.jpush; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import cn.com.taiji.ats.api.TokenHelper; | |||
import cn.com.taiji.ats.model.jpush.JPushManager; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.entity.dict.msgw.MessageJPushType; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageResponse; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
@Service | |||
public class JPushAllAppManagerImpl implements JPushAllAppManager{ | |||
@Autowired | |||
private JPushManager jpushManager; | |||
/** | |||
* * 极光推送-指定的registrationId列表(android/ios)-通知栏通知和自定义消息 | |||
* @param request | |||
* @return | |||
* @throws ManagerException | |||
*/ | |||
@Override | |||
public JPushSendMessageResponse jpushSendMessageHandler(JPushSendMessageRequest request) throws ServiceHandleException { | |||
JPushSendMessageResponse response = null; | |||
TokenHelper.logger.info("------- 极光推送-指定的registrationId列表-通知栏通知和自定义消息 START -------"); | |||
TokenHelper.logger.info("接收的request:{}", request.toJson()); | |||
//1、入参校验 | |||
request.valid(); | |||
try { | |||
if (request.getJPushType().equals(MessageJPushType.JPUSHALLAPPN)){ | |||
response = jpushManager.sendToAllAppMessage(request); | |||
}else if (request.getJPushType().equals(MessageJPushType.JPUSHALLAPPM)){ | |||
response = jpushManager.sendToAllAppNotification(request); | |||
}else if (request.getJPushType().equals(MessageJPushType.JPUSHALLAPPNM)){ | |||
response = jpushManager.sendToAllAppNotificationMessage(request); | |||
}else if (request.getJPushType().equals(MessageJPushType.JPUSHALLRIDN)){ | |||
response = jpushManager.sendToAllRidMessage(request); | |||
}else if (request.getJPushType().equals(MessageJPushType.JPUSHALLRIDM)){ | |||
response = jpushManager.sendToAllRidNotification(request); | |||
}else if (request.getJPushType().equals(MessageJPushType.JPUSHALLRIDNM)){ | |||
response = jpushManager.sendToAllRidNotificationMessage(request); | |||
} | |||
} catch (Exception e) { | |||
TokenHelper.logger.error("", e); | |||
throw GlyServiceError.RESPONSE_ERROR.toHandleException("极光推动发送消息失败!"); | |||
} finally { | |||
TokenHelper.logger.info("------- 极光推送-指定的registrationId列表-通知栏通知和自定义消息 END -------"); | |||
} | |||
return response; | |||
} | |||
} |
@@ -9,6 +9,7 @@ import cn.com.taiji.core.model.comm.protocol.ats.notice.AtsChannelNoticeRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.notice.AtsChannelNoticeResponse; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import okhttp3.*; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.io.IOException; | |||
import java.util.concurrent.TimeUnit; | |||
@@ -24,12 +25,14 @@ public class ChannelNoticeManager extends AbstractCommManager{ | |||
private static MediaType json = MediaType.get("application/json; charset=utf-8"); | |||
private static OkHttpClient client = new OkHttpClient.Builder() | |||
.connectTimeout(1000, TimeUnit.SECONDS)//连接超时 | |||
.readTimeout(2000, TimeUnit.SECONDS)//读取响应超时 | |||
.writeTimeout(1000, TimeUnit.SECONDS)//发送请求超时 | |||
.callTimeout(4000, TimeUnit.SECONDS)// 整个调用过程超时 | |||
.build(); | |||
// private static OkHttpClient client = new OkHttpClient.Builder() | |||
// .connectTimeout(1000, TimeUnit.SECONDS)//连接超时 | |||
// .readTimeout(2000, TimeUnit.SECONDS)//读取响应超时 | |||
// .writeTimeout(1000, TimeUnit.SECONDS)//发送请求超时 | |||
// .callTimeout(4000, TimeUnit.SECONDS)// 整个调用过程超时 | |||
// .build(); | |||
@Autowired | |||
private OkHttpClient okHttpClient; | |||
public AtsChannelNoticeResponse serviceHandle(AtsChannelNoticeRequest req) throws ServiceHandleException { | |||
logger.info("渠道通知请求参数:{}", req.toJson()); | |||
@@ -42,11 +45,10 @@ public class ChannelNoticeManager extends AbstractCommManager{ | |||
.post(body) | |||
.url(req.getUrl()) | |||
.build(); | |||
try (Response response = client.newCall(request).execute()){ | |||
try (Response response = okHttpClient.newCall(request).execute()){ | |||
String string = response.body().string(); | |||
logger.info("渠道通知返回结果:{}", string); | |||
res = JsonTools.json2Object(string, AtsChannelNoticeResponse.class); | |||
res.setBizContent(string); | |||
} catch (IOException e) { | |||
logger.error("渠道通知异常:{}", e.toString()); | |||
throw GlyServiceError.SYSTEM_ERROR.toHandleException(e.getMessage()); |
@@ -0,0 +1,53 @@ | |||
package cn.com.taiji.ats.manager.weixin; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.pub.json.JsonTools; | |||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ats.notice.AtsChannelNoticeResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ats.weiXin.AtsGetWeChatOpenIdRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.weiXin.AtsGetWeChatOpenIdResponse; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import okhttp3.OkHttpClient; | |||
import okhttp3.Request; | |||
import okhttp3.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.io.IOException; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/6/16 15:06 | |||
* @Filename:GetWeChatOpenIdManager | |||
* @description: 相关文档见:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html | |||
*/ | |||
@Service | |||
public class GetWeChatOpenIdManager extends AbstractManager { | |||
private static String appId = "wxa2d9acdd1054e69b"; | |||
private static String secret = "03bb0a5ce08fe6ccfeca4b7fe485a61e"; | |||
private static String url = "https://api.weixin.qq.com/sns/jscode2session"; | |||
@Autowired | |||
private OkHttpClient okHttpClient; | |||
public AbstractSignTypeResponse serviceHandle(AtsGetWeChatOpenIdRequest req) throws ServiceHandleException { | |||
String httpUrl=url + "?appid=" + appId + "&secret=" + secret + "&js_code=" + req.getJsCode() + "&grant_type=authorization_code"; | |||
Request request = new Request.Builder() | |||
.url(httpUrl) | |||
.build(); | |||
AtsGetWeChatOpenIdResponse res = null; | |||
try (Response response = okHttpClient.newCall(request).execute()){ | |||
String string = response.body().string(); | |||
res = JsonTools.json2Object(string, AtsGetWeChatOpenIdResponse.class); | |||
} catch (IOException e) { | |||
logger.error("微信登录获取openId异常:{}", e.toString()); | |||
throw GlyServiceError.SYSTEM_ERROR.toHandleException(e.getMessage()); | |||
} | |||
return res; | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
package cn.com.taiji.ats.model.jpush; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageResponse; | |||
public interface JPushManager { | |||
/**极光推送-全体App用户(android/ios)-自定义消息*/ | |||
JPushSendMessageResponse sendToAllAppMessage(JPushSendMessageRequest request) throws ManagerException; | |||
/**极光推送-全体App用户(android/ios)-通知栏通知*/ | |||
JPushSendMessageResponse sendToAllAppNotification(JPushSendMessageRequest request) throws ManagerException; | |||
/**极光推送-全体App用户(android/ios)-通知栏通知和自定义消息*/ | |||
JPushSendMessageResponse sendToAllAppNotificationMessage(JPushSendMessageRequest request) throws ManagerException; | |||
/**极光推送-指定registrationId(android/ios)-自定义消息*/ | |||
JPushSendMessageResponse sendToAllRidMessage(JPushSendMessageRequest request) throws ManagerException; | |||
/**极光推送-指定registrationId(android/ios)-通知栏通知*/ | |||
JPushSendMessageResponse sendToAllRidNotification(JPushSendMessageRequest request) throws ManagerException; | |||
/**极光推送-指定registrationId(android/ios)-通知栏通知和自定义消息*/ | |||
JPushSendMessageResponse sendToAllRidNotificationMessage(JPushSendMessageRequest request) throws ManagerException; | |||
} |
@@ -0,0 +1,104 @@ | |||
package cn.com.taiji.ats.model.jpush; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import cn.com.taiji.ats.manager.jpush.messageChannelClients.MyJpushClient; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.pub.CommonAbstract; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.jpush.JPushSendMessageResponse; | |||
@Service | |||
public class JPushManagerImpl extends CommonAbstract implements JPushManager { | |||
private static final Logger logger = LoggerFactory.getLogger(JPushManagerImpl.class); | |||
@Autowired | |||
private MyJpushClient myJpushClient; | |||
// 极光推送-全体App用户(android/ios)-自定义消息 | |||
@Override | |||
public JPushSendMessageResponse sendToAllAppMessage(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送全体用户自定义消息发送 START **********"); | |||
myJpushClient.sendToAllAppMessage(request.getMsgTitle(), | |||
request.getMsgContent(), | |||
request.getMsgExtra()); | |||
logger.info("********** 极光推送全体用户自定义消息发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
//极光推送-全体App用户(android/ios)-通知栏通知 | |||
@Override | |||
public JPushSendMessageResponse sendToAllAppNotification(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送全体用户通知栏通知发送 START **********"); | |||
myJpushClient.sendToAllAppNotification( | |||
request.getNotificationTitle(), | |||
request.getNotificationContent(), | |||
request.getNotificationExtras()); | |||
logger.info("********** 极光推送全体用户通知栏通知发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
//极光推送-全体App用户(android/ios)-通知栏通知和自定义消息 | |||
@Override | |||
public JPushSendMessageResponse sendToAllAppNotificationMessage(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送全体用户通知栏通知和自定义消息发送 START **********"); | |||
myJpushClient.sendToAllAppNotificationMessage( | |||
request.getNotificationTitle(), | |||
request.getNotificationContent(), | |||
request.getNotificationExtras(), | |||
request.getMsgTitle(), | |||
request.getMsgContent(), | |||
request.getMsgExtra()); | |||
logger.info("********** 极光推送全体用户通知栏通知和自定义消息发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
//极光推送-指定registrationId(android/ios)-自定义消息 | |||
@Override | |||
public JPushSendMessageResponse sendToAllRidMessage(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送指定rid自定义消息发送 START **********"); | |||
myJpushClient.sendToAllRidMessage( | |||
request.getRegistrationIdList(), | |||
request.getMsgTitle(), | |||
request.getMsgContent(), | |||
request.getMsgExtra()); | |||
logger.info("********** 极光推送指定rid自定义消息发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
//极光推送-指定registrationId(android/ios)-通知栏通知 | |||
@Override | |||
public JPushSendMessageResponse sendToAllRidNotification(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送指定rid通知栏通知发送 START **********"); | |||
myJpushClient.sendToAllRidNotification( | |||
request.getRegistrationIdList(), | |||
request.getNotificationTitle(), | |||
request.getNotificationContent(), | |||
request.getNotificationExtras()); | |||
logger.info("********** 极光推送指定rid通知栏通知发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
//极光推送-指定registrationId(android/ios)-通知栏通知和自定义消息 | |||
@Override | |||
public JPushSendMessageResponse sendToAllRidNotificationMessage(JPushSendMessageRequest request) throws ManagerException { | |||
logger.info("********** 极光推送指定rid通知栏通知和自定义消息发送 START **********"); | |||
// 发送 | |||
myJpushClient.sendToAllRidNotificationMessage( | |||
request.getRegistrationIdList().toString(), | |||
request.getNotificationTitle(), | |||
request.getNotificationContent(), | |||
request.getNotificationExtras(), | |||
request.getMsgTitle(), | |||
request.getMsgContent(), | |||
request.getMsgExtra()); | |||
logger.info("********** 极光推送指定rid通知栏通知和自定义消息发送 END **********"); | |||
JPushSendMessageResponse response = new JPushSendMessageResponse(); | |||
return response; | |||
} | |||
} |
@@ -1,6 +1,5 @@ | |||
package cn.com.taiji.ats.web; | |||
import lombok.Data; | |||
/** | |||
* @Author:ChenChao | |||
@@ -8,8 +7,16 @@ import lombok.Data; | |||
* @Filename:TestModel | |||
* @description: | |||
*/ | |||
@Data | |||
public class TestModel { | |||
private String data; | |||
public String getData() { | |||
return data; | |||
} | |||
public void setData(String data) { | |||
this.data = data; | |||
} | |||
} |