xuhy
2026-02-27 108c30a461e68d452d740465dc0764166f2eda55
阿里消息推送修改
3个文件已修改
34 ■■■■■ 已修改文件
xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/pushMessage/AliPushMessageDTO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/AliPushController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/pushMessage/AliPushMessageDTO.java
@@ -22,4 +22,7 @@
    @ApiModelProperty(value = "消息内容")
    private String body;
    @ApiModelProperty(value = "推送类型 NOTICE:表示通知。 MESSAGE:表示消息。")
    private String pushType;
}
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/AliPushController.java
@@ -14,8 +14,6 @@
public class AliPushController {
    @Autowired
    private RedisService redisService;
    @Autowired
    private AliPushUtil aliPushUtil;
    /**
@@ -23,8 +21,8 @@
     * @return
     */
    @GetMapping("/base/v1/aliPush/test")
    public R<String> test() throws Exception {
        String s = aliPushUtil.pushMessage(1, "13540694412", "测试", "{\"content\":\"测试消息\",\"strategy\":1\"type\":1,\"id\":1}");
    public R<String> test(){
        String s = aliPushUtil.pushMessage(1, "13540694412", "测试", "{\"content\":\"测试消息\",\"strategy\":1\"type\":1,\"id\":1}","NOTICE");
        return R.ok(s);
    }
@@ -34,7 +32,7 @@
     */
    @PostMapping("/inner/v1/aliPush/pushMessage")
    public R<String> pushMessage(@RequestBody AliPushMessageDTO dto) {
        String result = aliPushUtil.pushMessage(dto.getDeviceType(), dto.getAccount(), dto.getTitle(), dto.getBody());
        String result = aliPushUtil.pushMessage(dto.getDeviceType(), dto.getAccount(), dto.getTitle(), dto.getBody(),dto.getPushType());
        return R.ok(result);
    }
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java
@@ -34,10 +34,6 @@
    @Value("${ali.push.iosChannelId}")
    private String iosChannelId;
    /**
     * 消息类型  MESSAGE 消息  NOTICE  通知
     */
    private final String PUSH_TYPE = "MESSAGE";
    /**
     * 设备类型 ALL 全部 HARMONY 鸿蒙  IOS ios设备 ANDROID 安卓设备
     */
    private final String DEVICE_TYPE_ALL = "ALL";
@@ -60,9 +56,10 @@
     * @param account 运维手机号
     * @param title 标题
     * @param body 消息内容
     * @param pushType NOTICE:表示通知。 MESSAGE:表示消息。
     * @throws Exception
     */
    public String pushMessage(Integer deviceType,String account, String title, String body){
    public String pushMessage(Integer deviceType,String account, String title, String body,String pushType){
        try {
            StaticCredentialProvider credentialProvider = StaticCredentialProvider.create(
@@ -95,14 +92,28 @@
                PushRequest pushRequest = PushRequest.builder()
                        .appKey(appKeys)
                        .pushType(PUSH_TYPE)
                        .pushType(pushType)
                        .deviceType(DEVICE_TYPE_ALL)
                        .target(TARGET)
                        .targetValue(account)
                        .title(title)
                        .body(body)
                        .androidExtParameters(body)
                        .androidNotificationChannel(channelIds)
                        .build();
                if(deviceType == 2){
                    pushRequest = PushRequest.builder()
                            .appKey(appKeys)
                            .pushType(pushType)
                            .deviceType(DEVICE_TYPE_ALL)
                            .target(TARGET)
                            .targetValue(account)
                            .title(title)
                            .body(body)
                            .iOSExtParameters(body)
                            .androidNotificationChannel(channelIds)
                            .build();
                }
                CompletableFuture<PushResponse> response = client.push(pushRequest);
                PushResponse resp = response.get();
                String json = new Gson().toJson(resp);