From 5a719e0ce31feccb4da0073905d5f64e3d785def Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期六, 28 二月 2026 15:40:10 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java |   91 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
index 475cf04..46bcbc9 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpSchedulingDetailServiceImpl.java
@@ -1,16 +1,24 @@
 package com.xiaopeng.maintenance.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xiaopeng.api.dto.pushMessage.AliPushMessageDTO;
 import com.xiaopeng.api.feignClient.account.XpOperationUserClient;
+import com.xiaopeng.api.feignClient.account.XpOperationUserNotificationClient;
 import com.xiaopeng.api.feignClient.maintenance.XpCheckLocationClient;
+import com.xiaopeng.api.feignClient.pushMessage.XpAliPushMessageClient;
+import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient;
-import com.xiaopeng.api.model.account.XpOperationsUser;import com.xiaopeng.api.model.maintenance.*;
+import com.xiaopeng.api.model.account.XpOperationsUser;
+import com.xiaopeng.api.model.account.XpOperationsUserNotification;
+import com.xiaopeng.api.model.maintenance.*;
 import com.xiaopeng.api.model.vehicleConvoy.XpFleet;
 import com.xiaopeng.common.core.domain.R;
+import com.xiaopeng.common.core.enums.NotificationTypeEnum;
 import com.xiaopeng.common.core.utils.poi.ExcelUtil;
 import com.xiaopeng.common.core.web.page.PageInfo;
 import com.xiaopeng.maintenance.dto.ExportSchedulingDetailDto;
@@ -36,6 +44,9 @@
 import java.time.format.TextStyle;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 
 /**
  * <p>
@@ -64,6 +75,10 @@
     private XpFleetOperationsClient xpFleetOperationsClient;
     @Resource
     private XpOperationUserClient xpOperationUserClient;
+    @Resource
+    private XpAliPushMessageClient xpAliPushMessageClient;
+    @Resource
+    private XpOperationUserNotificationClient xpOperationUserNotificationClient;
 
     @Override
     public ShiftAttendanceVO shiftAttendance(ShiftAttendanceDTO dto) {
@@ -395,6 +410,10 @@
         //构建排班明细数据
         List<SaveSchedulingDetailVo> datas = vo.getDatas();
         List<XpSchedulingDetail> schedulingDetails = new ArrayList<>();
+        //存放推送消息
+        List<AliPushMessageDTO> pushMessage = new ArrayList<>();
+        //存放通知数据
+        List<XpOperationsUserNotification> notifications = new ArrayList<>();
         for (SaveSchedulingDetailVo data : datas) {
             Long fleetId = data.getFleetId();
             List<SaveSchedulingDetailDay> days = data.getDays();
@@ -428,7 +447,12 @@
                             for (XpOperationsUser xpOperationsUser : data1) {
                                 String nickName = xpOperationsUser.getNickName();
                                 String message = nickName + "请注意," + month + "你的排班由" + xpShift1.getShiftName() + "变更为了" + xpShift2.getShiftName() + "。详情请联系平台管理员。";
-
+                                //构建消息推送对象
+                                AliPushMessageDTO aliPushMessageDTO = buildPushMessage(message, xpOperationsUser);
+                                pushMessage.add(aliPushMessageDTO);
+                                //构建消息存储
+                                XpOperationsUserNotification operationsUserNotification = buildXpOperationsUserNotification(message, aliPushMessageDTO.getBody(), xpOperationsUser);
+                                notifications.add(operationsUserNotification);
                             }
                         }
                     }
@@ -448,11 +472,74 @@
         if(schedulingDetails.isEmpty()){
             this.saveOrUpdateBatch(schedulingDetails);
         }
+        //异步处理消息通知数据
+        pushMessage(pushMessage, notifications);
         return R.ok();
     }
 
 
     /**
+     * 构建推送消息对象
+     * @param message
+     * @param xpOperationsUser
+     * @return
+     */
+    private AliPushMessageDTO buildPushMessage(String message, XpOperationsUser xpOperationsUser){
+        JSONObject body = new JSONObject();
+        body.put("content", message);
+        body.put("strategy", 4);
+        body.put("type", 0);
+        body.put("id", 0);
+
+        AliPushMessageDTO aliPushMessageDTO = new AliPushMessageDTO();
+        aliPushMessageDTO.setDeviceType(xpOperationsUser.getDeviceType());
+        aliPushMessageDTO.setAccount(xpOperationsUser.getPhoneNumber());
+        aliPushMessageDTO.setTitle("排班变更提示");
+        aliPushMessageDTO.setBody(body.toJSONString());
+        aliPushMessageDTO.setPushType("NOTICE");
+        return aliPushMessageDTO;
+    }
+
+
+    /**
+     * 构建消息存储
+     * @param body
+     * @param xpOperationsUser
+     * @return
+     */
+    private XpOperationsUserNotification buildXpOperationsUserNotification(String message, String body, XpOperationsUser xpOperationsUser){
+        XpOperationsUserNotification operationsUserNotification = new XpOperationsUserNotification();
+        operationsUserNotification.setNotificationType(NotificationTypeEnum.SCHEDULE_CHANGED.getCode());
+        operationsUserNotification.setNotificationContent(message);
+        operationsUserNotification.setOperationsUserId(xpOperationsUser.getId());
+        operationsUserNotification.setReadStatus(0);
+        operationsUserNotification.setNotificationExt(body);
+        return operationsUserNotification;
+    }
+
+
+    /**
+     * 异步处理消息推送
+     * @param pushMessage
+     * @param notifications
+     */
+    private void pushMessage(List<AliPushMessageDTO> pushMessage, List<XpOperationsUserNotification> notifications) {
+        if(pushMessage.isEmpty()){
+            return;
+        }
+        ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
+        executor.execute(() -> {
+            xpOperationUserNotificationClient.addNotificationBatch(notifications);
+            for (AliPushMessageDTO aliPushMessageDTO : pushMessage) {
+                xpAliPushMessageClient.pushMessage(aliPushMessageDTO);
+            }
+        });
+    }
+
+
+
+
+    /**
      * 导出排班数据
      * @param month
      * @param response

--
Gitblit v1.7.1