From b069101e1bf347ceab11e33d73b2fbb7f37d4686 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 25 四月 2026 17:15:53 +0800
Subject: [PATCH] feat(production): 生产订单的工艺路线和参数的增删改逻辑
---
src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java | 70 ++++++++++++++++++++++-------------
1 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java b/src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java
index 7284ace..af06bbc 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java
+++ b/src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java
@@ -1,5 +1,6 @@
package com.ruoyi.project.system.service.impl;
+import com.alibaba.fastjson2.JSON;
import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi;
@@ -18,13 +19,14 @@
import com.ruoyi.project.system.domain.SysUserClient;
import com.ruoyi.project.system.mapper.SysMenuMapper;
import com.ruoyi.project.system.service.SysUserClientService;
+import jakarta.annotation.PostConstruct;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,16 +39,12 @@
*/
@Slf4j
@Component
+@RequiredArgsConstructor
public class UnipushService {
- @Autowired
- private SysMenuMapper sysMenuMapper;
-
- @Autowired
- private GetuiConfig getuiConfig;
-
- @Autowired
- private SysUserClientService userClientService;
+ private final SysMenuMapper sysMenuMapper;
+ private final GetuiConfig getuiConfig;
+ private final SysUserClientService userClientService;
private PushApi pushApi;
@@ -78,15 +76,19 @@
log.warn("鐢ㄦ埛 {} 鏈粦瀹氱Щ鍔ㄧ CID,璺宠繃鎺ㄩ��", sysNotice.getConsigneeId());
continue;
}
-
// 杞崲璺緞
String appPath = convertWebPathToAppPath(sysNotice.getJumpPath());
+ String content = sysNotice.getNoticeContent();
+ if (StringUtils.isNotEmpty(sysNotice.getRemark())) {
+ content = content + " " + sysNotice.getRemark();
+ }
// 鎺ㄩ��
sendRoutingPush(
+ sysNotice.getNoticeId(),
client.getCid(),
sysNotice.getNoticeTitle(),
- sysNotice.getRemark() != null ? sysNotice.getRemark() : sysNotice.getNoticeContent(),
+ content,
appPath
);
}
@@ -95,7 +97,7 @@
/**
* 灏� Web 绔垎灞傚叏璺緞杞崲涓� App 绔粍浠惰矾鐢�
*/
- private String convertWebPathToAppPath(String webPath) {
+ public String convertWebPathToAppPath(String webPath) {
if (StringUtils.isEmpty(webPath)) {
return DEFAULT_APP_PAGE;
}
@@ -115,42 +117,58 @@
} else {
lastSegment = pathOnly;
}
-
if (StringUtils.isEmpty(lastSegment)) {
return DEFAULT_APP_PAGE;
}
SysMenu menu = sysMenuMapper.selectMenuByPath(lastSegment);
-
if (menu != null && StringUtils.isNotEmpty(menu.getAppComponent())) {
String appPath = menu.getAppComponent();
-
if (appPath.startsWith("/")) {
appPath = appPath.substring(1);
}
-
// 鎷兼帴 Web 绔師濮嬪弬鏁板苟杩斿洖
return appPath + queryString;
}
-
return DEFAULT_APP_PAGE;
+ }
+
+ /**
+ * 鍙戦�佸洖璁挎彁閱�
+ */
+ public void sendReturnVisitReminder(Long returnVisitId, String cid, String content, Integer customerId) {
+ String targetPath = "pages/cooperativeOffice/customerManage/detail?customerId=" + customerId;
+ sendRoutingPush(returnVisitId, cid, "瀹㈡埛鍥炶鎻愰啋", content, targetPath, false);
}
/**
* 鍙戦�佸崟浜鸿矾鐢辨帹閫�
*/
- private void sendRoutingPush(String cid, String title, String content, String targetPath) {
- log.info("鍑嗗鎺ㄩ�佹秷鎭�: CID={}, Title={}, TargetPath={}", cid, title, targetPath);
+ private void sendRoutingPush(Long noticeId, String cid, String title, String content, String targetPath) {
+ sendRoutingPush(noticeId, cid, title, content, targetPath, true);
+ }
+
+ /**
+ * 鍙戦�佸崟浜鸿矾鐢辨帹閫�
+ */
+ private void sendRoutingPush(Long noticeId, String cid, String title, String content, String targetPath, boolean needMarkRead) {
+ log.info("鍑嗗鎺ㄩ�佹秷鎭�:NoticeId={}, CID={}, Title={}, TargetPath={}", noticeId, cid, title, targetPath);
PushDTO<Audience> pushDTO = new PushDTO<>();
pushDTO.setRequestId("REQ_" + System.currentTimeMillis());
// 鍦ㄧ嚎閫忎紶鍐呭
PushMessage pushMessage = new PushMessage();
- String transmissionContent = String.format(
- "{\"title\":\"%s\",\"content\":\"%s\",\"payload\":\"%s\"}",
- title, content, targetPath
- );
+ Map<String, Object> pushMessageMap = new HashMap<>();
+ Map<String, Object> payloadMap = new HashMap<>();
+ pushMessageMap.put("title", title);
+ pushMessageMap.put("content", content);
+ payloadMap.put("url", targetPath);
+ payloadMap.put("noticeId", noticeId);
+ payloadMap.put("needMarkRead", needMarkRead);
+ pushMessageMap.put("payload", JSON.toJSONString(payloadMap));
+
+ String transmissionContent = JSON.toJSONString(pushMessageMap);
pushMessage.setTransmission(transmissionContent);
pushDTO.setPushMessage(pushMessage);
@@ -160,7 +178,7 @@
pushDTO.setAudience(audience);
// 绂荤嚎鎺ㄩ�侀�氶亾
- pushDTO.setPushChannel(getPushChannel(title, content, targetPath));
+// pushDTO.setPushChannel(getPushChannel(noticeId, title, content, targetPath));
try {
ApiResult<Map<String, Map<String, String>>> result = pushApi.pushToSingleByCid(pushDTO);
@@ -175,7 +193,7 @@
}
@NotNull
- private PushChannel getPushChannel(String title, String content, String targetPath) {
+ private PushChannel getPushChannel(Long noticeId, String title, String content, String targetPath) {
PushChannel pushChannel = new PushChannel();
AndroidDTO androidDTO = new AndroidDTO();
Ups ups = new Ups();
--
Gitblit v1.9.3