From 9d85ce9ce660b098a0814782b798075d61b35a50 Mon Sep 17 00:00:00 2001 From: GUO <1923636941@qq.com> Date: Tue, 7 May 2024 15:43:03 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zhgd/mybatis/DataScopeHandler.java | 14 ++++++++- .../xmgl/modules/basicdata/entity/Notice.java | 3 ++ .../basicdata/service/INoticeService.java | 4 +++ .../service/impl/NoticeServiceImpl.java | 31 +++++++++++++++++-- .../quality/entity/QualityRectifyRecord.java | 1 - .../xml/QualityInspectionRecordMapper.xml | 2 +- .../controller/VideoCallbackController.java | 12 +++++-- .../zhgd/xmgl/push/config/PushPayloads.java | 2 +- .../xmgl/push/service/UniPushService.java | 2 +- .../push/service/impl/UniPushServiceImpl.java | 10 +++--- 10 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/zhgd/mybatis/DataScopeHandler.java b/src/main/java/com/zhgd/mybatis/DataScopeHandler.java index e2b477504..5b96a50a3 100644 --- a/src/main/java/com/zhgd/mybatis/DataScopeHandler.java +++ b/src/main/java/com/zhgd/mybatis/DataScopeHandler.java @@ -192,7 +192,19 @@ public class DataScopeHandler implements DataPermissionHandler { } if (!DataScopeInterceptor.isNotSqlTest()) { - equalsTo("'qqq'", "'qqq'", plainSelect); + String sql = " ('1qqq')"; + try { + Expression expression = CCJSqlParserUtil.parseCondExpression(sql); + Expression where = plainSelect.getWhere(); + if (where != null) { + where = new AndExpression(where, expression); + } else { + where = expression; + } + plainSelect.setWhere(where); + } catch (JSQLParserException e) { + throw new RuntimeException(e); + } } //List scopeIds = systemUserDataScopeService.list(Wrappers.lambdaQuery().eq(SystemUserDataScope::getUserId, user.getUserId())) diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/Notice.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/Notice.java index a9169ba0e..6883f62c6 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/Notice.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/Notice.java @@ -63,4 +63,7 @@ public class Notice implements Serializable { @Excel(name = "推送的时间", width = 15) @ApiModelProperty(value = "推送的时间") private java.lang.String sendTime; + @ApiModelProperty(value = "载荷") + private java.lang.String payload; + } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java index c0b4a63ea..272b0ad48 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java @@ -18,8 +18,12 @@ public interface INoticeService extends IService { void addNotice(Notice notice, boolean sendNotice); + void addNoticeAndApp(Notice notice, boolean sendNotice); + void cleanAllNotice(Map map); + void addUserNotice(Long accountId, String msg, String title, String type, String payload); + /** * 发通知,给某人 * diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java index d1f4b3b1f..b8e140276 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java @@ -1,5 +1,8 @@ package com.zhgd.xmgl.modules.basicdata.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializeConfig; +import com.alibaba.fastjson.serializer.ToStringSerializer; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -61,6 +64,20 @@ public class NoticeServiceImpl extends ServiceImpl impleme } } + @Override + public void addNoticeAndApp(Notice notice, boolean sendNotice) { + noticeMapper.insert(notice); + if (sendNotice) { + sendPushMessage(notice); + } + SystemUser systemUser = systemUserMapper.selectById(notice.getAccountId()); + if (systemUser == null) { + return; + } + uniPushService.pushToSingleByAlias(systemUser.getClientId(), notice.getTitle(), notice.getMsg(), null); + + } + @Override public void cleanAllNotice(Map map) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -69,7 +86,7 @@ public class NoticeServiceImpl extends ServiceImpl impleme } @Override - public void addUserNotice(Long accountId, String msg, String title, String type) { + public void addUserNotice(Long accountId, String msg, String title, String type, String payload) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Notice notice = new Notice(); notice.setAccountId(accountId); @@ -77,18 +94,26 @@ public class NoticeServiceImpl extends ServiceImpl impleme notice.setTitle(title); notice.setSendTime(sdf.format(new Date())); notice.setType(type); + notice.setPayload(payload); noticeMapper.insert(notice); sendPushMessage(notice); } + @Override + public void addUserNotice(Long accountId, String msg, String title, String type) { + addUserNotice(accountId, msg, title, type, null); + } + @Override public void addUserNoticeAndApp(Long accountId, String msg, String title, String type, Object payload) { - addUserNotice(accountId, msg, title, type); + final SerializeConfig config = new SerializeConfig(); + config.put(Long.class, ToStringSerializer.instance); + addUserNotice(accountId, msg, title, type, JSONObject.toJSONString(payload, config)); SystemUser systemUser = systemUserMapper.selectById(accountId); if (systemUser == null) { return; } - uniPushService.pushToSingleByAlias(systemUser.getClientId(), title, msg, payload); + uniPushService.pushToSingleByAlias(systemUser.getClientId(), title, msg, null); } @Override diff --git a/src/main/java/com/zhgd/xmgl/modules/quality/entity/QualityRectifyRecord.java b/src/main/java/com/zhgd/xmgl/modules/quality/entity/QualityRectifyRecord.java index 3ec9aedc5..566ec0553 100644 --- a/src/main/java/com/zhgd/xmgl/modules/quality/entity/QualityRectifyRecord.java +++ b/src/main/java/com/zhgd/xmgl/modules/quality/entity/QualityRectifyRecord.java @@ -34,7 +34,6 @@ public class QualityRectifyRecord implements Serializable { */ @Excel(name = "质量检查记录ID", width = 15) @ApiModelProperty(value = "质量检查记录ID") - private java.lang.Long qualityId; /** * 类型,1整改记录,2复查记录,3核验记录 diff --git a/src/main/java/com/zhgd/xmgl/modules/quality/mapper/xml/QualityInspectionRecordMapper.xml b/src/main/java/com/zhgd/xmgl/modules/quality/mapper/xml/QualityInspectionRecordMapper.xml index 0de5dae48..057318ae2 100644 --- a/src/main/java/com/zhgd/xmgl/modules/quality/mapper/xml/QualityInspectionRecordMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/quality/mapper/xml/QualityInspectionRecordMapper.xml @@ -50,7 +50,7 @@ ifnull((CASE WHEN a.status = 5 THEN (select rectify_time from quality_rectify_record - where quality_id = a.id and type = 3 and status = 2) > a.change_limit_time + where quality_id = a.id and type = 3 and status = 2 ORDER BY create_time desc LIMIT 1) > a.change_limit_time ELSE a.change_limit_time now() END),0) overTime from quality_inspection_record a LEFT JOIN enterprise_info b ON a.enterprise_sn = b.enterprise_sn diff --git a/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoCallbackController.java b/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoCallbackController.java index 47a784b97..60a05825c 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoCallbackController.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoCallbackController.java @@ -2,6 +2,8 @@ package com.zhgd.xmgl.modules.video.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializeConfig; +import com.alibaba.fastjson.serializer.ToStringSerializer; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.zhgd.xmgl.modules.basicdata.entity.DictionariesRecord; import com.zhgd.xmgl.modules.basicdata.entity.Notice; @@ -13,6 +15,7 @@ import com.zhgd.xmgl.modules.video.entity.VideoAlarm; import com.zhgd.xmgl.modules.video.entity.VideoItem; import com.zhgd.xmgl.modules.video.service.IVideoAlarmService; import com.zhgd.xmgl.modules.video.service.IVideoItemService; +import com.zhgd.xmgl.push.config.PushPayloads; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -109,14 +112,14 @@ public class VideoCallbackController { //向项目管理员推送通知 if(systemUserList.size()>0){ for (SystemUser systemUser:systemUserList){ - addNotice(systemUser.getUserId(),msg,title,sdf.format(new Date()),videoAlarm.getImageUrl()); + addNotice(systemUser.getUserId(),msg,title,sdf.format(new Date()),videoAlarm.getImageUrl(),videoAlarm); } } //向配置的推送人推送通知 if(StringUtils.isNotEmpty(item.getAlarmPushWorkerId())&&item.getAlarmPushWorkerId().length()>0){ String[] person=item.getAlarmPushWorkerId().split(","); for (int i = 0; i pushDTO = this.buildPushDTO(title, content, payload); // log.info("payload-----" + pushDTO.getPushMessage().getNotification().getPayload()); log.info("alias----{},title-----{},content-----{}", alias, title, content); @@ -65,7 +65,7 @@ public class UniPushServiceImpl implements UniPushService { } - private PushDTO buildPushDTO(String title, String content, Object payload) { + private PushDTO buildPushDTO(String title, String content, String payload) { PushDTO pushDTO = new PushDTO<>(); // 设置推送参数 //requestid需要每次变化唯一 @@ -100,7 +100,7 @@ public class UniPushServiceImpl implements UniPushService { aps.setSound("default"); aps.setAlert(alert); IosDTO iosDTO = new IosDTO(); - iosDTO.setPayload(payload.toString()); + iosDTO.setPayload(payload); iosDTO.setAps(aps); iosDTO.setType("notify"); @@ -117,8 +117,8 @@ public class UniPushServiceImpl implements UniPushService { notification1.setBody(content); notification1.setClickType("intent"); notification1.setIntent("intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component=com.weixiaobao/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=" + title + ";S.content=" + content + ";S.payload=" + payload + ";end"); - notification1.setPayload(payload.toString()); - notification1.setUrl(payload.toString()); + notification1.setPayload(payload); + notification1.setUrl(payload); //各厂商自有功能单项设置 //ups.addOption("HW", "/message/android/notification/badge/class", "io.dcloud.PandoraEntry "); //ups.addOption("HW", "/message/android/notification/badge/add_num", 1);