Browse Source

通知、通告 全部已读、部分已读功能开发

user5 2 năm trước cách đây
mục cha
commit
4cd432e8a9

+ 23 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/common/handler/ExtUserTaskActivityBehavior.java

@@ -155,6 +155,29 @@ public class ExtUserTaskActivityBehavior extends UserTaskActivityBehavior {
                                 candidateUserIds.add(map.get ("id").toString ());
                             }
                         }
+                        //如果字符串中包含 "zsCurrentUserSql:" 则进行如下代码替换和处理
+                        if(flowAssignee.getValue ().contains("zsbxCurrentUserSql:")){
+                            //对应sql为:select su.* from sys_user_role a left join sys_role sr on sr.id = a.role_id left join sys_user su on su.id = a.user_id left join sys_office so on so.id = su.office_id where sr.en_name= 'bmzr' and so.id = (select office_id from sys_user where id = @currentUser.id)
+                            //用于查询当前登录人的部门主任人员信息
+                            UserDTO currentUserDTO = UserUtils.getCurrentUserDTO();
+                            String sql = flowAssignee.getValue ();
+                            if(sql.contains("@currentUser.id")){
+                                //将标志进行去除
+                                sql = sql.replaceAll("zsbxCurrentUserSql:","");
+                                //将判断条件进行替换
+                                sql = sql.replaceAll("@currentUser.id","'" + currentUserDTO.getId() + "'");
+                            }
+                            if(sql.contains("@currentUser.officeDTO.name")){
+                                //将标志进行去除
+                                sql = sql.replaceAll("zsbxCurrentUserSql:","");
+                                //将判断条件进行替换
+                                sql = sql.replaceAll("@currentUser.officeDTO.name","'" + currentUserDTO.getOfficeDTO().getName() + "'");
+                            }
+                            List<Map<String, Object>> maps = SpringUtil.getBean(JdbcTemplate.class).queryForList(sql);
+                            for (Map<String, Object> map : maps) {
+                                candidateUserIds.add(map.get ("id").toString ());
+                            }
+                        }
 
                         break;
                 }

+ 23 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/common/handler/MutiInstanceHandler.java

@@ -136,6 +136,29 @@ public class MutiInstanceHandler {
                                 candidateUserIds.add(map.get ("id").toString ());
                             }
                         }
+                        //如果字符串中包含 "zsCurrentUserSql:" 则进行如下代码替换和处理
+                        if(flowAssignee.getValue ().contains("zsbxCurrentUserSql:")){
+                            //对应sql为:select su.* from sys_user_role a left join sys_role sr on sr.id = a.role_id left join sys_user su on su.id = a.user_id left join sys_office so on so.id = su.office_id where sr.en_name= 'bmzr' and so.id = (select office_id from sys_user where id = @currentUser.id)
+                            //用于查询当前登录人的部门主任人员信息
+                            UserDTO currentUserDTO = UserUtils.getCurrentUserDTO();
+                            String sql = flowAssignee.getValue ();
+                            if(sql.contains("@currentUser.id")){
+                                //将标志进行去除
+                                sql = sql.replaceAll("zsbxCurrentUserSql:","");
+                                //将判断条件进行替换
+                                sql = sql.replaceAll("@currentUser.id","'" + currentUserDTO.getId() + "'");
+                            }
+                            if(sql.contains("@currentUser.officeDTO.name")){
+                                //将标志进行去除
+                                sql = sql.replaceAll("zsbxCurrentUserSql:","");
+                                //将判断条件进行替换
+                                sql = sql.replaceAll("@currentUser.officeDTO.name","'" + currentUserDTO.getOfficeDTO().getName() + "'");
+                            }
+                            List<Map<String, Object>> maps = SpringUtil.getBean(JdbcTemplate.class).queryForList(sql);
+                            for (Map<String, Object> map : maps) {
+                                candidateUserIds.add(map.get ("id").toString ());
+                            }
+                        }
                         break;
                 }
             }

+ 20 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/controller/NotifyController.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
+import com.jeeplus.aop.logging.annotation.ApiLog;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.notify.domain.PluginNotifyComments;
@@ -140,4 +141,23 @@ public class NotifyController {
         return ResponseEntity.ok(s);
     }
 
+    /**
+     * 部分标记为已读
+     * @param ids
+     * @return
+     */
+    @ApiLog("部分标记为已读")
+    @PostMapping("portionRead")
+    public ResponseEntity portionRead(String ids) {
+        String idArray[] =ids.split(",");
+        notifyService.portionRead (Lists.newArrayList (idArray));
+        return ResponseEntity.ok ("部分标记为已读成功");
+    }
+
+    @ApiOperation(value = "全部标记已读")
+    @PostMapping("/readAll")
+    public String readAll() {
+        return notifyService.readAll();
+    }
+
 }

+ 2 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/NotifyMapper.java

@@ -71,4 +71,6 @@ public interface NotifyMapper extends BaseMapper <Notify> {
      * 将时间结束的通知关闭
      */
     void updateNotifyClose();
+
+    void readAll(@Param("userId") String userId);
 }

+ 5 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/NotifyMapper.xml

@@ -252,4 +252,9 @@
         notify_type = 0 and NOW() > end_date and del_flag = 0
     </update>
 
+    <update id="readAll">
+        update plugin_notify_record set read_flag = "1" where user_id = #{userId}
+        and notify_id in (select id from plugin_notify where is_close = "0")
+    </update>
+
 </mapper>

+ 26 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/NotifyService.java

@@ -298,4 +298,30 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
     public void closeById(String id) {
         notifyMapper.closeById(id);
     }
+
+    /**
+     * 将选定的通告信息改为已读
+     * @param idList
+     * @return
+     */
+    public void portionRead(List<String> idList){
+        if(null != idList && idList.size()>0){
+            for (String id: idList) {
+                notifyRecordService.lambdaUpdate ( ).eq ( NotifyRecord::getNotifyId, id )
+                        .eq ( NotifyRecord::getUserId, UserUtils.getCurrentUserDTO ( ).getId ( ) ).ne ( NotifyRecord::getReadFlag, CommonConstants.YES )
+                        .set ( NotifyRecord::getReadDate, new Date ( ) ).set ( NotifyRecord::getReadFlag, CommonConstants.YES ).update ( );
+            }
+        }
+    }
+
+    /**
+     * 当前登录人的所有有效通告均改为已读
+     * @return
+     */
+    public String readAll() {
+        // 获取当前登录人信息
+        UserDTO userDTO = UserUtils.getCurrentUserDTO();
+        notifyMapper.readAll(userDTO.getId());
+        return "操作成功";
+    }
 }