Selaa lähdekoodia

新增消息推送定时任务,修改推送服务查看链接

wch 3 vuotta sitten
vanhempi
commit
7c98eb323c

+ 12 - 0
ruoyi-hndj/src/main/java/com/ruoyi/daily/notice/domain/Notice.java

@@ -60,6 +60,9 @@ public class Notice extends BaseEntity
     /** 消息推送id*/
     private String taskId;
 
+    /** 消息状态*/
+    private String taskStatus;
+
     public String getTaskId() {
         return taskId;
     }
@@ -165,6 +168,14 @@ public class Notice extends BaseEntity
         this.pubOrganizeId = pubOrganizeId;
     }
 
+    public String getTaskStatus() {
+        return taskStatus;
+    }
+
+    public void setTaskStatus(String taskStatus) {
+        this.taskStatus = taskStatus;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -180,6 +191,7 @@ public class Notice extends BaseEntity
             .append("createTime", getCreateTime())
             .append("pubOrganize", getPubOrganize())
             .append("pubOrganizeId", getPubOrganizeId())
+            .append("taskStatus", getTaskStatus())
             .toString();
     }
 }

+ 2 - 1
ruoyi-hndj/src/main/java/com/ruoyi/daily/notice/service/impl/NoticeServiceImpl.java

@@ -49,7 +49,7 @@ public class NoticeServiceImpl implements INoticeService
      * @return 通知公告管理
      */
     @Override
-    @DataScope(deptAlias = "d")
+    //@DataScope(deptAlias = "d")
     public List<Notice> selectNoticeList(Notice notice)
     {
         return noticeMapper.selectNoticeList(notice);
@@ -76,6 +76,7 @@ public class NoticeServiceImpl implements INoticeService
     public int insertNotice(Notice notice)
     {
         notice.setCreateTime(DateUtils.getNowDate());
+        notice.setTaskStatus("未发布");
         int i = noticeMapper.insertNotice(notice);
         notice.setNoticeId(noticeMapper.selectNoticeByNotice(notice));
         if(i>0 && "1".equals(notice.getIsPublish())){

+ 9 - 3
ruoyi-hndj/src/main/resources/mapper/daily/NoticeMapper.xml

@@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime" column="update_time"/>
         <result property="noticeType"    column="notice_type"    />
         <result property="taskId"    column="task_id"    />
+        <result property="taskStatus"    column="task_status"    />
     </resultMap>
 
     <sql id="selectNoticeVo">
-        select notice_id, title, content, is_publish, publish_time, click_num, upload_photo, publish_by, create_by, create_time, notice_type , update_by, update_time, pub_organize, pub_organizeId from hndj_daily_notice
+        select notice_id, title, content, is_publish, publish_time, click_num, upload_photo, publish_by, create_by, create_time, notice_type , update_by, update_time, pub_organize, pub_organizeId ,task_status from hndj_daily_notice
     </sql>
 
     <select id="selectNoticeList" parameterType="Notice" resultMap="NoticeResult">
@@ -45,8 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null "> and h.create_time = #{createTime}</if>
             <if test="updateBy != null "> and h.update_by = #{updateBy}</if>
             <if test="updateTime != null "> and h.update_time = #{updateTime}</if>
+            <if test="taskStatus != null and taskStatus != ''"> and h.task_status = #{taskStatus}</if>
             <!-- 数据范围过滤 -->
-            ${params.dataScope}
+            /*${params.dataScope}*/
         </where>
     </select>
 
@@ -66,7 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
         
     <insert id="insertNotice" parameterType="Notice" useGeneratedKeys="true" keyProperty="noticeId">
-        insert into hndj_daily_notice        <trim prefix="(" suffix=")" suffixOverrides=",">
+        insert into hndj_daily_notice
+        <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="noticeId != null ">notice_id,</if>
             <if test="title != null  and title != ''">title,</if>
             <if test="content != null  and content != ''">content,</if>
@@ -78,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createBy != null  and createBy != ''">create_by,</if>
             <if test="createTime != null ">create_time,</if>
             <if test="noticeType != null ">notice_type,</if>
+            <if test="taskStatus != null and taskStatus != ''">task_status,</if>
 <!--            <if test="taskId != null ">task_id,</if>-->
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -92,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createBy != null  and createBy != ''">#{createBy},</if>
             <if test="createTime != null ">#{createTime},</if>
             <if test="noticeType != null ">#{noticeType},</if>
+            <if test="taskStatus != null  and taskStatus != ''">#{taskStatus},</if>
 <!--            <if test="taskId != null ">#{taskId},</if>-->
          </trim>
     </insert>
@@ -109,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null ">update_by = #{updateBy},</if>
             <if test="updateTime != null ">update_time = #{updateTime},</if>
             <if test="noticeType != null ">notice_type = #{noticeType},</if>
+            <if test="taskStatus != null and taskStatus != ''">task_status = #{taskStatus},</if>
 <!--            <if test="taskId != null ">task_id = #{taskId},</if>-->
         </trim>
         where notice_id = #{noticeId}

+ 19 - 8
ruoyi-hndj/src/main/resources/templates/daily/push/push.html

@@ -69,7 +69,7 @@
                     field: 'title',
                     title: '标题',
                     formatter: function (value,row,index) {
-                        return '<a href="javascript:void(0)" onclick="openDetail('+ row.pushId +')"> '+ row.title +' </a>';
+                        return '<a href="javascript:void(0)" onclick="openDetail(\'' + encodeURI(JSON.stringify(row)) + '\')"> '+ row.title +' </a>';
                     }
                 },
                 {
@@ -125,13 +125,24 @@
         $.modal.open("添加推送",prefix + "/edit/" + pushId);
     }
 
-    function openDetail(pushId) {
-        var options = {
-            title: '推送服务',
-            url: prefix + "/detail/" + pushId,
-            full:true
-        };
-        $.modal.openOptions(options);
+    function openDetail(data) {
+        var data = JSON.parse(decodeURI(data))
+        var index = layer.open({
+            type: 1,
+            fix: false,
+            //不固定
+            maxmin: true,
+            shade: 0.3,
+            title: data.title,
+            content: '<div style="padding: 10px;">' + data.content + '</div>',
+            btn: ['关闭'],
+            // 弹层外区域关闭
+            shadeClose: true,
+            cancel: function (index) {
+                return true;
+            }
+        });
+        layer.full(index);
     }
 </script>
 </body>

+ 47 - 0
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/noticeTask.java

@@ -0,0 +1,47 @@
+package com.ruoyi.quartz.task;
+
+import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.daily.getui.env.PushApiUtil;
+import com.ruoyi.daily.notice.domain.Notice;
+import com.ruoyi.daily.notice.service.INoticeService;
+import com.ruoyi.party.partychangecheck.domain.PartyChangeCheck;
+import com.ruoyi.party.partychangecheck.service.IPartyChangeCheckService;
+import com.ruoyi.party.partychargedetails.domain.PartyChargeDetails;
+import com.ruoyi.party.partychargedetails.service.IPartyChargeDetailsService;
+import com.ruoyi.party.partychargestandard.domain.PartyChargeStandard;
+import com.ruoyi.party.partychargestandard.serviice.IPartyChargeStandardService;
+import com.ruoyi.system.mapper.SysDeptMapper;
+import com.ruoyi.system.service.ISysDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+/**
+ * 定时任务调度测试
+ * 
+ * @author ruoyi
+ */
+@Component("noticeTask")
+public class noticeTask
+{
+    @Autowired
+    private INoticeService noticeService;
+
+    public void notice(){
+        Notice notice = new Notice();
+        notice.setTaskStatus("未发布");
+        List<Notice> list = noticeService.selectNoticeList(notice);
+        List<Notice> listStatus =  list.stream().filter(e->e.getPublishTime().before(DateUtils.getNowDate())).collect(Collectors.toList());
+        listStatus.stream().forEach(e->{
+            PushApiUtil.getInstance().pushAll(e);
+            e.setTaskStatus("已发布");
+            noticeService.updateNotice(e);
+        });
+    }
+}