mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 17:09:36 +08:00
20250618-添加已读未读,增加去重2.1
This commit is contained in:
parent
90277f4f30
commit
a565c4c9d1
@ -40,15 +40,14 @@ public class RepairRemindController extends BaseController {
|
||||
Long userId = getLoginStaffId();
|
||||
return result(repairRemindService.getRepairRemindList(userId, isRead));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定会议的所有通知
|
||||
* 查询指定会议提醒(根据会议repairId和用户userId)
|
||||
*/
|
||||
@RequiresPermissions(value = {"repair:manage:operator", "member:center:view"}, logical = Logical.OR)
|
||||
@RequestMapping("listByRepairId")
|
||||
public R listByRepairId(Long repairId) {
|
||||
public R listByRepairId(Long repairId, Long userId) {
|
||||
startPage();
|
||||
return result(repairRemindService.getRepairRemindListByRepairId(repairId));
|
||||
return result(repairRemindService.getRepairRemindListByRepairId(repairId,userId));
|
||||
}
|
||||
/**
|
||||
* 读取最新5条未读工单提醒
|
||||
|
@ -123,5 +123,12 @@ public interface RepairRemindMapper {
|
||||
*/
|
||||
int afterSMS(@Param("state") String state, @Param("ids") List<Long> ids);
|
||||
|
||||
List<RepairRemind> selectRepairRemindListByRepairId(Long repairId);
|
||||
/**
|
||||
* 根据会议ID和用户ID列表查询通知状态
|
||||
*
|
||||
* @param repairId 会议ID
|
||||
* @param userId 用户ID (可选,为null时查询所有)
|
||||
* @return 通知列表
|
||||
*/
|
||||
List<RepairRemind> selectRepairRemindListByRepairId(@Param("repairId") Long repairId, @Param("userId") Long userId);
|
||||
}
|
@ -3,6 +3,7 @@ package com.ics.admin.service;
|
||||
import com.ics.admin.domain.RepairRemind;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工单提醒Service接口
|
||||
@ -99,5 +100,6 @@ public interface IRepairRemindService {
|
||||
*/
|
||||
int afterSMS(List<Long> success, List<Long> failed);
|
||||
|
||||
List<?> getRepairRemindListByRepairId(Long repairId);
|
||||
// 根据repairId查询所有通知
|
||||
List<RepairRemind> getRepairRemindListByRepairId(Long repairId, Long userId);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工单提醒Service业务层处理
|
||||
@ -34,11 +34,8 @@ public class RepairRemindServiceImpl implements IRepairRemindService {
|
||||
return repairRemindMapper.selectRepairRemindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepairRemind> getRepairRemindListByRepairId(Long repairId) {
|
||||
// 根据repairId查询所有相关通知
|
||||
return repairRemindMapper.selectRepairRemindListByRepairId(repairId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户工单提醒列表
|
||||
*
|
||||
@ -153,4 +150,31 @@ public class RepairRemindServiceImpl implements IRepairRemindService {
|
||||
}
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<RepairRemind> getRepairRemindListByRepairId(Long repairId, Long userId) {
|
||||
// 根据repairId和userId查询相关通知
|
||||
List<RepairRemind> originalList = repairRemindMapper.selectRepairRemindListByRepairId(repairId, userId);
|
||||
|
||||
// 如果结果为空或只有一条记录,无需去重
|
||||
if (originalList == null || originalList.size() <= 1) {
|
||||
return originalList;
|
||||
}
|
||||
|
||||
// 使用Map进行去重,key为userId,value为最新的通知记录
|
||||
Map<Long, RepairRemind> latestRemindMap = new HashMap<>();
|
||||
|
||||
for (RepairRemind remind : originalList) {
|
||||
Long currentUserId = remind.getUserId();
|
||||
// 如果Map中不存在该userId的记录,或当前记录的创建时间比Map中已有记录更新
|
||||
if (!latestRemindMap.containsKey(currentUserId) ||
|
||||
remind.getCreateTime().compareTo(latestRemindMap.get(currentUserId).getCreateTime()) > 0) {
|
||||
latestRemindMap.put(currentUserId, remind);
|
||||
}
|
||||
}
|
||||
|
||||
// 返回去重后的列表
|
||||
return new ArrayList<>(latestRemindMap.values());
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,13 @@
|
||||
where delete_flag=0 and ext1='1'
|
||||
</select>
|
||||
<select id="selectRepairRemindListByRepairId" resultType="com.ics.admin.domain.RepairRemind">
|
||||
select * from ics_repair_remind where repair_id=#{repairId} and delete_flag=0
|
||||
select * from ics_repair_remind
|
||||
where repair_id = #{repairId}
|
||||
and delete_flag = 0
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<update id="afterWxPush">
|
||||
@ -157,4 +163,16 @@
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据会议ID和用户ID列表查询通知 -->
|
||||
<select id="selectRepairRemindByRepairIdAndUserIds" resultMap="RepairRemindResult">
|
||||
select * from ics_repair_remind
|
||||
where repair_id = #{repairId}
|
||||
and delete_flag = 0
|
||||
and user_id in
|
||||
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user