|
@@ -1,5 +1,6 @@
|
|
|
package com.rongwei.safecommon.utils;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -10,8 +11,12 @@ import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import com.rongwei.rwcommon.vo.CriteriaQuery;
|
|
|
+import com.rongwei.rwcommon.vo.generalsql.BatchSaveVo;
|
|
|
+import com.rongwei.rwcommon.vo.generalsql.GeneralInsertVo;
|
|
|
import com.rongwei.rwcommonentity.commonservers.vo.SysNotifyAnnounceVo;
|
|
|
import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
|
|
|
+import com.rongwei.safecommon.fegin.CXAdminFeginClient;
|
|
|
import com.rongwei.safecommon.fegin.CXCommonFeginClient;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -22,12 +27,10 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.rongwei.safecommon.utils.SaveConstans.AQ_ORG_CODE_MAP;
|
|
@@ -46,6 +49,8 @@ public class CXCommonUtils {
|
|
|
private RedisService autoRedisService;
|
|
|
@Autowired
|
|
|
private CXCommonFeginClient autoCommonFeginClient;
|
|
|
+ @Resource
|
|
|
+ private CXAdminFeginClient autoAdminFeginClient;
|
|
|
@Autowired
|
|
|
private SysSerialNumberService autoSysSerialNumberService;
|
|
|
|
|
@@ -54,14 +59,15 @@ public class CXCommonUtils {
|
|
|
private static RedisService redisService;
|
|
|
|
|
|
private static CXCommonFeginClient commonFeginClient;
|
|
|
+ private static CXAdminFeginClient adminFeginClient;
|
|
|
public static final String DEFAULT_NOTIFY_STATUS = "3";
|
|
|
|
|
|
|
|
|
-
|
|
|
@PostConstruct
|
|
|
public void info() {
|
|
|
redisService = autoRedisService;
|
|
|
commonFeginClient = autoCommonFeginClient;
|
|
|
+ adminFeginClient = autoAdminFeginClient;
|
|
|
sysSerialNumberService = autoSysSerialNumberService;
|
|
|
}
|
|
|
|
|
@@ -144,11 +150,37 @@ public class CXCommonUtils {
|
|
|
public static void sendNotify(String title, String content, String remark,
|
|
|
List<String> recipientIds, String roption,
|
|
|
String notifyStatus) {
|
|
|
- sendNotify(title, content, remark, recipientIds, roption, notifyStatus,true);
|
|
|
+ sendNotify(title, content, remark, recipientIds, roption, notifyStatus, true);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void pushApp(String title, String content, List<String> recipientIds){
|
|
|
+ public static void pushApp(String title, String content, List<String> recipientIds) {
|
|
|
+ if(recipientIds.size() <= 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BatchSaveVo batchSaveVo = new BatchSaveVo();
|
|
|
+ LinkedList<GeneralInsertVo> generalInserts = new LinkedList<>();
|
|
|
+ for (String recipientId : recipientIds) {
|
|
|
+ String uuid = SecurityUtil.getUUID();
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ID",uuid);
|
|
|
+ map.put("DELETED","0");
|
|
|
+ map.put("CREATEDATE",DateUtil.now());
|
|
|
+ map.put("TITLE", title);
|
|
|
+ map.put("CONTENT", content);
|
|
|
+ map.put("USERID", recipientId);
|
|
|
+
|
|
|
+ GeneralInsertVo generalInsertVo = new GeneralInsertVo();
|
|
|
+ generalInsertVo.setTablename("app_push_message");
|
|
|
+ generalInsertVo.setInsertcolumns(map);
|
|
|
+ generalInsertVo.setAutoGenId(false);
|
|
|
+ generalInsertVo.setIdCol("ID");
|
|
|
+ generalInserts.add(generalInsertVo);
|
|
|
+ }
|
|
|
+ batchSaveVo.setGeneralInserts(generalInserts);
|
|
|
+ adminFeginClient.batchSaveList(batchSaveVo);
|
|
|
+
|
|
|
//推送websocket消息给app
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("title", title);
|
|
@@ -158,7 +190,6 @@ public class CXCommonUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 发送消息提醒
|
|
|
*
|
|
@@ -171,9 +202,9 @@ public class CXCommonUtils {
|
|
|
* @param notifyStatus 消息提醒类型
|
|
|
* @param pushWebsocket 是否向webSocket推送消息
|
|
|
*/
|
|
|
- public static void sendNotify(String id,String title, String content, String remark,
|
|
|
+ public static void sendNotify(String id, String title, String content, String remark,
|
|
|
List<String> recipientIds, String roption,
|
|
|
- String notifyStatus,boolean pushWebsocket) {
|
|
|
+ String notifyStatus, boolean pushWebsocket) {
|
|
|
if (recipientIds == null || recipientIds.isEmpty()) {
|
|
|
log.debug("接收人ID为空");
|
|
|
return;
|
|
@@ -184,7 +215,7 @@ public class CXCommonUtils {
|
|
|
sysNotifyAnnounceVo.setNotifytype(notifyStatus);
|
|
|
sysNotifyAnnounceVo.setNotifystatus(DEFAULT_NOTIFY_STATUS);
|
|
|
sysNotifyAnnounceVo.setNotifytitle(title);
|
|
|
- sysNotifyAnnounceVo.setNotifycontent(content.replace("null"," "));
|
|
|
+ sysNotifyAnnounceVo.setNotifycontent(content.replace("null", " "));
|
|
|
sysNotifyAnnounceVo.setRemark(remark);
|
|
|
// 特殊处理
|
|
|
if (StringUtils.isNotBlank(roption)) {
|
|
@@ -194,9 +225,9 @@ public class CXCommonUtils {
|
|
|
log.debug("开始通过fegin发送消息通知: {}", sysNotifyAnnounceVo);
|
|
|
commonFeginClient.sendNotify(sysNotifyAnnounceVo);
|
|
|
// 通过webSocket推送数据
|
|
|
- if(pushWebsocket){
|
|
|
+ if (pushWebsocket) {
|
|
|
//防止推送用户过多,导致调用接口报错,实行分流
|
|
|
- Lists.partition(recipientIds, 10).forEach(userIds->{
|
|
|
+ Lists.partition(recipientIds, 10).forEach(userIds -> {
|
|
|
pushApp(title, content, userIds);
|
|
|
});
|
|
|
}
|
|
@@ -262,6 +293,7 @@ public class CXCommonUtils {
|
|
|
|
|
|
/**
|
|
|
* 计算时间和当前时间相差几天
|
|
|
+ *
|
|
|
* @param startDate
|
|
|
* @return
|
|
|
*/
|
|
@@ -281,13 +313,12 @@ public class CXCommonUtils {
|
|
|
* @return
|
|
|
* @date 2024/1/29 17:12
|
|
|
* @author shangmi
|
|
|
- *
|
|
|
*/
|
|
|
|
|
|
- public static void deleteSendNotify(String notifyType, String roption){
|
|
|
+ public static void deleteSendNotify(String notifyType, String roption) {
|
|
|
JSONArray data = JSONUtil.parseArray(commonFeginClient.list(new HashMap<String, Object>() {{
|
|
|
this.put("NOTIFYTYPE", notifyType);
|
|
|
- if (roption!=null){
|
|
|
+ if (roption != null) {
|
|
|
this.put("ROPTION", roption);
|
|
|
}
|
|
|
}}).getData());
|