Browse Source

feat(push): 优化极光推送服务及前端通知功能

- 修改 JiGuangPushService,支持开发环境别名前缀添加
- 更新推送日志打印格式,便于识别
- 修复 PsPatrolTask 中日期判断逻辑错误
- 简化 TIndexController 注解引入方式
- 增强发送测试接口,支持多别名推送
- 新增前端发送通知按钮与交互逻辑
- 优化首页通知滚动显示条件及动画计算
- 统一后端计划查询参数命名规则
jiangbiao 1 week ago
parent
commit
5b6dde68f8

+ 5 - 5
master/src/main/java/com/ruoyi/common/jpush/JiGuangPushService.java

@@ -49,15 +49,14 @@ public class JiGuangPushService {
         notificationMessage.setAlert(alert);
         notificationMessage.setAndroid(android);
         param.setNotification(notificationMessage);
-        String[] alias1 = alias;
         if (isDev) {
             for (int i = 0 ;i<alias.length;i++) {
-                alias1[i]="dev_" + alias[i];
+                alias[i]="dev_" + alias[i];
             }
         }
         // 目标人群
         Audience audience = new Audience();
-        audience.setAliasList(Arrays.asList(alias1));
+        audience.setAliasList(Arrays.asList(alias));
 //        audience.setRegistrationIdList(Arrays.asList("1104a89793af2cfc030", "1104a89793af2cfc030"));
         // 指定目标
         param.setAudience(audience);
@@ -69,13 +68,14 @@ public class JiGuangPushService {
         // 或者发送所有平台
         param.setPlatform(ApiConstants.Platform.ANDROID);
 
-        log.info("param:{}", JSON.toJSONString(param));
+        log.info("===================JiGuang param:{}", JSON.toJSONString(param));
         // 发送
         try {
             PushSendResult result = pushApi.send(param);
-            log.info("Push result: {}", result);
+            log.info("========================JiGuang Push result: {}", result);
         } catch (Exception e) {
             e.printStackTrace();
+            log.error("========================JiGuang Push result: {}", e.getMessage());
         }
 
     }

+ 1 - 1
master/src/main/java/com/ruoyi/framework/task/PsPatrolTask.java

@@ -40,7 +40,7 @@ public class PsPatrolTask extends BaseController {
         tPsPatrolPlan.setPlanYear((long) (calendar.get(Calendar.YEAR)));
         TPsPatrolMain tPsPatrolMain = new TPsPatrolMain();
         tPsPatrolMain.setYear(String.valueOf(calendar.get(Calendar.YEAR)));
-        if (calendar.get(Calendar.DATE) > 15) {
+        if (calendar.get(Calendar.DATE) < 15) {
             // 每三个月一次的
             if (calendar.get(Calendar.MONTH) == Calendar.FEBRUARY || calendar.get(Calendar.MONTH) == Calendar.MAY || calendar.get(Calendar.MONTH) == Calendar.AUGUST || calendar.get(Calendar.MONTH) == Calendar.NOVEMBER) {
                 // 每三个月一次巡检的设备,中间月创建巡检计划

+ 5 - 7
master/src/main/java/com/ruoyi/project/patrol/patrol/controller/TIndexController.java

@@ -6,10 +6,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.project.patrol.patrol.domain.TIndex;
 import com.ruoyi.project.patrol.patrol.service.ITIndexService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.*;
 
@@ -36,8 +33,9 @@ public class TIndexController extends BaseController {
         return AjaxResult.success(resultMap);
     }
 
-    @PostMapping
-    public void sentTest() {
-        jiGuangPushService.send("欢迎使用EHS管理助手", "欢迎使用EHS管理助手!","1");
+    @PostMapping("/sentTest/{alias}")
+    public void sentTest(@PathVariable("alias") String alias) {
+        String[] split = alias.split(",");
+        jiGuangPushService.send("欢迎使用EHS管理助手", "欢迎使用EHS管理助手!",split);
     }
 }

+ 6 - 0
ui/src/api/patrol/index.js

@@ -5,3 +5,9 @@ export function getCountNums() {
     method: 'get'
   })
 }
+export function sentTest(alias) {
+  return request({
+    url: '/patrol/index/sentTest/'+alias,
+    method: 'post'
+  })
+}

+ 27 - 0
ui/src/views/monitor/operlog/index.vue

@@ -100,6 +100,14 @@
           v-hasPermi="['system:config:export']"
         >{{ $t('导出') }}</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-chat-dot-square"
+          size="mini"
+          @click="handelNotice"
+        >发送通知</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -185,6 +193,8 @@
 
 <script>
 import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog";
+import {syncMoc} from "@/api/pssr/moc";
+import {sentTest} from "@/api/patrol";
 
 export default {
   name: "Operlog",
@@ -233,6 +243,23 @@ export default {
     });
   },
   methods: {
+    handelNotice(){
+      this.$prompt('请输入要发送的 alias', '提示', {
+        inputValue: '',
+        inputPlaceholder: '请输入要发送的 alias,多个 alias 请用英文逗号\',\'隔开',
+        confirmButtonText: '发送',
+        cancelButtonText: '取消',
+      }).then(({value}) => {
+        sentTest(value).then(response => {
+          this.msgSuccess("通知发送成功");
+        });
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '取消发送通知'
+        });
+      });
+    },
     /** 查询登录日志 */
     getList() {
       this.loading = true;

+ 0 - 1
ui/src/views/patrol/home/index.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="dashboard-editor-container">
-<!--    <el-button @click="sendNotification" type="text">发送通知</el-button>-->
     <panel-group/>
 
     <el-row>

+ 10 - 10
ui/src/views/ps/home/dashboard/NoticeChart.vue

@@ -13,7 +13,7 @@
           </span>
         </li>
         <!-- 复制一份列表实现无缝滚动 -->
-        <li v-for="(item,index) in noticeList" :key="'copy-' + index" class="notice-item">
+        <li v-for="(item,index) in noticeList" :key="'copy-' + index" class="notice-item" v-if="noticeList.length>10">
           <span>截止日期:{{ parseTime(item.deadline, '{yyyy}-{mm}-{dd}') }}
             <el-tag size="medium" effect="plain">{{ item.planName }}</el-tag>
           </span>
@@ -47,7 +47,7 @@ export default {
     return {
       // 查询参数
       queryParams: {
-        planQuarter: new Date().getMonth() + 1, planYear: new Date().getFullYear()
+        planMonth: new Date().getMonth() + 1, planYear: new Date().getFullYear()
       },
       // 公示公告列表
       noticeList: [],
@@ -79,25 +79,25 @@ export default {
     listNoticeNoPage() {
       listPlan(this.queryParams).then(response => {
         this.noticeList = response.rows || [];
-        
+
         // 判断是否需要滚动
-        if (this.noticeList.length > 0) {
+        if (this.noticeList.length > 10) {
           this.$nextTick(() => {
             // 清理之前的 style
             if (this.styleElement && this.styleElement.parentNode) {
               this.styleElement.parentNode.removeChild(this.styleElement);
             }
-            
+
             let elem = document.querySelector('.allNotice');
             if (!elem) return;
-            
+
             // 每个 li 的高度约为 50px(包括margin)
             const itemHeight = 50;
             const listHeight = this.noticeList.length * itemHeight;
-            
+
             // 设置滚动时间(可根据列表长度调整)
             const scrollTime = this.noticeList.length * 2;
-            
+
             // 创建无缝滚动的 keyframes
             // 从 0 滚动到 -listHeight,然后重新开始
             const keyframeName = 'seamlessScroll-' + Date.now();
@@ -109,13 +109,13 @@ export default {
                 transform: translateY(-${listHeight}px);
               }
             }`;
-            
+
             // 动态插入 keyframes
             this.styleElement = document.createElement("style");
             this.styleElement.setAttribute("type", "text/css");
             this.styleElement.textContent = myFirstkeyframes;
             document.head.appendChild(this.styleElement);
-            
+
             // 应用动画
             elem.style['animation'] = `${keyframeName} ${scrollTime}s linear infinite`;
           });

+ 1 - 1
ui/src/views/ps/home/dashboard/PieChart.vue

@@ -31,7 +31,7 @@ export default {
       planList: [],
       // 查询参数
       queryParams: {
-        planQuarter: new Date().getMonth() + 1, planYear: new Date().getFullYear()
+        planMonth: new Date().getMonth() + 1, planYear: new Date().getFullYear()
       },
     }
   },