消息管理

This commit is contained in:
liang.chao 2024-12-23 17:04:21 +08:00
parent 9dce8c3b3d
commit 0f127d5b6a
5 changed files with 69 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType; import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -44,6 +45,13 @@ public class BmMessageController extends BaseController {
List<BmMessage> list = bmMessageService.selectBmMessageListFromCache(bmMessage); List<BmMessage> list = bmMessageService.selectBmMessageListFromCache(bmMessage);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
@ApiOperation(value = "查询消息列表")
//@RequiresPermissions("basic:message:list")
@GetMapping("/listOneToOne")
public AjaxResult listOneToOne(BmMessage bmMessage) throws JsonProcessingException {
List<BmMessage> list = bmMessageService.selectBmMessageListFromCacheOne(bmMessage);
return AjaxResult.success(list);
}
/** /**
* 查询消息列表 * 查询消息列表

View File

@ -2,6 +2,7 @@ package com.bonus.material.basic.service;
import java.util.List; import java.util.List;
import com.bonus.material.basic.domain.BmMessage; import com.bonus.material.basic.domain.BmMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
/** /**
* 消息Service接口 * 消息Service接口
@ -59,4 +60,6 @@ public interface IBmMessageService {
* @return 结果 * @return 结果
*/ */
public int deleteBmMessageById(Long id); public int deleteBmMessageById(Long id);
List<BmMessage> selectBmMessageListFromCacheOne(BmMessage bmMessage) throws JsonProcessingException;
} }

View File

@ -1,21 +1,28 @@
package com.bonus.material.basic.service.impl; package com.bonus.material.basic.service.impl;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONReader;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.SpringUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.redis.service.RedisService; import com.bonus.common.redis.service.RedisService;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysDictData;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.material.basic.mapper.BmMessageMapper; import com.bonus.material.basic.mapper.BmMessageMapper;
import com.bonus.material.basic.domain.BmMessage; import com.bonus.material.basic.domain.BmMessage;
import com.bonus.material.basic.service.IBmMessageService; import com.bonus.material.basic.service.IBmMessageService;
import javax.annotation.Resource; import javax.annotation.Resource;
@Service @Service
@ -28,7 +35,7 @@ public class BmMessageServiceImpl implements IBmMessageService {
/** /**
* 查询消息 * 查询消息
* *
* @param id 消息主键 * @param id 消息主键
* @return 消息 * @return 消息
*/ */
@ -39,7 +46,7 @@ public class BmMessageServiceImpl implements IBmMessageService {
/** /**
* 查询消息列表 * 查询消息列表
* *
* @param bmMessage 消息 * @param bmMessage 消息
* @return 消息 * @return 消息
*/ */
@ -54,14 +61,38 @@ public class BmMessageServiceImpl implements IBmMessageService {
@Override @Override
public List<BmMessage> selectBmMessageListFromCache(BmMessage bmMessage) { public List<BmMessage> selectBmMessageListFromCache(BmMessage bmMessage) {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId(); Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
List<BmMessage> bmMessages = redisService.getCacheList(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + DateUtils.getDate()); Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + "*");
List<BmMessage> result = bmMessages.stream().filter(o -> companyId.equals(o.getFromCompany()) || companyId.equals(o.getToCompany())).collect(Collectors.toList()); List<BmMessage> list = new ArrayList<>();
keys.stream().forEach(t -> {
JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(t);
list.addAll(arrayCache.toList(BmMessage.class));
});
List<BmMessage> result = list.stream().filter(o -> companyId.equals(o.getFromCompany())).collect(Collectors.toList());
Map<Long, BmMessage> groupedMessages = result.stream()
.collect(Collectors.toMap(
BmMessage::getFromCompany,
Function.identity(),
(existing, replacement) -> existing
));
List<BmMessage> messages = new ArrayList<>(groupedMessages.values());
return messages;
}
public List<BmMessage> selectBmMessageListFromCacheOne(BmMessage bmMessage) {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + "*");
List<BmMessage> list = new ArrayList<>();
keys.stream().forEach(t -> {
JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(t);
list.addAll(arrayCache.toList(BmMessage.class));
});
List<BmMessage> result = list.stream().filter(o -> companyId.equals(o.getFromCompany()) && o.getToCompany().equals(bmMessage.getToCompany())).collect(Collectors.toList());
return result; return result;
} }
/** /**
* 新增消息 * 新增消息
* *
* @param bmMessage 消息 * @param bmMessage 消息
* @return 结果 * @return 结果
*/ */
@ -73,9 +104,8 @@ public class BmMessageServiceImpl implements IBmMessageService {
bmMessage.setFromCompany(companyId); bmMessage.setFromCompany(companyId);
bmMessage.setFromUser(SecurityUtils.getLoginUser().getSysUser().getUserId()); bmMessage.setFromUser(SecurityUtils.getLoginUser().getSysUser().getUserId());
bmMessage.setUuid(String.valueOf(UUID.randomUUID())); bmMessage.setUuid(String.valueOf(UUID.randomUUID()));
String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + DateUtils.getDate(); String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + System.currentTimeMillis();
String msgContent = JSONObject.toJSONString(bmMessage); (SpringUtils.getBean(RedisService.class)).setCacheObject(msgKey, Arrays.asList(bmMessage), MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_HOURS, TimeUnit.HOURS);
redisService.setCacheObject(msgKey, msgContent, MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_HOURS, TimeUnit.HOURS);
return bmMessageMapper.insertBmMessage(bmMessage); return bmMessageMapper.insertBmMessage(bmMessage);
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("错误信息描述"); throw new ServiceException("错误信息描述");
@ -84,7 +114,7 @@ public class BmMessageServiceImpl implements IBmMessageService {
/** /**
* 修改消息 * 修改消息
* *
* @param bmMessage 消息 * @param bmMessage 消息
* @return 结果 * @return 结果
*/ */
@ -100,7 +130,7 @@ public class BmMessageServiceImpl implements IBmMessageService {
/** /**
* 批量删除消息 * 批量删除消息
* *
* @param ids 需要删除的消息主键 * @param ids 需要删除的消息主键
* @return 结果 * @return 结果
*/ */
@ -111,7 +141,7 @@ public class BmMessageServiceImpl implements IBmMessageService {
/** /**
* 删除消息信息 * 删除消息信息
* *
* @param id 消息主键 * @param id 消息主键
* @return 结果 * @return 结果
*/ */

View File

@ -23,7 +23,7 @@ public class ReplyController extends BaseController {
private ReplyService replyService; private ReplyService replyService;
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获取公司列表") @ApiOperation("获取快捷回复列表")
public AjaxResult list(BmReply bmReply) { public AjaxResult list(BmReply bmReply) {
startPage(); startPage();
List<BmReply> list = replyService.list(bmReply); List<BmReply> list = replyService.list(bmReply);

View File

@ -17,27 +17,26 @@
<select id="getSafeBookByMaId" resultType="com.bonus.material.device.domain.SafeBookInfo"> <select id="getSafeBookByMaId" resultType="com.bonus.material.device.domain.SafeBookInfo">
SELECT SELECT
sb.*, d.code,
d.device_name,
su.nick_name, su.nick_name,
mdi.device_name, sb.create_time,
mdi.CODE AS deviceCode, sb.update_time
bfi.url
FROM FROM
safe_book sb ma_dev_info d
LEFT JOIN ma_dev_info mdi ON sb.ma_id = mdi.ma_id LEFT JOIN sys_user su ON d.own_id = su.user_id
LEFT JOIN bm_file_info bfi ON bfi.model_id = sb.ma_id LEFT JOIN safe_book sb ON d.ma_id = sb.ma_id
LEFT JOIN sys_user su on sb.upload_person = su.user_id
WHERE WHERE
bfi.task_type = 17 d.own_co = #{uploadCom}
AND bfi.file_type = 5 and d.ma_status != 0
AND sb.upload_com = #{uploadCom} AND d.is_active = '1'
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and mdi.code like concat('%',#{code},'%') and d.code like concat('%',#{code},'%')
</if> </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND sb.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59') AND sb.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if> </if>
order by create_time desc order by sb.update_time desc
</select> </select>
<select id="selectTaskNumByMonth" resultType="java.lang.String"> <select id="selectTaskNumByMonth" resultType="java.lang.String">